diff options
author | Kefeng Wang <wangkefeng.wang@huawei.com> | 2019-04-23 03:50:16 -0400 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-04-29 09:53:43 -0400 |
commit | 527bd754d1ffc4bbd89a33c643e74c53d713eb4e (patch) | |
tree | f2adaae984ff1e29070cb40a8804ea387df3fd7e | |
parent | c8889bb6e62f17822419bd253a08c96aee963722 (diff) |
rtc: Use dev_get_drvdata()
Using dev_get_drvdata directly.
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
-rw-r--r-- | drivers/rtc/rtc-hid-sensor-time.c | 3 | ||||
-rw-r--r-- | drivers/rtc/rtc-pxa.c | 3 | ||||
-rw-r--r-- | drivers/rtc/rtc-rk808.c | 6 | ||||
-rw-r--r-- | drivers/rtc/rtc-tx4939.c | 17 | ||||
-rw-r--r-- | drivers/rtc/rtc-wm831x.c | 18 | ||||
-rw-r--r-- | drivers/rtc/rtc-wm8350.c | 12 |
6 files changed, 21 insertions, 38 deletions
diff --git a/drivers/rtc/rtc-hid-sensor-time.c b/drivers/rtc/rtc-hid-sensor-time.c index 3e1abb455472..f27c40e8331f 100644 --- a/drivers/rtc/rtc-hid-sensor-time.c +++ b/drivers/rtc/rtc-hid-sensor-time.c | |||
@@ -205,8 +205,7 @@ static int hid_time_parse_report(struct platform_device *pdev, | |||
205 | static int hid_rtc_read_time(struct device *dev, struct rtc_time *tm) | 205 | static int hid_rtc_read_time(struct device *dev, struct rtc_time *tm) |
206 | { | 206 | { |
207 | unsigned long flags; | 207 | unsigned long flags; |
208 | struct hid_time_state *time_state = | 208 | struct hid_time_state *time_state = dev_get_drvdata(dev); |
209 | platform_get_drvdata(to_platform_device(dev)); | ||
210 | int ret; | 209 | int ret; |
211 | 210 | ||
212 | reinit_completion(&time_state->comp_last_time); | 211 | reinit_completion(&time_state->comp_last_time); |
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index e1887b86fdc7..d4766734e40b 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -145,8 +145,7 @@ static void rtsr_set_bits(struct pxa_rtc *pxa_rtc, u32 mask) | |||
145 | 145 | ||
146 | static irqreturn_t pxa_rtc_irq(int irq, void *dev_id) | 146 | static irqreturn_t pxa_rtc_irq(int irq, void *dev_id) |
147 | { | 147 | { |
148 | struct platform_device *pdev = to_platform_device(dev_id); | 148 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev_id); |
149 | struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); | ||
150 | u32 rtsr; | 149 | u32 rtsr; |
151 | unsigned long events = 0; | 150 | unsigned long events = 0; |
152 | 151 | ||
diff --git a/drivers/rtc/rtc-rk808.c b/drivers/rtc/rtc-rk808.c index 1fb864d4ef83..5c5d9f125669 100644 --- a/drivers/rtc/rtc-rk808.c +++ b/drivers/rtc/rtc-rk808.c | |||
@@ -336,8 +336,7 @@ static const struct rtc_class_ops rk808_rtc_ops = { | |||
336 | /* Turn off the alarm if it should not be a wake source. */ | 336 | /* Turn off the alarm if it should not be a wake source. */ |
337 | static int rk808_rtc_suspend(struct device *dev) | 337 | static int rk808_rtc_suspend(struct device *dev) |
338 | { | 338 | { |
339 | struct platform_device *pdev = to_platform_device(dev); | 339 | struct rk808_rtc *rk808_rtc = dev_get_drvdata(dev); |
340 | struct rk808_rtc *rk808_rtc = dev_get_drvdata(&pdev->dev); | ||
341 | 340 | ||
342 | if (device_may_wakeup(dev)) | 341 | if (device_may_wakeup(dev)) |
343 | enable_irq_wake(rk808_rtc->irq); | 342 | enable_irq_wake(rk808_rtc->irq); |
@@ -350,8 +349,7 @@ static int rk808_rtc_suspend(struct device *dev) | |||
350 | */ | 349 | */ |
351 | static int rk808_rtc_resume(struct device *dev) | 350 | static int rk808_rtc_resume(struct device *dev) |
352 | { | 351 | { |
353 | struct platform_device *pdev = to_platform_device(dev); | 352 | struct rk808_rtc *rk808_rtc = dev_get_drvdata(dev); |
354 | struct rk808_rtc *rk808_rtc = dev_get_drvdata(&pdev->dev); | ||
355 | 353 | ||
356 | if (device_may_wakeup(dev)) | 354 | if (device_may_wakeup(dev)) |
357 | disable_irq_wake(rk808_rtc->irq); | 355 | disable_irq_wake(rk808_rtc->irq); |
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c index 2d24babc4057..5a29915a06ec 100644 --- a/drivers/rtc/rtc-tx4939.c +++ b/drivers/rtc/rtc-tx4939.c | |||
@@ -42,11 +42,6 @@ struct tx4939rtc_plat_data { | |||
42 | spinlock_t lock; | 42 | spinlock_t lock; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | static struct tx4939rtc_plat_data *get_tx4939rtc_plat_data(struct device *dev) | ||
46 | { | ||
47 | return platform_get_drvdata(to_platform_device(dev)); | ||
48 | } | ||
49 | |||
50 | static int tx4939_rtc_cmd(struct tx4939_rtc_reg __iomem *rtcreg, int cmd) | 45 | static int tx4939_rtc_cmd(struct tx4939_rtc_reg __iomem *rtcreg, int cmd) |
51 | { | 46 | { |
52 | int i = 0; | 47 | int i = 0; |
@@ -64,7 +59,7 @@ static int tx4939_rtc_cmd(struct tx4939_rtc_reg __iomem *rtcreg, int cmd) | |||
64 | 59 | ||
65 | static int tx4939_rtc_set_time(struct device *dev, struct rtc_time *tm) | 60 | static int tx4939_rtc_set_time(struct device *dev, struct rtc_time *tm) |
66 | { | 61 | { |
67 | struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev); | 62 | struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev); |
68 | struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; | 63 | struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; |
69 | unsigned long secs = rtc_tm_to_time64(tm); | 64 | unsigned long secs = rtc_tm_to_time64(tm); |
70 | int i, ret; | 65 | int i, ret; |
@@ -89,7 +84,7 @@ static int tx4939_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
89 | 84 | ||
90 | static int tx4939_rtc_read_time(struct device *dev, struct rtc_time *tm) | 85 | static int tx4939_rtc_read_time(struct device *dev, struct rtc_time *tm) |
91 | { | 86 | { |
92 | struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev); | 87 | struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev); |
93 | struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; | 88 | struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; |
94 | int i, ret; | 89 | int i, ret; |
95 | unsigned long sec; | 90 | unsigned long sec; |
@@ -115,7 +110,7 @@ static int tx4939_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
115 | 110 | ||
116 | static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 111 | static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
117 | { | 112 | { |
118 | struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev); | 113 | struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev); |
119 | struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; | 114 | struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; |
120 | int i, ret; | 115 | int i, ret; |
121 | unsigned long sec; | 116 | unsigned long sec; |
@@ -140,7 +135,7 @@ static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
140 | 135 | ||
141 | static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 136 | static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
142 | { | 137 | { |
143 | struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev); | 138 | struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev); |
144 | struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; | 139 | struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; |
145 | int i, ret; | 140 | int i, ret; |
146 | unsigned long sec; | 141 | unsigned long sec; |
@@ -170,7 +165,7 @@ static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
170 | 165 | ||
171 | static int tx4939_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 166 | static int tx4939_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
172 | { | 167 | { |
173 | struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev); | 168 | struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev); |
174 | 169 | ||
175 | spin_lock_irq(&pdata->lock); | 170 | spin_lock_irq(&pdata->lock); |
176 | tx4939_rtc_cmd(pdata->rtcreg, | 171 | tx4939_rtc_cmd(pdata->rtcreg, |
@@ -182,7 +177,7 @@ static int tx4939_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
182 | 177 | ||
183 | static irqreturn_t tx4939_rtc_interrupt(int irq, void *dev_id) | 178 | static irqreturn_t tx4939_rtc_interrupt(int irq, void *dev_id) |
184 | { | 179 | { |
185 | struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev_id); | 180 | struct tx4939rtc_plat_data *pdata = dev_get_drvdata(dev_id); |
186 | struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; | 181 | struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; |
187 | unsigned long events = RTC_IRQF; | 182 | unsigned long events = RTC_IRQF; |
188 | 183 | ||
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c index ed29f4df2a3c..d2e8b21c90c4 100644 --- a/drivers/rtc/rtc-wm831x.c +++ b/drivers/rtc/rtc-wm831x.c | |||
@@ -346,11 +346,10 @@ static const struct rtc_class_ops wm831x_rtc_ops = { | |||
346 | /* Turn off the alarm if it should not be a wake source. */ | 346 | /* Turn off the alarm if it should not be a wake source. */ |
347 | static int wm831x_rtc_suspend(struct device *dev) | 347 | static int wm831x_rtc_suspend(struct device *dev) |
348 | { | 348 | { |
349 | struct platform_device *pdev = to_platform_device(dev); | 349 | struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev); |
350 | struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(&pdev->dev); | ||
351 | int ret, enable; | 350 | int ret, enable; |
352 | 351 | ||
353 | if (wm831x_rtc->alarm_enabled && device_may_wakeup(&pdev->dev)) | 352 | if (wm831x_rtc->alarm_enabled && device_may_wakeup(dev)) |
354 | enable = WM831X_RTC_ALM_ENA; | 353 | enable = WM831X_RTC_ALM_ENA; |
355 | else | 354 | else |
356 | enable = 0; | 355 | enable = 0; |
@@ -358,7 +357,7 @@ static int wm831x_rtc_suspend(struct device *dev) | |||
358 | ret = wm831x_set_bits(wm831x_rtc->wm831x, WM831X_RTC_CONTROL, | 357 | ret = wm831x_set_bits(wm831x_rtc->wm831x, WM831X_RTC_CONTROL, |
359 | WM831X_RTC_ALM_ENA, enable); | 358 | WM831X_RTC_ALM_ENA, enable); |
360 | if (ret != 0) | 359 | if (ret != 0) |
361 | dev_err(&pdev->dev, "Failed to update RTC alarm: %d\n", ret); | 360 | dev_err(dev, "Failed to update RTC alarm: %d\n", ret); |
362 | 361 | ||
363 | return 0; | 362 | return 0; |
364 | } | 363 | } |
@@ -368,15 +367,13 @@ static int wm831x_rtc_suspend(struct device *dev) | |||
368 | */ | 367 | */ |
369 | static int wm831x_rtc_resume(struct device *dev) | 368 | static int wm831x_rtc_resume(struct device *dev) |
370 | { | 369 | { |
371 | struct platform_device *pdev = to_platform_device(dev); | 370 | struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev); |
372 | struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(&pdev->dev); | ||
373 | int ret; | 371 | int ret; |
374 | 372 | ||
375 | if (wm831x_rtc->alarm_enabled) { | 373 | if (wm831x_rtc->alarm_enabled) { |
376 | ret = wm831x_rtc_start_alarm(wm831x_rtc); | 374 | ret = wm831x_rtc_start_alarm(wm831x_rtc); |
377 | if (ret != 0) | 375 | if (ret != 0) |
378 | dev_err(&pdev->dev, | 376 | dev_err(dev, "Failed to restart RTC alarm: %d\n", ret); |
379 | "Failed to restart RTC alarm: %d\n", ret); | ||
380 | } | 377 | } |
381 | 378 | ||
382 | return 0; | 379 | return 0; |
@@ -385,14 +382,13 @@ static int wm831x_rtc_resume(struct device *dev) | |||
385 | /* Unconditionally disable the alarm */ | 382 | /* Unconditionally disable the alarm */ |
386 | static int wm831x_rtc_freeze(struct device *dev) | 383 | static int wm831x_rtc_freeze(struct device *dev) |
387 | { | 384 | { |
388 | struct platform_device *pdev = to_platform_device(dev); | 385 | struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev); |
389 | struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(&pdev->dev); | ||
390 | int ret; | 386 | int ret; |
391 | 387 | ||
392 | ret = wm831x_set_bits(wm831x_rtc->wm831x, WM831X_RTC_CONTROL, | 388 | ret = wm831x_set_bits(wm831x_rtc->wm831x, WM831X_RTC_CONTROL, |
393 | WM831X_RTC_ALM_ENA, 0); | 389 | WM831X_RTC_ALM_ENA, 0); |
394 | if (ret != 0) | 390 | if (ret != 0) |
395 | dev_err(&pdev->dev, "Failed to stop RTC alarm: %d\n", ret); | 391 | dev_err(dev, "Failed to stop RTC alarm: %d\n", ret); |
396 | 392 | ||
397 | return 0; | 393 | return 0; |
398 | } | 394 | } |
diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c index 483c7993516b..f54fa12c4b4b 100644 --- a/drivers/rtc/rtc-wm8350.c +++ b/drivers/rtc/rtc-wm8350.c | |||
@@ -340,8 +340,7 @@ static const struct rtc_class_ops wm8350_rtc_ops = { | |||
340 | #ifdef CONFIG_PM_SLEEP | 340 | #ifdef CONFIG_PM_SLEEP |
341 | static int wm8350_rtc_suspend(struct device *dev) | 341 | static int wm8350_rtc_suspend(struct device *dev) |
342 | { | 342 | { |
343 | struct platform_device *pdev = to_platform_device(dev); | 343 | struct wm8350 *wm8350 = dev_get_drvdata(dev); |
344 | struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev); | ||
345 | int ret = 0; | 344 | int ret = 0; |
346 | u16 reg; | 345 | u16 reg; |
347 | 346 | ||
@@ -351,8 +350,7 @@ static int wm8350_rtc_suspend(struct device *dev) | |||
351 | reg & WM8350_RTC_ALMSTS) { | 350 | reg & WM8350_RTC_ALMSTS) { |
352 | ret = wm8350_rtc_stop_alarm(wm8350); | 351 | ret = wm8350_rtc_stop_alarm(wm8350); |
353 | if (ret != 0) | 352 | if (ret != 0) |
354 | dev_err(&pdev->dev, "Failed to stop RTC alarm: %d\n", | 353 | dev_err(dev, "Failed to stop RTC alarm: %d\n", ret); |
355 | ret); | ||
356 | } | 354 | } |
357 | 355 | ||
358 | return ret; | 356 | return ret; |
@@ -360,15 +358,13 @@ static int wm8350_rtc_suspend(struct device *dev) | |||
360 | 358 | ||
361 | static int wm8350_rtc_resume(struct device *dev) | 359 | static int wm8350_rtc_resume(struct device *dev) |
362 | { | 360 | { |
363 | struct platform_device *pdev = to_platform_device(dev); | 361 | struct wm8350 *wm8350 = dev_get_drvdata(dev); |
364 | struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev); | ||
365 | int ret; | 362 | int ret; |
366 | 363 | ||
367 | if (wm8350->rtc.alarm_enabled) { | 364 | if (wm8350->rtc.alarm_enabled) { |
368 | ret = wm8350_rtc_start_alarm(wm8350); | 365 | ret = wm8350_rtc_start_alarm(wm8350); |
369 | if (ret != 0) | 366 | if (ret != 0) |
370 | dev_err(&pdev->dev, | 367 | dev_err(dev, "Failed to restart RTC alarm: %d\n", ret); |
371 | "Failed to restart RTC alarm: %d\n", ret); | ||
372 | } | 368 | } |
373 | 369 | ||
374 | return 0; | 370 | return 0; |