Set the protocol per-device not per-plugin

Some plugins have devices with more than one protocol. Logically the protocol
belongs to the device, not the plugin, and in the future we could use this to
further check firmware that's about to be deployed.

This is also not exported into libfwupd (yet?) as it's remains a debug-feature
only -- protocols are not actually required for devices to be added.
This commit is contained in:
Richard Hughes 2019-11-25 13:44:49 +00:00
parent 28ab968cbf
commit 56ac823af9
56 changed files with 98 additions and 34 deletions

View File

@ -545,6 +545,7 @@ fu_altos_device_init (FuAltosDevice *self)
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_set_vendor (FU_DEVICE (self), "altusmetrum.org");
fu_device_set_summary (FU_DEVICE (self), "A USB hardware random number generator");
fu_device_set_protocol (FU_DEVICE (self), "org.altusmetrum.altos");
/* requires manual step */
if (!fu_device_has_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_IS_BOOTLOADER))

View File

@ -16,7 +16,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.altusmetrum.altos");
fu_plugin_set_device_gtype (plugin, FU_TYPE_ALTOS_DEVICE);
fu_plugin_add_firmware_gtype (plugin, "altos", FU_TYPE_ALTOS_FIRMWARE);
}

View File

@ -661,6 +661,7 @@ fu_ata_device_init (FuAtaDevice *self)
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_set_summary (FU_DEVICE (self), "ATA Drive");
fu_device_add_icon (FU_DEVICE (self), "drive-harddisk");
fu_device_set_protocol (FU_DEVICE (self), "org.t13.ata");
fu_udev_device_set_readonly (FU_UDEV_DEVICE (self), TRUE);
}

View File

@ -16,6 +16,5 @@ fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_udev_subsystem (plugin, "block");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.t13.ata");
fu_plugin_set_device_gtype (plugin, FU_TYPE_ATA_DEVICE);
}

View File

@ -455,6 +455,7 @@ fu_colorhug_device_init (FuColorhugDevice *self)
{
/* this is the application code */
self->start_addr = CH_EEPROM_ADDR_RUNCODE;
fu_device_set_protocol (FU_DEVICE (self), "com.hughski.colorhug");
fu_device_set_remove_delay (FU_DEVICE (self),
FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE);
}

View File

@ -15,6 +15,5 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.hughski.colorhug");
fu_plugin_set_device_gtype (plugin, FU_TYPE_COLORHUG_DEVICE);
}

View File

@ -548,8 +548,9 @@ fu_csr_device_close (FuUsbDevice *device, GError **error)
}
static void
fu_csr_device_init (FuCsrDevice *device)
fu_csr_device_init (FuCsrDevice *self)
{
fu_device_set_protocol (FU_DEVICE (self), "com.qualcomm.dfu");
}
static void

View File

@ -15,6 +15,5 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.qualcomm.dfu");
fu_plugin_set_device_gtype (plugin, FU_TYPE_CSR_DEVICE);
}

View File

@ -988,6 +988,7 @@ fu_dell_dock_ec_init (FuDellDockEc *self)
{
self->data = g_new0 (FuDellDockDockDataStructure, 1);
self->raw_versions = g_new0 (FuDellDockDockPackageFWVersion, 1);
fu_device_set_protocol (FU_DEVICE (self), "com.dell.dock");
}
static void

View File

@ -972,6 +972,7 @@ fu_dell_dock_mst_finalize (GObject *object)
static void
fu_dell_dock_mst_init (FuDellDockMst *self)
{
fu_device_set_protocol (FU_DEVICE (self), "com.synaptics.mst");
}
static void

View File

@ -280,8 +280,10 @@ fu_dell_dock_tbt_finalize (GObject *object)
}
static void
fu_dell_dock_tbt_init (FuDellDockTbt *device)
{}
fu_dell_dock_tbt_init (FuDellDockTbt *self)
{
fu_device_set_protocol (FU_DEVICE (self), "com.intel.thunderbolt");
}
static void
fu_dell_dock_tbt_class_init (FuDellDockTbtClass *klass)

View File

@ -142,6 +142,7 @@ fu_dell_dock_status_finalize (GObject *object)
static void
fu_dell_dock_status_init (FuDellDockStatus *self)
{
fu_device_set_protocol (FU_DEVICE (self), "com.dell.dock");
}
static void

