kernel-device: add get_interface_number() method
We already have methods to query for interface specific attributes like class/subclass/protocol, so add a new one for the interface number, and make sure we use ATTRS{bInterfaceNumber} to load it always, instead of assuming the ID_USB_INTERFACE_NUM property is set.
This commit is contained in:
@@ -63,7 +63,7 @@ get_usb_interface_config_index (MMPort *data,
|
|||||||
guint usb_iface_num;
|
guint usb_iface_num;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
usb_iface_num = mm_kernel_device_get_property_as_int_hex (mm_port_peek_kernel_device (data), "ID_USB_INTERFACE_NUM");
|
usb_iface_num = (guint) mm_kernel_device_get_interface_number (mm_port_peek_kernel_device (data));
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (usb_interface_configs); i++) {
|
for (i = 0; i < G_N_ELEMENTS (usb_interface_configs); i++) {
|
||||||
if (usb_interface_configs[i].usb_iface_num == usb_iface_num)
|
if (usb_interface_configs[i].usb_iface_num == usb_iface_num)
|
||||||
|
@@ -56,7 +56,7 @@ MM_PLUGIN_DEFINE_MINOR_VERSION
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MMPortProbe *probe;
|
MMPortProbe *probe;
|
||||||
guint first_usbif;
|
gint first_usbif;
|
||||||
guint timeout_id;
|
guint timeout_id;
|
||||||
gboolean custom_init_run;
|
gboolean custom_init_run;
|
||||||
} FirstInterfaceContext;
|
} FirstInterfaceContext;
|
||||||
@@ -177,23 +177,23 @@ try_next_usbif (MMPortProbe *probe,
|
|||||||
MMDevice *device)
|
MMDevice *device)
|
||||||
{
|
{
|
||||||
FirstInterfaceContext *fi_ctx;
|
FirstInterfaceContext *fi_ctx;
|
||||||
GList *l;
|
GList *l;
|
||||||
guint closest;
|
gint closest;
|
||||||
|
|
||||||
fi_ctx = g_object_get_data (G_OBJECT (device), TAG_FIRST_INTERFACE_CONTEXT);
|
fi_ctx = g_object_get_data (G_OBJECT (device), TAG_FIRST_INTERFACE_CONTEXT);
|
||||||
g_assert (fi_ctx != NULL);
|
g_assert (fi_ctx != NULL);
|
||||||
|
|
||||||
/* Look for the next closest one among the list of interfaces in the device,
|
/* Look for the next closest one among the list of interfaces in the device,
|
||||||
* and enable that one as being first */
|
* and enable that one as being first */
|
||||||
closest = G_MAXUINT;
|
closest = G_MAXINT;
|
||||||
for (l = mm_device_peek_port_probe_list (device); l; l = g_list_next (l)) {
|
for (l = mm_device_peek_port_probe_list (device); l; l = g_list_next (l)) {
|
||||||
MMPortProbe *iter = MM_PORT_PROBE (l->data);
|
MMPortProbe *iter = MM_PORT_PROBE (l->data);
|
||||||
|
|
||||||
/* Only expect ttys for next probing attempt */
|
/* Only expect ttys for next probing attempt */
|
||||||
if (g_str_equal (mm_port_probe_get_port_subsys (iter), "tty")) {
|
if (g_str_equal (mm_port_probe_get_port_subsys (iter), "tty")) {
|
||||||
guint usbif;
|
gint usbif;
|
||||||
|
|
||||||
usbif = mm_kernel_device_get_property_as_int_hex (mm_port_probe_peek_port (iter), "ID_USB_INTERFACE_NUM");
|
usbif = mm_kernel_device_get_interface_number (mm_port_probe_peek_port (iter));
|
||||||
if (usbif == fi_ctx->first_usbif) {
|
if (usbif == fi_ctx->first_usbif) {
|
||||||
/* This is the one we just probed, which wasn't yet removed, so just skip it */
|
/* This is the one we just probed, which wasn't yet removed, so just skip it */
|
||||||
} else if (usbif > fi_ctx->first_usbif &&
|
} else if (usbif > fi_ctx->first_usbif &&
|
||||||
@@ -203,7 +203,7 @@ try_next_usbif (MMPortProbe *probe,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (closest == G_MAXUINT) {
|
if (closest == G_MAXINT) {
|
||||||
/* No more ttys to try! Just return something */
|
/* No more ttys to try! Just return something */
|
||||||
closest = 0;
|
closest = 0;
|
||||||
mm_obj_dbg (probe, "no more ports to run initial probing");
|
mm_obj_dbg (probe, "no more ports to run initial probing");
|
||||||
@@ -359,9 +359,7 @@ huawei_custom_init (MMPortProbe *probe,
|
|||||||
g_task_set_task_data (task, ctx, (GDestroyNotify)huawei_custom_init_context_free);
|
g_task_set_task_data (task, ctx, (GDestroyNotify)huawei_custom_init_context_free);
|
||||||
|
|
||||||
/* Custom init only to be run in the first interface */
|
/* Custom init only to be run in the first interface */
|
||||||
if (mm_kernel_device_get_property_as_int_hex (mm_port_probe_peek_port (probe),
|
if (mm_kernel_device_get_interface_number (mm_port_probe_peek_port (probe)) != fi_ctx->first_usbif) {
|
||||||
"ID_USB_INTERFACE_NUM") != fi_ctx->first_usbif) {
|
|
||||||
|
|
||||||
if (fi_ctx->custom_init_run)
|
if (fi_ctx->custom_init_run)
|
||||||
/* If custom init was run already, we can consider this as successfully run */
|
/* If custom init was run already, we can consider this as successfully run */
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
@@ -391,8 +389,8 @@ static gint
|
|||||||
probe_cmp_by_usbif (MMPortProbe *a,
|
probe_cmp_by_usbif (MMPortProbe *a,
|
||||||
MMPortProbe *b)
|
MMPortProbe *b)
|
||||||
{
|
{
|
||||||
return ((gint) mm_kernel_device_get_property_as_int_hex (mm_port_probe_peek_port (a), "ID_USB_INTERFACE_NUM") -
|
return (mm_kernel_device_get_interface_number (mm_port_probe_peek_port (a)) -
|
||||||
(gint) mm_kernel_device_get_property_as_int_hex (mm_port_probe_peek_port (b), "ID_USB_INTERFACE_NUM"));
|
mm_kernel_device_get_interface_number (mm_port_probe_peek_port (b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
|
@@ -56,7 +56,7 @@ grab_port (MMPlugin *self,
|
|||||||
{
|
{
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
MMKernelDevice *port;
|
MMKernelDevice *port;
|
||||||
guint usbif;
|
gint usbif;
|
||||||
|
|
||||||
/* The Option plugin cannot do anything with non-AT ports */
|
/* The Option plugin cannot do anything with non-AT ports */
|
||||||
if (!mm_port_probe_is_at (probe)) {
|
if (!mm_port_probe_is_at (probe)) {
|
||||||
@@ -73,7 +73,7 @@ grab_port (MMPlugin *self,
|
|||||||
* the modem/data port, per mail with Option engineers. Only this port
|
* the modem/data port, per mail with Option engineers. Only this port
|
||||||
* will emit responses to dialing commands.
|
* will emit responses to dialing commands.
|
||||||
*/
|
*/
|
||||||
usbif = mm_kernel_device_get_property_as_int_hex (port, "ID_USB_INTERFACE_NUM");
|
usbif = mm_kernel_device_get_interface_number (port);
|
||||||
if (usbif == 0)
|
if (usbif == 0)
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY | MM_PORT_SERIAL_AT_FLAG_PPP;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY | MM_PORT_SERIAL_AT_FLAG_PPP;
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ telit_grab_port (MMPlugin *self,
|
|||||||
if (g_object_get_data (G_OBJECT (device), TAG_GETPORTCFG_SUPPORTED) != NULL) {
|
if (g_object_get_data (G_OBJECT (device), TAG_GETPORTCFG_SUPPORTED) != NULL) {
|
||||||
guint usbif;
|
guint usbif;
|
||||||
|
|
||||||
usbif = mm_kernel_device_get_property_as_int_hex (port, "ID_USB_INTERFACE_NUM");
|
usbif = (guint) mm_kernel_device_get_interface_number (port);
|
||||||
if (usbif == GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (device), TAG_TELIT_MODEM_PORT))) {
|
if (usbif == GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (device), TAG_TELIT_MODEM_PORT))) {
|
||||||
mm_obj_dbg (self, "AT port '%s/%s' flagged as primary",
|
mm_obj_dbg (self, "AT port '%s/%s' flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
@@ -257,9 +257,7 @@ telit_custom_init_step (GTask *task)
|
|||||||
* is always linked to an AT port
|
* is always linked to an AT port
|
||||||
*/
|
*/
|
||||||
port = mm_port_probe_peek_port (probe);
|
port = mm_port_probe_peek_port (probe);
|
||||||
if (!ctx->getportcfg_done &&
|
if (!ctx->getportcfg_done && mm_kernel_device_get_interface_number (port) == 0) {
|
||||||
g_strcmp0 (mm_kernel_device_get_property (port, "ID_USB_INTERFACE_NUM"), "00") == 0) {
|
|
||||||
|
|
||||||
if (ctx->getportcfg_retries == 0)
|
if (ctx->getportcfg_retries == 0)
|
||||||
goto out;
|
goto out;
|
||||||
ctx->getportcfg_retries--;
|
ctx->getportcfg_retries--;
|
||||||
|
@@ -550,6 +550,12 @@ kernel_device_get_sysfs_path (MMKernelDevice *self)
|
|||||||
return MM_KERNEL_DEVICE_GENERIC (self)->priv->sysfs_path;
|
return MM_KERNEL_DEVICE_GENERIC (self)->priv->sysfs_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
kernel_device_get_interface_number (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
return (gint) MM_KERNEL_DEVICE_GENERIC (self)->priv->interface_number;
|
||||||
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
kernel_device_get_interface_class (MMKernelDevice *self)
|
kernel_device_get_interface_class (MMKernelDevice *self)
|
||||||
{
|
{
|
||||||
@@ -1172,6 +1178,7 @@ mm_kernel_device_generic_class_init (MMKernelDeviceGenericClass *klass)
|
|||||||
kernel_device_class->get_physdev_subsystem = kernel_device_get_physdev_subsystem;
|
kernel_device_class->get_physdev_subsystem = kernel_device_get_physdev_subsystem;
|
||||||
kernel_device_class->get_physdev_manufacturer = kernel_device_get_physdev_manufacturer;
|
kernel_device_class->get_physdev_manufacturer = kernel_device_get_physdev_manufacturer;
|
||||||
kernel_device_class->get_physdev_product = kernel_device_get_physdev_product;
|
kernel_device_class->get_physdev_product = kernel_device_get_physdev_product;
|
||||||
|
kernel_device_class->get_interface_number = kernel_device_get_interface_number;
|
||||||
kernel_device_class->get_interface_class = kernel_device_get_interface_class;
|
kernel_device_class->get_interface_class = kernel_device_get_interface_class;
|
||||||
kernel_device_class->get_interface_subclass = kernel_device_get_interface_subclass;
|
kernel_device_class->get_interface_subclass = kernel_device_get_interface_subclass;
|
||||||
kernel_device_class->get_interface_protocol = kernel_device_get_interface_protocol;
|
kernel_device_class->get_interface_protocol = kernel_device_get_interface_protocol;
|
||||||
|
@@ -402,6 +402,15 @@ kernel_device_get_physdev_product (MMKernelDevice *_self)
|
|||||||
return (self->priv->physdev ? g_udev_device_get_sysfs_attr (self->priv->physdev, "product") : NULL);
|
return (self->priv->physdev ? g_udev_device_get_sysfs_attr (self->priv->physdev, "product") : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
kernel_device_get_interface_number (MMKernelDevice *_self)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
return (self->priv->interface ? (gint) udev_device_get_sysfs_attr_as_hex (self->priv->interface, "bInterfaceNumber") : -1);
|
||||||
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
kernel_device_get_interface_class (MMKernelDevice *_self)
|
kernel_device_get_interface_class (MMKernelDevice *_self)
|
||||||
{
|
{
|
||||||
@@ -743,6 +752,7 @@ mm_kernel_device_udev_class_init (MMKernelDeviceUdevClass *klass)
|
|||||||
kernel_device_class->get_physdev_subsystem = kernel_device_get_physdev_subsystem;
|
kernel_device_class->get_physdev_subsystem = kernel_device_get_physdev_subsystem;
|
||||||
kernel_device_class->get_physdev_manufacturer = kernel_device_get_physdev_manufacturer;
|
kernel_device_class->get_physdev_manufacturer = kernel_device_get_physdev_manufacturer;
|
||||||
kernel_device_class->get_physdev_product = kernel_device_get_physdev_product;
|
kernel_device_class->get_physdev_product = kernel_device_get_physdev_product;
|
||||||
|
kernel_device_class->get_interface_number = kernel_device_get_interface_number;
|
||||||
kernel_device_class->get_interface_class = kernel_device_get_interface_class;
|
kernel_device_class->get_interface_class = kernel_device_get_interface_class;
|
||||||
kernel_device_class->get_interface_subclass = kernel_device_get_interface_subclass;
|
kernel_device_class->get_interface_subclass = kernel_device_get_interface_subclass;
|
||||||
kernel_device_class->get_interface_protocol = kernel_device_get_interface_protocol;
|
kernel_device_class->get_interface_protocol = kernel_device_get_interface_protocol;
|
||||||
|
@@ -125,6 +125,14 @@ mm_kernel_device_get_physdev_product (MMKernelDevice *self)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
mm_kernel_device_get_interface_number (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_interface_number ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_interface_number (self) :
|
||||||
|
-1);
|
||||||
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
mm_kernel_device_get_interface_class (MMKernelDevice *self)
|
mm_kernel_device_get_interface_class (MMKernelDevice *self)
|
||||||
{
|
{
|
||||||
|
@@ -41,6 +41,7 @@ struct _MMKernelDeviceClass {
|
|||||||
const gchar * (* get_driver) (MMKernelDevice *self);
|
const gchar * (* get_driver) (MMKernelDevice *self);
|
||||||
const gchar * (* get_sysfs_path) (MMKernelDevice *self);
|
const gchar * (* get_sysfs_path) (MMKernelDevice *self);
|
||||||
|
|
||||||
|
gint (* get_interface_number) (MMKernelDevice *self);
|
||||||
gint (* get_interface_class) (MMKernelDevice *self);
|
gint (* get_interface_class) (MMKernelDevice *self);
|
||||||
gint (* get_interface_subclass) (MMKernelDevice *self);
|
gint (* get_interface_subclass) (MMKernelDevice *self);
|
||||||
gint (* get_interface_protocol) (MMKernelDevice *self);
|
gint (* get_interface_protocol) (MMKernelDevice *self);
|
||||||
@@ -74,6 +75,7 @@ const gchar *mm_kernel_device_get_name (MMKernelDevice *self);
|
|||||||
const gchar *mm_kernel_device_get_driver (MMKernelDevice *self);
|
const gchar *mm_kernel_device_get_driver (MMKernelDevice *self);
|
||||||
const gchar *mm_kernel_device_get_sysfs_path (MMKernelDevice *self);
|
const gchar *mm_kernel_device_get_sysfs_path (MMKernelDevice *self);
|
||||||
|
|
||||||
|
gint mm_kernel_device_get_interface_number (MMKernelDevice *self);
|
||||||
gint mm_kernel_device_get_interface_class (MMKernelDevice *self);
|
gint mm_kernel_device_get_interface_class (MMKernelDevice *self);
|
||||||
gint mm_kernel_device_get_interface_subclass (MMKernelDevice *self);
|
gint mm_kernel_device_get_interface_subclass (MMKernelDevice *self);
|
||||||
gint mm_kernel_device_get_interface_protocol (MMKernelDevice *self);
|
gint mm_kernel_device_get_interface_protocol (MMKernelDevice *self);
|
||||||
|
Reference in New Issue
Block a user