Skip to contentSkip to conversation

watchdog: of_xilinx_wdt: Update on xilinx watchdog driver

PATCH In review Srinivas Neeli 2 participants 8 messages Mar 29, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover watchdog: of_xilinx_wdt: Update on xilinx watchdog driver

This patch series does the following:
- Add comment to spinlock
- Used BIT macro
- Used dev_dbg()
- Remove passing null pointer
- Skip printing pointer value
---
Changes in V2:
-Updated minor review comments.
-Plan to create a separate driver for Window watchdog mode. -So dropping window watchdog related patches.
---

Srinivas Goud (3):
watchdog: of_xilinx_wdt: Add comment to spinlock
watchdog: of_xilinx_wdt: Used BIT macro
watchdog: of_xilinx_wdt: Used dev_dbg()

Srinivas Neeli (2):
watchdog: of_xilinx_wdt: Remove passing null pointer
watchdog: of_xilinx_wdt: Skip printing pointer value

 drivers/watchdog/of_xilinx_wdt.c | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)
Signature · 1 line
2.9.1
#1 lore raw

PATCH v2 1/5 watchdog: of_xilinx_wdt: Add comment to spinlock

From: Srinivas Goud <[email protected]>

Based on checkpatch every spinlock should be documented. The patch is fixing this issue:
./scripts/checkpatch.pl --strict -f drivers/watchdog/of_xilinx_wdt.c
CHECK: spinlock_t definition without comment
+ spinlock_t spinlock;

---
 drivers/watchdog/of_xilinx_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/of_xilinx_wdt.c +1 -1
index 7fe4f7c3f7ce..00549164b3d7 100644
@@ -40,7 +40,7 @@
 struct xwdt_device {
 	void __iomem *base;
 	u32 wdt_interval;
-	spinlock_t spinlock;
+	spinlock_t spinlock; /* spinlock for register handling */
 	struct watchdog_device xilinx_wdt_wdd;
 	struct clk		*clk;
 };
Signature · 1 line
2.9.1
#2 lore raw

PATCH v2 2/5 watchdog: of_xilinx_wdt: Used BIT macro

In reply to Srinivas Neeli

From: Srinivas Goud <[email protected]>

Used BIT macro instead of mask value.

---
Changes in V2:
-Included bits.h header file.

---
 drivers/watchdog/of_xilinx_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/watchdog/of_xilinx_wdt.c +5 -4
index 00549164b3d7..f76ec56859a4 100644
@@ -6,6 +6,7 @@
  * (C) Copyright 2011 (Alejandro Cabrera <[email protected]>)
  */
 
+#include <linux/bits.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/module.h>
@@ -24,12 +25,12 @@
 #define XWT_TBR_OFFSET      0x8 /* Timebase Register Offset */
 
 /* Control/Status Register Masks  */
-#define XWT_CSR0_WRS_MASK   0x00000008 /* Reset status */
-#define XWT_CSR0_WDS_MASK   0x00000004 /* Timer state  */
-#define XWT_CSR0_EWDT1_MASK 0x00000002 /* Enable bit 1 */
+#define XWT_CSR0_WRS_MASK	BIT(3) /* Reset status */
+#define XWT_CSR0_WDS_MASK	BIT(2) /* Timer state  */
+#define XWT_CSR0_EWDT1_MASK	BIT(1) /* Enable bit 1 */
 
 /* Control/Status Register 0/1 bits  */
-#define XWT_CSRX_EWDT2_MASK 0x00000001 /* Enable bit 2 */
+#define XWT_CSRX_EWDT2_MASK	BIT(0) /* Enable bit 2 */
 
 /* SelfTest constants */
 #define XWT_MAX_SELFTEST_LOOP_COUNT 0x00010000
Signature · 1 line
2.9.1
maintainer Reviewed-by on v2 2/5
#3 lore raw

Re: [PATCH V2 2/5] watchdog: of_xilinx_wdt: Used BIT macro

Quoted 7 lines · Srinivas Neeli

From: Srinivas Goud <[email protected]>

Used BIT macro instead of mask value.

Quoted 39 lines

---
Changes in V2:

(quoted diff) +0 -2
-Included bits.h header file.
---
 drivers/watchdog/of_xilinx_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/watchdog/of_xilinx_wdt.c +5 -4
index 00549164b3d7..f76ec56859a4 100644
@@ -6,6 +6,7 @@
  * (C) Copyright 2011 (Alejandro Cabrera <[email protected]>)
  */
 
+#include <linux/bits.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/module.h>
@@ -24,12 +25,12 @@
 #define XWT_TBR_OFFSET      0x8 /* Timebase Register Offset */
 
 /* Control/Status Register Masks  */
-#define XWT_CSR0_WRS_MASK   0x00000008 /* Reset status */
-#define XWT_CSR0_WDS_MASK   0x00000004 /* Timer state  */
-#define XWT_CSR0_EWDT1_MASK 0x00000002 /* Enable bit 1 */
+#define XWT_CSR0_WRS_MASK	BIT(3) /* Reset status */
+#define XWT_CSR0_WDS_MASK	BIT(2) /* Timer state  */
+#define XWT_CSR0_EWDT1_MASK	BIT(1) /* Enable bit 1 */
 
 /* Control/Status Register 0/1 bits  */
