Skip to content

Commit ad01032

Browse files
Jacopo Mondimchehab
authored andcommitted
media: i2c: max9271: Check max9271_write() return
Check the return value of the max9271_write() function in the max9271 library driver. While at it, modify an existing condition to be made identical to other checks. Signed-off-by: Jacopo Mondi <[email protected]> Reviewed-by: Kieran Bingham <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 4ff5278 commit ad01032

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

drivers/media/i2c/max9271.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ int max9271_set_serial_link(struct max9271_device *dev, bool enable)
106106
* Short delays here appear to show bit-errors in the writes following.
107107
* Therefore a conservative delay seems best here.
108108
*/
109-
max9271_write(dev, 0x04, val);
109+
ret = max9271_write(dev, 0x04, val);
110+
if (ret < 0)
111+
return ret;
112+
110113
usleep_range(5000, 8000);
111114

112115
return 0;
@@ -118,7 +121,7 @@ int max9271_configure_i2c(struct max9271_device *dev, u8 i2c_config)
118121
int ret;
119122

120123
ret = max9271_write(dev, 0x0d, i2c_config);
121-
if (ret)
124+
if (ret < 0)
122125
return ret;
123126

124127
/* The delay required after an I2C bus configuration change is not
@@ -143,7 +146,10 @@ int max9271_set_high_threshold(struct max9271_device *dev, bool enable)
143146
* Enable or disable reverse channel high threshold to increase
144147
* immunity to power supply noise.
145148
*/
146-
max9271_write(dev, 0x08, enable ? ret | BIT(0) : ret & ~BIT(0));
149+
ret = max9271_write(dev, 0x08, enable ? ret | BIT(0) : ret & ~BIT(0));
150+
if (ret < 0)
151+
return ret;
152+
147153
usleep_range(2000, 2500);
148154

149155
return 0;
@@ -152,6 +158,8 @@ EXPORT_SYMBOL_GPL(max9271_set_high_threshold);
152158

153159
int max9271_configure_gmsl_link(struct max9271_device *dev)
154160
{
161+
int ret;
162+
155163
/*
156164
* Configure the GMSL link:
157165
*
@@ -162,16 +170,24 @@ int max9271_configure_gmsl_link(struct max9271_device *dev)
162170
*
163171
* TODO: Make the GMSL link configuration parametric.
164172
*/
165-
max9271_write(dev, 0x07, MAX9271_DBL | MAX9271_HVEN |
166-
MAX9271_EDC_1BIT_PARITY);
173+
ret = max9271_write(dev, 0x07, MAX9271_DBL | MAX9271_HVEN |
174+
MAX9271_EDC_1BIT_PARITY);
175+
if (ret < 0)
176+
return ret;
177+
167178
usleep_range(5000, 8000);
168179

169180
/*
170181
* Adjust spread spectrum to +4% and auto-detect pixel clock
171182
* and serial link rate.
172183
*/
173-
max9271_write(dev, 0x02, MAX9271_SPREAD_SPECT_4 | MAX9271_R02_RES |
174-
MAX9271_PCLK_AUTODETECT | MAX9271_SERIAL_AUTODETECT);
184+
ret = max9271_write(dev, 0x02,
185+
MAX9271_SPREAD_SPECT_4 | MAX9271_R02_RES |
186+
MAX9271_PCLK_AUTODETECT |
187+
MAX9271_SERIAL_AUTODETECT);
188+
if (ret < 0)
189+
return ret;
190+
175191
usleep_range(5000, 8000);
176192

177193
return 0;

0 commit comments

Comments
 (0)