]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rtc: max77686: use dev_err_probe() where appropriate
authorAndré Draszik <andre.draszik@linaro.org>
Tue, 4 Mar 2025 17:05:43 +0000 (17:05 +0000)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 5 Mar 2025 22:08:01 +0000 (23:08 +0100)
dev_err_probe() exists to simplify code and harmonise error messages,
there's no reason not to use it here.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>
Link: https://lore.kernel.org/r/20250304-rtc-cleanups-v2-15-d4689a71668c@linaro.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-max77686.c

index 6b0d02b44c8097453f704cbec9f02580fb869ca3..69ea3ce75b5a5426d4a56b979773be71c4ee7562 100644 (file)
@@ -704,10 +704,9 @@ static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
        }
 
        info->regmap = dev_get_regmap(parent, NULL);
-       if (!info->regmap) {
-               dev_err(info->dev, "Failed to get rtc regmap\n");
-               return -ENODEV;
-       }
+       if (!info->regmap)
+               return dev_err_probe(info->dev, -ENODEV,
+                                    "Failed to get rtc regmap\n");
 
        if (info->drv_data->rtc_i2c_addr == MAX77686_INVALID_I2C_ADDR) {
                info->rtc_regmap = info->regmap;
@@ -716,28 +715,24 @@ static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
 
        client = devm_i2c_new_dummy_device(info->dev, parent_i2c->adapter,
                                           info->drv_data->rtc_i2c_addr);
-       if (IS_ERR(client)) {
-               dev_err(info->dev, "Failed to allocate I2C device for RTC\n");
-               return PTR_ERR(client);
-       }
+       if (IS_ERR(client))
+               return dev_err_probe(info->dev, PTR_ERR(client),
+                                    "Failed to allocate I2C device for RTC\n");
 
        info->rtc_regmap = devm_regmap_init_i2c(client,
                                                info->drv_data->regmap_config);
-       if (IS_ERR(info->rtc_regmap)) {
-               ret = PTR_ERR(info->rtc_regmap);
-               dev_err(info->dev, "Failed to allocate RTC regmap: %d\n", ret);
-               return ret;
-       }
+       if (IS_ERR(info->rtc_regmap))
+               return dev_err_probe(info->dev, PTR_ERR(info->rtc_regmap),
+                                    "Failed to allocate RTC regmap\n");
 
 add_rtc_irq:
        ret = regmap_add_irq_chip(info->rtc_regmap, info->rtc_irq,
                                  IRQF_ONESHOT | IRQF_SHARED,
                                  0, info->drv_data->rtc_irq_chip,
                                  &info->rtc_irq_data);
-       if (ret < 0) {
-               dev_err(info->dev, "Failed to add RTC irq chip: %d\n", ret);
-               return ret;
-       }
+       if (ret < 0)
+               return dev_err_probe(info->dev, ret,
+                                    "Failed to add RTC irq chip\n");
 
        return 0;
 }