]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
timer-uclass: add timer_get_ops() macro
authorOvidiu Panait <ovpanait@gmail.com>
Wed, 12 Oct 2022 05:36:54 +0000 (08:36 +0300)
committerMichal Simek <michal.simek@amd.com>
Tue, 22 Nov 2022 14:02:07 +0000 (15:02 +0100)
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@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Link: https://lore.kernel.org/r/20221012053656.1492457-1-ovpanait@gmail.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
drivers/timer/timer-uclass.c
include/timer.h

index cbc3647698722b63c5022f5e50fd9a56aa094e34..bdc77b38223fed0bc93eb1198d0b2405a2b624ae 100644 (file)
@@ -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;
index a044cb034ed0c4c343a1af40f637a2d2a7b01691..d33a26e28fe1e045f2a8d570d0c7a88871dfb267 100644 (file)
@@ -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