Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754107AbcKBIgL (ORCPT ); Wed, 2 Nov 2016 04:36:11 -0400 Received: from smtpout.microchip.com ([198.175.253.82]:44239 "EHLO email.microchip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752538AbcKBIgI (ORCPT ); Wed, 2 Nov 2016 04:36:08 -0400 Date: Wed, 2 Nov 2016 09:36:06 +0100 From: Ludovic Desroches To: Wenyou Yang CC: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , , Wenyou Yang , , Nicolas Ferre , Subject: Re: [PATCH v1] iio: adc: at91: add suspend and resume callback Message-ID: <20161102083606.y53bgtfwmig63e45@rfolt0960.corp.atmel.com> Mail-Followup-To: Wenyou Yang , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-kernel@vger.kernel.org, Wenyou Yang , linux-arm-kernel@lists.infradead.org, Nicolas Ferre , linux-iio@vger.kernel.org References: <1478054417-7520-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: <1478054417-7520-1-git-send-email-wenyou.yang@atmel.com> User-Agent: NeoMutt/20161014 (1.7.1) X-Brightmail-Tracker: H4sIAAAAAAAAC+NgFrrHrMTGxcLF5cOiW75UMsJg0d/Lb3ksGi8dYbeY9O0Go8XGk5tZLO592sZo0dPfx2Ixbfo7Zge2AIYo1sy8pPyKBNaMVYu3shb8EqpYcPorewPjev4uRi4OIYEFjBIf769i7mLk5GARUJE40nCLEcRmEzCVeLSgDywuIqAuMbPnJhtIA7PADSaJNRNaWEESwgLuEhcXLQWzeQXcJFpPf2ABKeIV6GeWaL56FSwhJOAicfzUYmaIIkGJkzOfsIDYzAI6Egt2fwKaygFkS0ss/8cBEuYUcJW43vcKrEQU6KBZl+ewQIzRkHg9fSsTiC0hECjxcfZzNgjbSWLn8qksELadxOHpF9khbAeJpb/nsMPUtC99wwpha0tsf7UPytaR2HawH6rXVmLPjIlQ890lHjxaDmX7Ssx62ABVEyXxdt4plgmMUrOQfDMLyTezEL5ZwMi8ilHa2cNPNzhM1zXC2cPAVC83OaNANzcxM08vOT93EyMkQrN2MPZO8pdqYOSetLqUqfXk7+YZG6XqFmsZnlj9/uitxLULxWZu8+QTlnScHe8d9C6XY84KydxZLlOUjrxt42L/5PfkbdKBzNKvM/OnL/3mce2rRLlkN8/Ly+Hlh1ZUTlp82Txmku8NQyPPhyU+C3qcuh4ZXylasndmi3nNjicns1yei3o52N9huCZnr9u37KISS3FGoqEWc1FxIgB2VBmEcQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2339 Lines: 87 On Wed, Nov 02, 2016 at 10:40:16AM +0800, Wenyou Yang wrote: > Add suspend/resume callback, support the pinctrl sleep state when > the system suspend as well. > > Signed-off-by: Wenyou Yang > --- > > drivers/iio/adc/at91_adc.c | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > > diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c > index bbdac07..ffa81a1 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,39 @@ static int at91_adc_remove(struct platform_device *pdev) > return 0; > } > > +#ifdef CONFIG_PM I would use 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; > +} > + > +static const struct dev_pm_ops at91_adc_pm_ops = { > + .suspend = at91_adc_suspend, > + .resume = at91_adc_resume, > +}; > + > +#define AT91_ADC_PM_OPS (&at91_adc_pm_ops) > +#else > +#define AT91_ADC_PM_OPS NULL > +#endif > + and this macro: SET_SYSTEM_SLEEP_PM_OPS Regards Ludovic > static struct at91_adc_caps at91sam9260_caps = { > .calc_startup_ticks = calc_startup_ticks_9260, > .num_channels = 4, > @@ -1441,6 +1475,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 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html