mirror of git://git.sysmocom.de/ofono
udev: Add support for default driver assignments
If devices are not tagged with OFONO_DRIVER, then the driver will be figured out based on kernel module name, vendor and/or product IDs. Of course the manual tagging with OFONO_DRIVER as part of an udev rule can always overwrite the default assignment.
This commit is contained in:
parent
40cf7449fe
commit
19e4dc97c1
|
@ -65,25 +65,6 @@ ENV{DEVTYPE}!="usb_device", GOTO="ofono_end"
|
|||
# Ignore fake serial number
|
||||
ATTRS{serial}=="1234567890ABCDEF", ENV{ID_SERIAL_SHORT}=""
|
||||
|
||||
# Novatel Wireless
|
||||
ATTRS{idVendor}=="1410", ENV{OFONO_DRIVER}="novatel"
|
||||
|
||||
# Sierra Wireless
|
||||
ATTRS{idVendor}=="1199", ENV{OFONO_DRIVER}="sierra"
|
||||
|
||||
# HUAWEI Technology
|
||||
ATTRS{idVendor}=="12d1", ENV{OFONO_DRIVER}="huawei"
|
||||
ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="140b", ENV{OFONO_DRIVER}="huaweicdma"
|
||||
|
||||
# Olive
|
||||
ATTRS{idVendor}=="201e", ENV{OFONO_DRIVER}="huaweicdma"
|
||||
|
||||
# Qualcomm Incorporated
|
||||
ATTRS{idVendor}=="05c6", ENV{OFONO_DRIVER}="gobi"
|
||||
|
||||
# ZTE Incorporated
|
||||
ATTRS{idVendor}=="19d2", ENV{OFONO_DRIVER}="zte"
|
||||
|
||||
# Alcatel X220L
|
||||
ATTRS{idVendor}=="1bbb", ATTRS{idProduct}=="0017", ENV{OFONO_DRIVER}="alcatel"
|
||||
|
||||
|
|
|
@ -385,6 +385,22 @@ static void add_device(const char *syspath, const char *devname,
|
|||
compare_device);
|
||||
}
|
||||
|
||||
static struct {
|
||||
const char *driver;
|
||||
const char *drv;
|
||||
const char *vid;
|
||||
const char *pid;
|
||||
} vendor_list[] = {
|
||||
{ "gobi", "qcserial" },
|
||||
{ "sierra", "sierra" },
|
||||
{ "huawei", "option", "12d1" },
|
||||
{ "huaweicdma", "option", "12d1", "140b" },
|
||||
{ "huaweicdma", "option", "201e" },
|
||||
{ "novatel", "option", "1410" },
|
||||
{ "zte", "option", "19d2" },
|
||||
{ }
|
||||
};
|
||||
|
||||
static void check_device(struct udev_device *device)
|
||||
{
|
||||
struct udev_device *usb_device;
|
||||
|
@ -411,8 +427,50 @@ static void check_device(struct udev_device *device)
|
|||
return;
|
||||
|
||||
driver = udev_device_get_property_value(usb_device, "OFONO_DRIVER");
|
||||
if (driver == NULL)
|
||||
return;
|
||||
if (driver == NULL) {
|
||||
const char *drv, *vid, *pid;
|
||||
unsigned int i;
|
||||
|
||||
drv = udev_device_get_property_value(device, "ID_USB_DRIVER");
|
||||
if (drv == NULL)
|
||||
return;
|
||||
|
||||
vid = udev_device_get_property_value(device, "ID_VENDOR_ID");
|
||||
if (vid == NULL)
|
||||
return;
|
||||
|
||||
pid = udev_device_get_property_value(device, "ID_MODEL_ID");
|
||||
if (pid == NULL)
|
||||
return;
|
||||
|
||||
DBG("%s [%s:%s]", drv, vid, pid);
|
||||
|
||||
for (i = 0; vendor_list[i].driver; i++) {
|
||||
if (g_str_equal(vendor_list[i].drv, drv) == FALSE)
|
||||
continue;
|
||||
|
||||
if (vendor_list[i].vid == NULL) {
|
||||
driver = vendor_list[i].driver;
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_str_equal(vendor_list[i].vid, vid) == TRUE) {
|
||||
if (vendor_list[i].pid == NULL) {
|
||||
if (driver == NULL)
|
||||
driver = vendor_list[i].driver;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (g_strcmp0(vendor_list[i].pid, pid) == 0) {
|
||||
driver = vendor_list[i].driver;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (driver == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
add_device(syspath, devname, driver, device);
|
||||
}
|
||||
|
@ -430,6 +488,7 @@ static void create_modem(gpointer key, gpointer value, gpointer user_data)
|
|||
return;
|
||||
|
||||
DBG("%s", syspath);
|
||||
DBG("driver=%s", modem->driver);
|
||||
|
||||
modem->modem = ofono_modem_create(NULL, modem->driver);
|
||||
if (modem->modem == NULL)
|
||||
|
|
Loading…
Reference in New Issue