diff options
| author | Francesco Dolcini <francesco.dolcini@toradex.com> | 2023-11-28 20:49:35 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-12-13 18:39:20 +0100 |
| commit | f5e6958919e0d70e3be8c30dfafae02ee16cfbf0 (patch) | |
| tree | 1378b241b4266d042886375035e7441711b3c337 /drivers/platform | |
| parent | bcd50a3bd637cece5303d4824485b89ce5c9871a (diff) | |
| download | linux-f5e6958919e0d70e3be8c30dfafae02ee16cfbf0.tar.gz linux-f5e6958919e0d70e3be8c30dfafae02ee16cfbf0.tar.bz2 linux-f5e6958919e0d70e3be8c30dfafae02ee16cfbf0.zip | |
platform/surface: aggregator: fix recv_buf() return value
commit c8820c92caf0770bec976b01fa9e82bb993c5865 upstream.
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().
Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")
Cc: stable@vger.kernel.org
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20231128194935.11350-1-francesco@dolcini.it
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/platform')
| -rw-r--r-- | drivers/platform/surface/aggregator/core.c | 5 |
1 files changed, 4 insertions, 1 deletions
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) |
