Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752125AbbFYANm (ORCPT ); Wed, 24 Jun 2015 20:13:42 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:51032 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751408AbbFYANe (ORCPT ); Wed, 24 Jun 2015 20:13:34 -0400 X-AuditID: cbfee68f-f793b6d000005f66-a4-558b47ab9a81 Message-id: <558B47AB.8050800@samsung.com> Date: Thu, 25 Jun 2015 09:13:31 +0900 From: Chanwoo Choi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-version: 1.0 To: Charles Keepax Cc: lee.jones@linaro.org, myungjoo.ham@samsung.com, sameo@linux.intel.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, patches@opensource.wolfsonmicro.com Subject: Re: [PATCH v5 4/7] extcon: arizona: Convert to gpiod References: <1434731014-19980-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> <1434731014-19980-5-git-send-email-ckeepax@opensource.wolfsonmicro.com> In-reply-to: <1434731014-19980-5-git-send-email-ckeepax@opensource.wolfsonmicro.com> Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIIsWRmVeSWpSXmKPExsWyRsSkUHe1e3eowaGX2hb/ptxgt5h/5Byr xf2vRxktLu+aw2Zxu3EFm8Xyt//ZLE53szqwe9y5tofNY97JQI+XE3+zefRtWcXo8XmTXABr FJdNSmpOZllqkb5dAldGx5JTrAUfFSsenH/I2sB4U6qLkYNDQsBE4tFSwS5GTiBTTOLCvfVs ILaQwFJGib/d9RBxE4lnp7+xdzFyAcWnA8XPzmaDcB4wSvw7PZ8JpIpXQEviy4v/YDaLgKpE +4xnjCA2G1B8/4sbYFNFBcIkVk6/wgJRLyjxY/I9MFtEwEJiypJbzCBDmQXWMEo0L77GDHKd sICtx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ajh1hwqxJpYVV+YeYpTgYFYS4c0BCfGmJFZWpRblxxeV5qQWH2I0BQbBRGYp0eR8YMLJK4k3 NDYxM7I0Mje0MDI2VxLnPZnvEyokkJ5YkpqdmlqQWgTTx8TBKdXAaH3/y8Lfrcoz7vbmtzmz xocXMnZyXxHdK7XQk/ezTYyyd1/RCq8nxl7Xl9TfZXu/+viyV8bT/rpHrHZcH7GIN+ZLQ5np yQ8i7JOD9P02yGscVU56K+9sKJL8/tf02kUfI6WcPx46ceinz9MnJ8WWXcp33CwwPzn0xKrD y/c9fBD+cfPN4BX/KpRYijMSDbWYi4oTAUmOhDEAAwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4449 Lines: 138 Hi, Applied it. Thanks, Chanwoo Choi On 06/20/2015 01:23 AM, Charles Keepax wrote: > Convert to using the newer gpiod interface for the micd_pol_gpio. > Although we still carry support for the old gpio interface from pdata. > > Signed-off-by: Charles Keepax > --- > drivers/extcon/extcon-arizona.c | 41 ++++++++++++++++++++++++++++++++++---- > 1 files changed, 36 insertions(+), 5 deletions(-) > > diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c > index b364b8b..8f0ef72 100644 > --- a/drivers/extcon/extcon-arizona.c > +++ b/drivers/extcon/extcon-arizona.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -95,6 +96,8 @@ struct arizona_extcon_info { > int hpdet_ip_version; > > struct extcon_dev *edev; > + > + struct gpio_desc *micd_pol_gpio; > }; > > static const struct arizona_micd_config micd_default_modes[] = { > @@ -205,6 +208,10 @@ static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode) > if (arizona->pdata.micd_pol_gpio > 0) > gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio, > info->micd_modes[mode].gpio); > + else > + gpiod_set_value_cansleep(info->micd_pol_gpio, > + info->micd_modes[mode].gpio); > + > regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1, > ARIZONA_MICD_BIAS_SRC_MASK, > info->micd_modes[mode].bias << > @@ -1258,6 +1265,27 @@ static int arizona_extcon_probe(struct platform_device *pdev) > arizona->pdata.micd_pol_gpio, ret); > goto err_register; > } > + } else { > + if (info->micd_modes[0].gpio) > + mode = GPIOD_OUT_HIGH; > + else > + mode = GPIOD_OUT_LOW; > + > + /* We can't use devm here because we need to do the get > + * against the MFD device, as that is where the of_node > + * will reside, but if we devm against that the GPIO > + * will not be freed if the extcon driver is unloaded. > + */ > + info->micd_pol_gpio = gpiod_get_optional(arizona->dev, > + "wlf,micd-pol", > + GPIOD_OUT_LOW); > + if (IS_ERR(info->micd_pol_gpio)) { > + ret = PTR_ERR(info->micd_pol_gpio); > + dev_err(arizona->dev, > + "Failed to get microphone polarity GPIO: %d\n", > + ret); > + goto err_register; > + } > } > > if (arizona->pdata.hpdet_id_gpio > 0) { > @@ -1268,7 +1296,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) > if (ret != 0) { > dev_err(arizona->dev, "Failed to request GPIO%d: %d\n", > arizona->pdata.hpdet_id_gpio, ret); > - goto err_register; > + goto err_gpio; > } > } > > @@ -1320,7 +1348,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) > dev_err(arizona->dev, > "MICD ranges must be sorted\n"); > ret = -EINVAL; > - goto err_input; > + goto err_gpio; > } > } > } > @@ -1339,7 +1367,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) > dev_err(arizona->dev, "Unsupported MICD level %d\n", > info->micd_ranges[i].max); > ret = -EINVAL; > - goto err_input; > + goto err_gpio; > } > > dev_dbg(arizona->dev, "%d ohms for MICD threshold %d\n", > @@ -1412,7 +1440,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) > if (ret != 0) { > dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n", > ret); > - goto err_input; > + goto err_gpio; > } > > ret = arizona_set_irq_wake(arizona, jack_irq_rise, 1); > @@ -1483,7 +1511,8 @@ err_rise_wake: > arizona_set_irq_wake(arizona, jack_irq_rise, 0); > err_rise: > arizona_free_irq(arizona, jack_irq_rise, info); > -err_input: > +err_gpio: > + gpiod_put(info->micd_pol_gpio); > err_register: > pm_runtime_disable(&pdev->dev); > return ret; > @@ -1495,6 +1524,8 @@ static int arizona_extcon_remove(struct platform_device *pdev) > struct arizona *arizona = info->arizona; > int jack_irq_rise, jack_irq_fall; > > + gpiod_put(info->micd_pol_gpio); > + > pm_runtime_disable(&pdev->dev); > > regmap_update_bits(arizona->regmap, > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/