* [PATCH v1] platform/surface: aggregator: fix recv_buf() return value
@ 2023-11-28 19:49 Francesco Dolcini
2023-11-28 20:13 ` Maximilian Luz
2023-11-29 11:21 ` Ilpo Järvinen
0 siblings, 2 replies; 3+ messages in thread
From: Francesco Dolcini @ 2023-11-28 19:49 UTC (permalink / raw)
To: Maximilian Luz, Hans de Goede, Ilpo Järvinen, Mark Gross
Cc: Francesco Dolcini, platform-driver-x86, linux-kernel, stable
From: Francesco Dolcini <francesco.dolcini@toradex.com>
Serdev recv_buf() callback is supposed to return the amount of bytes
consumed, therefore an int in between 0 and count.
Do not return negative number in case of issue, when
ssam_controller_receive_buf() returns ESHUTDOWN just returns 0, e.g. no
bytes consumed, this keep the exact same behavior as it was before.
This fixes a potential WARN in serdev-ttyport.c:ttyport_receive_buf().
Cc: <stable@vger.kernel.org>
Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
---
drivers/platform/surface/aggregator/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/surface/aggregator/core.c b/drivers/platform/surface/aggregator/core.c
index 1a6373dea109..6152be38398c 100644
--- a/drivers/platform/surface/aggregator/core.c
+++ b/drivers/platform/surface/aggregator/core.c
@@ -231,9 +231,12 @@ static int ssam_receive_buf(struct serdev_device *dev, const unsigned char *buf,
size_t n)
{
struct ssam_controller *ctrl;
+ int ret;
ctrl = serdev_device_get_drvdata(dev);
- return ssam_controller_receive_buf(ctrl, buf, n);
+ ret = ssam_controller_receive_buf(ctrl, buf, n);
+
+ return ret < 0 ? 0 : ret;
}
static void ssam_write_wakeup(struct serdev_device *dev)
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1] platform/surface: aggregator: fix recv_buf() return value
2023-11-28 19:49 [PATCH v1] platform/surface: aggregator: fix recv_buf() return value Francesco Dolcini
@ 2023-11-28 20:13 ` Maximilian Luz
2023-11-29 11:21 ` Ilpo Järvinen
1 sibling, 0 replies; 3+ messages in thread
From: Maximilian Luz @ 2023-11-28 20:13 UTC (permalink / raw)
To: Francesco Dolcini, Hans de Goede, Ilpo Järvinen, Mark Gross
Cc: Francesco Dolcini, platform-driver-x86, linux-kernel, stable
On 11/28/23 20:49, Francesco Dolcini wrote:
> From: Francesco Dolcini <francesco.dolcini@toradex.com>
>
> Serdev recv_buf() callback is supposed to return the amount of bytes
> consumed, therefore an int in between 0 and count.
>
> Do not return negative number in case of issue, when
> ssam_controller_receive_buf() returns ESHUTDOWN just returns 0, e.g. no
> bytes consumed, this keep the exact same behavior as it was before.
>
> This fixes a potential WARN in serdev-ttyport.c:ttyport_receive_buf().
>
> Cc: <stable@vger.kernel.org>
> Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")
> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Thanks! Looks good to me.
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
> ---
> drivers/platform/surface/aggregator/core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/surface/aggregator/core.c b/drivers/platform/surface/aggregator/core.c
> index 1a6373dea109..6152be38398c 100644
> --- a/drivers/platform/surface/aggregator/core.c
> +++ b/drivers/platform/surface/aggregator/core.c
> @@ -231,9 +231,12 @@ static int ssam_receive_buf(struct serdev_device *dev, const unsigned char *buf,
> size_t n)
> {
> struct ssam_controller *ctrl;
> + int ret;
>
> ctrl = serdev_device_get_drvdata(dev);
> - return ssam_controller_receive_buf(ctrl, buf, n);
> + ret = ssam_controller_receive_buf(ctrl, buf, n);
> +
> + return ret < 0 ? 0 : ret;
> }
>
> static void ssam_write_wakeup(struct serdev_device *dev)
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1] platform/surface: aggregator: fix recv_buf() return value
2023-11-28 19:49 [PATCH v1] platform/surface: aggregator: fix recv_buf() return value Francesco Dolcini
2023-11-28 20:13 ` Maximilian Luz
@ 2023-11-29 11:21 ` Ilpo Järvinen
1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2023-11-29 11:21 UTC (permalink / raw)
To: Maximilian Luz, Hans de Goede, Mark Gross, Francesco Dolcini
Cc: Francesco Dolcini, platform-driver-x86, linux-kernel, stable
On Tue, 28 Nov 2023 20:49:35 +0100, Francesco Dolcini wrote:
> Serdev recv_buf() callback is supposed to return the amount of bytes
> consumed, therefore an int in between 0 and count.
>
> Do not return negative number in case of issue, when
> ssam_controller_receive_buf() returns ESHUTDOWN just returns 0, e.g. no
> bytes consumed, this keep the exact same behavior as it was before.
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo branch. Note it will show up in the public
platform-drivers-x86/review-ilpo branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/1] platform/surface: aggregator: fix recv_buf() return value
commit: c8820c92caf0770bec976b01fa9e82bb993c5865
--
i.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-29 11:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-28 19:49 [PATCH v1] platform/surface: aggregator: fix recv_buf() return value Francesco Dolcini
2023-11-28 20:13 ` Maximilian Luz
2023-11-29 11:21 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®