View File

@ -33,8 +33,6 @@ fu_plugin_init (FuPlugin *plugin)
/* currently slower performance, but more reliable in corner cases */
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_BETTER_THAN, "synapticsmst");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.dell.dock");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.synaptics.mst");
}
static gboolean

View File

@ -332,6 +332,13 @@ dfu_device_add_targets (DfuDevice *device, GError **error)
priv->version = DFU_VERSION_DFU_1_1;
}
/* set expected protocol */
if (priv->version == DFU_VERSION_DFUSE) {
fu_device_set_protocol (FU_DEVICE (device), "com.st.dfuse");
} else {
fu_device_set_protocol (FU_DEVICE (device), "org.usb.dfu");
}
/* fix up the transfer size */
if (priv->transfer_size == 0xffff) {
priv->transfer_size = 0x0400;

View File

@ -15,7 +15,5 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.usb.dfu");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.st.dfuse");
fu_plugin_set_device_gtype (plugin, DFU_TYPE_DEVICE);
}

View File

@ -578,6 +578,7 @@ fu_ebitdo_device_prepare_firmware (FuDevice *device,
static void
fu_ebitdo_device_init (FuEbitdoDevice *self)
{
fu_device_set_protocol (FU_DEVICE (self), "com.8bitdo");
}
static void

View File

@ -16,7 +16,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.8bitdo");
fu_plugin_set_device_gtype (plugin, FU_TYPE_EBITDO_DEVICE);
fu_plugin_add_firmware_gtype (plugin, "8bitdo", FU_TYPE_EBITDO_FIRMWARE);
}

View File

@ -478,6 +478,7 @@ fu_emmc_device_write_firmware (FuDevice *device,
static void
fu_emmc_device_init (FuEmmcDevice *self)
{
fu_device_set_protocol (FU_DEVICE (self), "org.jedec.mmc");
fu_device_add_icon (FU_DEVICE (self), "media-memory");
}

View File

@ -16,6 +16,5 @@ fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_udev_subsystem (plugin, "block");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.jedec.mmc");
fu_plugin_set_device_gtype (plugin, FU_TYPE_EMMC_DEVICE);
}

View File

@ -694,6 +694,7 @@ fu_fastboot_device_init (FuFastbootDevice *self)
{
/* this is a safe default, even using USBv1 */
self->blocksz = 512;
fu_device_set_protocol (FU_DEVICE (self), "com.google.fastboot");
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_IS_BOOTLOADER);
fu_device_set_remove_delay (FU_DEVICE (self), FASTBOOT_REMOVE_DELAY_RE_ENUMERATE);

View File

@ -15,6 +15,5 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.google.fastboot");
fu_plugin_set_device_gtype (plugin, FU_TYPE_FASTBOOT_DEVICE);
}

View File

@ -41,7 +41,6 @@ fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_alloc_data (plugin, sizeof (FuPluginData));
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.flashrom");
}
void
@ -101,6 +100,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error)
g_autoptr(FuDevice) dev = fu_device_new ();
fu_device_set_id (dev, device_id);
fu_device_set_quirks (dev, fu_plugin_get_quirks (plugin));
fu_device_set_protocol (dev, "org.flashrom");
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_INTERNAL);
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_set_name (dev, fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_PRODUCT_NAME));

View File

@ -588,6 +588,7 @@ fu_logitech_hidpp_peripheral_setup (FuDevice *device, GError **error)
self->is_updatable = TRUE;
fu_device_remove_flag (FU_DEVICE (device), FWUPD_DEVICE_FLAG_IS_BOOTLOADER);
}
fu_device_set_protocol (FU_DEVICE (device), "com.logitech.unifyingsigned");
}
idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU);
if (idx != 0x00) {
@ -1020,6 +1021,7 @@ fu_logitech_hidpp_peripheral_init (FuLogitechHidPpPeripheral *self)
self->feature_index = g_ptr_array_new_with_free_func (g_free);
fu_device_add_parent_guid (FU_DEVICE (self), "HIDRAW\\VEN_046D&DEV_C52B");
fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE);
fu_device_set_protocol (FU_DEVICE (self), "com.logitech.unifying");
/* there are a lot of unifying peripherals, but not all respond
* well to opening -- so limit to ones with issued updates */

View File

@ -35,8 +35,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.logitech.unifying");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.logitech.unifyingsigned");
fu_plugin_add_udev_subsystem (plugin, "hidraw");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_CONFLICTS, "unifying");

View File

@ -431,6 +431,7 @@ fu_nvme_device_init (FuNvmeDevice *self)
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_set_summary (FU_DEVICE (self), "NVM Express Solid State Drive");
fu_device_add_icon (FU_DEVICE (self), "drive-harddisk");
fu_device_set_protocol (FU_DEVICE (self), "org.nvmexpress");
fu_udev_device_set_readonly (FU_UDEV_DEVICE (self), TRUE);
}

View File

@ -16,6 +16,5 @@ fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_udev_subsystem (plugin, "nvme");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.nvmexpress");
fu_plugin_set_device_gtype (plugin, FU_TYPE_NVME_DEVICE);
}

View File

@ -121,7 +121,6 @@ fu_plugin_init (FuPlugin *plugin)
{
FuPluginData *data = fu_plugin_alloc_data (plugin, sizeof (FuPluginData));
data->client = fu_redfish_client_new ();
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.dmtf.redfish");
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
}

View File

@ -123,6 +123,7 @@ fu_redfish_client_coldplug_member (FuRedfishClient *self,
id = g_strdup_printf ("Redfish-Inventory-%s",
json_object_get_string_member (member, "Id"));
fu_device_set_id (dev, id);
fu_device_set_protocol (dev, "org.dmtf.redfish");
fu_device_add_guid (dev, guid);
if (json_object_has_member (member, "Name"))

View File

@ -16,7 +16,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.realtek.rts54");
fu_plugin_set_device_gtype (plugin, FU_TYPE_RTS54HID_DEVICE);
/* register the custom types */

View File

@ -377,6 +377,7 @@ fu_rts54hid_device_write_firmware (FuDevice *device,
static void
fu_rts54hid_device_init (FuRts54HidDevice *self)
{
fu_device_set_protocol (FU_DEVICE (self), "com.realtek.rts54");
}
static void

View File

@ -15,6 +15,5 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.realtek.rts54");
fu_plugin_set_device_gtype (plugin, FU_TYPE_RTS54HUB_DEVICE);
}

View File

@ -416,6 +416,7 @@ fu_rts54hub_device_prepare_firmware (FuDevice *device,
static void
fu_rts54hub_device_init (FuRts54HubDevice *self)
{
fu_device_set_protocol (FU_DEVICE (self), "com.realtek.rts54");
fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE);
}

View File

@ -16,7 +16,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.solokeys");
fu_plugin_set_device_gtype (plugin, FU_TYPE_SOLOKEY_DEVICE);
fu_plugin_add_firmware_gtype (plugin, "solokey", FU_TYPE_SOLOKEY_FIRMWARE);
}

View File

@ -484,6 +484,7 @@ fu_solokey_device_init (FuSolokeyDevice *self)
self->cid = 0xffffffff;
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_USER_REPLUG);
fu_device_set_protocol (FU_DEVICE (self), "com.solokeys");
fu_device_set_name (FU_DEVICE (self), "Solo Secure");
fu_device_set_summary (FU_DEVICE (self), "An open source FIDO2 security key");
fu_device_add_icon (FU_DEVICE (self), "applications-internet");

View File

@ -90,7 +90,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "tw.com.ite.superio");
}
gboolean

View File

@ -396,6 +396,7 @@ fu_superio_device_init (FuSuperioDevice *self)
fu_device_set_physical_id (FU_DEVICE (self), "/dev/port");
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_INTERNAL);
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE);
fu_device_set_protocol (FU_DEVICE (self), "tw.com.ite.superio");
fu_device_set_summary (FU_DEVICE (self), "Embedded Controller");
fu_device_add_icon (FU_DEVICE (self), "computer");
}

View File

@ -16,7 +16,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.synaptics.prometheus");
fu_plugin_set_device_gtype (plugin, FU_TYPE_SYNAPROM_DEVICE);
fu_plugin_add_firmware_gtype (plugin, "synaprom", FU_TYPE_SYNAPROM_FIRMWARE);
}

View File

