* [PATCH v1 0/3] units: complement the set of Hz units
@ 2022-07-25 18:44 Dmitry Rokosov
2022-07-25 18:44 ` [PATCH v1 1/3] " Dmitry Rokosov
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Dmitry Rokosov @ 2022-07-25 18:44 UTC (permalink / raw)
To: akpm, andriy.shevchenko, daniel.lezcano, jic23, wsa,
andy.shevchenko, lars, Michael.Hennerich, jbhayana
Cc: linux-iio, kernel, linux-kernel, Dmitry Rokosov
During msa311 accel IIO driver development
https://lore.kernel.org/linux-iio/20220616104211.9257-1-ddrokosov@sberdevices.ru/
Andy requested to use proper units in the hz->ms calculation. Current
units.h header doesn't have milli, micro and nano HZ coefficients, so
some drivers (in the IIO subsystem) implement their own copies for that.
The current patchset resolves such a problem and intoduces general
MHZ_PER_HZ, UHZ_PER_HZ and NHZ_PER_HZ definitions in the units.h, and
fixes all drivers which duplicate these units.
Dmitry Rokosov (3):
units: complement the set of Hz units
iio: accel: adxl345: use HZ macro from units.h
iio: common: scmi_sensors: use HZ macro from units.h
drivers/iio/accel/adxl345_core.c | 2 +-
drivers/iio/common/scmi_sensors/scmi_iio.c | 2 +-
include/linux/units.h | 3 +++
3 files changed, 5 insertions(+), 2 deletions(-)
--
2.36.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 1/3] units: complement the set of Hz units
2022-07-25 18:44 [PATCH v1 0/3] units: complement the set of Hz units Dmitry Rokosov
@ 2022-07-25 18:44 ` Dmitry Rokosov
2022-07-25 21:29 ` Andy Shevchenko
2022-07-25 18:44 ` [PATCH v1 2/3] iio: accel: adxl345: use HZ macro from units.h Dmitry Rokosov
2022-07-25 18:44 ` [PATCH v1 3/3] iio: common: scmi_sensors: " Dmitry Rokosov
2 siblings, 1 reply; 6+ messages in thread
From: Dmitry Rokosov @ 2022-07-25 18:44 UTC (permalink / raw)
To: akpm, andriy.shevchenko, daniel.lezcano, jic23, wsa,
andy.shevchenko, lars, Michael.Hennerich, jbhayana
Cc: linux-iio, kernel, linux-kernel, Dmitry Rokosov
Currently, Hz units do not have milli, micro and nano Hz coefficients.
Some drivers (IIO especially) use their analogues to calculate
appropriate Hz values. This patch includes them to units.h definitions,
so they can be used from different kernel places.
Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
---
include/linux/units.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/units.h b/include/linux/units.h
index 681fc652e3d7..900a642f0ff8 100644
--- a/include/linux/units.h
+++ b/include/linux/units.h
@@ -20,6 +20,9 @@
#define PICO 1000000000000ULL
#define FEMTO 1000000000000000ULL
+#define NHZ_PER_HZ 1000000000UL
+#define UHZ_PER_HZ 1000000UL
+#define MHZ_PER_HZ 1000UL
#define HZ_PER_KHZ 1000UL
#define KHZ_PER_MHZ 1000UL
#define HZ_PER_MHZ 1000000UL
--
2.36.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/3] iio: accel: adxl345: use HZ macro from units.h
2022-07-25 18:44 [PATCH v1 0/3] units: complement the set of Hz units Dmitry Rokosov
2022-07-25 18:44 ` [PATCH v1 1/3] " Dmitry Rokosov
@ 2022-07-25 18:44 ` Dmitry Rokosov
2022-07-25 18:44 ` [PATCH v1 3/3] iio: common: scmi_sensors: " Dmitry Rokosov
2 siblings, 0 replies; 6+ messages in thread
From: Dmitry Rokosov @ 2022-07-25 18:44 UTC (permalink / raw)
To: akpm, andriy.shevchenko, daniel.lezcano, jic23, wsa,
andy.shevchenko, lars, Michael.Hennerich, jbhayana
Cc: linux-iio, kernel, linux-kernel, Dmitry Rokosov
Remove duplicate definition of NHZ_PER_HZ, because it's available in
the units.h.
Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
---
drivers/iio/accel/adxl345_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index 370bfec1275a..94189133fe8f 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/property.h>
#include <linux/regmap.h>
+#include <linux/units.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -32,7 +33,6 @@
#define ADXL345_BW_RATE GENMASK(3, 0)
#define ADXL345_BASE_RATE_NANO_HZ 97656250LL
-#define NHZ_PER_HZ 1000000000LL
#define ADXL345_POWER_CTL_MEASURE BIT(3)
#define ADXL345_POWER_CTL_STANDBY 0x00
--
2.36.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 3/3] iio: common: scmi_sensors: use HZ macro from units.h
2022-07-25 18:44 [PATCH v1 0/3] units: complement the set of Hz units Dmitry Rokosov
2022-07-25 18:44 ` [PATCH v1 1/3] " Dmitry Rokosov
2022-07-25 18:44 ` [PATCH v1 2/3] iio: accel: adxl345: use HZ macro from units.h Dmitry Rokosov
@ 2022-07-25 18:44 ` Dmitry Rokosov
2 siblings, 0 replies; 6+ messages in thread
From: Dmitry Rokosov @ 2022-07-25 18:44 UTC (permalink / raw)
To: akpm, andriy.shevchenko, daniel.lezcano, jic23, wsa,
andy.shevchenko, lars, Michael.Hennerich, jbhayana
Cc: linux-iio, kernel, linux-kernel, Dmitry Rokosov
Remove duplicate definition of UHZ_PER_HZ, because it's available in
the units.h.
Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
---
drivers/iio/common/scmi_sensors/scmi_iio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c
index 793d628db55f..c6d2cf5504cb 100644
--- a/drivers/iio/common/scmi_sensors/scmi_iio.c
+++ b/drivers/iio/common/scmi_sensors/scmi_iio.c
@@ -18,6 +18,7 @@
#include <linux/scmi_protocol.h>
#include <linux/time.h>
#include <linux/types.h>
+#include <linux/units.h>
#define SCMI_IIO_NUM_OF_AXIS 3
@@ -130,7 +131,6 @@ static const struct iio_buffer_setup_ops scmi_iio_buffer_ops = {
static int scmi_iio_set_odr_val(struct iio_dev *iio_dev, int val, int val2)
{
struct scmi_iio_priv *sensor = iio_priv(iio_dev);
- const unsigned long UHZ_PER_HZ = 1000000UL;
u64 sec, mult, uHz, sf;
u32 sensor_config;
char buf[32];
--
2.36.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/3] units: complement the set of Hz units
2022-07-25 18:44 ` [PATCH v1 1/3] " Dmitry Rokosov
@ 2022-07-25 21:29 ` Andy Shevchenko
2022-07-26 9:49 ` Dmitry Rokosov
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2022-07-25 21:29 UTC (permalink / raw)
To: Dmitry Rokosov
Cc: akpm, andriy.shevchenko, daniel.lezcano, jic23, wsa, lars,
Michael.Hennerich, jbhayana, linux-iio, kernel, linux-kernel
On Mon, Jul 25, 2022 at 8:44 PM Dmitry Rokosov <DDRokosov@sberdevices.ru> wrote:
>
> Currently, Hz units do not have milli, micro and nano Hz coefficients.
> Some drivers (IIO especially) use their analogues to calculate
> appropriate Hz values. This patch includes them to units.h definitions,
> so they can be used from different kernel places.
...
> +#define NHZ_PER_HZ 1000000000UL
> +#define UHZ_PER_HZ 1000000UL
> +#define MHZ_PER_HZ 1000UL
mHZ perhaps?
> #define HZ_PER_KHZ 1000UL
> #define KHZ_PER_MHZ 1000UL
> #define HZ_PER_MHZ 1000000UL
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/3] units: complement the set of Hz units
2022-07-25 21:29 ` Andy Shevchenko
@ 2022-07-26 9:49 ` Dmitry Rokosov
0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Rokosov @ 2022-07-26 9:49 UTC (permalink / raw)
To: Andy Shevchenko
Cc: akpm, andriy.shevchenko, daniel.lezcano, jic23, wsa, lars,
Michael.Hennerich, jbhayana, linux-iio, kernel, linux-kernel
Hello Andy,
Thank you for quick review.
On Mon, Jul 25, 2022 at 11:29:31PM +0200, Andy Shevchenko wrote:
> On Mon, Jul 25, 2022 at 8:44 PM Dmitry Rokosov <DDRokosov@sberdevices.ru> wrote:
> >
> > Currently, Hz units do not have milli, micro and nano Hz coefficients.
> > Some drivers (IIO especially) use their analogues to calculate
> > appropriate Hz values. This patch includes them to units.h definitions,
> > so they can be used from different kernel places.
>
> ...
>
> > +#define NHZ_PER_HZ 1000000000UL
> > +#define UHZ_PER_HZ 1000000UL
> > +#define MHZ_PER_HZ 1000UL
>
> mHZ perhaps?
>
I'm afraid it will not have the same view as other HZ units.
Maybe it's better to call mHZ as MILLIHZ? What do you think?
--
Thank you,
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-07-26 9:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-25 18:44 [PATCH v1 0/3] units: complement the set of Hz units Dmitry Rokosov
2022-07-25 18:44 ` [PATCH v1 1/3] " Dmitry Rokosov
2022-07-25 21:29 ` Andy Shevchenko
2022-07-26 9:49 ` Dmitry Rokosov
2022-07-25 18:44 ` [PATCH v1 2/3] iio: accel: adxl345: use HZ macro from units.h Dmitry Rokosov
2022-07-25 18:44 ` [PATCH v1 3/3] iio: common: scmi_sensors: " Dmitry Rokosov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.