linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup
@ 2021-05-06 20:27 Krzysztof Kozlowski
  2021-05-06 20:27 ` [PATCH 2/5] clocksource/drivers/samsung_pwm: Constify passed structure Krzysztof Kozlowski
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-06 20:27 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Daniel Lezcano, Thomas Gleixner,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

Cleanup the code to be slightly more readable and follow coding
convention - only whitespace.  This fixes checkpatch warnings:

  WARNING: Block comments should align the * on each line
  WARNING: please, no space before tabs
  WARNING: Missing a blank line after declarations
  CHECK: Alignment should match open parenthesis

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/clocksource/samsung_pwm_timer.c | 19 +++++++++++--------
 include/clocksource/samsung_pwm.h       |  3 ++-
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c
index f760229d0c7f..69bf79c7f462 100644
--- a/drivers/clocksource/samsung_pwm_timer.c
+++ b/drivers/clocksource/samsung_pwm_timer.c
@@ -4,7 +4,7 @@
  *		http://www.samsung.com/
  *
  * samsung - Common hr-timer support (s3c and s5p)
-*/
+ */
 
 #include <linux/interrupt.h>
 #include <linux/irq.h>
@@ -22,7 +22,6 @@
 
 #include <clocksource/samsung_pwm.h>
 
-
 /*
  * Clocksource driver
  */
@@ -38,8 +37,8 @@
 #define TCFG0_PRESCALER_MASK		0xff
 #define TCFG0_PRESCALER1_SHIFT		8
 
-#define TCFG1_SHIFT(x)	  		((x) * 4)
-#define TCFG1_MUX_MASK	  		0xf
+#define TCFG1_SHIFT(x)			((x) * 4)
+#define TCFG1_MUX_MASK			0xf
 
 /*
  * Each channel occupies 4 bits in TCON register, but there is a gap of 4
@@ -183,7 +182,7 @@ static void samsung_time_start(unsigned int channel, bool periodic)
 }
 
 static int samsung_set_next_event(unsigned long cycles,
-				struct clock_event_device *evt)
+				  struct clock_event_device *evt)
 {
 	/*
 	 * This check is needed to account for internal rounding
@@ -225,6 +224,7 @@ static void samsung_clockevent_resume(struct clock_event_device *cev)
 
 	if (pwm.variant.has_tint_cstat) {
 		u32 mask = (1 << pwm.event_id);
+
 		writel(mask | (mask << 5), pwm.base + REG_TINT_CSTAT);
 	}
 }
@@ -248,6 +248,7 @@ static irqreturn_t samsung_clock_event_isr(int irq, void *dev_id)
 
 	if (pwm.variant.has_tint_cstat) {
 		u32 mask = (1 << pwm.event_id);
+
 		writel(mask | (mask << 5), pwm.base + REG_TINT_CSTAT);
 	}
 
@@ -272,7 +273,7 @@ static void __init samsung_clockevent_init(void)
 
 	time_event_device.cpumask = cpumask_of(0);
 	clockevents_config_and_register(&time_event_device,
-						clock_rate, 1, pwm.tcnt_max);
+					clock_rate, 1, pwm.tcnt_max);
 
 	irq_number = pwm.irq[pwm.event_id];
 	if (request_irq(irq_number, samsung_clock_event_isr,
@@ -282,6 +283,7 @@ static void __init samsung_clockevent_init(void)
 
 	if (pwm.variant.has_tint_cstat) {
 		u32 mask = (1 << pwm.event_id);
+
 		writel(mask | (mask << 5), pwm.base + REG_TINT_CSTAT);
 	}
 }
@@ -347,7 +349,7 @@ static int __init samsung_clocksource_init(void)
 		pwm.source_reg = pwm.base + pwm.source_id * 0x0c + 0x14;
 
 	sched_clock_register(samsung_read_sched_clock,
-						pwm.variant.bits, clock_rate);
+			     pwm.variant.bits, clock_rate);
 
 	samsung_clocksource.mask = CLOCKSOURCE_MASK(pwm.variant.bits);
 	return clocksource_register_hz(&samsung_clocksource, clock_rate);
@@ -398,7 +400,8 @@ static int __init _samsung_pwm_clocksource_init(void)
 }
 
 void __init samsung_pwm_clocksource_init(void __iomem *base,
-			unsigned int *irqs, struct samsung_pwm_variant *variant)
+					 unsigned int *irqs,
+					 struct samsung_pwm_variant *variant)
 {
 	pwm.base = base;
 	memcpy(&pwm.variant, variant, sizeof(pwm.variant));
diff --git a/include/clocksource/samsung_pwm.h b/include/clocksource/samsung_pwm.h
index c395238d0922..76341988fb4f 100644
--- a/include/clocksource/samsung_pwm.h
+++ b/include/clocksource/samsung_pwm.h
@@ -27,6 +27,7 @@ struct samsung_pwm_variant {
 };
 
 void samsung_pwm_clocksource_init(void __iomem *base,
-		unsigned int *irqs, struct samsung_pwm_variant *variant);
+				  unsigned int *irqs,
+				  struct samsung_pwm_variant *variant);
 
 #endif /* __CLOCKSOURCE_SAMSUNG_PWM_H */
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] clocksource/drivers/samsung_pwm: Constify passed structure
  2021-05-06 20:27 [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup Krzysztof Kozlowski
@ 2021-05-06 20:27 ` Krzysztof Kozlowski
  2021-05-06 20:27 ` [PATCH 3/5] clocksource/drivers/samsung_pwm: Cleanup on init error Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-06 20:27 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Daniel Lezcano, Thomas Gleixner,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

The 'struct samsung_pwm_variant' argument passed to initialization
functions is not modified, so it can be made const for safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/clocksource/samsung_pwm_timer.c | 2 +-
 include/clocksource/samsung_pwm.h       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c
index 69bf79c7f462..bfad61b509f9 100644
--- a/drivers/clocksource/samsung_pwm_timer.c
+++ b/drivers/clocksource/samsung_pwm_timer.c
@@ -401,7 +401,7 @@ static int __init _samsung_pwm_clocksource_init(void)
 
 void __init samsung_pwm_clocksource_init(void __iomem *base,
 					 unsigned int *irqs,
-					 struct samsung_pwm_variant *variant)
+					 const struct samsung_pwm_variant *variant)
 {
 	pwm.base = base;
 	memcpy(&pwm.variant, variant, sizeof(pwm.variant));
diff --git a/include/clocksource/samsung_pwm.h b/include/clocksource/samsung_pwm.h
index 76341988fb4f..9b435caa95fe 100644
--- a/include/clocksource/samsung_pwm.h
+++ b/include/clocksource/samsung_pwm.h
@@ -28,6 +28,6 @@ struct samsung_pwm_variant {
 
 void samsung_pwm_clocksource_init(void __iomem *base,
 				  unsigned int *irqs,
-				  struct samsung_pwm_variant *variant);
+				  const struct samsung_pwm_variant *variant);
 
 #endif /* __CLOCKSOURCE_SAMSUNG_PWM_H */
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] clocksource/drivers/samsung_pwm: Cleanup on init error
  2021-05-06 20:27 [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup Krzysztof Kozlowski
  2021-05-06 20:27 ` [PATCH 2/5] clocksource/drivers/samsung_pwm: Constify passed structure Krzysztof Kozlowski
