[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] Add Linux gpio sysfs applets
From:       Sascha Hauer <s.hauer () pengutronix ! de>
Date:       2014-04-30 10:00:12
Message-ID: 20140430100012.GA20591 () pengutronix ! de
[Download RAW message or body]

On Tue, Apr 29, 2014 at 09:18:06PM +0200, Tito wrote:
> On Tuesday 29 April 2014 16:31:33 Sascha Hauer wrote:
> > This adds applets for manipulating gpios under Linux via sysfs. It uses
> > the /sys/class/gpio API to set direction and value of gpios and to read
> > back the actual value. The applets work like the corresponding C functions
> > in the kernel:
> > 
> > gpio_set_value <gpio> <value>
> > gpio_get_value <gpio>
> > gpio_direction_output <gpio> <value>
> > gpio_direction_input <gpio>
> > 
> > <gpio> is the Linux gpio number and <value> is 0 for low and 1 for high.
> > gpio_get_value will report the value to stdout.
> > 
> > If not already exported the applets export the gpio via
> > /sys/class/gpio/export. After usage the gpio is unexported again,
> > but only if it wasn't exported before calling the applet.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  include/applets.src.h |   4 +
> >  miscutils/Config.src  |   8 ++
> >  miscutils/Kbuild.src  |   1 +
> >  miscutils/gpio.c      | 354 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  4 files changed, 367 insertions(+)
> >  create mode 100644 miscutils/gpio.c
> > 
> > diff --git a/include/applets.src.h b/include/applets.src.h
> > index aedcf22..b4abb4f 100644
> > --- a/include/applets.src.h
> > +++ b/include/applets.src.h
> > @@ -167,6 +167,10 @@ IF_GETENFORCE(APPLET(getenforce, BB_DIR_USR_SBIN, BB_SUID_DROP))
> >  IF_GETOPT(APPLET(getopt, BB_DIR_BIN, BB_SUID_DROP))
> >  IF_GETSEBOOL(APPLET(getsebool, BB_DIR_USR_SBIN, BB_SUID_DROP))
> >  IF_GETTY(APPLET(getty, BB_DIR_SBIN, BB_SUID_DROP))
> 
> Hi,
> why must it be 4  different applets couldn't the same
> applet get/set the value as they share a lot of code?
> Eventually you could use the app name to check if the
> action to perform is to get or to set:
> 
>  (applet_name[6] == 's')
> 
> Also you maybe could use some libbb functions  to reduce the
> code size. I've listed the most obvious of them in the code
> but there could be more.

Thanks for showing the functions, as an occasional busybox developer I'm
not aware of most of these. I can further optimize the code once it's
clear these applets are acceptable in general.

> I suspect that the RidgeRun license could a problem
> for the inclusion of this code in busybox and I wonder
> if it wouldn't be a cleaner solution to rewrite the app
> as it is rather simple stuff.

I'll rewrite the offending bits...

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic