All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: s3c/rx1950: Use pwm_get() in favour of pwm_request()
@ 2021-03-26  9:06 ` Uwe Kleine-König
  0 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2021-03-26  9:06 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Thierry Reding, Lee Jones, linux-pwm, linux-arm-kernel,
	linux-samsung-soc, kernel

pwm_request() is deprecated because (among others) it depends on a global
numbering of PWM devices. So register a pwm_lookup to pick the right PWM
device (identified by provider and its local id) and use pwm_get().

Before this patch the PWM #1 was used. This is provided by the
samsung-pwm device which is the only PWM provider on this machine. The
local offset is 1, see also commit c107fe904a10 ("ARM: S3C24XX: Use PWM
lookup table for mach-rx1950") with a similar conversion for PWM #0.

As a follow up specify the period only once and symmetrically use pwm_put()
instead of pwm_free() to drop the reference.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

it looks a bit strange to me that the backlight requires two PWMs. But I
think the conversion is done correctly and the code behaves as it did
before.

Best regards
Uwe

 arch/arm/mach-s3c/mach-rx1950.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-s3c/mach-rx1950.c b/arch/arm/mach-s3c/mach-rx1950.c
index 6e19add158a9..a3f46aa61c45 100644
--- a/arch/arm/mach-s3c/mach-rx1950.c
+++ b/arch/arm/mach-s3c/mach-rx1950.c
@@ -384,6 +384,8 @@ static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
 static struct pwm_lookup rx1950_pwm_lookup[] = {
 	PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight.0", NULL, 48000,
 		   PWM_POLARITY_NORMAL),
+	PWM_LOOKUP("samsung-pwm", 1, "pwm-backlight.0", "RX1950 LCD", LCD_PWM_PERIOD,
+		   PWM_POLARITY_NORMAL),
 };
 
 static struct pwm_device *lcd_pwm;
@@ -498,19 +500,18 @@ static void rx1950_bl_power(int enable)
 static int rx1950_backlight_init(struct device *dev)
 {
 	WARN_ON(gpio_request(S3C2410_GPB(0), "Backlight"));
-	lcd_pwm = pwm_request(1, "RX1950 LCD");
+	lcd_pwm = pwm_get(dev, "RX1950 LCD");
 	if (IS_ERR(lcd_pwm)) {
 		dev_err(dev, "Unable to request PWM for LCD power!\n");
 		return PTR_ERR(lcd_pwm);
 	}
 
 	/*
-	 * This is only required to initialize .polarity; all other values are
-	 * fixed in this driver.
+	 * Call pwm_init_state to initialize .polarity and .period. The other
+	 * values are fixed in this driver.
 	 */
 	pwm_init_state(lcd_pwm, &lcd_pwm_state);
 
-	lcd_pwm_state.period = LCD_PWM_PERIOD;
 	lcd_pwm_state.duty_cycle = LCD_PWM_DUTY;
 
 	rx1950_lcd_power(1);
@@ -524,7 +525,7 @@ static void rx1950_backlight_exit(struct device *dev)
 	rx1950_bl_power(0);
 	rx1950_lcd_power(0);
 
-	pwm_free(lcd_pwm);
+	pwm_put(lcd_pwm);
 	gpio_free(S3C2410_GPB(0));
 }
 
-- 
2.30.2


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

* [PATCH] ARM: s3c/rx1950: Use pwm_get() in favour of pwm_request()
@ 2021-03-26  9:06 ` Uwe Kleine-König
  0 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2021-03-26  9:06 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Thierry Reding, Lee Jones, linux-pwm, linux-arm-kernel,
	linux-samsung-soc, kernel

pwm_request() is deprecated because (among others) it depends on a global
numbering of PWM devices. So register a pwm_lookup to pick the right PWM
device (identified by provider and its local id) and use pwm_get().

Before this patch the PWM #1 was used. This is provided by the
samsung-pwm device which is the only PWM provider on this machine. The
local offset is 1, see also commit c107fe904a10 ("ARM: S3C24XX: Use PWM
lookup table for mach-rx1950") with a similar conversion for PWM #0.

As a follow up specify the period only once and symmetrically use pwm_put()
instead of pwm_free() to drop the reference.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

it looks a bit strange to me that the backlight requires two PWMs. But I
think the conversion is done correctly and the code behaves as it did
before.

Best regards
Uwe

 arch/arm/mach-s3c/mach-rx1950.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-s3c/mach-rx1950.c b/arch/arm/mach-s3c/mach-rx1950.c
index 6e19add158a9..a3f46aa61c45 100644
--- a/arch/arm/mach-s3c/mach-rx1950.c
+++ b/arch/arm/mach-s3c/mach-rx1950.c
@@ -384,6 +384,8 @@ static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
 static struct pwm_lookup rx1950_pwm_lookup[] = {
 	PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight.0", NULL, 48000,
 		   PWM_POLARITY_NORMAL),
+	PWM_LOOKUP("samsung-pwm", 1, "pwm-backlight.0", "RX1950 LCD", LCD_PWM_PERIOD,
+		   PWM_POLARITY_NORMAL),
 };
 
 static struct pwm_device *lcd_pwm;
