From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756320AbeARNfk (ORCPT ); Thu, 18 Jan 2018 08:35:40 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:21874 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756258AbeARNfg (ORCPT ); Thu, 18 Jan 2018 08:35:36 -0500 From: Patrice CHOTARD To: Ulf Hansson CC: Russell King , Michael Turquette , Stephen Boyd , Linus Walleij , Rob Herring , Mark Rutland , Alexandre TORGUE , "linux-mmc@vger.kernel.org" , "Linux Kernel Mailing List" , linux-clk , "linux-arm-kernel@lists.infradead.org" , "linux-gpio@vger.kernel.org" , "devicetree@vger.kernel.org" , Andrea Merello Subject: Re: [PATCH v2 04/15] mmc: mmci: Add support for setting pad type via pinctrl Thread-Topic: [PATCH v2 04/15] mmc: mmci: Add support for setting pad type via pinctrl Thread-Index: AQHTjsXi16UiRSyLG0SZoOTfM13GsKN3voMAgAHVeAA= Date: Thu, 18 Jan 2018 13:35:05 +0000 Message-ID: <0c73774b-f06e-2db8-ef50-3bf590b57cff@st.com> References: <1516105859-3525-1-git-send-email-patrice.chotard@st.com> <1516105859-3525-5-git-send-email-patrice.chotard@st.com> In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.48] Content-Type: text/plain; charset="utf-8" Content-ID: <3FFEB509F6551545A33B36799B1C7DBB@st.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-18_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id w0IDZrxs023154 Hi Ulf On 01/17/2018 10:34 AM, Ulf Hansson wrote: > [...] > >> /* >> @@ -1616,6 +1625,32 @@ static int mmci_probe(struct amba_device *dev, >> host = mmc_priv(mmc); >> host->mmc = mmc; >> >> + /* >> + * Some variant (STM32) doesn't have opendrain bit, nevertheless >> + * pins can be set accordingly using pinctrl >> + */ >> + if (!variant->opendrain) { >> + host->pinctrl = devm_pinctrl_get(&dev->dev); >> + if (IS_ERR(host->pinctrl)) { >> + dev_err(&dev->dev, "failed to get pinctrl"); >> + goto host_free; >> + } >> + >> + host->pins_default = pinctrl_lookup_state(host->pinctrl, >> + PINCTRL_STATE_DEFAULT); >> + if (IS_ERR(host->pins_default)) { >> + dev_warn(mmc_dev(mmc), "Can't select default pins\n"); >> + host->pins_default = NULL; > > This is wrong, I think you should bail out and return the error code instead. Ok > > Moreover, calling pinctrl_select_state() from ->set_ios by using a > NULL state, will likely trigger a NULL pointer deference bug in the > pinctrl layer. Regarding pinctrl_select_state() call with a NULL state, this case is managed inside pinctrl_state(), but ok, it will be more elegant to exit directly in case of no DT pins definition found. > >> + } >> + >> + host->pins_opendrain = pinctrl_lookup_state(host->pinctrl, >> + MMCI_PINCTRL_STATE_OPENDRAIN); >> + if (IS_ERR(host->pins_opendrain)) { >> + dev_warn(mmc_dev(mmc), "Can't select opendrain pins\n"); >> + host->pins_opendrain = NULL; > > Ditto. ok Thanks Patrice > >> + } >> + } >> + > > [...] > > Kind regards > Uffe >