From patchwork Mon Oct 16 13:42:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 10008367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E6D1160235 for ; Mon, 16 Oct 2017 13:43:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6C2A28599 for ; Mon, 16 Oct 2017 13:43:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB52B2859F; Mon, 16 Oct 2017 13:43:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C219428599 for ; Mon, 16 Oct 2017 13:43:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HnAIWpWkdIorN7/ICZ0law91bzAlYjkm+gEaPFhRenY=; b=QYrnOwWDR0HjtkC3RdIhr3Fx0 omE/3GcxpcuVhKMdwLN9ixiF6RyLCzM/6JopHXX/eVGbW1X/nXCFb9fVv+mL+VUPudy4yUJr77J83 jm/uKbEw10MBpxaxjmrjPtJM2vsaovGJwc8bpDxlxJCDaWmjr5kBzLtDY7hMpswACMV+8NQefqMSg OURTvVQUVn+WSnmGVPXhjHOqfSgmQhE0pusI0BglC/Qr3oufhgdH7kHfOTDhUt9++rC6/rqMyrj6T kt2MuzKcuiOjMmgcI/MIBt31wUaoDzhUowpm1etGR42VDPjP0P54E69X9WNaTA/ytUIhZKFlVSKuM 5DbT/4IjQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e45fg-0001Sn-AO; Mon, 16 Oct 2017 13:43:08 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e45fc-0001Ph-F4 for linux-arm-kernel@lists.infradead.org; Mon, 16 Oct 2017 13:43:06 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 121F860B11; Mon, 16 Oct 2017 13:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1508161364; bh=Unx3Cy+t6C5oZ9dMyLubI+ojWhevBTYH4BQLR64QfXU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=LqKhPt53SHlBRts/4Hwc2cZp/OI4T0ZTB4zYbUBFG0PgwGGvQgtfodJ4BDD7oTaq/ lm8BCSuSyXYbngaEJd/pJslfJC12eCDv/BL/n8/SUuLXEauLF/x72SfnScpbvdCQgc N6z2SNpxx6C+XaFgWdkRsrtRdzaAWoEd10w7rFS4= Received: from [10.222.143.167] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A23386083D; Mon, 16 Oct 2017 13:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1508161363; bh=Unx3Cy+t6C5oZ9dMyLubI+ojWhevBTYH4BQLR64QfXU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=ix0A2U+Cj2dkGetu2+1wCiFHGCiGTMZUjQtynMCUgZ2srYOeE+VCU4LlasDcat8LR h9kh0asWDwdtcPgGrE6xrjm1JdkZhojBLRl8EEDyvPHiaoRb6znegR9hp/CtSpjOoi 2R68mLl0FDZukTW3oDKgwkJd7BnyFOPd5/GOjmzo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A23386083D Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=timur@codeaurora.org Subject: Re: [PATCH 0/2] [v5] pinctrl: qcom: add support for sparse GPIOs To: Linus Walleij , Stephen Boyd References: <1ecdf6ee-5098-15d3-f85e-66b39a6c25f9@codeaurora.org> <619f48d2-59c7-c090-4ace-9e8db9f92064@codeaurora.org> <255ad0dc-2d16-ae7f-0b45-500e23cff1a4@codeaurora.org> <20171003220311.GU457@codeaurora.org> <20171012073922.GB18706@codeaurora.org> From: Timur Tabi Message-ID: <22ef3c75-bdf6-6aeb-a1dd-2d03eb46fd58@codeaurora.org> Date: Mon, 16 Oct 2017 08:42:41 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171016_064304_701338_9E01B43C X-CRM114-Status: GOOD ( 16.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-gpio@vger.kernel.org" , "linux-arm-msm@vger.kernel.org" , anjiandi@codeaurora.org, Bjorn Andersson , David Brown , "thierry.reding@gmail.com" , Andy Gross , Andy Shevchenko , Mika Westerberg , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 10/14/2017 05:43 PM, Linus Walleij wrote: > So I guess the driver needs to know what pin registers it can't > access so the user does not get a gun to shoot in the foot with. > > If we augment gpiolib to just handle -EACCES or something > (-EIO?) from the driver .get_direction() callback for these lines, > things should be smooth? You mean like this: /* 0 = output, 1 = input */ This is what I have in my patch already. I can return any error message you like, but -ENODEV already works. The problem is that it's insufficient. I also want the non-available GPIOs to be as absent as possible. I don't want them to show up in /sys/kernel/debug/gpio, and I don't want to be able to create them via /sys/class/gpio/export. diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index ff491da64dab..ca4ae3d76eb4 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -443,6 +443,14 @@ static int msm_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) g = &pctrl->soc->groups[offset]; + /* + * During initialization, gpiolib may query all GPIOs for their + * initial direction, regardless if they exist, so block access + * to those that are unavailable. + */ + if (!g->npins) + return -ENODEV; + val = readl(pctrl->regs + g->ctl_reg);