Re: [PATCH v4 2/2] iio: adc: ti-ads7950: add GPIO support

From: Dan Carpenter
Date: Mon Mar 04 2019 - 09:53:57 EST


Hi Justin,

url: https://github.com/0day-ci/linux/commits/justinpopo6-gmail-com/iio-adc-ads7950-add-gpio-support/20190301-201828
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg

smatch warnings:
drivers/iio/adc/ti-ads7950.c:530 ti_ads7950_init_hw() error: double unlock 'mutex:&st->slock'

# https://github.com/0day-ci/linux/commit/5290a7752b734ae0b2f5b343bd761366decdbbeb
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 5290a7752b734ae0b2f5b343bd761366decdbbeb
vim +530 drivers/iio/adc/ti-ads7950.c

5290a775 Justin Chen 2019-02-28 506
5290a775 Justin Chen 2019-02-28 507 static int ti_ads7950_init_hw(struct ti_ads7950_state *st)
5290a775 Justin Chen 2019-02-28 508 {
5290a775 Justin Chen 2019-02-28 509 int ret = 0;
5290a775 Justin Chen 2019-02-28 510
5290a775 Justin Chen 2019-02-28 511 mutex_lock(&st->slock);
5290a775 Justin Chen 2019-02-28 512
5290a775 Justin Chen 2019-02-28 513 /* Settings for Manual/Auto1/Auto2 commands */
5290a775 Justin Chen 2019-02-28 514 /* Default to 5v ref */
5290a775 Justin Chen 2019-02-28 515 st->cmd_settings_bitmask = TI_ADS7950_CR_RANGE_5V;
5290a775 Justin Chen 2019-02-28 516 st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);
5290a775 Justin Chen 2019-02-28 517 ret = spi_sync(st->spi, &st->scan_single_msg);
5290a775 Justin Chen 2019-02-28 518 if (ret)
5290a775 Justin Chen 2019-02-28 519 goto out;
5290a775 Justin Chen 2019-02-28 520
5290a775 Justin Chen 2019-02-28 521 /* Settings for GPIO command */
5290a775 Justin Chen 2019-02-28 522 st->gpio_cmd_settings_bitmask = 0x0;
5290a775 Justin Chen 2019-02-28 523 st->single_tx = TI_ADS7950_GPIO_CMD_SETTINGS(st);
5290a775 Justin Chen 2019-02-28 524 ret = spi_sync(st->spi, &st->scan_single_msg);
5290a775 Justin Chen 2019-02-28 525 mutex_unlock(&st->slock);
^^^^^^^^^^^^^^^^^^^^^^^^

5290a775 Justin Chen 2019-02-28 526 if (ret)
5290a775 Justin Chen 2019-02-28 527 goto out;
5290a775 Justin Chen 2019-02-28 528
5290a775 Justin Chen 2019-02-28 529 out:
5290a775 Justin Chen 2019-02-28 @530 mutex_unlock(&st->slock);
^^^^^^^^^^^^^^^^^^^^^^^^

It's a bit disappointing that mutex_unlock() doesn't generate a warning
at runtime... :(

5290a775 Justin Chen 2019-02-28 531
5290a775 Justin Chen 2019-02-28 532 return ret;
5290a775 Justin Chen 2019-02-28 533 }
5290a775 Justin Chen 2019-02-28 534

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation