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: 9144379928 ("drm/bridge: nxp-ptn3460: fix i2c_master_send() error checking")
Suggested-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Robert Foss <rfoss@kernel.org>
Signed-off-by: Robert Foss <rfoss@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/04242630-42d8-4920-8c67-24ac9db6b3c9@moroto.mountain
This commit is contained in:
Dan Carpenter 2023-12-06 18:05:15 +03:00 committed by Robert Foss
parent 4b83b783ad
commit 28d3d06966
No known key found for this signature in database
GPG key ID: 3EFD900F76D1D784

View file

@ -54,15 +54,15 @@ static int ptn3460_read_bytes(struct ptn3460_bridge *ptn_bridge, char addr,
int ret;
ret = i2c_master_send(ptn_bridge->client, &addr, 1);
if (ret <= 0) {
if (ret < 0) {
DRM_ERROR("Failed to send i2c command, ret=%d\n", ret);
return ret ?: -EIO;
return ret;
}
ret = i2c_master_recv(ptn_bridge->client, buf, len);
if (ret != len) {
if (ret < 0) {
DRM_ERROR("Failed to recv i2c data, ret=%d\n", ret);
return ret < 0 ? ret : -EIO;
return ret;
}
return 0;
@ -78,9 +78,9 @@ static int ptn3460_write_byte(struct ptn3460_bridge *ptn_bridge, char addr,
buf[1] = val;
ret = i2c_master_send(ptn_bridge->client, buf, ARRAY_SIZE(buf));
if (ret != ARRAY_SIZE(buf)) {
if (ret < 0) {
DRM_ERROR("Failed to send i2c command, ret=%d\n", ret);
return ret < 0 ? ret : -EIO;
return ret;
}
return 0;