Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3673263ybh; Tue, 17 Mar 2020 04:33:17 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtuTQOUNdQ00p7Y4QKzTez3DYcsbr03AkklncK+lT8R+ZK9N2tIbTL/sSsb2w/7HGK75fvS X-Received: by 2002:a9d:1a4:: with SMTP id e33mr3093268ote.343.1584444797097; Tue, 17 Mar 2020 04:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584444797; cv=none; d=google.com; s=arc-20160816; b=edqzQJC2pjynvSWtnQEkrNrBTYvtOVriNfMoJq7OucLbQfl2sjeSTjeTsdhirutjck tMHFcq9eRgxrQmDAmvhkTxhQQJ6RekW4wdEP2B9Q3zYy97iBw11e1rB4b9Hei3kUe5sB uFPHRl5A5+IKKYJwgc0b23PSXTSe61YvyAnRYjf2jG7X3ZPUc4aFV9oilWqlqHYrL9G0 Clas20QWQauynQ5GJ7kFwsuwa0ytD6U8DBlaTMtpvibTC7qTrXHqdexJc/xj+rcP03Mh BqKxN6Rvzk6NTtPDNH3H1jIeNBMwIIG3JWjyTj4jJbNkwte3uy9bIa1iLdCXo0cFLX9O JR2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=yETyFwQ9Htl1KGbLhFFP34JxwM+8all8kt5P2BYv2cs=; b=MZZHvctIiaKyrsbUcRSXAUvHUdn3YFWhQRbk0gimRVBUSdKgflZZjPMgUp6bDxhWh6 pNbQPwucAn9AK2/6AG5yvnEyWOGFyFTAXA2Y/PyjGo7tMZq1+9A5n8I2T2DtmAnOmDTO RkGynyASKwtCN1l2tKHKdNqXrQdpc3u2i2CMR7B/YQRbbmhcF6FXUnUuPjyp3V89vubG gwdiFOd1Uy5UgUxmfgZS8aIB8BQwuWSklBkz0sGhkpcjfSNKQBk7w6WSvoEb0ceXbs0R 9kY6edibYgeT/13wSevmK82AQdkmknrCZqpjBT5QaHH7kohKFfCh/HGg3eSgo1UDTk1i XGGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k81si1534842oif.105.2020.03.17.04.33.03; Tue, 17 Mar 2020 04:33:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726484AbgCQLcq (ORCPT + 99 others); Tue, 17 Mar 2020 07:32:46 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:42291 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbgCQLcq (ORCPT ); Tue, 17 Mar 2020 07:32:46 -0400 Received: by mail-ot1-f66.google.com with SMTP id a2so362818otq.9; Tue, 17 Mar 2020 04:32:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yETyFwQ9Htl1KGbLhFFP34JxwM+8all8kt5P2BYv2cs=; b=fFmWaGRP50iLWykmVJMdnEKnpISzEjo9Sn0f1FwWkcW/b+/a2QQhFmVdPlvbFS3WaH yGlVd6Qj9wfuOK4rAOCEqjh345Vk63nTpOHsyckuJO4luM5x8giHWlbjhe45f3pY62xy hE5+fUPtfuuRv3TNobMIeVOCgAVVMmDf6oDKmbj6vZtdC7iF+sv7+aluMJgBjD9+q9zy E2ij2P3iO73fiIUpJk8y9ENCsA+MR8qOFAbZ3L40pIW57E+irTeiA0QwDHjPYiwyxtbS Ha10zX+5EJ7qoJZBnEqlR2enM9jM7VbUkflNLtZKooC95MJeh27URlNMY10VnvJbVKRS thmA== X-Gm-Message-State: ANhLgQ0xU5/AaCkxHNeIDFuPw7wxuPKBc6+R4U3TlZha5Rn1fTePRvk1 mXCElEIonS1sEGkrUdElq6jKMgOkmfG9QyTH3VE= X-Received: by 2002:a9d:1708:: with SMTP id i8mr3337224ota.250.1584444762958; Tue, 17 Mar 2020 04:32:42 -0700 (PDT) MIME-Version: 1.0 References: <20200218151812.7816-1-geert+renesas@glider.be> <20200218151812.7816-4-geert+renesas@glider.be> In-Reply-To: <20200218151812.7816-4-geert+renesas@glider.be> From: Geert Uytterhoeven Date: Tue, 17 Mar 2020 12:32:31 +0100 Message-ID: Subject: Re: [PATCH v5 3/5] gpio: Add GPIO Aggregator To: Linus Walleij , Bartosz Golaszewski Cc: Jonathan Corbet , Harish Jenny K N , Eugeniu Rosca , Alexander Graf , Peter Maydell , Paolo Bonzini , Phil Reid , Marc Zyngier , Christoffer Dall , Magnus Damm , Rob Herring , Mark Rutland , "open list:GPIO SUBSYSTEM" , "open list:DOCUMENTATION" , Linux-Renesas , Linux Kernel Mailing List , QEMU Developers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 18, 2020 at 4:18 PM Geert Uytterhoeven wrote: > GPIO controllers are exported to userspace using /dev/gpiochip* > character devices. Access control to these devices is provided by > standard UNIX file system permissions, on an all-or-nothing basis: > either a GPIO controller is accessible for a user, or it is not. > Currently no mechanism exists to control access to individual GPIOs. > > Hence add a GPIO driver to aggregate existing GPIOs, and expose them as > a new gpiochip. > > This supports the following use cases: > - Aggregating GPIOs using Sysfs > This is useful for implementing access control, and assigning a set > of GPIOs to a specific user or virtual machine. > - Generic GPIO Driver > This is useful for industrial control, where it can provide > userspace access to a simple GPIO-operated device described in DT, > cfr. e.g. spidev for SPI-operated devices. > > Signed-off-by: Geert Uytterhoeven > --- /dev/null > +++ b/drivers/gpio/gpio-aggregator.c > +static int gpio_fwd_set_config(struct gpio_chip *chip, unsigned int offset, > + unsigned long config) > +{ > + struct gpiochip_fwd *fwd = gpiochip_get_data(chip); > + > + chip = fwd->descs[offset]->gdev->chip; > + if (chip->set_config) - chip = fwd->descs[offset]->gdev->chip; - if (chip->set_config) + chip = gpiod_to_chip(fwd->descs[offset]); + if (chip && chip->set_config) > + return chip->set_config(chip, offset, config); This is not correct: offset should be translated, too, i.e. offset = gpio_chip_hwgpio(fwd->descs[offset]); Which adds a new dependency on "gpiolib.h"... Is there a better alternative, than providing a public gpiod_set_config() helper? Thanks! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds