diff mbox series

[2/3] watchdog: iTCO_wdt: use dev_*() instead of pr_*() for logging

Message ID 20201117152214.32244-2-info@metux.net (mailing list archive)
State Accepted
Headers show
Series [1/3] watchdog: iTCO_wdt: use module_platform_device() macro | expand

Commit Message

Enrico Weigelt, metux IT consult Nov. 17, 2020, 3:22 p.m. UTC
For device log outputs, it's better to have device name / ID
prefixed in all messages, so use the proper dev_*() functions here.

Explicit message on module load/unload don't seem to be really helpful
(we have other means to check which modules have been loaded), instead
just add noise to the kernel log. So, removing them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
 drivers/watchdog/iTCO_wdt.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Comments

Bjorn Helgaas June 9, 2021, 8:32 p.m. UTC | #1
On Tue, Nov 17, 2020 at 04:22:13PM +0100, Enrico Weigelt, metux IT consult wrote:
> For device log outputs, it's better to have device name / ID
> prefixed in all messages, so use the proper dev_*() functions here.
> 
> Explicit message on module load/unload don't seem to be really helpful
> (we have other means to check which modules have been loaded), instead
> just add noise to the kernel log. So, removing them.
> 
> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>

I like this patch a lot; thanks for doing it!  It's merged upstream as
c21172b3a73e ("watchdog: iTCO_wdt: use dev_*() instead of pr_*() for
logging").

It looks like there are a couple more pr_err() uses, so I wondered if
they were missed or skipped intentionally:

  if (p->smi_res) {
          /* The TCO logic uses the TCO_EN bit in the SMI_EN register */
          if (!devm_request_region(dev, p->smi_res->start,
                                   resource_size(p->smi_res),
                                   pdev->name)) {
                  pr_err("I/O address 0x%04llx already in use, device disabled\n",
                         (u64)SMI_EN(p));
                  return -EBUSY;
          }
  } else if (iTCO_vendorsupport ||
             turn_SMI_watchdog_clear_off >= p->iTCO_version) {
          pr_err("SMI I/O resource is missing\n");
          return -ENODEV;
  }

> ---
>  drivers/watchdog/iTCO_wdt.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
> index f2ddc8fc71cd..edc588a06ae6 100644
> --- a/drivers/watchdog/iTCO_wdt.c
> +++ b/drivers/watchdog/iTCO_wdt.c
> @@ -40,8 +40,6 @@
>   *	Includes, defines, variables, module parameters, ...
>   */
>  
> -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> -
>  /* Module and version information */
>  #define DRV_NAME	"iTCO_wdt"
>  #define DRV_VERSION	"1.11"
> @@ -279,7 +277,7 @@ static int iTCO_wdt_start(struct watchdog_device *wd_dev)
>  	/* disable chipset's NO_REBOOT bit */
>  	if (p->update_no_reboot_bit(p->no_reboot_priv, false)) {
>  		spin_unlock(&p->io_lock);
> -		pr_err("failed to reset NO_REBOOT flag, reboot disabled by hardware/BIOS\n");
> +		dev_err(wd_dev->dev, "failed to reset NO_REBOOT flag, reboot disabled by hardware/BIOS\n");
>  		return -EIO;
>  	}
>  
> @@ -510,7 +508,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
>  	/* Check chipset's NO_REBOOT bit */
>  	if (p->update_no_reboot_bit(p->no_reboot_priv, false) &&
>  	    iTCO_vendor_check_noreboot_on()) {
> -		pr_info("unable to reset NO_REBOOT flag, device disabled by hardware/BIOS\n");
> +		dev_info(dev, "unable to reset NO_REBOOT flag, device disabled by hardware/BIOS\n");
>  		return -ENODEV;	/* Cannot reset NO_REBOOT bit */
>  	}
>  
> @@ -530,12 +528,12 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
>  	if (!devm_request_region(dev, p->tco_res->start,
>  				 resource_size(p->tco_res),
>  				 pdev->name)) {
> -		pr_err("I/O address 0x%04llx already in use, device disabled\n",
> +		dev_err(dev, "I/O address 0x%04llx already in use, device disabled\n",
>  		       (u64)TCOBASE(p));
>  		return -EBUSY;
>  	}
>  
> -	pr_info("Found a %s TCO device (Version=%d, TCOBASE=0x%04llx)\n",
> +	dev_info(dev, "Found a %s TCO device (Version=%d, TCOBASE=0x%04llx)\n",
>  		pdata->name, pdata->version, (u64)TCOBASE(p));
>  
>  	/* Clear out the (probably old) status */
> @@ -558,7 +556,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
>  		break;
>  	}
>  
> -	p->wddev.info =	&ident,
> +	p->wddev.info = &ident,
>  	p->wddev.ops = &iTCO_wdt_ops,
>  	p->wddev.bootstatus = 0;
>  	p->wddev.timeout = WATCHDOG_TIMEOUT;
> @@ -575,7 +573,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
>  	   if not reset to the default */
>  	if (iTCO_wdt_set_timeout(&p->wddev, heartbeat)) {
>  		iTCO_wdt_set_timeout(&p->wddev, WATCHDOG_TIMEOUT);
> -		pr_info("timeout value out of range, using %d\n",
> +		dev_info(dev, "timeout value out of range, using %d\n",
>  			WATCHDOG_TIMEOUT);
>  	}
>  
> @@ -583,11 +581,11 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
>  	watchdog_stop_on_unregister(&p->wddev);
>  	ret = devm_watchdog_register_device(dev, &p->wddev);
>  	if (ret != 0) {
> -		pr_err("cannot register watchdog device (err=%d)\n", ret);
> +		dev_err(dev, "cannot register watchdog device (err=%d)\n", ret);
>  		return ret;
>  	}
>  
> -	pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n",
> +	dev_info(dev, "initialized. heartbeat=%d sec (nowayout=%d)\n",
>  		heartbeat, nowayout);
>  
>  	return 0;
> -- 
> 2.11.0
>
Guenter Roeck June 9, 2021, 11:54 p.m. UTC | #2
On Wed, Jun 09, 2021 at 03:32:29PM -0500, Bjorn Helgaas wrote:
> On Tue, Nov 17, 2020 at 04:22:13PM +0100, Enrico Weigelt, metux IT consult wrote:
> > For device log outputs, it's better to have device name / ID
> > prefixed in all messages, so use the proper dev_*() functions here.
> > 
> > Explicit message on module load/unload don't seem to be really helpful
> > (we have other means to check which modules have been loaded), instead
> > just add noise to the kernel log. So, removing them.
> > 
> > Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
> 
> I like this patch a lot; thanks for doing it!  It's merged upstream as
> c21172b3a73e ("watchdog: iTCO_wdt: use dev_*() instead of pr_*() for
> logging").
> 
> It looks like there are a couple more pr_err() uses, so I wondered if
> they were missed or skipped intentionally:
> 
>   if (p->smi_res) {
>           /* The TCO logic uses the TCO_EN bit in the SMI_EN register */
>           if (!devm_request_region(dev, p->smi_res->start,
>                                    resource_size(p->smi_res),
>                                    pdev->name)) {
>                   pr_err("I/O address 0x%04llx already in use, device disabled\n",
>                          (u64)SMI_EN(p));
>                   return -EBUSY;
>           }
>   } else if (iTCO_vendorsupport ||
>              turn_SMI_watchdog_clear_off >= p->iTCO_version) {
>           pr_err("SMI I/O resource is missing\n");
>           return -ENODEV;
>   }
> 
The above came in with a recent commit. I suspect they simply got lost,
and they should be converted as well.

Guenter
Enrico Weigelt, metux IT consult June 14, 2021, 5:55 p.m. UTC | #3
On 10.06.21 01:54, Guenter Roeck wrote:

> The above came in with a recent commit. I suspect they simply got lost,
> and they should be converted as well.

Since I might need to touch it again in near future, I'll do it in
one of the next rounds.


--mtx
Bjorn Helgaas June 15, 2021, 2:51 p.m. UTC | #4
On Mon, Jun 14, 2021 at 07:55:24PM +0200, Enrico Weigelt, metux IT consult wrote:
> On 10.06.21 01:54, Guenter Roeck wrote:
> 
> > The above came in with a recent commit. I suspect they simply got lost,
> > and they should be converted as well.
> 
> Since I might need to touch it again in near future, I'll do it in
> one of the next rounds.

Thanks!
diff mbox series

Patch

diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index f2ddc8fc71cd..edc588a06ae6 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -40,8 +40,6 @@ 
  *	Includes, defines, variables, module parameters, ...
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
 /* Module and version information */
 #define DRV_NAME	"iTCO_wdt"
 #define DRV_VERSION	"1.11"
@@ -279,7 +277,7 @@  static int iTCO_wdt_start(struct watchdog_device *wd_dev)
 	/* disable chipset's NO_REBOOT bit */
 	if (p->update_no_reboot_bit(p->no_reboot_priv, false)) {
 		spin_unlock(&p->io_lock);
-		pr_err("failed to reset NO_REBOOT flag, reboot disabled by hardware/BIOS\n");
+		dev_err(wd_dev->dev, "failed to reset NO_REBOOT flag, reboot disabled by hardware/BIOS\n");
 		return -EIO;
 	}
 
@@ -510,7 +508,7 @@  static int iTCO_wdt_probe(struct platform_device *pdev)
 	/* Check chipset's NO_REBOOT bit */
 	if (p->update_no_reboot_bit(p->no_reboot_priv, false) &&
 	    iTCO_vendor_check_noreboot_on()) {
-		pr_info("unable to reset NO_REBOOT flag, device disabled by hardware/BIOS\n");
+		dev_info(dev, "unable to reset NO_REBOOT flag, device disabled by hardware/BIOS\n");
 		return -ENODEV;	/* Cannot reset NO_REBOOT bit */
 	}
 
@@ -530,12 +528,12 @@  static int iTCO_wdt_probe(struct platform_device *pdev)
 	if (!devm_request_region(dev, p->tco_res->start,
 				 resource_size(p->tco_res),
 				 pdev->name)) {
-		pr_err("I/O address 0x%04llx already in use, device disabled\n",
+		dev_err(dev, "I/O address 0x%04llx already in use, device disabled\n",
 		       (u64)TCOBASE(p));
 		return -EBUSY;
 	}
 
-	pr_info("Found a %s TCO device (Version=%d, TCOBASE=0x%04llx)\n",
+	dev_info(dev, "Found a %s TCO device (Version=%d, TCOBASE=0x%04llx)\n",
 		pdata->name, pdata->version, (u64)TCOBASE(p));
 
 	/* Clear out the (probably old) status */
@@ -558,7 +556,7 @@  static int iTCO_wdt_probe(struct platform_device *pdev)
 		break;
 	}
 
-	p->wddev.info =	&ident,
+	p->wddev.info = &ident,
 	p->wddev.ops = &iTCO_wdt_ops,
 	p->wddev.bootstatus = 0;
 	p->wddev.timeout = WATCHDOG_TIMEOUT;
@@ -575,7 +573,7 @@  static int iTCO_wdt_probe(struct platform_device *pdev)
 	   if not reset to the default */
 	if (iTCO_wdt_set_timeout(&p->wddev, heartbeat)) {
 		iTCO_wdt_set_timeout(&p->wddev, WATCHDOG_TIMEOUT);
-		pr_info("timeout value out of range, using %d\n",
+		dev_info(dev, "timeout value out of range, using %d\n",
 			WATCHDOG_TIMEOUT);
 	}
 
@@ -583,11 +581,11 @@  static int iTCO_wdt_probe(struct platform_device *pdev)
 	watchdog_stop_on_unregister(&p->wddev);
 	ret = devm_watchdog_register_device(dev, &p->wddev);
 	if (ret != 0) {
-		pr_err("cannot register watchdog device (err=%d)\n", ret);
+		dev_err(dev, "cannot register watchdog device (err=%d)\n", ret);
 		return ret;
 	}
 
-	pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n",
+	dev_info(dev, "initialized. heartbeat=%d sec (nowayout=%d)\n",
 		heartbeat, nowayout);
 
 	return 0;