pdata = pdev->dev.platform_data;
- info = kzalloc(sizeof(struct pm860x_rtc_info), GFP_KERNEL);
+ info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_rtc_info),
+ GFP_KERNEL);
if (!info)
return -ENOMEM;
info->irq = platform_get_irq(pdev, 0);
if (info->irq < 0) {
dev_err(&pdev->dev, "No IRQ resource!\n");
- ret = -EINVAL;
- goto out;
+ return info->irq;
}
info->chip = chip;
info->dev = &pdev->dev;
dev_set_drvdata(&pdev->dev, info);
- ret = request_threaded_irq(info->irq, NULL, rtc_update_handler,
- IRQF_ONESHOT, "rtc", info);
+ ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
+ rtc_update_handler, IRQF_ONESHOT, "rtc",
+ info);
if (ret < 0) {
dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
info->irq, ret);
- goto out;
+ return ret;
}
/* set addresses of 32-bit base value for RTC time */
ret = pm860x_rtc_read_time(&pdev->dev, &tm);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to read initial time.\n");
- goto out_rtc;
+ return ret;
}
if ((tm.tm_year < 70) || (tm.tm_year > 138)) {
tm.tm_year = 70;
ret = pm860x_rtc_set_time(&pdev->dev, &tm);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to set initial time.\n");
- goto out_rtc;
+ return ret;
}
}
rtc_tm_to_time(&tm, &ticks);
}
}
- info->rtc_dev = rtc_device_register("88pm860x-rtc", &pdev->dev,
+ info->rtc_dev = devm_rtc_device_register(&pdev->dev, "88pm860x-rtc",
&pm860x_rtc_ops, THIS_MODULE);
ret = PTR_ERR(info->rtc_dev);
if (IS_ERR(info->rtc_dev)) {
dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
- goto out_rtc;
+ return ret;
}
/*
device_init_wakeup(&pdev->dev, 1);
return 0;
-out_rtc:
- free_irq(info->irq, info);
-out:
- kfree(info);
- return ret;
}
static int pm860x_rtc_remove(struct platform_device *pdev)
#endif /* VRTC_CALIBRATION */
platform_set_drvdata(pdev, NULL);
- rtc_device_unregister(info->rtc_dev);
- free_irq(info->irq, info);
- kfree(info);
return 0;
}