Skip to content

Commit c8820c9

Browse files
dolciniij-intel
authored andcommitted
platform/surface: aggregator: fix recv_buf() return value
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: c167b9c ("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>
1 parent e0894ff commit c8820c9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • drivers/platform/surface/aggregator

drivers/platform/surface/aggregator/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,12 @@ static int ssam_receive_buf(struct serdev_device *dev, const unsigned char *buf,
231231
size_t n)
232232
{
233233
struct ssam_controller *ctrl;
234+
int ret;
234235

235236
ctrl = serdev_device_get_drvdata(dev);
236-
return ssam_controller_receive_buf(ctrl, buf, n);
237+
ret = ssam_controller_receive_buf(ctrl, buf, n);
238+
239+
return ret < 0 ? 0 : ret;
237240
}
238241

239242
static void ssam_write_wakeup(struct serdev_device *dev)

0 commit comments

Comments
 (0)