Skip to content

Commit daf405c

Browse files
author
Jiri Kosina
committed
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 <[email protected]> Fixes: 960f9df ("HID: mcp2221: add ADC/DAC support via iio subsystem") Signed-off-by: Jiri Kosina <[email protected]>
1 parent 960f9df commit daf405c

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

drivers/hid/hid-mcp2221.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ static int mcp_get_i2c_eng_state(struct mcp2221 *mcp,
731731
static int mcp2221_raw_event(struct hid_device *hdev,
732732
struct hid_report *report, u8 *data, int size)
733733
{
734-
u8 *buf, tmp;
734+
u8 *buf;
735735
struct mcp2221 *mcp = hid_get_drvdata(hdev);
736736

737737
switch (data[0]) {
@@ -875,19 +875,22 @@ static int mcp2221_raw_event(struct hid_device *hdev,
875875
}
876876

877877
#if IS_REACHABLE(CONFIG_IIO)
878-
/* DAC scale value */
879-
tmp = FIELD_GET(GENMASK(7, 6), data[6]);
880-
if ((data[6] & BIT(5)) && tmp)
881-
mcp->dac_scale = tmp + 4;
882-
else
883-
mcp->dac_scale = 5;
884-
885-
/* ADC scale value */
886-
tmp = FIELD_GET(GENMASK(4, 3), data[7]);
887-
if ((data[7] & BIT(2)) && tmp)
888-
mcp->adc_scale = tmp - 1;
889-
else
890-
mcp->adc_scale = 0;
878+
{
879+
u8 tmp;
880+
/* DAC scale value */
881+
tmp = FIELD_GET(GENMASK(7, 6), data[6]);
882+
if ((data[6] & BIT(5)) && tmp)
883+
mcp->dac_scale = tmp + 4;
884+
else
885+
mcp->dac_scale = 5;
886+
887+
/* ADC scale value */
888+
tmp = FIELD_GET(GENMASK(4, 3), data[7]);
889+
if ((data[7] & BIT(2)) && tmp)
890+
mcp->adc_scale = tmp - 1;
891+
else
892+
mcp->adc_scale = 0;
893+
}
891894
#endif
892895

893896
break;

0 commit comments

Comments
 (0)