Skip to content

Commit 28d3d06

Browse files
Dan Carpenterrobertfoss
authored andcommitted
drm/bridge: nxp-ptn3460: simplify some error checking
The i2c_master_send/recv() functions return negative error codes or they return "len" on success. So the error handling here can be written as just normal checks for "if (ret < 0) return ret;". No need to complicate things. Btw, in this code the "len" parameter can never be zero, but even if it were, then I feel like this would still be the best way to write it. Fixes: 9144379 ("drm/bridge: nxp-ptn3460: fix i2c_master_send() error checking") Suggested-by: Neil Armstrong <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Robert Foss <[email protected]> Signed-off-by: Robert Foss <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 4b83b78 commit 28d3d06

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/gpu/drm/bridge/nxp-ptn3460.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ static int ptn3460_read_bytes(struct ptn3460_bridge *ptn_bridge, char addr,
5454
int ret;
5555

5656
ret = i2c_master_send(ptn_bridge->client, &addr, 1);
57-
if (ret <= 0) {
57+
if (ret < 0) {
5858
DRM_ERROR("Failed to send i2c command, ret=%d\n", ret);
59-
return ret ?: -EIO;
59+
return ret;
6060
}
6161

6262
ret = i2c_master_recv(ptn_bridge->client, buf, len);
63-
if (ret != len) {
63+
if (ret < 0) {
6464
DRM_ERROR("Failed to recv i2c data, ret=%d\n", ret);
65-
return ret < 0 ? ret : -EIO;
65+
return ret;
6666
}
6767

6868
return 0;
@@ -78,9 +78,9 @@ static int ptn3460_write_byte(struct ptn3460_bridge *ptn_bridge, char addr,
7878
buf[1] = val;
7979

8080
ret = i2c_master_send(ptn_bridge->client, buf, ARRAY_SIZE(buf));
81-
if (ret != ARRAY_SIZE(buf)) {
81+
if (ret < 0) {
8282
DRM_ERROR("Failed to send i2c command, ret=%d\n", ret);
83-
return ret < 0 ? ret : -EIO;
83+
return ret;
8484
}
8585

8686
return 0;

0 commit comments

Comments
 (0)