@@ -498,19 +500,18 @@ static void rx1950_bl_power(int enable)
 static int rx1950_backlight_init(struct device *dev)
 {
 	WARN_ON(gpio_request(S3C2410_GPB(0), "Backlight"));
-	lcd_pwm = pwm_request(1, "RX1950 LCD");
+	lcd_pwm = pwm_get(dev, "RX1950 LCD");
 	if (IS_ERR(lcd_pwm)) {
 		dev_err(dev, "Unable to request PWM for LCD power!\n");
 		return PTR_ERR(lcd_pwm);
 	}
 
 	/*
-	 * This is only required to initialize .polarity; all other values are
-	 * fixed in this driver.
+	 * Call pwm_init_state to initialize .polarity and .period. The other
+	 * values are fixed in this driver.
 	 */
 	pwm_init_state(lcd_pwm, &lcd_pwm_state);
 
-	lcd_pwm_state.period = LCD_PWM_PERIOD;
 	lcd_pwm_state.duty_cycle = LCD_PWM_DUTY;
 
 	rx1950_lcd_power(1);
@@ -524,7 +525,7 @@ static void rx1950_backlight_exit(struct device *dev)
 	rx1950_bl_power(0);
 	rx1950_lcd_power(0);
 
-	pwm_free(lcd_pwm);
+	pwm_put(lcd_pwm);
 	gpio_free(S3C2410_GPB(0));
 }
 
-- 
2.30.2


_______________________________________________
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] 4+ messages in thread

* Re: [PATCH] ARM: s3c/rx1950: Use pwm_get() in favour of pwm_request()
  2021-03-26  9:06 ` Uwe Kleine-König
@ 2021-04-01 17:41   ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-01 17:41 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Uwe Kleine-König
  Cc: Krzysztof Kozlowski, Lee Jones, linux-arm-kernel, linux-pwm,
	linux-samsung-soc, kernel, Thierry Reding

On Fri, 26 Mar 2021 10:06:41 +0100, Uwe Kleine-König wrote:
> pwm_request() is deprecated because (among others) it depends on a global
> numbering of PWM devices. So register a pwm_lookup to pick the right PWM
> device (identified by provider and its local id) and use pwm_get().
> 
> Before this patch the PWM #1 was used. This is provided by the
> samsung-pwm device which is the only PWM provider on this machine. The
> local offset is 1, see also commit c107fe904a10 ("ARM: S3C24XX: Use PWM
> lookup table for mach-rx1950") with a similar conversion for PWM #0.
> 
> [...]

Applied, thanks!

[1/1] ARM: s3c/rx1950: Use pwm_get() in favour of pwm_request()
      commit: 19f5027e0394d2f3e1766200b6bbde660f0b7848

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

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

* Re: [PATCH] ARM: s3c/rx1950: Use pwm_get() in favour of pwm_request()
@ 2021-04-01 17:41   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-01 17:41 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Uwe Kleine-König
  Cc: Krzysztof Kozlowski, Lee Jones, linux-arm-kernel, linux-pwm,
	linux-samsung-soc, kernel, Thierry Reding

On Fri, 26 Mar 2021 10:06:41 +0100, Uwe Kleine-König wrote:
> pwm_request() is deprecated because (among others) it depends on a global
> numbering of PWM devices. So register a pwm_lookup to pick the right PWM
> device (identified by provider and its local id) and use pwm_get().
> 
> Before this patch the PWM #1 was used. This is provided by the
> samsung-pwm device which is the only PWM provider on this machine. The
> local offset is 1, see also commit c107fe904a10 ("ARM: S3C24XX: Use PWM
> lookup table for mach-rx1950") with a similar conversion for PWM #0.
> 
> [...]

Applied, thanks!

[1/1] ARM: s3c/rx1950: Use pwm_get() in favour of pwm_request()
      commit: 19f5027e0394d2f3e1766200b6bbde660f0b7848

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] 4+ messages in thread

end of thread, other threads:[~2021-04-01 20:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26  9:06 [PATCH] ARM: s3c/rx1950: Use pwm_get() in favour of pwm_request() Uwe Kleine-König
2021-03-26  9:06 ` Uwe Kleine-König
2021-04-01 17:41 ` Krzysztof Kozlowski
2021-04-01 17:41   ` Krzysztof Kozlowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.