public inbox for linux-mediatek@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: mt6577_auxadc: Fix kernel panic on suspend
@ 2023-10-10 12:19 AngeloGioacchino Del Regno
  2023-10-10 12:34 ` Alexandre Mergnat
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-10-10 12:19 UTC (permalink / raw)
  To: jic23
  Cc: lars, matthias.bgg, angelogioacchino.delregno, ruanjinjie,
	linux-iio, linux-kernel, linux-arm-kernel, linux-mediatek, wenst,
	kernel

Commit a2d518fbe376 ("iio: adc: mt6577_auxadc: Simplify with device managed function")
simplified the driver with devm hooks, but wrongly states that the
platform_set_drvdata(), platform_get_drvdata() are unused after the
simplification: the driver data is infact used in .suspend() and
.resume() PM callbacks, currently producing a kernel panic.

Reintroduce the call to platform_set_drvdata() in the probe function

Fixes: a2d518fbe376 ("iio: adc: mt6577_auxadc: Simplify with device managed function")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/iio/adc/mt6577_auxadc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
index 370b84c2d0ba..3343b54e8e44 100644
--- a/drivers/iio/adc/mt6577_auxadc.c
+++ b/drivers/iio/adc/mt6577_auxadc.c
@@ -293,6 +293,7 @@ static int mt6577_auxadc_probe(struct platform_device *pdev)
 	mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
 			      MT6577_AUXADC_PDN_EN, 0);
 	mdelay(MT6577_AUXADC_POWER_READY_MS);
+	platform_set_drvdata(pdev, indio_dev);
 
 	ret = devm_add_action_or_reset(&pdev->dev, mt6577_power_off, adc_dev);
 	if (ret)
-- 
2.42.0



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

* Re: [PATCH] iio: adc: mt6577_auxadc: Fix kernel panic on suspend
  2023-10-10 12:19 [PATCH] iio: adc: mt6577_auxadc: Fix kernel panic on suspend AngeloGioacchino Del Regno
@ 2023-10-10 12:34 ` Alexandre Mergnat
  2023-10-10 12:44 ` Markus Schneider-Pargmann
  2023-10-10 15:33 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Mergnat @ 2023-10-10 12:34 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, jic23
  Cc: lars, matthias.bgg, ruanjinjie, linux-iio, linux-kernel,
	linux-arm-kernel, linux-mediatek, wenst, kernel

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>

On 10/10/2023 14:19, AngeloGioacchino Del Regno wrote:
> Commit a2d518fbe376 ("iio: adc: mt6577_auxadc: Simplify with device 
> managed function") simplified the driver with devm hooks, but wrongly 
> states that the platform_set_drvdata(), platform_get_drvdata() are 
> unused after the simplification: the driver data is infact used in 
> .suspend() and .resume() PM callbacks, currently producing a kernel 
> panic. Reintroduce the call to platform_set_drvdata() in the probe function

-- 
Regards,
Alexandre


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

* Re: [PATCH] iio: adc: mt6577_auxadc: Fix kernel panic on suspend
  2023-10-10 12:19 [PATCH] iio: adc: mt6577_auxadc: Fix kernel panic on suspend AngeloGioacchino Del Regno
  2023-10-10 12:34 ` Alexandre Mergnat
@ 2023-10-10 12:44 ` Markus Schneider-Pargmann
  2023-10-10 15:33 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Schneider-Pargmann @ 2023-10-10 12:44 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: jic23, lars, matthias.bgg, ruanjinjie, linux-iio, linux-kernel,
	linux-arm-kernel, linux-mediatek, wenst, kernel

On Tue, Oct 10, 2023 at 02:19:40PM +0200, AngeloGioacchino Del Regno wrote:
> Commit a2d518fbe376 ("iio: adc: mt6577_auxadc: Simplify with device managed function")
> simplified the driver with devm hooks, but wrongly states that the
> platform_set_drvdata(), platform_get_drvdata() are unused after the
> simplification: the driver data is infact used in .suspend() and
> .resume() PM callbacks, currently producing a kernel panic.
> 
> Reintroduce the call to platform_set_drvdata() in the probe function
> 
> Fixes: a2d518fbe376 ("iio: adc: mt6577_auxadc: Simplify with device managed function")
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com>

Best,
Markus

> ---
>  drivers/iio/adc/mt6577_auxadc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
> index 370b84c2d0ba..3343b54e8e44 100644
> --- a/drivers/iio/adc/mt6577_auxadc.c
> +++ b/drivers/iio/adc/mt6577_auxadc.c
> @@ -293,6 +293,7 @@ static int mt6577_auxadc_probe(struct platform_device *pdev)
>  	mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
>  			      MT6577_AUXADC_PDN_EN, 0);
>  	mdelay(MT6577_AUXADC_POWER_READY_MS);
> +	platform_set_drvdata(pdev, indio_dev);
>  
>  	ret = devm_add_action_or_reset(&pdev->dev, mt6577_power_off, adc_dev);
>  	if (ret)
> -- 
> 2.42.0
> 


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

* Re: [PATCH] iio: adc: mt6577_auxadc: Fix kernel panic on suspend
  2023-10-10 12:19 [PATCH] iio: adc: mt6577_auxadc: Fix kernel panic on suspend AngeloGioacchino Del Regno
  2023-10-10 12:34 ` Alexandre Mergnat
  2023-10-10 12:44 ` Markus Schneider-Pargmann
@ 2023-10-10 15:33 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2023-10-10 15:33 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: lars, matthias.bgg, ruanjinjie, linux-iio, linux-kernel,
	linux-arm-kernel, linux-mediatek, wenst, kernel

On Tue, 10 Oct 2023 14:19:40 +0200
AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:

> Commit a2d518fbe376 ("iio: adc: mt6577_auxadc: Simplify with device managed function")
> simplified the driver with devm hooks, but wrongly states that the
> platform_set_drvdata(), platform_get_drvdata() are unused after the
> simplification: the driver data is infact used in .suspend() and
> .resume() PM callbacks, currently producing a kernel panic.
> 
> Reintroduce the call to platform_set_drvdata() in the probe function
> 
> Fixes: a2d518fbe376 ("iio: adc: mt6577_auxadc: Simplify with device managed function")
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Applied to the togreg branch of iio.git (as the patch it is fixing is only there for now)
Pushed out initially as testing for 0-day to take a look.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/mt6577_auxadc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
> index 370b84c2d0ba..3343b54e8e44 100644
> --- a/drivers/iio/adc/mt6577_auxadc.c
> +++ b/drivers/iio/adc/mt6577_auxadc.c
> @@ -293,6 +293,7 @@ static int mt6577_auxadc_probe(struct platform_device *pdev)
>  	mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
>  			      MT6577_AUXADC_PDN_EN, 0);
>  	mdelay(MT6577_AUXADC_POWER_READY_MS);
> +	platform_set_drvdata(pdev, indio_dev);
>  
>  	ret = devm_add_action_or_reset(&pdev->dev, mt6577_power_off, adc_dev);
>  	if (ret)



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

end of thread, other threads:[~2023-10-10 15:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-10 12:19 [PATCH] iio: adc: mt6577_auxadc: Fix kernel panic on suspend AngeloGioacchino Del Regno
2023-10-10 12:34 ` Alexandre Mergnat
2023-10-10 12:44 ` Markus Schneider-Pargmann
2023-10-10 15:33 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox