Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3048989pxu; Tue, 8 Dec 2020 02:01:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGIOCoQ0MGOOVrByeA02nvU/anP7eCZysBl+GH0wGbxNeSfJXtp7IZmwXf9Bu+LRdrpRTR X-Received: by 2002:a17:906:814a:: with SMTP id z10mr21892463ejw.96.1607421689048; Tue, 08 Dec 2020 02:01:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607421689; cv=none; d=google.com; s=arc-20160816; b=iFXUthRHkHopig0Y3iXo7KUkOVk32JVG1GNTYNvPtPupOrKeGD7Zp0eBDLji4wJggJ alSALbSwHkE5L/a0IvoWrYvLRSILnnaFmHHxorybJ1w3DAq6TQBA5xX4pjYhglOsVLfE hvWAhqCyIcvNk0zoOouAbzpcYLNsNPndl+MZHHHJafnjpFrmCMOwLYC6jyaGS98Dgt5L dQRim5uXYu0paAZbduM7lAhPk9kCU7irh4SWGkwBlKKpA/hM7QdtjYaWKiVSXCRa+TEz NHDGIdzVjL4eHA8K66u4nEDrT1PPPAnE/pMtxLlalO4ozrzWynyswA1ylqipt04qNjmY XYcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Q47D2MCEJANfe8A3Mn/U//6T+qK1xgRot8Ay5wujQIg=; b=veU3pZ5TS06jDXgn1Pf/x/+k0Pox6brYK0aIEyxltIj2XQ98f+NouPNT8VqP5B7UhW FPPfhhD7Q8cffHtvg6n1ElnyPwSmVsE3lymQ1QV6rw9S4gkIRr3ZkJ2VpEUHEqz7dkPt lpQKZBpDzYW8bElzlf/m2BrgKEdZ+PRK5WpLUNda+Txn09jvOxKkvOc4VuCw/XYFcI9H 1dIsnXxNQTHvepV9MTe7uUHqTbm2FHxO1MYsbxqc5YtAG1FUeDC1i9G/xDP/02/4/gHW hoT0/0fTgF7BpfImRTA13M4uAQ7xBaLB8Ixz3nemqEFcPaNLOy+DMSmH8ZUp9woX11QP rIIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 10si8225943ejn.746.2020.12.08.02.01.06; Tue, 08 Dec 2020 02:01:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728594AbgLHJ6X (ORCPT + 99 others); Tue, 8 Dec 2020 04:58:23 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:45515 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727132AbgLHJ6X (ORCPT ); Tue, 8 Dec 2020 04:58:23 -0500 Received: by mail-lj1-f195.google.com with SMTP id q8so18352703ljc.12; Tue, 08 Dec 2020 01:58:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Q47D2MCEJANfe8A3Mn/U//6T+qK1xgRot8Ay5wujQIg=; b=KipQnqbgUuyoecsjKoPfDKVBuDTOswBrGz2z4I+zK4j9O6L88cDle97w93n2AYi9Z+ drz2IMLl4i/hWI4ahqEqDXoU+XUZhMWgnNGcjGOmJ5XdkYz7hhB+X3N685Wo2HDJbkHg sKOaCaAohxL6cKJCtDkCixzIZwdhoThRWsZWmONo9ADdVqblZdUAxHa8fi6NF8ROyrmS dd8niFye19l7keZuuoVaw4D3jMNzlmugkReY2vwT5qyhhX0gsp7NL0OE4FHSOY2yAuSW jujdO1O2LVFkN91/5uX1tkkyQ0GKeGx3jCtv696NS5XZtmtPxKNnqtEL0l9ltsGNIqYq NtwA== X-Gm-Message-State: AOAM532uDRJwkTBHKNnSNbHeL77P8kbCqdX4CnY1wS0Y6yEQucdJzTFc vwGv1MAmfqknFCL4D4RobbA= X-Received: by 2002:a2e:81d1:: with SMTP id s17mr10404025ljg.287.1607421460890; Tue, 08 Dec 2020 01:57:40 -0800 (PST) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id m11sm862904ljp.12.2020.12.08.01.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 01:57:40 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kmZlB-0002ZK-9Y; Tue, 08 Dec 2020 10:58:18 +0100 Date: Tue, 8 Dec 2020 10:58:17 +0100 From: Johan Hovold To: Linus Walleij Cc: Johan Hovold , Manivannan Sadhasivam , Greg KH , linux-usb , "linux-kernel@vger.kernel.org" , patong.mxl@gmail.com, Mauro Carvalho Chehab , Angelo Dureghello , "open list:GPIO SUBSYSTEM" Subject: Re: [PATCH v5 2/3] usb: serial: xr_serial: Add gpiochip support Message-ID: References: <20201122170822.21715-1-mani@kernel.org> <20201122170822.21715-3-mani@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 05, 2020 at 11:21:09PM +0100, Linus Walleij wrote: > On Tue, Dec 1, 2020 at 4:50 PM Johan Hovold wrote: > > On Tue, Dec 01, 2020 at 03:37:38PM +0100, Linus Walleij wrote: > > > On Sun, Nov 22, 2020 at 6:08 PM Manivannan Sadhasivam wrote: > > > > You know the names of the pins... > > > > > > > + port_priv->gc.ngpio = 6; > > > > + port_priv->gc.label = "xr_gpios"; > > > > + port_priv->gc.request = xr_gpio_request; > > > > + port_priv->gc.free = xr_gpio_free; > > > > + port_priv->gc.get_direction = xr_gpio_direction_get; > > > > + port_priv->gc.direction_input = xr_gpio_direction_input; > > > > + port_priv->gc.direction_output = xr_gpio_direction_output; > > > > + port_priv->gc.get = xr_gpio_get; > > > > + port_priv->gc.set = xr_gpio_set; > > > > + port_priv->gc.owner = THIS_MODULE; > > > > + port_priv->gc.parent = &port->dev; > > > > + port_priv->gc.base = -1; > > > > + port_priv->gc.can_sleep = true; > > > > > > So assign port_priv->gc.names here as well with an array > > > of strings with the names ("RI", "CD", ... etc). > > > This makes it look really nice in userspace if you do > > > e.g. "lsgpio". > > > > Last time we tried that gpiolib still used a flat namespace so that you > > can't have have more than one device using the same names. Unless that > > has changed this is a no-go. See > > > > https://lore.kernel.org/r/20180930122703.7115-1-johan@kernel.org > > > > for our previous discussion about this. > > Hm hm yeah we actually put in a nasty warning there since: > > gpio = gpio_name_to_desc(gc->names[i]); > if (gpio) > dev_warn(&gdev->dev, > "Detected name collision for GPIO name '%s'\n", > gc->names[i]); > > > A better approach might be to create an array of names > prepended with something device-unique like the USB > bus topology? Or do we need a helper to help naming the > GPIOs? What would be helpful here? > > name = kasprintf(GFP_KERNEL, "%s-NAME", topology_str); Well we started discussing this back when we only had the sysfs interface which suffered from the same problem. I thought the chardev interface was supposed to get rid of the assumption of a flat name space? Perhaps in v3 of the ABI. ;P If this is too built into the new chardev interface as well to be fixed up, a unique prefix is the only way to go. Perhaps gpiolib can just prefix it with the controller name? gpiochip508-CBUS0 Based on a hotpluggable bus flag? But what about any other non-pluggable IC, which provides a few named GPIO lines and of which there could be more than one in a system? The topology is already encoded in sysfs and it seems backwards to have each and every gpio driver reconstruct it. Johan