@ -203,6 +203,7 @@ fu_synaprom_config_write_firmware (FuDevice *device,
static void
fu_synaprom_config_init (FuSynapromConfig *self)
{
fu_device_set_protocol (FU_DEVICE (self), "com.synaptics.prometheus.config");
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_set_logical_id (FU_DEVICE (self), "cfg");
fu_device_set_name (FU_DEVICE (self), "Prometheus IOTA Config");

View File

@ -436,6 +436,7 @@ fu_synaprom_device_init (FuSynapromDevice *self)
{
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_CAN_VERIFY);
fu_device_set_protocol (FU_DEVICE (self), "com.synaptics.prometheus");
fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE);
fu_device_set_name (FU_DEVICE (self), "Prometheus");
fu_device_set_summary (FU_DEVICE (self), "Fingerprint reader");

View File

@ -16,7 +16,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.synaptics.rmi");
fu_plugin_add_udev_subsystem (plugin, "hidraw");
fu_plugin_set_device_gtype (plugin, FU_TYPE_SYNAPTICS_RMI_DEVICE);
fu_plugin_add_firmware_gtype (plugin, "rmi", FU_TYPE_SYNAPTICS_RMI_FIRMWARE);

View File

@ -993,6 +993,7 @@ static void
fu_synaptics_rmi_device_init (FuSynapticsRmiDevice *self)
{
FuSynapticsRmiDevicePrivate *priv = GET_PRIVATE (self);
fu_device_set_protocol (FU_DEVICE (self), "com.synaptics.rmi");
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_set_name (FU_DEVICE (self), "Touchpad");
fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE);

View File

@ -171,7 +171,6 @@ fu_plugin_init (FuPlugin *plugin)
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_udev_subsystem (plugin, "drm"); /* used for uevent only */
fu_plugin_add_udev_subsystem (plugin, "drm_dp_aux_dev");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.synaptics.mst");
}
void

View File

@ -68,6 +68,7 @@ fu_synapticsmst_device_finalize (GObject *object)
static void
fu_synapticsmst_device_init (FuSynapticsmstDevice *self)
{
fu_device_set_protocol (FU_DEVICE (self), "com.synaptics.mst");
fu_device_set_vendor (FU_DEVICE (self), "Synaptics");
fu_device_set_summary (FU_DEVICE (self), "Multi-Stream Transport Device");
fu_device_add_icon (FU_DEVICE (self), "video-display");

View File

@ -20,7 +20,6 @@ fu_plugin_init (FuPlugin *plugin)
fu_plugin_set_build_hash (plugin, "invalid");
else
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.acme.test");
fu_plugin_alloc_data (plugin, sizeof (FuPluginData));
g_debug ("init");
}
@ -43,6 +42,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error)
fu_device_add_icon (device, "preferences-desktop-keyboard");
fu_device_add_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_add_flag (device, FWUPD_DEVICE_FLAG_CAN_VERIFY);
fu_device_set_protocol (device, "com.acme.test");
fu_device_set_summary (device, "A fake webcam");
fu_device_set_vendor (device, "ACME Corp.");
fu_device_set_vendor_id (device, "USB:0x046D");

View File

@ -407,6 +407,7 @@ fu_plugin_thunderbolt_add (FuPlugin *plugin, GUdevDevice *device)
if (is_host)
fu_device_set_summary (dev, "Unmatched performance for high-speed I/O");
fu_device_add_icon (dev, "thunderbolt");
fu_device_set_protocol (dev, "com.intel.thunderbolt");
fu_device_set_quirks (dev, fu_plugin_get_quirks (plugin));
vendor = g_udev_device_get_sysfs_attr (device, "vendor_name");
@ -640,7 +641,6 @@ fu_plugin_init (FuPlugin *plugin)
const gchar *subsystems[] = { "thunderbolt", NULL };
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.intel.thunderbolt");
data->udev = g_udev_client_new (subsystems);
g_signal_connect (data->udev, "uevent",
G_CALLBACK (udev_uevent_cb), plugin);

View File

@ -37,7 +37,6 @@ fu_plugin_init (FuPlugin *plugin)
FuPluginData *data = fu_plugin_alloc_data (plugin, sizeof (FuPluginData));
data->bgrt = fu_uefi_bgrt_new ();
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.uefi.capsule");
fu_plugin_add_compile_version (plugin, "com.redhat.efivar", EFIVAR_LIBRARY_VERSION);
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
}

View File

