optionrom: Test if the PCI device has ROM in probe

This means we make things a simpler by not relying on udev to stat the file.
It also reduces the number of added *unused* GUIDs by one per device too.
This commit is contained in:
Richard Hughes 2020-09-19 10:59:47 +01:00
parent b9ef4399c9
commit 7ef2dea271
2 changed files with 5 additions and 8 deletions

View File

@ -4,8 +4,5 @@
# SPDX-License-Identifier: LGPL-2.1+
#
# PCI cards with ROM
SUBSYSTEM=="pci", TEST=="/sys$devpath/rom", ENV{FWUPD_GUID}="$attr{vendor}:$attr{device}"
# NVMe hardware
SUBSYSTEM=="nvme", ENV{ID_VENDOR_FROM_DATABASE}=="", IMPORT{builtin}="hwdb --subsystem=pci"

View File

@ -18,15 +18,15 @@ G_DEFINE_TYPE (FuOptionromDevice, fu_optionrom_device, FU_TYPE_UDEV_DEVICE)
static gboolean
fu_optionrom_device_probe (FuUdevDevice *device, GError **error)
{
GUdevDevice *udev_device = fu_udev_device_get_dev (device);
const gchar *guid = NULL;
g_autofree gchar *fn = NULL;
guid = g_udev_device_get_property (udev_device, "FWUPD_GUID");
if (guid == NULL) {
/* does the device even have ROM? */
fn = g_build_filename (fu_udev_device_get_sysfs_path (device), "rom", NULL);
if (!g_file_test (fn, G_FILE_TEST_EXISTS)) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"no FWUPD_GUID property");
"Unable to read firmware from device");
return FALSE;
}