watchdog: Add DA906x PMIC watchdog driver.
Subsystems (2)
PATCH v4 1/1 watchdog: Add DA906x PMIC watchdog driver.
From: Krystian Garbaciak <[email protected]>
This driver supports the watchdog device inside the DA906x PMIC.
---
Notes:
Changes in v4:
- Fixed indentation
- Fixed lock without unlock
- Check for parent device and device driver data in probe(). If not present, this is an invalid prober initialization, return -EINVAL.
Changes in v3:
- Cleanup error handling for timeout selection and setting
- Fix race condition due to late wdt drvdata setup
- Remove static struct watchdog_device. It is not initialized in the probe function
- Use WATCHDOG_NOWAYOUT_INIT_STATUS for the status
- Remove 0 shift using DA9063_TWDSCALE_SHIFT
drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/da9063_wdt.c | 231 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 drivers/watchdog/da9063_wdt.c
drivers/watchdog/Kconfig +7 -0
@@ -87,6 +87,13 @@ config DA9055_WATCHDOG This driver can also be built as a module. If so, the module will be called da9055_wdt. +config DA9063_WATCHDOG + tristate "Dialog DA9063 Watchdog" + depends on MFD_DA9063 + select WATCHDOG_CORE + help + Support for the watchdog in the DA9063 PMIC. + config GPIO_WATCHDOG tristate "Watchdog device controlled through GPIO-line" depends on OF_GPIO
drivers/watchdog/Makefile +1 -0
@@ -172,6 +172,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o # Architecture Independent obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o +obj-$(CONFIG_DA9063_WATCHDOG) += da9063_wdt.o obj-$(CONFIG_GPIO_WATCHDOG) += gpio_wdt.o obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o
drivers/watchdog/da9063_wdt.c new file +231 -0
231 lines not on this page · raw message
Signature · 1 line
2.0.1
Guenter Roeck
maintainerPATCH v4 1/1 watchdog: Add DA906x PMIC watchdog driver.
Quoted 35 lines · Markus Pargmann
From: Krystian Garbaciak <[email protected]>
This driver supports the watchdog device inside the DA906x PMIC.
Signed-off-by Krystian Garbaciak <[email protected]>Signed-off-by Philipp Zabel <[email protected]>Signed-off-by Markus Pargmann <[email protected]>---
Notes:
Changes in v4:
- Fixed indentation
- Fixed lock without unlock
- Check for parent device and device driver data inprobe(). If not present, this is an invalid prober initialization, return-EINVAL.Changes in v3:
- Cleanup error handling for timeout selection and setting
- Fix race condition due to late wdt drvdata setup
- Remove static structwatchdog_device. It is not initialized in the probe function
- UseWATCHDOG_NOWAYOUT_INIT_STATUSfor the status
- Remove 0 shift usingDA9063_TWDSCALE_SHIFTdrivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/da9063_wdt.c | 231 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 drivers/watchdog/da9063_wdt.cdrivers/watchdog/Kconfig +0
-0
drivers/watchdog/Kconfig config DA9055_WATCHDOG · line 96
Quoted 10 lines
drivers/watchdog/Kconfig +7
-0@@ -87,6 +87,13 @@ config DA9055_WATCHDOG This driver can also be built as a module. If so, the module will be called da9055_wdt. +config DA9063_WATCHDOG + tristate "Dialog DA9063 Watchdog" + depends on MFD_DA9063 + select WATCHDOG_CORE + help + Support for the watchdog in the DA9063 PMIC. +
Please add a note such as above, listing the module name.
Quoted 59 lines
drivers/watchdog/Kconfig +0
-0config GPIO_WATCHDOG tristate "Watchdog device controlled through GPIO-line" depends on OF_GPIOdrivers/watchdog/Makefile +1
-0@@ -172,6 +172,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o # Architecture Independent obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o +obj-$(CONFIG_DA9063_WATCHDOG) += da9063_wdt.o obj-$(CONFIG_GPIO_WATCHDOG) += gpio_wdt.o obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.odrivers/watchdog/da9063_wdt.c new file +38
-0@@ -0,0 +1,231 @@ +/* +* Watchdog driver for DA9063 PMICs. +* +* Copyright(c) 2012 Dialog Semiconductor Ltd. +* +* Author: Mariusz Wojtasik <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/watchdog.h> +#include <linux/platform_device.h> +#include <linux/uaccess.h> +#include <linux/slab.h> +#include <linux/delay.h> +#include <linux/mfd/da9063/registers.h> +#include <linux/mfd/da9063/core.h> +#include <linux/regmap.h> + +/* +* Watchdog selector to timeout in seconds. +* 0: WDT disabled; +* others: timeout = 2048 ms * 2^(TWDSCALE-1). +*/ +static const int wdt_timeout[] = {0 ,2 ,4 ,8 ,16 ,32 ,65 ,131 }; +#define DA9063_TWDSCALE_DISABLE 0 +#define DA9063_TWDSCALE_MIN 1 +#define DA9063_TWDSCALE_MAX (ARRAY_SIZE(wdt_timeout) - 1) +#define DA9063_WDT_MIN_TIMEOUT wdt_timeout[DA9063_TWDSCALE_MIN] +#define DA9063_WDT_MAX_TIMEOUT wdt_timeout[DA9063_TWDSCALE_MAX] +#define DA9063_WDG_TIMEOUT wdt_timeout[3] + +struct da9063_watchdog {
drivers/watchdog/da9063_wdt.c line 48
Quoted 10 lines
drivers/watchdog/da9063_wdt.c new file +10
-0+struct da9063 *da9063; +struct watchdog_device wdtdev; +struct mutex lock; +}; + +static int da9063_wdt_timeout_to_sel (int secs) +{ +int i; + +for (i =DA9063_TWDSCALE_MIN ; i <=DA9063_TWDSCALE_MAX ; i++) {
When building with W=1, gcc complains about this line. Would be great if you can have a look and fix it.
Quoted 24 lines
drivers/watchdog/da9063_wdt.c new file +24
-0+if (wdt_timeout[i] >= secs) +return i; + } + +return -EINVAL ; +} + +static int da9063_wdt_disable (struct da9063 *da9063) +{ +return regmap_update_bits (da9063->regmap,DA9063_REG_CONTROL_D , +DA9063_TWDSCALE_MASK , +DA9063_TWDSCALE_DISABLE ); +} + +static int _da9063_wdt_set_timeout (struct da9063 *da9063,unsigned int regval) +{ +return regmap_update_bits (da9063->regmap,DA9063_REG_CONTROL_D , +DA9063_TWDSCALE_MASK , regval); +} + +static int _da9063_wdt_kick (struct da9063 *da9063) +{ +return regmap_write (da9063->regmap,DA9063_REG_CONTROL_F , +DA9063_WATCHDOG );
drivers/watchdog/da9063_wdt.c line 82
Quoted 10 lines
drivers/watchdog/da9063_wdt.c new file +10
-0+} + +static int da9063_wdt_start (struct watchdog_device *wdd) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +unsigned int selector; +int ret; + + selector =da9063_wdt_timeout_to_sel (wdt->wdtdev.timeout); +if (selector <0 ) {
selector has to be an int for this to work. Building the driver with W=1 reports it, btw.
Quoted 16 lines
drivers/watchdog/da9063_wdt.c new file +16
-0+dev_err (wdt->da9063->dev,"Timeout out of range (timeout=%d)\n" , + wdt->wdtdev.timeout); +return selector; + } + +mutex_lock (&wdt->lock); + ret =_da9063_wdt_set_timeout (wdt->da9063, selector); +if (ret) { +dev_err (wdt->da9063->dev,"Watchdog failed to start (err = %d)\n" , + ret); + } +mutex_unlock (&wdt->lock); + +return ret; +} +
drivers/watchdog/da9063_wdt.c line 108
Quoted 10 lines
drivers/watchdog/da9063_wdt.c new file +10
-0+static int da9063_wdt_stop (struct watchdog_device *wdd) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +int ret; + +mutex_lock (&wdt->lock); + ret =da9063_wdt_disable (wdt->da9063); +if (ret) +dev_alert (wdt->da9063->dev,"Watchdog failed to stop (err = %d)\n" , + ret);
You have a number of places where the continuation line _on purpose_ does not align to te opening '('. I would understand it if your indentation rules were in any way consistent, but I don't see that either.
Ok, I can see that you dislike the rule that continuation lines should be aligned to '(', but to misalign even when the '(' matches a tab position doesn't really make any sense.
Quoted 19 lines
drivers/watchdog/da9063_wdt.c new file +19
-0+mutex_unlock (&wdt->lock); + +return ret; +} + +static int da9063_wdt_ping (struct watchdog_device *wdd) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +int ret; + +mutex_lock (&wdt->lock); + ret =_da9063_wdt_kick (wdt->da9063); +if (ret) +dev_alert (wdt->da9063->dev,"Failed to ping the watchdog (err = %d)\n" , + ret); +mutex_unlock (&wdt->lock); + +return ret; +}
drivers/watchdog/da9063_wdt.c line 137
Quoted 10 lines
drivers/watchdog/da9063_wdt.c new file +10
-0+ +static int da9063_wdt_set_timeout (struct watchdog_device *wdd, +unsigned int timeout) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +unsigned int selector; +int ret; + + selector =da9063_wdt_timeout_to_sel (timeout); +if (selector <0 ) {
selector must be an int for this to work.
drivers/watchdog/da9063_wdt.c line 138
Quoted 1 line
drivers/watchdog/da9063_wdt.c new file +1
-0+dev_err (wdt->da9063->dev,"Unsupported watchdog timeout, should be between 2 and 131\n" );
Please use a continuation line here.
Quoted 93 lines
drivers/watchdog/da9063_wdt.c new file +93
-0+return -EINVAL ; + } + +mutex_lock (&wdt->lock); + + ret =_da9063_wdt_set_timeout (wdt->da9063, selector); +if (ret) +dev_err (wdt->da9063->dev,"Failed to set watchdog timeout (err = %d)\n" , + ret); +else + wdd->timeout = wdt_timeout[selector]; + +mutex_unlock (&wdt->lock); + +return ret; +} + +static const struct watchdog_info da9063_watchdog_info = { + .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING , + .identity ="DA9063 Watchdog" , +}; + +static const struct watchdog_ops da9063_watchdog_ops = { + .owner =THIS_MODULE , + .start = da9063_wdt_start, + .stop = da9063_wdt_stop, + .ping = da9063_wdt_ping, + .set_timeout = da9063_wdt_set_timeout, +}; + +static int da9063_wdt_probe (struct platform_device *pdev) +{ +int ret; +struct da9063 *da9063; +struct da9063_watchdog *wdt; + +if (!pdev->dev.parent) +return -EINVAL ; + + da9063 =dev_get_drvdata (pdev->dev.parent); +if (!da9063) +return -EINVAL ; + + wdt =devm_kzalloc (&pdev->dev,sizeof (*wdt),GFP_KERNEL ); +if (!wdt) +return -ENOMEM ; + + wdt->da9063 = da9063; +mutex_init (&wdt->lock); + + wdt->wdtdev.info = &da9063_watchdog_info; + wdt->wdtdev.ops = &da9063_watchdog_ops; + wdt->wdtdev.min_timeout =DA9063_WDT_MIN_TIMEOUT ; + wdt->wdtdev.max_timeout =DA9063_WDT_MAX_TIMEOUT ; + wdt->wdtdev.timeout =DA9063_WDG_TIMEOUT ; + + wdt->wdtdev.status =WATCHDOG_NOWAYOUT_INIT_STATUS ; + +watchdog_set_drvdata (&wdt->wdtdev, wdt); +dev_set_drvdata (&pdev->dev, wdt); + + ret =watchdog_register_device (&wdt->wdtdev); +if (ret) { +dev_err (da9063->dev,"da9063-watchdog registration failed (err = %d)" , + ret); +return ret; + } + +return 0 ; +} + +static int da9063_wdt_remove (struct platform_device *pdev) +{ +struct da9063_watchdog *wdt =dev_get_drvdata (&pdev->dev); + +watchdog_unregister_device (&wdt->wdtdev); + +return 0 ; +} + +static struct platform_driver da9063_wdt_driver = { + .probe = da9063_wdt_probe, + .remove = da9063_wdt_remove, + .driver = { + .name =DA9063_DRVNAME_WATCHDOG , + }, +}; +module_platform_driver (da9063_wdt_driver); + +MODULE_AUTHOR ("Mariusz Wojtasik <[email protected]>" ); +MODULE_DESCRIPTION ("Watchdog driver for Dialog DA9063" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:" DA9063_DRVNAME_WATCHDOG );
PATCH v4 1/1 watchdog: Add DA906x PMIC watchdog driver.
Hi,
Quoted 39 lines · Guenter Roeck
Quoted 38 lines · Markus Pargmann
From: Krystian Garbaciak <[email protected]>
This driver supports the watchdog device inside the DA906x PMIC.
Signed-off-by Krystian Garbaciak <[email protected]>Signed-off-by Philipp Zabel <[email protected]>Signed-off-by Markus Pargmann <[email protected]>---
Notes:
Changes in v4:
- Fixed indentation
- Fixed lock without unlock
- Check for parent device and device driver data inprobe(). If not present, this is an invalid prober initialization, return-EINVAL.Changes in v3:
- Cleanup error handling for timeout selection and setting
- Fix race condition due to late wdt drvdata setup
- Remove static structwatchdog_device. It is not initialized in the probe function
- UseWATCHDOG_NOWAYOUT_INIT_STATUSfor the status
- Remove 0 shift usingDA9063_TWDSCALE_SHIFTdrivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/da9063_wdt.c | 231 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 drivers/watchdog/da9063_wdt.cdrivers/watchdog/Kconfig +0
-0@@ -87,6 +87,13 @@ config DA9055_WATCHDOG This driver can also be built as a module. If so, the module will be called da9055_wdt.
Quoted 8 lines
drivers/watchdog/Kconfig config DA9055_WATCHDOG · line 96
Quoted 7 lines
drivers/watchdog/Kconfig +7
-0+config DA9063_WATCHDOG + tristate "Dialog DA9063 Watchdog" + depends on MFD_DA9063 + select WATCHDOG_CORE + help + Support for the watchdog in the DA9063 PMIC. +Please add a note such as above, listing the module name.
Added such a note.
Quoted 65 lines
Quoted 65 lines
drivers/watchdog/Kconfig +0
-0config GPIO_WATCHDOG tristate "Watchdog device controlled through GPIO-line" depends on OF_GPIOdrivers/watchdog/Makefile +1
-0@@ -172,6 +172,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o # Architecture Independent obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o +obj-$(CONFIG_DA9063_WATCHDOG) += da9063_wdt.o obj-$(CONFIG_GPIO_WATCHDOG) += gpio_wdt.o obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.odrivers/watchdog/da9063_wdt.c new file +43
-0@@ -0,0 +1,231 @@ +/* +* Watchdog driver for DA9063 PMICs. +* +* Copyright(c) 2012 Dialog Semiconductor Ltd. +* +* Author: Mariusz Wojtasik <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/watchdog.h> +#include <linux/platform_device.h> +#include <linux/uaccess.h> +#include <linux/slab.h> +#include <linux/delay.h> +#include <linux/mfd/da9063/registers.h> +#include <linux/mfd/da9063/core.h> +#include <linux/regmap.h> + +/* +* Watchdog selector to timeout in seconds. +* 0: WDT disabled; +* others: timeout = 2048 ms * 2^(TWDSCALE-1). +*/ +static const int wdt_timeout[] = {0 ,2 ,4 ,8 ,16 ,32 ,65 ,131 }; +#define DA9063_TWDSCALE_DISABLE 0 +#define DA9063_TWDSCALE_MIN 1 +#define DA9063_TWDSCALE_MAX (ARRAY_SIZE(wdt_timeout) - 1) +#define DA9063_WDT_MIN_TIMEOUT wdt_timeout[DA9063_TWDSCALE_MIN] +#define DA9063_WDT_MAX_TIMEOUT wdt_timeout[DA9063_TWDSCALE_MAX] +#define DA9063_WDG_TIMEOUT wdt_timeout[3] + +struct da9063_watchdog { +struct da9063 *da9063; +struct watchdog_device wdtdev; +struct mutex lock; +}; +
Quoted 8 lines
drivers/watchdog/da9063_wdt.c line 48
Quoted 5 lines
drivers/watchdog/da9063_wdt.c new file +5
-0+static int da9063_wdt_timeout_to_sel (int secs) +{ +int i; + +for (i =DA9063_TWDSCALE_MIN ; i <=DA9063_TWDSCALE_MAX ; i++) {When building with W=1, gcc complains about this line. Would be great if you can have a look and fix it.
I just compiled with W=1, it doesn't complain here about this line. Could you give me the warning?
Quoted 30 lines
Quoted 30 lines
drivers/watchdog/da9063_wdt.c new file +29
-0+if (wdt_timeout[i] >= secs) +return i; + } + +return -EINVAL ; +} + +static int da9063_wdt_disable (struct da9063 *da9063) +{ +return regmap_update_bits (da9063->regmap,DA9063_REG_CONTROL_D , +DA9063_TWDSCALE_MASK , +DA9063_TWDSCALE_DISABLE ); +} + +static int _da9063_wdt_set_timeout (struct da9063 *da9063,unsigned int regval) +{ +return regmap_update_bits (da9063->regmap,DA9063_REG_CONTROL_D , +DA9063_TWDSCALE_MASK , regval); +} + +static int _da9063_wdt_kick (struct da9063 *da9063) +{ +return regmap_write (da9063->regmap,DA9063_REG_CONTROL_F , +DA9063_WATCHDOG ); +} + +static int da9063_wdt_start (struct watchdog_device *wdd) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd);
Quoted 8 lines
drivers/watchdog/da9063_wdt.c line 82
Quoted 5 lines
drivers/watchdog/da9063_wdt.c new file +5
-0+unsigned int selector; +int ret; + + selector =da9063_wdt_timeout_to_sel (wdt->wdtdev.timeout); +if (selector <0 ) {selector has to be an int for this to work. Building the driver with W=1 reports it, btw.
Yes, thanks, I changed both selector variables to int.
Quoted 26 lines
Quoted 26 lines
drivers/watchdog/da9063_wdt.c new file +25
-0+dev_err (wdt->da9063->dev,"Timeout out of range (timeout=%d)\n" , + wdt->wdtdev.timeout); +return selector; + } + +mutex_lock (&wdt->lock); + ret =_da9063_wdt_set_timeout (wdt->da9063, selector); +if (ret) { +dev_err (wdt->da9063->dev,"Watchdog failed to start (err = %d)\n" , + ret); + } +mutex_unlock (&wdt->lock); + +return ret; +} + +static int da9063_wdt_stop (struct watchdog_device *wdd) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +int ret; + +mutex_lock (&wdt->lock); + ret =da9063_wdt_disable (wdt->da9063); +if (ret) + dev_alert(wdt->da9063->dev, "Watchdog failed to stop (err = %d)\n",
Quoted 8 lines
drivers/watchdog/da9063_wdt.c line 108
Quoted 1 line
drivers/watchdog/da9063_wdt.c new file +1
-0+ ret);You have a number of places where the continuation line
_onpurpose_does not align to te opening '('. I would understand it if your indentation rules were in any way consistent, but I don't see that either.
Ok, I can see that you dislike the rule that continuation lines should be aligned to '(', but to misalign even when the '(' matches a tab position doesn't really make any sense.
My indentation rules are consistent, otherwise I made a mistake. I always indent two tabs after an opening bracket when breaking long lines. Also I can't find any specific rules about how to break long lines in the coding style document.
Quoted 33 lines
Quoted 20 lines
drivers/watchdog/da9063_wdt.c new file +19
-0+mutex_unlock (&wdt->lock); + +return ret; +} + +static int da9063_wdt_ping (struct watchdog_device *wdd) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +int ret; + +mutex_lock (&wdt->lock); + ret =_da9063_wdt_kick (wdt->da9063); +if (ret) +dev_alert (wdt->da9063->dev,"Failed to ping the watchdog (err = %d)\n" , + ret); +mutex_unlock (&wdt->lock); + +return ret; +}drivers/watchdog/da9063_wdt.c line 137
Quoted 10 lines
drivers/watchdog/da9063_wdt.c new file +10
-0+ +static int da9063_wdt_set_timeout (struct watchdog_device *wdd, +unsigned int timeout) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +unsigned int selector; +int ret; + + selector =da9063_wdt_timeout_to_sel (timeout); +if (selector <0 ) {selector must be an int for this to work.
Quoted 3 lines
drivers/watchdog/da9063_wdt.c line 138
Quoted 1 line
drivers/watchdog/da9063_wdt.c new file +1
-0+dev_err (wdt->da9063->dev,"Unsupported watchdog timeout, should be between 2 and 131\n" );Please use a continuation line here.
Ok.
Thank you,
Markus
Signature · 11 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140821/3bda1b04/attachment.sig>
Guenter Roeck
maintainerPATCH v4 1/1 watchdog: Add DA906x PMIC watchdog driver.
Quoted 2 lines · Markus Pargmann
Hi,
...
Quoted 9 lines
Quoted 8 lines
drivers/watchdog/da9063_wdt.c line 48
Quoted 5 lines
drivers/watchdog/da9063_wdt.c new file +5
-0+static int da9063_wdt_timeout_to_sel (int secs) +{ +int i; + +for (i =DA9063_TWDSCALE_MIN ; i <=DA9063_TWDSCALE_MAX ; i++) {When building with W=1, gcc complains about this line. Would be great if you can have a look and fix it.
Quoted 3 lines
I just compiled with W=1, it doesn't complain here about this line. Could you give me the warning?
drivers/watchdog/da9063_wdt.c: In function 'da9063_wdt_timeout_to_sel':drivers/watchdog/da9063_wdt.c:48:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
This is with arm-poky-linux-gnueabi-gcc (GCC) 4.7.2.
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
drivers/watchdog/da9063_wdt.c new file +9
-0+static int da9063_wdt_stop (struct watchdog_device *wdd) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +int ret; + +mutex_lock (&wdt->lock); + ret =da9063_wdt_disable (wdt->da9063); +if (ret) + dev_alert(wdt->da9063->dev, "Watchdog failed to stop (err = %d)\n",Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ ret);You have a number of places where the continuation line
_onpurpose_does not align to te opening '('. I would understand it if your indentation rules were in any way consistent, but I don't see that either.
Ok, I can see that you dislike the rule that continuation lines should be aligned to '(', but to misalign even when the '(' matches a tab position doesn't really make any sense.
Quoted 5 lines
My indentation rules are consistent, otherwise I made a mistake. I always indent two tabs after an opening bracket when breaking long lines. Also I can't find any specific rules about how to break long lines in the coding style document.
Hmm, I thought this was an official CodingStyle rule. Guess it is just a checkpatch rule. Oh well.
Guenter
PATCH v4 1/1 watchdog: Add DA906x PMIC watchdog driver.
Hi,
Quoted 13 lines · Guenter Roeck
Quoted 2 lines · Markus Pargmann
Hi,
...
Quoted 9 lines
Quoted 8 lines
drivers/watchdog/da9063_wdt.c line 48
Quoted 5 lines
drivers/watchdog/da9063_wdt.c new file +5
-0+static int da9063_wdt_timeout_to_sel (int secs) +{ +int i; + +for (i =DA9063_TWDSCALE_MIN ; i <=DA9063_TWDSCALE_MAX ; i++) {When building with W=1, gcc complains about this line. Would be great if you can have a look and fix it.
Quoted 8 lines
Quoted 3 lines
I just compiled with W=1, it doesn't complain here about this line. Could you give me the warning?
drivers/watchdog/da9063_wdt.c: In function 'da9063_wdt_timeout_to_sel':drivers/watchdog/da9063_wdt.c:48:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]This is with arm-poky-linux-gnueabi-gcc (GCC) 4.7.2.
Thanks, I am using gcc 4.8.3. I replaced the used 'int' type by 'unsigend int', that should fix it.
Best regards,
Markus
Signature · 11 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140824/7006bf5a/attachment.sig>
PATCH v4 1/1 watchdog: Add DA906x PMIC watchdog driver.
In reply to Markus PargmannQuoted 1 line · On 16 August 2014 13:36, Markus Pargmann [mailto:mpa at pengutronix.de] wrote:
Subject: [PATCH v4] watchdog: Add DA906x PMIC watchdog driver.
Hi Markus,
Quoted 5 lines
From: Krystian Garbaciak <[email protected]>
This driver supports the watchdog device inside the DA906x PMIC.
There is only DA9063 , in this case there is no "x". Thanks.
[...]
drivers/watchdog/da9063_wdt.c line 30
Quoted 7 lines
drivers/watchdog/da9063_wdt.c new file +7
-0+ +/* +* Watchdog selector to timeout in seconds. +* 0: WDT disabled; +* others: timeout = 2048 ms * 2^(TWDSCALE-1). +*/ +static const int wdt_timeout[] = {0 ,2 ,4 ,8 ,16 ,32 ,65 ,131 };
This table is just an approximation of the real times provided by the PMIC.
The first three bits in the CONTROL_D register at 0x11 define a scaling value for the nominal maximum time TWDMAX. The 7 values specifying the timeout of the watchdog are:
001 = 1 = 1x = 2048ms
010 = 2 = 2x = 4096ms
011 = 3 = 4x = 8192ms
100 = 4 = 8x = 16384ms
101 = 5 = 16x = 32768ms
110 = 6 = 32x = 65536ms
111 = 7 = 64x = 131072ms
[...]
Quoted 14 lines
drivers/watchdog/da9063_wdt.c new file +4
-0+ +static int da9063_wdt_disable (struct da9063 *da9063) +{ + return regmap_update_bits(da9063->regmap,
DA9063_REG_CONTROL_D,drivers/watchdog/da9063_wdt.c new file +5
-0+DA9063_TWDSCALE_MASK , + DA9063_TWDSCALE_DISABLE); +} + +static int _da9063_wdt_set_timeout(struct da9063 *da9063, unsigned intregval)
(quoted diff) +2
-0+{ + return regmap_update_bits(da9063->regmap,
DA9063_REG_CONTROL_D,
drivers/watchdog/da9063_wdt.c line 74
Quoted 9 lines
drivers/watchdog/da9063_wdt.c new file +9
-0+ DA9063_TWDSCALE_MASK, regval); +} + +static int _da9063_wdt_kick (struct da9063 *da9063) +{ +return regmap_write (da9063->regmap,DA9063_REG_CONTROL_F , +DA9063_WATCHDOG ); +} +
The _da9063_wdt_kick() and da9063_wdt_disable() functions are only used once throughout the code -- in the watchdog_ops functions da9063_wdt_ping() and da9063_wdt_stop() respectively.
Since these are just simple regmap calls, could they be added at those places directly and therefore remove the function calls?
[...]
drivers/watchdog/da9063_wdt.c line 82
Quoted 8 lines
drivers/watchdog/da9063_wdt.c new file +8
-0+static int da9063_wdt_start (struct watchdog_device *wdd) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +unsigned int selector; +int ret; + + selector =da9063_wdt_timeout_to_sel (wdt->wdtdev.timeout); +if (selector <0 ) {
Unsigned if < 0
[...]
drivers/watchdog/da9063_wdt.c line 137
Quoted 9 lines
drivers/watchdog/da9063_wdt.c new file +9
-0+static int da9063_wdt_set_timeout (struct watchdog_device *wdd, +unsigned int timeout) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +unsigned int selector; +int ret; + + selector =da9063_wdt_timeout_to_sel (timeout); +if (selector <0 ) {
And again
Regards,
Steve
PATCH v4 1/1 watchdog: Add DA906x PMIC watchdog driver.
Hi Steve,
Quoted 7 lines · Opensource [Steve Twiss]
Quoted 1 line · On 16 August 2014 13:36, Markus Pargmann [mailto:mpa at pengutronix.de] wrote:
Subject: [PATCH v4] watchdog: Add DA906x PMIC watchdog driver.
Hi Markus,
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
From: Krystian Garbaciak <[email protected]>
This driver supports the watchdog device inside the DA906x PMIC.
There is only DA9063 , in this case there is no "x". Thanks.
Thanks, fixed in the commit message.
Quoted 17 lines
[...]
drivers/watchdog/da9063_wdt.c line 30
Quoted 7 lines
drivers/watchdog/da9063_wdt.c new file +7
-0+ +/* +* Watchdog selector to timeout in seconds. +* 0: WDT disabled; +* others: timeout = 2048 ms * 2^(TWDSCALE-1). +*/ +static const int wdt_timeout[] = {0 ,2 ,4 ,8 ,16 ,32 ,65 ,131 };This table is just an approximation of the real times provided by the PMIC.
The first three bits in the
CONTROL_Dregister at0x11define a scaling value for the nominal maximum time TWDMAX. The 7 values specifying the timeout of the watchdog are:
Quoted 7 lines
001 = 1 = 1x = 2048ms
010 = 2 = 2x = 4096ms
011 = 3 = 4x = 8192ms
100 = 4 = 8x = 16384ms
101 = 5 = 16x = 32768ms
110 = 6 = 32x = 65536ms
111 = 7 = 64x = 131072ms
Thanks. So the 7 values are good approximations for the real values right?
Quoted 24 lines
[...]
Quoted 21 lines
drivers/watchdog/da9063_wdt.c new file +4
-0+ +static int da9063_wdt_disable (struct da9063 *da9063) +{ + return regmap_update_bits(da9063->regmap,
DA9063_REG_CONTROL_D,drivers/watchdog/da9063_wdt.c new file +5
-0+DA9063_TWDSCALE_MASK , + DA9063_TWDSCALE_DISABLE); +} + +static int _da9063_wdt_set_timeout(struct da9063 *da9063, unsigned intregval)
(quoted diff) +2
-0+{ + return regmap_update_bits(da9063->regmap,
DA9063_REG_CONTROL_D,drivers/watchdog/da9063_wdt.c new file +7
-0+ DA9063_TWDSCALE_MASK, regval); +} + +static int _da9063_wdt_kick (struct da9063 *da9063) +{ +return regmap_write (da9063->regmap,DA9063_REG_CONTROL_F , +DA9063_WATCHDOG );
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+} +The
_da9063_wdt_kick()andda9063_wdt_disable()functions are only used once throughout the code -- in thewatchdog_opsfunctionsda9063_wdt_ping()andda9063_wdt_stop()respectively.
Since these are just simple regmap calls, could they be added at those places directly and therefore remove the function calls?
Thanks, I removed those functions and included the regmap function calls directly as they are already well described by the functions from which they are called.
Quoted 13 lines
[...]
drivers/watchdog/da9063_wdt.c line 82
Quoted 8 lines
drivers/watchdog/da9063_wdt.c new file +8
-0+static int da9063_wdt_start (struct watchdog_device *wdd) +{ +struct da9063_watchdog *wdt =watchdog_get_drvdata (wdd); +unsigned int selector; +int ret; + + selector =da9063_wdt_timeout_to_sel (wdt->wdtdev.timeout); +if (selector <0 ) {Unsigned if < 0
That was already fixed for the next version.
Thanks,
Markus
Signature · 11 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140824/947ef81b/attachment.sig>