Skip to content

Commit 29bf975

Browse files
richard-bootlinalexandrebelloni
authored andcommitted
rtc: tps6594: introduce private structure as drvdata
This patch will prepare for the next one (power management support) by introducing struct tps6594_rtc. No functionnal change. Signed-off-by: Richard Genoud <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 94d4154 commit 29bf975

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

drivers/rtc/rtc-tps6594.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
// Multiplier for ppb conversions
4343
#define PPB_MULT NANO
4444

45+
struct tps6594_rtc {
46+
struct rtc_device *rtc_dev;
47+
};
48+
4549
static int tps6594_rtc_alarm_irq_enable(struct device *dev,
4650
unsigned int enabled)
4751
{
@@ -325,19 +329,19 @@ static int tps6594_rtc_set_offset(struct device *dev, long offset)
325329
return tps6594_rtc_set_calibration(dev, calibration);
326330
}
327331

328-
static irqreturn_t tps6594_rtc_interrupt(int irq, void *rtc)
332+
static irqreturn_t tps6594_rtc_interrupt(int irq, void *data)
329333
{
330-
struct device *dev = rtc;
334+
struct device *dev = data;
331335
struct tps6594 *tps = dev_get_drvdata(dev->parent);
332-
struct rtc_device *rtc_dev = dev_get_drvdata(dev);
336+
struct tps6594_rtc *rtc = dev_get_drvdata(dev);
333337
int ret;
334338
u32 rtc_reg;
335339

336340
ret = regmap_read(tps->regmap, TPS6594_REG_RTC_STATUS, &rtc_reg);
337341
if (ret)
338342
return IRQ_NONE;
339343

340-
rtc_update_irq(rtc_dev, 1, RTC_IRQF | RTC_AF);
344+
rtc_update_irq(rtc->rtc_dev, 1, RTC_IRQF | RTC_AF);
341345

342346
return IRQ_HANDLED;
343347
}
@@ -356,13 +360,17 @@ static int tps6594_rtc_probe(struct platform_device *pdev)
356360
{
357361
struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent);
358362
struct device *dev = &pdev->dev;
359-
struct rtc_device *rtc;
363+
struct tps6594_rtc *rtc;
360364
int irq;
361365
int ret;
362366

363-
rtc = devm_rtc_allocate_device(dev);
364-
if (IS_ERR(rtc))
365-
return PTR_ERR(rtc);
367+
rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL);
368+
if (!rtc)
369+
return -ENOMEM;
370+
371+
rtc->rtc_dev = devm_rtc_allocate_device(dev);
372+
if (IS_ERR(rtc->rtc_dev))
373+
return PTR_ERR(rtc->rtc_dev);
366374

367375
// Enable crystal oscillator.
368376
ret = regmap_set_bits(tps->regmap, TPS6594_REG_RTC_CTRL_2,
@@ -423,11 +431,11 @@ static int tps6594_rtc_probe(struct platform_device *pdev)
423431
return dev_err_probe(dev, ret,
424432
"Failed to init rtc as wakeup source\n");
425433

426-
rtc->ops = &tps6594_rtc_ops;
427-
rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
428-
rtc->range_max = RTC_TIMESTAMP_END_2099;
434+
rtc->rtc_dev->ops = &tps6594_rtc_ops;
435+
rtc->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000;
436+
rtc->rtc_dev->range_max = RTC_TIMESTAMP_END_2099;
429437

430-
return devm_rtc_register_device(rtc);
438+
return devm_rtc_register_device(rtc->rtc_dev);
431439
}
432440

433441
static const struct platform_device_id tps6594_rtc_id_table[] = {

0 commit comments

Comments
 (0)