public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ovidiu Panait <ovpanait@gmail.com>
To: u-boot@lists.denx.de
Cc: Ovidiu Panait <ovpanait@gmail.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Simon Glass <sjg@chromium.org>
Subject: [PATCH 1/3] timer-uclass: add timer_get_ops() macro
Date: Wed, 12 Oct 2022 08:36:54 +0300	[thread overview]
Message-ID: <20221012053656.1492457-1-ovpanait@gmail.com> (raw)

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>
---

 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


             reply	other threads:[~2022-10-12  5:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-12  5:36 Ovidiu Panait [this message]
2022-10-12  5:36 ` [PATCH 2/3] timer-uclass: relocate ops pointers for CONFIG_NEEDS_MANUAL_RELOC Ovidiu Panait
2022-10-12 12:59   ` Simon Glass
2022-10-12 15:21     ` Ovidiu Panait
2022-10-12  5:36 ` [PATCH 3/3] timer: xilinx-timer: use timer_conv_64() to fix timer wrap around Ovidiu Panait
2022-10-12  8:58   ` Michal Simek
2022-10-25  9:32   ` Michal Simek
2022-10-12 12:59 ` [PATCH 1/3] timer-uclass: add timer_get_ops() macro Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221012053656.1492457-1-ovpanait@gmail.com \
    --to=ovpanait@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox