core: new kernel device object instead of an explicit GUdevDevice
Instead of relying constantly on GUdevDevice objects reported by GUdev, we now use a new generic object (MMKernelDevice) for which we provide an initial GUdev based backend.
This commit is contained in:
@@ -12,6 +12,7 @@ AM_CFLAGS = \
|
|||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(top_srcdir)/src \
|
-I$(top_srcdir)/src \
|
||||||
-I$(top_builddir)/src \
|
-I$(top_builddir)/src \
|
||||||
|
-I$(top_srcdir)/src/kerneldevice \
|
||||||
-I$(top_srcdir)/include \
|
-I$(top_srcdir)/include \
|
||||||
-I$(top_builddir)/include \
|
-I$(top_builddir)/include \
|
||||||
-I$(top_srcdir)/libmm-glib \
|
-I$(top_srcdir)/libmm-glib \
|
||||||
|
@@ -176,7 +176,7 @@ grab_port (MMPlugin *self,
|
|||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PPP;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PPP;
|
||||||
} else if (g_udev_device_get_property_as_boolean (mm_port_probe_peek_port (probe),
|
} else if (mm_kernel_device_get_property_as_boolean (mm_port_probe_peek_port (probe),
|
||||||
"ID_MM_CINTERION_PORT_TYPE_GPS")) {
|
"ID_MM_CINTERION_PORT_TYPE_GPS")) {
|
||||||
mm_dbg ("(%s/%s)' Port flagged as GPS",
|
mm_dbg ("(%s/%s)' Port flagged as GPS",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
|
@@ -324,9 +324,9 @@ dell_custom_init (MMPortProbe *probe,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CustomInitContext *ctx;
|
CustomInitContext *ctx;
|
||||||
GUdevDevice *udevDevice;
|
MMKernelDevice *port_device;
|
||||||
|
|
||||||
udevDevice = mm_port_probe_peek_port (probe);
|
port_device = mm_port_probe_peek_port (probe);
|
||||||
|
|
||||||
ctx = g_slice_new0 (CustomInitContext);
|
ctx = g_slice_new0 (CustomInitContext);
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (probe),
|
ctx->result = g_simple_async_result_new (G_OBJECT (probe),
|
||||||
@@ -342,7 +342,7 @@ dell_custom_init (MMPortProbe *probe,
|
|||||||
|
|
||||||
/* Dell-branded Telit modems always answer to +GMI
|
/* Dell-branded Telit modems always answer to +GMI
|
||||||
* Avoid +CGMI and ATI sending for minimizing port probing time */
|
* Avoid +CGMI and ATI sending for minimizing port probing time */
|
||||||
if (g_udev_device_get_property_as_boolean (udevDevice, "ID_MM_TELIT_PORTS_TAGGED")) {
|
if (mm_kernel_device_get_property_as_boolean (port_device, "ID_MM_TELIT_PORTS_TAGGED")) {
|
||||||
ctx->cgmi_retries = 0;
|
ctx->cgmi_retries = 0;
|
||||||
ctx->ati_retries = 0;
|
ctx->ati_retries = 0;
|
||||||
}
|
}
|
||||||
|
@@ -52,13 +52,13 @@ grab_port (MMPlugin *self,
|
|||||||
MMPortProbe *probe,
|
MMPortProbe *probe,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
|
|
||||||
port = mm_port_probe_peek_port (probe);
|
port = mm_port_probe_peek_port (probe);
|
||||||
|
|
||||||
/* Look for port type hints */
|
/* Look for port type hints */
|
||||||
if (mm_port_probe_is_at (probe) && g_udev_device_get_property_as_boolean (port, "ID_MM_HAIER_PORT_TYPE_MODEM")) {
|
if (mm_port_probe_is_at (probe) && mm_kernel_device_get_property_as_boolean (port, "ID_MM_HAIER_PORT_TYPE_MODEM")) {
|
||||||
mm_dbg ("HAIER: AT port '%s/%s' flagged as primary",
|
mm_dbg ("HAIER: AT port '%s/%s' flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
|
@@ -229,7 +229,7 @@ try_next_usbif (MMDevice *device)
|
|||||||
if (g_str_equal (mm_port_probe_get_port_subsys (probe), "tty")) {
|
if (g_str_equal (mm_port_probe_get_port_subsys (probe), "tty")) {
|
||||||
gint usbif;
|
gint usbif;
|
||||||
|
|
||||||
usbif = g_udev_device_get_property_as_int (mm_port_probe_peek_port (probe), "ID_USB_INTERFACE_NUM");
|
usbif = mm_kernel_device_get_property_as_int (mm_port_probe_peek_port (probe), "ID_USB_INTERFACE_NUM");
|
||||||
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 &&
|
||||||
@@ -254,7 +254,7 @@ static void
|
|||||||
huawei_custom_init_step (HuaweiCustomInitContext *ctx)
|
huawei_custom_init_step (HuaweiCustomInitContext *ctx)
|
||||||
{
|
{
|
||||||
FirstInterfaceContext *fi_ctx;
|
FirstInterfaceContext *fi_ctx;
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
|
|
||||||
/* If cancelled, end */
|
/* If cancelled, end */
|
||||||
if (g_cancellable_is_cancelled (ctx->cancellable)) {
|
if (g_cancellable_is_cancelled (ctx->cancellable)) {
|
||||||
@@ -292,7 +292,7 @@ huawei_custom_init_step (HuaweiCustomInitContext *ctx)
|
|||||||
|
|
||||||
/* Try to get a port map from the modem */
|
/* Try to get a port map from the modem */
|
||||||
port = mm_port_probe_peek_port (ctx->probe);
|
port = mm_port_probe_peek_port (ctx->probe);
|
||||||
if (!ctx->getportmode_done && !g_udev_device_get_property_as_boolean (port, "ID_MM_HUAWEI_DISABLE_GETPORTMODE")) {
|
if (!ctx->getportmode_done && !mm_kernel_device_get_property_as_boolean (port, "ID_MM_HUAWEI_DISABLE_GETPORTMODE")) {
|
||||||
if (ctx->getportmode_retries == 0) {
|
if (ctx->getportmode_retries == 0) {
|
||||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||||
huawei_custom_init_context_complete_and_free (ctx);
|
huawei_custom_init_context_complete_and_free (ctx);
|
||||||
@@ -390,7 +390,7 @@ huawei_custom_init (MMPortProbe *probe,
|
|||||||
ctx->getportmode_retries = 3;
|
ctx->getportmode_retries = 3;
|
||||||
|
|
||||||
/* Custom init only to be run in the first interface */
|
/* Custom init only to be run in the first interface */
|
||||||
if (g_udev_device_get_property_as_int (mm_port_probe_peek_port (probe),
|
if (mm_kernel_device_get_property_as_int (mm_port_probe_peek_port (probe),
|
||||||
"ID_USB_INTERFACE_NUM") != fi_ctx->first_usbif) {
|
"ID_USB_INTERFACE_NUM") != fi_ctx->first_usbif) {
|
||||||
|
|
||||||
if (fi_ctx->custom_init_run)
|
if (fi_ctx->custom_init_run)
|
||||||
@@ -433,7 +433,7 @@ propagate_port_mode_results (GList *probes)
|
|||||||
MMPortSerialAtFlag at_port_flags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag at_port_flags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
gint usbif;
|
gint usbif;
|
||||||
|
|
||||||
usbif = g_udev_device_get_property_as_int (mm_port_probe_peek_port (MM_PORT_PROBE (l->data)), "ID_USB_INTERFACE_NUM");
|
usbif = mm_kernel_device_get_property_as_int (mm_port_probe_peek_port (MM_PORT_PROBE (l->data)), "ID_USB_INTERFACE_NUM");
|
||||||
|
|
||||||
if (GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (device), TAG_GETPORTMODE_SUPPORTED))) {
|
if (GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (device), TAG_GETPORTMODE_SUPPORTED))) {
|
||||||
if (usbif + 1 == GPOINTER_TO_INT (g_object_get_data (G_OBJECT (device), TAG_HUAWEI_PCUI_PORT))) {
|
if (usbif + 1 == GPOINTER_TO_INT (g_object_get_data (G_OBJECT (device), TAG_HUAWEI_PCUI_PORT))) {
|
||||||
@@ -526,23 +526,23 @@ grab_port (MMPlugin *self,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
MMPortType port_type;
|
MMPortType port_type;
|
||||||
|
|
||||||
port_type = mm_port_probe_get_port_type (probe);
|
port_type = mm_port_probe_get_port_type (probe);
|
||||||
port = mm_port_probe_peek_port (probe);
|
port = mm_port_probe_peek_port (probe);
|
||||||
|
|
||||||
if (g_udev_device_get_property_as_boolean (port, "ID_MM_HUAWEI_AT_PORT")) {
|
if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_HUAWEI_AT_PORT")) {
|
||||||
mm_dbg ("(%s/%s)' Port flagged as primary",
|
mm_dbg ("(%s/%s)' Port flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
||||||
} else if (g_udev_device_get_property_as_boolean (port, "ID_MM_HUAWEI_MODEM_PORT")) {
|
} else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_HUAWEI_MODEM_PORT")) {
|
||||||
mm_dbg ("(%s/%s) Port flagged as PPP",
|
mm_dbg ("(%s/%s) Port flagged as PPP",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PPP;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PPP;
|
||||||
} else if (g_udev_device_get_property_as_boolean (port, "ID_MM_HUAWEI_GPS_PORT")) {
|
} else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_HUAWEI_GPS_PORT")) {
|
||||||
mm_dbg ("(%s/%s) Port flagged as GPS",
|
mm_dbg ("(%s/%s) Port flagged as GPS",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
|
@@ -206,7 +206,7 @@ grab_port (MMPlugin *self,
|
|||||||
MMPortProbe *probe,
|
MMPortProbe *probe,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
MMPortType ptype;
|
MMPortType ptype;
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
|
|
||||||
@@ -217,12 +217,12 @@ grab_port (MMPlugin *self,
|
|||||||
* be the data/primary port on these devices. We have to tag them based on
|
* be the data/primary port on these devices. We have to tag them based on
|
||||||
* what the Windows .INF files say the port layout should be.
|
* what the Windows .INF files say the port layout should be.
|
||||||
*/
|
*/
|
||||||
if (g_udev_device_get_property_as_boolean (port, "ID_MM_LONGCHEER_PORT_TYPE_MODEM")) {
|
if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_LONGCHEER_PORT_TYPE_MODEM")) {
|
||||||
mm_dbg ("longcheer: AT port '%s/%s' flagged as primary",
|
mm_dbg ("longcheer: AT port '%s/%s' flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
||||||
} else if (g_udev_device_get_property_as_boolean (port, "ID_MM_LONGCHEER_PORT_TYPE_AUX")) {
|
} else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_LONGCHEER_PORT_TYPE_AUX")) {
|
||||||
mm_dbg ("longcheer: AT port '%s/%s' flagged as secondary",
|
mm_dbg ("longcheer: AT port '%s/%s' flagged as secondary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
|
@@ -72,13 +72,13 @@ grab_port (MMPlugin *self,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
MMPortType port_type;
|
MMPortType port_type;
|
||||||
|
|
||||||
port_type = mm_port_probe_get_port_type (probe);
|
port_type = mm_port_probe_get_port_type (probe);
|
||||||
port = mm_port_probe_peek_port (probe);
|
port = mm_port_probe_peek_port (probe);
|
||||||
|
|
||||||
if (g_udev_device_get_property_as_boolean (port, "ID_MM_ERICSSON_MBM_GPS_PORT")) {
|
if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_ERICSSON_MBM_GPS_PORT")) {
|
||||||
mm_dbg ("(%s/%s) Port flagged as GPS",
|
mm_dbg ("(%s/%s) Port flagged as GPS",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
|
@@ -56,19 +56,19 @@ grab_port (MMPlugin *self,
|
|||||||
MMPortProbe *probe,
|
MMPortProbe *probe,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
|
|
||||||
port = mm_port_probe_peek_port (probe);
|
port = mm_port_probe_peek_port (probe);
|
||||||
|
|
||||||
if (mm_port_probe_is_at (probe)) {
|
if (mm_port_probe_is_at (probe)) {
|
||||||
/* Get port type from udev */
|
/* Get port type from udev */
|
||||||
if (g_udev_device_get_property_as_boolean (port, "ID_MM_MTK_AT_PORT")) {
|
if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_MTK_AT_PORT")) {
|
||||||
mm_dbg ("MTK: AT port '%s/%s' flagged as secondary",
|
mm_dbg ("MTK: AT port '%s/%s' flagged as secondary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
|
||||||
} else if (g_udev_device_get_property_as_boolean (port, "ID_MM_MTK_MODEM_PORT")) {
|
} else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_MTK_MODEM_PORT")) {
|
||||||
mm_dbg ("MTK: Modem port '%s/%s' flagged as primary",
|
mm_dbg ("MTK: Modem port '%s/%s' flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
|
@@ -63,19 +63,19 @@ grab_port (MMPlugin *self,
|
|||||||
MMPortProbe *probe,
|
MMPortProbe *probe,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
|
|
||||||
port = mm_port_probe_peek_port (probe);
|
port = mm_port_probe_peek_port (probe);
|
||||||
|
|
||||||
/* Look for port type hints */
|
/* Look for port type hints */
|
||||||
if (mm_port_probe_is_at (probe)) {
|
if (mm_port_probe_is_at (probe)) {
|
||||||
if (g_udev_device_get_property_as_boolean (port, "ID_MM_NOKIA_PORT_TYPE_MODEM")) {
|
if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_NOKIA_PORT_TYPE_MODEM")) {
|
||||||
mm_dbg ("Nokia: AT port '%s/%s' flagged as primary",
|
mm_dbg ("Nokia: AT port '%s/%s' flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
||||||
} else if (g_udev_device_get_property_as_boolean (port, "ID_MM_NOKIA_PORT_TYPE_AUX")) {
|
} else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_NOKIA_PORT_TYPE_AUX")) {
|
||||||
mm_dbg ("Nokia: AT port '%s/%s' flagged as secondary",
|
mm_dbg ("Nokia: AT port '%s/%s' flagged as secondary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
|
@@ -56,13 +56,13 @@ hso_custom_init (MMPortProbe *probe,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GUdevDevice *udev_port;
|
MMKernelDevice *kernel_port;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
const gchar *subsys, *sysfs_path;
|
const gchar *subsys, *sysfs_path;
|
||||||
|
|
||||||
subsys = mm_port_probe_get_port_subsys (probe);
|
subsys = mm_port_probe_get_port_subsys (probe);
|
||||||
udev_port = mm_port_probe_peek_port (probe);
|
kernel_port = mm_port_probe_peek_port (probe);
|
||||||
sysfs_path = g_udev_device_get_sysfs_path (udev_port);
|
sysfs_path = mm_kernel_device_get_sysfs_path (kernel_port);
|
||||||
|
|
||||||
if (g_str_equal (subsys, "tty")) {
|
if (g_str_equal (subsys, "tty")) {
|
||||||
gchar *hsotype_path;
|
gchar *hsotype_path;
|
||||||
|
@@ -55,7 +55,7 @@ grab_port (MMPlugin *self,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
gint usbif;
|
gint usbif;
|
||||||
|
|
||||||
/* The Option plugin cannot do anything with non-AT ports */
|
/* The Option plugin cannot do anything with non-AT ports */
|
||||||
@@ -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 = g_udev_device_get_property_as_int (port, "ID_USB_INTERFACE_NUM");
|
usbif = mm_kernel_device_get_property_as_int (port, "ID_USB_INTERFACE_NUM");
|
||||||
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;
|
||||||
|
|
||||||
|
@@ -69,7 +69,7 @@ grab_port (MMPlugin *self,
|
|||||||
MMPortProbe *probe,
|
MMPortProbe *probe,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
MMPortType ptype;
|
MMPortType ptype;
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
|
|
||||||
@@ -81,12 +81,12 @@ grab_port (MMPlugin *self,
|
|||||||
* be the data/primary port on these devices. We have to tag them based on
|
* be the data/primary port on these devices. We have to tag them based on
|
||||||
* what the Windows .INF files say the port layout should be.
|
* what the Windows .INF files say the port layout should be.
|
||||||
*/
|
*/
|
||||||
if (g_udev_device_get_property_as_boolean (port, "ID_MM_SIMTECH_PORT_TYPE_MODEM")) {
|
if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_SIMTECH_PORT_TYPE_MODEM")) {
|
||||||
mm_dbg ("Simtech: AT port '%s/%s' flagged as primary",
|
mm_dbg ("Simtech: AT port '%s/%s' flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
||||||
} else if (g_udev_device_get_property_as_boolean (port, "ID_MM_SIMTECH_PORT_TYPE_AUX")) {
|
} else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_SIMTECH_PORT_TYPE_AUX")) {
|
||||||
mm_dbg ("Simtech: AT port '%s/%s' flagged as secondary",
|
mm_dbg ("Simtech: AT port '%s/%s' flagged as secondary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
@@ -98,7 +98,7 @@ grab_port (MMPlugin *self,
|
|||||||
* to show up with more than two AT-capable ports.
|
* to show up with more than two AT-capable ports.
|
||||||
*/
|
*/
|
||||||
if (pflags == MM_PORT_SERIAL_AT_FLAG_NONE &&
|
if (pflags == MM_PORT_SERIAL_AT_FLAG_NONE &&
|
||||||
g_udev_device_get_property_as_boolean (port, "ID_MM_SIMTECH_TAGGED"))
|
mm_kernel_device_get_property_as_boolean (port, "ID_MM_SIMTECH_TAGGED"))
|
||||||
ptype = MM_PORT_TYPE_IGNORED;
|
ptype = MM_PORT_TYPE_IGNORED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ telit_grab_port (MMPlugin *self,
|
|||||||
MMPortProbe *probe,
|
MMPortProbe *probe,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
MMDevice *device;
|
MMDevice *device;
|
||||||
MMPortType ptype;
|
MMPortType ptype;
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
@@ -48,33 +48,33 @@ telit_grab_port (MMPlugin *self,
|
|||||||
* If no udev rules are found, AT#PORTCFG (if supported) can be used for
|
* If no udev rules are found, AT#PORTCFG (if supported) can be used for
|
||||||
* identifying the port layout
|
* identifying the port layout
|
||||||
*/
|
*/
|
||||||
if (g_udev_device_get_property_as_boolean (port, TAG_TELIT_MODEM_PORT)) {
|
if (mm_kernel_device_get_property_as_boolean (port, TAG_TELIT_MODEM_PORT)) {
|
||||||
mm_dbg ("telit: AT port '%s/%s' flagged as primary",
|
mm_dbg ("telit: AT port '%s/%s' flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
||||||
} else if (g_udev_device_get_property_as_boolean (port, TAG_TELIT_AUX_PORT)) {
|
} else if (mm_kernel_device_get_property_as_boolean (port, TAG_TELIT_AUX_PORT)) {
|
||||||
mm_dbg ("telit: AT port '%s/%s' flagged as secondary",
|
mm_dbg ("telit: AT port '%s/%s' flagged as secondary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
|
||||||
} else if (g_udev_device_get_property_as_boolean (port, TAG_TELIT_NMEA_PORT)) {
|
} else if (mm_kernel_device_get_property_as_boolean (port, TAG_TELIT_NMEA_PORT)) {
|
||||||
mm_dbg ("telit: port '%s/%s' flagged as NMEA",
|
mm_dbg ("telit: port '%s/%s' flagged as NMEA",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
ptype = MM_PORT_TYPE_GPS;
|
ptype = MM_PORT_TYPE_GPS;
|
||||||
} else if (g_object_get_data (G_OBJECT (device), TAG_GETPORTCFG_SUPPORTED) != NULL) {
|
} else if (g_object_get_data (G_OBJECT (device), TAG_GETPORTCFG_SUPPORTED) != NULL) {
|
||||||
if (g_strcmp0 (g_udev_device_get_property (port, "ID_USB_INTERFACE_NUM"), g_object_get_data (G_OBJECT (device), TAG_TELIT_MODEM_PORT)) == 0) {
|
if (g_strcmp0 (mm_kernel_device_get_property (port, "ID_USB_INTERFACE_NUM"), g_object_get_data (G_OBJECT (device), TAG_TELIT_MODEM_PORT)) == 0) {
|
||||||
mm_dbg ("telit: AT port '%s/%s' flagged as primary",
|
mm_dbg ("telit: AT port '%s/%s' flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
||||||
} else if (g_strcmp0 (g_udev_device_get_property (port, "ID_USB_INTERFACE_NUM"), g_object_get_data (G_OBJECT (device), TAG_TELIT_AUX_PORT)) == 0) {
|
} else if (g_strcmp0 (mm_kernel_device_get_property (port, "ID_USB_INTERFACE_NUM"), g_object_get_data (G_OBJECT (device), TAG_TELIT_AUX_PORT)) == 0) {
|
||||||
mm_dbg ("telit: AT port '%s/%s' flagged as secondary",
|
mm_dbg ("telit: AT port '%s/%s' flagged as secondary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
|
||||||
} else if (g_strcmp0 (g_udev_device_get_property (port, "ID_USB_INTERFACE_NUM"), g_object_get_data (G_OBJECT (device), TAG_TELIT_NMEA_PORT)) == 0) {
|
} else if (g_strcmp0 (mm_kernel_device_get_property (port, "ID_USB_INTERFACE_NUM"), g_object_get_data (G_OBJECT (device), TAG_TELIT_NMEA_PORT)) == 0) {
|
||||||
mm_dbg ("telit: port '%s/%s' flagged as NMEA",
|
mm_dbg ("telit: port '%s/%s' flagged as NMEA",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
@@ -245,7 +245,7 @@ telit_custom_init_context_complete_and_free (TelitCustomInitContext *ctx)
|
|||||||
static void
|
static void
|
||||||
telit_custom_init_step (TelitCustomInitContext *ctx)
|
telit_custom_init_step (TelitCustomInitContext *ctx)
|
||||||
{
|
{
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
|
|
||||||
/* If cancelled, end */
|
/* If cancelled, end */
|
||||||
if (g_cancellable_is_cancelled (ctx->cancellable)) {
|
if (g_cancellable_is_cancelled (ctx->cancellable)) {
|
||||||
@@ -259,7 +259,7 @@ telit_custom_init_step (TelitCustomInitContext *ctx)
|
|||||||
*/
|
*/
|
||||||
port = mm_port_probe_peek_port (ctx->probe);
|
port = mm_port_probe_peek_port (ctx->probe);
|
||||||
if (!ctx->getportcfg_done &&
|
if (!ctx->getportcfg_done &&
|
||||||
g_strcmp0 (g_udev_device_get_property (port, "ID_USB_INTERFACE_NUM"), "00") == 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;
|
||||||
@@ -290,11 +290,11 @@ telit_custom_init (MMPortProbe *probe,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MMDevice *device;
|
MMDevice *device;
|
||||||
GUdevDevice *udevDevice;
|
MMKernelDevice *port_device;
|
||||||
TelitCustomInitContext *ctx;
|
TelitCustomInitContext *ctx;
|
||||||
|
|
||||||
device = mm_port_probe_peek_device (probe);
|
device = mm_port_probe_peek_device (probe);
|
||||||
udevDevice = mm_port_probe_peek_port (probe);
|
port_device = mm_port_probe_peek_port (probe);
|
||||||
|
|
||||||
ctx = g_slice_new (TelitCustomInitContext);
|
ctx = g_slice_new (TelitCustomInitContext);
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (probe),
|
ctx->result = g_simple_async_result_new (G_OBJECT (probe),
|
||||||
@@ -308,7 +308,7 @@ telit_custom_init (MMPortProbe *probe,
|
|||||||
ctx->getportcfg_retries = 3;
|
ctx->getportcfg_retries = 3;
|
||||||
|
|
||||||
/* If the device is tagged for supporting #PORTCFG do the custom init */
|
/* If the device is tagged for supporting #PORTCFG do the custom init */
|
||||||
if (g_udev_device_get_property_as_boolean (udevDevice, "ID_MM_TELIT_PORTS_TAGGED")) {
|
if (mm_kernel_device_get_property_as_boolean (port_device, "ID_MM_TELIT_PORTS_TAGGED")) {
|
||||||
telit_custom_init_step (ctx);
|
telit_custom_init_step (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -220,7 +220,7 @@ grab_port (MMPlugin *self,
|
|||||||
MMPortProbe *probe,
|
MMPortProbe *probe,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
MMPortType ptype;
|
MMPortType ptype;
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
|
|
||||||
@@ -232,12 +232,12 @@ grab_port (MMPlugin *self,
|
|||||||
* be the data/primary port on these devices. We have to tag them based on
|
* be the data/primary port on these devices. We have to tag them based on
|
||||||
* what the Windows .INF files say the port layout should be.
|
* what the Windows .INF files say the port layout should be.
|
||||||
*/
|
*/
|
||||||
if (g_udev_device_get_property_as_boolean (port, "ID_MM_X22X_PORT_TYPE_MODEM")) {
|
if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_X22X_PORT_TYPE_MODEM")) {
|
||||||
mm_dbg ("x22x: AT port '%s/%s' flagged as primary",
|
mm_dbg ("x22x: AT port '%s/%s' flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
||||||
} else if (g_udev_device_get_property_as_boolean (port, "ID_MM_X22X_PORT_TYPE_AUX")) {
|
} else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_X22X_PORT_TYPE_AUX")) {
|
||||||
mm_dbg ("x22x: AT port '%s/%s' flagged as secondary",
|
mm_dbg ("x22x: AT port '%s/%s' flagged as secondary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
|
@@ -110,7 +110,7 @@ grab_port (MMPlugin *self,
|
|||||||
MMPortProbe *probe,
|
MMPortProbe *probe,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
|
||||||
MMPortType ptype;
|
MMPortType ptype;
|
||||||
|
|
||||||
@@ -128,12 +128,12 @@ grab_port (MMPlugin *self,
|
|||||||
|
|
||||||
if (mm_port_probe_is_at (probe)) {
|
if (mm_port_probe_is_at (probe)) {
|
||||||
/* Look for port type hints */
|
/* Look for port type hints */
|
||||||
if (g_udev_device_get_property_as_boolean (port, "ID_MM_ZTE_PORT_TYPE_MODEM")) {
|
if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_ZTE_PORT_TYPE_MODEM")) {
|
||||||
mm_dbg ("ZTE: AT port '%s/%s' flagged as primary",
|
mm_dbg ("ZTE: AT port '%s/%s' flagged as primary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
||||||
} else if (g_udev_device_get_property_as_boolean (port, "ID_MM_ZTE_PORT_TYPE_AUX")) {
|
} else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_ZTE_PORT_TYPE_AUX")) {
|
||||||
mm_dbg ("ZTE: AT port '%s/%s' flagged as secondary",
|
mm_dbg ("ZTE: AT port '%s/%s' flagged as secondary",
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
mm_port_probe_get_port_name (probe));
|
mm_port_probe_get_port_name (probe));
|
||||||
@@ -141,7 +141,7 @@ grab_port (MMPlugin *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_udev_device_get_property_as_boolean (port, "ID_MM_ZTE_ICERA_DHCP")) {
|
if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_ZTE_ICERA_DHCP")) {
|
||||||
mm_dbg ("ZTE: Icera-based modem will use DHCP");
|
mm_dbg ("ZTE: Icera-based modem will use DHCP");
|
||||||
g_object_set (modem,
|
g_object_set (modem,
|
||||||
MM_BROADBAND_MODEM_ICERA_DEFAULT_IP_METHOD, MM_BEARER_IP_METHOD_DHCP,
|
MM_BROADBAND_MODEM_ICERA_DEFAULT_IP_METHOD, MM_BEARER_IP_METHOD_DHCP,
|
||||||
|
@@ -22,6 +22,7 @@ AM_CFLAGS = \
|
|||||||
-I$(top_srcdir)/libmm-glib \
|
-I$(top_srcdir)/libmm-glib \
|
||||||
-I${top_builddir}/libmm-glib/generated \
|
-I${top_builddir}/libmm-glib/generated \
|
||||||
-I${top_builddir}/libmm-glib/generated/tests \
|
-I${top_builddir}/libmm-glib/generated/tests \
|
||||||
|
-I$(srcdir)/kerneldevice \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
AM_LDFLAGS = \
|
AM_LDFLAGS = \
|
||||||
@@ -95,6 +96,19 @@ libhelpers_la_SOURCES += \
|
|||||||
$(NULL)
|
$(NULL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# kerneldevice library
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
noinst_LTLIBRARIES += libkerneldevice.la
|
||||||
|
|
||||||
|
libkerneldevice_la_SOURCES = \
|
||||||
|
kerneldevice/mm-kernel-device.h \
|
||||||
|
kerneldevice/mm-kernel-device.c \
|
||||||
|
kerneldevice/mm-kernel-device-udev.h \
|
||||||
|
kerneldevice/mm-kernel-device-udev.c \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# ports library
|
# ports library
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -208,6 +222,7 @@ ModemManager_LDADD = \
|
|||||||
$(top_builddir)/libmm-glib/generated/tests/libmm-test-generated.la \
|
$(top_builddir)/libmm-glib/generated/tests/libmm-test-generated.la \
|
||||||
$(builddir)/libhelpers.la \
|
$(builddir)/libhelpers.la \
|
||||||
$(builddir)/libport.la \
|
$(builddir)/libport.la \
|
||||||
|
$(builddir)/libkerneldevice.la \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
ModemManager_SOURCES = \
|
ModemManager_SOURCES = \
|
||||||
|
623
src/kerneldevice/mm-kernel-device-udev.c
Normal file
623
src/kerneldevice/mm-kernel-device-udev.c
Normal file
@@ -0,0 +1,623 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Velocloud, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define _LIBMM_INSIDE_MM
|
||||||
|
#include <libmm-glib.h>
|
||||||
|
|
||||||
|
#include "mm-kernel-device-udev.h"
|
||||||
|
#include "mm-log.h"
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (MMKernelDeviceUdev, mm_kernel_device_udev, MM_TYPE_KERNEL_DEVICE)
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_UDEV_DEVICE,
|
||||||
|
PROP_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
static GParamSpec *properties[PROP_LAST];
|
||||||
|
|
||||||
|
struct _MMKernelDeviceUdevPrivate {
|
||||||
|
GUdevDevice *device;
|
||||||
|
GUdevDevice *parent;
|
||||||
|
GUdevDevice *physdev;
|
||||||
|
guint16 vendor;
|
||||||
|
guint16 product;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
get_device_ids (GUdevDevice *device,
|
||||||
|
guint16 *vendor,
|
||||||
|
guint16 *product)
|
||||||
|
{
|
||||||
|
GUdevDevice *parent = NULL;
|
||||||
|
const gchar *vid = NULL, *pid = NULL, *parent_subsys;
|
||||||
|
gboolean success = FALSE;
|
||||||
|
char *pci_vid = NULL, *pci_pid = NULL;
|
||||||
|
|
||||||
|
parent = g_udev_device_get_parent (device);
|
||||||
|
if (parent) {
|
||||||
|
parent_subsys = g_udev_device_get_subsystem (parent);
|
||||||
|
if (parent_subsys) {
|
||||||
|
if (g_str_equal (parent_subsys, "bluetooth")) {
|
||||||
|
/* Bluetooth devices report the VID/PID of the BT adapter here,
|
||||||
|
* which isn't really what we want. Just return null IDs instead.
|
||||||
|
*/
|
||||||
|
success = TRUE;
|
||||||
|
goto out;
|
||||||
|
} else if (g_str_equal (parent_subsys, "pcmcia")) {
|
||||||
|
/* For PCMCIA devices we need to grab the PCMCIA subsystem's
|
||||||
|
* manfid and cardid, since any IDs on the tty device itself
|
||||||
|
* may be from PCMCIA controller or something else.
|
||||||
|
*/
|
||||||
|
vid = g_udev_device_get_sysfs_attr (parent, "manf_id");
|
||||||
|
pid = g_udev_device_get_sysfs_attr (parent, "card_id");
|
||||||
|
if (!vid || !pid)
|
||||||
|
goto out;
|
||||||
|
} else if (g_str_equal (parent_subsys, "platform")) {
|
||||||
|
/* Platform devices don't usually have a VID/PID */
|
||||||
|
success = TRUE;
|
||||||
|
goto out;
|
||||||
|
} else if (g_str_has_prefix (parent_subsys, "usb") &&
|
||||||
|
(!g_strcmp0 (g_udev_device_get_driver (parent), "qmi_wwan") ||
|
||||||
|
!g_strcmp0 (g_udev_device_get_driver (parent), "cdc_mbim"))) {
|
||||||
|
/* Need to look for vendor/product in the parent of the QMI/MBIM device */
|
||||||
|
GUdevDevice *qmi_parent;
|
||||||
|
|
||||||
|
qmi_parent = g_udev_device_get_parent (parent);
|
||||||
|
if (qmi_parent) {
|
||||||
|
vid = g_udev_device_get_property (qmi_parent, "ID_VENDOR_ID");
|
||||||
|
pid = g_udev_device_get_property (qmi_parent, "ID_MODEL_ID");
|
||||||
|
g_object_unref (qmi_parent);
|
||||||
|
}
|
||||||
|
} else if (g_str_equal (parent_subsys, "pci")) {
|
||||||
|
const char *pci_id;
|
||||||
|
|
||||||
|
/* We can't always rely on the model + vendor showing up on
|
||||||
|
* the PCI device's child, so look at the PCI parent. PCI_ID
|
||||||
|
* has the format "1931:000C".
|
||||||
|
*/
|
||||||
|
pci_id = g_udev_device_get_property (parent, "PCI_ID");
|
||||||
|
if (pci_id && strlen (pci_id) == 9 && pci_id[4] == ':') {
|
||||||
|
vid = pci_vid = g_strdup (pci_id);
|
||||||
|
pci_vid[4] = '\0';
|
||||||
|
pid = pci_pid = g_strdup (pci_id + 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vid)
|
||||||
|
vid = g_udev_device_get_property (device, "ID_VENDOR_ID");
|
||||||
|
if (!vid)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (strncmp (vid, "0x", 2) == 0)
|
||||||
|
vid += 2;
|
||||||
|
if (strlen (vid) != 4)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (vendor) {
|
||||||
|
*vendor = (guint16) (mm_utils_hex2byte (vid + 2) & 0xFF);
|
||||||
|
*vendor |= (guint16) ((mm_utils_hex2byte (vid) & 0xFF) << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pid)
|
||||||
|
pid = g_udev_device_get_property (device, "ID_MODEL_ID");
|
||||||
|
if (!pid) {
|
||||||
|
*vendor = 0;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strncmp (pid, "0x", 2) == 0)
|
||||||
|
pid += 2;
|
||||||
|
if (strlen (pid) != 4) {
|
||||||
|
*vendor = 0;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (product) {
|
||||||
|
*product = (guint16) (mm_utils_hex2byte (pid + 2) & 0xFF);
|
||||||
|
*product |= (guint16) ((mm_utils_hex2byte (pid) & 0xFF) << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
success = TRUE;
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (parent)
|
||||||
|
g_object_unref (parent);
|
||||||
|
g_free (pci_vid);
|
||||||
|
g_free (pci_pid);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ensure_device_ids (MMKernelDeviceUdev *self)
|
||||||
|
{
|
||||||
|
if (self->priv->vendor || self->priv->product)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!get_device_ids (self->priv->device, &self->priv->vendor, &self->priv->product))
|
||||||
|
mm_dbg ("(%s/%s) could not get vendor/product ID",
|
||||||
|
g_udev_device_get_subsystem (self->priv->device),
|
||||||
|
g_udev_device_get_name (self->priv->device));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static GUdevDevice *
|
||||||
|
find_physical_gudevdevice (GUdevDevice *child)
|
||||||
|
{
|
||||||
|
GUdevDevice *iter, *old = NULL;
|
||||||
|
GUdevDevice *physdev = NULL;
|
||||||
|
const char *subsys, *type, *name;
|
||||||
|
guint32 i = 0;
|
||||||
|
gboolean is_usb = FALSE, is_pci = FALSE, is_pcmcia = FALSE, is_platform = FALSE;
|
||||||
|
gboolean is_pnp = FALSE;
|
||||||
|
|
||||||
|
g_return_val_if_fail (child != NULL, NULL);
|
||||||
|
|
||||||
|
/* Bluetooth rfcomm devices are "virtual" and don't necessarily have
|
||||||
|
* parents at all.
|
||||||
|
*/
|
||||||
|
name = g_udev_device_get_name (child);
|
||||||
|
if (name && strncmp (name, "rfcomm", 6) == 0)
|
||||||
|
return g_object_ref (child);
|
||||||
|
|
||||||
|
iter = g_object_ref (child);
|
||||||
|
while (iter && i++ < 8) {
|
||||||
|
subsys = g_udev_device_get_subsystem (iter);
|
||||||
|
if (subsys) {
|
||||||
|
if (is_usb || g_str_has_prefix (subsys, "usb")) {
|
||||||
|
is_usb = TRUE;
|
||||||
|
type = g_udev_device_get_devtype (iter);
|
||||||
|
if (type && !strcmp (type, "usb_device")) {
|
||||||
|
physdev = iter;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (is_pcmcia || !strcmp (subsys, "pcmcia")) {
|
||||||
|
GUdevDevice *pcmcia_parent;
|
||||||
|
const char *tmp_subsys;
|
||||||
|
|
||||||
|
is_pcmcia = TRUE;
|
||||||
|
|
||||||
|
/* If the parent of this PCMCIA device is no longer part of
|
||||||
|
* the PCMCIA subsystem, we want to stop since we're looking
|
||||||
|
* for the base PCMCIA device, not the PCMCIA controller which
|
||||||
|
* is usually PCI or some other bus type.
|
||||||
|
*/
|
||||||
|
pcmcia_parent = g_udev_device_get_parent (iter);
|
||||||
|
if (pcmcia_parent) {
|
||||||
|
tmp_subsys = g_udev_device_get_subsystem (pcmcia_parent);
|
||||||
|
if (tmp_subsys && strcmp (tmp_subsys, "pcmcia"))
|
||||||
|
physdev = iter;
|
||||||
|
g_object_unref (pcmcia_parent);
|
||||||
|
if (physdev)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (is_platform || !strcmp (subsys, "platform")) {
|
||||||
|
/* Take the first platform parent as the physical device */
|
||||||
|
is_platform = TRUE;
|
||||||
|
physdev = iter;
|
||||||
|
break;
|
||||||
|
} else if (is_pci || !strcmp (subsys, "pci")) {
|
||||||
|
is_pci = TRUE;
|
||||||
|
physdev = iter;
|
||||||
|
break;
|
||||||
|
} else if (is_pnp || !strcmp (subsys, "pnp")) {
|
||||||
|
is_pnp = TRUE;
|
||||||
|
physdev = iter;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
old = iter;
|
||||||
|
iter = g_udev_device_get_parent (old);
|
||||||
|
g_object_unref (old);
|
||||||
|
}
|
||||||
|
|
||||||
|
return physdev;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ensure_physdev (MMKernelDeviceUdev *self)
|
||||||
|
{
|
||||||
|
if (self->priv->physdev)
|
||||||
|
return;
|
||||||
|
self->priv->physdev = find_physical_gudevdevice (self->priv->device);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
kernel_device_get_subsystem (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (self), NULL);
|
||||||
|
|
||||||
|
return g_udev_device_get_subsystem (MM_KERNEL_DEVICE_UDEV (self)->priv->device);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
kernel_device_get_name (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (self), NULL);
|
||||||
|
|
||||||
|
return g_udev_device_get_name (MM_KERNEL_DEVICE_UDEV (self)->priv->device);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
kernel_device_get_driver (MMKernelDevice *_self)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
const gchar *driver, *subsys, *name;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), NULL);
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
|
||||||
|
driver = g_udev_device_get_driver (self->priv->device);
|
||||||
|
if (!driver) {
|
||||||
|
GUdevDevice *parent;
|
||||||
|
|
||||||
|
parent = g_udev_device_get_parent (self->priv->device);
|
||||||
|
if (parent)
|
||||||
|
driver = g_udev_device_get_driver (parent);
|
||||||
|
|
||||||
|
/* Check for bluetooth; it's driver is a bunch of levels up so we
|
||||||
|
* just check for the subsystem of the parent being bluetooth.
|
||||||
|
*/
|
||||||
|
if (!driver && parent) {
|
||||||
|
subsys = g_udev_device_get_subsystem (parent);
|
||||||
|
if (subsys && !strcmp (subsys, "bluetooth"))
|
||||||
|
driver = "bluetooth";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent)
|
||||||
|
g_object_unref (parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Newer kernels don't set up the rfcomm port parent in sysfs,
|
||||||
|
* so we must infer it from the device name.
|
||||||
|
*/
|
||||||
|
name = g_udev_device_get_name (self->priv->device);
|
||||||
|
if (!driver && strncmp (name, "rfcomm", 6) == 0)
|
||||||
|
driver = "bluetooth";
|
||||||
|
|
||||||
|
/* Note: may return NULL! */
|
||||||
|
return driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
kernel_device_get_sysfs_path (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), NULL);
|
||||||
|
|
||||||
|
return g_udev_device_get_sysfs_path (MM_KERNEL_DEVICE_UDEV (self)->priv->device);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
kernel_device_get_physdev_uid (MMKernelDevice *_self)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
const gchar *uid = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), NULL);
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
ensure_physdev (self);
|
||||||
|
|
||||||
|
if (!self->priv->physdev)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
uid = g_udev_device_get_property (self->priv->physdev, "ID_MM_PHYSDEV_UID");
|
||||||
|
if (!uid)
|
||||||
|
uid = g_udev_device_get_sysfs_path (self->priv->physdev);
|
||||||
|
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
static guint16
|
||||||
|
kernel_device_get_physdev_vid (MMKernelDevice *_self)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), 0);
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
ensure_device_ids (self);
|
||||||
|
return self->priv->vendor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static guint16
|
||||||
|
kernel_device_get_physdev_pid (MMKernelDevice *_self)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), 0);
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
ensure_device_ids (self);
|
||||||
|
return self->priv->product;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
kernel_device_get_parent_sysfs_path (MMKernelDevice *_self)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), 0);
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
if (!self->priv->parent)
|
||||||
|
self->priv->parent = g_udev_device_get_parent (self->priv->device);
|
||||||
|
return (self->priv->parent ? g_udev_device_get_sysfs_path (self->priv->parent) : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
kernel_device_is_candidate (MMKernelDevice *_self,
|
||||||
|
gboolean manual_scan)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
const gchar *physdev_subsys;
|
||||||
|
const gchar *name;
|
||||||
|
const gchar *subsys;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), FALSE);
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
|
||||||
|
name = g_udev_device_get_name (self->priv->device);
|
||||||
|
subsys = g_udev_device_get_subsystem (self->priv->device);
|
||||||
|
|
||||||
|
/* ignore VTs */
|
||||||
|
if (strncmp (name, "tty", 3) == 0 && g_ascii_isdigit (name[3]))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Ignore devices that aren't completely configured by udev yet. If
|
||||||
|
* ModemManager is started in parallel with udev, explicitly requesting
|
||||||
|
* devices may return devices for which not all udev rules have yet been
|
||||||
|
* applied (a bug in udev/gudev). Since we often need those rules to match
|
||||||
|
* the device to a specific ModemManager driver, we need to ensure that all
|
||||||
|
* rules have been processed before handling a device.
|
||||||
|
*
|
||||||
|
* The udev tag applies to each port in a device. In other words, the flag
|
||||||
|
* may be set in some ports, but not in others */
|
||||||
|
if (!g_udev_device_get_property_as_boolean (self->priv->device, "ID_MM_CANDIDATE"))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Load physical device. If there is no physical device, we don't process
|
||||||
|
* the device. */
|
||||||
|
ensure_physdev (self);
|
||||||
|
if (!self->priv->physdev) {
|
||||||
|
/* Log about it, but filter out some common ports that we know don't have
|
||||||
|
* anything to do with mobile broadband.
|
||||||
|
*/
|
||||||
|
if ( strcmp (name, "console")
|
||||||
|
&& strcmp (name, "ptmx")
|
||||||
|
&& strcmp (name, "lo")
|
||||||
|
&& strcmp (name, "tty")
|
||||||
|
&& !strstr (name, "virbr"))
|
||||||
|
mm_dbg ("(%s/%s): could not get port's parent device", subsys, name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The blacklist applies to the device as a whole, and therefore the flag
|
||||||
|
* will be applied always in the physical device, not in each port. */
|
||||||
|
if (g_udev_device_get_property_as_boolean (self->priv->physdev, "ID_MM_DEVICE_IGNORE")) {
|
||||||
|
mm_dbg ("(%s/%s): device is blacklisted", subsys, name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Is the device in the manual-only greylist? If so, return if this is an
|
||||||
|
* automatic scan. */
|
||||||
|
if (!manual_scan && g_udev_device_get_property_as_boolean (self->priv->physdev, "ID_MM_DEVICE_MANUAL_SCAN_ONLY")) {
|
||||||
|
mm_dbg ("(%s/%s): device probed only in manual scan", subsys, name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the physdev is a 'platform' or 'pnp' device that's not whitelisted, ignore it */
|
||||||
|
physdev_subsys = g_udev_device_get_subsystem (self->priv->physdev);
|
||||||
|
if ((!g_strcmp0 (physdev_subsys, "platform") || !g_strcmp0 (physdev_subsys, "pnp")) &&
|
||||||
|
(!g_udev_device_get_property_as_boolean (self->priv->physdev, "ID_MM_PLATFORM_DRIVER_PROBE"))) {
|
||||||
|
mm_dbg ("(%s/%s): port's parent platform driver is not whitelisted", subsys, name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
kernel_device_cmp (MMKernelDevice *_a,
|
||||||
|
MMKernelDevice *_b)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *a;
|
||||||
|
MMKernelDeviceUdev *b;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_a), FALSE);
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_b), FALSE);
|
||||||
|
|
||||||
|
a = MM_KERNEL_DEVICE_UDEV (_a);
|
||||||
|
b = MM_KERNEL_DEVICE_UDEV (_b);
|
||||||
|
|
||||||
|
if (g_udev_device_has_property (a->priv->device, "DEVPATH_OLD") &&
|
||||||
|
g_str_has_suffix (g_udev_device_get_sysfs_path (b->priv->device),
|
||||||
|
g_udev_device_get_property (a->priv->device, "DEVPATH_OLD")))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
if (g_udev_device_has_property (b->priv->device, "DEVPATH_OLD") &&
|
||||||
|
g_str_has_suffix (g_udev_device_get_sysfs_path (a->priv->device),
|
||||||
|
g_udev_device_get_property (b->priv->device, "DEVPATH_OLD")))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return !g_strcmp0 (g_udev_device_get_sysfs_path (a->priv->device), g_udev_device_get_sysfs_path (b->priv->device));
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
kernel_device_has_property (MMKernelDevice *_self,
|
||||||
|
const gchar *property)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), FALSE);
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
return g_udev_device_has_property (self->priv->device, property);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
kernel_device_get_property (MMKernelDevice *_self,
|
||||||
|
const gchar *property)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), NULL);
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
return g_udev_device_get_property (self->priv->device, property);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
kernel_device_get_property_as_boolean (MMKernelDevice *_self,
|
||||||
|
const gchar *property)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), FALSE);
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
return g_udev_device_get_property_as_boolean (self->priv->device, property);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
kernel_device_get_property_as_int (MMKernelDevice *_self,
|
||||||
|
const gchar *property)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), -1);
|
||||||
|
|
||||||
|
self = MM_KERNEL_DEVICE_UDEV (_self);
|
||||||
|
return g_udev_device_get_property_as_int (self->priv->device, property);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
MMKernelDevice *
|
||||||
|
mm_kernel_device_udev_new (GUdevDevice *udev_device)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (G_UDEV_IS_DEVICE (udev_device), NULL);
|
||||||
|
|
||||||
|
return MM_KERNEL_DEVICE (g_object_new (MM_TYPE_KERNEL_DEVICE_UDEV,
|
||||||
|
"udev-device", udev_device,
|
||||||
|
NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_kernel_device_udev_init (MMKernelDeviceUdev *self)
|
||||||
|
{
|
||||||
|
/* Initialize private data */
|
||||||
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_KERNEL_DEVICE_UDEV, MMKernelDeviceUdevPrivate);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self = MM_KERNEL_DEVICE_UDEV (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_UDEV_DEVICE:
|
||||||
|
g_assert (!self->priv->device);
|
||||||
|
self->priv->device = g_value_dup_object (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self = MM_KERNEL_DEVICE_UDEV (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_UDEV_DEVICE:
|
||||||
|
g_value_set_object (value, self->priv->device);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dispose (GObject *object)
|
||||||
|
{
|
||||||
|
MMKernelDeviceUdev *self = MM_KERNEL_DEVICE_UDEV (object);
|
||||||
|
|
||||||
|
g_clear_object (&self->priv->physdev);
|
||||||
|
g_clear_object (&self->priv->parent);
|
||||||
|
g_clear_object (&self->priv->device);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (mm_kernel_device_udev_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_kernel_device_udev_class_init (MMKernelDeviceUdevClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
MMKernelDeviceClass *kernel_device_class = MM_KERNEL_DEVICE_CLASS (klass);
|
||||||
|
|
||||||
|
g_type_class_add_private (object_class, sizeof (MMKernelDeviceUdevPrivate));
|
||||||
|
|
||||||
|
object_class->dispose = dispose;
|
||||||
|
object_class->get_property = get_property;
|
||||||
|
object_class->set_property = set_property;
|
||||||
|
|
||||||
|
kernel_device_class->get_subsystem = kernel_device_get_subsystem;
|
||||||
|
kernel_device_class->get_name = kernel_device_get_name;
|
||||||
|
kernel_device_class->get_driver = kernel_device_get_driver;
|
||||||
|
kernel_device_class->get_sysfs_path = kernel_device_get_sysfs_path;
|
||||||
|
kernel_device_class->get_physdev_uid = kernel_device_get_physdev_uid;
|
||||||
|
kernel_device_class->get_physdev_vid = kernel_device_get_physdev_vid;
|
||||||
|
kernel_device_class->get_physdev_pid = kernel_device_get_physdev_pid;
|
||||||
|
kernel_device_class->get_parent_sysfs_path = kernel_device_get_parent_sysfs_path;
|
||||||
|
kernel_device_class->is_candidate = kernel_device_is_candidate;
|
||||||
|
kernel_device_class->cmp = kernel_device_cmp;
|
||||||
|
kernel_device_class->has_property = kernel_device_has_property;
|
||||||
|
kernel_device_class->get_property = kernel_device_get_property;
|
||||||
|
kernel_device_class->get_property_as_boolean = kernel_device_get_property_as_boolean;
|
||||||
|
kernel_device_class->get_property_as_int = kernel_device_get_property_as_int;
|
||||||
|
|
||||||
|
properties[PROP_UDEV_DEVICE] =
|
||||||
|
g_param_spec_object ("udev-device",
|
||||||
|
"udev device",
|
||||||
|
"Device object as reported by GUdev",
|
||||||
|
G_UDEV_TYPE_DEVICE,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||||
|
g_object_class_install_property (object_class, PROP_UDEV_DEVICE, properties[PROP_UDEV_DEVICE]);
|
||||||
|
}
|
48
src/kerneldevice/mm-kernel-device-udev.h
Normal file
48
src/kerneldevice/mm-kernel-device-udev.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Velocloud, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MM_KERNEL_DEVICE_UDEV_H
|
||||||
|
#define MM_KERNEL_DEVICE_UDEV_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <gudev/gudev.h>
|
||||||
|
|
||||||
|
#include "mm-kernel-device.h"
|
||||||
|
|
||||||
|
#define MM_TYPE_KERNEL_DEVICE_UDEV (mm_kernel_device_udev_get_type ())
|
||||||
|
#define MM_KERNEL_DEVICE_UDEV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_KERNEL_DEVICE_UDEV, MMKernelDeviceUdev))
|
||||||
|
#define MM_KERNEL_DEVICE_UDEV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_KERNEL_DEVICE_UDEV, MMKernelDeviceUdevClass))
|
||||||
|
#define MM_IS_KERNEL_DEVICE_UDEV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_KERNEL_DEVICE_UDEV))
|
||||||
|
#define MM_IS_KERNEL_DEVICE_UDEV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_KERNEL_DEVICE_UDEV))
|
||||||
|
#define MM_KERNEL_DEVICE_UDEV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_KERNEL_DEVICE_UDEV, MMKernelDeviceUdevClass))
|
||||||
|
|
||||||
|
typedef struct _MMKernelDeviceUdev MMKernelDeviceUdev;
|
||||||
|
typedef struct _MMKernelDeviceUdevClass MMKernelDeviceUdevClass;
|
||||||
|
typedef struct _MMKernelDeviceUdevPrivate MMKernelDeviceUdevPrivate;
|
||||||
|
|
||||||
|
struct _MMKernelDeviceUdev {
|
||||||
|
MMKernelDevice parent;
|
||||||
|
MMKernelDeviceUdevPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MMKernelDeviceUdevClass {
|
||||||
|
MMKernelDeviceClass parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType mm_kernel_device_udev_get_type (void);
|
||||||
|
MMKernelDevice *mm_kernel_device_udev_new (GUdevDevice *udev_device);
|
||||||
|
|
||||||
|
#endif /* MM_KERNEL_DEVICE_UDEV_H */
|
179
src/kerneldevice/mm-kernel-device.c
Normal file
179
src/kerneldevice/mm-kernel-device.c
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Velocloud, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mm-kernel-device.h"
|
||||||
|
|
||||||
|
G_DEFINE_ABSTRACT_TYPE (MMKernelDevice, mm_kernel_device, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
mm_kernel_device_get_subsystem (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), NULL);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_subsystem ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_subsystem (self) :
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
mm_kernel_device_get_name (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), NULL);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_name ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_name (self) :
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
mm_kernel_device_get_driver (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), NULL);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_driver ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_driver (self) :
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
mm_kernel_device_get_sysfs_path (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), NULL);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_sysfs_path ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_sysfs_path (self) :
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
mm_kernel_device_get_physdev_uid (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), NULL);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_physdev_uid ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_physdev_uid (self) :
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
guint16
|
||||||
|
mm_kernel_device_get_physdev_vid (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), 0);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_physdev_vid ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_physdev_vid (self) :
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
|
guint16
|
||||||
|
mm_kernel_device_get_physdev_pid (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), 0);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_physdev_pid ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_physdev_pid (self) :
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
mm_kernel_device_is_candidate (MMKernelDevice *self,
|
||||||
|
gboolean manual_scan)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), FALSE);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->is_candidate ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->is_candidate (self, manual_scan) :
|
||||||
|
FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
mm_kernel_device_get_parent_sysfs_path (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), NULL);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_parent_sysfs_path ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_parent_sysfs_path (self) :
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
mm_kernel_device_cmp (MMKernelDevice *a,
|
||||||
|
MMKernelDevice *b)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (a), FALSE);
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (b), FALSE);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (a)->cmp ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (a)->cmp (a, b) :
|
||||||
|
FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
mm_kernel_device_has_property (MMKernelDevice *self,
|
||||||
|
const gchar *property)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), FALSE);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->has_property ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->has_property (self, property) :
|
||||||
|
FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
mm_kernel_device_get_property (MMKernelDevice *self,
|
||||||
|
const gchar *property)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), NULL);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_property ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_property (self, property) :
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
mm_kernel_device_get_property_as_boolean (MMKernelDevice *self,
|
||||||
|
const gchar *property)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), FALSE);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_property_as_boolean ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_property_as_boolean (self, property) :
|
||||||
|
FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
mm_kernel_device_get_property_as_int (MMKernelDevice *self,
|
||||||
|
const gchar *property)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), -1);
|
||||||
|
|
||||||
|
return (MM_KERNEL_DEVICE_GET_CLASS (self)->get_property_as_int ?
|
||||||
|
MM_KERNEL_DEVICE_GET_CLASS (self)->get_property_as_int (self, property) :
|
||||||
|
-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_kernel_device_init (MMKernelDevice *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_kernel_device_class_init (MMKernelDeviceClass *klass)
|
||||||
|
{
|
||||||
|
}
|
89
src/kerneldevice/mm-kernel-device.h
Normal file
89
src/kerneldevice/mm-kernel-device.h
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Velocloud, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MM_KERNEL_DEVICE_H
|
||||||
|
#define MM_KERNEL_DEVICE_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#define MM_TYPE_KERNEL_DEVICE (mm_kernel_device_get_type ())
|
||||||
|
#define MM_KERNEL_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_KERNEL_DEVICE, MMKernelDevice))
|
||||||
|
#define MM_KERNEL_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_KERNEL_DEVICE, MMKernelDeviceClass))
|
||||||
|
#define MM_IS_KERNEL_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_KERNEL_DEVICE))
|
||||||
|
#define MM_IS_KERNEL_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_KERNEL_DEVICE))
|
||||||
|
#define MM_KERNEL_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_KERNEL_DEVICE, MMKernelDeviceClass))
|
||||||
|
|
||||||
|
typedef struct _MMKernelDevice MMKernelDevice;
|
||||||
|
typedef struct _MMKernelDeviceClass MMKernelDeviceClass;
|
||||||
|
|
||||||
|
struct _MMKernelDevice {
|
||||||
|
GObject parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MMKernelDeviceClass {
|
||||||
|
GObjectClass parent;
|
||||||
|
|
||||||
|
const gchar * (* get_subsystem) (MMKernelDevice *self);
|
||||||
|
|
||||||
|
const gchar * (* get_name) (MMKernelDevice *self);
|
||||||
|
|
||||||
|
const gchar * (* get_driver) (MMKernelDevice *self);
|
||||||
|
|
||||||
|
const gchar * (* get_sysfs_path) (MMKernelDevice *self);
|
||||||
|
|
||||||
|
gboolean (* is_candidate) (MMKernelDevice *self,
|
||||||
|
gboolean manual_scan);
|
||||||
|
|
||||||
|
const gchar * (* get_parent_sysfs_path) (MMKernelDevice *self);
|
||||||
|
|
||||||
|
const gchar * (* get_physdev_uid) (MMKernelDevice *self);
|
||||||
|
|
||||||
|
guint16 (* get_physdev_vid) (MMKernelDevice *self);
|
||||||
|
|
||||||
|
guint16 (* get_physdev_pid) (MMKernelDevice *self);
|
||||||
|
|
||||||
|
gboolean (* cmp) (MMKernelDevice *a, MMKernelDevice *b);
|
||||||
|
|
||||||
|
gboolean (* has_property) (MMKernelDevice *self, const gchar *property);
|
||||||
|
const gchar * (* get_property) (MMKernelDevice *self, const gchar *property);
|
||||||
|
gboolean (* get_property_as_boolean) (MMKernelDevice *self, const gchar *property);
|
||||||
|
gint (* get_property_as_int) (MMKernelDevice *self, const gchar *property);
|
||||||
|
};
|
||||||
|
|
||||||
|
GType mm_kernel_device_get_type (void);
|
||||||
|
|
||||||
|
const gchar *mm_kernel_device_get_subsystem (MMKernelDevice *self);
|
||||||
|
const gchar *mm_kernel_device_get_name (MMKernelDevice *self);
|
||||||
|
const gchar *mm_kernel_device_get_driver (MMKernelDevice *self);
|
||||||
|
const gchar *mm_kernel_device_get_sysfs_path (MMKernelDevice *self);
|
||||||
|
|
||||||
|
gboolean mm_kernel_device_is_candidate (MMKernelDevice *self,
|
||||||
|
gboolean manual_scan);
|
||||||
|
|
||||||
|
const gchar *mm_kernel_device_get_parent_sysfs_path (MMKernelDevice *self);
|
||||||
|
|
||||||
|
const gchar *mm_kernel_device_get_physdev_uid (MMKernelDevice *self);
|
||||||
|
guint16 mm_kernel_device_get_physdev_vid (MMKernelDevice *self);
|
||||||
|
guint16 mm_kernel_device_get_physdev_pid (MMKernelDevice *self);
|
||||||
|
|
||||||
|
gboolean mm_kernel_device_cmp (MMKernelDevice *a, MMKernelDevice *b);
|
||||||
|
|
||||||
|
gboolean mm_kernel_device_has_property (MMKernelDevice *self, const gchar *property);
|
||||||
|
const gchar *mm_kernel_device_get_property (MMKernelDevice *self, const gchar *property);
|
||||||
|
gboolean mm_kernel_device_get_property_as_boolean (MMKernelDevice *self, const gchar *property);
|
||||||
|
gint mm_kernel_device_get_property_as_int (MMKernelDevice *self, const gchar *property);
|
||||||
|
|
||||||
|
#endif /* MM_KERNEL_DEVICE_H */
|
@@ -12,15 +12,16 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||||
* Copyright (C) 2009 - 2012 Red Hat, Inc.
|
* Copyright (C) 2009 - 2012 Red Hat, Inc.
|
||||||
* Copyright (C) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org>
|
* Copyright (C) 2011 - 2012 Google, Inc
|
||||||
* Copyright (C) 2011 - 2012 Google, Inc.
|
* Copyright (C) 2016 Velocloud, Inc.
|
||||||
|
* Copyright (C) 2011 - 2016 Aleksander Morgado <aleksander@aleksander.es>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
#include <gudev/gudev.h>
|
#include "mm-kernel-device-udev.h"
|
||||||
|
|
||||||
#include <ModemManager.h>
|
#include <ModemManager.h>
|
||||||
#include <mm-errors-types.h>
|
#include <mm-errors-types.h>
|
||||||
@@ -95,7 +96,7 @@ find_device_by_modem (MMBaseManager *manager,
|
|||||||
|
|
||||||
static MMDevice *
|
static MMDevice *
|
||||||
find_device_by_port (MMBaseManager *manager,
|
find_device_by_port (MMBaseManager *manager,
|
||||||
GUdevDevice *port)
|
MMKernelDevice *port)
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
@@ -118,10 +119,10 @@ find_device_by_physdev_uid (MMBaseManager *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static MMDevice *
|
static MMDevice *
|
||||||
find_device_by_udev_device (MMBaseManager *manager,
|
find_device_by_kernel_device (MMBaseManager *manager,
|
||||||
GUdevDevice *udev_device)
|
MMKernelDevice *kernel_device)
|
||||||
{
|
{
|
||||||
return find_device_by_physdev_uid (manager, g_udev_device_get_sysfs_path (udev_device));
|
return find_device_by_physdev_uid (manager, mm_kernel_device_get_physdev_uid (kernel_device));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -175,100 +176,26 @@ device_support_check_ready (MMPluginManager *plugin_manager,
|
|||||||
find_device_support_context_free (ctx);
|
find_device_support_context_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GUdevDevice *
|
|
||||||
find_physical_device (GUdevDevice *child)
|
|
||||||
{
|
|
||||||
GUdevDevice *iter, *old = NULL;
|
|
||||||
GUdevDevice *physdev = NULL;
|
|
||||||
const char *subsys, *type, *name;
|
|
||||||
guint32 i = 0;
|
|
||||||
gboolean is_usb = FALSE, is_pci = FALSE, is_pcmcia = FALSE, is_platform = FALSE;
|
|
||||||
gboolean is_pnp = FALSE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (child != NULL, NULL);
|
|
||||||
|
|
||||||
/* Bluetooth rfcomm devices are "virtual" and don't necessarily have
|
|
||||||
* parents at all.
|
|
||||||
*/
|
|
||||||
name = g_udev_device_get_name (child);
|
|
||||||
if (name && strncmp (name, "rfcomm", 6) == 0)
|
|
||||||
return g_object_ref (child);
|
|
||||||
|
|
||||||
iter = g_object_ref (child);
|
|
||||||
while (iter && i++ < 8) {
|
|
||||||
subsys = g_udev_device_get_subsystem (iter);
|
|
||||||
if (subsys) {
|
|
||||||
if (is_usb || g_str_has_prefix (subsys, "usb")) {
|
|
||||||
is_usb = TRUE;
|
|
||||||
type = g_udev_device_get_devtype (iter);
|
|
||||||
if (type && !strcmp (type, "usb_device")) {
|
|
||||||
physdev = iter;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (is_pcmcia || !strcmp (subsys, "pcmcia")) {
|
|
||||||
GUdevDevice *pcmcia_parent;
|
|
||||||
const char *tmp_subsys;
|
|
||||||
|
|
||||||
is_pcmcia = TRUE;
|
|
||||||
|
|
||||||
/* If the parent of this PCMCIA device is no longer part of
|
|
||||||
* the PCMCIA subsystem, we want to stop since we're looking
|
|
||||||
* for the base PCMCIA device, not the PCMCIA controller which
|
|
||||||
* is usually PCI or some other bus type.
|
|
||||||
*/
|
|
||||||
pcmcia_parent = g_udev_device_get_parent (iter);
|
|
||||||
if (pcmcia_parent) {
|
|
||||||
tmp_subsys = g_udev_device_get_subsystem (pcmcia_parent);
|
|
||||||
if (tmp_subsys && strcmp (tmp_subsys, "pcmcia"))
|
|
||||||
physdev = iter;
|
|
||||||
g_object_unref (pcmcia_parent);
|
|
||||||
if (physdev)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (is_platform || !strcmp (subsys, "platform")) {
|
|
||||||
/* Take the first platform parent as the physical device */
|
|
||||||
is_platform = TRUE;
|
|
||||||
physdev = iter;
|
|
||||||
break;
|
|
||||||
} else if (is_pci || !strcmp (subsys, "pci")) {
|
|
||||||
is_pci = TRUE;
|
|
||||||
physdev = iter;
|
|
||||||
break;
|
|
||||||
} else if (is_pnp || !strcmp (subsys, "pnp")) {
|
|
||||||
is_pnp = TRUE;
|
|
||||||
physdev = iter;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
old = iter;
|
|
||||||
iter = g_udev_device_get_parent (old);
|
|
||||||
g_object_unref (old);
|
|
||||||
}
|
|
||||||
|
|
||||||
return physdev;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
device_removed (MMBaseManager *self,
|
device_removed (MMBaseManager *self,
|
||||||
GUdevDevice *udev_device)
|
MMKernelDevice *kernel_device)
|
||||||
{
|
{
|
||||||
MMDevice *device;
|
MMDevice *device;
|
||||||
const gchar *subsys;
|
const gchar *subsys;
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
|
|
||||||
g_return_if_fail (udev_device != NULL);
|
g_return_if_fail (kernel_device != NULL);
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (udev_device);
|
subsys = mm_kernel_device_get_subsystem (kernel_device);
|
||||||
name = g_udev_device_get_name (udev_device);
|
name = mm_kernel_device_get_name (kernel_device);
|
||||||
|
|
||||||
if (!g_str_has_prefix (subsys, "usb") ||
|
if (!g_str_has_prefix (subsys, "usb") ||
|
||||||
(name && g_str_has_prefix (name, "cdc-wdm"))) {
|
(name && g_str_has_prefix (name, "cdc-wdm"))) {
|
||||||
/* Handle tty/net/wdm port removal */
|
/* Handle tty/net/wdm port removal */
|
||||||
device = find_device_by_port (self, udev_device);
|
device = find_device_by_port (self, kernel_device);
|
||||||
if (device) {
|
if (device) {
|
||||||
mm_info ("(%s/%s): released by device '%s'", subsys, name, mm_device_get_uid (device));
|
mm_info ("(%s/%s): released by device '%s'", subsys, name, mm_device_get_uid (device));
|
||||||
mm_device_release_port (device, udev_device);
|
mm_device_release_port (device, kernel_device);
|
||||||
|
|
||||||
/* If port probe list gets empty, remove the device object iself */
|
/* If port probe list gets empty, remove the device object iself */
|
||||||
if (!mm_device_peek_port_probe_list (device)) {
|
if (!mm_device_peek_port_probe_list (device)) {
|
||||||
@@ -291,105 +218,49 @@ device_removed (MMBaseManager *self,
|
|||||||
* device has been removed. That way, if the device is reinserted later, we'll go through
|
* device has been removed. That way, if the device is reinserted later, we'll go through
|
||||||
* the process of exporting it.
|
* the process of exporting it.
|
||||||
*/
|
*/
|
||||||
device = find_device_by_udev_device (self, udev_device);
|
device = find_device_by_kernel_device (self, kernel_device);
|
||||||
if (device) {
|
if (device) {
|
||||||
mm_dbg ("Removing device '%s'", mm_device_get_uid (device));
|
mm_dbg ("Removing device '%s'", mm_device_get_uid (device));
|
||||||
mm_device_remove_modem (device);
|
mm_device_remove_modem (device);
|
||||||
g_hash_table_remove (self->priv->devices, mm_device_get_uid (device));
|
g_hash_table_remove (self->priv->devices, mm_device_get_uid (device));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Maybe a plugin is checking whether or not the port is supported.
|
|
||||||
* TODO: Cancel every possible supports check in this port. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
device_added (MMBaseManager *manager,
|
device_added (MMBaseManager *manager,
|
||||||
GUdevDevice *port,
|
MMKernelDevice *port,
|
||||||
gboolean hotplugged,
|
gboolean hotplugged,
|
||||||
gboolean manual_scan)
|
gboolean manual_scan)
|
||||||
{
|
{
|
||||||
MMDevice *device;
|
MMDevice *device;
|
||||||
const char *subsys, *name, *physdev_uid, *physdev_subsys;
|
const gchar *physdev_uid;
|
||||||
gboolean is_candidate;
|
|
||||||
GUdevDevice *physdev = NULL;
|
|
||||||
|
|
||||||
g_return_if_fail (port != NULL);
|
g_return_if_fail (port != NULL);
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (port);
|
if (!mm_kernel_device_is_candidate (port, manual_scan)) {
|
||||||
name = g_udev_device_get_name (port);
|
/* This could mean that device changed, losing its ID_MM_CANDIDATE
|
||||||
|
|
||||||
/* ignore VTs */
|
|
||||||
if (strncmp (name, "tty", 3) == 0 && isdigit (name[3]))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Ignore devices that aren't completely configured by udev yet. If
|
|
||||||
* ModemManager is started in parallel with udev, explicitly requesting
|
|
||||||
* devices may return devices for which not all udev rules have yet been
|
|
||||||
* applied (a bug in udev/gudev). Since we often need those rules to match
|
|
||||||
* the device to a specific ModemManager driver, we need to ensure that all
|
|
||||||
* rules have been processed before handling a device.
|
|
||||||
*/
|
|
||||||
is_candidate = g_udev_device_get_property_as_boolean (port, "ID_MM_CANDIDATE");
|
|
||||||
if (!is_candidate) {
|
|
||||||
/* This could mean that device changed, loosing its ID_MM_CANDIDATE
|
|
||||||
* flags (such as Bluetooth RFCOMM devices upon disconnect.
|
* flags (such as Bluetooth RFCOMM devices upon disconnect.
|
||||||
* Try to forget it. */
|
* Try to forget it. */
|
||||||
if (hotplugged && !manual_scan)
|
|
||||||
device_removed (manager, port);
|
device_removed (manager, port);
|
||||||
|
mm_dbg ("(%s/%s): port not candidate",
|
||||||
|
mm_kernel_device_get_subsystem (port),
|
||||||
|
mm_kernel_device_get_name (port));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (find_device_by_port (manager, port))
|
/* If already added, ignore new event */
|
||||||
|
if (find_device_by_port (manager, port)) {
|
||||||
|
mm_dbg ("(%s/%s): port already added",
|
||||||
|
mm_kernel_device_get_subsystem (port),
|
||||||
|
mm_kernel_device_get_name (port));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Find the port's physical device's sysfs path. This is the kernel device
|
|
||||||
* that "owns" all the ports of the device, like the USB device or the PCI
|
|
||||||
* device the provides each tty or network port.
|
|
||||||
*/
|
|
||||||
physdev = find_physical_device (port);
|
|
||||||
if (!physdev) {
|
|
||||||
/* Warn about it, but filter out some common ports that we know don't have
|
|
||||||
* anything to do with mobile broadband.
|
|
||||||
*/
|
|
||||||
if ( strcmp (name, "console")
|
|
||||||
&& strcmp (name, "ptmx")
|
|
||||||
&& strcmp (name, "lo")
|
|
||||||
&& strcmp (name, "tty")
|
|
||||||
&& !strstr (name, "virbr"))
|
|
||||||
mm_dbg ("(%s/%s): could not get port's parent device", subsys, name);
|
|
||||||
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is the device blacklisted? */
|
/* Get the port's physical device's uid. All ports of the same physical
|
||||||
if (g_udev_device_get_property_as_boolean (physdev, "ID_MM_DEVICE_IGNORE")) {
|
* device will share the same uid. */
|
||||||
mm_dbg ("(%s/%s): port's parent device is blacklisted", subsys, name);
|
physdev_uid = mm_kernel_device_get_physdev_uid (port);
|
||||||
goto out;
|
g_assert (physdev_uid);
|
||||||
}
|
|
||||||
|
|
||||||
/* Is the device in the manual-only greylist? If so, return if this is an
|
|
||||||
* automatic scan. */
|
|
||||||
if (!manual_scan && g_udev_device_get_property_as_boolean (physdev, "ID_MM_DEVICE_MANUAL_SCAN_ONLY")) {
|
|
||||||
mm_dbg ("(%s/%s): port probed only in manual scan", subsys, name);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the physdev is a 'platform' or 'pnp' device that's not whitelisted, ignore it */
|
|
||||||
physdev_subsys = g_udev_device_get_subsystem (physdev);
|
|
||||||
if ( physdev_subsys
|
|
||||||
&& ( g_str_equal (physdev_subsys, "platform")
|
|
||||||
|| g_str_equal (physdev_subsys, "pnp"))
|
|
||||||
&& !g_udev_device_get_property_as_boolean (physdev, "ID_MM_PLATFORM_DRIVER_PROBE")) {
|
|
||||||
mm_dbg ("(%s/%s): port's parent platform driver is not whitelisted", subsys, name);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
physdev_uid = g_udev_device_get_sysfs_path (physdev);
|
|
||||||
if (!physdev_uid) {
|
|
||||||
mm_dbg ("(%s/%s): could not get port's parent device sysfs path", subsys, name);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* See if we already created an object to handle ports in this device */
|
/* See if we already created an object to handle ports in this device */
|
||||||
device = find_device_by_physdev_uid (manager, physdev_uid);
|
device = find_device_by_physdev_uid (manager, physdev_uid);
|
||||||
@@ -397,7 +268,7 @@ device_added (MMBaseManager *manager,
|
|||||||
FindDeviceSupportContext *ctx;
|
FindDeviceSupportContext *ctx;
|
||||||
|
|
||||||
/* Keep the device listed in the Manager */
|
/* Keep the device listed in the Manager */
|
||||||
device = mm_device_new (physdev, hotplugged);
|
device = mm_device_new (physdev_uid, hotplugged, FALSE);
|
||||||
g_hash_table_insert (manager->priv->devices,
|
g_hash_table_insert (manager->priv->devices,
|
||||||
g_strdup (physdev_uid),
|
g_strdup (physdev_uid),
|
||||||
device);
|
device);
|
||||||
@@ -415,10 +286,6 @@ device_added (MMBaseManager *manager,
|
|||||||
|
|
||||||
/* Grab the port in the existing device. */
|
/* Grab the port in the existing device. */
|
||||||
mm_device_grab_port (device, port);
|
mm_device_grab_port (device, port);
|
||||||
|
|
||||||
out:
|
|
||||||
if (physdev)
|
|
||||||
g_object_unref (physdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -430,6 +297,7 @@ handle_uevent (GUdevClient *client,
|
|||||||
MMBaseManager *self = MM_BASE_MANAGER (user_data);
|
MMBaseManager *self = MM_BASE_MANAGER (user_data);
|
||||||
const gchar *subsys;
|
const gchar *subsys;
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
|
MMKernelDevice *kernel_device;
|
||||||
|
|
||||||
g_return_if_fail (action != NULL);
|
g_return_if_fail (action != NULL);
|
||||||
|
|
||||||
@@ -438,15 +306,19 @@ handle_uevent (GUdevClient *client,
|
|||||||
g_return_if_fail (subsys != NULL);
|
g_return_if_fail (subsys != NULL);
|
||||||
g_return_if_fail (g_str_equal (subsys, "tty") || g_str_equal (subsys, "net") || g_str_has_prefix (subsys, "usb"));
|
g_return_if_fail (g_str_equal (subsys, "tty") || g_str_equal (subsys, "net") || g_str_has_prefix (subsys, "usb"));
|
||||||
|
|
||||||
|
kernel_device = mm_kernel_device_udev_new (device);
|
||||||
|
|
||||||
/* We only care about tty/net and usb/cdc-wdm devices when adding modem ports,
|
/* We only care about tty/net and usb/cdc-wdm devices when adding modem ports,
|
||||||
* but for remove, also handle usb parent device remove events
|
* but for remove, also handle usb parent device remove events
|
||||||
*/
|
*/
|
||||||
name = g_udev_device_get_name (device);
|
name = mm_kernel_device_get_name (kernel_device);
|
||||||
if ( (g_str_equal (action, "add") || g_str_equal (action, "move") || g_str_equal (action, "change"))
|
if ( (g_str_equal (action, "add") || g_str_equal (action, "move") || g_str_equal (action, "change"))
|
||||||
&& (!g_str_has_prefix (subsys, "usb") || (name && g_str_has_prefix (name, "cdc-wdm"))))
|
&& (!g_str_has_prefix (subsys, "usb") || (name && g_str_has_prefix (name, "cdc-wdm"))))
|
||||||
device_added (self, device, TRUE, FALSE);
|
device_added (self, kernel_device, TRUE, FALSE);
|
||||||
else if (g_str_equal (action, "remove"))
|
else if (g_str_equal (action, "remove"))
|
||||||
device_removed (self, device);
|
device_removed (self, kernel_device);
|
||||||
|
|
||||||
|
g_object_unref (kernel_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -458,7 +330,12 @@ typedef struct {
|
|||||||
static gboolean
|
static gboolean
|
||||||
start_device_added_idle (StartDeviceAdded *ctx)
|
start_device_added_idle (StartDeviceAdded *ctx)
|
||||||
{
|
{
|
||||||
device_added (ctx->self, ctx->device, FALSE, ctx->manual_scan);
|
MMKernelDevice *kernel_device;
|
||||||
|
|
||||||
|
kernel_device = mm_kernel_device_udev_new (ctx->device);
|
||||||
|
device_added (ctx->self, kernel_device, FALSE, ctx->manual_scan);
|
||||||
|
g_object_unref (kernel_device);
|
||||||
|
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->device);
|
g_object_unref (ctx->device);
|
||||||
g_slice_free (StartDeviceAdded, ctx);
|
g_slice_free (StartDeviceAdded, ctx);
|
||||||
@@ -757,7 +634,7 @@ handle_set_profile (MmGdbusTest *skeleton,
|
|||||||
|
|
||||||
/* Create device and keep it listed in the Manager */
|
/* Create device and keep it listed in the Manager */
|
||||||
physdev_uid = g_strdup_printf ("/virtual/%s", id);
|
physdev_uid = g_strdup_printf ("/virtual/%s", id);
|
||||||
device = mm_device_virtual_new (physdev_uid, TRUE);
|
device = mm_device_new (physdev_uid, TRUE, TRUE);
|
||||||
g_hash_table_insert (self->priv->devices, physdev_uid, device);
|
g_hash_table_insert (self->priv->devices, physdev_uid, device);
|
||||||
|
|
||||||
/* Grab virtual ports */
|
/* Grab virtual ports */
|
||||||
|
321
src/mm-device.c
321
src/mm-device.c
@@ -32,7 +32,6 @@ G_DEFINE_TYPE (MMDevice, mm_device, G_TYPE_OBJECT);
|
|||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_UID,
|
PROP_UID,
|
||||||
PROP_UDEV_DEVICE,
|
|
||||||
PROP_PLUGIN,
|
PROP_PLUGIN,
|
||||||
PROP_MODEM,
|
PROP_MODEM,
|
||||||
PROP_HOTPLUGGED,
|
PROP_HOTPLUGGED,
|
||||||
@@ -56,8 +55,7 @@ struct _MMDevicePrivate {
|
|||||||
/* Unique id */
|
/* Unique id */
|
||||||
gchar *uid;
|
gchar *uid;
|
||||||
|
|
||||||
/* Parent UDev device */
|
/* If USB, device vid/pid */
|
||||||
GUdevDevice *udev_device;
|
|
||||||
guint16 vendor;
|
guint16 vendor;
|
||||||
guint16 product;
|
guint16 product;
|
||||||
|
|
||||||
@@ -88,7 +86,7 @@ struct _MMDevicePrivate {
|
|||||||
|
|
||||||
static MMPortProbe *
|
static MMPortProbe *
|
||||||
device_find_probe_with_device (MMDevice *self,
|
device_find_probe_with_device (MMDevice *self,
|
||||||
GUdevDevice *udev_port,
|
MMKernelDevice *kernel_port,
|
||||||
gboolean lookup_ignored)
|
gboolean lookup_ignored)
|
||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
@@ -96,13 +94,7 @@ device_find_probe_with_device (MMDevice *self,
|
|||||||
for (l = self->priv->port_probes; l; l = g_list_next (l)) {
|
for (l = self->priv->port_probes; l; l = g_list_next (l)) {
|
||||||
MMPortProbe *probe = MM_PORT_PROBE (l->data);
|
MMPortProbe *probe = MM_PORT_PROBE (l->data);
|
||||||
|
|
||||||
if ( g_udev_device_has_property (udev_port, "DEVPATH_OLD")
|
if (mm_kernel_device_cmp (mm_port_probe_peek_port (probe), kernel_port))
|
||||||
&& g_str_has_suffix (g_udev_device_get_sysfs_path (mm_port_probe_peek_port (probe)),
|
|
||||||
g_udev_device_get_property (udev_port, "DEVPATH_OLD")))
|
|
||||||
return probe;
|
|
||||||
|
|
||||||
if (g_str_equal (g_udev_device_get_sysfs_path (mm_port_probe_peek_port (probe)),
|
|
||||||
g_udev_device_get_sysfs_path (udev_port)))
|
|
||||||
return probe;
|
return probe;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,13 +104,7 @@ device_find_probe_with_device (MMDevice *self,
|
|||||||
for (l = self->priv->ignored_port_probes; l; l = g_list_next (l)) {
|
for (l = self->priv->ignored_port_probes; l; l = g_list_next (l)) {
|
||||||
MMPortProbe *probe = MM_PORT_PROBE (l->data);
|
MMPortProbe *probe = MM_PORT_PROBE (l->data);
|
||||||
|
|
||||||
if ( g_udev_device_has_property (udev_port, "DEVPATH_OLD")
|
if (mm_kernel_device_cmp (mm_port_probe_peek_port (probe), kernel_port))
|
||||||
&& g_str_has_suffix (g_udev_device_get_sysfs_path (mm_port_probe_peek_port (probe)),
|
|
||||||
g_udev_device_get_property (udev_port, "DEVPATH_OLD")))
|
|
||||||
return probe;
|
|
||||||
|
|
||||||
if (g_str_equal (g_udev_device_get_sysfs_path (mm_port_probe_peek_port (probe)),
|
|
||||||
g_udev_device_get_sysfs_path (udev_port)))
|
|
||||||
return probe;
|
return probe;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,163 +113,20 @@ device_find_probe_with_device (MMDevice *self,
|
|||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mm_device_owns_port (MMDevice *self,
|
mm_device_owns_port (MMDevice *self,
|
||||||
GUdevDevice *udev_port)
|
MMKernelDevice *kernel_port)
|
||||||
{
|
{
|
||||||
return !!device_find_probe_with_device (self, udev_port, TRUE);
|
return !!device_find_probe_with_device (self, kernel_port, TRUE);
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
get_device_ids (GUdevDevice *device,
|
|
||||||
guint16 *vendor,
|
|
||||||
guint16 *product)
|
|
||||||
{
|
|
||||||
GUdevDevice *parent = NULL;
|
|
||||||
const gchar *vid = NULL, *pid = NULL, *parent_subsys;
|
|
||||||
gboolean success = FALSE;
|
|
||||||
char *pci_vid = NULL, *pci_pid = NULL;
|
|
||||||
|
|
||||||
parent = g_udev_device_get_parent (device);
|
|
||||||
if (parent) {
|
|
||||||
parent_subsys = g_udev_device_get_subsystem (parent);
|
|
||||||
if (parent_subsys) {
|
|
||||||
if (g_str_equal (parent_subsys, "bluetooth")) {
|
|
||||||
/* Bluetooth devices report the VID/PID of the BT adapter here,
|
|
||||||
* which isn't really what we want. Just return null IDs instead.
|
|
||||||
*/
|
|
||||||
success = TRUE;
|
|
||||||
goto out;
|
|
||||||
} else if (g_str_equal (parent_subsys, "pcmcia")) {
|
|
||||||
/* For PCMCIA devices we need to grab the PCMCIA subsystem's
|
|
||||||
* manfid and cardid, since any IDs on the tty device itself
|
|
||||||
* may be from PCMCIA controller or something else.
|
|
||||||
*/
|
|
||||||
vid = g_udev_device_get_sysfs_attr (parent, "manf_id");
|
|
||||||
pid = g_udev_device_get_sysfs_attr (parent, "card_id");
|
|
||||||
if (!vid || !pid)
|
|
||||||
goto out;
|
|
||||||
} else if (g_str_equal (parent_subsys, "platform")) {
|
|
||||||
/* Platform devices don't usually have a VID/PID */
|
|
||||||
success = TRUE;
|
|
||||||
goto out;
|
|
||||||
} else if (g_str_has_prefix (parent_subsys, "usb") &&
|
|
||||||
(!g_strcmp0 (g_udev_device_get_driver (parent), "qmi_wwan") ||
|
|
||||||
!g_strcmp0 (g_udev_device_get_driver (parent), "cdc_mbim"))) {
|
|
||||||
/* Need to look for vendor/product in the parent of the QMI/MBIM device */
|
|
||||||
GUdevDevice *qmi_parent;
|
|
||||||
|
|
||||||
qmi_parent = g_udev_device_get_parent (parent);
|
|
||||||
if (qmi_parent) {
|
|
||||||
vid = g_udev_device_get_property (qmi_parent, "ID_VENDOR_ID");
|
|
||||||
pid = g_udev_device_get_property (qmi_parent, "ID_MODEL_ID");
|
|
||||||
g_object_unref (qmi_parent);
|
|
||||||
}
|
|
||||||
} else if (g_str_equal (parent_subsys, "pci")) {
|
|
||||||
const char *pci_id;
|
|
||||||
|
|
||||||
/* We can't always rely on the model + vendor showing up on
|
|
||||||
* the PCI device's child, so look at the PCI parent. PCI_ID
|
|
||||||
* has the format "1931:000C".
|
|
||||||
*/
|
|
||||||
pci_id = g_udev_device_get_property (parent, "PCI_ID");
|
|
||||||
if (pci_id && strlen (pci_id) == 9 && pci_id[4] == ':') {
|
|
||||||
vid = pci_vid = g_strdup (pci_id);
|
|
||||||
pci_vid[4] = '\0';
|
|
||||||
pid = pci_pid = g_strdup (pci_id + 5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!vid)
|
|
||||||
vid = g_udev_device_get_property (device, "ID_VENDOR_ID");
|
|
||||||
if (!vid)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (strncmp (vid, "0x", 2) == 0)
|
|
||||||
vid += 2;
|
|
||||||
if (strlen (vid) != 4)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (vendor) {
|
|
||||||
*vendor = (guint16) (mm_utils_hex2byte (vid + 2) & 0xFF);
|
|
||||||
*vendor |= (guint16) ((mm_utils_hex2byte (vid) & 0xFF) << 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pid)
|
|
||||||
pid = g_udev_device_get_property (device, "ID_MODEL_ID");
|
|
||||||
if (!pid) {
|
|
||||||
*vendor = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncmp (pid, "0x", 2) == 0)
|
|
||||||
pid += 2;
|
|
||||||
if (strlen (pid) != 4) {
|
|
||||||
*vendor = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (product) {
|
|
||||||
*product = (guint16) (mm_utils_hex2byte (pid + 2) & 0xFF);
|
|
||||||
*product |= (guint16) ((mm_utils_hex2byte (pid) & 0xFF) << 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
success = TRUE;
|
|
||||||
|
|
||||||
out:
|
|
||||||
if (parent)
|
|
||||||
g_object_unref (parent);
|
|
||||||
g_free (pci_vid);
|
|
||||||
g_free (pci_pid);
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar *
|
|
||||||
mm_device_utils_get_port_driver (GUdevDevice *udev_port)
|
|
||||||
{
|
|
||||||
const gchar *driver, *subsys;
|
|
||||||
const char *name = g_udev_device_get_name (udev_port);
|
|
||||||
|
|
||||||
driver = g_udev_device_get_driver (udev_port);
|
|
||||||
if (!driver) {
|
|
||||||
GUdevDevice *parent;
|
|
||||||
|
|
||||||
parent = g_udev_device_get_parent (udev_port);
|
|
||||||
if (parent)
|
|
||||||
driver = g_udev_device_get_driver (parent);
|
|
||||||
|
|
||||||
/* Check for bluetooth; it's driver is a bunch of levels up so we
|
|
||||||
* just check for the subsystem of the parent being bluetooth.
|
|
||||||
*/
|
|
||||||
if (!driver && parent) {
|
|
||||||
subsys = g_udev_device_get_subsystem (parent);
|
|
||||||
if (subsys && !strcmp (subsys, "bluetooth"))
|
|
||||||
driver = "bluetooth";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parent)
|
|
||||||
g_object_unref (parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Newer kernels don't set up the rfcomm port parent in sysfs,
|
|
||||||
* so we must infer it from the device name.
|
|
||||||
*/
|
|
||||||
if (!driver && strncmp (name, "rfcomm", 6) == 0)
|
|
||||||
driver = "bluetooth";
|
|
||||||
|
|
||||||
/* Note: may return NULL! */
|
|
||||||
return driver;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_port_driver (MMDevice *self,
|
add_port_driver (MMDevice *self,
|
||||||
GUdevDevice *udev_port)
|
MMKernelDevice *kernel_port)
|
||||||
{
|
{
|
||||||
const gchar *driver;
|
const gchar *driver;
|
||||||
guint n_items;
|
guint n_items;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
driver = mm_device_utils_get_port_driver (udev_port);
|
driver = mm_kernel_device_get_driver (kernel_port);
|
||||||
if (!driver)
|
if (!driver)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -301,51 +144,46 @@ add_port_driver (MMDevice *self,
|
|||||||
if (!driver)
|
if (!driver)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self->priv->drivers = g_realloc (self->priv->drivers,
|
self->priv->drivers = g_realloc (self->priv->drivers, (n_items + 2) * sizeof (gchar *));
|
||||||
(n_items + 2) * sizeof (gchar *));
|
|
||||||
self->priv->drivers[n_items] = g_strdup (driver);
|
self->priv->drivers[n_items] = g_strdup (driver);
|
||||||
self->priv->drivers[n_items + 1] = NULL;
|
self->priv->drivers[n_items + 1] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_device_grab_port (MMDevice *self,
|
mm_device_grab_port (MMDevice *self,
|
||||||
GUdevDevice *udev_port)
|
MMKernelDevice *kernel_port)
|
||||||
{
|
{
|
||||||
MMPortProbe *probe;
|
MMPortProbe *probe;
|
||||||
|
|
||||||
if (mm_device_owns_port (self, udev_port))
|
if (mm_device_owns_port (self, kernel_port))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Get the vendor/product IDs out of the first one that gives us
|
/* Get the vendor/product IDs out of the first one that gives us
|
||||||
* some valid value (it seems we may get NULL reported for VID in QMI
|
* some valid value (it seems we may get NULL reported for VID in QMI
|
||||||
* ports, e.g. Huawei E367) */
|
* ports, e.g. Huawei E367) */
|
||||||
if (!self->priv->vendor && !self->priv->product) {
|
if (!self->priv->vendor && !self->priv->product) {
|
||||||
if (!get_device_ids (udev_port,
|
self->priv->vendor = mm_kernel_device_get_physdev_vid (kernel_port);
|
||||||
&self->priv->vendor,
|
self->priv->product = mm_kernel_device_get_physdev_pid (kernel_port);
|
||||||
&self->priv->product)) {
|
|
||||||
mm_dbg ("(%s) could not get vendor/product ID",
|
|
||||||
self->priv->uid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add new port driver */
|
/* Add new port driver */
|
||||||
add_port_driver (self, udev_port);
|
add_port_driver (self, kernel_port);
|
||||||
|
|
||||||
/* Create and store new port probe */
|
/* Create and store new port probe */
|
||||||
probe = mm_port_probe_new (self, udev_port);
|
probe = mm_port_probe_new (self, kernel_port);
|
||||||
self->priv->port_probes = g_list_prepend (self->priv->port_probes, probe);
|
self->priv->port_probes = g_list_prepend (self->priv->port_probes, probe);
|
||||||
|
|
||||||
/* Notify about the grabbed port */
|
/* Notify about the grabbed port */
|
||||||
g_signal_emit (self, signals[SIGNAL_PORT_GRABBED], 0, udev_port);
|
g_signal_emit (self, signals[SIGNAL_PORT_GRABBED], 0, kernel_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_device_release_port (MMDevice *self,
|
mm_device_release_port (MMDevice *self,
|
||||||
GUdevDevice *udev_port)
|
MMKernelDevice *kernel_port)
|
||||||
{
|
{
|
||||||
MMPortProbe *probe;
|
MMPortProbe *probe;
|
||||||
|
|
||||||
probe = device_find_probe_with_device (self, udev_port, TRUE);
|
probe = device_find_probe_with_device (self, kernel_port, TRUE);
|
||||||
if (probe) {
|
if (probe) {
|
||||||
/* Found, remove from lists and destroy probe */
|
/* Found, remove from lists and destroy probe */
|
||||||
if (g_list_find (self->priv->port_probes, probe))
|
if (g_list_find (self->priv->port_probes, probe))
|
||||||
@@ -361,16 +199,17 @@ mm_device_release_port (MMDevice *self,
|
|||||||
|
|
||||||
void
|
void
|
||||||
mm_device_ignore_port (MMDevice *self,
|
mm_device_ignore_port (MMDevice *self,
|
||||||
GUdevDevice *udev_port)
|
MMKernelDevice *kernel_port)
|
||||||
{
|
{
|
||||||
MMPortProbe *probe;
|
MMPortProbe *probe;
|
||||||
|
|
||||||
probe = device_find_probe_with_device (self, udev_port, FALSE);
|
probe = device_find_probe_with_device (self, kernel_port, FALSE);
|
||||||
if (probe) {
|
if (probe) {
|
||||||
/* Found, remove from list and add to the ignored list */
|
/* Found, remove from list and add to the ignored list */
|
||||||
mm_dbg ("Fully ignoring port '%s/%s' from now on",
|
mm_dbg ("[device %s] fully ignoring port '%s/%s' from now on",
|
||||||
g_udev_device_get_subsystem (udev_port),
|
self->priv->uid,
|
||||||
g_udev_device_get_name (udev_port));
|
mm_kernel_device_get_subsystem (kernel_port),
|
||||||
|
mm_kernel_device_get_name (kernel_port));
|
||||||
self->priv->port_probes = g_list_remove (self->priv->port_probes, probe);
|
self->priv->port_probes = g_list_remove (self->priv->port_probes, probe);
|
||||||
self->priv->ignored_port_probes = g_list_prepend (self->priv->ignored_port_probes, probe);
|
self->priv->ignored_port_probes = g_list_prepend (self->priv->ignored_port_probes, probe);
|
||||||
}
|
}
|
||||||
@@ -392,10 +231,7 @@ unexport_modem (MMDevice *self)
|
|||||||
g_object_set (self->priv->modem,
|
g_object_set (self->priv->modem,
|
||||||
MM_BASE_MODEM_CONNECTION, NULL,
|
MM_BASE_MODEM_CONNECTION, NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
mm_dbg ("[device %s] unexported modem from path '%s'", self->priv->uid, path);
|
||||||
mm_dbg ("Unexported modem '%s' from path '%s'",
|
|
||||||
g_udev_device_get_sysfs_path (self->priv->udev_device),
|
|
||||||
path);
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,8 +250,7 @@ export_modem (MMDevice *self)
|
|||||||
|
|
||||||
/* If modem not yet valid (not fully initialized), don't export it */
|
/* If modem not yet valid (not fully initialized), don't export it */
|
||||||
if (!mm_base_modem_get_valid (self->priv->modem)) {
|
if (!mm_base_modem_get_valid (self->priv->modem)) {
|
||||||
mm_dbg ("Modem '%s' not yet fully initialized",
|
mm_dbg ("[device %s] modem not yet fully initialized", self->priv->uid);
|
||||||
g_udev_device_get_sysfs_path (self->priv->udev_device));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,8 +260,7 @@ export_modem (MMDevice *self)
|
|||||||
NULL);
|
NULL);
|
||||||
if (path) {
|
if (path) {
|
||||||
g_free (path);
|
g_free (path);
|
||||||
mm_dbg ("Modem '%s' already exported",
|
mm_dbg ("[device %s] modem already exported", self->priv->uid);
|
||||||
g_udev_device_get_sysfs_path (self->priv->udev_device));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,21 +279,14 @@ export_modem (MMDevice *self)
|
|||||||
g_dbus_object_manager_server_export (self->priv->object_manager,
|
g_dbus_object_manager_server_export (self->priv->object_manager,
|
||||||
G_DBUS_OBJECT_SKELETON (self->priv->modem));
|
G_DBUS_OBJECT_SKELETON (self->priv->modem));
|
||||||
|
|
||||||
mm_dbg ("Exported modem '%s' at path '%s'",
|
mm_dbg ("[device %s] exported modem at path '%s'", self->priv->uid, path);
|
||||||
(self->priv->virtual ?
|
mm_dbg ("[device %s] plugin: %s", self->priv->uid, mm_base_modem_get_plugin (self->priv->modem));
|
||||||
self->priv->uid :
|
mm_dbg ("[device %s] vid:pid: 0x%04X:0x%04X",
|
||||||
g_udev_device_get_sysfs_path (self->priv->udev_device)),
|
self->priv->uid,
|
||||||
path);
|
|
||||||
|
|
||||||
/* Once connected, dump additional debug info about the modem */
|
|
||||||
mm_dbg ("(%s): '%s' modem, VID 0x%04X PID 0x%04X (%s)",
|
|
||||||
path,
|
|
||||||
mm_base_modem_get_plugin (self->priv->modem),
|
|
||||||
(mm_base_modem_get_vendor_id (self->priv->modem) & 0xFFFF),
|
(mm_base_modem_get_vendor_id (self->priv->modem) & 0xFFFF),
|
||||||
(mm_base_modem_get_product_id (self->priv->modem) & 0xFFFF),
|
(mm_base_modem_get_product_id (self->priv->modem) & 0xFFFF));
|
||||||
(self->priv->virtual ?
|
if (self->priv->virtual)
|
||||||
"virtual" :
|
mm_dbg ("[device %s] virtual", self->priv->uid);
|
||||||
g_udev_device_get_subsystem (self->priv->udev_device)));
|
|
||||||
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
@@ -512,7 +339,7 @@ modem_valid (MMBaseModem *modem,
|
|||||||
if (self->priv->modem)
|
if (self->priv->modem)
|
||||||
export_modem (self);
|
export_modem (self);
|
||||||
else
|
else
|
||||||
mm_dbg ("Not exporting modem; no longer available");
|
mm_dbg ("[device %s] not exporting modem; no longer available", self->priv->uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,7 +360,8 @@ mm_device_create_modem (MMDevice *self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mm_info ("Creating modem with plugin '%s' and '%u' ports",
|
mm_info ("[device %s] creating modem with plugin '%s' and '%u' ports",
|
||||||
|
self->priv->uid,
|
||||||
mm_plugin_get_name (self->priv->plugin),
|
mm_plugin_get_name (self->priv->plugin),
|
||||||
g_list_length (self->priv->port_probes));
|
g_list_length (self->priv->port_probes));
|
||||||
} else {
|
} else {
|
||||||
@@ -545,7 +373,8 @@ mm_device_create_modem (MMDevice *self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mm_info ("Creating virtual modem with plugin '%s' and '%u' ports",
|
mm_info ("[device %s] creating virtual modem with plugin '%s' and '%u' ports",
|
||||||
|
self->priv->uid,
|
||||||
mm_plugin_get_name (self->priv->plugin),
|
mm_plugin_get_name (self->priv->plugin),
|
||||||
g_strv_length (self->priv->virtual_ports));
|
g_strv_length (self->priv->virtual_ports));
|
||||||
}
|
}
|
||||||
@@ -591,20 +420,6 @@ mm_device_get_product (MMDevice *self)
|
|||||||
return self->priv->product;
|
return self->priv->product;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUdevDevice *
|
|
||||||
mm_device_peek_udev_device (MMDevice *self)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (self->priv->udev_device != NULL, NULL);
|
|
||||||
return self->priv->udev_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
GUdevDevice *
|
|
||||||
mm_device_get_udev_device (MMDevice *self)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (self->priv->udev_device != NULL, NULL);
|
|
||||||
return G_UDEV_DEVICE (g_object_ref (self->priv->udev_device));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_device_set_plugin (MMDevice *self,
|
mm_device_set_plugin (MMDevice *self,
|
||||||
GObject *plugin)
|
GObject *plugin)
|
||||||
@@ -648,21 +463,21 @@ mm_device_get_modem (MMDevice *self)
|
|||||||
|
|
||||||
GObject *
|
GObject *
|
||||||
mm_device_peek_port_probe (MMDevice *self,
|
mm_device_peek_port_probe (MMDevice *self,
|
||||||
GUdevDevice *udev_port)
|
MMKernelDevice *kernel_port)
|
||||||
{
|
{
|
||||||
MMPortProbe *probe;
|
MMPortProbe *probe;
|
||||||
|
|
||||||
probe = device_find_probe_with_device (self, udev_port, FALSE);
|
probe = device_find_probe_with_device (self, kernel_port, FALSE);
|
||||||
return (probe ? G_OBJECT (probe) : NULL);
|
return (probe ? G_OBJECT (probe) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
GObject *
|
GObject *
|
||||||
mm_device_get_port_probe (MMDevice *self,
|
mm_device_get_port_probe (MMDevice *self,
|
||||||
GUdevDevice *udev_port)
|
MMKernelDevice *kernel_port)
|
||||||
{
|
{
|
||||||
MMPortProbe *probe;
|
MMPortProbe *probe;
|
||||||
|
|
||||||
probe = device_find_probe_with_device (self, udev_port, FALSE);
|
probe = device_find_probe_with_device (self, kernel_port, FALSE);
|
||||||
return (probe ? g_object_ref (probe) : NULL);
|
return (probe ? g_object_ref (probe) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -723,34 +538,16 @@ mm_device_is_virtual (MMDevice *self)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
MMDevice *
|
MMDevice *
|
||||||
mm_device_new (GUdevDevice *udev_device,
|
mm_device_new (const gchar *uid,
|
||||||
gboolean hotplugged)
|
gboolean hotplugged,
|
||||||
{
|
gboolean virtual)
|
||||||
const gchar *uid;
|
|
||||||
|
|
||||||
g_return_val_if_fail (udev_device != NULL, NULL);
|
|
||||||
|
|
||||||
uid = g_udev_device_get_property (udev_device, "ID_MM_PHYSDEV_UID");
|
|
||||||
if (uid)
|
|
||||||
mm_dbg ("device with an explicit physdev UID: %s", uid);
|
|
||||||
|
|
||||||
return MM_DEVICE (g_object_new (MM_TYPE_DEVICE,
|
|
||||||
MM_DEVICE_UDEV_DEVICE, udev_device,
|
|
||||||
MM_DEVICE_UID, uid ? uid : g_udev_device_get_sysfs_path (udev_device),
|
|
||||||
MM_DEVICE_HOTPLUGGED, hotplugged,
|
|
||||||
NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
MMDevice *
|
|
||||||
mm_device_virtual_new (const gchar *uid,
|
|
||||||
gboolean hotplugged)
|
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (uid != NULL, NULL);
|
g_return_val_if_fail (uid != NULL, NULL);
|
||||||
|
|
||||||
return MM_DEVICE (g_object_new (MM_TYPE_DEVICE,
|
return MM_DEVICE (g_object_new (MM_TYPE_DEVICE,
|
||||||
MM_DEVICE_UID, uid,
|
MM_DEVICE_UID, uid,
|
||||||
MM_DEVICE_HOTPLUGGED, hotplugged,
|
MM_DEVICE_HOTPLUGGED, hotplugged,
|
||||||
MM_DEVICE_VIRTUAL, TRUE,
|
MM_DEVICE_VIRTUAL, virtual,
|
||||||
NULL));
|
NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -758,9 +555,7 @@ static void
|
|||||||
mm_device_init (MMDevice *self)
|
mm_device_init (MMDevice *self)
|
||||||
{
|
{
|
||||||
/* Initialize private data */
|
/* Initialize private data */
|
||||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_DEVICE, MMDevicePrivate);
|
||||||
MM_TYPE_DEVICE,
|
|
||||||
MMDevicePrivate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -776,10 +571,6 @@ set_property (GObject *object,
|
|||||||
/* construct only */
|
/* construct only */
|
||||||
self->priv->uid = g_value_dup_string (value);
|
self->priv->uid = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_UDEV_DEVICE:
|
|
||||||
/* construct only */
|
|
||||||
self->priv->udev_device = g_value_dup_object (value);
|
|
||||||
break;
|
|
||||||
case PROP_PLUGIN:
|
case PROP_PLUGIN:
|
||||||
g_clear_object (&(self->priv->plugin));
|
g_clear_object (&(self->priv->plugin));
|
||||||
self->priv->plugin = g_value_dup_object (value);
|
self->priv->plugin = g_value_dup_object (value);
|
||||||
@@ -812,9 +603,6 @@ get_property (GObject *object,
|
|||||||
case PROP_UID:
|
case PROP_UID:
|
||||||
g_value_set_string (value, self->priv->uid);
|
g_value_set_string (value, self->priv->uid);
|
||||||
break;
|
break;
|
||||||
case PROP_UDEV_DEVICE:
|
|
||||||
g_value_set_object (value, self->priv->udev_device);
|
|
||||||
break;
|
|
||||||
case PROP_PLUGIN:
|
case PROP_PLUGIN:
|
||||||
g_value_set_object (value, self->priv->plugin);
|
g_value_set_object (value, self->priv->plugin);
|
||||||
break;
|
break;
|
||||||
@@ -838,7 +626,6 @@ dispose (GObject *object)
|
|||||||
{
|
{
|
||||||
MMDevice *self = MM_DEVICE (object);
|
MMDevice *self = MM_DEVICE (object);
|
||||||
|
|
||||||
g_clear_object (&(self->priv->udev_device));
|
|
||||||
g_clear_object (&(self->priv->plugin));
|
g_clear_object (&(self->priv->plugin));
|
||||||
g_list_free_full (self->priv->port_probes, (GDestroyNotify)g_object_unref);
|
g_list_free_full (self->priv->port_probes, (GDestroyNotify)g_object_unref);
|
||||||
g_list_free_full (self->priv->ignored_port_probes, (GDestroyNotify)g_object_unref);
|
g_list_free_full (self->priv->ignored_port_probes, (GDestroyNotify)g_object_unref);
|
||||||
@@ -880,14 +667,6 @@ mm_device_class_init (MMDeviceClass *klass)
|
|||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||||
g_object_class_install_property (object_class, PROP_UID, properties[PROP_UID]);
|
g_object_class_install_property (object_class, PROP_UID, properties[PROP_UID]);
|
||||||
|
|
||||||
properties[PROP_UDEV_DEVICE] =
|
|
||||||
g_param_spec_object (MM_DEVICE_UDEV_DEVICE,
|
|
||||||
"UDev Device",
|
|
||||||
"UDev device object",
|
|
||||||
G_UDEV_TYPE_DEVICE,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
||||||
g_object_class_install_property (object_class, PROP_UDEV_DEVICE, properties[PROP_UDEV_DEVICE]);
|
|
||||||
|
|
||||||
properties[PROP_PLUGIN] =
|
properties[PROP_PLUGIN] =
|
||||||
g_param_spec_object (MM_DEVICE_PLUGIN,
|
g_param_spec_object (MM_DEVICE_PLUGIN,
|
||||||
"Plugin",
|
"Plugin",
|
||||||
@@ -927,7 +706,7 @@ mm_device_class_init (MMDeviceClass *klass)
|
|||||||
G_STRUCT_OFFSET (MMDeviceClass, port_grabbed),
|
G_STRUCT_OFFSET (MMDeviceClass, port_grabbed),
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_generic,
|
g_cclosure_marshal_generic,
|
||||||
G_TYPE_NONE, 1, G_UDEV_TYPE_DEVICE);
|
G_TYPE_NONE, 1, MM_TYPE_KERNEL_DEVICE);
|
||||||
|
|
||||||
signals[SIGNAL_PORT_RELEASED] =
|
signals[SIGNAL_PORT_RELEASED] =
|
||||||
g_signal_new (MM_DEVICE_PORT_RELEASED,
|
g_signal_new (MM_DEVICE_PORT_RELEASED,
|
||||||
@@ -936,5 +715,5 @@ mm_device_class_init (MMDeviceClass *klass)
|
|||||||
G_STRUCT_OFFSET (MMDeviceClass, port_released),
|
G_STRUCT_OFFSET (MMDeviceClass, port_released),
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_generic,
|
g_cclosure_marshal_generic,
|
||||||
G_TYPE_NONE, 1, G_UDEV_TYPE_DEVICE);
|
G_TYPE_NONE, 1, MM_TYPE_KERNEL_DEVICE);
|
||||||
}
|
}
|
||||||
|
@@ -19,8 +19,7 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
#include <gudev/gudev.h>
|
#include "mm-kernel-device.h"
|
||||||
|
|
||||||
#include "mm-base-modem.h"
|
#include "mm-base-modem.h"
|
||||||
|
|
||||||
#define MM_TYPE_DEVICE (mm_device_get_type ())
|
#define MM_TYPE_DEVICE (mm_device_get_type ())
|
||||||
@@ -35,7 +34,6 @@ typedef struct _MMDeviceClass MMDeviceClass;
|
|||||||
typedef struct _MMDevicePrivate MMDevicePrivate;
|
typedef struct _MMDevicePrivate MMDevicePrivate;
|
||||||
|
|
||||||
#define MM_DEVICE_UID "uid"
|
#define MM_DEVICE_UID "uid"
|
||||||
#define MM_DEVICE_UDEV_DEVICE "udev-device"
|
|
||||||
#define MM_DEVICE_PLUGIN "plugin"
|
#define MM_DEVICE_PLUGIN "plugin"
|
||||||
#define MM_DEVICE_MODEM "modem"
|
#define MM_DEVICE_MODEM "modem"
|
||||||
#define MM_DEVICE_HOTPLUGGED "hotplugged"
|
#define MM_DEVICE_HOTPLUGGED "hotplugged"
|
||||||
@@ -54,24 +52,25 @@ struct _MMDeviceClass {
|
|||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
void (* port_grabbed) (MMDevice *self,
|
void (* port_grabbed) (MMDevice *self,
|
||||||
GUdevDevice *port);
|
MMKernelDevice *port);
|
||||||
void (* port_released) (MMDevice *self,
|
void (* port_released) (MMDevice *self,
|
||||||
GUdevDevice *port);
|
MMKernelDevice *port);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType mm_device_get_type (void);
|
GType mm_device_get_type (void);
|
||||||
|
|
||||||
MMDevice *mm_device_new (GUdevDevice *udev_device,
|
MMDevice *mm_device_new (const gchar *uid,
|
||||||
gboolean hotplugged);
|
gboolean hotplugged,
|
||||||
|
gboolean virtual);
|
||||||
|
|
||||||
void mm_device_grab_port (MMDevice *self,
|
void mm_device_grab_port (MMDevice *self,
|
||||||
GUdevDevice *udev_port);
|
MMKernelDevice *kernel_port);
|
||||||
void mm_device_release_port (MMDevice *self,
|
void mm_device_release_port (MMDevice *self,
|
||||||
GUdevDevice *udev_port);
|
MMKernelDevice *kernel_port);
|
||||||
gboolean mm_device_owns_port (MMDevice *self,
|
gboolean mm_device_owns_port (MMDevice *self,
|
||||||
GUdevDevice *udev_port);
|
MMKernelDevice *kernel_port);
|
||||||
void mm_device_ignore_port (MMDevice *self,
|
void mm_device_ignore_port (MMDevice *self,
|
||||||
GUdevDevice *udev_port);
|
MMKernelDevice *kernel_port);
|
||||||
|
|
||||||
gboolean mm_device_create_modem (MMDevice *self,
|
gboolean mm_device_create_modem (MMDevice *self,
|
||||||
GDBusObjectManagerServer *object_manager,
|
GDBusObjectManagerServer *object_manager,
|
||||||
@@ -82,30 +81,21 @@ const gchar *mm_device_get_uid (MMDevice *self);
|
|||||||
const gchar **mm_device_get_drivers (MMDevice *self);
|
const gchar **mm_device_get_drivers (MMDevice *self);
|
||||||
guint16 mm_device_get_vendor (MMDevice *self);
|
guint16 mm_device_get_vendor (MMDevice *self);
|
||||||
guint16 mm_device_get_product (MMDevice *self);
|
guint16 mm_device_get_product (MMDevice *self);
|
||||||
GUdevDevice *mm_device_peek_udev_device (MMDevice *self);
|
|
||||||
GUdevDevice *mm_device_get_udev_device (MMDevice *self);
|
|
||||||
void mm_device_set_plugin (MMDevice *self,
|
void mm_device_set_plugin (MMDevice *self,
|
||||||
GObject *plugin);
|
GObject *plugin);
|
||||||
GObject *mm_device_peek_plugin (MMDevice *self);
|
GObject *mm_device_peek_plugin (MMDevice *self);
|
||||||
GObject *mm_device_get_plugin (MMDevice *self);
|
GObject *mm_device_get_plugin (MMDevice *self);
|
||||||
MMBaseModem *mm_device_peek_modem (MMDevice *self);
|
MMBaseModem *mm_device_peek_modem (MMDevice *self);
|
||||||
MMBaseModem *mm_device_get_modem (MMDevice *self);
|
MMBaseModem *mm_device_get_modem (MMDevice *self);
|
||||||
|
|
||||||
GObject *mm_device_peek_port_probe (MMDevice *self,
|
GObject *mm_device_peek_port_probe (MMDevice *self,
|
||||||
GUdevDevice *udev_port);
|
MMKernelDevice *kernel_port);
|
||||||
GObject *mm_device_get_port_probe (MMDevice *self,
|
GObject *mm_device_get_port_probe (MMDevice *self,
|
||||||
GUdevDevice *udev_port);
|
MMKernelDevice *kernel_port);
|
||||||
GList *mm_device_peek_port_probe_list (MMDevice *self);
|
GList *mm_device_peek_port_probe_list (MMDevice *self);
|
||||||
GList *mm_device_get_port_probe_list (MMDevice *self);
|
GList *mm_device_get_port_probe_list (MMDevice *self);
|
||||||
|
|
||||||
const gchar *mm_device_utils_get_port_driver (GUdevDevice *udev_port);
|
|
||||||
|
|
||||||
gboolean mm_device_get_hotplugged (MMDevice *self);
|
gboolean mm_device_get_hotplugged (MMDevice *self);
|
||||||
|
|
||||||
|
|
||||||
/* For testing purposes */
|
/* For testing purposes */
|
||||||
MMDevice *mm_device_virtual_new (const gchar *uid,
|
|
||||||
gboolean hotplugged);
|
|
||||||
void mm_device_virtual_grab_ports (MMDevice *self,
|
void mm_device_virtual_grab_ports (MMDevice *self,
|
||||||
const gchar **ports);
|
const gchar **ports);
|
||||||
const gchar **mm_device_virtual_peek_ports (MMDevice *self);
|
const gchar **mm_device_virtual_peek_ports (MMDevice *self);
|
||||||
|
@@ -62,7 +62,7 @@ struct _MMPluginManagerPrivate {
|
|||||||
static GList *
|
static GList *
|
||||||
plugin_manager_build_plugins_list (MMPluginManager *self,
|
plugin_manager_build_plugins_list (MMPluginManager *self,
|
||||||
MMDevice *device,
|
MMDevice *device,
|
||||||
GUdevDevice *port)
|
MMKernelDevice *port)
|
||||||
{
|
{
|
||||||
GList *list = NULL;
|
GList *list = NULL;
|
||||||
GList *l;
|
GList *l;
|
||||||
@@ -179,8 +179,8 @@ struct _PortContext {
|
|||||||
gchar *name;
|
gchar *name;
|
||||||
/* The device where the port is*/
|
/* The device where the port is*/
|
||||||
MMDevice *device;
|
MMDevice *device;
|
||||||
/* The GUDev reported port object */
|
/* The reported kernel port object */
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
|
|
||||||
/* The operation task */
|
/* The operation task */
|
||||||
GTask *task;
|
GTask *task;
|
||||||
@@ -642,7 +642,7 @@ static PortContext *
|
|||||||
port_context_new (MMPluginManager *self,
|
port_context_new (MMPluginManager *self,
|
||||||
const gchar *parent_name,
|
const gchar *parent_name,
|
||||||
MMDevice *device,
|
MMDevice *device,
|
||||||
GUdevDevice *port)
|
MMKernelDevice *port)
|
||||||
{
|
{
|
||||||
PortContext *port_context;
|
PortContext *port_context;
|
||||||
|
|
||||||
@@ -653,7 +653,7 @@ port_context_new (MMPluginManager *self,
|
|||||||
port_context->timer = g_timer_new ();
|
port_context->timer = g_timer_new ();
|
||||||
|
|
||||||
/* Set context name */
|
/* Set context name */
|
||||||
port_context->name = g_strdup_printf ("%s,%s", parent_name, g_udev_device_get_name (port));
|
port_context->name = g_strdup_printf ("%s,%s", parent_name, mm_kernel_device_get_name (port));
|
||||||
|
|
||||||
return port_context;
|
return port_context;
|
||||||
}
|
}
|
||||||
@@ -758,7 +758,7 @@ device_context_ref (DeviceContext *device_context)
|
|||||||
|
|
||||||
static PortContext *
|
static PortContext *
|
||||||
device_context_peek_running_port_context (DeviceContext *device_context,
|
device_context_peek_running_port_context (DeviceContext *device_context,
|
||||||
GUdevDevice *port)
|
MMKernelDevice *port)
|
||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
@@ -767,7 +767,7 @@ device_context_peek_running_port_context (DeviceContext *device_context,
|
|||||||
|
|
||||||
port_context = (PortContext *)(l->data);
|
port_context = (PortContext *)(l->data);
|
||||||
if ((port_context->port == port) ||
|
if ((port_context->port == port) ||
|
||||||
(!g_strcmp0 (g_udev_device_get_name (port_context->port), g_udev_device_get_name (port))))
|
(!g_strcmp0 (mm_kernel_device_get_name (port_context->port), mm_kernel_device_get_name (port))))
|
||||||
return port_context;
|
return port_context;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -775,7 +775,7 @@ device_context_peek_running_port_context (DeviceContext *device_context,
|
|||||||
|
|
||||||
static PortContext *
|
static PortContext *
|
||||||
device_context_peek_waiting_port_context (DeviceContext *device_context,
|
device_context_peek_waiting_port_context (DeviceContext *device_context,
|
||||||
GUdevDevice *port)
|
MMKernelDevice *port)
|
||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
@@ -784,7 +784,7 @@ device_context_peek_waiting_port_context (DeviceContext *device_context,
|
|||||||
|
|
||||||
port_context = (PortContext *)(l->data);
|
port_context = (PortContext *)(l->data);
|
||||||
if ((port_context->port == port) ||
|
if ((port_context->port == port) ||
|
||||||
(!g_strcmp0 (g_udev_device_get_name (port_context->port), g_udev_device_get_name (port))))
|
(!g_strcmp0 (mm_kernel_device_get_name (port_context->port), mm_kernel_device_get_name (port))))
|
||||||
return port_context;
|
return port_context;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -988,7 +988,7 @@ device_context_continue (DeviceContext *device_context)
|
|||||||
PortContext *port_context = (PortContext *) (l->data);
|
PortContext *port_context = (PortContext *) (l->data);
|
||||||
const gchar *portname;
|
const gchar *portname;
|
||||||
|
|
||||||
portname = g_udev_device_get_name (port_context->port);
|
portname = mm_kernel_device_get_name (port_context->port);
|
||||||
if (!s)
|
if (!s)
|
||||||
s = g_string_new (portname);
|
s = g_string_new (portname);
|
||||||
else
|
else
|
||||||
@@ -1123,12 +1123,12 @@ device_context_min_wait_time_elapsed (DeviceContext *device_context)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
device_context_port_released (DeviceContext *device_context,
|
device_context_port_released (DeviceContext *device_context,
|
||||||
GUdevDevice *port)
|
MMKernelDevice *port)
|
||||||
{
|
{
|
||||||
PortContext *port_context;
|
PortContext *port_context;
|
||||||
|
|
||||||
mm_dbg ("[plugin manager] task %s: port released: %s",
|
mm_dbg ("[plugin manager] task %s: port released: %s",
|
||||||
device_context->name, g_udev_device_get_name (port));
|
device_context->name, mm_kernel_device_get_name (port));
|
||||||
|
|
||||||
/* Check if there's a waiting port context */
|
/* Check if there's a waiting port context */
|
||||||
port_context = device_context_peek_waiting_port_context (device_context, port);
|
port_context = device_context_peek_waiting_port_context (device_context, port);
|
||||||
@@ -1150,12 +1150,12 @@ device_context_port_released (DeviceContext *device_context,
|
|||||||
/* This is not something worth warning. If the probing task has already
|
/* This is not something worth warning. If the probing task has already
|
||||||
* been finished, it will already be removed from the list */
|
* been finished, it will already be removed from the list */
|
||||||
mm_dbg ("[plugin manager] task %s: port wasn't found: %s",
|
mm_dbg ("[plugin manager] task %s: port wasn't found: %s",
|
||||||
device_context->name, g_udev_device_get_name (port));
|
device_context->name, mm_kernel_device_get_name (port));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
device_context_port_grabbed (DeviceContext *device_context,
|
device_context_port_grabbed (DeviceContext *device_context,
|
||||||
GUdevDevice *port)
|
MMKernelDevice *port)
|
||||||
{
|
{
|
||||||
MMPluginManager *self;
|
MMPluginManager *self;
|
||||||
PortContext *port_context;
|
PortContext *port_context;
|
||||||
@@ -1164,7 +1164,7 @@ device_context_port_grabbed (DeviceContext *device_context,
|
|||||||
self = MM_PLUGIN_MANAGER (device_context->self);
|
self = MM_PLUGIN_MANAGER (device_context->self);
|
||||||
|
|
||||||
mm_dbg ("[plugin manager] task %s: port grabbed: %s",
|
mm_dbg ("[plugin manager] task %s: port grabbed: %s",
|
||||||
device_context->name, g_udev_device_get_name (port));
|
device_context->name, mm_kernel_device_get_name (port));
|
||||||
|
|
||||||
/* Ignore if for any reason we still have it in the running list */
|
/* Ignore if for any reason we still have it in the running list */
|
||||||
port_context = device_context_peek_running_port_context (device_context, port);
|
port_context = device_context_peek_running_port_context (device_context, port);
|
||||||
|
@@ -23,13 +23,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <gudev/gudev.h>
|
|
||||||
|
|
||||||
#include <ModemManager.h>
|
#include <ModemManager.h>
|
||||||
#include <mm-errors-types.h>
|
#include <mm-errors-types.h>
|
||||||
|
|
||||||
#include "mm-plugin.h"
|
#include "mm-plugin.h"
|
||||||
#include "mm-device.h"
|
#include "mm-device.h"
|
||||||
|
#include "mm-kernel-device.h"
|
||||||
#include "mm-port-serial-at.h"
|
#include "mm-port-serial-at.h"
|
||||||
#include "mm-port-serial-qcdm.h"
|
#include "mm-port-serial-qcdm.h"
|
||||||
#include "mm-serial-parsers.h"
|
#include "mm-serial-parsers.h"
|
||||||
@@ -163,13 +162,13 @@ is_virtual_port (const gchar *device_name)
|
|||||||
/* Returns TRUE if the support check request was filtered out */
|
/* Returns TRUE if the support check request was filtered out */
|
||||||
static gboolean
|
static gboolean
|
||||||
apply_subsystem_filter (MMPlugin *self,
|
apply_subsystem_filter (MMPlugin *self,
|
||||||
GUdevDevice *port)
|
MMKernelDevice *port)
|
||||||
{
|
{
|
||||||
if (self->priv->subsystems) {
|
if (self->priv->subsystems) {
|
||||||
const gchar *subsys;
|
const gchar *subsys;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (port);
|
subsys = mm_kernel_device_get_subsystem (port);
|
||||||
for (i = 0; self->priv->subsystems[i]; i++) {
|
for (i = 0; self->priv->subsystems[i]; i++) {
|
||||||
if (g_str_equal (subsys, self->priv->subsystems[i]))
|
if (g_str_equal (subsys, self->priv->subsystems[i]))
|
||||||
break;
|
break;
|
||||||
@@ -191,7 +190,7 @@ apply_subsystem_filter (MMPlugin *self,
|
|||||||
static gboolean
|
static gboolean
|
||||||
apply_pre_probing_filters (MMPlugin *self,
|
apply_pre_probing_filters (MMPlugin *self,
|
||||||
MMDevice *device,
|
MMDevice *device,
|
||||||
GUdevDevice *port,
|
MMKernelDevice *port,
|
||||||
gboolean *need_vendor_probing,
|
gboolean *need_vendor_probing,
|
||||||
gboolean *need_product_probing)
|
gboolean *need_product_probing)
|
||||||
{
|
{
|
||||||
@@ -209,7 +208,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
if (apply_subsystem_filter (self, port)) {
|
if (apply_subsystem_filter (self, port)) {
|
||||||
mm_dbg ("(%s) [%s] filtered by subsystem",
|
mm_dbg ("(%s) [%s] filtered by subsystem",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +231,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
const gchar **drivers;
|
const gchar **drivers;
|
||||||
|
|
||||||
/* Detect any modems accessible through the list of virtual ports */
|
/* Detect any modems accessible through the list of virtual ports */
|
||||||
drivers = (is_virtual_port (g_udev_device_get_name (port)) ?
|
drivers = (is_virtual_port (mm_kernel_device_get_name (port)) ?
|
||||||
virtual_drivers :
|
virtual_drivers :
|
||||||
mm_device_get_drivers (device));
|
mm_device_get_drivers (device));
|
||||||
|
|
||||||
@@ -240,7 +239,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
if (!drivers) {
|
if (!drivers) {
|
||||||
mm_dbg ("(%s) [%s] filtered as couldn't retrieve drivers",
|
mm_dbg ("(%s) [%s] filtered as couldn't retrieve drivers",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +260,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
if (!found) {
|
if (!found) {
|
||||||
mm_dbg ("(%s) [%s] filtered by drivers",
|
mm_dbg ("(%s) [%s] filtered by drivers",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,7 +275,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
if (g_str_equal (drivers[j], self->priv->forbidden_drivers[i])) {
|
if (g_str_equal (drivers[j], self->priv->forbidden_drivers[i])) {
|
||||||
mm_dbg ("(%s) [%s] filtered by forbidden drivers",
|
mm_dbg ("(%s) [%s] filtered by forbidden drivers",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,7 +291,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
if (g_str_equal (drivers[j], "qmi_wwan")) {
|
if (g_str_equal (drivers[j], "qmi_wwan")) {
|
||||||
mm_dbg ("(%s) [%s] filtered by implicit QMI driver",
|
mm_dbg ("(%s) [%s] filtered by implicit QMI driver",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,7 +306,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
if (g_str_equal (drivers[j], "cdc_mbim")) {
|
if (g_str_equal (drivers[j], "cdc_mbim")) {
|
||||||
mm_dbg ("(%s) [%s] filtered by implicit MBIM driver",
|
mm_dbg ("(%s) [%s] filtered by implicit MBIM driver",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -369,11 +368,11 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
((!self->priv->vendor_strings &&
|
((!self->priv->vendor_strings &&
|
||||||
!self->priv->product_strings &&
|
!self->priv->product_strings &&
|
||||||
!self->priv->forbidden_product_strings) ||
|
!self->priv->forbidden_product_strings) ||
|
||||||
g_str_equal (g_udev_device_get_subsystem (port), "net") ||
|
g_str_equal (mm_kernel_device_get_subsystem (port), "net") ||
|
||||||
g_str_has_prefix (g_udev_device_get_name (port), "cdc-wdm"))) {
|
g_str_has_prefix (mm_kernel_device_get_name (port), "cdc-wdm"))) {
|
||||||
mm_dbg ("(%s) [%s] filtered by vendor/product IDs",
|
mm_dbg ("(%s) [%s] filtered by vendor/product IDs",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +384,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
product == self->priv->forbidden_product_ids[i].r) {
|
product == self->priv->forbidden_product_ids[i].r) {
|
||||||
mm_dbg ("(%s) [%s] filtered by forbidden vendor/product IDs",
|
mm_dbg ("(%s) [%s] filtered by forbidden vendor/product IDs",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -418,8 +417,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
if (self->priv->udev_tags) {
|
if (self->priv->udev_tags) {
|
||||||
for (i = 0; self->priv->udev_tags[i]; i++) {
|
for (i = 0; self->priv->udev_tags[i]; i++) {
|
||||||
/* Check if the port was tagged */
|
/* Check if the port was tagged */
|
||||||
if (g_udev_device_get_property_as_boolean (port,
|
if (mm_kernel_device_get_property_as_boolean (port, self->priv->udev_tags[i]))
|
||||||
self->priv->udev_tags[i]))
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,7 +425,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
if (!self->priv->udev_tags[i]) {
|
if (!self->priv->udev_tags[i]) {
|
||||||
mm_dbg ("(%s) [%s] filtered by udev tags",
|
mm_dbg ("(%s) [%s] filtered by udev tags",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -676,7 +674,7 @@ mm_plugin_supports_port_finish (MMPlugin *self,
|
|||||||
void
|
void
|
||||||
mm_plugin_supports_port (MMPlugin *self,
|
mm_plugin_supports_port (MMPlugin *self,
|
||||||
MMDevice *device,
|
MMDevice *device,
|
||||||
GUdevDevice *port,
|
MMKernelDevice *port,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -691,7 +689,7 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
|
|
||||||
g_return_if_fail (MM_IS_PLUGIN (self));
|
g_return_if_fail (MM_IS_PLUGIN (self));
|
||||||
g_return_if_fail (MM_IS_DEVICE (device));
|
g_return_if_fail (MM_IS_DEVICE (device));
|
||||||
g_return_if_fail (G_UDEV_IS_DEVICE (port));
|
g_return_if_fail (MM_IS_KERNEL_DEVICE (port));
|
||||||
|
|
||||||
/* Create new cancellable task */
|
/* Create new cancellable task */
|
||||||
task = g_task_new (self, cancellable, callback, user_data);
|
task = g_task_new (self, cancellable, callback, user_data);
|
||||||
@@ -718,16 +716,16 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
MM_CORE_ERROR_FAILED,
|
MM_CORE_ERROR_FAILED,
|
||||||
"(%s) Missing port probe for port (%s/%s)",
|
"(%s) Missing port probe for port (%s/%s)",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_subsystem (port),
|
mm_kernel_device_get_subsystem (port),
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Before launching any probing, check if the port is a net device. */
|
/* Before launching any probing, check if the port is a net device. */
|
||||||
if (g_str_equal (g_udev_device_get_subsystem (port), "net")) {
|
if (g_str_equal (mm_kernel_device_get_subsystem (port), "net")) {
|
||||||
mm_dbg ("(%s) [%s] probing deferred until result suggested",
|
mm_dbg ("(%s) [%s] probing deferred until result suggested",
|
||||||
self->priv->name, g_udev_device_get_name (port));
|
self->priv->name, mm_kernel_device_get_name (port));
|
||||||
g_task_return_int (task, MM_PLUGIN_SUPPORTS_PORT_DEFER_UNTIL_SUGGESTED);
|
g_task_return_int (task, MM_PLUGIN_SUPPORTS_PORT_DEFER_UNTIL_SUGGESTED);
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
return;
|
return;
|
||||||
@@ -735,7 +733,7 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
|
|
||||||
/* Build flags depending on what probing needed */
|
/* Build flags depending on what probing needed */
|
||||||
probe_run_flags = MM_PORT_PROBE_NONE;
|
probe_run_flags = MM_PORT_PROBE_NONE;
|
||||||
if (!g_str_has_prefix (g_udev_device_get_name (port), "cdc-wdm")) {
|
if (!g_str_has_prefix (mm_kernel_device_get_name (port), "cdc-wdm")) {
|
||||||
/* Serial ports... */
|
/* Serial ports... */
|
||||||
if (self->priv->at)
|
if (self->priv->at)
|
||||||
probe_run_flags |= MM_PORT_PROBE_AT;
|
probe_run_flags |= MM_PORT_PROBE_AT;
|
||||||
@@ -745,9 +743,9 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
probe_run_flags |= MM_PORT_PROBE_QCDM;
|
probe_run_flags |= MM_PORT_PROBE_QCDM;
|
||||||
} else {
|
} else {
|
||||||
/* cdc-wdm ports... */
|
/* cdc-wdm ports... */
|
||||||
if (self->priv->qmi && !g_strcmp0 (mm_device_utils_get_port_driver (port), "qmi_wwan"))
|
if (self->priv->qmi && !g_strcmp0 (mm_kernel_device_get_driver (port), "qmi_wwan"))
|
||||||
probe_run_flags |= MM_PORT_PROBE_QMI;
|
probe_run_flags |= MM_PORT_PROBE_QMI;
|
||||||
else if (self->priv->mbim && !g_strcmp0 (mm_device_utils_get_port_driver (port), "cdc_mbim"))
|
else if (self->priv->mbim && !g_strcmp0 (mm_kernel_device_get_driver (port), "cdc_mbim"))
|
||||||
probe_run_flags |= MM_PORT_PROBE_MBIM;
|
probe_run_flags |= MM_PORT_PROBE_MBIM;
|
||||||
else
|
else
|
||||||
probe_run_flags |= MM_PORT_PROBE_AT;
|
probe_run_flags |= MM_PORT_PROBE_AT;
|
||||||
@@ -780,7 +778,7 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
mm_dbg ("(%s) [%s] not setting up AT probing tasks: "
|
mm_dbg ("(%s) [%s] not setting up AT probing tasks: "
|
||||||
"modem already has the expected single AT port",
|
"modem already has the expected single AT port",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
mm_kernel_device_get_name (port));
|
||||||
|
|
||||||
/* Assuming it won't be an AT port. We still run the probe anyway, in
|
/* Assuming it won't be an AT port. We still run the probe anyway, in
|
||||||
* case we need to check for other port types (e.g. QCDM) */
|
* case we need to check for other port types (e.g. QCDM) */
|
||||||
@@ -800,7 +798,7 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
probe_list_str = mm_port_probe_flag_build_string_from_mask (ctx->flags);
|
probe_list_str = mm_port_probe_flag_build_string_from_mask (ctx->flags);
|
||||||
mm_dbg ("(%s) [%s] probe required: '%s'",
|
mm_dbg ("(%s) [%s] probe required: '%s'",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port),
|
mm_kernel_device_get_name (port),
|
||||||
probe_list_str);
|
probe_list_str);
|
||||||
g_free (probe_list_str);
|
g_free (probe_list_str);
|
||||||
|
|
||||||
@@ -821,7 +819,7 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
MMPluginSupportsHint
|
MMPluginSupportsHint
|
||||||
mm_plugin_discard_port_early (MMPlugin *self,
|
mm_plugin_discard_port_early (MMPlugin *self,
|
||||||
MMDevice *device,
|
MMDevice *device,
|
||||||
GUdevDevice *port)
|
MMKernelDevice *port)
|
||||||
{
|
{
|
||||||
gboolean need_vendor_probing = FALSE;
|
gboolean need_vendor_probing = FALSE;
|
||||||
gboolean need_product_probing = FALSE;
|
gboolean need_product_probing = FALSE;
|
||||||
@@ -913,7 +911,7 @@ mm_plugin_create_modem (MMPlugin *self,
|
|||||||
}
|
}
|
||||||
#if !defined WITH_QMI
|
#if !defined WITH_QMI
|
||||||
else if (mm_port_probe_get_port_type (probe) == MM_PORT_TYPE_NET &&
|
else if (mm_port_probe_get_port_type (probe) == MM_PORT_TYPE_NET &&
|
||||||
!g_strcmp0 (mm_device_utils_get_port_driver (mm_port_probe_peek_port (probe)), "qmi_wwan")) {
|
!g_strcmp0 (mm_kernel_device_get_driver (mm_port_probe_peek_port (probe)), "qmi_wwan")) {
|
||||||
/* Try to generically grab the port, but flagged as ignored */
|
/* Try to generically grab the port, but flagged as ignored */
|
||||||
grabbed = mm_base_modem_grab_port (modem,
|
grabbed = mm_base_modem_grab_port (modem,
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
@@ -926,7 +924,7 @@ mm_plugin_create_modem (MMPlugin *self,
|
|||||||
#endif
|
#endif
|
||||||
#if !defined WITH_MBIM
|
#if !defined WITH_MBIM
|
||||||
else if (mm_port_probe_get_port_type (probe) == MM_PORT_TYPE_NET &&
|
else if (mm_port_probe_get_port_type (probe) == MM_PORT_TYPE_NET &&
|
||||||
!g_strcmp0 (mm_device_utils_get_port_driver (mm_port_probe_peek_port (probe)), "cdc_mbim")) {
|
!g_strcmp0 (mm_kernel_device_get_driver (mm_port_probe_peek_port (probe)), "cdc_mbim")) {
|
||||||
/* Try to generically grab the port, but flagged as ignored */
|
/* Try to generically grab the port, but flagged as ignored */
|
||||||
grabbed = mm_base_modem_grab_port (modem,
|
grabbed = mm_base_modem_grab_port (modem,
|
||||||
mm_port_probe_get_port_subsys (probe),
|
mm_port_probe_get_port_subsys (probe),
|
||||||
|
@@ -20,12 +20,12 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <gudev/gudev.h>
|
|
||||||
|
|
||||||
#include "mm-base-modem.h"
|
#include "mm-base-modem.h"
|
||||||
#include "mm-port.h"
|
#include "mm-port.h"
|
||||||
#include "mm-port-probe.h"
|
#include "mm-port-probe.h"
|
||||||
#include "mm-device.h"
|
#include "mm-device.h"
|
||||||
|
#include "mm-kernel-device.h"
|
||||||
|
|
||||||
#define MM_PLUGIN_GENERIC_NAME "Generic"
|
#define MM_PLUGIN_GENERIC_NAME "Generic"
|
||||||
#define MM_PLUGIN_MAJOR_VERSION 4
|
#define MM_PLUGIN_MAJOR_VERSION 4
|
||||||
@@ -127,11 +127,11 @@ const gchar *mm_plugin_get_name (MMPlugin *plugin);
|
|||||||
* plugin from the probing logic as soon as possible. */
|
* plugin from the probing logic as soon as possible. */
|
||||||
MMPluginSupportsHint mm_plugin_discard_port_early (MMPlugin *plugin,
|
MMPluginSupportsHint mm_plugin_discard_port_early (MMPlugin *plugin,
|
||||||
MMDevice *device,
|
MMDevice *device,
|
||||||
GUdevDevice *port);
|
MMKernelDevice *port);
|
||||||
|
|
||||||
void mm_plugin_supports_port (MMPlugin *plugin,
|
void mm_plugin_supports_port (MMPlugin *plugin,
|
||||||
MMDevice *device,
|
MMDevice *device,
|
||||||
GUdevDevice *port,
|
MMKernelDevice *port,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
@@ -74,8 +74,7 @@ static GParamSpec *properties[PROP_LAST];
|
|||||||
struct _MMPortProbePrivate {
|
struct _MMPortProbePrivate {
|
||||||
/* Properties */
|
/* Properties */
|
||||||
MMDevice *device;
|
MMDevice *device;
|
||||||
GUdevDevice *port;
|
MMKernelDevice *port;
|
||||||
GUdevDevice *parent;
|
|
||||||
|
|
||||||
/* Probing results */
|
/* Probing results */
|
||||||
guint32 flags;
|
guint32 flags;
|
||||||
@@ -151,8 +150,8 @@ mm_port_probe_set_result_at (MMPortProbe *self,
|
|||||||
|
|
||||||
if (self->priv->is_at) {
|
if (self->priv->is_at) {
|
||||||
mm_dbg ("(%s/%s) port is AT-capable",
|
mm_dbg ("(%s/%s) port is AT-capable",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
|
|
||||||
/* Also set as not a QCDM/QMI/MBIM port */
|
/* Also set as not a QCDM/QMI/MBIM port */
|
||||||
self->priv->is_qcdm = FALSE;
|
self->priv->is_qcdm = FALSE;
|
||||||
@@ -161,8 +160,8 @@ mm_port_probe_set_result_at (MMPortProbe *self,
|
|||||||
self->priv->flags |= (MM_PORT_PROBE_QCDM | MM_PORT_PROBE_QMI | MM_PORT_PROBE_MBIM);
|
self->priv->flags |= (MM_PORT_PROBE_QCDM | MM_PORT_PROBE_QMI | MM_PORT_PROBE_MBIM);
|
||||||
} else {
|
} else {
|
||||||
mm_dbg ("(%s/%s) port is not AT-capable",
|
mm_dbg ("(%s/%s) port is not AT-capable",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
self->priv->vendor = NULL;
|
self->priv->vendor = NULL;
|
||||||
self->priv->product = NULL;
|
self->priv->product = NULL;
|
||||||
self->priv->is_icera = FALSE;
|
self->priv->is_icera = FALSE;
|
||||||
@@ -178,14 +177,14 @@ mm_port_probe_set_result_at_vendor (MMPortProbe *self,
|
|||||||
{
|
{
|
||||||
if (at_vendor) {
|
if (at_vendor) {
|
||||||
mm_dbg ("(%s/%s) vendor probing finished",
|
mm_dbg ("(%s/%s) vendor probing finished",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
self->priv->vendor = g_utf8_casefold (at_vendor, -1);
|
self->priv->vendor = g_utf8_casefold (at_vendor, -1);
|
||||||
self->priv->flags |= MM_PORT_PROBE_AT_VENDOR;
|
self->priv->flags |= MM_PORT_PROBE_AT_VENDOR;
|
||||||
} else {
|
} else {
|
||||||
mm_dbg ("(%s/%s) couldn't probe for vendor string",
|
mm_dbg ("(%s/%s) couldn't probe for vendor string",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
self->priv->vendor = NULL;
|
self->priv->vendor = NULL;
|
||||||
self->priv->product = NULL;
|
self->priv->product = NULL;
|
||||||
self->priv->flags |= (MM_PORT_PROBE_AT_VENDOR | MM_PORT_PROBE_AT_PRODUCT);
|
self->priv->flags |= (MM_PORT_PROBE_AT_VENDOR | MM_PORT_PROBE_AT_PRODUCT);
|
||||||
@@ -198,14 +197,14 @@ mm_port_probe_set_result_at_product (MMPortProbe *self,
|
|||||||
{
|
{
|
||||||
if (at_product) {
|
if (at_product) {
|
||||||
mm_dbg ("(%s/%s) product probing finished",
|
mm_dbg ("(%s/%s) product probing finished",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
self->priv->product = g_utf8_casefold (at_product, -1);
|
self->priv->product = g_utf8_casefold (at_product, -1);
|
||||||
self->priv->flags |= MM_PORT_PROBE_AT_PRODUCT;
|
self->priv->flags |= MM_PORT_PROBE_AT_PRODUCT;
|
||||||
} else {
|
} else {
|
||||||
mm_dbg ("(%s/%s) couldn't probe for product string",
|
mm_dbg ("(%s/%s) couldn't probe for product string",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
self->priv->product = NULL;
|
self->priv->product = NULL;
|
||||||
self->priv->flags |= MM_PORT_PROBE_AT_PRODUCT;
|
self->priv->flags |= MM_PORT_PROBE_AT_PRODUCT;
|
||||||
}
|
}
|
||||||
@@ -217,14 +216,14 @@ mm_port_probe_set_result_at_icera (MMPortProbe *self,
|
|||||||
{
|
{
|
||||||
if (is_icera) {
|
if (is_icera) {
|
||||||
mm_dbg ("(%s/%s) Modem is Icera-based",
|
mm_dbg ("(%s/%s) Modem is Icera-based",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
self->priv->is_icera = TRUE;
|
self->priv->is_icera = TRUE;
|
||||||
self->priv->flags |= MM_PORT_PROBE_AT_ICERA;
|
self->priv->flags |= MM_PORT_PROBE_AT_ICERA;
|
||||||
} else {
|
} else {
|
||||||
mm_dbg ("(%s/%s) Modem is probably not Icera-based",
|
mm_dbg ("(%s/%s) Modem is probably not Icera-based",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
self->priv->is_icera = FALSE;
|
self->priv->is_icera = FALSE;
|
||||||
self->priv->flags |= MM_PORT_PROBE_AT_ICERA;
|
self->priv->flags |= MM_PORT_PROBE_AT_ICERA;
|
||||||
}
|
}
|
||||||
@@ -239,8 +238,8 @@ mm_port_probe_set_result_qcdm (MMPortProbe *self,
|
|||||||
|
|
||||||
if (self->priv->is_qcdm) {
|
if (self->priv->is_qcdm) {
|
||||||
mm_dbg ("(%s/%s) port is QCDM-capable",
|
mm_dbg ("(%s/%s) port is QCDM-capable",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
|
|
||||||
/* Also set as not an AT/QMI/MBIM port */
|
/* Also set as not an AT/QMI/MBIM port */
|
||||||
self->priv->is_at = FALSE;
|
self->priv->is_at = FALSE;
|
||||||
@@ -257,8 +256,8 @@ mm_port_probe_set_result_qcdm (MMPortProbe *self,
|
|||||||
MM_PORT_PROBE_MBIM);
|
MM_PORT_PROBE_MBIM);
|
||||||
} else
|
} else
|
||||||
mm_dbg ("(%s/%s) port is not QCDM-capable",
|
mm_dbg ("(%s/%s) port is not QCDM-capable",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -270,8 +269,8 @@ mm_port_probe_set_result_qmi (MMPortProbe *self,
|
|||||||
|
|
||||||
if (self->priv->is_qmi) {
|
if (self->priv->is_qmi) {
|
||||||
mm_dbg ("(%s/%s) port is QMI-capable",
|
mm_dbg ("(%s/%s) port is QMI-capable",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
|
|
||||||
/* Also set as not an AT/QCDM/MBIM port */
|
/* Also set as not an AT/QCDM/MBIM port */
|
||||||
self->priv->is_at = FALSE;
|
self->priv->is_at = FALSE;
|
||||||
@@ -287,8 +286,8 @@ mm_port_probe_set_result_qmi (MMPortProbe *self,
|
|||||||
MM_PORT_PROBE_MBIM);
|
MM_PORT_PROBE_MBIM);
|
||||||
} else
|
} else
|
||||||
mm_dbg ("(%s/%s) port is not QMI-capable",
|
mm_dbg ("(%s/%s) port is not QMI-capable",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -300,8 +299,8 @@ mm_port_probe_set_result_mbim (MMPortProbe *self,
|
|||||||
|
|
||||||
if (self->priv->is_mbim) {
|
if (self->priv->is_mbim) {
|
||||||
mm_dbg ("(%s/%s) port is MBIM-capable",
|
mm_dbg ("(%s/%s) port is MBIM-capable",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
|
|
||||||
/* Also set as not an AT/QCDM/QMI port */
|
/* Also set as not an AT/QCDM/QMI port */
|
||||||
self->priv->is_at = FALSE;
|
self->priv->is_at = FALSE;
|
||||||
@@ -317,8 +316,8 @@ mm_port_probe_set_result_mbim (MMPortProbe *self,
|
|||||||
MM_PORT_PROBE_QMI);
|
MM_PORT_PROBE_QMI);
|
||||||
} else
|
} else
|
||||||
mm_dbg ("(%s/%s) port is not MBIM-capable",
|
mm_dbg ("(%s/%s) port is not MBIM-capable",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -445,8 +444,8 @@ port_qmi_open_ready (MMPortQmi *port_qmi,
|
|||||||
is_qmi = mm_port_qmi_open_finish (port_qmi, res, &error);
|
is_qmi = mm_port_qmi_open_finish (port_qmi, res, &error);
|
||||||
if (!is_qmi) {
|
if (!is_qmi) {
|
||||||
mm_dbg ("(%s/%s) error checking QMI support: '%s'",
|
mm_dbg ("(%s/%s) error checking QMI support: '%s'",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port),
|
mm_kernel_device_get_name (self->priv->port),
|
||||||
error ? error->message : "unknown error");
|
error ? error->message : "unknown error");
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
@@ -471,11 +470,11 @@ wdm_probe_qmi (MMPortProbe *self)
|
|||||||
|
|
||||||
#if defined WITH_QMI
|
#if defined WITH_QMI
|
||||||
mm_dbg ("(%s/%s) probing QMI...",
|
mm_dbg ("(%s/%s) probing QMI...",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
|
|
||||||
/* Create a port and try to open it */
|
/* Create a port and try to open it */
|
||||||
ctx->port_qmi = mm_port_qmi_new (g_udev_device_get_name (self->priv->port));
|
ctx->port_qmi = mm_port_qmi_new (mm_kernel_device_get_name (self->priv->port));
|
||||||
mm_port_qmi_open (ctx->port_qmi,
|
mm_port_qmi_open (ctx->port_qmi,
|
||||||
FALSE,
|
FALSE,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -521,8 +520,8 @@ mbim_port_open_ready (MMPortMbim *mbim_port,
|
|||||||
is_mbim = mm_port_mbim_open_finish (mbim_port, res, &error);
|
is_mbim = mm_port_mbim_open_finish (mbim_port, res, &error);
|
||||||
if (!is_mbim) {
|
if (!is_mbim) {
|
||||||
mm_dbg ("(%s/%s) error checking MBIM support: '%s'",
|
mm_dbg ("(%s/%s) error checking MBIM support: '%s'",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port),
|
mm_kernel_device_get_name (self->priv->port),
|
||||||
error ? error->message : "unknown error");
|
error ? error->message : "unknown error");
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
@@ -547,11 +546,11 @@ wdm_probe_mbim (MMPortProbe *self)
|
|||||||
|
|
||||||
#if defined WITH_MBIM
|
#if defined WITH_MBIM
|
||||||
mm_dbg ("(%s/%s) probing MBIM...",
|
mm_dbg ("(%s/%s) probing MBIM...",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
|
|
||||||
/* Create a port and try to open it */
|
/* Create a port and try to open it */
|
||||||
ctx->mbim_port = mm_port_mbim_new (g_udev_device_get_name (self->priv->port));
|
ctx->mbim_port = mm_port_mbim_new (mm_kernel_device_get_name (self->priv->port));
|
||||||
mm_port_mbim_open (ctx->mbim_port,
|
mm_port_mbim_open (ctx->mbim_port,
|
||||||
NULL,
|
NULL,
|
||||||
(GAsyncReadyCallback) mbim_port_open_ready,
|
(GAsyncReadyCallback) mbim_port_open_ready,
|
||||||
@@ -623,8 +622,8 @@ serial_probe_qcdm_parse_response (MMPortSerialQcdm *port,
|
|||||||
result = qcdm_cmd_version_info_result ((const gchar *) response->data, response->len, &err);
|
result = qcdm_cmd_version_info_result ((const gchar *) response->data, response->len, &err);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
mm_warn ("(%s/%s) failed to parse QCDM version info command result: %d",
|
mm_warn ("(%s/%s) failed to parse QCDM version info command result: %d",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port),
|
mm_kernel_device_get_name (self->priv->port),
|
||||||
err);
|
err);
|
||||||
retry = TRUE;
|
retry = TRUE;
|
||||||
} else {
|
} else {
|
||||||
@@ -687,8 +686,8 @@ serial_probe_qcdm (MMPortProbe *self)
|
|||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
|
|
||||||
mm_dbg ("(%s/%s) probing QCDM...",
|
mm_dbg ("(%s/%s) probing QCDM...",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
|
|
||||||
/* If open, close the AT port */
|
/* If open, close the AT port */
|
||||||
if (ctx->serial) {
|
if (ctx->serial) {
|
||||||
@@ -702,14 +701,14 @@ serial_probe_qcdm (MMPortProbe *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Open the QCDM port */
|
/* Open the QCDM port */
|
||||||
ctx->serial = MM_PORT_SERIAL (mm_port_serial_qcdm_new (g_udev_device_get_name (self->priv->port)));
|
ctx->serial = MM_PORT_SERIAL (mm_port_serial_qcdm_new (mm_kernel_device_get_name (self->priv->port)));
|
||||||
if (!ctx->serial) {
|
if (!ctx->serial) {
|
||||||
port_probe_task_return_error (self,
|
port_probe_task_return_error (self,
|
||||||
g_error_new (MM_CORE_ERROR,
|
g_error_new (MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_FAILED,
|
MM_CORE_ERROR_FAILED,
|
||||||
"(%s/%s) Couldn't create QCDM port",
|
"(%s/%s) Couldn't create QCDM port",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port)));
|
mm_kernel_device_get_name (self->priv->port)));
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,8 +718,8 @@ serial_probe_qcdm (MMPortProbe *self)
|
|||||||
g_error_new (MM_SERIAL_ERROR,
|
g_error_new (MM_SERIAL_ERROR,
|
||||||
MM_SERIAL_ERROR_OPEN_FAILED,
|
MM_SERIAL_ERROR_OPEN_FAILED,
|
||||||
"(%s/%s) Failed to open QCDM port: %s",
|
"(%s/%s) Failed to open QCDM port: %s",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port),
|
mm_kernel_device_get_name (self->priv->port),
|
||||||
(error ? error->message : "unknown error")));
|
(error ? error->message : "unknown error")));
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
@@ -739,9 +738,9 @@ serial_probe_qcdm (MMPortProbe *self)
|
|||||||
port_probe_task_return_error (self,
|
port_probe_task_return_error (self,
|
||||||
g_error_new (MM_SERIAL_ERROR,
|
g_error_new (MM_SERIAL_ERROR,
|
||||||
MM_SERIAL_ERROR_OPEN_FAILED,
|
MM_SERIAL_ERROR_OPEN_FAILED,
|
||||||
"(%s/%s) Failed to create QCDM versin info command",
|
"(%s/%s) Failed to create QCDM version info command",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port)));
|
mm_kernel_device_get_name (self->priv->port)));
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
verinfo->len = len + 1;
|
verinfo->len = len + 1;
|
||||||
@@ -899,8 +898,8 @@ serial_probe_at_parse_response (MMPortSerialAt *port,
|
|||||||
/* If AT probing cancelled, end this partial probing */
|
/* If AT probing cancelled, end this partial probing */
|
||||||
if (g_cancellable_is_cancelled (ctx->at_probing_cancellable)) {
|
if (g_cancellable_is_cancelled (ctx->at_probing_cancellable)) {
|
||||||
mm_dbg ("(%s/%s) no need to keep on probing the port for AT support",
|
mm_dbg ("(%s/%s) no need to keep on probing the port for AT support",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
ctx->at_result_processor (self, NULL);
|
ctx->at_result_processor (self, NULL);
|
||||||
serial_probe_schedule (self);
|
serial_probe_schedule (self);
|
||||||
return;
|
return;
|
||||||
@@ -920,8 +919,8 @@ serial_probe_at_parse_response (MMPortSerialAt *port,
|
|||||||
g_error_new (MM_CORE_ERROR,
|
g_error_new (MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
MM_CORE_ERROR_UNSUPPORTED,
|
||||||
"(%s/%s) error while probing AT features: %s",
|
"(%s/%s) error while probing AT features: %s",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port),
|
mm_kernel_device_get_name (self->priv->port),
|
||||||
result_error->message));
|
result_error->message));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -942,8 +941,8 @@ serial_probe_at_parse_response (MMPortSerialAt *port,
|
|||||||
ctx->source_id = g_idle_add ((GSourceFunc) serial_probe_at, self);
|
ctx->source_id = g_idle_add ((GSourceFunc) serial_probe_at, self);
|
||||||
else {
|
else {
|
||||||
mm_dbg ("(%s/%s) re-scheduling next command in probing group in %u seconds...",
|
mm_dbg ("(%s/%s) re-scheduling next command in probing group in %u seconds...",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port),
|
mm_kernel_device_get_name (self->priv->port),
|
||||||
ctx->at_commands_wait_secs);
|
ctx->at_commands_wait_secs);
|
||||||
ctx->source_id = g_timeout_add_seconds (ctx->at_commands_wait_secs, (GSourceFunc) serial_probe_at, self);
|
ctx->source_id = g_timeout_add_seconds (ctx->at_commands_wait_secs, (GSourceFunc) serial_probe_at, self);
|
||||||
}
|
}
|
||||||
@@ -979,8 +978,8 @@ serial_probe_at (MMPortProbe *self)
|
|||||||
/* If AT probing cancelled, end this partial probing */
|
/* If AT probing cancelled, end this partial probing */
|
||||||
if (g_cancellable_is_cancelled (ctx->at_probing_cancellable)) {
|
if (g_cancellable_is_cancelled (ctx->at_probing_cancellable)) {
|
||||||
mm_dbg ("(%s/%s) no need to launch probing for AT support",
|
mm_dbg ("(%s/%s) no need to launch probing for AT support",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
ctx->at_result_processor (self, NULL);
|
ctx->at_result_processor (self, NULL);
|
||||||
serial_probe_schedule (self);
|
serial_probe_schedule (self);
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
@@ -1156,8 +1155,8 @@ serial_buffer_full (MMPortSerial *serial,
|
|||||||
ctx = g_task_get_task_data (self->priv->task);
|
ctx = g_task_get_task_data (self->priv->task);
|
||||||
|
|
||||||
mm_dbg ("(%s/%s) serial buffer full",
|
mm_dbg ("(%s/%s) serial buffer full",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
/* Don't explicitly close the AT port, just end the AT probing
|
/* Don't explicitly close the AT port, just end the AT probing
|
||||||
* (or custom init probing) */
|
* (or custom init probing) */
|
||||||
mm_port_probe_set_result_at (self, FALSE);
|
mm_port_probe_set_result_at (self, FALSE);
|
||||||
@@ -1200,17 +1199,17 @@ serial_open_at (MMPortProbe *self)
|
|||||||
gpointer parser;
|
gpointer parser;
|
||||||
MMPortSubsys subsys = MM_PORT_SUBSYS_TTY;
|
MMPortSubsys subsys = MM_PORT_SUBSYS_TTY;
|
||||||
|
|
||||||
if (g_str_has_prefix (g_udev_device_get_subsystem (self->priv->port), "usb"))
|
if (g_str_has_prefix (mm_kernel_device_get_subsystem (self->priv->port), "usb"))
|
||||||
subsys = MM_PORT_SUBSYS_USB;
|
subsys = MM_PORT_SUBSYS_USB;
|
||||||
|
|
||||||
ctx->serial = MM_PORT_SERIAL (mm_port_serial_at_new (g_udev_device_get_name (self->priv->port), subsys));
|
ctx->serial = MM_PORT_SERIAL (mm_port_serial_at_new (mm_kernel_device_get_name (self->priv->port), subsys));
|
||||||
if (!ctx->serial) {
|
if (!ctx->serial) {
|
||||||
port_probe_task_return_error (self,
|
port_probe_task_return_error (self,
|
||||||
g_error_new (MM_CORE_ERROR,
|
g_error_new (MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_FAILED,
|
MM_CORE_ERROR_FAILED,
|
||||||
"(%s/%s) couldn't create AT port",
|
"(%s/%s) couldn't create AT port",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port)));
|
mm_kernel_device_get_name (self->priv->port)));
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1240,8 +1239,8 @@ serial_open_at (MMPortProbe *self)
|
|||||||
g_error_new (MM_CORE_ERROR,
|
g_error_new (MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_FAILED,
|
MM_CORE_ERROR_FAILED,
|
||||||
"(%s/%s) failed to open port after 4 tries",
|
"(%s/%s) failed to open port after 4 tries",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port)));
|
mm_kernel_device_get_name (self->priv->port)));
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
@@ -1257,8 +1256,8 @@ serial_open_at (MMPortProbe *self)
|
|||||||
g_error_new (MM_SERIAL_ERROR,
|
g_error_new (MM_SERIAL_ERROR,
|
||||||
MM_SERIAL_ERROR_OPEN_FAILED,
|
MM_SERIAL_ERROR_OPEN_FAILED,
|
||||||
"(%s/%s) failed to open port: %s",
|
"(%s/%s) failed to open port: %s",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port),
|
mm_kernel_device_get_name (self->priv->port),
|
||||||
(error ? error->message : "unknown error")));
|
(error ? error->message : "unknown error")));
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
@@ -1297,8 +1296,8 @@ mm_port_probe_run_cancel_at_probing (MMPortProbe *self)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
mm_dbg ("(%s/%s) requested to cancel all AT probing",
|
mm_dbg ("(%s/%s) requested to cancel all AT probing",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
g_cancellable_cancel (ctx->at_probing_cancellable);
|
g_cancellable_cancel (ctx->at_probing_cancellable);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1363,8 +1362,8 @@ mm_port_probe_run (MMPortProbe *self,
|
|||||||
/* All requested probings already available? If so, we're done */
|
/* All requested probings already available? If so, we're done */
|
||||||
if (!ctx->flags) {
|
if (!ctx->flags) {
|
||||||
mm_dbg ("(%s/%s) port probing finished: no more probings needed",
|
mm_dbg ("(%s/%s) port probing finished: no more probings needed",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port));
|
mm_kernel_device_get_name (self->priv->port));
|
||||||
port_probe_task_return_boolean (self, TRUE);
|
port_probe_task_return_boolean (self, TRUE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1372,8 +1371,8 @@ mm_port_probe_run (MMPortProbe *self,
|
|||||||
/* Log the probes scheduled to be run */
|
/* Log the probes scheduled to be run */
|
||||||
probe_list_str = mm_port_probe_flag_build_string_from_mask (ctx->flags);
|
probe_list_str = mm_port_probe_flag_build_string_from_mask (ctx->flags);
|
||||||
mm_dbg ("(%s/%s) launching port probing: '%s'",
|
mm_dbg ("(%s/%s) launching port probing: '%s'",
|
||||||
g_udev_device_get_subsystem (self->priv->port),
|
mm_kernel_device_get_subsystem (self->priv->port),
|
||||||
g_udev_device_get_name (self->priv->port),
|
mm_kernel_device_get_name (self->priv->port),
|
||||||
probe_list_str);
|
probe_list_str);
|
||||||
g_free (probe_list_str);
|
g_free (probe_list_str);
|
||||||
|
|
||||||
@@ -1417,8 +1416,8 @@ mm_port_probe_is_at (MMPortProbe *self)
|
|||||||
|
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (self->priv->port);
|
subsys = mm_kernel_device_get_subsystem (self->priv->port);
|
||||||
name = g_udev_device_get_name (self->priv->port);
|
name = mm_kernel_device_get_name (self->priv->port);
|
||||||
if (g_str_equal (subsys, "net"))
|
if (g_str_equal (subsys, "net"))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -1452,8 +1451,8 @@ mm_port_probe_is_qcdm (MMPortProbe *self)
|
|||||||
|
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (self->priv->port);
|
subsys = mm_kernel_device_get_subsystem (self->priv->port);
|
||||||
name = g_udev_device_get_name (self->priv->port);
|
name = mm_kernel_device_get_name (self->priv->port);
|
||||||
if (g_str_equal (subsys, "net") ||
|
if (g_str_equal (subsys, "net") ||
|
||||||
(g_str_has_prefix (subsys, "usb") &&
|
(g_str_has_prefix (subsys, "usb") &&
|
||||||
g_str_has_prefix (name, "cdc-wdm")))
|
g_str_has_prefix (name, "cdc-wdm")))
|
||||||
@@ -1472,8 +1471,8 @@ mm_port_probe_is_qmi (MMPortProbe *self)
|
|||||||
|
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (self->priv->port);
|
subsys = mm_kernel_device_get_subsystem (self->priv->port);
|
||||||
name = g_udev_device_get_name (self->priv->port);
|
name = mm_kernel_device_get_name (self->priv->port);
|
||||||
if (!g_str_has_prefix (subsys, "usb") ||
|
if (!g_str_has_prefix (subsys, "usb") ||
|
||||||
!name ||
|
!name ||
|
||||||
!g_str_has_prefix (name, "cdc-wdm"))
|
!g_str_has_prefix (name, "cdc-wdm"))
|
||||||
@@ -1506,8 +1505,8 @@ mm_port_probe_is_mbim (MMPortProbe *self)
|
|||||||
|
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (self->priv->port);
|
subsys = mm_kernel_device_get_subsystem (self->priv->port);
|
||||||
name = g_udev_device_get_name (self->priv->port);
|
name = mm_kernel_device_get_name (self->priv->port);
|
||||||
if (!g_str_has_prefix (subsys, "usb") ||
|
if (!g_str_has_prefix (subsys, "usb") ||
|
||||||
!name ||
|
!name ||
|
||||||
!g_str_has_prefix (name, "cdc-wdm"))
|
!g_str_has_prefix (name, "cdc-wdm"))
|
||||||
@@ -1540,8 +1539,8 @@ mm_port_probe_get_port_type (MMPortProbe *self)
|
|||||||
|
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (self->priv->port);
|
subsys = mm_kernel_device_get_subsystem (self->priv->port);
|
||||||
name = g_udev_device_get_name (self->priv->port);
|
name = mm_kernel_device_get_name (self->priv->port);
|
||||||
|
|
||||||
if (g_str_equal (subsys, "net"))
|
if (g_str_equal (subsys, "net"))
|
||||||
return MM_PORT_TYPE_NET;
|
return MM_PORT_TYPE_NET;
|
||||||
@@ -1587,7 +1586,7 @@ mm_port_probe_get_device (MMPortProbe *self)
|
|||||||
return MM_DEVICE (g_object_ref (self->priv->device));
|
return MM_DEVICE (g_object_ref (self->priv->device));
|
||||||
}
|
}
|
||||||
|
|
||||||
GUdevDevice *
|
MMKernelDevice *
|
||||||
mm_port_probe_peek_port (MMPortProbe *self)
|
mm_port_probe_peek_port (MMPortProbe *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
||||||
@@ -1595,12 +1594,12 @@ mm_port_probe_peek_port (MMPortProbe *self)
|
|||||||
return self->priv->port;
|
return self->priv->port;
|
||||||
};
|
};
|
||||||
|
|
||||||
GUdevDevice *
|
MMKernelDevice *
|
||||||
mm_port_probe_get_port (MMPortProbe *self)
|
mm_port_probe_get_port (MMPortProbe *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
||||||
|
|
||||||
return G_UDEV_DEVICE (g_object_ref (self->priv->port));
|
return MM_KERNEL_DEVICE (g_object_ref (self->priv->port));
|
||||||
};
|
};
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
@@ -1611,8 +1610,8 @@ mm_port_probe_get_vendor (MMPortProbe *self)
|
|||||||
|
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (self->priv->port);
|
subsys = mm_kernel_device_get_subsystem (self->priv->port);
|
||||||
name = g_udev_device_get_name (self->priv->port);
|
name = mm_kernel_device_get_name (self->priv->port);
|
||||||
if (g_str_equal (subsys, "net") ||
|
if (g_str_equal (subsys, "net") ||
|
||||||
(g_str_has_prefix (subsys, "usb") &&
|
(g_str_has_prefix (subsys, "usb") &&
|
||||||
g_str_has_prefix (name, "cdc-wdm")))
|
g_str_has_prefix (name, "cdc-wdm")))
|
||||||
@@ -1631,8 +1630,8 @@ mm_port_probe_get_product (MMPortProbe *self)
|
|||||||
|
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (self->priv->port);
|
subsys = mm_kernel_device_get_subsystem (self->priv->port);
|
||||||
name = g_udev_device_get_name (self->priv->port);
|
name = mm_kernel_device_get_name (self->priv->port);
|
||||||
if (g_str_equal (subsys, "net") ||
|
if (g_str_equal (subsys, "net") ||
|
||||||
(g_str_has_prefix (subsys, "usb") &&
|
(g_str_has_prefix (subsys, "usb") &&
|
||||||
g_str_has_prefix (name, "cdc-wdm")))
|
g_str_has_prefix (name, "cdc-wdm")))
|
||||||
@@ -1648,7 +1647,7 @@ mm_port_probe_is_icera (MMPortProbe *self)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
||||||
|
|
||||||
if (g_str_equal (g_udev_device_get_subsystem (self->priv->port), "net"))
|
if (g_str_equal (mm_kernel_device_get_subsystem (self->priv->port), "net"))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return (self->priv->flags & MM_PORT_PROBE_AT_ICERA ?
|
return (self->priv->flags & MM_PORT_PROBE_AT_ICERA ?
|
||||||
@@ -1682,7 +1681,7 @@ mm_port_probe_get_port_name (MMPortProbe *self)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
||||||
|
|
||||||
return g_udev_device_get_name (self->priv->port);
|
return mm_kernel_device_get_name (self->priv->port);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
@@ -1690,7 +1689,7 @@ mm_port_probe_get_port_subsys (MMPortProbe *self)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
||||||
|
|
||||||
return g_udev_device_get_subsystem (self->priv->port);
|
return mm_kernel_device_get_subsystem (self->priv->port);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
@@ -1698,14 +1697,14 @@ mm_port_probe_get_parent_path (MMPortProbe *self)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
||||||
|
|
||||||
return (self->priv->parent ? g_udev_device_get_sysfs_path (self->priv->parent) : NULL);
|
return mm_kernel_device_get_parent_sysfs_path (self->priv->port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
MMPortProbe *
|
MMPortProbe *
|
||||||
mm_port_probe_new (MMDevice *device,
|
mm_port_probe_new (MMDevice *device,
|
||||||
GUdevDevice *port)
|
MMKernelDevice *port)
|
||||||
{
|
{
|
||||||
return MM_PORT_PROBE (g_object_new (MM_TYPE_PORT_PROBE,
|
return MM_PORT_PROBE (g_object_new (MM_TYPE_PORT_PROBE,
|
||||||
MM_PORT_PROBE_DEVICE, device,
|
MM_PORT_PROBE_DEVICE, device,
|
||||||
@@ -1737,8 +1736,7 @@ set_property (GObject *object,
|
|||||||
case PROP_PORT:
|
case PROP_PORT:
|
||||||
/* construct only */
|
/* construct only */
|
||||||
self->priv->port = g_value_dup_object (value);
|
self->priv->port = g_value_dup_object (value);
|
||||||
self->priv->parent = g_udev_device_get_parent (self->priv->port);
|
self->priv->is_ignored = mm_kernel_device_get_property_as_boolean (self->priv->port, "ID_MM_PORT_IGNORE");
|
||||||
self->priv->is_ignored = g_udev_device_get_property_as_boolean (self->priv->port, "ID_MM_PORT_IGNORE");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@@ -1789,7 +1787,6 @@ dispose (GObject *object)
|
|||||||
/* We didn't get a reference to the device */
|
/* We didn't get a reference to the device */
|
||||||
self->priv->device = NULL;
|
self->priv->device = NULL;
|
||||||
|
|
||||||
g_clear_object (&self->priv->parent);
|
|
||||||
g_clear_object (&self->priv->port);
|
g_clear_object (&self->priv->port);
|
||||||
|
|
||||||
G_OBJECT_CLASS (mm_port_probe_parent_class)->dispose (object);
|
G_OBJECT_CLASS (mm_port_probe_parent_class)->dispose (object);
|
||||||
@@ -1819,8 +1816,8 @@ mm_port_probe_class_init (MMPortProbeClass *klass)
|
|||||||
properties[PROP_PORT] =
|
properties[PROP_PORT] =
|
||||||
g_param_spec_object (MM_PORT_PROBE_PORT,
|
g_param_spec_object (MM_PORT_PROBE_PORT,
|
||||||
"Port",
|
"Port",
|
||||||
"UDev device object of the port",
|
"kernel device object of the port",
|
||||||
G_UDEV_TYPE_DEVICE,
|
MM_TYPE_KERNEL_DEVICE,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||||
g_object_class_install_property (object_class, PROP_PORT, properties[PROP_PORT]);
|
g_object_class_install_property (object_class, PROP_PORT, properties[PROP_PORT]);
|
||||||
}
|
}
|
||||||
|
@@ -21,11 +21,11 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gudev/gudev.h>
|
|
||||||
|
|
||||||
#include "mm-private-boxed-types.h"
|
#include "mm-private-boxed-types.h"
|
||||||
#include "mm-port-probe-at.h"
|
#include "mm-port-probe-at.h"
|
||||||
#include "mm-port-serial-at.h"
|
#include "mm-port-serial-at.h"
|
||||||
|
#include "mm-kernel-device.h"
|
||||||
#include "mm-device.h"
|
#include "mm-device.h"
|
||||||
|
|
||||||
#define MM_TYPE_PORT_PROBE (mm_port_probe_get_type ())
|
#define MM_TYPE_PORT_PROBE (mm_port_probe_get_type ())
|
||||||
@@ -79,12 +79,12 @@ typedef gboolean (* MMPortProbeAtCustomInitFinish) (MMPortProbe *probe,
|
|||||||
GType mm_port_probe_get_type (void);
|
GType mm_port_probe_get_type (void);
|
||||||
|
|
||||||
MMPortProbe *mm_port_probe_new (MMDevice *device,
|
MMPortProbe *mm_port_probe_new (MMDevice *device,
|
||||||
GUdevDevice *port);
|
MMKernelDevice *port);
|
||||||
|
|
||||||
MMDevice *mm_port_probe_peek_device (MMPortProbe *self);
|
MMDevice *mm_port_probe_peek_device (MMPortProbe *self);
|
||||||
MMDevice *mm_port_probe_get_device (MMPortProbe *self);
|
MMDevice *mm_port_probe_get_device (MMPortProbe *self);
|
||||||
GUdevDevice *mm_port_probe_peek_port (MMPortProbe *self);
|
MMKernelDevice *mm_port_probe_peek_port (MMPortProbe *self);
|
||||||
GUdevDevice *mm_port_probe_get_port (MMPortProbe *self);
|
MMKernelDevice *mm_port_probe_get_port (MMPortProbe *self);
|
||||||
const gchar *mm_port_probe_get_port_name (MMPortProbe *self);
|
const gchar *mm_port_probe_get_port_name (MMPortProbe *self);
|
||||||
const gchar *mm_port_probe_get_port_subsys (MMPortProbe *self);
|
const gchar *mm_port_probe_get_port_subsys (MMPortProbe *self);
|
||||||
const gchar *mm_port_probe_get_parent_path (MMPortProbe *self);
|
const gchar *mm_port_probe_get_parent_path (MMPortProbe *self);
|
||||||
|
Reference in New Issue
Block a user