Skip to content

Commit 16d477a

Browse files
Uwe Kleine-KönigWim Van Sebroeck
authored andcommitted
watchdog: s3c2410: Make s3c2410_get_wdt_drv_data() return an int
This is a preparation for making more use of dev_err_probe(). The idea is that s3c2410_get_wdt_drv_data() (as it's called only by .probe()) can make effective use of dev_err_probe() only if it returns an int. For that the assignment to wdt->drv_data has to happen in the function. The caller can then just pass on the return value in the error case. This seems to be nicer for the compiler: bloatometer reports for an ARCH=arm s3c6400_defconfig build: add/remove: 1/1 grow/shrink: 0/1 up/down: 4/-64 (-60) Function old new delta __initcall__kmod_s3c2410_wdt__209_821_s3c2410wdt_driver_init6 - 4 +4 __initcall__kmod_s3c2410_wdt__209_819_s3c2410wdt_driver_init6 4 - -4 s3c2410wdt_probe 1332 1272 -60 There is no semantical change. (Just one minor difference: Before this patch wdt->drv_data was always assigned, now that only happens in the non-error case. That doesn't matter however as *wdt is freed in the error case.) Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20230307065603.2253054-2-u.kleine-koenig@pengutronix.de Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
1 parent 0e89b2c commit 16d477a

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

drivers/watchdog/s3c2410_wdt.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,8 @@ static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt)
579579
return 0;
580580
}
581581

582-
static inline const struct s3c2410_wdt_variant *
583-
s3c2410_get_wdt_drv_data(struct platform_device *pdev)
582+
static inline int
583+
s3c2410_get_wdt_drv_data(struct platform_device *pdev, struct s3c2410_wdt *wdt)
584584
{
585585
const struct s3c2410_wdt_variant *variant;
586586
struct device *dev = &pdev->dev;
@@ -603,24 +603,26 @@ s3c2410_get_wdt_drv_data(struct platform_device *pdev)
603603
"samsung,cluster-index", &index);
604604
if (err) {
605605
dev_err(dev, "failed to get cluster index\n");
606-
return NULL;
606+
return -EINVAL;
607607
}
608608

609609
switch (index) {
610610
case 0:
611-
return variant;
611+
break;
612612
case 1:
613-
return (variant == &drv_data_exynos850_cl0) ?
613+
variant = (variant == &drv_data_exynos850_cl0) ?
614614
&drv_data_exynos850_cl1 :
615615
&drv_data_exynosautov9_cl1;
616+
break;
616617
default:
617618
dev_err(dev, "wrong cluster index: %u\n", index);
618-
return NULL;
619+
return -EINVAL;
619620
}
620621
}
621622
#endif
622623

623-
return variant;
624+
wdt->drv_data = variant;
625+
return 0;
624626
}
625627

626628
static void s3c2410wdt_wdt_disable_action(void *data)
@@ -644,9 +646,9 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
644646
spin_lock_init(&wdt->lock);
645647
wdt->wdt_device = s3c2410_wdd;
646648

647-
wdt->drv_data = s3c2410_get_wdt_drv_data(pdev);
648-
if (!wdt->drv_data)
649-
return -EINVAL;
649+
ret = s3c2410_get_wdt_drv_data(pdev, wdt);
650+
if (ret)
651+
return ret;
650652

651653
if (wdt->drv_data->quirks & QUIRKS_HAVE_PMUREG) {
652654
wdt->pmureg = syscon_regmap_lookup_by_phandle(dev->of_node,

0 commit comments

Comments
 (0)