From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755487AbcKXGxH (ORCPT ); Thu, 24 Nov 2016 01:53:07 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:3549 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751126AbcKXGxF (ORCPT ); Thu, 24 Nov 2016 01:53:05 -0500 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Wed, 23 Nov 2016 10:51:37 -0800 Message-ID: <58368A60.2010702@nvidia.com> Date: Thu, 24 Nov 2016 12:06:16 +0530 From: Laxman Dewangan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Thierry Reding , Linus Walleij CC: Stephen Warren , Suresh Mangipudi , Alexandre Courbot , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" , "linux-tegra@vger.kernel.org" Subject: Re: [PATCH] gpio: tegra186: Add support for T186 GPIO References: <1478083719-14836-1-git-send-email-smangipudi@nvidia.com> <0e3e89a8-a2f1-68c2-0586-58902fb91587@wwwdotorg.org> <20161122173042.GA3239@ulmo.ba.sec> <20161123194036.GA25876@ulmo.ba.sec> In-Reply-To: <20161123194036.GA25876@ulmo.ba.sec> X-Originating-IP: [10.19.65.30] X-ClientProxiedBy: DRUKMAIL101.nvidia.com (10.25.59.19) To bgmail102.nvidia.com (10.25.59.11) Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 24 November 2016 01:10 AM, Thierry Reding wrote: > * PGP Signed by an unknown key > > On Wed, Nov 23, 2016 at 02:25:51PM +0100, Linus Walleij wrote: >> >> This is already possible and several drivers are doing this. >> >> Everything, all kernel users and all character device users, end up >> calling gpiod_request(). > It looks like I stumbled across the only case where this isn't true. > What I was seeing, and which ultimately led me to implement the compact > numberspace is that gpiochip_add_data() calls ->get_direction() directly > without first going through ->request(). We'd have to guard that one > case as well in order for this to work. > In T186, we have 8 pins per PORT and for some of ports, all pins are not available. Like Port A has 7 pins valid (0 to 6) and port E have 8 pins (0 to 7). The great part is that each port has valid pins start from 0. So just having the number of valid pins for each port as part of SOC data will help to find out whether GPIO exist or not. int port = GPIO_PORT(offset); int pin = GPIO_PIN(offset); if (pin >= tgi->soc->port[port].valid_pins) return false; Similar logic can be used for APIs which can get called without gpio_request().