Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Feb 2018 23:08:43 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329537 - head/sys/dev/gpio
Message-ID:  <201802182308.w1IN8hia046125@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sun Feb 18 23:08:43 2018
New Revision: 329537
URL: https://svnweb.freebsd.org/changeset/base/329537

Log:
  Provide a public function to acquire a gpio pin by giving the property name
  and index.  A private function to do exactly that already existed, so this
  renames gpio_pin_get_by_ofw_impl() to gpio_pin_get_by_ofw_propidx() and
  provides a declaration for it in a public header.
  
  Previously there were functions to get a pin by property name (assuming
  there would only be one pin defined for the name), or by index (asuming
  the property has the standard name "gpios").  It turns out there are
  devicetree bindings that describe properties with names other than "gpios"
  which can describe multiple pins.  Hence the need to retrieve the Nth item
  from a named property.

Modified:
  head/sys/dev/gpio/gpiobusvar.h
  head/sys/dev/gpio/ofw_gpiobus.c

Modified: head/sys/dev/gpio/gpiobusvar.h
==============================================================================
--- head/sys/dev/gpio/gpiobusvar.h	Sun Feb 18 23:01:33 2018	(r329536)
+++ head/sys/dev/gpio/gpiobusvar.h	Sun Feb 18 23:08:43 2018	(r329537)
@@ -136,6 +136,8 @@ int gpio_pin_get_by_ofw_idx(device_t consumer, phandle
     int idx, gpio_pin_t *gpio);
 int gpio_pin_get_by_ofw_property(device_t consumer, phandle_t node,
     char *name, gpio_pin_t *gpio);
+int gpio_pin_get_by_ofw_propidx(device_t consumer, phandle_t node,
+    char *name, int idx, gpio_pin_t *gpio);
 void gpio_pin_release(gpio_pin_t gpio);
 int gpio_pin_getcaps(gpio_pin_t pin, uint32_t *caps);
 int gpio_pin_is_active(gpio_pin_t pin, bool *active);

Modified: head/sys/dev/gpio/ofw_gpiobus.c
==============================================================================
--- head/sys/dev/gpio/ofw_gpiobus.c	Sun Feb 18 23:01:33 2018	(r329536)
+++ head/sys/dev/gpio/ofw_gpiobus.c	Sun Feb 18 23:08:43 2018	(r329537)
@@ -59,8 +59,8 @@ static int ofw_gpiobus_parse_gpios_impl(device_t, phan
  * tree consumers.
  *
  */
-static int
-gpio_pin_get_by_ofw_impl(device_t consumer, phandle_t cnode,
+int
+gpio_pin_get_by_ofw_propidx(device_t consumer, phandle_t cnode,
     char *prop_name, int idx, gpio_pin_t *out_pin)
 {
 	phandle_t xref;
@@ -114,7 +114,7 @@ gpio_pin_get_by_ofw_idx(device_t consumer, phandle_t n
     int idx, gpio_pin_t *pin)
 {
 
-	return (gpio_pin_get_by_ofw_impl(consumer, node, "gpios", idx, pin));
+	return (gpio_pin_get_by_ofw_propidx(consumer, node, "gpios", idx, pin));
 }
 
 int
@@ -122,7 +122,7 @@ gpio_pin_get_by_ofw_property(device_t consumer, phandl
     char *name, gpio_pin_t *pin)
 {
 
-	return (gpio_pin_get_by_ofw_impl(consumer, node, name, 0, pin));
+	return (gpio_pin_get_by_ofw_propidx(consumer, node, name, 0, pin));
 }
 
 int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802182308.w1IN8hia046125>