All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] hwmon: (aspeed-g6-pwm-tacho): Prepare for further pwm core changes
@ 2024-03-18 16:09 ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2024-03-18 16:09 UTC (permalink / raw
  To: Jean Delvare, Guenter Roeck, Joel Stanley
  Cc: Andrew Jeffery, linux-hwmon, linux-arm-kernel, linux-aspeed,
	linux-pwm, kernel

Hello,

there is a pending rework for the pwm framework[1] that requires a
preparatory change for all pwm drivers. When creating them I wasn't
aware of the aspeed-g6-pwm-tacho driver, just found this now while doing
build tests with my series.

To not delay application of my series, I'd like to take the two patches
from this series via my pwm tree.

To state the (maybe) obvious: This series depends on the following commits:

	7e1449cd15d1 "hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach"
	024913dbf99f pwm: Provide pwmchip_alloc() function and a devm variant of it
	4e59267c7a20 pwm: Provide an inline function to get the parent device of a given chip

The earliest commit containing all those is:

	15223fdbdf4f "Merge tag 'hwmon-for-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging"

Best regards
Uwe

[1] https://lore.kernel.org/linux-pwm/cover.1710670958.git.u.kleine-koenig@pengutronix.de

Uwe Kleine-König (2):
  hwmon: (aspeed-g6-pwm-tacho): Make use of pwmchip_parent() accessor
  hwmon: (aspeed-g6-pwm-tacho): Make use of devm_pwmchip_alloc()
    function

 drivers/hwmon/aspeed-g6-pwm-tach.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

base-commit: f6cef5f8c37f58a3bc95b3754c3ae98e086631ca
-- 
2.43.0


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

* [PATCH 0/2] hwmon: (aspeed-g6-pwm-tacho): Prepare for further pwm core changes
@ 2024-03-18 16:09 ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2024-03-18 16:09 UTC (permalink / raw
  To: Jean Delvare, Guenter Roeck, Joel Stanley
  Cc: Andrew Jeffery, linux-hwmon, linux-arm-kernel, linux-aspeed,
	linux-pwm, kernel

Hello,

there is a pending rework for the pwm framework[1] that requires a
preparatory change for all pwm drivers. When creating them I wasn't
aware of the aspeed-g6-pwm-tacho driver, just found this now while doing
build tests with my series.

To not delay application of my series, I'd like to take the two patches
from this series via my pwm tree.

To state the (maybe) obvious: This series depends on the following commits:

	7e1449cd15d1 "hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach"
	024913dbf99f pwm: Provide pwmchip_alloc() function and a devm variant of it
	4e59267c7a20 pwm: Provide an inline function to get the parent device of a given chip

The earliest commit containing all those is:

	15223fdbdf4f "Merge tag 'hwmon-for-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging"

Best regards
Uwe

[1] https://lore.kernel.org/linux-pwm/cover.1710670958.git.u.kleine-koenig@pengutronix.de

Uwe Kleine-König (2):
  hwmon: (aspeed-g6-pwm-tacho): Make use of pwmchip_parent() accessor
  hwmon: (aspeed-g6-pwm-tacho): Make use of devm_pwmchip_alloc()
    function

 drivers/hwmon/aspeed-g6-pwm-tach.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

base-commit: f6cef5f8c37f58a3bc95b3754c3ae98e086631ca
-- 
2.43.0


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

* [PATCH 1/2] hwmon: (aspeed-g6-pwm-tacho): Make use of pwmchip_parent() accessor
  2024-03-18 16:09 ` Uwe Kleine-König
@ 2024-03-18 16:09   ` Uwe Kleine-König
  -1 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2024-03-18 16:09 UTC (permalink / raw
  To: Jean Delvare, Guenter Roeck, Joel Stanley
  Cc: Andrew Jeffery, linux-hwmon, linux-arm-kernel, linux-aspeed,
	linux-pwm, kernel

struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/hwmon/aspeed-g6-pwm-tach.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/aspeed-g6-pwm-tach.c b/drivers/hwmon/aspeed-g6-pwm-tach.c
index 597b3b019d49..64def5e4cdf6 100644
--- a/drivers/hwmon/aspeed-g6-pwm-tach.c
+++ b/drivers/hwmon/aspeed-g6-pwm-tach.c
@@ -195,7 +195,7 @@ static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 	expect_period = div64_u64(ULLONG_MAX, (u64)priv->clk_rate);
 	expect_period = min(expect_period, state->period);
-	dev_dbg(chip->dev, "expect period: %lldns, duty_cycle: %lldns",
+	dev_dbg(pwmchip_parent(chip), "expect period: %lldns, duty_cycle: %lldns",
 		expect_period, state->duty_cycle);
 	/*
 	 * Pick the smallest value for div_h so that div_l can be the biggest
@@ -218,12 +218,12 @@ static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	if (div_l > 255)
 		div_l = 255;
 
-	dev_dbg(chip->dev, "clk source: %ld div_h %lld, div_l : %lld\n",
+	dev_dbg(pwmchip_parent(chip), "clk source: %ld div_h %lld, div_l : %lld\n",
 		priv->clk_rate, div_h, div_l);
 	/* duty_pt = duty_cycle * (PERIOD + 1) / period */
 	duty_pt = div64_u64(state->duty_cycle * priv->clk_rate,
 			    (u64)NSEC_PER_SEC * (div_l + 1) << div_h);
-	dev_dbg(chip->dev, "duty_cycle = %lld, duty_pt = %d\n",
+	dev_dbg(pwmchip_parent(chip), "duty_cycle = %lld, duty_pt = %d\n",
 		state->duty_cycle, duty_pt);
 
 	/*
-- 
2.43.0


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

* [PATCH 1/2] hwmon: (aspeed-g6-pwm-tacho): Make use of pwmchip_parent() accessor
@ 2024-03-18 16:09   ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2024-03-18 16:09 UTC (permalink / raw
  To: Jean Delvare, Guenter Roeck, Joel Stanley
  Cc: Andrew Jeffery, linux-hwmon, linux-arm-kernel, linux-aspeed,
	linux-pwm, kernel

struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/hwmon/aspeed-g6-pwm-tach.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/aspeed-g6-pwm-tach.c b/drivers/hwmon/aspeed-g6-pwm-tach.c
index 597b3b019d49..64def5e4cdf6 100644
--- a/drivers/hwmon/aspeed-g6-pwm-tach.c
+++ b/drivers/hwmon/aspeed-g6-pwm-tach.c
@@ -195,7 +195,7 @@ static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 	expect_period = div64_u64(ULLONG_MAX, (u64)priv->clk_rate);
 	expect_period = min(expect_period, state->period);
-	dev_dbg(chip->dev, "expect period: %lldns, duty_cycle: %lldns",
+	dev_dbg(pwmchip_parent(chip), "expect period: %lldns, duty_cycle: %lldns",
 		expect_period, state->duty_cycle);
 	/*
 	 * Pick the smallest value for div_h so that div_l can be the biggest
@@ -218,12 +218,12 @@ static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	if (div_l > 255)
 		div_l = 255;
 
-	dev_dbg(chip->dev, "clk source: %ld div_h %lld, div_l : %lld\n",
+	dev_dbg(pwmchip_parent(chip), "clk source: %ld div_h %lld, div_l : %lld\n",
 		priv->clk_rate, div_h, div_l);
 	/* duty_pt = duty_cycle * (PERIOD + 1) / period */
 	duty_pt = div64_u64(state->duty_cycle * priv->clk_rate,
 			    (u64)NSEC_PER_SEC * (div_l + 1) << div_h);
-	dev_dbg(chip->dev, "duty_cycle = %lld, duty_pt = %d\n",
+	dev_dbg(pwmchip_parent(chip), "duty_cycle = %lld, duty_pt = %d\n",
 		state->duty_cycle, duty_pt);
 
 	/*
-- 
2.43.0


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

* [PATCH 2/2] hwmon: (aspeed-g6-pwm-tacho): Make use of devm_pwmchip_alloc() function
  2024-03-18 16:09 ` Uwe Kleine-König
@ 2024-03-18 16:09   ` Uwe Kleine-König
  -1 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2024-03-18 16:09 UTC (permalink / raw
  To: Jean Delvare, Guenter Roeck, Joel Stanley
  Cc: Andrew Jeffery, linux-hwmon, linux-arm-kernel, linux-aspeed,
	linux-pwm, kernel

This prepares the aspeed-g6-pwm-tacho driver to further changes of the
pwm core outlined in the commit introducing devm_pwmchip_alloc(). There
is no intended semantical change and the driver should behave as before.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/hwmon/aspeed-g6-pwm-tach.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/aspeed-g6-pwm-tach.c b/drivers/hwmon/aspeed-g6-pwm-tach.c
index 64def5e4cdf6..332c02216668 100644
--- a/drivers/hwmon/aspeed-g6-pwm-tach.c
+++ b/drivers/hwmon/aspeed-g6-pwm-tach.c
@@ -136,7 +136,6 @@ struct aspeed_pwm_tach_data {
 	struct clk *clk;
 	struct reset_control *reset;
 	unsigned long clk_rate;
-	struct pwm_chip chip;
 	bool tach_present[TACH_ASPEED_NR_TACHS];
 	u32 tach_divisor;
 };
@@ -144,7 +143,7 @@ struct aspeed_pwm_tach_data {
 static inline struct aspeed_pwm_tach_data *
 aspeed_pwm_chip_to_data(struct pwm_chip *chip)
 {
-	return container_of(chip, struct aspeed_pwm_tach_data, chip);
+	return pwmchip_get_drvdata(chip);
 }
 
 static int aspeed_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
@@ -459,6 +458,7 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev)
 	int ret;
 	struct device_node *child;
 	struct aspeed_pwm_tach_data *priv;
+	struct pwm_chip *chip;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -487,11 +487,14 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	priv->chip.dev = dev;
-	priv->chip.ops = &aspeed_pwm_ops;
-	priv->chip.npwm = PWM_ASPEED_NR_PWMS;
+	chip = devm_pwmchip_alloc(dev, PWM_ASPEED_NR_PWMS, 0);
+	if (IS_ERR(chip))
+		return PTR_ERR(chip);
 
-	ret = devm_pwmchip_add(dev, &priv->chip);
+	pwmchip_set_drvdata(chip, priv);
+	chip->ops = &aspeed_pwm_ops;
+
+	ret = devm_pwmchip_add(dev, chip);
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to add PWM chip\n");
 
-- 
2.43.0


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

* [PATCH 2/2] hwmon: (aspeed-g6-pwm-tacho): Make use of devm_pwmchip_alloc() function
@ 2024-03-18 16:09   ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2024-03-18 16:09 UTC (permalink / raw
  To: Jean Delvare, Guenter Roeck, Joel Stanley
  Cc: Andrew Jeffery, linux-hwmon, linux-arm-kernel, linux-aspeed,
	linux-pwm, kernel

This prepares the aspeed-g6-pwm-tacho driver to further changes of the
pwm core outlined in the commit introducing devm_pwmchip_alloc(). There
is no intended semantical change and the driver should behave as before.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/hwmon/aspeed-g6-pwm-tach.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/aspeed-g6-pwm-tach.c b/drivers/hwmon/aspeed-g6-pwm-tach.c
index 64def5e4cdf6..332c02216668 100644
--- a/drivers/hwmon/aspeed-g6-pwm-tach.c
+++ b/drivers/hwmon/aspeed-g6-pwm-tach.c
@@ -136,7 +136,6 @@ struct aspeed_pwm_tach_data {
 	struct clk *clk;
 	struct reset_control *reset;
 	unsigned long clk_rate;
-	struct pwm_chip chip;
 	bool tach_present[TACH_ASPEED_NR_TACHS];
 	u32 tach_divisor;
 };
@@ -144,7 +143,7 @@ struct aspeed_pwm_tach_data {
 static inline struct aspeed_pwm_tach_data *
 aspeed_pwm_chip_to_data(struct pwm_chip *chip)
 {
-	return container_of(chip, struct aspeed_pwm_tach_data, chip);
+	return pwmchip_get_drvdata(chip);
 }
 
 static int aspeed_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
@@ -459,6 +458,7 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev)
 	int ret;
 	struct device_node *child;
 	struct aspeed_pwm_tach_data *priv;
+	struct pwm_chip *chip;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -487,11 +487,14 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	priv->chip.dev = dev;
-	priv->chip.ops = &aspeed_pwm_ops;
-	priv->chip.npwm = PWM_ASPEED_NR_PWMS;
+	chip = devm_pwmchip_alloc(dev, PWM_ASPEED_NR_PWMS, 0);
+	if (IS_ERR(chip))
+		return PTR_ERR(chip);
 
-	ret = devm_pwmchip_add(dev, &priv->chip);
+	pwmchip_set_drvdata(chip, priv);
+	chip->ops = &aspeed_pwm_ops;
+
+	ret = devm_pwmchip_add(dev, chip);
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to add PWM chip\n");
 
-- 
2.43.0


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

* Re: [PATCH 1/2] hwmon: (aspeed-g6-pwm-tacho): Make use of pwmchip_parent() accessor
  2024-03-18 16:09   ` Uwe Kleine-König
@ 2024-03-18 16:44     ` Guenter Roeck
  -1 siblings, 0 replies; 12+ messages in thread
From: Guenter Roeck @ 2024-03-18 16:44 UTC (permalink / raw
  To: Uwe Kleine-König, Jean Delvare, Joel Stanley
  Cc: Andrew Jeffery, linux-hwmon, linux-arm-kernel, linux-aspeed,
	linux-pwm, kernel

On 3/18/24 09:09, Uwe Kleine-König wrote:
> struct pwm_chip::dev is about to change. To not have to touch this
> driver in the same commit as struct pwm_chip::dev, use the accessor
> function provided for exactly this purpose.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/hwmon/aspeed-g6-pwm-tach.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/aspeed-g6-pwm-tach.c b/drivers/hwmon/aspeed-g6-pwm-tach.c
> index 597b3b019d49..64def5e4cdf6 100644
> --- a/drivers/hwmon/aspeed-g6-pwm-tach.c
> +++ b/drivers/hwmon/aspeed-g6-pwm-tach.c
> @@ -195,7 +195,7 @@ static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>   
>   	expect_period = div64_u64(ULLONG_MAX, (u64)priv->clk_rate);
>   	expect_period = min(expect_period, state->period);
> -	dev_dbg(chip->dev, "expect period: %lldns, duty_cycle: %lldns",
> +	dev_dbg(pwmchip_parent(chip), "expect period: %lldns, duty_cycle: %lldns",
>   		expect_period, state->duty_cycle);
>   	/*
>   	 * Pick the smallest value for div_h so that div_l can be the biggest
> @@ -218,12 +218,12 @@ static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>   	if (div_l > 255)
>   		div_l = 255;
>   
> -	dev_dbg(chip->dev, "clk source: %ld div_h %lld, div_l : %lld\n",
> +	dev_dbg(pwmchip_parent(chip), "clk source: %ld div_h %lld, div_l : %lld\n",
>   		priv->clk_rate, div_h, div_l);
>   	/* duty_pt = duty_cycle * (PERIOD + 1) / period */
>   	duty_pt = div64_u64(state->duty_cycle * priv->clk_rate,
>   			    (u64)NSEC_PER_SEC * (div_l + 1) << div_h);
> -	dev_dbg(chip->dev, "duty_cycle = %lld, duty_pt = %d\n",
> +	dev_dbg(pwmchip_parent(chip), "duty_cycle = %lld, duty_pt = %d\n",
>   		state->duty_cycle, duty_pt);
>   
>   	/*


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

* Re: [PATCH 1/2] hwmon: (aspeed-g6-pwm-tacho): Make use of pwmchip_parent() accessor
@ 2024-03-18 16:44     ` Guenter Roeck
  0 siblings, 0 replies; 12+ messages in thread
From: Guenter Roeck @ 2024-03-18 16:44 UTC (permalink / raw
  To: Uwe Kleine-König, Jean Delvare, Joel Stanley
  Cc: Andrew Jeffery, linux-hwmon, linux-arm-kernel, linux-aspeed,
	linux-pwm, kernel

On 3/18/24 09:09, Uwe Kleine-König wrote:
> struct pwm_chip::dev is about to change. To not have to touch this
> driver in the same commit as struct pwm_chip::dev, use the accessor
> function provided for exactly this purpose.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/hwmon/aspeed-g6-pwm-tach.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/aspeed-g6-pwm-tach.c b/drivers/hwmon/aspeed-g6-pwm-tach.c
> index 597b3b019d49..64def5e4cdf6 100644
> --- a/drivers/hwmon/aspeed-g6-pwm-tach.c
> +++ b/drivers/hwmon/aspeed-g6-pwm-tach.c
> @@ -195,7 +195,7 @@ static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>   
>   	expect_period = div64_u64(ULLONG_MAX, (u64)priv->clk_rate);
>   	expect_period = min(expect_period, state->period);
> -	dev_dbg(chip->dev, "expect period: %lldns, duty_cycle: %lldns",
> +	dev_dbg(pwmchip_parent(chip), "expect period: %lldns, duty_cycle: %lldns",
>   		expect_period, state->duty_cycle);
>   	/*
>   	 * Pick the smallest value for div_h so that div_l can be the biggest
> @@ -218,12 +218,12 @@ static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>   	if (div_l > 255)
>   		div_l = 255;
>   
> -	dev_dbg(chip->dev, "clk source: %ld div_h %lld, div_l : %lld\n",
> +	dev_dbg(pwmchip_parent(chip), "clk source: %ld div_h %lld, div_l : %lld\n",
>   		priv->clk_rate, div_h, div_l);
>   	/* duty_pt = duty_cycle * (PERIOD + 1) / period */
>   	duty_pt = div64_u64(state->duty_cycle * priv->clk_rate,
>   			    (u64)NSEC_PER_SEC * (div_l + 1) << div_h);
> -	dev_dbg(chip->dev, "duty_cycle = %lld, duty_pt = %d\n",
> +	dev_dbg(pwmchip_parent(chip), "duty_cycle = %lld, duty_pt = %d\n",
>   		state->duty_cycle, duty_pt);
>   
>   	/*


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

* Re: [PATCH 2/2] hwmon: (aspeed-g6-pwm-tacho): Make use of devm_pwmchip_alloc() function
  2024-03-18 16:09   ` Uwe Kleine-König
@ 2024-03-18 16:45     ` Guenter Roeck
  -1 siblings, 0 replies; 12+ messages in thread
From: Guenter Roeck @ 2024-03-18 16:45 UTC (permalink / raw
  To: Uwe Kleine-König, Jean Delvare, Joel Stanley
  Cc: Andrew Jeffery, linux-hwmon, linux-arm-kernel, linux-aspeed,
	linux-pwm, kernel

On 3/18/24 09:09, Uwe Kleine-König wrote:
> This prepares the aspeed-g6-pwm-tacho driver to further changes of the
> pwm core outlined in the commit introducing devm_pwmchip_alloc(). There
> is no intended semantical change and the driver should behave as before.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/hwmon/aspeed-g6-pwm-tach.c | 15 +++++++++------
>   1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/hwmon/aspeed-g6-pwm-tach.c b/drivers/hwmon/aspeed-g6-pwm-tach.c
> index 64def5e4cdf6..332c02216668 100644
> --- a/drivers/hwmon/aspeed-g6-pwm-tach.c
> +++ b/drivers/hwmon/aspeed-g6-pwm-tach.c
> @@ -136,7 +136,6 @@ struct aspeed_pwm_tach_data {
>   	struct clk *clk;
>   	struct reset_control *reset;
>   	unsigned long clk_rate;
> -	struct pwm_chip chip;
>   	bool tach_present[TACH_ASPEED_NR_TACHS];
>   	u32 tach_divisor;
>   };
> @@ -144,7 +143,7 @@ struct aspeed_pwm_tach_data {
>   static inline struct aspeed_pwm_tach_data *
>   aspeed_pwm_chip_to_data(struct pwm_chip *chip)
>   {
> -	return container_of(chip, struct aspeed_pwm_tach_data, chip);
> +	return pwmchip_get_drvdata(chip);
>   }
>   
>   static int aspeed_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
> @@ -459,6 +458,7 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev)
>   	int ret;
>   	struct device_node *child;
>   	struct aspeed_pwm_tach_data *priv;
> +	struct pwm_chip *chip;
>   
>   	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>   	if (!priv)
> @@ -487,11 +487,14 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev)
>   	if (ret)
>   		return ret;
>   
> -	priv->chip.dev = dev;
> -	priv->chip.ops = &aspeed_pwm_ops;
> -	priv->chip.npwm = PWM_ASPEED_NR_PWMS;
> +	chip = devm_pwmchip_alloc(dev, PWM_ASPEED_NR_PWMS, 0);
> +	if (IS_ERR(chip))
> +		return PTR_ERR(chip);
>   
> -	ret = devm_pwmchip_add(dev, &priv->chip);
> +	pwmchip_set_drvdata(chip, priv);
> +	chip->ops = &aspeed_pwm_ops;
> +
> +	ret = devm_pwmchip_add(dev, chip);
>   	if (ret)
>   		return dev_err_probe(dev, ret, "Failed to add PWM chip\n");
>   


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

* Re: [PATCH 2/2] hwmon: (aspeed-g6-pwm-tacho): Make use of devm_pwmchip_alloc() function
@ 2024-03-18 16:45     ` Guenter Roeck
  0 siblings, 0 replies; 12+ messages in thread
From: Guenter Roeck @ 2024-03-18 16:45 UTC (permalink / raw
  To: Uwe Kleine-König, Jean Delvare, Joel Stanley
  Cc: Andrew Jeffery, linux-hwmon, linux-arm-kernel, linux-aspeed,
	linux-pwm, kernel

On 3/18/24 09:09, Uwe Kleine-König wrote:
> This prepares the aspeed-g6-pwm-tacho driver to further changes of the
> pwm core outlined in the commit introducing devm_pwmchip_alloc(). There
> is no intended semantical change and the driver should behave as before.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/hwmon/aspeed-g6-pwm-tach.c | 15 +++++++++------
>   1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/hwmon/aspeed-g6-pwm-tach.c b/drivers/hwmon/aspeed-g6-pwm-tach.c
> index 64def5e4cdf6..332c02216668 100644
> --- a/drivers/hwmon/aspeed-g6-pwm-tach.c
> +++ b/drivers/hwmon/aspeed-g6-pwm-tach.c
> @@ -136,7 +136,6 @@ struct aspeed_pwm_tach_data {
>   	struct clk *clk;
>   	struct reset_control *reset;
>   	unsigned long clk_rate;
> -	struct pwm_chip chip;
>   	bool tach_present[TACH_ASPEED_NR_TACHS];
>   	u32 tach_divisor;
>   };
> @@ -144,7 +143,7 @@ struct aspeed_pwm_tach_data {
>   static inline struct aspeed_pwm_tach_data *
>   aspeed_pwm_chip_to_data(struct pwm_chip *chip)
>   {
> -	return container_of(chip, struct aspeed_pwm_tach_data, chip);
> +	return pwmchip_get_drvdata(chip);
>   }
>   
>   static int aspeed_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
> @@ -459,6 +458,7 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev)
>   	int ret;
>   	struct device_node *child;
>   	struct aspeed_pwm_tach_data *priv;
> +	struct pwm_chip *chip;
>   
>   	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>   	if (!priv)
> @@ -487,11 +487,14 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev)
>   	if (ret)
>   		return ret;
>   
> -	priv->chip.dev = dev;
> -	priv->chip.ops = &aspeed_pwm_ops;
> -	priv->chip.npwm = PWM_ASPEED_NR_PWMS;
> +	chip = devm_pwmchip_alloc(dev, PWM_ASPEED_NR_PWMS, 0);
> +	if (IS_ERR(chip))
> +		return PTR_ERR(chip);
>   
> -	ret = devm_pwmchip_add(dev, &priv->chip);
> +	pwmchip_set_drvdata(chip, priv);
> +	chip->ops = &aspeed_pwm_ops;
> +
> +	ret = devm_pwmchip_add(dev, chip);
>   	if (ret)
>   		return dev_err_probe(dev, ret, "Failed to add PWM chip\n");
>   


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

* Re: [PATCH 0/2] hwmon: (aspeed-g6-pwm-tacho): Prepare for further pwm core changes
  2024-03-18 16:09 ` Uwe Kleine-König
@ 2024-04-13  8:33   ` Uwe Kleine-König
  -1 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2024-04-13  8:33 UTC (permalink / raw
  To: Jean Delvare, Guenter Roeck, Joel Stanley
  Cc: linux-hwmon, linux-pwm, linux-aspeed, kernel, Andrew Jeffery,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]

Hello,

On Mon, Mar 18, 2024 at 05:09:48PM +0100, Uwe Kleine-König wrote:
> there is a pending rework for the pwm framework[1] that requires a
> preparatory change for all pwm drivers. When creating them I wasn't
> aware of the aspeed-g6-pwm-tacho driver, just found this now while doing
> build tests with my series.
> 
> To not delay application of my series, I'd like to take the two patches
> from this series via my pwm tree.
> 
> To state the (maybe) obvious: This series depends on the following commits:
> 
> 	7e1449cd15d1 "hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach"
> 	024913dbf99f pwm: Provide pwmchip_alloc() function and a devm variant of it
> 	4e59267c7a20 pwm: Provide an inline function to get the parent device of a given chip
> 
> The earliest commit containing all those is:
> 
> 	15223fdbdf4f "Merge tag 'hwmon-for-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging"

I applied this series with Guenter's ack to my branch at
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
. (Honestly I already did that a while ago, only noticed now that I
didn't explicitly tell about that.)

Thanks
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 0/2] hwmon: (aspeed-g6-pwm-tacho): Prepare for further pwm core changes
@ 2024-04-13  8:33   ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2024-04-13  8:33 UTC (permalink / raw
  To: Jean Delvare, Guenter Roeck, Joel Stanley
  Cc: linux-hwmon, linux-pwm, linux-aspeed, kernel, Andrew Jeffery,
	linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1375 bytes --]

Hello,

On Mon, Mar 18, 2024 at 05:09:48PM +0100, Uwe Kleine-König wrote:
> there is a pending rework for the pwm framework[1] that requires a
> preparatory change for all pwm drivers. When creating them I wasn't
> aware of the aspeed-g6-pwm-tacho driver, just found this now while doing
> build tests with my series.
> 
> To not delay application of my series, I'd like to take the two patches
> from this series via my pwm tree.
> 
> To state the (maybe) obvious: This series depends on the following commits:
> 
> 	7e1449cd15d1 "hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach"
> 	024913dbf99f pwm: Provide pwmchip_alloc() function and a devm variant of it
> 	4e59267c7a20 pwm: Provide an inline function to get the parent device of a given chip
> 
> The earliest commit containing all those is:
> 
> 	15223fdbdf4f "Merge tag 'hwmon-for-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging"

I applied this series with Guenter's ack to my branch at
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
. (Honestly I already did that a while ago, only noticed now that I
didn't explicitly tell about that.)

Thanks
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

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

end of thread, other threads:[~2024-04-13  8:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-18 16:09 [PATCH 0/2] hwmon: (aspeed-g6-pwm-tacho): Prepare for further pwm core changes Uwe Kleine-König
2024-03-18 16:09 ` Uwe Kleine-König
2024-03-18 16:09 ` [PATCH 1/2] hwmon: (aspeed-g6-pwm-tacho): Make use of pwmchip_parent() accessor Uwe Kleine-König
2024-03-18 16:09   ` Uwe Kleine-König
2024-03-18 16:44   ` Guenter Roeck
2024-03-18 16:44     ` Guenter Roeck
2024-03-18 16:09 ` [PATCH 2/2] hwmon: (aspeed-g6-pwm-tacho): Make use of devm_pwmchip_alloc() function Uwe Kleine-König
2024-03-18 16:09   ` Uwe Kleine-König
2024-03-18 16:45   ` Guenter Roeck
2024-03-18 16:45     ` Guenter Roeck
2024-04-13  8:33 ` [PATCH 0/2] hwmon: (aspeed-g6-pwm-tacho): Prepare for further pwm core changes Uwe Kleine-König
2024-04-13  8:33   ` Uwe Kleine-König

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.