Skip to content

Commit

Permalink
iwlegacy: use <linux/units.h> helpers
Browse files Browse the repository at this point in the history
This switches the iwlegacy driver to use celsius_to_kelvin() and
kelvin_to_celsius() in <linux/units.h>.

[[email protected]: fix build warnings with format string]
  Link: http://lkml.kernel.org/r/[email protected]
  Link: https://lore.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Akinobu Mita <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Acked-by: Kalle Valo <[email protected]>
Cc: Kalle Valo <[email protected]>
Cc: Stanislaw Gruszka <[email protected]>
Cc: Amit Kucheria <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Daniel Lezcano <[email protected]>
Cc: Darren Hart <[email protected]>
Cc: Emmanuel Grumbach <[email protected]>
Cc: Guenter Roeck <[email protected]>
Cc: Hartmut Knaack <[email protected]>
Cc: Jean Delvare <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Johannes Berg <[email protected]>
Cc: Jonathan Cameron <[email protected]>
Cc: Keith Busch <[email protected]>
Cc: Lars-Peter Clausen <[email protected]>
Cc: Luca Coelho <[email protected]>
Cc: Peter Meerwald-Stadler <[email protected]>
Cc: Sagi Grimberg <[email protected]>
Cc: Sujith Thomas <[email protected]>
Cc: Zhang Rui <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mita authored and torvalds committed Jan 31, 2020
1 parent cdf309f commit 1410b2f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
3 changes: 2 additions & 1 deletion drivers/net/wireless/intel/iwlegacy/4965-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/firmware.h>
#include <linux/etherdevice.h>
#include <linux/if_arp.h>
#include <linux/units.h>

#include <net/mac80211.h>

Expand Down Expand Up @@ -6468,7 +6469,7 @@ il4965_set_hw_params(struct il_priv *il)
il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant;

il->hw_params.ct_kill_threshold =
CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY);
celsius_to_kelvin(CT_KILL_THRESHOLD_LEGACY);

il->hw_params.sens = &il4965_sensitivity;
il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS;
Expand Down
17 changes: 9 additions & 8 deletions drivers/net/wireless/intel/iwlegacy/4965.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/sched.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/units.h>
#include <net/mac80211.h>
#include <linux/etherdevice.h>
#include <asm/unaligned.h>
Expand Down Expand Up @@ -1104,7 +1105,7 @@ il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, u8 is_ht40,
/* get current temperature (Celsius) */
current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN);
current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX);
current_temp = KELVIN_TO_CELSIUS(current_temp);
current_temp = kelvin_to_celsius(current_temp);

/* select thermal txpower adjustment params, based on channel group
* (same frequency group used for mimo txatten adjustment) */
Expand Down Expand Up @@ -1610,8 +1611,8 @@ il4965_hw_get_temperature(struct il_priv *il)
temperature =
(temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET;

D_TEMP("Calibrated temperature: %dK, %dC\n", temperature,
KELVIN_TO_CELSIUS(temperature));
D_TEMP("Calibrated temperature: %dK, %ldC\n", temperature,
kelvin_to_celsius(temperature));

return temperature;
}
Expand Down Expand Up @@ -1670,12 +1671,12 @@ il4965_temperature_calib(struct il_priv *il)

if (il->temperature != temp) {
if (il->temperature)
D_TEMP("Temperature changed " "from %dC to %dC\n",
KELVIN_TO_CELSIUS(il->temperature),
KELVIN_TO_CELSIUS(temp));
D_TEMP("Temperature changed " "from %ldC to %ldC\n",
kelvin_to_celsius(il->temperature),
kelvin_to_celsius(temp));
else
D_TEMP("Temperature " "initialized to %dC\n",
KELVIN_TO_CELSIUS(temp));
D_TEMP("Temperature " "initialized to %ldC\n",
kelvin_to_celsius(temp));
}

il->temperature = temp;
Expand Down
3 changes: 0 additions & 3 deletions drivers/net/wireless/intel/iwlegacy/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -779,9 +779,6 @@ struct il_sensitivity_ranges {
u16 nrg_th_cca;
};

#define KELVIN_TO_CELSIUS(x) ((x)-273)
#define CELSIUS_TO_KELVIN(x) ((x)+273)

/**
* struct il_hw_params
* @bcast_id: f/w broadcast station ID
Expand Down

0 comments on commit 1410b2f

Please sign in to comment.