Skip to content

Commit

Permalink
wifi: rt2x00: use explicitly signed or unsigned types
Browse files Browse the repository at this point in the history
commit 6606303 upstream.

On some platforms, `char` is unsigned, but this driver, for the most
part, assumed it was signed. In other places, it uses `char` to mean an
unsigned number, but only in cases when the values are small. And in
still other places, `char` is used as a boolean. Put an end to this
confusion by declaring explicit types, depending on the context.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Stanislaw Gruszka <stf_xl@wp.pl>
Cc: Helmut Schaa <helmut.schaa@googlemail.com>
Cc: Kalle Valo <kvalo@kernel.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221019155541.3410813-1-Jason@zx2c4.com
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
zx2c4 authored and gregkh committed Jul 27, 2024
1 parent 53e21cf commit 2d3cef3
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 46 deletions.
8 changes: 4 additions & 4 deletions drivers/net/wireless/ralink/rt2x00/rt2400pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,9 +1023,9 @@ static int rt2400pci_set_state(struct rt2x00_dev *rt2x00dev,
{
u32 reg, reg2;
unsigned int i;
char put_to_sleep;
char bbp_state;
char rf_state;
bool put_to_sleep;
u8 bbp_state;
u8 rf_state;

put_to_sleep = (state != STATE_AWAKE);

Expand Down Expand Up @@ -1561,7 +1561,7 @@ static int rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
{
struct hw_mode_spec *spec = &rt2x00dev->spec;
struct channel_info *info;
char *tx_power;
u8 *tx_power;
unsigned int i;

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/ralink/rt2x00/rt2400pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@
#define DEFAULT_TXPOWER 39

#define __CLAMP_TX(__txpower) \
clamp_t(char, (__txpower), MIN_TXPOWER, MAX_TXPOWER)
clamp_t(u8, (__txpower), MIN_TXPOWER, MAX_TXPOWER)

#define TXPOWER_FROM_DEV(__txpower) \
((__CLAMP_TX(__txpower) - MAX_TXPOWER) + MIN_TXPOWER)
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/ralink/rt2x00/rt2500pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1176,9 +1176,9 @@ static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev,
{
u32 reg, reg2;
unsigned int i;
char put_to_sleep;
char bbp_state;
char rf_state;
bool put_to_sleep;
u8 bbp_state;
u8 rf_state;

put_to_sleep = (state != STATE_AWAKE);

Expand Down Expand Up @@ -1856,7 +1856,7 @@ static int rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
{
struct hw_mode_spec *spec = &rt2x00dev->spec;
struct channel_info *info;
char *tx_power;
u8 *tx_power;
unsigned int i;

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/ralink/rt2x00/rt2500pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,6 @@
(((u8)(__txpower)) > MAX_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)

#define TXPOWER_TO_DEV(__txpower) \
clamp_t(char, __txpower, MIN_TXPOWER, MAX_TXPOWER)
clamp_t(u8, __txpower, MIN_TXPOWER, MAX_TXPOWER)

#endif /* RT2500PCI_H */
8 changes: 4 additions & 4 deletions drivers/net/wireless/ralink/rt2x00/rt2500usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,9 @@ static int rt2500usb_set_state(struct rt2x00_dev *rt2x00dev,
u16 reg;
u16 reg2;
unsigned int i;
char put_to_sleep;
char bbp_state;
char rf_state;
bool put_to_sleep;
u8 bbp_state;
u8 rf_state;

put_to_sleep = (state != STATE_AWAKE);

Expand Down Expand Up @@ -1663,7 +1663,7 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
{
struct hw_mode_spec *spec = &rt2x00dev->spec;
struct channel_info *info;
char *tx_power;
u8 *tx_power;
unsigned int i;

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/ralink/rt2x00/rt2500usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,6 @@
(((u8)(__txpower)) > MAX_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)

#define TXPOWER_TO_DEV(__txpower) \
clamp_t(char, __txpower, MIN_TXPOWER, MAX_TXPOWER)
clamp_t(u8, __txpower, MIN_TXPOWER, MAX_TXPOWER)

#endif /* RT2500USB_H */
36 changes: 18 additions & 18 deletions drivers/net/wireless/ralink/rt2x00/rt2800lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3310,10 +3310,10 @@ static void rt2800_config_channel_rf53xx(struct rt2x00_dev *rt2x00dev,
if (rt2x00_has_cap_bt_coexist(rt2x00dev)) {
if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F)) {
/* r55/r59 value array of channel 1~14 */
static const char r55_bt_rev[] = {0x83, 0x83,
static const u8 r55_bt_rev[] = {0x83, 0x83,
0x83, 0x73, 0x73, 0x63, 0x53, 0x53,
0x53, 0x43, 0x43, 0x43, 0x43, 0x43};
static const char r59_bt_rev[] = {0x0e, 0x0e,
static const u8 r59_bt_rev[] = {0x0e, 0x0e,
0x0e, 0x0e, 0x0e, 0x0b, 0x0a, 0x09,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07};

Expand All @@ -3322,18 +3322,18 @@ static void rt2800_config_channel_rf53xx(struct rt2x00_dev *rt2x00dev,
rt2800_rfcsr_write(rt2x00dev, 59,
r59_bt_rev[idx]);
} else {
static const char r59_bt[] = {0x8b, 0x8b, 0x8b,
static const u8 r59_bt[] = {0x8b, 0x8b, 0x8b,
0x8b, 0x8b, 0x8b, 0x8b, 0x8a, 0x89,
0x88, 0x88, 0x86, 0x85, 0x84};

rt2800_rfcsr_write(rt2x00dev, 59, r59_bt[idx]);
}
} else {
if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F)) {
static const char r55_nonbt_rev[] = {0x23, 0x23,
static const u8 r55_nonbt_rev[] = {0x23, 0x23,
0x23, 0x23, 0x13, 0x13, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03};
static const char r59_nonbt_rev[] = {0x07, 0x07,
static const u8 r59_nonbt_rev[] = {0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x06, 0x05, 0x04, 0x04};

Expand All @@ -3344,14 +3344,14 @@ static void rt2800_config_channel_rf53xx(struct rt2x00_dev *rt2x00dev,
} else if (rt2x00_rt(rt2x00dev, RT5390) ||
rt2x00_rt(rt2x00dev, RT5392) ||
rt2x00_rt(rt2x00dev, RT6352)) {
static const char r59_non_bt[] = {0x8f, 0x8f,
static const u8 r59_non_bt[] = {0x8f, 0x8f,
0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8d,
0x8a, 0x88, 0x88, 0x87, 0x87, 0x86};

rt2800_rfcsr_write(rt2x00dev, 59,
r59_non_bt[idx]);
} else if (rt2x00_rt(rt2x00dev, RT5350)) {
static const char r59_non_bt[] = {0x0b, 0x0b,
static const u8 r59_non_bt[] = {0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0a,
0x0a, 0x09, 0x08, 0x07, 0x07, 0x06};

Expand Down Expand Up @@ -3974,23 +3974,23 @@ 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,
static s8 rt2800_txpower_to_dev(struct rt2x00_dev *rt2x00dev,
unsigned int channel,
char txpower)
s8 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(s8, 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(s8, txpower, MIN_A_TXPOWER_3593,
MAX_A_TXPOWER_3593);
else
return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
return clamp_t(s8, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
}

static void rt3883_bbp_adjust(struct rt2x00_dev *rt2x00dev,
Expand Down Expand Up @@ -8492,11 +8492,11 @@ static int rt2800_rf_lp_config(struct rt2x00_dev *rt2x00dev, bool btxcal)
return 0;
}

static char rt2800_lp_tx_filter_bw_cal(struct rt2x00_dev *rt2x00dev)
static s8 rt2800_lp_tx_filter_bw_cal(struct rt2x00_dev *rt2x00dev)
{
unsigned int cnt;
u8 bbp_val;
char cal_val;
s8 cal_val;

rt2800_bbp_dcoc_write(rt2x00dev, 0, 0x82);

Expand Down Expand Up @@ -8528,7 +8528,7 @@ static void rt2800_bw_filter_calibration(struct rt2x00_dev *rt2x00dev,
u8 rx_filter_target_20m = 0x27, rx_filter_target_40m = 0x31;
int loop = 0, is_ht40, cnt;
u8 bbp_val, rf_val;
char cal_r32_init, cal_r32_val, cal_diff;
s8 cal_r32_init, cal_r32_val, cal_diff;
u8 saverfb5r00, saverfb5r01, saverfb5r03, saverfb5r04, saverfb5r05;
u8 saverfb5r06, saverfb5r07;
u8 saverfb5r08, saverfb5r17, saverfb5r18, saverfb5r19, saverfb5r20;
Expand Down Expand Up @@ -9979,9 +9979,9 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
{
struct hw_mode_spec *spec = &rt2x00dev->spec;
struct channel_info *info;
char *default_power1;
char *default_power2;
char *default_power3;
s8 *default_power1;
s8 *default_power2;
s8 *default_power3;
unsigned int i, tx_chains, rx_chains;
u32 reg;

Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/ralink/rt2x00/rt2800lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
struct rt2800_drv_data {
u8 calibration_bw20;
u8 calibration_bw40;
char rx_calibration_bw20;
char rx_calibration_bw40;
char tx_calibration_bw20;
char tx_calibration_bw40;
s8 rx_calibration_bw20;
s8 rx_calibration_bw40;
s8 tx_calibration_bw20;
s8 tx_calibration_bw40;
u8 bbp25;
u8 bbp26;
u8 txmixer_gain_24g;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev,
const u16 buffer_length)
{
int status = 0;
unsigned char *tb;
u8 *tb;
u16 off, len, bsize;

mutex_lock(&rt2x00dev->csr_mutex);

tb = (char *)buffer;
tb = (u8 *)buffer;
off = offset;
len = buffer_length;
while (len && !status) {
Expand Down Expand Up @@ -215,7 +215,7 @@ void rt2x00usb_register_read_async(struct rt2x00_dev *rt2x00dev,
rd->cr.wLength = cpu_to_le16(sizeof(u32));

usb_fill_control_urb(urb, usb_dev, usb_rcvctrlpipe(usb_dev, 0),
(unsigned char *)(&rd->cr), &rd->reg, sizeof(rd->reg),
(u8 *)(&rd->cr), &rd->reg, sizeof(rd->reg),
rt2x00usb_register_read_async_cb, rd);
usb_anchor_urb(urb, rt2x00dev->anchor);
if (usb_submit_urb(urb, GFP_ATOMIC) < 0) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ralink/rt2x00/rt61pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ static int rt61pci_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state)
{
u32 reg, reg2;
unsigned int i;
char put_to_sleep;
bool put_to_sleep;

put_to_sleep = (state != STATE_AWAKE);

Expand Down Expand Up @@ -2656,7 +2656,7 @@ static int rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
{
struct hw_mode_spec *spec = &rt2x00dev->spec;
struct channel_info *info;
char *tx_power;
u8 *tx_power;
unsigned int i;

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/ralink/rt2x00/rt61pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,6 @@ struct hw_pairwise_ta_entry {
(((u8)(__txpower)) > MAX_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)

#define TXPOWER_TO_DEV(__txpower) \
clamp_t(char, __txpower, MIN_TXPOWER, MAX_TXPOWER)
clamp_t(u8, __txpower, MIN_TXPOWER, MAX_TXPOWER)

#endif /* RT61PCI_H */
4 changes: 2 additions & 2 deletions drivers/net/wireless/ralink/rt2x00/rt73usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ static int rt73usb_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state)
{
u32 reg, reg2;
unsigned int i;
char put_to_sleep;
bool put_to_sleep;

put_to_sleep = (state != STATE_AWAKE);

Expand Down Expand Up @@ -2090,7 +2090,7 @@ static int rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
{
struct hw_mode_spec *spec = &rt2x00dev->spec;
struct channel_info *info;
char *tx_power;
u8 *tx_power;
unsigned int i;

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/ralink/rt2x00/rt73usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,6 @@ struct hw_pairwise_ta_entry {
(((u8)(__txpower)) > MAX_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)

#define TXPOWER_TO_DEV(__txpower) \
clamp_t(char, __txpower, MIN_TXPOWER, MAX_TXPOWER)
clamp_t(u8, __txpower, MIN_TXPOWER, MAX_TXPOWER)

#endif /* RT73USB_H */

0 comments on commit 2d3cef3

Please sign in to comment.