42
42
// Multiplier for ppb conversions
43
43
#define PPB_MULT NANO
44
44
45
+ struct tps6594_rtc {
46
+ struct rtc_device * rtc_dev ;
47
+ };
48
+
45
49
static int tps6594_rtc_alarm_irq_enable (struct device * dev ,
46
50
unsigned int enabled )
47
51
{
@@ -325,19 +329,19 @@ static int tps6594_rtc_set_offset(struct device *dev, long offset)
325
329
return tps6594_rtc_set_calibration (dev , calibration );
326
330
}
327
331
328
- static irqreturn_t tps6594_rtc_interrupt (int irq , void * rtc )
332
+ static irqreturn_t tps6594_rtc_interrupt (int irq , void * data )
329
333
{
330
- struct device * dev = rtc ;
334
+ struct device * dev = data ;
331
335
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 );
333
337
int ret ;
334
338
u32 rtc_reg ;
335
339
336
340
ret = regmap_read (tps -> regmap , TPS6594_REG_RTC_STATUS , & rtc_reg );
337
341
if (ret )
338
342
return IRQ_NONE ;
339
343
340
- rtc_update_irq (rtc_dev , 1 , RTC_IRQF | RTC_AF );
344
+ rtc_update_irq (rtc -> rtc_dev , 1 , RTC_IRQF | RTC_AF );
341
345
342
346
return IRQ_HANDLED ;
343
347
}
@@ -356,13 +360,17 @@ static int tps6594_rtc_probe(struct platform_device *pdev)
356
360
{
357
361
struct tps6594 * tps = dev_get_drvdata (pdev -> dev .parent );
358
362
struct device * dev = & pdev -> dev ;
359
- struct rtc_device * rtc ;
363
+ struct tps6594_rtc * rtc ;
360
364
int irq ;
361
365
int ret ;
362
366
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 );
366
374
367
375
// Enable crystal oscillator.
368
376
ret = regmap_set_bits (tps -> regmap , TPS6594_REG_RTC_CTRL_2 ,
@@ -423,11 +431,11 @@ static int tps6594_rtc_probe(struct platform_device *pdev)
423
431
return dev_err_probe (dev , ret ,
424
432
"Failed to init rtc as wakeup source\n" );
425
433
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 ;
429
437
430
- return devm_rtc_register_device (rtc );
438
+ return devm_rtc_register_device (rtc -> rtc_dev );
431
439
}
432
440
433
441
static const struct platform_device_id tps6594_rtc_id_table [] = {
0 commit comments