mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-13 21:35:02 +00:00
vli: Allow setting the device kind from a quirk
This commit is contained in:
parent
050f998835
commit
e2a9b15f16
@ -51,6 +51,7 @@ This plugin uses the following plugin-specific quirks:
|
||||
|
||||
| Quirk | Description | Minimum fwupd version |
|
||||
|----------------------------|----------------------------------|-----------------------|
|
||||
| `DeviceKind` | Device kind, e.g. `VL102` | 1.3.7 |
|
||||
| `SpiCmdChipErase` | Flash command to erase chip | 1.3.3 |
|
||||
| `SpiCmdChipErase` | Flash command to erase sector | 1.3.3 |
|
||||
| `SpiCmdReadId` | Flash command to read the ID | 1.3.3 |
|
||||
|
31
plugins/vli/fu-self-test.c
Normal file
31
plugins/vli/fu-self-test.c
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Richard Hughes <richard@hughsie.com>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1+
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <fwupd.h>
|
||||
|
||||
#include "fu-vli-common.h"
|
||||
|
||||
static void
|
||||
fu_test_common_device_kind_func (void)
|
||||
{
|
||||
for (guint i = 0; i < 0xffff; i++) {
|
||||
const gchar *tmp = fu_vli_common_device_kind_to_string (i);
|
||||
if (tmp == NULL)
|
||||
continue;
|
||||
g_assert_cmpint (fu_vli_common_device_kind_from_string (tmp), ==, i);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
|
||||
g_test_add_func ("/vli/common{device-kind}", fu_test_common_device_kind_func);
|
||||
return g_test_run ();
|
||||
}
|
@ -95,6 +95,60 @@ fu_vli_common_device_kind_to_string (FuVliDeviceKind device_kind)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FuVliDeviceKind
|
||||
fu_vli_common_device_kind_from_string (const gchar *device_kind)
|
||||
{
|
||||
if (g_strcmp0 (device_kind, "VL100") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL100;
|
||||
if (g_strcmp0 (device_kind, "VL101") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL101;
|
||||
if (g_strcmp0 (device_kind, "VL102") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL102;
|
||||
if (g_strcmp0 (device_kind, "VL103") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL103;
|
||||
if (g_strcmp0 (device_kind, "VL104") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL104;
|
||||
if (g_strcmp0 (device_kind, "VL105") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL105;
|
||||
if (g_strcmp0 (device_kind, "VL810") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL810;
|
||||
if (g_strcmp0 (device_kind, "VL811") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL811;
|
||||
if (g_strcmp0 (device_kind, "VL811PB0") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL811PB0;
|
||||
if (g_strcmp0 (device_kind, "VL811PB3") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL811PB3;
|
||||
if (g_strcmp0 (device_kind, "VL812B0") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL812B0;
|
||||
if (g_strcmp0 (device_kind, "VL812B3") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL812B3;
|
||||
if (g_strcmp0 (device_kind, "VL812Q4S") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL812Q4S;
|
||||
if (g_strcmp0 (device_kind, "VL813") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL813;
|
||||
if (g_strcmp0 (device_kind, "VL815") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL815;
|
||||
if (g_strcmp0 (device_kind, "VL817") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL817;
|
||||
if (g_strcmp0 (device_kind, "VL819") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL819;
|
||||
if (g_strcmp0 (device_kind, "VL820Q7") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL820Q7;
|
||||
if (g_strcmp0 (device_kind, "VL820Q8") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL820Q8;
|
||||
if (g_strcmp0 (device_kind, "VL120") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL120;
|
||||
if (g_strcmp0 (device_kind, "VL210") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL210;
|
||||
if (g_strcmp0 (device_kind, "VL211") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL211;
|
||||
if (g_strcmp0 (device_kind, "VL212") == 0)
|
||||
return FU_VLI_DEVICE_KIND_VL212;
|
||||
if (g_strcmp0 (device_kind, "MSP430") == 0)
|
||||
return FU_VLI_DEVICE_KIND_MSP430;
|
||||
return FU_VLI_DEVICE_KIND_UNKNOWN;
|
||||
}
|
||||
|
||||
guint32
|
||||
fu_vli_common_device_kind_get_size (FuVliDeviceKind device_kind)
|
||||
{
|
||||
|
@ -38,6 +38,7 @@ typedef enum {
|
||||
} FuVliDeviceKind;
|
||||
|
||||
const gchar *fu_vli_common_device_kind_to_string (FuVliDeviceKind device_kind);
|
||||
FuVliDeviceKind fu_vli_common_device_kind_from_string (const gchar *device_kind);
|
||||
guint32 fu_vli_common_device_kind_get_size (FuVliDeviceKind device_kind);
|
||||
guint32 fu_vli_common_device_kind_get_offset (FuVliDeviceKind device_kind);
|
||||
|
||||
|
@ -220,6 +220,18 @@ fu_vli_device_set_quirk_kv (FuDevice *device,
|
||||
priv->spi_cmds[FU_VLI_DEVICE_SPI_REQ_SECTOR_ERASE] = fu_common_strtoull (value);
|
||||
return TRUE;
|
||||
}
|
||||
if (g_strcmp0 (key, "DeviceKind") == 0) {
|
||||
priv->kind = fu_vli_common_device_kind_from_string (value);
|
||||
if (priv->kind == FU_VLI_DEVICE_KIND_UNKNOWN) {
|
||||
g_set_error (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_NOT_SUPPORTED,
|
||||
"DeviceKind %s is not supported",
|
||||
value);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
g_set_error_literal (error,
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_NOT_SUPPORTED,
|
||||
|
@ -38,3 +38,30 @@ shared_module('fu_plugin_vli',
|
||||
plugin_deps,
|
||||
],
|
||||
)
|
||||
|
||||
if get_option('tests')
|
||||
testdatadir = join_paths(meson.current_source_dir(), 'data')
|
||||
cargs += '-DTESTDATADIR="' + testdatadir + '"'
|
||||
e = executable(
|
||||
'vli-self-test',
|
||||
fu_hash,
|
||||
sources : [
|
||||
'fu-self-test.c',
|
||||
'fu-vli-common.c',
|
||||
],
|
||||
include_directories : [
|
||||
root_incdir,
|
||||
fwupd_incdir,
|
||||
fwupdplugin_incdir,
|
||||
],
|
||||
dependencies : [
|
||||
plugin_deps,
|
||||
],
|
||||
link_with : [
|
||||
fwupd,
|
||||
fwupdplugin,
|
||||
],
|
||||
c_args : cargs
|
||||
)
|
||||
test('vli-self-test', e)
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user