1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
From 7a910b216e77b21dfdf0582118b5b6e9dba90e1a Mon Sep 17 00:00:00 2001
From: Richard Hughes <richard@hughsie.com>
Date: Mon, 13 Oct 2025 16:12:34 +0100
Subject: [PATCH] Revert "flashrom: Do not use deprecated API"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit 0731ac4730520b68adca26e8b06a26cc88b32ccb.
We can't use `flashrom_flash_probe_v2` as an external user of libflashrom as
it expects to be allocated on the stack -- but according to the compiler,
the `storage size of ‘structflashrom_flashctx’ isn't known` and there is no API
interface to allocate a flashctx on the heap. The old `flashrom_flash_probe`
method returned us a pointer to the allocated flashctx and didn't have this
problem.
The new API is badly designed and unusable, so use the old deprecated method.
Fixes https://github.com/fwupd/fwupd/issues/9379
---
meson.build | 6 --
plugins/flashrom/fu-flashrom-plugin.c | 89 +++++++--------------------
2 files changed, 23 insertions(+), 72 deletions(-)
diff --git a/meson.build b/meson.build
index eb65036f1..b711ab04b 100644
--- a/meson.build
+++ b/meson.build
@@ -669,12 +669,6 @@ if build_standalone
)
conf.set('HAVE_FLASHROM_SET_PROGRESS_CALLBACK_V2' , '1')
endif
- if libflashrom.type_name() == 'pkgconfig' and cc.has_function(
- 'flashrom_flash_probe_v2',
- dependencies: libflashrom,
- )
- conf.set('HAVE_FLASHROM_FLASH_PROBE_V2' , '1')
- endif
endif
if libsystemd.found()
diff --git a/plugins/flashrom/fu-flashrom-plugin.c b/plugins/flashrom/fu-flashrom-plugin.c
index 1fca2dd99..3939eb552 100644
--- a/plugins/flashrom/fu-flashrom-plugin.c
+++ b/plugins/flashrom/fu-flashrom-plugin.c
@@ -291,76 +291,12 @@ fu_flashrom_plugin_find_guid(FuPlugin *plugin, GError **error)
return NULL;
}
-typedef char *flashrom_data;
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(flashrom_data, flashrom_data_free)
-
-static gboolean
-fu_flashrom_plugin_probe(FuFlashromPlugin *self, GError **error)
-{
- gint rc;
-#ifdef HAVE_FLASHROM_FLASH_PROBE_V2
- g_autoptr(flashrom_data) all_matched_names = NULL;
-
- rc = flashrom_flash_probe_v2(self->flashctx,
- (const char ***const)&all_matched_names,
- self->flashprog,
- NULL);
- if (rc == -1) {
- g_set_error_literal(error,
- FWUPD_ERROR,
- FWUPD_ERROR_NOT_SUPPORTED,
- "flash probe failed: unknown error");
- return FALSE;
- }
- if (rc == 0) {
- g_set_error_literal(error,
- FWUPD_ERROR,
- FWUPD_ERROR_NOT_SUPPORTED,
- "flash probe failed: no chips matched");
- return FALSE;
- }
- if (rc > 1) {
- g_autofree gchar *names = g_strjoinv(",", all_matched_names);
- g_set_error(error,
- FWUPD_ERROR,
- FWUPD_ERROR_NOT_SUPPORTED,
- "flash probe failed: multiple chips were found: %s",
- names);
- return FALSE;
- }
-#else
- rc = flashrom_flash_probe(&self->flashctx, self->flashprog, NULL);
- if (rc == 3) {
- g_set_error_literal(error,
- FWUPD_ERROR,
- FWUPD_ERROR_NOT_SUPPORTED,
- "flash probe failed: multiple chips were found");
- return FALSE;
- }
- if (rc == 2) {
- g_set_error_literal(error,
- FWUPD_ERROR,
- FWUPD_ERROR_NOT_SUPPORTED,
- "flash probe failed: no chip was found");
- return FALSE;
- }
- if (rc != 0) {
- g_set_error_literal(error,
- FWUPD_ERROR,
- FWUPD_ERROR_NOT_SUPPORTED,
- "flash probe failed: unknown error");
- return FALSE;
- }
-#endif
- /* success */
- return TRUE;
-}
-
static gboolean
fu_flashrom_plugin_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{
const gchar *flashrom_args;
const gchar *flashrom_prog;
+ gint rc;
const gchar *guid;
FuContext *ctx = fu_plugin_get_context(plugin);
FuFlashromPlugin *self = FU_FLASHROM_PLUGIN(plugin);
@@ -405,8 +341,29 @@ fu_flashrom_plugin_startup(FuPlugin *plugin, FuProgress *progress, GError **erro
"programmer initialization failed");
return FALSE;
}
- if (!fu_flashrom_plugin_probe(self, error))
+
+ rc = flashrom_flash_probe(&self->flashctx, self->flashprog, NULL);
+ if (rc == 3) {
+ g_set_error_literal(error,
+ FWUPD_ERROR,
+ FWUPD_ERROR_NOT_SUPPORTED,
+ "flash probe failed: multiple chips were found");
+ return FALSE;
+ }
+ if (rc == 2) {
+ g_set_error_literal(error,
+ FWUPD_ERROR,
+ FWUPD_ERROR_NOT_SUPPORTED,
+ "flash probe failed: no chip was found");
return FALSE;
+ }
+ if (rc != 0) {
+ g_set_error_literal(error,
+ FWUPD_ERROR,
+ FWUPD_ERROR_NOT_SUPPORTED,
+ "flash probe failed: unknown error");
+ return FALSE;
+ }
fu_progress_step_done(progress);
return TRUE;
--
2.43.0
|