From: Guenter Roeck <linux@roeck-us.net>
To: Corentin Labbe <clabbe.montjoie@gmail.com>
Cc: wim@iguana.be, maxime.ripard@free-electrons.com, wens@csie.org,
linux-watchdog@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: watchdog: sunxi_wdt: use of_device_get_match_data
Date: Sun, 22 Oct 2017 10:44:16 -0700 [thread overview]
Message-ID: <20171022174416.GA21100@roeck-us.net> (raw)
In-Reply-To: <20171021174513.1653-1-clabbe.montjoie@gmail.com>
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))
prev parent reply other threads:[~2017-10-22 17:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-21 17:45 [PATCH] " Corentin Labbe
2017-10-22 17:44 ` Guenter Roeck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171022174416.GA21100@roeck-us.net \
--to=linux@roeck-us.net \
--cc=clabbe.montjoie@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=wens@csie.org \
--cc=wim@iguana.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®