* [bug report] iio: light: introduce si1133
@ 2018-07-31 18:11 Dan Carpenter
2018-07-31 18:40 ` Maxime Roussin-Belanger
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2018-07-31 18:11 UTC (permalink / raw)
To: maxime.roussinbelanger; +Cc: linux-iio
Hello Maxime Roussin-Bélanger,
The patch e01e7eaf37d8: "iio: light: introduce si1133" from Jul 19,
2018, leads to the following static checker warning:
drivers/iio/light/si1133.c:428 si1133_command()
error: uninitialized symbol 'resp'.
drivers/iio/light/si1133.c
384 static int si1133_command(struct si1133_data *data, u8 cmd)
385 {
386 struct device *dev = &data->client->dev;
387 u32 resp;
^^^^^^^^
388 int err;
389 int expected_seq;
390
391 mutex_lock(&data->mutex);
392
393 expected_seq = (data->rsp_seq + 1) & SI1133_MAX_CMD_CTR;
394
395 if (cmd == SI1133_CMD_FORCE)
396 reinit_completion(&data->completion);
397
398 err = regmap_write(data->regmap, SI1133_REG_COMMAND, cmd);
399 if (err) {
400 dev_warn(dev, "Failed to write command %#02hhx, ret=%d\n", cmd,
401 err);
402 goto out;
403 }
404
405 if (cmd == SI1133_CMD_FORCE) {
406 /* wait for irq */
407 if (!wait_for_completion_timeout(&data->completion,
408 msecs_to_jiffies(SI1133_COMPLETION_TIMEOUT_MS))) {
409 err = -ETIMEDOUT;
410 goto out;
411 }
Assume "cmd == SI1133_CMD_FORCE" and we don't timeout, then "resp" isn't
initialized.
412 } else {
413 err = regmap_read_poll_timeout(data->regmap,
414 SI1133_REG_RESPONSE0, resp,
415 (resp & SI1133_CMD_SEQ_MASK) ==
416 expected_seq ||
417 (resp & SI1133_CMD_ERR_MASK),
418 SI1133_CMD_MINSLEEP_US_LOW,
419 SI1133_CMD_TIMEOUT_MS * 1000);
420 if (err) {
421 dev_warn(dev,
422 "Failed to read command %#02hhx, ret=%d\n",
423 cmd, err);
424 goto out;
425 }
426 }
427
428 if (resp & SI1133_CMD_ERR_MASK) {
^^^^^^^^^^^^^^^^^^^^^^^^^^
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] iio: light: introduce si1133
2018-07-31 18:11 [bug report] iio: light: introduce si1133 Dan Carpenter
@ 2018-07-31 18:40 ` Maxime Roussin-Belanger
2018-07-31 19:06 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Maxime Roussin-Belanger @ 2018-07-31 18:40 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-iio
First time receiving a bug report, just to be sure... I only need to submit
a PATCH right?
Do I need to put you as a CC for the patch?
Thanks,
Max
On Tue, Jul 31, 2018 at 09:11:49PM +0300, Dan Carpenter wrote:
> Hello Maxime Roussin-Bélanger,
>
> The patch e01e7eaf37d8: "iio: light: introduce si1133" from Jul 19,
> 2018, leads to the following static checker warning:
>
> drivers/iio/light/si1133.c:428 si1133_command()
> error: uninitialized symbol 'resp'.
>
> drivers/iio/light/si1133.c
> 384 static int si1133_command(struct si1133_data *data, u8 cmd)
> 385 {
> 386 struct device *dev = &data->client->dev;
> 387 u32 resp;
> ^^^^^^^^
> 388 int err;
> 389 int expected_seq;
> 390
> 391 mutex_lock(&data->mutex);
> 392
> 393 expected_seq = (data->rsp_seq + 1) & SI1133_MAX_CMD_CTR;
> 394
> 395 if (cmd == SI1133_CMD_FORCE)
> 396 reinit_completion(&data->completion);
> 397
> 398 err = regmap_write(data->regmap, SI1133_REG_COMMAND, cmd);
> 399 if (err) {
> 400 dev_warn(dev, "Failed to write command %#02hhx, ret=%d\n", cmd,
> 401 err);
> 402 goto out;
> 403 }
> 404
> 405 if (cmd == SI1133_CMD_FORCE) {
> 406 /* wait for irq */
> 407 if (!wait_for_completion_timeout(&data->completion,
> 408 msecs_to_jiffies(SI1133_COMPLETION_TIMEOUT_MS))) {
> 409 err = -ETIMEDOUT;
> 410 goto out;
> 411 }
>
> Assume "cmd == SI1133_CMD_FORCE" and we don't timeout, then "resp" isn't
> initialized.
>
> 412 } else {
> 413 err = regmap_read_poll_timeout(data->regmap,
> 414 SI1133_REG_RESPONSE0, resp,
> 415 (resp & SI1133_CMD_SEQ_MASK) ==
> 416 expected_seq ||
> 417 (resp & SI1133_CMD_ERR_MASK),
> 418 SI1133_CMD_MINSLEEP_US_LOW,
> 419 SI1133_CMD_TIMEOUT_MS * 1000);
> 420 if (err) {
> 421 dev_warn(dev,
> 422 "Failed to read command %#02hhx, ret=%d\n",
> 423 cmd, err);
> 424 goto out;
> 425 }
> 426 }
> 427
> 428 if (resp & SI1133_CMD_ERR_MASK) {
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> regards,
> dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] iio: light: introduce si1133
2018-07-31 18:40 ` Maxime Roussin-Belanger
@ 2018-07-31 19:06 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2018-07-31 19:06 UTC (permalink / raw)
To: Maxime Roussin-Belanger; +Cc: linux-iio
On Tue, Jul 31, 2018 at 02:40:41PM -0400, Maxime Roussin-Belanger wrote:
> First time receiving a bug report, just to be sure... I only need to submit
> a PATCH right?
Yeah.
>
> Do I need to put you as a CC for the patch?
If you could give me a Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
credit that would be great. I do sometimes like to review the fixes
people send, but this one should be totally simple so there's no need.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-31 20:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 18:11 [bug report] iio: light: introduce si1133 Dan Carpenter
2018-07-31 18:40 ` Maxime Roussin-Belanger
2018-07-31 19:06 ` Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.