From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755020AbcFPPU2 (ORCPT ); Thu, 16 Jun 2016 11:20:28 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:5024 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754964AbcFPPUY (ORCPT ); Thu, 16 Jun 2016 11:20:24 -0400 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Thu, 16 Jun 2016 08:17:38 -0700 Subject: Re: [PATCH] pinctrl: Don't create a pinctrl handle if no pinctrl entries exist To: Linus Walleij References: <1466080749-23567-1-git-send-email-jonathanh@nvidia.com> CC: , From: Jon Hunter Message-ID: <5762C3B1.7000800@nvidia.com> Date: Thu, 16 Jun 2016 16:20:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <1466080749-23567-1-git-send-email-jonathanh@nvidia.com> X-Originating-IP: [10.26.11.173] X-ClientProxiedBy: UKMAIL102.nvidia.com (10.26.138.15) To UKMAIL102.nvidia.com (10.26.138.15) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/06/16 13:39, Jon Hunter wrote: > When pinctrl_get() is called for a device, it will return a valid handle > even if the device itself has no pinctrl state entries defined in > device-tree. This is caused by the function pinctrl_dt_to_map() which > will return success even if the first pinctrl state, 'pinctrl-0', is not > found in the device-tree node for a device. > > According to the pinctrl device-tree binding documentation, pinctrl > states must be numbered starting from 0 and so 'pinctrl-0' should always > be present if a device uses pinctrl and therefore, if 'pinctrl-0' is not > present it seems valid that we should not return a valid pinctrl handle. > > Fix this by returning an error code if the property 'pinctrl-0' is not > present for a device. > > Signed-off-by: Jon Hunter > --- > > I was wondering if this meant we are creating pinctrl handles for > devices on boot that don't use pinctrl (when > calling pinctrl_bind_pins()). However, although devm_pinctrl_get() > does return successful for all devices, the subsequent call to > pinctrl_lookup_state() (to get the default state) will fail and so > we will destroy the pinctrl handle afterall. > > drivers/pinctrl/devicetree.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c > index fe04e748dfe4..f41c16e11a11 100644 > --- a/drivers/pinctrl/devicetree.c > +++ b/drivers/pinctrl/devicetree.c > @@ -195,8 +195,11 @@ int pinctrl_dt_to_map(struct pinctrl *p) > propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state); > prop = of_find_property(np, propname, &size); > kfree(propname); > - if (!prop) > + if (!prop) { > + if (state == 0) I think there should be a of_node_put() here. Will resend. > + return -ENODEV; > break; > + } Cheers Jon -- nvpublic