Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: ds2404: simplify .probe and remove .remove

Use devm_add_action_or_reset to simplify .probe and remove .remove

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

+7 -18
+7 -18
drivers/rtc/rtc-ds2404.c
··· 72 72 return err; 73 73 } 74 74 75 - static void ds2404_gpio_unmap(struct ds2404 *chip) 75 + static void ds2404_gpio_unmap(void *data) 76 76 { 77 77 int i; 78 78 ··· 218 218 219 219 retval = ds2404_gpio_map(chip, pdev, pdata); 220 220 if (retval) 221 - goto err_chip; 221 + return retval; 222 + 223 + retval = devm_add_action_or_reset(&pdev->dev, ds2404_gpio_unmap, chip); 224 + if (retval) 225 + return retval; 222 226 223 227 dev_info(&pdev->dev, "using GPIOs RST:%d, CLK:%d, DQ:%d\n", 224 228 chip->gpio[DS2404_RST].gpio, chip->gpio[DS2404_CLK].gpio, ··· 235 231 236 232 retval = rtc_register_device(chip->rtc); 237 233 if (retval) 238 - goto err_io; 234 + return retval; 239 235 240 236 ds2404_enable_osc(&pdev->dev); 241 - return 0; 242 - 243 - err_io: 244 - ds2404_gpio_unmap(chip); 245 - err_chip: 246 - return retval; 247 - } 248 - 249 - static int rtc_remove(struct platform_device *dev) 250 - { 251 - struct ds2404 *chip = platform_get_drvdata(dev); 252 - 253 - ds2404_gpio_unmap(chip); 254 - 255 237 return 0; 256 238 } 257 239 258 240 static struct platform_driver rtc_device_driver = { 259 241 .probe = rtc_probe, 260 - .remove = rtc_remove, 261 242 .driver = { 262 243 .name = "ds2404", 263 244 },