Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752521AbeAQJeu (ORCPT + 1 other); Wed, 17 Jan 2018 04:34:50 -0500 Received: from mail-it0-f46.google.com ([209.85.214.46]:36828 "EHLO mail-it0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752144AbeAQJer (ORCPT ); Wed, 17 Jan 2018 04:34:47 -0500 X-Google-Smtp-Source: ACJfBovfuaiivMaL9rWClPjX8d3nhDSePxKnRoAt6Qyj1GsUEJnIxv9pwhsNXLo5x5MgZhp7DOnDvK+Sj8hCItUCFKI= MIME-Version: 1.0 In-Reply-To: <1516105859-3525-5-git-send-email-patrice.chotard@st.com> References: <1516105859-3525-1-git-send-email-patrice.chotard@st.com> <1516105859-3525-5-git-send-email-patrice.chotard@st.com> From: Ulf Hansson Date: Wed, 17 Jan 2018 10:34:46 +0100 Message-ID: Subject: Re: [PATCH v2 04/15] mmc: mmci: Add support for setting pad type via pinctrl To: Patrice CHOTARD 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: [...] > /* > @@ -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. 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. > + } > + > + 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. > + } > + } > + [...] Kind regards Uffe