diff --git a/libfwupdplugin/fu-cfi-device.c b/libfwupdplugin/fu-cfi-device.c index 0847a6e60..6e426234b 100644 --- a/libfwupdplugin/fu-cfi-device.c +++ b/libfwupdplugin/fu-cfi-device.c @@ -9,6 +9,7 @@ #include "config.h" #include "fu-cfi-device.h" +#include "fu-quirks.h" /** * FuCfiDevice: @@ -365,79 +366,79 @@ fu_cfi_device_set_quirk_kv(FuDevice *device, const gchar *key, const gchar *valu FuCfiDevicePrivate *priv = GET_PRIVATE(self); guint64 tmp; - if (g_strcmp0(key, "CfiDeviceCmdReadId") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_READ_ID) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) return FALSE; priv->cmds[FU_CFI_DEVICE_CMD_READ_ID] = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceCmdReadIdSz") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_READ_ID_SZ) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) return FALSE; priv->cmd_read_id_sz = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceCmdChipErase") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_CHIP_ERASE) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) return FALSE; priv->cmds[FU_CFI_DEVICE_CMD_CHIP_ERASE] = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceCmdBlockErase") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_BLOCK_ERASE) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) return FALSE; priv->cmds[FU_CFI_DEVICE_CMD_BLOCK_ERASE] = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceCmdSectorErase") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_SECTOR_ERASE) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) return FALSE; priv->cmds[FU_CFI_DEVICE_CMD_SECTOR_ERASE] = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceCmdWriteStatus") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_WRITE_STATUS) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) return FALSE; priv->cmds[FU_CFI_DEVICE_CMD_WRITE_STATUS] = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceCmdPageProg") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_PAGE_PROG) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) return FALSE; priv->cmds[FU_CFI_DEVICE_CMD_PAGE_PROG] = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceCmdReadData") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_READ_DATA) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) return FALSE; priv->cmds[FU_CFI_DEVICE_CMD_READ_DATA] = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceCmdReadStatus") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_READ_STATUS) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) return FALSE; priv->cmds[FU_CFI_DEVICE_CMD_READ_STATUS] = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceCmdWriteEn") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_WRITE_EN) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) return FALSE; priv->cmds[FU_CFI_DEVICE_CMD_WRITE_EN] = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDevicePageSize") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_PAGE_SIZE) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT32, error)) return FALSE; priv->page_size = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceSectorSize") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_SECTOR_SIZE) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT32, error)) return FALSE; priv->sector_size = tmp; return TRUE; } - if (g_strcmp0(key, "CfiDeviceBlockSize") == 0) { + if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_BLOCK_SIZE) == 0) { if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT32, error)) return FALSE; priv->block_size = tmp; diff --git a/libfwupdplugin/fu-quirks.c b/libfwupdplugin/fu-quirks.c index e5acef85c..99615c3b5 100644 --- a/libfwupdplugin/fu-quirks.c +++ b/libfwupdplugin/fu-quirks.c @@ -588,14 +588,19 @@ fu_quirks_init(FuQuirks *self) fu_quirks_add_possible_key(self, FU_QUIRKS_VENDOR_ID); fu_quirks_add_possible_key(self, FU_QUIRKS_VERSION); fu_quirks_add_possible_key(self, FU_QUIRKS_VERSION_FORMAT); - fu_quirks_add_possible_key(self, "CfiDeviceCmdBlockErase"); - fu_quirks_add_possible_key(self, "CfiDeviceCmdReadId"); - fu_quirks_add_possible_key(self, "CfiDeviceCmdReadIdSz"); - fu_quirks_add_possible_key(self, "CfiDeviceCmdChipErase"); - fu_quirks_add_possible_key(self, "CfiDeviceCmdSectorErase"); - fu_quirks_add_possible_key(self, "CfiDeviceBlockSize"); - fu_quirks_add_possible_key(self, "CfiDevicePageSize"); - fu_quirks_add_possible_key(self, "CfiDeviceSectorSize"); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_CMD_READ_ID); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_CMD_READ_ID_SZ); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_CMD_CHIP_ERASE); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_CMD_BLOCK_ERASE); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_CMD_SECTOR_ERASE); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_CMD_WRITE_STATUS); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_CMD_PAGE_PROG); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_CMD_READ_DATA); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_CMD_READ_STATUS); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_CMD_WRITE_EN); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_PAGE_SIZE); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_SECTOR_SIZE); + fu_quirks_add_possible_key(self, FU_QUIRKS_CFI_DEVICE_BLOCK_SIZE); } static void diff --git a/libfwupdplugin/fu-quirks.h b/libfwupdplugin/fu-quirks.h index ce1df91bb..cd112c015 100644 --- a/libfwupdplugin/fu-quirks.h +++ b/libfwupdplugin/fu-quirks.h @@ -292,3 +292,107 @@ fu_quirks_add_possible_key(FuQuirks *self, const gchar *possible_key); * Since: 1.7.6 **/ #define FU_QUIRKS_ISSUE "Issue" +/** + * FU_QUIRKS_CFI_DEVICE_CMD_READ_ID + * + * The quirk key to set the CFI read ID command. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_CMD_READ_ID "CfiDeviceCmdReadId" +/** + * FU_QUIRKS_CFI_DEVICE_CMD_READ_ID_SZ + * + * The quirk key to set the CFI read ID size. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_CMD_READ_ID_SZ "CfiDeviceCmdReadIdSz" +/** + * FU_QUIRKS_CFI_DEVICE_CMD_CHIP_ERASE + * + * The quirk key to set the CFI chip erase command. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_CMD_CHIP_ERASE "CfiDeviceCmdChipErase" +/** + * FU_QUIRKS_CFI_DEVICE_CMD_BLOCK_ERASE + * + * The quirk key to set the CFI block erase command. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_CMD_BLOCK_ERASE "CfiDeviceCmdBlockErase" +/** + * FU_QUIRKS_CFI_DEVICE_CMD_SECTOR_ERASE + * + * The quirk key to set the CFI sector erase command. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_CMD_SECTOR_ERASE "CfiDeviceCmdSectorErase" +/** + * FU_QUIRKS_CFI_DEVICE_CMD_WRITE_STATUS + * + * The quirk key to set the CFI write status command. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_CMD_WRITE_STATUS "CfiDeviceCmdWriteStatus" +/** + * FU_QUIRKS_CFI_DEVICE_CMD_PAGE_PROG + * + * The quirk key to set the CFI page program command. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_CMD_PAGE_PROG "CfiDeviceCmdPageProg" +/** + * FU_QUIRKS_CFI_DEVICE_CMD_READ_DATA + * + * The quirk key to set the CFI read data command. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_CMD_READ_DATA "CfiDeviceCmdReadData" +/** + * FU_QUIRKS_CFI_DEVICE_CMD_READ_STATUS + * + * The quirk key to set the CFI read status command. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_CMD_READ_STATUS "CfiDeviceCmdReadStatus" +/** + * FU_QUIRKS_CFI_DEVICE_CMD_WRITE_EN + * + * The quirk key to set the CFI write en command. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_CMD_WRITE_EN "CfiDeviceCmdWriteEn" +/** + * FU_QUIRKS_CFI_DEVICE_PAGE_SIZE + * + * The quirk key to set the CFI page size. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_PAGE_SIZE "CfiDevicePageSize" +/** + * FU_QUIRKS_CFI_DEVICE_SECTOR_SIZE + * + * The quirk key to set the CFI sector size. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_SECTOR_SIZE "CfiDeviceSectorSize" +/** + * FU_QUIRKS_CFI_DEVICE_BLOCK_SIZE + * + * The quirk key to set the CFI block size. + * + * Since: 1.8.2 + **/ +#define FU_QUIRKS_CFI_DEVICE_BLOCK_SIZE "CfiDeviceBlockSize"