Re: [PATCH 12/22] watchdog: da9063_wdt: Use 'dev' instead of dereferencing it repeatedly

From: Guenter Roeck
Date: Wed Apr 10 2019 - 09:11:25 EST


Hi Steve,

On 4/10/19 5:50 AM, Steve Twiss wrote:
Hi Guenter,

On 08 April 2019 20:39, Guenter Roeck:

Subject: [PATCH 12/22] watchdog: da9063_wdt: Use 'dev' instead of
dereferencing it repeatedly

Introduce local variable 'struct device *dev' and use it instead of
dereferencing it repeatedly.

The conversion was done automatically with coccinelle using the
following semantic patches. The semantic patches and the scripts
used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

Cc: Support Opensource <support.opensource@xxxxxxxxxxx>
Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
---
drivers/watchdog/da9063_wdt.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index 384dca16af8b..06eb9070203c 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -188,17 +188,18 @@ static const struct watchdog_ops
da9063_watchdog_ops = {

static int da9063_wdt_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct da9063 *da9063;
struct watchdog_device *wdd;

- if (!pdev->dev.parent)
+ if (!dev->parent)
return -EINVAL;

None of my previous Acked e-mails in this patch set considered whether the
dev->parent was NULL. But this DA9063 driver does.

Logically, this is correct to check, but ... any thoughts?

The check is not really necessary. All da90xx drivers are instantiated from
mfd drivers and do provide a parent. Anyone changing that code or trying
to instantiate the drivers from some other place without providing a parent
really deserves the resulting crash (it would be a bug).

Either case, I don't think this warrants changing this driver to drop
the check, or changing the other drivers to add unnecessary checks
just to make the code consistent.

Otherwise,

Acked-by: Steve Twiss <stwiss.opensource@xxxxxxxxxxx>


Thanks,
Guenter