Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758080AbcKCORD (ORCPT ); Thu, 3 Nov 2016 10:17:03 -0400 Received: from exsmtp01.microchip.com ([198.175.253.37]:19793 "EHLO email.microchip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758071AbcKCOQ5 (ORCPT ); Thu, 3 Nov 2016 10:16:57 -0400 Date: Thu, 3 Nov 2016 15:16:54 +0100 From: Ludovic Desroches To: Wenyou Yang CC: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , , , Ludovic Desroches , Wenyou Yang , , Nicolas Ferre Subject: Re: [PATCH v2] iio: adc: at91: add suspend and resume callback Message-ID: <20161103141654.7oitq25gxqcy7qna@rfolt0960.corp.atmel.com> Mail-Followup-To: Wenyou Yang , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Wenyou Yang , linux-arm-kernel@lists.infradead.org, Nicolas Ferre References: <1478078508-24541-1-git-send-email-wenyou.yang@atmel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1478078508-24541-1-git-send-email-wenyou.yang@atmel.com> User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2064 Lines: 74 On Wed, Nov 02, 2016 at 05:21:48PM +0800, Wenyou Yang wrote: > Add suspend/resume callback, support the pinctrl sleep state when > the system suspend as well. > > Signed-off-by: Wenyou Yang Acked-by: Ludovic Desroches Thanks > --- > > Changes in v2: > - Use CONFIG_PM_SLEEP. > - Use SIMPLE_DEV_PM_OPS macro. > > drivers/iio/adc/at91_adc.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c > index bbdac07..34b928c 100644 > --- a/drivers/iio/adc/at91_adc.c > +++ b/drivers/iio/adc/at91_adc.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > > /* Registers */ > #define AT91_ADC_CR 0x00 /* Control Register */ > @@ -1347,6 +1348,32 @@ static int at91_adc_remove(struct platform_device *pdev) > return 0; > } > > +#ifdef CONFIG_PM_SLEEP > +static int at91_adc_suspend(struct device *dev) > +{ > + struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev)); > + struct at91_adc_state *st = iio_priv(idev); > + > + pinctrl_pm_select_sleep_state(dev); > + clk_disable_unprepare(st->clk); > + > + return 0; > +} > + > +static int at91_adc_resume(struct device *dev) > +{ > + struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev)); > + struct at91_adc_state *st = iio_priv(idev); > + > + clk_prepare_enable(st->clk); > + pinctrl_pm_select_default_state(dev); > + > + return 0; > +} > +#endif > + > +static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume); > + > static struct at91_adc_caps at91sam9260_caps = { > .calc_startup_ticks = calc_startup_ticks_9260, > .num_channels = 4, > @@ -1441,6 +1468,7 @@ static struct platform_driver at91_adc_driver = { > .driver = { > .name = DRIVER_NAME, > .of_match_table = of_match_ptr(at91_adc_dt_ids), > + .pm = &at91_adc_pm_ops, > }, > }; > > -- > 2.7.4 >