rtc-ds2404.c (c7ac260fe76fa69caa62fe8e7eef544f7962bf33) | rtc-ds2404.c (d9aa5ca429ad30dde96e5966173d18004f16f312) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2// Copyright (C) 2012 Sven Schnelle <svens@stackframe.org> 3 4#include <linux/platform_device.h> 5#include <linux/module.h> 6#include <linux/init.h> 7#include <linux/rtc.h> 8#include <linux/types.h> --- 58 unchanged lines hidden (view full) --- 67 return 0; 68 69err_request: 70 while (--i >= 0) 71 gpio_free(ds2404_gpio[i].gpio); 72 return err; 73} 74 | 1// SPDX-License-Identifier: GPL-2.0 2// Copyright (C) 2012 Sven Schnelle <svens@stackframe.org> 3 4#include <linux/platform_device.h> 5#include <linux/module.h> 6#include <linux/init.h> 7#include <linux/rtc.h> 8#include <linux/types.h> --- 58 unchanged lines hidden (view full) --- 67 return 0; 68 69err_request: 70 while (--i >= 0) 71 gpio_free(ds2404_gpio[i].gpio); 72 return err; 73} 74 |
75static void ds2404_gpio_unmap(struct ds2404 *chip) | 75static void ds2404_gpio_unmap(void *data) |
76{ 77 int i; 78 79 for (i = 0; i < ARRAY_SIZE(ds2404_gpio); i++) 80 gpio_free(ds2404_gpio[i].gpio); 81} 82 83static void ds2404_reset(struct device *dev) --- 129 unchanged lines hidden (view full) --- 213 return -ENOMEM; 214 215 chip->rtc = devm_rtc_allocate_device(&pdev->dev); 216 if (IS_ERR(chip->rtc)) 217 return PTR_ERR(chip->rtc); 218 219 retval = ds2404_gpio_map(chip, pdev, pdata); 220 if (retval) | 76{ 77 int i; 78 79 for (i = 0; i < ARRAY_SIZE(ds2404_gpio); i++) 80 gpio_free(ds2404_gpio[i].gpio); 81} 82 83static void ds2404_reset(struct device *dev) --- 129 unchanged lines hidden (view full) --- 213 return -ENOMEM; 214 215 chip->rtc = devm_rtc_allocate_device(&pdev->dev); 216 if (IS_ERR(chip->rtc)) 217 return PTR_ERR(chip->rtc); 218 219 retval = ds2404_gpio_map(chip, pdev, pdata); 220 if (retval) |
221 goto err_chip; | 221 return retval; |
222 | 222 |
223 retval = devm_add_action_or_reset(&pdev->dev, ds2404_gpio_unmap, chip); 224 if (retval) 225 return retval; 226 |
|
223 dev_info(&pdev->dev, "using GPIOs RST:%d, CLK:%d, DQ:%d\n", 224 chip->gpio[DS2404_RST].gpio, chip->gpio[DS2404_CLK].gpio, 225 chip->gpio[DS2404_DQ].gpio); 226 227 platform_set_drvdata(pdev, chip); 228 229 chip->rtc->ops = &ds2404_rtc_ops; 230 chip->rtc->range_max = U32_MAX; 231 232 retval = rtc_register_device(chip->rtc); 233 if (retval) | 227 dev_info(&pdev->dev, "using GPIOs RST:%d, CLK:%d, DQ:%d\n", 228 chip->gpio[DS2404_RST].gpio, chip->gpio[DS2404_CLK].gpio, 229 chip->gpio[DS2404_DQ].gpio); 230 231 platform_set_drvdata(pdev, chip); 232 233 chip->rtc->ops = &ds2404_rtc_ops; 234 chip->rtc->range_max = U32_MAX; 235 236 retval = rtc_register_device(chip->rtc); 237 if (retval) |
234 goto err_io; | 238 return retval; |
235 236 ds2404_enable_osc(&pdev->dev); 237 return 0; | 239 240 ds2404_enable_osc(&pdev->dev); 241 return 0; |
238 239err_io: 240 ds2404_gpio_unmap(chip); 241err_chip: 242 return retval; | |
243} 244 | 242} 243 |
245static int rtc_remove(struct platform_device *dev) 246{ 247 struct ds2404 *chip = platform_get_drvdata(dev); 248 249 ds2404_gpio_unmap(chip); 250 251 return 0; 252} 253 | |
254static struct platform_driver rtc_device_driver = { 255 .probe = rtc_probe, | 244static struct platform_driver rtc_device_driver = { 245 .probe = rtc_probe, |
256 .remove = rtc_remove, | |
257 .driver = { 258 .name = "ds2404", 259 }, 260}; 261module_platform_driver(rtc_device_driver); 262 263MODULE_DESCRIPTION("DS2404 RTC"); 264MODULE_AUTHOR("Sven Schnelle"); 265MODULE_LICENSE("GPL"); 266MODULE_ALIAS("platform:ds2404"); | 246 .driver = { 247 .name = "ds2404", 248 }, 249}; 250module_platform_driver(rtc_device_driver); 251 252MODULE_DESCRIPTION("DS2404 RTC"); 253MODULE_AUTHOR("Sven Schnelle"); 254MODULE_LICENSE("GPL"); 255MODULE_ALIAS("platform:ds2404"); |