platform/chrome: chromeos_laptop - factor out getting IRQ from DMI
This will make code instantiating I2C device a bit clearer. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Benson Leung <bleung@chromium.org>
This commit is contained in:
parent
4f27f677c9
commit
ab6c5600d8
@ -120,36 +120,47 @@ static struct i2c_board_info atmel_1664s_device = {
|
|||||||
.flags = I2C_CLIENT_WAKE,
|
.flags = I2C_CLIENT_WAKE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int chromeos_laptop_get_irq_from_dmi(const char *dmi_name)
|
||||||
|
{
|
||||||
|
const struct dmi_device *dmi_dev;
|
||||||
|
const struct dmi_dev_onboard *dev_data;
|
||||||
|
|
||||||
|
dmi_dev = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD, dmi_name, NULL);
|
||||||
|
if (!dmi_dev) {
|
||||||
|
pr_err("failed to find DMI device '%s'\n", dmi_name);
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_data = dmi_dev->device_data;
|
||||||
|
if (!dev_data) {
|
||||||
|
pr_err("failed to get data from DMI for '%s'\n", dmi_name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dev_data->instance;
|
||||||
|
}
|
||||||
|
|
||||||
static struct i2c_client *__add_probed_i2c_device(
|
static struct i2c_client *__add_probed_i2c_device(
|
||||||
const char *name,
|
const char *name,
|
||||||
int bus,
|
int bus,
|
||||||
struct i2c_board_info *info,
|
struct i2c_board_info *info,
|
||||||
const unsigned short *alt_addr_list)
|
const unsigned short *alt_addr_list)
|
||||||
{
|
{
|
||||||
const struct dmi_device *dmi_dev;
|
|
||||||
const struct dmi_dev_onboard *dev_data;
|
|
||||||
struct i2c_adapter *adapter;
|
struct i2c_adapter *adapter;
|
||||||
struct i2c_client *client = NULL;
|
struct i2c_client *client = NULL;
|
||||||
const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END };
|
const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END };
|
||||||
|
|
||||||
if (bus < 0)
|
if (bus < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If a name is specified, look for irq platform information stashed
|
* If a name is specified, look for irq platform information stashed
|
||||||
* in DMI_DEV_TYPE_DEV_ONBOARD by the Chrome OS custom system firmware.
|
* in DMI_DEV_TYPE_DEV_ONBOARD by the Chrome OS custom system firmware.
|
||||||
*/
|
*/
|
||||||
if (name) {
|
if (name) {
|
||||||
dmi_dev = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD, name, NULL);
|
info->irq = chromeos_laptop_get_irq_from_dmi(name);
|
||||||
if (!dmi_dev) {
|
if (info->irq < 0)
|
||||||
pr_err("failed to dmi find device %s\n", name);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
dev_data = (struct dmi_dev_onboard *)dmi_dev->device_data;
|
|
||||||
if (!dev_data) {
|
|
||||||
pr_err("failed to get data from dmi for %s\n", name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
info->irq = dev_data->instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter = i2c_get_adapter(bus);
|
adapter = i2c_get_adapter(bus);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user