* [PATCH] watchdog: sunxi_wdt: use of_device_get_match_data
@ 2017-10-21 17:45 ` Corentin Labbe
0 siblings, 0 replies; 4+ messages in thread
From: Corentin Labbe @ 2017-10-21 17:45 UTC (permalink / raw)
To: wim, linux, maxime.ripard, wens
Cc: linux-watchdog, linux-arm-kernel, linux-kernel, Corentin Labbe
The usage of of_device_get_match_data reduce the code size a bit.
Furthermore, it prevents an improbable dereference when
of_match_device() return NULL.
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
drivers/watchdog/sunxi_wdt.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c
index 9728fa32c357..802e31b1416d 100644
--- a/drivers/watchdog/sunxi_wdt.c
+++ b/drivers/watchdog/sunxi_wdt.c
@@ -234,7 +234,6 @@ MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids);
static int sunxi_wdt_probe(struct platform_device *pdev)
{
struct sunxi_wdt_dev *sunxi_wdt;
- const struct of_device_id *device;
struct resource *res;
int err;
@@ -242,12 +241,10 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
if (!sunxi_wdt)
return -EINVAL;
- device = of_match_device(sunxi_wdt_dt_ids, &pdev->dev);
- if (!device)
+ sunxi_wdt->wdt_regs = of_device_get_match_data(&pdev->dev);
+ if (!sunxi_wdt->wdt_regs)
return -ENODEV;
- sunxi_wdt->wdt_regs = device->data;
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
sunxi_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(sunxi_wdt->wdt_base))
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] watchdog: sunxi_wdt: use of_device_get_match_data
@ 2017-10-21 17:45 ` Corentin Labbe
0 siblings, 0 replies; 4+ messages in thread
From: Corentin Labbe @ 2017-10-21 17:45 UTC (permalink / raw)
To: linux-arm-kernel
The usage of of_device_get_match_data reduce the code size a bit.
Furthermore, it prevents an improbable dereference when
of_match_device() return NULL.
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
drivers/watchdog/sunxi_wdt.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c
index 9728fa32c357..802e31b1416d 100644
--- a/drivers/watchdog/sunxi_wdt.c
+++ b/drivers/watchdog/sunxi_wdt.c
@@ -234,7 +234,6 @@ MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids);
static int sunxi_wdt_probe(struct platform_device *pdev)
{
struct sunxi_wdt_dev *sunxi_wdt;
- const struct of_device_id *device;
struct resource *res;
int err;
@@ -242,12 +241,10 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
if (!sunxi_wdt)
return -EINVAL;
- device = of_match_device(sunxi_wdt_dt_ids, &pdev->dev);
- if (!device)
+ sunxi_wdt->wdt_regs = of_device_get_match_data(&pdev->dev);
+ if (!sunxi_wdt->wdt_regs)
return -ENODEV;
- sunxi_wdt->wdt_regs = device->data;
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
sunxi_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(sunxi_wdt->wdt_base))
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: watchdog: sunxi_wdt: use of_device_get_match_data
2017-10-21 17:45 ` Corentin Labbe
@ 2017-10-22 17:44 ` Guenter Roeck
-1 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2017-10-22 17:44 UTC (permalink / raw)
To: Corentin Labbe
Cc: wim, maxime.ripard, wens, linux-watchdog, linux-arm-kernel, linux-kernel
On Sat, Oct 21, 2017 at 07:45:13PM +0200, Corentin Labbe wrote:
> The usage of of_device_get_match_data reduce the code size a bit.
> Furthermore, it prevents an improbable dereference when
> of_match_device() return NULL.
>
> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/watchdog/sunxi_wdt.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c
> index 9728fa32c357..802e31b1416d 100644
> --- a/drivers/watchdog/sunxi_wdt.c
> +++ b/drivers/watchdog/sunxi_wdt.c
> @@ -234,7 +234,6 @@ MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids);
> static int sunxi_wdt_probe(struct platform_device *pdev)
> {
> struct sunxi_wdt_dev *sunxi_wdt;
> - const struct of_device_id *device;
> struct resource *res;
> int err;
>
> @@ -242,12 +241,10 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
> if (!sunxi_wdt)
> return -EINVAL;
>
> - device = of_match_device(sunxi_wdt_dt_ids, &pdev->dev);
> - if (!device)
> + sunxi_wdt->wdt_regs = of_device_get_match_data(&pdev->dev);
> + if (!sunxi_wdt->wdt_regs)
> return -ENODEV;
>
> - sunxi_wdt->wdt_regs = device->data;
> -
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> sunxi_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res);
> if (IS_ERR(sunxi_wdt->wdt_base))
^ permalink raw reply [flat|nested] 4+ messages in thread
* watchdog: sunxi_wdt: use of_device_get_match_data
@ 2017-10-22 17:44 ` Guenter Roeck
0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2017-10-22 17:44 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Oct 21, 2017 at 07:45:13PM +0200, Corentin Labbe wrote:
> The usage of of_device_get_match_data reduce the code size a bit.
> Furthermore, it prevents an improbable dereference when
> of_match_device() return NULL.
>
> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/watchdog/sunxi_wdt.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c
> index 9728fa32c357..802e31b1416d 100644
> --- a/drivers/watchdog/sunxi_wdt.c
> +++ b/drivers/watchdog/sunxi_wdt.c
> @@ -234,7 +234,6 @@ MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids);
> static int sunxi_wdt_probe(struct platform_device *pdev)
> {
> struct sunxi_wdt_dev *sunxi_wdt;
> - const struct of_device_id *device;
> struct resource *res;
> int err;
>
> @@ -242,12 +241,10 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
> if (!sunxi_wdt)
> return -EINVAL;
>
> - device = of_match_device(sunxi_wdt_dt_ids, &pdev->dev);
> - if (!device)
> + sunxi_wdt->wdt_regs = of_device_get_match_data(&pdev->dev);
> + if (!sunxi_wdt->wdt_regs)
> return -ENODEV;
>
> - sunxi_wdt->wdt_regs = device->data;
> -
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> sunxi_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res);
> if (IS_ERR(sunxi_wdt->wdt_base))
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-10-22 17:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-21 17:45 [PATCH] watchdog: sunxi_wdt: use of_device_get_match_data Corentin Labbe
2017-10-21 17:45 ` Corentin Labbe
2017-10-22 17:44 ` Guenter Roeck
2017-10-22 17:44 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.