From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Tue, 30 Sep 2014 19:40:12 -0600 Subject: [U-Boot] [PATCH 1/4] dm: rpi: Convert GPIO driver to driver model In-Reply-To: <1411428659-6823-2-git-send-email-sjg@chromium.org> References: <1411428659-6823-1-git-send-email-sjg@chromium.org> <1411428659-6823-2-git-send-email-sjg@chromium.org> Message-ID: <542B5B7C.8040004@wwwdotorg.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 09/22/2014 05:30 PM, Simon Glass wrote: > Convert the BCM2835 GPIO driver to use driver model, and switch over > Raspberry Pi to use this, since it is the only board. > diff --git a/drivers/gpio/bcm2835_gpio.c b/drivers/gpio/bcm2835_gpio.c > +static inline bool gpio_is_requested(struct bcm2835_gpios *gpios, int offset) > { > + return *gpios->label[offset] != '\0'; > } > > +static int check_requested(struct udevice *dev, unsigned offset, > + const char *func) > { > + struct bcm2835_gpios *gpios = dev_get_priv(dev); > + struct gpio_dev_priv *uc_priv = dev->uclass_priv; > + > + if (!gpio_is_requested(gpios, offset)) { > + printf("omap_gpio: %s: error: gpio %s%d not requested\n", > + func, uc_priv->bank_name, offset); > + return -EPERM; > + } > + > + return 0; > } It seems like the core GPIO layer should be doing the high-level management of GPIO requesting, so each driver doesn't have to duplicate the code?