@ -721,6 +721,7 @@ fu_uefi_device_probe (FuDevice *device, GError **error)
static void
fu_uefi_device_init (FuUefiDevice *self)
{
fu_device_set_protocol (FU_DEVICE (self), "org.uefi.capsule");
}
static void

View File

@ -17,7 +17,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.vli.usbhub");
fu_plugin_set_device_gtype (plugin, FU_TYPE_VLI_USBHUB_DEVICE);
fu_plugin_add_firmware_gtype (plugin, "vli-usbhub", FU_TYPE_VLI_USBHUB_FIRMWARE);
fu_plugin_add_firmware_gtype (plugin, "vli-usbhub-pd", FU_TYPE_VLI_USBHUB_PD_FIRMWARE);

View File

@ -1498,6 +1498,7 @@ fu_vli_usbhub_device_init (FuVliUsbhubDevice *self)
self->spi_cmd_read_id = 0x9f;
self->spi_cmd_read_id_sz = 2;
fu_device_add_icon (FU_DEVICE (self), "audio-card");
fu_device_set_protocol (FU_DEVICE (self), "com.vli.usbhub");
fu_device_set_firmware_size_max (FU_DEVICE (self), 0x20000);
fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE);
}

View File

@ -16,7 +16,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.wacom.raw");
fu_plugin_add_udev_subsystem (plugin, "hidraw");
/* register the custom types */

View File

@ -339,6 +339,7 @@ fu_wacom_device_set_quirk_kv (FuDevice *device,
static void
fu_wacom_device_init (FuWacomDevice *self)
{
fu_device_set_protocol (FU_DEVICE (self), "com.wacom.raw");
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_INTERNAL);
}

View File

@ -16,7 +16,6 @@ void
fu_plugin_init (FuPlugin *plugin)
{
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.wacom.usb");
fu_plugin_set_device_gtype (plugin, FU_TYPE_WAC_DEVICE);
fu_plugin_add_firmware_gtype (plugin, "wacom", FU_TYPE_WAC_FIRMWARE);
}

View File

@ -850,6 +850,7 @@ fu_wac_device_init (FuWacDevice *self)
self->checksums = g_array_new (FALSE, FALSE, sizeof(guint32));
self->configuration = 0xffff;
self->firmware_index = 0xffff;
fu_device_set_protocol (FU_DEVICE (self), "com.wacom.usb");
fu_device_add_icon (FU_DEVICE (self), "input-tablet");
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_set_install_duration (FU_DEVICE (self), 10);

View File

