Date: Thu, 23 May 2019 14:33:01 +0300 From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r348153 - head/sys/dev/gpio Message-ID: <2da5318e-ad03-6b20-950c-d43289bd8608@FreeBSD.org> In-Reply-To: <201905231115.x4NBFMSu037564@repo.freebsd.org> References: <201905231115.x4NBFMSu037564@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 23/05/2019 14:15, Andriy Gapon wrote: > Author: avg > Date: Thu May 23 11:15:22 2019 > New Revision: 348153 > URL: https://svnweb.freebsd.org/changeset/base/348153 > > Log: > gpioled: add a new hint for initial state > > hint.gpioled.%d.state determines the initial state of the LED when the > driver takes control over it: > 0 - the LED is off > 1 - the LED is on > -1 - the LED is kept as it was > > While here, add a module version declaration. By the way, can anyone suggest a mechanism to set device properties like this one _programmatically_ ? I am thinking of a case where I know exactly how everything is wired on a platform. And there is no FDT or alike support for it. And hints are not possible to set up correctly (e.g., bus numbers may float). So, I want to create a gpioled child on a specific bus and I want to set some properties for the device. Of course, I can probably do something like kern_setenv("hints.foo.X.bar", ...) using the child's name and unit number. But that feels a bit cumbersome. And this question is not about gpioled specifically. IVARs is definitely not the right mechanism, because it is about bus-specific properties of devices on the bus. So, it is not aware of properties specific to an individual device (or rather its driver). > Modified: > head/sys/dev/gpio/gpioled.c > > Modified: head/sys/dev/gpio/gpioled.c > ============================================================================== > --- head/sys/dev/gpio/gpioled.c Thu May 23 11:06:38 2019 (r348152) > +++ head/sys/dev/gpio/gpioled.c Thu May 23 11:15:22 2019 (r348153) > @@ -115,6 +115,8 @@ gpioled_attach(device_t dev) > name = NULL; > resource_int_value(device_get_name(dev), > device_get_unit(dev), "invert", &sc->sc_invert); > + resource_int_value(device_get_name(dev), > + device_get_unit(dev), "state", &state); > > sc->sc_leddev = led_create_state(gpioled_control, sc, name ? name : > device_get_nameunit(dev), state); > @@ -155,3 +157,4 @@ static driver_t gpioled_driver = { > > DRIVER_MODULE(gpioled, gpiobus, gpioled_driver, gpioled_devclass, 0, 0); > MODULE_DEPEND(gpioled, gpiobus, 1, 1, 1); > +MODULE_VERSION(gpioled, 1); > -- Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2da5318e-ad03-6b20-950c-d43289bd8608>