-#define XWT_CSRX_EWDT2_MASK 0x00000001 /* Enable bit 2 */
+#define XWT_CSRX_EWDT2_MASK	BIT(0) /* Enable bit 2 */
 
 /* SelfTest constants */
 #define XWT_MAX_SELFTEST_LOOP_COUNT 0x00010000
Signature · 1 line
2.9.1
#4 lore raw

PATCH v2 3/5 watchdog: of_xilinx_wdt: Used dev_dbg()

In reply to Srinivas Neeli

From: Srinivas Goud <[email protected]>

This patch removes pr_info in stop function and adds dev_dbg() in start/stop function to display device specific debug info.

---
Changes in V2:
-Updated minor review comments.

---
 drivers/watchdog/of_xilinx_wdt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/watchdog/of_xilinx_wdt.c +3 -1
index f76ec56859a4..5f31fdea517a 100644
@@ -71,6 +71,8 @@ static int xilinx_wdt_start(struct watchdog_device *wdd)
 
 	spin_unlock(&xdev->spinlock);
 
+	dev_dbg(wdd->parent, "Watchdog Started!\n");
+
 	return 0;
 }
 
@@ -92,7 +94,7 @@ static int xilinx_wdt_stop(struct watchdog_device *wdd)
 
 	clk_disable(xdev->clk);
 
-	pr_info("Stopped!\n");
+	dev_dbg(wdd->parent, "Watchdog Stopped!\n");
 
 	return 0;
 }
Signature · 1 line
2.9.1
maintainer Reviewed-by on v2 3/5
#5 lore raw

Re: [PATCH V2 3/5] watchdog: of_xilinx_wdt: Used dev_dbg()

Quoted 8 lines · Srinivas Neeli

From: Srinivas Goud <[email protected]>

This patch removes pr_info in stop function and adds dev_dbg() in start/stop function to display device specific debug info.

Quoted 32 lines

---
Changes in V2:

(quoted diff) +0 -2
-Updated minor review comments.
---
 drivers/watchdog/of_xilinx_wdt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/watchdog/of_xilinx_wdt.c +3 -1
index f76ec56859a4..5f31fdea517a 100644
@@ -71,6 +71,8 @@ static int xilinx_wdt_start(struct watchdog_device *wdd)
 
 	spin_unlock(&xdev->spinlock);
 
+	dev_dbg(wdd->parent, "Watchdog Started!\n");
+
 	return 0;
 }
 
@@ -92,7 +94,7 @@ static int xilinx_wdt_stop(struct watchdog_device *wdd)
 
 	clk_disable(xdev->clk);
 
-	pr_info("Stopped!\n");
+	dev_dbg(wdd->parent, "Watchdog Stopped!\n");
 
 	return 0;
 }
Signature · 1 line
2.9.1
#6 lore raw

PATCH v2 4/5 watchdog: of_xilinx_wdt: Remove passing null pointer

In reply to Srinivas Neeli

clk is an optional property, if clock not defined, calling clk_prepare_enable() and devm_add_action_or_reset() are not useful.
so calling these two apis only when clock is present.

Addresses-Coverity:"FORWARD_NULL"

---
 drivers/watchdog/of_xilinx_wdt.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/watchdog/of_xilinx_wdt.c +9 -10
index 5f31fdea517a..afbff79cce42 100644
@@ -211,6 +211,15 @@ static int xwdt_probe(struct platform_device *pdev)
 				 "The watchdog clock freq cannot be obtained\n");
 	} else {
 		pfreq = clk_get_rate(xdev->clk);
+		rc = clk_prepare_enable(xdev->clk);
+		if (rc) {
+			dev_err(dev, "unable to enable clock\n");
+			return rc;
+		}
+		rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare,
+					      xdev->clk);
+		if (rc)
+			return rc;
 	}
 
 	/*
@@ -224,16 +233,6 @@ static int xwdt_probe(struct platform_device *pdev)
 	spin_lock_init(&xdev->spinlock);
 	watchdog_set_drvdata(xilinx_wdt_wdd, xdev);
 
-	rc = clk_prepare_enable(xdev->clk);
-	if (rc) {
-		dev_err(dev, "unable to enable clock\n");
-		return rc;
-	}
-	rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare,
-				      xdev->clk);
-	if (rc)
-		return rc;
-
 	rc = xwdt_selftest(xdev);
 	if (rc == XWT_TIMER_FAILED) {
 		dev_err(dev, "SelfTest routine error\n");
Signature · 1 line
2.9.1
#7 lore raw

PATCH v2 5/5 watchdog: of_xilinx_wdt: Skip printing pointer value

In reply to Srinivas Neeli

"%p" is not printing the pointer value.
In driver, printing pointer value is not useful so avoiding print.

---
 drivers/watchdog/of_xilinx_wdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/of_xilinx_wdt.c +2 -2
index afbff79cce42..3318544366b8 100644
@@ -245,8 +245,8 @@ static int xwdt_probe(struct platform_device *pdev)
 
 	clk_disable(xdev->clk);
 
-	dev_info(dev, "Xilinx Watchdog Timer at %p with timeout %ds\n",
-		 xdev->base, xilinx_wdt_wdd->timeout);
+	dev_info(dev, "Xilinx Watchdog Timer with timeout %ds\n",
+		 xilinx_wdt_wdd->timeout);
 
 	platform_set_drvdata(pdev, xdev);
 
Signature · 1 line
2.9.1