Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752228AbbLNELX (ORCPT ); Sun, 13 Dec 2015 23:11:23 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:57814 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751974AbbLNELU convert rfc822-to-8bit (ORCPT ); Sun, 13 Dec 2015 23:11:20 -0500 X-AuditID: cbfee68f-f793a6d000001364-d4-566e4165d5e5 MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8BIT Message-id: <566E4161.5070307@samsung.com> Date: Mon, 14 Dec 2015 13:11:13 +0900 From: Chanwoo Choi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 To: Charles Keepax Cc: myungjoo.ham@samsung.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, patches@opensource.wolfsonmicro.com Subject: Re: [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations References: <1449767299-29691-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> In-reply-to: <1449767299-29691-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRmVeSWpSXmKPExsWyRsSkWDfVMS/M4E2bjcW/KTfYLeYfOcdq cXnXHDaL240r2CyWv/3P5sDq8XLibzaPvi2rGD0+b5ILYI7isklJzcksSy3St0vgymiYPomx YKJ0xZo+nwbGHrEuRg4OCQETiYuLzLsYOYFMMYkL99azdTFycQgJrGCUmHnkOztEwkRiZe9E ZojELEaJK7N3sIEkeAUEJX5MvscCYjMLqEtMmreIGcIWkdjxoR8qri2xbOFrqOYHjBK/W1rY IZq1JNb1XgAbxCKgKnH92E0wmw0ovv/FDTaQ60QFIiS6T1SChEUELCSmLLkFNb9WYtn2V8wg JcIC0RJHHwWAmEICoRLXd4FVcAqESRy/tRLsFwmBTewSz+eeZ4LYJCDxbfIhFojf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MyNLI3NDCyNjcyVx 3n2XIsOEBNITS1KzU1MLUotg+pg4OKUaGLVeXNJjv1d0udJ5+b5tTNKqsRNuTpJnNdh3fK3S u7yyD9r3XNb+Crja5/tc8mXeBtNTydUSG98VTbzsNMMh/8P+5O0pwSYTNbcpFAVve3yBt67P 14lrntfmNWK5dx+UNzK1Jiw4Yqbk1u2YIqCaondBUbL84Rddp5NZGj66P6dGMN77e3SZmxJL cUaioRZzUXEiAB1BTuzqAgAA 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: 3554 Lines: 109 Hi Charles, On 2015년 12월 11일 02:08, Charles Keepax wrote: > Add device bindings to support configuring the jack detection > configurations. Each configuration needs to specify the connection of > the mic det pins, which micbias should be used and the value of the > micd polarity GPIO required to activate that configuration. > > Signed-off-by: Charles Keepax > --- > drivers/extcon/extcon-arizona.c | 53 +++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 51 insertions(+), 2 deletions(-) > > diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c > index 8647533..edbf2e1 100644 > --- a/drivers/extcon/extcon-arizona.c > +++ b/drivers/extcon/extcon-arizona.c > @@ -1201,7 +1201,54 @@ static void arizona_micd_set_level(struct arizona *arizona, int index, > regmap_update_bits(arizona->regmap, reg, mask, level); > } > > -static int arizona_extcon_device_get_pdata(struct arizona *arizona) > +static int arizona_extcon_get_micd_configs(struct device *dev, > + struct arizona *arizona) > +{ > + const char * const prop = "wlf,micd-configs"; > + const int entries_per_config = 3; > + struct arizona_micd_config *micd_configs; > + int nconfs, ret; > + int i, j; > + u32 *vals; > + > + nconfs = device_property_read_u32_array(arizona->dev, prop, NULL, 0); > + if (nconfs <= 0) > + return 0; > + > + vals = kcalloc(nconfs, sizeof(u32), GFP_KERNEL); > + if (!vals) > + return -ENOMEM; > + > + ret = device_property_read_u32_array(arizona->dev, prop, vals, nconfs); > + if (ret < 0) > + goto out; > + > + nconfs /= entries_per_config; > + > + micd_configs = devm_kzalloc(dev, > + nconfs * sizeof(struct arizona_micd_range), > + GFP_KERNEL); > + if (!micd_configs) { > + ret = -ENOMEM; > + goto out; > + } > + > + for (i = 0, j = 0; i < nconfs; ++i) { > + micd_configs[i].src = vals[j++] ? ARIZONA_ACCDET_SRC : 0; > + micd_configs[i].bias = vals[j++]; > + micd_configs[i].gpio = vals[j++]; > + } > + > + arizona->pdata.micd_configs = micd_configs; > + arizona->pdata.num_micd_configs = nconfs; > + > +out: > + kfree(vals); > + return ret; > +} > + > +static int arizona_extcon_device_get_pdata(struct device *dev, > + struct arizona *arizona) > { > struct arizona_pdata *pdata = &arizona->pdata; > unsigned int val = ARIZONA_ACCDET_MODE_HPL; > @@ -1249,6 +1296,8 @@ static int arizona_extcon_device_get_pdata(struct arizona *arizona) > pdata->jd_gpio5_nopull = device_property_read_bool(arizona->dev, > "wlf,use-jd2-nopull"); > > + arizona_extcon_get_micd_configs(dev, arizona); You need to check out the return value of arizona_extcon_get_micd_configs(). If arizona_extcon_get_micd_configs() returns the error, arizona_extcon_device_get_pdata() don't handle the error case. > + > return 0; > } > > @@ -1270,7 +1319,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) > return -ENOMEM; > > if (!dev_get_platdata(arizona->dev)) > - arizona_extcon_device_get_pdata(arizona); > + arizona_extcon_device_get_pdata(&pdev->dev, arizona); > > info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD"); > if (IS_ERR(info->micvdd)) { > Except for above comment, Looks good to me. Acked-by: Chanwoo Choi Thanks, Chanwoo Choi -- 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/