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>
This commit is contained in:
parent
c8889bb6e6
commit
527bd754d1
|
@ -205,8 +205,7 @@ static int hid_time_parse_report(struct platform_device *pdev,
|
|||
static int hid_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct hid_time_state *time_state =
|
||||
platform_get_drvdata(to_platform_device(dev));
|
||||
struct hid_time_state *time_state = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
reinit_completion(&time_state->comp_last_time);
|
||||
|
|
|
@ -145,8 +145,7 @@ static void rtsr_set_bits(struct pxa_rtc *pxa_rtc, u32 mask)
|
|||
|
||||
static irqreturn_t pxa_rtc_irq(int irq, void *dev_id)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev_id);
|
||||
struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev);
|
||||
struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev_id);
|
||||
u32 rtsr;
|
||||
unsigned long events = 0;
|
||||
|
||||
|
|
|
@ -336,8 +336,7 @@ static const struct rtc_class_ops rk808_rtc_ops = {
|
|||
/* Turn off the alarm if it should not be a wake source. */
|
||||
static int rk808_rtc_suspend(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct rk808_rtc *rk808_rtc = dev_get_drvdata(&pdev->dev);
|
||||
struct rk808_rtc *rk808_rtc = dev_get_drvdata(dev);
|
||||
|
||||
if (device_may_wakeup(dev))
|
||||
enable_irq_wake(rk808_rtc->irq);
|
||||
|
@ -350,8 +349,7 @@ static int rk808_rtc_suspend(struct device *dev)
|
|||
*/
|
||||
static int rk808_rtc_resume(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct rk808_rtc *rk808_rtc = dev_get_drvdata(&pdev->dev);
|
||||
struct rk808_rtc *rk808_rtc = dev_get_drvdata(dev);
|
||||
|
||||
if (device_may_wakeup(dev))
|
||||
disable_irq_wake(rk808_rtc->irq);
|
||||
|
|
|
@ -42,11 +42,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;
|
||||
|
@ -64,7 +59,7 @@ static int tx4939_rtc_cmd(struct tx4939_rtc_reg __iomem *rtcreg, int cmd)
|
|||
|
||||
static int tx4939_rtc_set_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;
|
||||
unsigned long secs = rtc_tm_to_time64(tm);
|
||||
int i, ret;
|
||||
|
@ -89,7 +84,7 @@ static int tx4939_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
|||
|
||||
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;
|
||||
|
@ -115,7 +110,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;
|
||||
|
@ -140,7 +135,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;
|
||||
|
@ -170,7 +165,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,
|
||||
|
@ -182,7 +177,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;
|
||||
|
||||
|
|
|
@ -346,11 +346,10 @@ static const struct rtc_class_ops wm831x_rtc_ops = {
|
|||
/* Turn off the alarm if it should not be a wake source. */
|
||||
static int wm831x_rtc_suspend(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(&pdev->dev);
|
||||
struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev);
|
||||
int ret, enable;
|
||||
|
||||
if (wm831x_rtc->alarm_enabled && device_may_wakeup(&pdev->dev))
|
||||
if (wm831x_rtc->alarm_enabled && device_may_wakeup(dev))
|
||||
enable = WM831X_RTC_ALM_ENA;
|
||||
else
|
||||
enable = 0;
|
||||
|
@ -358,7 +357,7 @@ static int wm831x_rtc_suspend(struct device *dev)
|
|||
ret = wm831x_set_bits(wm831x_rtc->wm831x, WM831X_RTC_CONTROL,
|
||||
WM831X_RTC_ALM_ENA, enable);
|
||||
if (ret != 0)
|
||||
dev_err(&pdev->dev, "Failed to update RTC alarm: %d\n", ret);
|
||||
dev_err(dev, "Failed to update RTC alarm: %d\n", ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -368,15 +367,13 @@ static int wm831x_rtc_suspend(struct device *dev)
|
|||
*/
|
||||
static int wm831x_rtc_resume(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(&pdev->dev);
|
||||
struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
if (wm831x_rtc->alarm_enabled) {
|
||||
ret = wm831x_rtc_start_alarm(wm831x_rtc);
|
||||
if (ret != 0)
|
||||
dev_err(&pdev->dev,
|
||||
"Failed to restart RTC alarm: %d\n", ret);
|
||||
dev_err(dev, "Failed to restart RTC alarm: %d\n", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -385,14 +382,13 @@ static int wm831x_rtc_resume(struct device *dev)
|
|||
/* Unconditionally disable the alarm */
|
||||
static int wm831x_rtc_freeze(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(&pdev->dev);
|
||||
struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
ret = wm831x_set_bits(wm831x_rtc->wm831x, WM831X_RTC_CONTROL,
|
||||
WM831X_RTC_ALM_ENA, 0);
|
||||
if (ret != 0)
|
||||
dev_err(&pdev->dev, "Failed to stop RTC alarm: %d\n", ret);
|
||||
dev_err(dev, "Failed to stop RTC alarm: %d\n", ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -340,8 +340,7 @@ static const struct rtc_class_ops wm8350_rtc_ops = {
|
|||
#ifdef CONFIG_PM_SLEEP
|
||||
static int wm8350_rtc_suspend(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev);
|
||||
struct wm8350 *wm8350 = dev_get_drvdata(dev);
|
||||
int ret = 0;
|
||||
u16 reg;
|
||||
|
||||
|
@ -351,8 +350,7 @@ static int wm8350_rtc_suspend(struct device *dev)
|
|||
reg & WM8350_RTC_ALMSTS) {
|
||||
ret = wm8350_rtc_stop_alarm(wm8350);
|
||||
if (ret != 0)
|
||||
dev_err(&pdev->dev, "Failed to stop RTC alarm: %d\n",
|
||||
ret);
|
||||
dev_err(dev, "Failed to stop RTC alarm: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -360,15 +358,13 @@ static int wm8350_rtc_suspend(struct device *dev)
|
|||
|
||||
static int wm8350_rtc_resume(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev);
|
||||
struct wm8350 *wm8350 = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
if (wm8350->rtc.alarm_enabled) {
|
||||
ret = wm8350_rtc_start_alarm(wm8350);
|
||||
if (ret != 0)
|
||||
dev_err(&pdev->dev,
|
||||
"Failed to restart RTC alarm: %d\n", ret);
|
||||
dev_err(dev, "Failed to restart RTC alarm: %d\n", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user