From 04778ddd3814f8764eec8b0f43150a07d9356221 Mon Sep 17 00:00:00 2001 From: Maximilian Brune Date: Fri, 7 Nov 2025 21:41:12 +0100 Subject: [PATCH] drivers/option/cfr: Remove old sm_object from constructor There is no reason I can think to also pass the old object into the constructor considering that the new objects contains the exact same contents during that call (it's copied over a few lines above). Signed-off-by: Maximilian Brune Change-Id: Idd5b34134b6064c19266448b551248eb29e097fe Reviewed-on: https://review.coreboot.org/c/coreboot/+/89957 Reviewed-by: Elyes Haouas Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons Reviewed-by: Sean Rhodes Reviewed-by: Matt DeVillier --- Documentation/drivers/cfr_internal.md | 2 +- src/drivers/option/cfr.c | 2 +- src/drivers/option/cfr_frontend.h | 2 +- src/mainboard/lenovo/sklkbl_thinkpad/cfr.c | 2 +- src/mainboard/prodrive/atlas/cfr.c | 16 ++++++++-------- src/mainboard/starlabs/common/cfr/cfr.c | 4 +--- .../starlabs/common/include/common/cfr.h | 2 +- src/mainboard/starlabs/starlite_adl/cfr.c | 2 +- 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Documentation/drivers/cfr_internal.md b/Documentation/drivers/cfr_internal.md index 6aa896ed68..82f5bda04c 100644 --- a/Documentation/drivers/cfr_internal.md +++ b/Documentation/drivers/cfr_internal.md @@ -78,7 +78,7 @@ coreboot table. EMI eeprom. ``` -static void update_serial(const struct sm_object *obj, struct sm_object *new) +static void update_serial(struct sm_object *new) { new->sm_varchar.default_value = get_emi_eeprom_vpd()->serial_number; } diff --git a/src/drivers/option/cfr.c b/src/drivers/option/cfr.c index a332d906d6..d338648029 100644 --- a/src/drivers/option/cfr.c +++ b/src/drivers/option/cfr.c @@ -347,8 +347,8 @@ static uint32_t sm_write_object(char *current, const struct sm_object *sm_obj) /* Invoke callback to update fields */ if (sm_obj->ctor) { memcpy(&sm_obj_copy, sm_obj, sizeof(*sm_obj)); - sm_obj->ctor(sm_obj, &sm_obj_copy); + sm_obj->ctor(&sm_obj_copy); assert(sm_obj->kind == sm_obj_copy.kind); sm_obj = (const struct sm_object *)&sm_obj_copy; } diff --git a/src/drivers/option/cfr_frontend.h b/src/drivers/option/cfr_frontend.h index 3beaaa7690..4a154be985 100644 --- a/src/drivers/option/cfr_frontend.h +++ b/src/drivers/option/cfr_frontend.h @@ -82,7 +82,7 @@ struct sm_object { const struct sm_object *dep; const uint32_t *dep_values; const uint32_t num_dep_values; - void (*ctor)(const struct sm_object *obj, struct sm_object *new); /* Called on object creation */ + void (*ctor)(struct sm_object *new); /* Called on object creation */ union { struct sm_obj_enum sm_enum; struct sm_obj_number sm_number; diff --git a/src/mainboard/lenovo/sklkbl_thinkpad/cfr.c b/src/mainboard/lenovo/sklkbl_thinkpad/cfr.c index 45f344b939..8f282facdd 100644 --- a/src/mainboard/lenovo/sklkbl_thinkpad/cfr.c +++ b/src/mainboard/lenovo/sklkbl_thinkpad/cfr.c @@ -9,7 +9,7 @@ #include /* Hide the dGPU CFR entry if dGPU not present */ -static void update_dgpu(const struct sm_object *obj, struct sm_object *new) +static void update_dgpu(struct sm_object *new) { struct device *dgpu = DEV_PTR(dgpu); if (!dgpu || !dgpu->enabled) { diff --git a/src/mainboard/prodrive/atlas/cfr.c b/src/mainboard/prodrive/atlas/cfr.c index f5700e2ba0..b275bd23c8 100644 --- a/src/mainboard/prodrive/atlas/cfr.c +++ b/src/mainboard/prodrive/atlas/cfr.c @@ -12,23 +12,23 @@ #include "vpd.h" -static void update_rt_perf(const struct sm_object *obj, struct sm_object *new) +static void update_rt_perf(struct sm_object *new) { const bool rt_perf = get_emi_eeprom_vpd()->profile == ATLAS_PROF_REALTIME_PERFORMANCE; if (!rt_perf) return; - if (obj->kind == SM_OBJ_BOOL) { + if (new->kind == SM_OBJ_BOOL) { new->sm_bool.flags = CFR_OPTFLAG_SUPPRESS; new->sm_bool.default_value = false; - } else if (obj->kind == SM_OBJ_ENUM) { + } else if (new->kind == SM_OBJ_ENUM) { new->sm_enum.flags = CFR_OPTFLAG_SUPPRESS; new->sm_enum.default_value = 0; } } -static void update_bad_profile(const struct sm_object *obj, struct sm_object *new) +static void update_bad_profile(struct sm_object *new) { const bool pf_ok = get_emi_eeprom_vpd()->profile != 0; @@ -37,17 +37,17 @@ static void update_bad_profile(const struct sm_object *obj, struct sm_object *ne new->sm_comment.flags |= CFR_OPTFLAG_SUPPRESS; } -static void update_serial(const struct sm_object *obj, struct sm_object *new) +static void update_serial(struct sm_object *new) { new->sm_varchar.default_value = get_emi_eeprom_vpd()->serial_number; } -static void update_part_number(const struct sm_object *obj, struct sm_object *new) +static void update_part_number(struct sm_object *new) { new->sm_varchar.default_value = get_emi_eeprom_vpd()->part_number; } -static void update_profile(const struct sm_object *obj, struct sm_object *new) +static void update_profile(struct sm_object *new) { new->sm_number.default_value = get_emi_eeprom_vpd()->profile; } @@ -180,7 +180,7 @@ static struct sm_enum_value pch_pm_pcie_pll_ssc_values[] = { SM_ENUM_VALUE_END, }; -static void update_pll_ssc_values(const struct sm_object *obj, struct sm_object *new) +static void update_pll_ssc_values(struct sm_object *new) { for (size_t i = 0; i < NUM_PCIE_SSC_SETTINGS; i++) { char buffer[16]; diff --git a/src/mainboard/starlabs/common/cfr/cfr.c b/src/mainboard/starlabs/common/cfr/cfr.c index ebf5ffc7ce..78a41814e5 100644 --- a/src/mainboard/starlabs/common/cfr/cfr.c +++ b/src/mainboard/starlabs/common/cfr/cfr.c @@ -3,9 +3,7 @@ #include #include -void __weak cfr_card_reader_update(const struct sm_object *obj, - struct sm_object *new_obj) +void __weak cfr_card_reader_update(struct sm_object *new_obj) { - (void)obj; (void)new_obj; } diff --git a/src/mainboard/starlabs/common/include/common/cfr.h b/src/mainboard/starlabs/common/include/common/cfr.h index e71f1bafd3..6566ce6e96 100644 --- a/src/mainboard/starlabs/common/include/common/cfr.h +++ b/src/mainboard/starlabs/common/include/common/cfr.h @@ -6,7 +6,7 @@ #include #include -void cfr_card_reader_update(const struct sm_object *obj, struct sm_object *new_obj); +void cfr_card_reader_update(struct sm_object *new_obj); static const struct sm_object accelerometer = SM_DECLARE_BOOL({ .opt_name = "accelerometer", diff --git a/src/mainboard/starlabs/starlite_adl/cfr.c b/src/mainboard/starlabs/starlite_adl/cfr.c index 62dc785b6c..2ed505a17f 100644 --- a/src/mainboard/starlabs/starlite_adl/cfr.c +++ b/src/mainboard/starlabs/starlite_adl/cfr.c @@ -11,7 +11,7 @@ #include #include -void cfr_card_reader_update(const struct sm_object *obj, struct sm_object *new_obj) +void cfr_card_reader_update(struct sm_object *new_obj) { struct device *mxc_accel = DEV_PTR(mxc6655);