@ 2021-05-06 20:27 ` Krzysztof Kozlowski
  2021-05-06 20:27 ` [PATCH 4/5] clocksource/drivers/samsung_pwm: Constify source IO memory Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-06 20:27 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Daniel Lezcano, Thomas Gleixner,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

Failure of timer initialization is likely to be fatal for the system, so
cleanup in such case is not strictly necessary.  However the code might
be refactored or reused, so better not to rely on such assumption that
system won't continue init failure.

Unmap the IO memory and put the clock on initialization failures from
devicetree.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

---

Not marking as cc-stable and not adding Fixes tag, as this is not really
a bug.
---
 drivers/clocksource/samsung_pwm_timer.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c
index bfad61b509f9..55e2f9fa2a15 100644
--- a/drivers/clocksource/samsung_pwm_timer.c
+++ b/drivers/clocksource/samsung_pwm_timer.c
@@ -421,7 +421,7 @@ static int __init samsung_pwm_alloc(struct device_node *np,
 	struct property *prop;
 	const __be32 *cur;
 	u32 val;
-	int i;
+	int i, ret;
 
 	memcpy(&pwm.variant, variant, sizeof(pwm.variant));
 	for (i = 0; i < SAMSUNG_PWM_NUM; ++i)
@@ -444,10 +444,24 @@ static int __init samsung_pwm_alloc(struct device_node *np,
 	pwm.timerclk = of_clk_get_by_name(np, "timers");
 	if (IS_ERR(pwm.timerclk)) {
 		pr_crit("failed to get timers clock for timer\n");
-		return PTR_ERR(pwm.timerclk);
+		ret = PTR_ERR(pwm.timerclk);
+		goto err_clk;
 	}
 
-	return _samsung_pwm_clocksource_init();
+	ret = _samsung_pwm_clocksource_init();
+	if (ret)
+		goto err_clocksource;
+
+	return 0;
+
+err_clocksource:
+	clk_put(pwm.timerclk);
+	pwm.timerclk = NULL;
+err_clk:
+	iounmap(pwm.base);
+	pwm.base = NULL;
+
+	return ret;
 }
 
 static const struct samsung_pwm_variant s3c24xx_variant = {
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] clocksource/drivers/samsung_pwm: Constify source IO memory
  2021-05-06 20:27 [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup Krzysztof Kozlowski
  2021-05-06 20:27 ` [PATCH 2/5] clocksource/drivers/samsung_pwm: Constify passed structure Krzysztof Kozlowski
  2021-05-06 20:27 ` [PATCH 3/5] clocksource/drivers/samsung_pwm: Cleanup on init error Krzysztof Kozlowski
@ 2021-05-06 20:27 ` Krzysztof Kozlowski
  2021-05-06 20:27 ` [PATCH 5/5] MAINTAINERS: Include Samsung PWM in Samsung SoC entry Krzysztof Kozlowski
  2021-05-27 16:01 ` (subset) [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup Krzysztof Kozlowski
  4 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-06 20:27 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Daniel Lezcano, Thomas Gleixner,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

The 'source_reg' IO memory is only read, so the pointer can point to
const for safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/clocksource/samsung_pwm_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c
index 55e2f9fa2a15..6e46781bc9ac 100644
--- a/drivers/clocksource/samsung_pwm_timer.c
+++ b/drivers/clocksource/samsung_pwm_timer.c
@@ -61,7 +61,7 @@ EXPORT_SYMBOL(samsung_pwm_lock);
 
 struct samsung_pwm_clocksource {
 	void __iomem *base;
-	void __iomem *source_reg;
+	const void __iomem *source_reg;
 	unsigned int irq[SAMSUNG_PWM_NUM];
 	struct samsung_pwm_variant variant;
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] MAINTAINERS: Include Samsung PWM in Samsung SoC entry
  2021-05-06 20:27 [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2021-05-06 20:27 ` [PATCH 4/5] clocksource/drivers/samsung_pwm: Constify source IO memory Krzysztof Kozlowski
@ 2021-05-06 20:27 ` Krzysztof Kozlowski
  2021-05-27 16:01 ` (subset) [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup Krzysztof Kozlowski
  4 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-06 20:27 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Daniel Lezcano, Thomas Gleixner,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

The Samsung PWM and PWM-based timer/clocksource drivers lacked dedicated
maintainers entry.  They are used on all Samsung SoC designs (although
timer/clocksource driver only on older platforms), so include them in
Samsung SoC entry maintained by Krzysztof Kozlowski.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

---

This can go via clocksource/drivers tree or I can take it via Samsung
SoC.
---
 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index efeaebe1bcae..bb9c5815a308 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2436,9 +2436,12 @@ F:	drivers/*/*/*s3c24*
 F:	drivers/*/*s3c24*
 F:	drivers/*/*s3c64xx*
 F:	drivers/*/*s5pv210*
+F:	drivers/clocksource/samsung_pwm_timer.c
 F:	drivers/memory/samsung/
+F:	drivers/pwm/pwm-samsung.c
 F:	drivers/soc/samsung/
 F:	drivers/tty/serial/samsung*
+F:	include/clocksource/samsung_pwm.h
 F:	include/linux/platform_data/*s3c*
 F:	include/linux/serial_s3c.h
 F:	include/linux/soc/samsung/
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: (subset) [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup
  2021-05-06 20:27 [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  2021-05-06 20:27 ` [PATCH 5/5] MAINTAINERS: Include Samsung PWM in Samsung SoC entry Krzysztof Kozlowski
@ 2021-05-27 16:01 ` Krzysztof Kozlowski
  4 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-27 16:01 UTC (permalink / raw)
  To: linux-kernel, linux-samsung-soc, Daniel Lezcano,
	Krzysztof Kozlowski, linux-arm-kernel, Thomas Gleixner

On Thu, 6 May 2021 16:27:25 -0400, Krzysztof Kozlowski wrote:
> Cleanup the code to be slightly more readable and follow coding
> convention - only whitespace.  This fixes checkpatch warnings:
> 
>   WARNING: Block comments should align the * on each line
>   WARNING: please, no space before tabs
>   WARNING: Missing a blank line after declarations
>   CHECK: Alignment should match open parenthesis

Applied, thanks!

[5/5] MAINTAINERS: Include Samsung PWM in Samsung SoC entry
      commit: a6419e53c779302f8d5dd409eccf5b41ffa184a4

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-27 17:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 20:27 [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup Krzysztof Kozlowski
2021-05-06 20:27 ` [PATCH 2/5] clocksource/drivers/samsung_pwm: Constify passed structure Krzysztof Kozlowski
2021-05-06 20:27 ` [PATCH 3/5] clocksource/drivers/samsung_pwm: Cleanup on init error Krzysztof Kozlowski
2021-05-06 20:27 ` [PATCH 4/5] clocksource/drivers/samsung_pwm: Constify source IO memory Krzysztof Kozlowski
2021-05-06 20:27 ` [PATCH 5/5] MAINTAINERS: Include Samsung PWM in Samsung SoC entry Krzysztof Kozlowski
2021-05-27 16:01 ` (subset) [PATCH 1/5] clocksource/drivers/samsung_pwm: Minor whitespace cleanup Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).