diff options
author | Jiri Kosina <jkosina@suse.cz> | 2022-10-20 13:42:38 +0200 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2022-10-20 16:13:33 +0200 |
commit | daf405c8b9b93388295dec07391798039d0f5c26 (patch) | |
tree | a1a7ca72638734a927e1870959718d5f52066699 /drivers/hid | |
parent | 960f9df7c620ecb6030aff1d9a6c3d67598b8290 (diff) |
HID: mcp2221: fix usage of tmp variable in mcp2221_raw_event()
In mcp2221_raw_event(), 'tmp' is used only conditionally. Move
the declaration into the conditional block in order to prevent
unused variable warning.
Reported-by: kernel test robot <lkp@intel.com>
Fixes: 960f9df7c620 ("HID: mcp2221: add ADC/DAC support via iio subsystem")
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-mcp2221.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c index 2b3c3a483300..b3eaf170f0ec 100644 --- a/drivers/hid/hid-mcp2221.c +++ b/drivers/hid/hid-mcp2221.c @@ -731,7 +731,7 @@ static int mcp_get_i2c_eng_state(struct mcp2221 *mcp, static int mcp2221_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size) { - u8 *buf, tmp; + u8 *buf; struct mcp2221 *mcp = hid_get_drvdata(hdev); switch (data[0]) { @@ -875,19 +875,22 @@ static int mcp2221_raw_event(struct hid_device *hdev, } #if IS_REACHABLE(CONFIG_IIO) - /* DAC scale value */ - tmp = FIELD_GET(GENMASK(7, 6), data[6]); - if ((data[6] & BIT(5)) && tmp) - mcp->dac_scale = tmp + 4; - else - mcp->dac_scale = 5; - - /* ADC scale value */ - tmp = FIELD_GET(GENMASK(4, 3), data[7]); - if ((data[7] & BIT(2)) && tmp) - mcp->adc_scale = tmp - 1; - else - mcp->adc_scale = 0; + { + u8 tmp; + /* DAC scale value */ + tmp = FIELD_GET(GENMASK(7, 6), data[6]); + if ((data[6] & BIT(5)) && tmp) + mcp->dac_scale = tmp + 4; + else + mcp->dac_scale = 5; + + /* ADC scale value */ + tmp = FIELD_GET(GENMASK(4, 3), data[7]); + if ((data[7] & BIT(2)) && tmp) + mcp->adc_scale = tmp - 1; + else + mcp->adc_scale = 0; + } #endif break; |