udev: define all generic tags as symbols
This prevents errors due to nasty typos in the strings. We define all symbols in a single header file that is NOT considered part of the API, as there is no need for MM clients to know about these tags code-wise. These tags are only meaningful when associated to devices in udev. Information of each tag is included in the general API documentation. https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/88
This commit is contained in:
committed by
Dan Williams
parent
a2705abb24
commit
2a1a0b88fb
@@ -21,6 +21,8 @@
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
|
||||
#include <ModemManager-tags.h>
|
||||
|
||||
#include "mm-kernel-device-generic.h"
|
||||
#include "mm-kernel-device-generic-rules.h"
|
||||
#include "mm-log.h"
|
||||
@@ -486,7 +488,7 @@ kernel_device_get_physdev_uid (MMKernelDevice *self)
|
||||
return uid;
|
||||
|
||||
/* Try to load from properties set */
|
||||
if ((uid = mm_kernel_device_get_property (self, "ID_MM_PHYSDEV_UID")) != NULL)
|
||||
if ((uid = mm_kernel_device_get_property (self, ID_MM_PHYSDEV_UID)) != NULL)
|
||||
return uid;
|
||||
|
||||
/* Use physical device path, if any */
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
|
||||
#include <ModemManager-tags.h>
|
||||
|
||||
#include "mm-kernel-device-udev.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
@@ -358,7 +360,7 @@ kernel_device_get_physdev_uid (MMKernelDevice *_self)
|
||||
}
|
||||
|
||||
/* 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)
|
||||
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 */
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "mm-kernel-device-generic.h"
|
||||
|
||||
#include <ModemManager.h>
|
||||
#include <ModemManager-tags.h>
|
||||
|
||||
#include <mm-errors-types.h>
|
||||
#include <mm-gdbus-manager.h>
|
||||
#include <mm-gdbus-test.h>
|
||||
@@ -303,8 +305,8 @@ device_added (MMBaseManager *manager,
|
||||
*
|
||||
* 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 (!mm_kernel_device_get_property_as_boolean (port, "ID_MM_CANDIDATE")) {
|
||||
/* This could mean that device changed, losing its ID_MM_CANDIDATE
|
||||
if (!mm_kernel_device_get_property_as_boolean (port, ID_MM_CANDIDATE)) {
|
||||
/* This could mean that device changed, losing its candidate
|
||||
* flags (such as Bluetooth RFCOMM devices upon disconnect.
|
||||
* Try to forget it. */
|
||||
device_removed (manager, port);
|
||||
|
||||
+8
-6
@@ -23,6 +23,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <ModemManager.h>
|
||||
#include <ModemManager-tags.h>
|
||||
|
||||
#include <mm-errors-types.h>
|
||||
#include <mm-gdbus-modem.h>
|
||||
|
||||
@@ -215,13 +217,13 @@ mm_base_modem_grab_port (MMBaseModem *self,
|
||||
mm_serial_parser_v1_destroy);
|
||||
/* Prefer plugin-provided flags to the generic ones */
|
||||
if (at_pflags == MM_PORT_SERIAL_AT_FLAG_NONE) {
|
||||
if (mm_kernel_device_get_property_as_boolean (kernel_device, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
|
||||
if (mm_kernel_device_get_property_as_boolean (kernel_device, ID_MM_PORT_TYPE_AT_PRIMARY)) {
|
||||
mm_dbg ("AT port '%s/%s' flagged as primary", subsys, name);
|
||||
at_pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
|
||||
} else if (mm_kernel_device_get_property_as_boolean (kernel_device, "ID_MM_PORT_TYPE_AT_SECONDARY")) {
|
||||
} else if (mm_kernel_device_get_property_as_boolean (kernel_device, ID_MM_PORT_TYPE_AT_SECONDARY)) {
|
||||
mm_dbg ("AT port '%s/%s' flagged as secondary", subsys, name);
|
||||
at_pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
|
||||
} else if (mm_kernel_device_get_property_as_boolean (kernel_device, "ID_MM_PORT_TYPE_AT_PPP")) {
|
||||
} else if (mm_kernel_device_get_property_as_boolean (kernel_device, ID_MM_PORT_TYPE_AT_PPP)) {
|
||||
mm_dbg ("AT port '%s/%s' flagged as PPP", subsys, name);
|
||||
at_pflags = MM_PORT_SERIAL_AT_FLAG_PPP;
|
||||
}
|
||||
@@ -249,12 +251,12 @@ mm_base_modem_grab_port (MMBaseModem *self,
|
||||
self);
|
||||
|
||||
/* For serial ports, optionally use a specific baudrate and flow control */
|
||||
if (mm_kernel_device_has_property (kernel_device, "ID_MM_TTY_BAUDRATE"))
|
||||
if (mm_kernel_device_has_property (kernel_device, ID_MM_TTY_BAUDRATE))
|
||||
g_object_set (port,
|
||||
MM_PORT_SERIAL_BAUD, mm_kernel_device_get_property_as_int (kernel_device, "ID_MM_TTY_BAUDRATE"),
|
||||
MM_PORT_SERIAL_BAUD, mm_kernel_device_get_property_as_int (kernel_device, ID_MM_TTY_BAUDRATE),
|
||||
NULL);
|
||||
|
||||
flow_control_tag = mm_kernel_device_get_property (kernel_device, "ID_MM_TTY_FLOW_CONTROL");
|
||||
flow_control_tag = mm_kernel_device_get_property (kernel_device, ID_MM_TTY_FLOW_CONTROL);
|
||||
if (flow_control_tag) {
|
||||
MMFlowControl flow_control;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
+8
-5
@@ -16,6 +16,9 @@
|
||||
#include <config.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ModemManager.h>
|
||||
#include <ModemManager-tags.h>
|
||||
|
||||
#include "mm-daemon-enums-types.h"
|
||||
#include "mm-filter.h"
|
||||
#include "mm-log.h"
|
||||
@@ -51,8 +54,8 @@ mm_filter_port (MMFilter *self,
|
||||
* allow specifying this flag per-port instead of for the full device, e.g.
|
||||
* for platform tty ports where there's only one port anyway. */
|
||||
if ((self->priv->enabled_rules & MM_FILTER_RULE_EXPLICIT_WHITELIST) &&
|
||||
(mm_kernel_device_get_global_property_as_boolean (port, "ID_MM_DEVICE_PROCESS") ||
|
||||
mm_kernel_device_get_property_as_boolean (port, "ID_MM_DEVICE_PROCESS"))) {
|
||||
(mm_kernel_device_get_global_property_as_boolean (port, ID_MM_DEVICE_PROCESS) ||
|
||||
mm_kernel_device_get_property_as_boolean (port, ID_MM_DEVICE_PROCESS))) {
|
||||
mm_dbg ("[filter] (%s/%s) port allowed: device is whitelisted", subsystem, name);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -89,7 +92,7 @@ mm_filter_port (MMFilter *self,
|
||||
|
||||
/* Ignore blacklisted tty devices. */
|
||||
if ((self->priv->enabled_rules & MM_FILTER_RULE_TTY_BLACKLIST) &&
|
||||
(mm_kernel_device_get_global_property_as_boolean (port, "ID_MM_DEVICE_IGNORE"))) {
|
||||
(mm_kernel_device_get_global_property_as_boolean (port, ID_MM_DEVICE_IGNORE))) {
|
||||
mm_dbg ("[filter] (%s/%s): port filtered: device is blacklisted", subsystem, name);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -97,7 +100,7 @@ mm_filter_port (MMFilter *self,
|
||||
/* Is the device in the manual-only greylist? If so, return if this is an
|
||||
* automatic scan. */
|
||||
if ((self->priv->enabled_rules & MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY) &&
|
||||
(!manual_scan && mm_kernel_device_get_global_property_as_boolean (port, "ID_MM_DEVICE_MANUAL_SCAN_ONLY"))) {
|
||||
(!manual_scan && mm_kernel_device_get_global_property_as_boolean (port, ID_MM_DEVICE_MANUAL_SCAN_ONLY))) {
|
||||
mm_dbg ("[filter] (%s/%s): port filtered: device probed only in manual scan", subsystem, name);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -111,7 +114,7 @@ mm_filter_port (MMFilter *self,
|
||||
!g_strcmp0 (physdev_subsystem, "pci") ||
|
||||
!g_strcmp0 (physdev_subsystem, "pnp") ||
|
||||
!g_strcmp0 (physdev_subsystem, "sdio"))) {
|
||||
if (!mm_kernel_device_get_global_property_as_boolean (port, "ID_MM_PLATFORM_DRIVER_PROBE")) {
|
||||
if (!mm_kernel_device_get_global_property_as_boolean (port, ID_MM_PLATFORM_DRIVER_PROBE)) {
|
||||
mm_dbg ("[filter] (%s/%s): port filtered: port's parent platform driver is not whitelisted", subsystem, name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+11
-9
@@ -22,6 +22,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <ModemManager.h>
|
||||
#include <ModemManager-tags.h>
|
||||
|
||||
#include <mm-errors-types.h>
|
||||
|
||||
#include "mm-port-probe.h"
|
||||
@@ -637,12 +639,12 @@ common_serial_port_setup (MMPortProbe *self,
|
||||
{
|
||||
const gchar *flow_control_tag;
|
||||
|
||||
if (mm_kernel_device_has_property (self->priv->port, "ID_MM_TTY_BAUDRATE"))
|
||||
if (mm_kernel_device_has_property (self->priv->port, ID_MM_TTY_BAUDRATE))
|
||||
g_object_set (serial,
|
||||
MM_PORT_SERIAL_BAUD, mm_kernel_device_get_property_as_int (self->priv->port, "ID_MM_TTY_BAUDRATE"),
|
||||
MM_PORT_SERIAL_BAUD, mm_kernel_device_get_property_as_int (self->priv->port, ID_MM_TTY_BAUDRATE),
|
||||
NULL);
|
||||
|
||||
flow_control_tag = mm_kernel_device_get_property (self->priv->port, "ID_MM_TTY_FLOW_CONTROL");
|
||||
flow_control_tag = mm_kernel_device_get_property (self->priv->port, ID_MM_TTY_FLOW_CONTROL);
|
||||
if (flow_control_tag) {
|
||||
MMFlowControl flow_control;
|
||||
GError *error = NULL;
|
||||
@@ -1896,12 +1898,12 @@ set_property (GObject *object,
|
||||
case PROP_PORT:
|
||||
/* construct only */
|
||||
self->priv->port = g_value_dup_object (value);
|
||||
self->priv->is_ignored = mm_kernel_device_get_property_as_boolean (self->priv->port, "ID_MM_PORT_IGNORE");
|
||||
self->priv->is_gps = mm_kernel_device_get_property_as_boolean (self->priv->port, "ID_MM_PORT_TYPE_GPS");
|
||||
self->priv->maybe_at_primary = mm_kernel_device_get_property_as_boolean (self->priv->port, "ID_MM_PORT_TYPE_AT_PRIMARY");
|
||||
self->priv->maybe_at_secondary = mm_kernel_device_get_property_as_boolean (self->priv->port, "ID_MM_PORT_TYPE_AT_SECONDARY");
|
||||
self->priv->maybe_at_ppp = mm_kernel_device_get_property_as_boolean (self->priv->port, "ID_MM_PORT_TYPE_AT_PPP");
|
||||
self->priv->maybe_qcdm = mm_kernel_device_get_property_as_boolean (self->priv->port, "ID_MM_PORT_TYPE_QCDM");
|
||||
self->priv->is_ignored = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_IGNORE);
|
||||
self->priv->is_gps = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_GPS);
|
||||
self->priv->maybe_at_primary = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_PRIMARY);
|
||||
self->priv->maybe_at_secondary = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_SECONDARY);
|
||||
self->priv->maybe_at_ppp = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_PPP);
|
||||
self->priv->maybe_qcdm = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_QCDM);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
||||
Reference in New Issue
Block a user