From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Frysinger Date: Fri, 20 Jan 2012 13:59:20 -0500 Subject: [U-Boot] [PATCH v2 3/8] sandbox: gpio: Add basic driver for simulating GPIOs In-Reply-To: <1326242752-9981-3-git-send-email-sjg@chromium.org> References: <1326242752-9981-1-git-send-email-sjg@chromium.org> <1326242752-9981-3-git-send-email-sjg@chromium.org> Message-ID: <201201201359.21521.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tuesday 10 January 2012 19:45:47 Simon Glass wrote: > This provides a way of simulating GPIOs by setting values which are seen > by the normal gpio_get/set_value() calls. seems to be a desync in types ... all "gpio" fields should be "unsigned" and not "int" > --- /dev/null > +++ b/arch/sandbox/include/asm/gpio.h > > +int sandbox_gpio_get_value(int gp); why bother with parallel sandbox gpio API ? why can't we just implement the gpio API directly and throw away sandbox_gpio_xxx ? then we can also stub out sandbox/include/asm/gpio.h ... also, missing gpio_status() define to gpio_info() > --- /dev/null > +++ b/drivers/gpio/sandbox.c > > +enum { > + CMD_INFO, > + CMD_PORT, > + CMD_OUTPUT, > + CMD_INPUT, > +}; CMD_XXX enums are unused -> punt > +enum { > + GPIOF_OUTPUT = 1 << 1, > + GPIOF_HIGH = 1 << 2, > +}; turn enum bit flags into defines also, add a "reserved" bit flag and check it in gpio_request() > +/* read GPIO IN value of port 'gp' */ > +int gpio_get_value(int gp) > ... > + if (get_gpio_flag(gp, GPIOF_OUTPUT)) > ... > +int gpio_set_value(int gp, int value) > ... > + if (get_gpio_flag(gp, GPIOF_OUTPUT)) { drop valid gpio checking in these funcs ... only the request func should do this > +int gpio_request(unsigned gpio, const char *label) > +{ > + /* for now, do nothing */ > + return 0; > +} add (gpio <= CONFIG_SANDBOX_GPIO_COUNT) check to verify the gpio is valid > +int gpio_info(int gp) > +{ > + printf("Sandbox GPIOs\n"); > + return 0; > +} implement it ? -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. URL: