Add Hz macros
Subsystems (12)
v3 cover Add Hz macros
There are multiple definitions of the HZ_PER_MHZ or HZ_PER_KHZ in the different drivers. Instead of duplicating this definition again and again, add one in the units.h header to be reused in all the place the redefiniton occurs.
At the same time, change the type of the Watts, as they can not be negative.
Daniel Lezcano (10):
units: Change from 'L' to 'UL'
units: Add the HZ macros
thermal/drivers/devfreq_cooling: Use HZ macros
devfreq: Use HZ macros
iio/drivers/as73211: Use HZ macros
hwmon/drivers/mr75203: Use HZ macros
iio/drivers/hid-sensor: Use HZ macros
i2c/drivers/ov02q10: Use HZ macros
mtd/drivers/nand: Use HZ macros
phy/drivers/stm32: Use HZ macros
drivers/devfreq/devfreq.c | 2 +- drivers/hwmon/mr75203.c | 2 +- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 3 +-- drivers/iio/light/as73211.c | 3 +-- drivers/media/i2c/ov02a10.c | 2 +- drivers/mtd/nand/raw/intel-nand-controller.c | 2 +- drivers/phy/st/phy-stm32-usbphyc.c | 2 +- drivers/thermal/devfreq_cooling.c | 2 +- include/linux/units.h | 10 +++++++--- 9 files changed, 15 insertions(+), 13 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/10 units: Change from 'L' to 'UL'
The users of the macros are safe to be assigned with an unsigned instead of signed as the variables using them are themselves unsigned.
--- include/linux/units.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/units.h +3 -3
@@ -4,9 +4,9 @@#include <linux/math.h> -#define MILLIWATT_PER_WATT 1000L -#define MICROWATT_PER_MILLIWATT 1000L -#define MICROWATT_PER_WATT 1000000L +#define MILLIWATT_PER_WATT 1000UL +#define MICROWATT_PER_MILLIWATT 1000UL +#define MICROWATT_PER_WATT 1000000UL#define ABSOLUTE_ZERO_MILLICELSIUS -273150
Signature · 1 line
2.25.1
PATCH v3 2/10 units: Add the HZ macros
In reply to Daniel LezcanoThe macros for the unit conversion for frequency are duplicated in different places.
Provide these macros in the 'units' header, so they can be reused.
--- include/linux/units.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/units.h +4 -0
@@ -4,6 +4,10 @@#include <linux/math.h> +#define HZ_PER_KHZ 1000UL +#define KHZ_PER_MHZ 1000UL +#define HZ_PER_MHZ 1000000UL +#define MILLIWATT_PER_WATT 1000UL#define MICROWATT_PER_MILLIWATT 1000UL#define MICROWATT_PER_WATT 1000000UL
Signature · 1 line
2.25.1
PATCH v3 3/10 thermal/drivers/devfreq_cooling: Use HZ macros
In reply to Daniel LezcanoHZ unit conversion macros are available in units.h, use them and remove the duplicate definition.
The new macro uses a unsigned long type which is already the type in the current code via the 'freq' variable.
--- drivers/thermal/devfreq_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/devfreq_cooling.c +1 -1
@@ -18,10 +18,10 @@#include <linux/pm_opp.h> #include <linux/pm_qos.h> #include <linux/thermal.h> +#include <linux/units.h> #include <trace/events/thermal.h> -#define HZ_PER_KHZ 1000#define SCALE_ERROR_MITIGATION 100/**
Signature · 1 line
2.25.1
PATCH v3 4/10 devfreq: Use HZ macros
In reply to Daniel LezcanoHZ unit conversion macros are available in units.h, use them and remove the duplicate definition.
The new macro has an unsigned long type.
All the code is dealing with unsigned long and the code using the macro is doing a coercitive cast to unsigned long.
--- drivers/devfreq/devfreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/devfreq.c +1 -1
@@ -27,6 +27,7 @@#include <linux/hrtimer.h> #include <linux/of.h> #include <linux/pm_qos.h> +#include <linux/units.h> #include "governor.h" #define CREATE_TRACE_POINTS
@@ -34,7 +35,6 @@#define IS_SUPPORTED_FLAG (f, name) ((f & DEVFREQ_GOV_FLAG_##name) ? true : false)#define IS_SUPPORTED_ATTR (f, name) ((f & DEVFREQ_GOV_ATTR_##name) ? true : false) -#define HZ_PER_KHZ 1000static struct class *devfreq_class;static struct dentry *devfreq_debugfs;
Signature · 1 line
2.25.1
PATCH v3 5/10 iio/drivers/as73211: Use HZ macros
In reply to Daniel LezcanoHZ unit conversion macros are available in units.h, use them and remove the duplicate definition.
--- drivers/iio/light/as73211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/light/as73211.c +1 -2
@@ -24,8 +24,7 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/pm.h> - -#define HZ_PER_KHZ 1000 +#include <linux/units.h> #define AS73211_DRV_NAME "as73211"
Signature · 1 line
2.25.1
PATCH v3 6/10 hwmon/drivers/mr75203: Use HZ macros
In reply to Daniel LezcanoHZ unit conversion macros are available in units.h, use them and remove the duplicate definition.
The new macro is an unsigned long. The code dealing with it is considering as an unsigned long also.
--- drivers/hwmon/mr75203.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/mr75203.c +1 -1
@@ -17,6 +17,7 @@#include <linux/property.h> #include <linux/regmap.h> #include <linux/reset.h> +#include <linux/units.h> /* PVT Common register */ #define PVT_IP_CONFIG 0x04
@@ -37,7 +38,6 @@#define CLK_SYNTH_EN BIT(24)#define CLK_SYS_CYCLES_MAX 514#define CLK_SYS_CYCLES_MIN 2 -#define HZ_PER_MHZ 1000000L#define SDIF_DISABLE 0x04
Signature · 1 line
2.25.1
PATCH v3 7/10 iio/drivers/hid-sensor: Use HZ macros
In reply to Daniel LezcanoHZ unit conversion macros are available in units.h, use them and remove the duplicate definition.
--- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +1 -2
@@ -6,12 +6,11 @@#include <linux/module.h> #include <linux/kernel.h> #include <linux/time.h> +#include <linux/units.h> #include <linux/hid-sensor-hub.h> #include <linux/iio/iio.h> -#define HZ_PER_MHZ 1000000L - static struct { u32 usage_id; int unit; /* 0 for default others from HID sensor spec */
Signature · 1 line
2.25.1
PATCH v3 8/10 i2c/drivers/ov02q10: Use HZ macros
In reply to Daniel LezcanoHZ unit conversion macros are available in units.h, use them and remove the duplicate definition.
--- drivers/media/i2c/ov02a10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov02a10.c +1 -1
@@ -9,6 +9,7 @@#include <linux/module.h> #include <linux/pm_runtime.h> #include <linux/regulator/consumer.h> +#include <linux/units.h> #include <media/media-entity.h> #include <media/v4l2-async.h> #include <media/v4l2-ctrls.h>
@@ -64,7 +65,6 @@/* Test pattern control */ #define OV02A10_REG_TEST_PATTERN 0xb6 -#define HZ_PER_MHZ 1000000L#define OV02A10_LINK_FREQ_390MHZ (390 * HZ_PER_MHZ)#define OV02A10_ECLK_FREQ (24 * HZ_PER_MHZ)
Signature · 1 line
2.25.1
PATCH v3 9/10 mtd/drivers/nand: Use HZ macros
In reply to Daniel LezcanoHZ unit conversion macros are available in units.h, use them and remove the duplicate definition.
--- drivers/mtd/nand/raw/intel-nand-controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/intel-nand-controller.c +1 -1
@@ -20,6 +20,7 @@#include <linux/sched.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/units.h> #include <asm/unaligned.h> #define EBU_CLC 0x000
@@ -102,7 +103,6 @@#define MAX_CS 2 -#define HZ_PER_MHZ 1000000L#define USEC_PER_SEC 1000000Lstruct ebu_nand_cs {
Signature · 1 line
2.25.1
PATCH v3 10/10 phy/drivers/stm32: Use HZ macros
In reply to Daniel LezcanoHZ unit conversion macros are available in units.h, use them and remove the duplicate definition.
--- drivers/phy/st/phy-stm32-usbphyc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/st/phy-stm32-usbphyc.c +1 -1
@@ -15,6 +15,7 @@#include <linux/of_platform.h> #include <linux/phy/phy.h> #include <linux/reset.h> +#include <linux/units.h> #define STM32_USBPHYC_PLL 0x0#define STM32_USBPHYC_MISC 0x8
@@ -47,7 +48,6 @@#define PLL_FVCO_MHZ 2880#define PLL_INFF_MIN_RATE_HZ 19200000#define PLL_INFF_MAX_RATE_HZ 38400000 -#define HZ_PER_MHZ 1000000Lstruct pll_params {u8 ndiv;
Signature · 1 line
2.25.1