core: add platform device support and whitelist
This commit is contained in:
14
src/77-mm-platform-serial-whitelist.rules
Normal file
14
src/77-mm-platform-serial-whitelist.rules
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# do not edit this file, it will be overwritten on update
|
||||||
|
|
||||||
|
ACTION!="add|change", GOTO="mm_platform_device_whitelist_end"
|
||||||
|
SUBSYSTEM!="platform", GOTO="mm_platform_device_whitelist_end"
|
||||||
|
|
||||||
|
# Be careful here since many devices connected to platform drivers on PCs
|
||||||
|
# are legacy devices that won't like probing. But often on embedded
|
||||||
|
# systems serial ports are provided by platform devices.
|
||||||
|
|
||||||
|
# Allow atmel_usart
|
||||||
|
DRIVERS=="atmel_usart", ENV{ID_MM_PLATFORM_DRIVER_PROBE}="1"
|
||||||
|
|
||||||
|
LABEL="mm_platform_device_whitelist_end"
|
||||||
|
|
@@ -3,7 +3,8 @@ SUBDIRS=. tests
|
|||||||
udevrulesdir = $(UDEV_BASE_DIR)/rules.d
|
udevrulesdir = $(UDEV_BASE_DIR)/rules.d
|
||||||
udevrules_DATA = \
|
udevrules_DATA = \
|
||||||
77-mm-usb-device-blacklist.rules \
|
77-mm-usb-device-blacklist.rules \
|
||||||
77-mm-pcmcia-device-blacklist.rules
|
77-mm-pcmcia-device-blacklist.rules \
|
||||||
|
77-mm-platform-serial-whitelist.rules
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
$(udevrules_DATA)
|
$(udevrules_DATA)
|
||||||
|
@@ -636,7 +636,7 @@ find_physical_device (GUdevDevice *child)
|
|||||||
GUdevDevice *physdev = NULL;
|
GUdevDevice *physdev = NULL;
|
||||||
const char *subsys, *type;
|
const char *subsys, *type;
|
||||||
guint32 i = 0;
|
guint32 i = 0;
|
||||||
gboolean is_usb = FALSE, is_pci = FALSE, is_pcmcia = FALSE;
|
gboolean is_usb = FALSE, is_pci = FALSE, is_pcmcia = FALSE, is_platform = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (child != NULL, NULL);
|
g_return_val_if_fail (child != NULL, NULL);
|
||||||
|
|
||||||
@@ -671,6 +671,11 @@ find_physical_device (GUdevDevice *child)
|
|||||||
if (physdev)
|
if (physdev)
|
||||||
break;
|
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")) {
|
} else if (is_pci || !strcmp (subsys, "pci")) {
|
||||||
is_pci = TRUE;
|
is_pci = TRUE;
|
||||||
physdev = iter;
|
physdev = iter;
|
||||||
@@ -690,7 +695,7 @@ static void
|
|||||||
device_added (MMManager *manager, GUdevDevice *device)
|
device_added (MMManager *manager, GUdevDevice *device)
|
||||||
{
|
{
|
||||||
MMManagerPrivate *priv = MM_MANAGER_GET_PRIVATE (manager);
|
MMManagerPrivate *priv = MM_MANAGER_GET_PRIVATE (manager);
|
||||||
const char *subsys, *name, *physdev_path;
|
const char *subsys, *name, *physdev_path, *physdev_subsys;
|
||||||
SupportsInfo *info;
|
SupportsInfo *info;
|
||||||
char *key;
|
char *key;
|
||||||
gboolean found;
|
gboolean found;
|
||||||
@@ -743,6 +748,15 @@ device_added (MMManager *manager, GUdevDevice *device)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If the physdev is a 'platform' device that's not whitelisted, ignore it */
|
||||||
|
physdev_subsys = g_udev_device_get_subsystem (physdev);
|
||||||
|
if ( physdev_subsys
|
||||||
|
&& !strcmp (physdev_subsys, "platform")
|
||||||
|
&& !g_udev_device_get_property_as_boolean (physdev, "ID_MM_PLATFORM_DRIVER_PROBE")) {
|
||||||
|
g_debug ("(%s/%s): port's parent platform driver is not whitelisted", subsys, name);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
physdev_path = g_udev_device_get_sysfs_path (physdev);
|
physdev_path = g_udev_device_get_sysfs_path (physdev);
|
||||||
if (!physdev_path) {
|
if (!physdev_path) {
|
||||||
g_debug ("(%s/%s): could not get port's parent device sysfs path", subsys, name);
|
g_debug ("(%s/%s): could not get port's parent device sysfs path", subsys, name);
|
||||||
|
Reference in New Issue
Block a user