[PATCH 1/3] timer-uclass: add timer_get_ops() macro
Ovidiu Panait
ovpanait at gmail.com
Wed Oct 12 07:36:54 CEST 2022
Align timer uclass with the other subsystems and provide a timer_get_ops()
convenience macro.
Using this instead of the generic device_get_ops() also prevents
-Wdiscarded-qualifiers warnings when used with non-const variables.
Signed-off-by: Ovidiu Panait <ovpanait at gmail.com>
---
drivers/timer/timer-uclass.c | 2 +-
include/timer.h | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index cbc3647698..bdc77b3822 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -32,7 +32,7 @@ DECLARE_GLOBAL_DATA_PTR;
int notrace timer_get_count(struct udevice *dev, u64 *count)
{
- const struct timer_ops *ops = device_get_ops(dev);
+ struct timer_ops *ops = timer_get_ops(dev);
if (!ops->get_count)
return -ENOSYS;
diff --git a/include/timer.h b/include/timer.h
index a044cb034e..d33a26e28f 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -6,6 +6,8 @@
#ifndef _TIMER_H_
#define _TIMER_H_
+#define timer_get_ops(dev) ((struct timer_ops *)(dev)->driver->ops)
+
/**
* dm_timer_init() - initialize a timer for time keeping. On success
* initializes gd->timer so that lib/timer can use it for future
--
2.25.1
More information about the U-Boot
mailing list