linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to ensure other module/driver is initialized?
@ 2016-12-15 19:50 Ian Pilcher
  2017-01-24 13:02 ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Pilcher @ 2016-12-15 19:50 UTC (permalink / raw)
  To: linux-kernel, linux-gpio

I maintain an out-of-tree kernel module that enables the front-panel
LEDs on the Thecus N5550 NAS.

   https://github.com/ipilcher/n5550/blob/master/modules/n5550_board.c

The drive activity LEDs are connected to GPIO pins on the ICH10R, so
the gpio_ich driver must be loaded and initialized before my module is
loaded.  Unfortunately, the "and initialized" part is giving me trouble
after a recent CentOS kernel update.

My modprobe configuration includes:

   install n5550_board /sbin/modprobe gpio_ich; /sbin/modprobe i2c_i801;
       /sbin/modprobe --ignore-install n5550_board

But although the gpio_ich module does get loaded, it apparently hasn't
finished initializing when my module is loaded.  The result looks like
this:

  [    2.049217] leds-pca953x 0-0064: setting platform data
  [    2.051756] leds-gpio leds-gpio: pins are not configured from the 
driver
  [    2.051886] ------------[ cut here ]------------
  [    2.052004] WARNING: at drivers/gpio/gpiolib.c:176 
gpio_to_desc+0x94/0xd0()
  [    2.052120] invalid GPIO 195
  [    2.052273] Modules linked in: leds_gpio(+) leds_pca9532(+) 
dm_mirror dm_region_hash dm_log dm_mod it87 hwmon_vid n5550_board(OE) 
i2c_i801 gpio_ich i2c_core
  ...
  [    2.055171] Call Trace:
  ...
  [    2.060439] ---[ end trace d53e8e3ea852c413 ]---
  [    2.060589] gpiod_request: invalid GPIO
  [    2.060767] leds-pca953x 0-0062: setting platform data
  [    2.062718] leds-gpio: probe of leds-gpio failed with error -22
  [    2.066156] leds-pca953x 0-0062: gpios 16...31
  ...
  [    2.265708] gpio_ich: GPIO from 195 to 255 on gpio_ich

You can see that gpio_ich does appear on the "Modules linked in" line,
but it hasn't finished initializing until more that 1/10th of a
second after my module tries to use its GPIOs (indirectly through
leds_gpio).

I can work around this by adding a sleep to my modprobe configuration,
but that feels hacky and fragile.

What is the "right" way to do this?

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
-------- "I grew up before Mark Zuckerberg invented friendship" --------
========================================================================

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-01-26 14:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-15 19:50 How to ensure other module/driver is initialized? Ian Pilcher
2017-01-24 13:02 ` Linus Walleij
2017-01-24 16:40   ` Ian Pilcher
2017-01-26 14:51     ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).