* [PATCH] drm/mediatek: dsi: fix error codes in mtk_dsi_host_transfer()
@ 2023-02-27 10:08 Dan Carpenter
2023-03-01 9:53 ` Mattijs Korpershoek
2023-03-01 9:58 ` AngeloGioacchino Del Regno
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-02-27 10:08 UTC (permalink / raw)
To: Julien STEPHAN
Cc: Philipp Zabel, David Airlie, Daniel Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Mattijs Korpershoek, dri-devel,
linux-mediatek, kernel-janitors
There is a type bug because the return statement:
return ret < 0 ? ret : recv_cnt;
will not return negatives on 64bit systems. The problem is that the
function returns ssize_t types, while "ret" is int and "recv_cnt" is a
u32. The negative values are type promoted to u32 and returned as
positive values instead of negative error codes.
Fixes: 81cc7e51c4f1 ("drm/mediatek: Allow commands to be sent during video mode")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
drivers/gpu/drm/mediatek/mtk_dsi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 7d5250351193..8e99981ca0e1 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -1016,12 +1016,12 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
const struct mipi_dsi_msg *msg)
{
struct mtk_dsi *dsi = host_to_dsi(host);
- u32 recv_cnt, i;
+ ssize_t recv_cnt;
u8 read_data[16];
void *src_addr;
u8 irq_flag = CMD_DONE_INT_FLAG;
u32 dsi_mode;
- int ret;
+ int ret, i;
dsi_mode = readl(dsi->regs + DSI_MODE_CTRL);
if (dsi_mode & MODE) {
@@ -1070,7 +1070,7 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
if (recv_cnt)
memcpy(msg->rx_buf, src_addr, recv_cnt);
- DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n",
+ DRM_INFO("dsi get %zd byte data from the panel address(0x%x)\n",
recv_cnt, *((u8 *)(msg->tx_buf)));
restore_dsi_mode:
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] drm/mediatek: dsi: fix error codes in mtk_dsi_host_transfer()
2023-02-27 10:08 [PATCH] drm/mediatek: dsi: fix error codes in mtk_dsi_host_transfer() Dan Carpenter
@ 2023-03-01 9:53 ` Mattijs Korpershoek
2023-03-01 9:58 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 3+ messages in thread
From: Mattijs Korpershoek @ 2023-03-01 9:53 UTC (permalink / raw)
To: Dan Carpenter, Julien STEPHAN
Cc: Philipp Zabel, David Airlie, Daniel Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, dri-devel, linux-mediatek,
kernel-janitors
Dear Dan,
Thank you for your patch.
On lun., févr. 27, 2023 at 13:08, Dan Carpenter <error27@gmail.com> wrote:
> There is a type bug because the return statement:
>
> return ret < 0 ? ret : recv_cnt;
>
> will not return negatives on 64bit systems. The problem is that the
> function returns ssize_t types, while "ret" is int and "recv_cnt" is a
> u32. The negative values are type promoted to u32 and returned as
> positive values instead of negative error codes.
>
> Fixes: 81cc7e51c4f1 ("drm/mediatek: Allow commands to be sent during video mode")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> ---
> drivers/gpu/drm/mediatek/mtk_dsi.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index 7d5250351193..8e99981ca0e1 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -1016,12 +1016,12 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
> const struct mipi_dsi_msg *msg)
> {
> struct mtk_dsi *dsi = host_to_dsi(host);
> - u32 recv_cnt, i;
> + ssize_t recv_cnt;
> u8 read_data[16];
> void *src_addr;
> u8 irq_flag = CMD_DONE_INT_FLAG;
> u32 dsi_mode;
> - int ret;
> + int ret, i;
>
> dsi_mode = readl(dsi->regs + DSI_MODE_CTRL);
> if (dsi_mode & MODE) {
> @@ -1070,7 +1070,7 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
> if (recv_cnt)
> memcpy(msg->rx_buf, src_addr, recv_cnt);
>
> - DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n",
> + DRM_INFO("dsi get %zd byte data from the panel address(0x%x)\n",
> recv_cnt, *((u8 *)(msg->tx_buf)));
>
> restore_dsi_mode:
> --
> 2.39.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] drm/mediatek: dsi: fix error codes in mtk_dsi_host_transfer()
2023-02-27 10:08 [PATCH] drm/mediatek: dsi: fix error codes in mtk_dsi_host_transfer() Dan Carpenter
2023-03-01 9:53 ` Mattijs Korpershoek
@ 2023-03-01 9:58 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-03-01 9:58 UTC (permalink / raw)
To: Dan Carpenter, Julien STEPHAN
Cc: Philipp Zabel, David Airlie, Daniel Vetter, Matthias Brugger,
Mattijs Korpershoek, dri-devel, linux-mediatek, kernel-janitors
Il 27/02/23 11:08, Dan Carpenter ha scritto:
> There is a type bug because the return statement:
>
> return ret < 0 ? ret : recv_cnt;
>
> will not return negatives on 64bit systems. The problem is that the
> function returns ssize_t types, while "ret" is int and "recv_cnt" is a
> u32. The negative values are type promoted to u32 and returned as
> positive values instead of negative error codes.
>
> Fixes: 81cc7e51c4f1 ("drm/mediatek: Allow commands to be sent during video mode")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-01 10:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-27 10:08 [PATCH] drm/mediatek: dsi: fix error codes in mtk_dsi_host_transfer() Dan Carpenter
2023-03-01 9:53 ` Mattijs Korpershoek
2023-03-01 9:58 ` AngeloGioacchino Del Regno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox