[PATCH 1/1] rt2x00: Avoid using 'char' for signed operations
From: Andy Shevchenko
Date: Tue Oct 18 2022 - 16:35:06 EST
The default Tx power is defined as 'short' in the data structure.
There is nothing prevents us to use 'short' in the
rt2800_txpower_to_dev(). With 'char' it's implementation defined
signedess and sometimes it may be tricky.
drivers/net/wireless/ralink/rt2x00/rt2800lib.c: In function 'rt2800_txpower_to_dev':
include/linux/build_bug.h:16:51: error: negative width in bit-field '<anonymous>'
...
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:4054:24: note: in expansion of macro 'clamp_t'
4054 | return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index cbbb1a4849cf..d7dffea6df82 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -4035,23 +4035,22 @@ static void rt2800_iq_calibrate(struct rt2x00_dev *rt2x00dev, int channel)
rt2800_bbp_write(rt2x00dev, 159, cal != 0xff ? cal : 0);
}
-static char rt2800_txpower_to_dev(struct rt2x00_dev *rt2x00dev,
- unsigned int channel,
- char txpower)
+static short rt2800_txpower_to_dev(struct rt2x00_dev *rt2x00dev,
+ unsigned int channel, short txpower)
{
if (rt2x00_rt(rt2x00dev, RT3593) ||
rt2x00_rt(rt2x00dev, RT3883))
txpower = rt2x00_get_field8(txpower, EEPROM_TXPOWER_ALC);
if (channel <= 14)
- return clamp_t(char, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER);
+ return clamp_t(short, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER);
if (rt2x00_rt(rt2x00dev, RT3593) ||
rt2x00_rt(rt2x00dev, RT3883))
- return clamp_t(char, txpower, MIN_A_TXPOWER_3593,
+ return clamp_t(short, txpower, MIN_A_TXPOWER_3593,
MAX_A_TXPOWER_3593);
else
- return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
+ return clamp_t(short, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
}
static void rt3883_bbp_adjust(struct rt2x00_dev *rt2x00dev,
--
2.35.1
--
With Best Regards,
Andy Shevchenko