diff --git a/libfwupdplugin/fu-i2c-device.c b/libfwupdplugin/fu-i2c-device.c index cca4d6633..852123919 100644 --- a/libfwupdplugin/fu-i2c-device.c +++ b/libfwupdplugin/fu-i2c-device.c @@ -114,8 +114,7 @@ fu_i2c_device_probe(FuDevice *device, GError **error) FuI2cDevicePrivate *priv = GET_PRIVATE(self); GUdevDevice *udev_device = fu_udev_device_get_dev(FU_UDEV_DEVICE(device)); const gchar *tmp; - g_autoptr(GMatchInfo) info = NULL; - g_autoptr(GRegex) regex = NULL; + g_autofree gchar *devname = NULL; #endif /* set physical ID */ @@ -130,13 +129,13 @@ fu_i2c_device_probe(FuDevice *device, GError **error) return FALSE; /* get bus number out of sysfs path */ - regex = g_regex_new("/i2c-([0-9]+)/", 0, 0, error); - if (regex == NULL) - return FALSE; - tmp = g_udev_device_get_sysfs_path(udev_device); - if (!g_regex_match_full(regex, tmp, -1, 0, 0, &info, error)) - return FALSE; - priv->bus_number = g_ascii_strtoll(g_match_info_fetch(info, 1), NULL, 10); + devname = g_path_get_basename(fu_udev_device_get_sysfs_path(FU_UDEV_DEVICE(device))); + if (g_str_has_prefix(devname, "i2c-")) { + guint64 tmp64 = 0; + if (!fu_strtoull(devname + 4, &tmp64, 0, G_MAXUINT, error)) + return FALSE; + priv->bus_number = tmp64; + } #endif /* success */