2017-06-20 05:35:07

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH] watchdog: cadence_wdt: make of_device_ids const.

of_device_ids are not supposed to change at runtime. All functions
working with of_device_ids provided by <linux/of.h> work with const
of_device_ids. So mark the non-const structs as const.

File size before:
text data bss dec hex filename
1962 612 4 2578 a12 drivers/watchdog/cadence_wdt.o

File size after constify cdns_wdt_of_match:
text data bss dec hex filename
2378 196 4 2578 a12 drivers/watchdog/cadence_wdt.o

Signed-off-by: Arvind Yadav <[email protected]>
---
drivers/watchdog/cadence_wdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c
index 8d61e8b..4824b0a 100644
--- a/drivers/watchdog/cadence_wdt.c
+++ b/drivers/watchdog/cadence_wdt.c
@@ -458,7 +458,7 @@ static int __maybe_unused cdns_wdt_resume(struct device *dev)

static SIMPLE_DEV_PM_OPS(cdns_wdt_pm_ops, cdns_wdt_suspend, cdns_wdt_resume);

-static struct of_device_id cdns_wdt_of_match[] = {
+static const struct of_device_id cdns_wdt_of_match[] = {
{ .compatible = "cdns,wdt-r1p2", },
{ /* end of table */ }
};
--
1.9.1


2017-06-20 20:53:55

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH] watchdog: cadence_wdt: make of_device_ids const.

On Tue, Jun 20, 2017 at 11:04:26AM +0530, Arvind Yadav wrote:
> of_device_ids are not supposed to change at runtime. All functions
> working with of_device_ids provided by <linux/of.h> work with const
> of_device_ids. So mark the non-const structs as const.
>
> File size before:
> text data bss dec hex filename
> 1962 612 4 2578 a12 drivers/watchdog/cadence_wdt.o
>
> File size after constify cdns_wdt_of_match:
> text data bss dec hex filename
> 2378 196 4 2578 a12 drivers/watchdog/cadence_wdt.o
>
> Signed-off-by: Arvind Yadav <[email protected]>

Reviewed-by: Guenter Roeck <[email protected]>

> ---
> drivers/watchdog/cadence_wdt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c
> index 8d61e8b..4824b0a 100644
> --- a/drivers/watchdog/cadence_wdt.c
> +++ b/drivers/watchdog/cadence_wdt.c
> @@ -458,7 +458,7 @@ static int __maybe_unused cdns_wdt_resume(struct device *dev)
>
> static SIMPLE_DEV_PM_OPS(cdns_wdt_pm_ops, cdns_wdt_suspend, cdns_wdt_resume);
>
> -static struct of_device_id cdns_wdt_of_match[] = {
> +static const struct of_device_id cdns_wdt_of_match[] = {
> { .compatible = "cdns,wdt-r1p2", },
> { /* end of table */ }
> };
> --
> 1.9.1
>