[PATCH] kernel-device: device-specific properties in either port or physdev

Dan Williams dcbw at redhat.com
Tue Mar 21 21:08:59 UTC 2017


On Sat, 2017-03-11 at 13:00 +0100, Aleksander Morgado wrote:
> There are 2 main types of udev properties: device-specific and
> port-specific.
> 
> The port-specific properties are set independently per port (e.g.
> port
> type hints set per interface number for a given vid:pid).
> 
> The device-specific properties apply to all ports in the device. Some
> of these properties are currently expected in the physical device
> (e.g. ID_MM_PLATFORM_DRIVER_PROBE) while some others are expected in
> each port (e.g. the plugin udev tag filters).
> 
> This patch tries to simplify the logic and just assume that the
> device
> specific tags may be given in either the physical device or the port
> device, by providing separate APIs to retrieve port-specific or
> device-specific (global) properties. If the same tag is given in both
> the device and the port, the one in the device takes preference.
> 
> For the generic backend, these new APIs are really useless, as all
> device-specific and port-specific properties are always stored in the
> port object themselves (there is no 'tree' of devices in the generic
> backend, no 'physdev' device).
> 
> For the udev backend, though, there really is a difference, as the
> tags may be set in port or device.
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=100156
> ---
> 
> Hey Dan, Ben and everyone,
> 
> The rationale for this is that we may want to have udev rules that
> apply to all ports in a device one by one, or udev rules that apply
> only to the physical device object, and in both cases they should be
> treated in the same way.
> 
> This patch therefore differenciates between port-specific and device-
> specific tags when the program reads them.
> 
> What does everyone think?

LGTM.

Dan

