Date: Sat, 24 Mar 2018 23:03:59 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331504 - stable/11/sys/dev/gpio Message-ID: <201803242303.w2ON3x5t026661@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Sat Mar 24 23:03:59 2018 New Revision: 331504 URL: https://svnweb.freebsd.org/changeset/base/331504 Log: MFC r329537: 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: stable/11/sys/dev/gpio/gpiobusvar.h stable/11/sys/dev/gpio/ofw_gpiobus.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/gpio/gpiobusvar.h ============================================================================== --- stable/11/sys/dev/gpio/gpiobusvar.h Sat Mar 24 23:01:10 2018 (r331503) +++ stable/11/sys/dev/gpio/gpiobusvar.h Sat Mar 24 23:03:59 2018 (r331504) @@ -133,6 +133,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: stable/11/sys/dev/gpio/ofw_gpiobus.c ============================================================================== --- stable/11/sys/dev/gpio/ofw_gpiobus.c Sat Mar 24 23:01:10 2018 (r331503) +++ stable/11/sys/dev/gpio/ofw_gpiobus.c Sat Mar 24 23:03:59 2018 (r331504) @@ -57,8 +57,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; @@ -112,7 +112,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 @@ -120,7 +120,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?201803242303.w2ON3x5t026661>