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

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Uwe Kleine-König and committed by
Wim Van Sebroeck
16d477a1 0e89b2c9

+12 -10
+12 -10
drivers/watchdog/s3c2410_wdt.c
··· 579 579 return 0; 580 580 } 581 581 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) 584 584 { 585 585 const struct s3c2410_wdt_variant *variant; 586 586 struct device *dev = &pdev->dev; ··· 603 603 "samsung,cluster-index", &index); 604 604 if (err) { 605 605 dev_err(dev, "failed to get cluster index\n"); 606 - return NULL; 606 + return -EINVAL; 607 607 } 608 608 609 609 switch (index) { 610 610 case 0: 611 - return variant; 611 + break; 612 612 case 1: 613 - return (variant == &drv_data_exynos850_cl0) ? 613 + variant = (variant == &drv_data_exynos850_cl0) ? 614 614 &drv_data_exynos850_cl1 : 615 615 &drv_data_exynosautov9_cl1; 616 + break; 616 617 default: 617 618 dev_err(dev, "wrong cluster index: %u\n", index); 618 - return NULL; 619 + return -EINVAL; 619 620 } 620 621 } 621 622 #endif 622 623 623 - return variant; 624 + wdt->drv_data = variant; 625 + return 0; 624 626 } 625 627 626 628 static void s3c2410wdt_wdt_disable_action(void *data) ··· 646 644 spin_lock_init(&wdt->lock); 647 645 wdt->wdt_device = s3c2410_wdd; 648 646 649 - wdt->drv_data = s3c2410_get_wdt_drv_data(pdev); 650 - if (!wdt->drv_data) 651 - return -EINVAL; 647 + ret = s3c2410_get_wdt_drv_data(pdev, wdt); 648 + if (ret) 649 + return ret; 652 650 653 651 if (wdt->drv_data->quirks & QUIRKS_HAVE_PMUREG) { 654 652 wdt->pmureg = syscon_regmap_lookup_by_phandle(dev->of_node,