@ -36,6 +36,7 @@ typedef struct {
gchar *equivalent_id;
gchar *physical_id;
gchar *logical_id;
gchar *protocol;
FuDevice *alternate;
FuDevice *parent; /* noref */
FuQuirks *quirks;
@ -65,6 +66,7 @@ enum {
PROP_PROGRESS,
PROP_PHYSICAL_ID,
PROP_LOGICAL_ID,
PROP_PROTOCOL,
PROP_QUIRKS,
PROP_LAST
};
@ -91,6 +93,9 @@ fu_device_get_property (GObject *object, guint prop_id,
case PROP_LOGICAL_ID:
g_value_set_string (value, priv->logical_id);
break;
case PROP_PROTOCOL:
g_value_set_string (value, priv->protocol);
break;
case PROP_QUIRKS:
g_value_set_object (value, priv->quirks);
break;
@ -118,6 +123,9 @@ fu_device_set_property (GObject *object, guint prop_id,
case PROP_LOGICAL_ID:
fu_device_set_logical_id (self, g_value_get_string (value));
break;
case PROP_PROTOCOL:
fu_device_set_protocol (self, g_value_get_string (value));
break;
case PROP_QUIRKS:
fu_device_set_quirks (self, g_value_get_object (value));
break;
@ -1411,6 +1419,42 @@ fu_device_set_logical_id (FuDevice *self, const gchar *logical_id)
priv->logical_id = g_strdup (logical_id);
}
/**
* fu_device_get_protocol:
* @self: A #FuDevice
*
* Gets the protocol ID on the device.
*
* Returns: a string value e.g. `org.hughski.colorhug`, or %NULL
*
* Since: 1.3.5
**/
const gchar *
fu_device_get_protocol (FuDevice *self)
{
FuDevicePrivate *priv = GET_PRIVATE (self);
g_return_val_if_fail (FU_IS_DEVICE (self), NULL);
return priv->protocol;
}
/**
* fu_device_set_protocol:
* @self: A #FuDevice
* @protocol: a defined protocol ID, e.g. `org.hughski.colorhug`
*
* Sets the protocol ID on the device.
*
* Since: 1.3.5
**/
void
fu_device_set_protocol (FuDevice *self, const gchar *protocol)
{
FuDevicePrivate *priv = GET_PRIVATE (self);
g_return_if_fail (FU_IS_DEVICE (self));
g_free (priv->protocol);
priv->protocol = g_strdup (protocol);
}
/**
* fu_device_set_physical_id:
* @self: A #FuDevice
@ -1729,6 +1773,8 @@ fu_device_add_string (FuDevice *self, guint idt, GString *str)
fu_common_string_append_kv (str, idt + 1, "PhysicalId", priv->physical_id);
if (priv->logical_id != NULL)
fu_common_string_append_kv (str, idt + 1, "LogicalId", priv->logical_id);
if (priv->protocol != NULL)
fu_common_string_append_kv (str, idt + 1, "Protocol", priv->protocol);
if (priv->size_min > 0) {
g_autofree gchar *sz = g_strdup_printf ("%" G_GUINT64_FORMAT, priv->size_min);
fu_common_string_append_kv (str, idt + 1, "FirmwareSizeMin", sz);
@ -2456,6 +2502,8 @@ fu_device_incorporate (FuDevice *self, FuDevice *donor)
fu_device_set_physical_id (self, priv_donor->physical_id);
if (priv->logical_id == NULL && priv_donor->logical_id != NULL)
fu_device_set_logical_id (self, priv_donor->logical_id);
if (priv->protocol == NULL && priv_donor->protocol != NULL)
fu_device_set_protocol (self, priv_donor->protocol);
if (priv->quirks == NULL)
fu_device_set_quirks (self, fu_device_get_quirks (donor));
g_rw_lock_reader_lock (&priv_donor->parent_guids_mutex);
@ -2535,6 +2583,11 @@ fu_device_class_init (FuDeviceClass *klass)
G_PARAM_STATIC_NAME);
g_object_class_install_property (object_class, PROP_LOGICAL_ID, pspec);
pspec = g_param_spec_string ("protocol", NULL, NULL, NULL,
G_PARAM_READWRITE |
G_PARAM_STATIC_NAME);
g_object_class_install_property (object_class, PROP_PROTOCOL, pspec);
pspec = g_param_spec_uint ("progress", NULL, NULL,
0, 100, 0,
G_PARAM_READWRITE |
@ -2586,6 +2639,7 @@ fu_device_finalize (GObject *object)
g_free (priv->equivalent_id);
g_free (priv->physical_id);
g_free (priv->logical_id);
g_free (priv->protocol);
G_OBJECT_CLASS (fu_device_parent_class)->finalize (object);
}

View File

@ -186,6 +186,9 @@ void fu_device_set_physical_id (FuDevice *self,
const gchar *fu_device_get_logical_id (FuDevice *self);
void fu_device_set_logical_id (FuDevice *self,
const gchar *logical_id);
const gchar *fu_device_get_protocol (FuDevice *self);
void fu_device_set_protocol (FuDevice *self,
const gchar *protocol);
void fu_device_add_flag (FuDevice *self,
FwupdDeviceFlags flag);
const gchar *fu_device_get_custom_flags (FuDevice *self);

View File

@ -71,7 +71,6 @@ typedef enum {
* @FU_PLUGIN_RULE_RUN_BEFORE: Order the plugin before another
* @FU_PLUGIN_RULE_BETTER_THAN: Is better than another plugin
* @FU_PLUGIN_RULE_INHIBITS_IDLE: The plugin inhibits the idle shutdown
* @FU_PLUGIN_RULE_SUPPORTS_PROTOCOL: The plugin supports a well known protocol
*
* The rules used for ordering plugins.
* Plugins are expected to add rules in fu_plugin_initialize().
@ -82,7 +81,6 @@ typedef enum {
FU_PLUGIN_RULE_RUN_BEFORE,
FU_PLUGIN_RULE_BETTER_THAN,
FU_PLUGIN_RULE_INHIBITS_IDLE,
FU_PLUGIN_RULE_SUPPORTS_PROTOCOL,
/*< private >*/
FU_PLUGIN_RULE_LAST
} FuPluginRule;