Patchwork rtc: tx4939: Kill get_tx4939rtc_plat_data() function

login
register
mail settings
Submitter Axel Lin
Date Dec. 19, 2012, 9:29 a.m.
Message ID <1355909344.11204.3.camel@phoenix>
Download mbox | patch
Permalink /patch/207272/
State New
Headers show

Comments

Axel Lin - Dec. 19, 2012, 9:29 a.m.
Simply use dev_get_drvdata() instead.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/rtc/rtc-tx4939.c |   21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
Axel Lin - Dec. 19, 2012, 1:36 p.m.
2012/12/19 Atsushi Nemoto <anemo@mba.ocn.ne.jp>

> On Wed, 19 Dec 2012 17:29:04 +0800, Axel Lin <axel.lin@ingics.com> wrote:
> > Simply use dev_get_drvdata() instead.
> >
> > Signed-off-by: Axel Lin <axel.lin@ingics.com>
> > ---
> >  drivers/rtc/rtc-tx4939.c |   21 ++++++++-------------
> >  1 file changed, 8 insertions(+), 13 deletions(-)
>
> Hi Axel,
>
> Thank you for cleanup, but, a platform driver should use
> platform_get_drvdata / platform_set_drvdata, no?
>
> I think using dev_get_drvdata() in platform_get_drvdata() is an
> implementation detail of the platform device framework, so we should
> not depends on such an internal detail.
>

I think there is no problem calling dev_get_drvdata() in this driver.
It's pretty common in various driver code.


> If there was any reason to use dev_get_drvdata, please convert all
> platform_get_drvdata and platform_set_drvdata to dev_get_drvdata and
> dev_set_drvdata.  We should avoid mixing two APIs.
>

I think using either API is ok.
Just no need to add get_tx4939rtc_plat_data() helper here.

Regards,
Axel

Patch

diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c
index a12bfac..b570d02 100644
--- a/drivers/rtc/rtc-tx4939.c
+++ b/drivers/rtc/rtc-tx4939.c
@@ -22,11 +22,6 @@  struct tx4939rtc_plat_data {
 	spinlock_t lock;
 };
 
-static struct tx4939rtc_plat_data *get_tx4939rtc_plat_data(struct device *dev)
-{
-	return platform_get_drvdata(to_platform_device(dev));
-}
-
 static int tx4939_rtc_cmd(struct tx4939_rtc_reg __iomem *rtcreg, int cmd)
 {
 	int i = 0;
@@ -44,7 +39,7 @@  static int tx4939_rtc_cmd(struct tx4939_rtc_reg __iomem *rtcreg, int cmd)
 
 static int tx4939_rtc_set_mmss(struct device *dev, unsigned long secs)
 {
-	struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev);
+	struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev);
 	struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
 	int i, ret;
 	unsigned char buf[6];
@@ -68,7 +63,7 @@  static int tx4939_rtc_set_mmss(struct device *dev, unsigned long secs)
 
 static int tx4939_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
-	struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev);
+	struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev);
 	struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
 	int i, ret;
 	unsigned long sec;
@@ -93,7 +88,7 @@  static int tx4939_rtc_read_time(struct device *dev, struct rtc_time *tm)
 
 static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
-	struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev);
+	struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev);
 	struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
 	int i, ret;
 	unsigned long sec;
@@ -125,7 +120,7 @@  static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 
 static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
-	struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev);
+	struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev);
 	struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
 	int i, ret;
 	unsigned long sec;
@@ -154,7 +149,7 @@  static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 
 static int tx4939_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
 {
-	struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev);
+	struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev);
 
 	spin_lock_irq(&pdata->lock);
 	tx4939_rtc_cmd(pdata->rtcreg,
@@ -166,7 +161,7 @@  static int tx4939_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
 
 static irqreturn_t tx4939_rtc_interrupt(int irq, void *dev_id)
 {
-	struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev_id);
+	struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev_id);
 	struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
 	unsigned long events = RTC_IRQF;
 
@@ -194,7 +189,7 @@  static ssize_t tx4939_rtc_nvram_read(struct file *filp, struct kobject *kobj,
 				     char *buf, loff_t pos, size_t size)
 {
 	struct device *dev = container_of(kobj, struct device, kobj);
-	struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev);
+	struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev);
 	struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
 	ssize_t count;
 
@@ -213,7 +208,7 @@  static ssize_t tx4939_rtc_nvram_write(struct file *filp, struct kobject *kobj,
 				      char *buf, loff_t pos, size_t size)
 {
 	struct device *dev = container_of(kobj, struct device, kobj);
-	struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev);
+	struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev);
 	struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
 	ssize_t count;