* Find i801 i2c_adapter in other module
@ 2013-11-21 20:43 Ian Pilcher
0 siblings, 0 replies; only message in thread
From: Ian Pilcher @ 2013-11-21 20:43 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
I have a Thecus N5550 NAS, on which I run CentOS 6.4. I have created a
"board info" module which sets up the system's GPIOs and LEDs.
https://github.com/ipilcher/n5550/blob/master/modules/n5550_board.c
Some of the LEDs are driven by a couple of NXP PCA9532 dimmers, which
are connected to the i801 SMBus. I am currently hardcoding the bus
number, which is fragile. If the drivers are loaded in a different
order, as they are on Debian, the bus gets a different number, and the
module doesn't work.
#define N5550_PCA9532_I2C_BUS 5
static int __init n5550_pca9532_setup(void)
{
struct i2c_adapter *adapter;
adapter = i2c_get_adapter(N5550_PCA9532_I2C_BUS);
if (adapter == NULL) {
return -ENOMEM;
}
n5550_pca9532_0_client = i2c_new_device(adapter, &n5550_pca9532_0_info);
if (n5550_pca9532_0_client == NULL) {
i2c_put_adapter(adapter);
return -ENOMEM;
}
n5550_pca9532_1_client = i2c_new_device(adapter, &n5550_pca9532_1_info);
if (n5550_pca9532_1_client == NULL) {
i2c_unregister_device(n5550_pca9532_0_client);
i2c_put_adapter(adapter);
return -ENOMEM;
}
i2c_put_adapter(adapter);
return 0;
}
What is the best way to get the correct i2c_adapter, either by driver
name or PCI address?
Thanks!
--
========================================================================
Ian Pilcher arequipeno-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Sent from the cloud -- where it's already tomorrow
========================================================================
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-11-21 20:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-21 20:43 Find i801 i2c_adapter in other module Ian Pilcher
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).