> P.S.: We should probably also have some documentation explaining what
> each udev tag does...
> 
> ---
>  plugins/dell/mm-plugin-dell.c               |   2 +-
>  plugins/huawei/mm-broadband-modem-huawei.c  |   2 +-
>  plugins/huawei/mm-plugin-huawei.c           |   2 +-
>  plugins/simtech/mm-plugin-simtech.c         |   2 +-
>  plugins/telit/mm-common-telit.c             |   2 +-
>  plugins/zte/mm-plugin-zte.c                 |   2 +-
>  src/kerneldevice/mm-kernel-device-generic.c |   7 ++
>  src/kerneldevice/mm-kernel-device-udev.c    | 160
> ++++++++++++++++++++++------
>  src/kerneldevice/mm-kernel-device.c         |  55 ++++++++++
>  src/kerneldevice/mm-kernel-device.h         |  14 +++
>  src/mm-plugin.c                             |   4 +-
>  11 files changed, 213 insertions(+), 39 deletions(-)
> 
> diff --git a/plugins/dell/mm-plugin-dell.c b/plugins/dell/mm-plugin-
> dell.c
> index 5efcb192..f9dfd1a6 100644
> --- a/plugins/dell/mm-plugin-dell.c
> +++ b/plugins/dell/mm-plugin-dell.c
> @@ -342,7 +342,7 @@ dell_custom_init (MMPortProbe *probe,
> 
>      /* Dell-branded Telit modems always answer to +GMI
>       * Avoid +CGMI and ATI sending for minimizing port probing time
> */
> -    if (mm_kernel_device_get_property_as_boolean (port_device,
> "ID_MM_TELIT_PORTS_TAGGED")) {
> +    if (mm_kernel_device_get_global_property_as_boolean
> (port_device, "ID_MM_TELIT_PORTS_TAGGED")) {
>          ctx->cgmi_retries = 0;
>          ctx->ati_retries = 0;
>      }
> diff --git a/plugins/huawei/mm-broadband-modem-huawei.c
> b/plugins/huawei/mm-broadband-modem-huawei.c
> index 607e14ee..0e375e13 100644
> --- a/plugins/huawei/mm-broadband-modem-huawei.c
> +++ b/plugins/huawei/mm-broadband-modem-huawei.c
> @@ -2367,7 +2367,7 @@ ensure_ndisdup_support_checked
> (MMBroadbandModemHuawei *self,
> 
>      /* First, check for devices which support NDISDUP on any AT
> port. These
>       * devices are tagged by udev */
> -    if (mm_kernel_device_get_property_as_boolean
> (mm_port_peek_kernel_device (port),
> "ID_MM_HUAWEI_NDISDUP_SUPPORTED")) {
> +    if (mm_kernel_device_get_global_property_as_boolean
> (mm_port_peek_kernel_device (port),
> "ID_MM_HUAWEI_NDISDUP_SUPPORTED")) {
>          mm_dbg ("This device (%s) can support ndisdup feature",
> mm_port_get_device (port));
>          self->priv->ndisdup_support = FEATURE_SUPPORTED;
>      }
> diff --git a/plugins/huawei/mm-plugin-huawei.c b/plugins/huawei/mm-
> plugin-huawei.c
> index 83667955..deb17510 100644
> --- a/plugins/huawei/mm-plugin-huawei.c
> +++ b/plugins/huawei/mm-plugin-huawei.c
> @@ -292,7 +292,7 @@ huawei_custom_init_step (HuaweiCustomInitContext
> *ctx)
> 
>      /* Try to get a port map from the modem */
>      port = mm_port_probe_peek_port (ctx->probe);
> -    if (!ctx->getportmode_done &&
> !mm_kernel_device_get_property_as_boolean (port,
> "ID_MM_HUAWEI_DISABLE_GETPORTMODE")) {
> +    if (!ctx->getportmode_done &&
> !mm_kernel_device_get_global_property_as_boolean (port,
> "ID_MM_HUAWEI_DISABLE_GETPORTMODE")) {
>          if (ctx->getportmode_retries == 0) {
>              g_simple_async_result_set_op_res_gboolean (ctx->result,
> TRUE);
>              huawei_custom_init_context_complete_and_free (ctx);
> diff --git a/plugins/simtech/mm-plugin-simtech.c
> b/plugins/simtech/mm-plugin-simtech.c
> index 54544aa0..b150868f 100644
> --- a/plugins/simtech/mm-plugin-simtech.c
> +++ b/plugins/simtech/mm-plugin-simtech.c
> @@ -98,7 +98,7 @@ grab_port (MMPlugin *self,
>           * to show up with more than two AT-capable ports.
>           */
>          if (pflags == MM_PORT_SERIAL_AT_FLAG_NONE &&
> -            mm_kernel_device_get_property_as_boolean (port,
> "ID_MM_SIMTECH_TAGGED"))
> +            mm_kernel_device_get_global_property_as_boolean (port,
> "ID_MM_SIMTECH_TAGGED"))
>              ptype = MM_PORT_TYPE_IGNORED;
>      }
> 
> diff --git a/plugins/telit/mm-common-telit.c b/plugins/telit/mm-
> common-telit.c
> index 78530c42..4a1dd998 100644
> --- a/plugins/telit/mm-common-telit.c
> +++ b/plugins/telit/mm-common-telit.c
> @@ -319,7 +319,7 @@ telit_custom_init (MMPortProbe *probe,
>      ctx->getportcfg_retries = 3;
> 
>      /* If the device is tagged for supporting #PORTCFG do the custom
> init */
> -    if (mm_kernel_device_get_property_as_boolean (port_device,
> "ID_MM_TELIT_PORTS_TAGGED")) {
> +    if (mm_kernel_device_get_global_property_as_boolean
> (port_device, "ID_MM_TELIT_PORTS_TAGGED")) {
>          telit_custom_init_step (ctx);
>          return;
>      }
> diff --git a/plugins/zte/mm-plugin-zte.c b/plugins/zte/mm-plugin-
> zte.c
> index 172f275e..3a87c376 100644
> --- a/plugins/zte/mm-plugin-zte.c
> +++ b/plugins/zte/mm-plugin-zte.c
> @@ -141,7 +141,7 @@ grab_port (MMPlugin *self,
>          }
>      }
> 
> -    if (mm_kernel_device_get_property_as_boolean (port,
> "ID_MM_ZTE_ICERA_DHCP")) {
> +    if (mm_kernel_device_get_global_property_as_boolean (port,
> "ID_MM_ZTE_ICERA_DHCP")) {
>          mm_dbg ("ZTE: Icera-based modem will use DHCP");
>          g_object_set (modem,
>                        MM_BROADBAND_MODEM_ICERA_DEFAULT_IP_METHOD,
> MM_BEARER_IP_METHOD_DHCP,
> diff --git a/src/kerneldevice/mm-kernel-device-generic.c
> b/src/kerneldevice/mm-kernel-device-generic.c
> index 0434bd1b..07681398 100644
> --- a/src/kerneldevice/mm-kernel-device-generic.c
> +++ b/src/kerneldevice/mm-kernel-device-generic.c
> @@ -1067,6 +1067,13 @@ mm_kernel_device_generic_class_init
> (MMKernelDeviceGenericClass *klass)
>      kernel_device_class->get_property_as_int     =
> kernel_device_get_property_as_int;
>      kernel_device_class->get_property_as_int_hex =
> kernel_device_get_property_as_int_hex;
> 
> +    /* Device-wide properties are stored per-port in the generic
> backend */
> +    kernel_device_class->has_global_property            =
> kernel_device_has_property;
> +    kernel_device_class->get_global_property            =
> kernel_device_get_property;
> +    kernel_device_class->get_global_property_as_boolean =
> kernel_device_get_property_as_boolean;
> +    kernel_device_class->get_global_property_as_int     =
> kernel_device_get_property_as_int;
> +    kernel_device_class->get_global_property_as_int_hex =
> kernel_device_get_property_as_int_hex;
> +
>      properties[PROP_PROPERTIES] =
>          g_param_spec_object ("properties",
>                               "Properties",
> diff --git a/src/kerneldevice/mm-kernel-device-udev.c
> b/src/kerneldevice/mm-kernel-device-udev.c
> index 2b2f19cb..e8763f7e 100644
> --- a/src/kerneldevice/mm-kernel-device-udev.c
> +++ b/src/kerneldevice/mm-kernel-device-udev.c
> @@ -352,16 +352,13 @@ kernel_device_get_physdev_uid (MMKernelDevice
> *_self)
>              return uid;
>      }
> 
> -    ensure_physdev (self);
> -    if (self->priv->physdev) {
> -        /* Try to load from properties set on the physical device */
> -        if ((uid = g_udev_device_get_property (self->priv->physdev,
> "ID_MM_PHYSDEV_UID")) != NULL)
> -            return uid;
> +    /* Try to load from properties set on the physical device */
> +    if ((uid = mm_kernel_device_get_global_property
> (MM_KERNEL_DEVICE (self), "ID_MM_PHYSDEV_UID")) != NULL)
> +        return uid;
> 
> -        /* Use physical device sysfs path, if any */
> -        if ((uid = g_udev_device_get_sysfs_path (self->priv-
> >physdev)) != NULL)
> -            return uid;
> -    }
> +    /* Use physical device sysfs path, if any */
> +    if (self->priv->physdev && (uid = g_udev_device_get_sysfs_path
> (self->priv->physdev)) != NULL)
> +        return uid;
> 
>      /* If there is no physical device sysfs path, use the device
> sysfs itself */
>      g_assert (self->priv->device);
> @@ -436,9 +433,9 @@ kernel_device_is_candidate (MMKernelDevice
> *_self,
>       * 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
> +     * This 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"))
> +    if (!mm_kernel_device_get_property_as_boolean (MM_KERNEL_DEVICE
> (self), "ID_MM_CANDIDATE"))
>          return FALSE;
> 
>      /* Load physical device. If there is no physical device, we
> don't process
> @@ -457,16 +454,15 @@ kernel_device_is_candidate (MMKernelDevice
> *_self,
>          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")) {
> +    /* Ignore blacklisted devices. */
> +    if (mm_kernel_device_get_global_property_as_boolean
> (MM_KERNEL_DEVICE (self), "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")) {
> +    if (!manual_scan &&
> mm_kernel_device_get_global_property_as_boolean (MM_KERNEL_DEVICE
> (self), "ID_MM_DEVICE_MANUAL_SCAN_ONLY")) {
>          mm_dbg ("(%s/%s): device probed only in manual scan",
> subsys, name);
>          return FALSE;
>      }
> @@ -474,7 +470,7 @@ kernel_device_is_candidate (MMKernelDevice
> *_self,
>      /* 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_kernel_device_get_global_property_as_boolean
> (MM_KERNEL_DEVICE (self), "ID_MM_PLATFORM_DRIVER_PROBE"))) {
>          mm_dbg ("(%s/%s): port's parent platform driver is not
> whitelisted", subsys, name);
>          return FALSE;
>      }
> @@ -596,6 +592,103 @@ kernel_device_get_property_as_int_hex
> (MMKernelDevice *_self,
>      return ((s && mm_get_uint_from_hex_str (s, &out)) ? out : 0);
>  }
> 
> +static gboolean
> +kernel_device_has_global_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);
> +
> +    ensure_physdev (self);
> +    if (self->priv->physdev && g_udev_device_has_property (self-
> >priv->physdev, property))
> +        return TRUE;
> +
> +    return kernel_device_has_property (_self, property);
> +}
> +
> +static const gchar *
> +kernel_device_get_global_property (MMKernelDevice *_self,
> +                                   const gchar    *property)
> +{
> +    MMKernelDeviceUdev *self;
> +    const gchar        *str;
> +
> +    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 &&
> +        g_udev_device_has_property (self->priv->physdev, property)
> &&
> +        (str = g_udev_device_get_property (self->priv->physdev,
> property)) != NULL)
> +        return str;
> +
> +    return kernel_device_get_property (_self, property);
> +}
> +
> +static gboolean
> +kernel_device_get_global_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);
> +
> +    ensure_physdev (self);
> +    if (self->priv->physdev &&
> +        g_udev_device_has_property (self->priv->physdev, property)
> &&
> +        g_udev_device_get_property (self->priv->physdev, property))
> +        return TRUE;
> +
> +    return kernel_device_get_property_as_boolean (_self, property);
> +}
> +
> +static gint
> +kernel_device_get_global_property_as_int (MMKernelDevice *_self,
> +                                          const gchar    *property)
> +{
> +    MMKernelDeviceUdev *self;
> +    gint                value;
> +
> +    g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self), -1);
> +
> +    self = MM_KERNEL_DEVICE_UDEV (_self);
> +
> +    ensure_physdev (self);
> +    if (self->priv->physdev &&
> +        g_udev_device_has_property (self->priv->physdev, property)
> &&
> +        (value = g_udev_device_get_property_as_int (self->priv-
> >physdev, property)) >= 0)
> +        return value;
> +
> +    return kernel_device_get_property_as_int (_self, property);
> +}
> +
> +static guint
> +kernel_device_get_global_property_as_int_hex (MMKernelDevice *_self,
> +                                              const
> gchar    *property)
> +{
> +    MMKernelDeviceUdev *self;
> +    const gchar        *s;
> +    guint               out = 0;
> +
> +    g_return_val_if_fail (MM_IS_KERNEL_DEVICE_UDEV (_self),
> G_MAXUINT);
> +
> +    self = MM_KERNEL_DEVICE_UDEV (_self);
> +
> +    ensure_physdev (self);
> +    if (self->priv->physdev &&
> +        g_udev_device_has_property (self->priv->physdev, property)
> &&
> +        (s = g_udev_device_get_property (self->priv->physdev,
> property)) != NULL)
> +        return ((s && mm_get_uint_from_hex_str (s, &out)) ? out :
> 0);
> +
> +    return kernel_device_get_property_as_int_hex (_self, property);
> +}
> +
>  /*******************************************************************
> **********/
> 
>  MMKernelDevice *
> @@ -770,21 +863,26 @@ mm_kernel_device_udev_class_init
> (MMKernelDeviceUdevClass *klass)
>      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;
> -    kernel_device_class->get_property_as_int_hex =
> kernel_device_get_property_as_int_hex;
> +    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;
> +    kernel_device_class->get_property_as_int_hex        =
> kernel_device_get_property_as_int_hex;
> +    kernel_device_class->has_global_property            =
> kernel_device_has_global_property;
> +    kernel_device_class->get_global_property            =
> kernel_device_get_global_property;
> +    kernel_device_class->get_global_property_as_boolean =
> kernel_device_get_global_property_as_boolean;
> +    kernel_device_class->get_global_property_as_int     =
> kernel_device_get_global_property_as_int;
> +    kernel_device_class->get_global_property_as_int_hex =
> kernel_device_get_global_property_as_int_hex;
> 
>      properties[PROP_UDEV_DEVICE] =
>          g_param_spec_object ("udev-device",
> diff --git a/src/kerneldevice/mm-kernel-device.c
> b/src/kerneldevice/mm-kernel-device.c
> index 4de4e744..e69e9d1d 100644
> --- a/src/kerneldevice/mm-kernel-device.c
> +++ b/src/kerneldevice/mm-kernel-device.c
> @@ -177,6 +177,61 @@ mm_kernel_device_get_property_as_int_hex
> (MMKernelDevice *self,
>              0);
>  }
> 
> +gboolean
> +mm_kernel_device_has_global_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_global_property ?
> +            MM_KERNEL_DEVICE_GET_CLASS (self)->has_global_property
> (self, property) :
> +            FALSE);
> +}
> +
> +const gchar *
> +mm_kernel_device_get_global_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_global_property ?
> +            MM_KERNEL_DEVICE_GET_CLASS (self)->get_global_property
> (self, property) :
> +            NULL);
> +}
> +
> +gboolean
> +mm_kernel_device_get_global_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_global_property_as_boolean ?
> +            MM_KERNEL_DEVICE_GET_CLASS (self)-
> >get_global_property_as_boolean (self, property) :
> +            FALSE);
> +}
> +
> +gint
> +mm_kernel_device_get_global_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_global_property_as_int ?
> +            MM_KERNEL_DEVICE_GET_CLASS (self)-
> >get_global_property_as_int (self, property) :
> +            -1);
> +}
> +
> +guint
> +mm_kernel_device_get_global_property_as_int_hex (MMKernelDevice
> *self,
> +                                                 const
> gchar    *property)
> +{
> +    g_return_val_if_fail (MM_IS_KERNEL_DEVICE (self), 0);
> +
> +    return (MM_KERNEL_DEVICE_GET_CLASS (self)-
> >get_global_property_as_int_hex ?
> +            MM_KERNEL_DEVICE_GET_CLASS (self)-
> >get_global_property_as_int_hex (self, property) :
> +            0);
> +}
> +
>  /*******************************************************************
> **********/
> 
>  static void
> diff --git a/src/kerneldevice/mm-kernel-device.h
> b/src/kerneldevice/mm-kernel-device.h
> index 5c1f6db0..efb64ae7 100644
> --- a/src/kerneldevice/mm-kernel-device.h
> +++ b/src/kerneldevice/mm-kernel-device.h
> @@ -62,6 +62,12 @@ struct _MMKernelDeviceClass {
>      gboolean      (* get_property_as_boolean) (MMKernelDevice *self,
> const gchar *property);
>      gint          (* get_property_as_int)     (MMKernelDevice *self,
> const gchar *property);
>      guint         (* get_property_as_int_hex) (MMKernelDevice *self,
> const gchar *property);
> +
> +    gboolean      (* has_global_property)            (MMKernelDevice
> *self, const gchar *property);
> +    const gchar * (* get_global_property)            (MMKernelDevice
> *self, const gchar *property);
> +    gboolean      (* get_global_property_as_boolean) (MMKernelDevice
> *self, const gchar *property);
> +    gint          (* get_global_property_as_int)     (MMKernelDevice
> *self, const gchar *property);
> +    guint         (* get_global_property_as_int_hex) (MMKernelDevice
> *self, const gchar *property);
>  };
> 
>  GType mm_kernel_device_get_type (void);
> @@ -82,10 +88,18 @@ guint16      mm_kernel_device_get_physdev_pid
> (MMKernelDevice *self);
> 
>  gboolean     mm_kernel_device_cmp (MMKernelDevice *a, MMKernelDevice
> *b);
> 
> +/* Standard properties are usually associated to single ports */
>  gboolean     mm_kernel_device_has_property            (MMKernelDevic
> e *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     (MMKernelDevic
> e *self, const gchar *property);
>  guint        mm_kernel_device_get_property_as_int_hex
> (MMKernelDevice *self, const gchar *property);
> 
> +/* Global properties are usually associated to full devices */
> +gboolean     mm_kernel_device_has_global_property            (MMKern
> elDevice *self, const gchar *property);
> +const gchar
> *mm_kernel_device_get_global_property            (MMKernelDevice
> *self, const gchar *property);
> +gboolean     mm_kernel_device_get_global_property_as_boolean
> (MMKernelDevice *self, const gchar *property);
> +gint         mm_kernel_device_get_global_property_as_int     (MMKern
> elDevice *self, const gchar *property);
> +guint        mm_kernel_device_get_global_property_as_int_hex
> (MMKernelDevice *self, const gchar *property);
> +
>  #endif /* MM_KERNEL_DEVICE_H */
> diff --git a/src/mm-plugin.c b/src/mm-plugin.c
> index 6fce8898..af4bc739 100644
> --- a/src/mm-plugin.c
> +++ b/src/mm-plugin.c
> @@ -417,8 +417,8 @@ apply_pre_probing_filters (MMPlugin       *self,
>       * supported. If that is the case, filter by udev tag */
>      if (self->priv->udev_tags) {
>          for (i = 0; self->priv->udev_tags[i]; i++) {
> -            /* Check if the port was tagged */
> -            if (mm_kernel_device_get_property_as_boolean (port,
> self->priv->udev_tags[i]))
> +            /* Check if the port or device was tagged */
> +            if (mm_kernel_device_get_global_property_as_boolean
> (port, self->priv->udev_tags[i]))
>                  break;
>          }
> 
> --
> 2.12.0


More information about the ModemManager-devel mailing list