* [bug report] iio:temperature: Add MAX31856 thermocouple support
@ 2019-04-09 11:59 Dan Carpenter
2019-04-14 12:47 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-04-09 11:59 UTC (permalink / raw)
To: paresh.chaudhary; +Cc: linux-iio
Hello Paresh Chaudhary,
The patch fb55a51310d1: "iio:temperature: Add MAX31856 thermocouple
support" from Mar 26, 2019, leads to the following static checker
warning:
drivers/iio/temperature/max31856.c:215 max31856_read_raw()
error: uninitialized symbol 'ret'.
drivers/iio/temperature/max31856.c
185 static int max31856_read_raw(struct iio_dev *indio_dev,
186 struct iio_chan_spec const *chan,
187 int *val, int *val2, long mask)
188 {
189 struct max31856_data *data = iio_priv(indio_dev);
190 int ret;
191
192 switch (mask) {
193 case IIO_CHAN_INFO_RAW:
194 ret = max31856_thermocouple_read(data, chan, val);
195 if (ret)
196 return ret;
197 return IIO_VAL_INT;
198 case IIO_CHAN_INFO_SCALE:
199 switch (chan->channel2) {
200 case IIO_MOD_TEMP_AMBIENT:
201 /* Cold junction Temp. Data resolution is 0.015625 */
202 *val = 15;
203 *val2 = 625000; /* 1000 * 0.015625 */
204 ret = IIO_VAL_INT_PLUS_MICRO;
205 break;
206 default:
207 /* Thermocouple Temp. Data resolution is 0.0078125 */
208 *val = 7;
209 *val2 = 812500; /* 1000 * 0.0078125) */
210 return IIO_VAL_INT_PLUS_MICRO;
211 }
212 break;
Smatch thinks mask can also IIO_CHAN_INFO_PROCESSED, IIO_CHAN_INFO_OFFSET,
and IIO_CHAN_INFO_AVERAGE_RAW. It often gets these function pointer
calls a be merged together though.
213 }
214
--> 215 return ret;
216 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] iio:temperature: Add MAX31856 thermocouple support
2019-04-09 11:59 [bug report] iio:temperature: Add MAX31856 thermocouple support Dan Carpenter
@ 2019-04-14 12:47 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-04-14 12:47 UTC (permalink / raw)
To: Dan Carpenter; +Cc: paresh.chaudhary, linux-iio
On Tue, 9 Apr 2019 14:59:55 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Hello Paresh Chaudhary,
>
> The patch fb55a51310d1: "iio:temperature: Add MAX31856 thermocouple
> support" from Mar 26, 2019, leads to the following static checker
> warning:
>
> drivers/iio/temperature/max31856.c:215 max31856_read_raw()
> error: uninitialized symbol 'ret'.
>
> drivers/iio/temperature/max31856.c
> 185 static int max31856_read_raw(struct iio_dev *indio_dev,
> 186 struct iio_chan_spec const *chan,
> 187 int *val, int *val2, long mask)
> 188 {
> 189 struct max31856_data *data = iio_priv(indio_dev);
> 190 int ret;
> 191
> 192 switch (mask) {
> 193 case IIO_CHAN_INFO_RAW:
> 194 ret = max31856_thermocouple_read(data, chan, val);
> 195 if (ret)
> 196 return ret;
> 197 return IIO_VAL_INT;
> 198 case IIO_CHAN_INFO_SCALE:
> 199 switch (chan->channel2) {
> 200 case IIO_MOD_TEMP_AMBIENT:
> 201 /* Cold junction Temp. Data resolution is 0.015625 */
> 202 *val = 15;
> 203 *val2 = 625000; /* 1000 * 0.015625 */
> 204 ret = IIO_VAL_INT_PLUS_MICRO;
> 205 break;
> 206 default:
> 207 /* Thermocouple Temp. Data resolution is 0.0078125 */
> 208 *val = 7;
> 209 *val2 = 812500; /* 1000 * 0.0078125) */
> 210 return IIO_VAL_INT_PLUS_MICRO;
> 211 }
> 212 break;
>
> Smatch thinks mask can also IIO_CHAN_INFO_PROCESSED, IIO_CHAN_INFO_OFFSET,
> and IIO_CHAN_INFO_AVERAGE_RAW. It often gets these function pointer
> calls a be merged together though.
>
> 213 }
> 214
> --> 215 return ret;
> 216 }
>
> regards,
> dan carpenter
Colin sent out a fix for this which does what is being suggested here.
I'll apply that.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-14 12:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-09 11:59 [bug report] iio:temperature: Add MAX31856 thermocouple support Dan Carpenter
2019-04-14 12:47 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).