Re: [PATCH] backlight: pwm_bl: move suspend/resume entries fromplatform_driver to driver.pm

From: Eric Miao
Date: Wed Nov 30 2011 - 21:03:17 EST


On Thu, Dec 1, 2011 at 9:53 AM, Barry Song <Barry.Song@xxxxxxx> wrote:
> From: Xiangzhen Ye <Xiangzhen.Ye@xxxxxxx>
>
> At first, people are moving suspend/resume entries from platform_driver
> to driver.pm for many drivers.
> On the other hand, if we use swsusp to do hibernation for an embedded
> system using pwm_bl, in the process of preparing snapshot, backlight
> will be off and make lcd black screen. This gives bad user experiences.
> This patch will fix this issue as swsusp will go to call pm.freeze()
> but not platform_driver.suspend. we have no pm.freeze() for pwm_bl, so
> the lcd black screen will disappear.
>
> Signed-off-by: Xiangzhen Ye <Xiangzhen.Ye@xxxxxxx>
> Signed-off-by: Barry Song <Baohua.Song@xxxxxxx>

Acked-by: Eric Miao <eric.y.miao@xxxxxxxxx>

> ---
> Âdrivers/video/backlight/pwm_bl.c | Â 15 ++++++++++-----
> Â1 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 8b5b2a4..50f3134 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -169,9 +169,9 @@ static int pwm_backlight_remove(struct platform_device *pdev)
> Â}
>
> Â#ifdef CONFIG_PM
> -static int pwm_backlight_suspend(struct platform_device *pdev,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âpm_message_t state)
> +static int pwm_backlight_suspend(struct device *dev)
> Â{
> + Â Â Â struct platform_device *pdev = to_platform_device(dev);
> Â Â Â Âstruct backlight_device *bl = platform_get_drvdata(pdev);
> Â Â Â Âstruct pwm_bl_data *pb = dev_get_drvdata(&bl->dev);
>
> @@ -184,8 +184,9 @@ static int pwm_backlight_suspend(struct platform_device *pdev,
> Â Â Â Âreturn 0;
> Â}
>
> -static int pwm_backlight_resume(struct platform_device *pdev)
> +static int pwm_backlight_resume(struct device *dev)
> Â{
> + Â Â Â struct platform_device *pdev = to_platform_device(dev);
> Â Â Â Âstruct backlight_device *bl = platform_get_drvdata(pdev);
>
> Â Â Â Âbacklight_update_status(bl);
> @@ -196,15 +197,19 @@ static int pwm_backlight_resume(struct platform_device *pdev)
> Â#define pwm_backlight_resume  NULL
> Â#endif
>
> +static const struct dev_pm_ops pwm_backlight_pm_ops = {
> + Â Â Â .suspend = pwm_backlight_suspend,
> + Â Â Â .resume = pwm_backlight_resume,
> +};
> +
> Âstatic struct platform_driver pwm_backlight_driver = {
>    Â.driver     = {
>        Â.name  = "pwm-backlight",
> Â Â Â Â Â Â Â Â.owner Â= THIS_MODULE,
> +        .pm   = &pwm_backlight_pm_ops,
> Â Â Â Â},
>    Â.probe     Â= pwm_backlight_probe,
>    Â.remove     = pwm_backlight_remove,
> -    .suspend    Â= pwm_backlight_suspend,
> -    .resume     = pwm_backlight_resume,
> Â};
>
> Âstatic int __init pwm_backlight_init(void)
> --
> 1.7.1
>
>
>
> Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
> More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/