From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Shevchenko Subject: Re: [PATCH] pinctrl: intel: Implements gpio free function Date: Thu, 4 Apr 2019 14:52:08 +0300 Message-ID: <20190404115208.GR9224@smile.fi.intel.com> References: <1553135724-38331-1-git-send-email-zhuchangchun@cvte.com> <20190321084420.GG3622@lahna.fi.intel.com> <20190321092330.GK9224@smile.fi.intel.com> <140c6ec0-7c11-6aa9-8434-f14d77be9a8c@metux.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: "Enrico Weigelt, metux IT consult" Cc: Linus Walleij , Mika Westerberg , zhuchangchun , "open list:GPIO SUBSYSTEM" , "linux-kernel@vger.kernel.org" , hendychu@aliyun.coma, Bartosz Golaszewski List-Id: linux-gpio@vger.kernel.org On Thu, Apr 04, 2019 at 12:51:35PM +0200, Enrico Weigelt, metux IT consult wrote: > On 03.04.19 06:13, Linus Walleij wrote: > > > But the chardev on the other hand will protect you from all this.> > If the program crashes, the lines will be free:ed.> > If two scripts > try to access the same GPIO, they will be denied. > Right, when you want this concurrency protection and cleanup stiff > the chardev is the better choice. But I've already had several cases > where the simplicity of the sysfs interface is a big win - all you need > few trivial fs operations. > > That's also nice for exporting in a grid, eg. via 9P (eg. nice for > quickly building up HIL environments) > > ioctls have the bad side effect that they can't be exported via > network in a generic way - your remote fs protocol must support all of > them - even worse: it needs to cope with overlapping ioctl-nr's that > can have entirely different data structures depending on the actual > device. And now try to do that w/ reasonable effort and w/o creating > a shared memory between server and client :p > > Another interesting usecase is permission handling: > > a) some ioctls need special privileges (oh, how I hate all these "if > (!capable(CAP_SYS_ADMIN)) ..." lines in the drivers), but you wanna > give some unprivileged user access to them > b) you wanna give an unprivileged user access to specific gpio's, > but not to all at once. > > With pure filesystem based approach, you can easly define permissions > for each filesystem object. Also you may consider gpiod daemon and it's socket interface, for example. Yes, complicated, but solves above problems AFAICT. I guess the best person, missed in Cc, Bartosz, can tell more about user space interaction. And btw gpiod still a good to have for other even local cases: https://github.com/brgl/libgpiod/issues/29 https://github.com/brgl/libgpiod/issues/40 ... > Yes, these usecases aren't so common for average Jon Doe, but the gpio > subsystem is used that way, out there in the field, and it would be bad > if that functionality would go away someday. -- With Best Regards, Andy Shevchenko