drm/bridge/synopsys: dsi: readl_poll_timeout return value clean up
Subsystems (4)
PATCH 1/1 drm/bridge/synopsys: dsi: readl_poll_timeout return value clean up
The readl_poll_timeout() return value is 0 in case of success so it is better to detect errors without taking care of the return value sign.
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +5 -5
@@ -342,7 +342,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val) ret =readl_poll_timeout (dsi->base +DSI_CMD_PKT_STATUS , val, !(val &GEN_CMD_FULL ),1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to get available command FIFO\n" );return ret; }
@@ -353,7 +353,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val) ret =readl_poll_timeout (dsi->base +DSI_CMD_PKT_STATUS , val, (val & mask) == mask,1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to write command FIFO\n" );return ret; }
@@ -385,7 +385,7 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi, ret =readl_poll_timeout (dsi->base +DSI_CMD_PKT_STATUS , val, !(val &GEN_PLD_W_FULL ),1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to get available write payload FIFO\n" );return ret;
@@ -716,13 +716,13 @@ static void dw_mipi_dsi_dphy_enable(struct dw_mipi_dsi *dsi) ret =readl_poll_timeout (dsi->base +DSI_PHY_STATUS , val, val &PHY_LOCK ,1000 ,PHY_STATUS_TIMEOUT_US ); -if (ret <0 ) +if (ret)DRM_DEBUG_DRIVER ("failed to wait phy lock state\n" ); ret =readl_poll_timeout (dsi->base +DSI_PHY_STATUS , val, val &PHY_STOP_STATE_CLK_LANE ,1000 ,PHY_STATUS_TIMEOUT_US ); -if (ret <0 ) +if (ret)DRM_DEBUG_DRIVER ("failed to wait phy clk lane stop state\n" ); }
Signature · 1 line
2.15.1
Hi Archit, Andrzej & Laurent,
May I ask you please your feedback on this small patch? Many thanks,
Philippe :-)
Quoted 57 lines · Philippe Cornu
The
readl_poll_timeout()return value is 0 in case of success so it is better to detect errors without taking care of the return value sign.Signed-off-by Philippe Cornu <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +5
-5@@ -342,7 +342,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val) ret =readl_poll_timeout (dsi->base +DSI_CMD_PKT_STATUS , val, !(val &GEN_CMD_FULL ),1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to get available command FIFO\n" );return ret; }@@ -353,7 +353,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val) ret =readl_poll_timeout (dsi->base +DSI_CMD_PKT_STATUS , val, (val & mask) == mask,1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to write command FIFO\n" );return ret; }@@ -385,7 +385,7 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi, ret =readl_poll_timeout (dsi->base +DSI_CMD_PKT_STATUS , val, !(val &GEN_PLD_W_FULL ),1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to get available write payload FIFO\n" );return ret;@@ -716,13 +716,13 @@ static void dw_mipi_dsi_dphy_enable(struct dw_mipi_dsi *dsi) ret =readl_poll_timeout (dsi->base +DSI_PHY_STATUS , val, val &PHY_LOCK ,1000 ,PHY_STATUS_TIMEOUT_US ); -if (ret <0 ) +if (ret)DRM_DEBUG_DRIVER ("failed to wait phy lock state\n" ); ret =readl_poll_timeout (dsi->base +DSI_PHY_STATUS , val, val &PHY_STOP_STATE_CLK_LANE ,1000 ,PHY_STATUS_TIMEOUT_US ); -if (ret <0 ) +if (ret)DRM_DEBUG_DRIVER ("failed to wait phy clk lane stop state\n" ); }
Andrzej Hajda
Reviewed-byQuoted 13 lines · Philippe CORNU
Hi Archit, Andrzej & Laurent,
May I ask you please your feedback on this small patch? Many thanks,
Philippe :-)
Quoted 5 lines · Philippe Cornu
The
readl_poll_timeout()return value is 0 in case of success so it is better to detect errors without taking care of the return value sign.Signed-off-by Philippe Cornu <[email protected]>
The patch is of course correct. However I am not sure if necessary. For sure functionally it does not change anything.
AFAIK kernel CodingStyle says nothing about it, so I suppose it is matter of personal taste.
Anyway I can give it:
?--
Regards
Andrzej
Quoted 51 lines
Quoted 51 lines
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +5
-5@@ -342,7 +342,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val) ret =DSI_CMD_PKT_STATUS , val, !(val &GEN_CMD_FULL ),1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to get available command FIFO\n" );return ret; }@@ -353,7 +353,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val) ret =readl_poll_timeout (dsi->base +DSI_CMD_PKT_STATUS , val, (val & mask) == mask,1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to write command FIFO\n" );return ret; }@@ -385,7 +385,7 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi, ret =readl_poll_timeout (dsi->base +DSI_CMD_PKT_STATUS , val, !(val &GEN_PLD_W_FULL ),1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to get available write payload FIFO\n" );return ret;@@ -716,13 +716,13 @@ static void dw_mipi_dsi_dphy_enable(struct dw_mipi_dsi *dsi) ret =readl_poll_timeout (dsi->base +DSI_PHY_STATUS , val, val &PHY_LOCK ,1000 ,PHY_STATUS_TIMEOUT_US ); -if (ret <0 ) +if (ret)DRM_DEBUG_DRIVER ("failed to wait phy lock state\n" ); ret =readl_poll_timeout (dsi->base +DSI_PHY_STATUS , val, val &PHY_STOP_STATE_CLK_LANE ,1000 ,PHY_STATUS_TIMEOUT_US ); -if (ret <0 ) +if (ret)DRM_DEBUG_DRIVER ("failed to wait phy clk lane stop state\n" ); }
Hi Andrzej,
Quoted 13 lines · Andrzej Hajda
Quoted 12 lines · Philippe CORNU
Hi Archit, Andrzej & Laurent,
May I ask you please your feedback on this small patch? Many thanks,
Philippe :-)
Quoted 4 lines · Philippe Cornu
The
readl_poll_timeout()return value is 0 in case of success so it is better to detect errors without taking care of the return value sign.
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Philippe Cornu <[email protected]>The patch is of course correct. However I am not sure if necessary. For sure functionally it does not change anything.
AFAIK kernel CodingStyle says nothing about it, so I suppose it is matter of personal taste.
I sent this tiny patch in order to homogenize the dw mipi driver because there were both cases "if (ret)" & "if (ret < 0)" in the source code.
I did not really find a preferred way in the kernel source code so I selected what sounds the best to me ie "if (ret)" but it is not a problem to make another patch for "if (ret < 0)" everywhere :-)
In any case, the most important from my pov is to have a homogeneous source code :-)
Does anyone have a preferred choice between "if (ret)" & "if (ret < 0)" after a "ret = readl_poll_timeout()"?
Quoted 2 lines
Anyway I can give it:
Reviewed-by Andrzej Hajda <[email protected]>
Many thanks,
Philippe :)
Quoted 58 lines
?--
Regards
AndrzejQuoted 51 lines
Quoted 51 lines
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +5
-5@@ -342,7 +342,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val) ret =DSI_CMD_PKT_STATUS , val, !(val &GEN_CMD_FULL ),1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to get available command FIFO\n" );return ret; }@@ -353,7 +353,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val) ret =readl_poll_timeout (dsi->base +DSI_CMD_PKT_STATUS , val, (val & mask) == mask,1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to write command FIFO\n" );return ret; }@@ -385,7 +385,7 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi, ret =readl_poll_timeout (dsi->base +DSI_CMD_PKT_STATUS , val, !(val &GEN_PLD_W_FULL ),1000 ,CMD_PKT_STATUS_TIMEOUT_US ); -if (ret <0 ) { +if (ret) {dev_err (dsi->dev,"failed to get available write payload FIFO\n" );return ret;@@ -716,13 +716,13 @@ static void dw_mipi_dsi_dphy_enable(struct dw_mipi_dsi *dsi) ret =readl_poll_timeout (dsi->base +DSI_PHY_STATUS , val, val &PHY_LOCK ,1000 ,PHY_STATUS_TIMEOUT_US ); -if (ret <0 ) +if (ret)DRM_DEBUG_DRIVER ("failed to wait phy lock state\n" ); ret =readl_poll_timeout (dsi->base +DSI_PHY_STATUS , val, val &PHY_STOP_STATE_CLK_LANE ,1000 ,PHY_STATUS_TIMEOUT_US ); -if (ret <0 ) +if (ret)DRM_DEBUG_DRIVER ("failed to wait phy clk lane stop state\n" ); }
Andrzej Hajda
AppliedQuoted 25 lines · Philippe CORNU
Hi Andrzej,
Quoted 13 lines · Andrzej Hajda
Quoted 12 lines · Philippe CORNU
Hi Archit, Andrzej & Laurent,
May I ask you please your feedback on this small patch? Many thanks,
Philippe :-)
Quoted 4 lines · Philippe Cornu
The
readl_poll_timeout()return value is 0 in case of success so it is better to detect errors without taking care of the return value sign.Quoted 5 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Philippe Cornu <[email protected]>The patch is of course correct. However I am not sure if necessary. For sure functionally it does not change anything.
AFAIK kernel CodingStyle says nothing about it, so I suppose it is matter of personal taste.I sent this tiny patch in order to homogenize the dw mipi driver because there were both cases "if (ret)" & "if (ret < 0)" in the source code.
Quoted 6 lines
I did not really find a preferred way in the kernel source code so I selected what sounds the best to me ie "if (ret)" but it is not a problem to make another patch for "if (ret < 0)" everywhere :-)
In any case, the most important from my pov is to have a homogeneous source code :-)
OK
Queued to drm-misc-next.
Regards
Andrzej