elantp: Only match the I2C adaptor on the correct laptop model

I2C doesn't have any specification for what is a probe and what is a more
destructive action. Sending tx_buf out on the i2c bus to a generic address
might not be safe in all cases.

To prevent this, use a HWID to check the machine DMI value during device
creation before ->probe() or ->setup() is called on the device.
This commit is contained in:
Richard Hughes 2020-09-09 10:22:38 +01:00
parent ad32b0c17e
commit 32173430d4
4 changed files with 19 additions and 1 deletions

View File

@ -21,7 +21,6 @@ void fu_device_set_order (FuDevice *self,
gint order);
void fu_device_set_alternate (FuDevice *self,
FuDevice *alternate);
GType fu_device_get_specialized_gtype (FuDevice *self);
gboolean fu_device_ensure_id (FuDevice *self,
GError **error);
void fu_device_incorporate_from_component (FuDevice *device,

View File

@ -267,6 +267,7 @@ void fu_device_set_quirks (FuDevice *self,
FuQuirks *quirks);
FuQuirks *fu_device_get_quirks (FuDevice *self);
FwupdRelease *fu_device_get_release_default (FuDevice *self);
GType fu_device_get_specialized_gtype (FuDevice *self);
gboolean fu_device_write_firmware (FuDevice *self,
GBytes *fw,
FwupdInstallFlags flags,

View File

@ -6,6 +6,10 @@ GType = FuElantpHidDevice
Plugin = elantp
GType = FuElantpHidDevice
# Acer Aspire V3-372T
[HwId=513cde3d-d939-59bd-a634-5c1645ebb93b]
Flags = elantp-recovery
# recovery device
[DeviceInstanceId=I2C\NAME_Synopsys-DesignWare-I2C-adapter]
Plugin = elantp

View File

@ -13,6 +13,20 @@
#include "fu-elantp-hid-device.h"
#include "fu-elantp-i2c-device.h"
gboolean
fu_plugin_device_created (FuPlugin *plugin, FuDevice *dev, GError **error)
{
if (fu_device_get_specialized_gtype (dev) == FU_TYPE_ELANTP_I2C_DEVICE &&
!fu_plugin_has_custom_flag (plugin, "elantp-recovery")) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"not required");
return FALSE;
}
return TRUE;
}
void
fu_plugin_init (FuPlugin *plugin)
{