From: Guenter Roeck <linux@roeck-us.net>
To: linux-hwmon@vger.kernel.org
Cc: Tomasz Bojanowski <tomasz@bojanowski.me>,
Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 1/4] hwmon: (msi_mystic_light) Rearrange code to simplify adding per-board read functions
Date: Sat, 7 Nov 2026 16:01:28 -0800 [thread overview]
Message-ID: <20261108000131.1249664-2-linux@roeck-us.net> (raw)
In-Reply-To: <20261108000131.1249664-1-linux@roeck-us.net>
Currently, struct msi_ml_board, the per-board channel definitions, and
msi_ml_dmi_table[] are placed at the top of the file ahead of struct
msi_ml_data and the driver's operational functions.
Upcoming support for MSI 500- and 600-series motherboards requires a
board-specific sensor read callback in struct msi_ml_board that takes a
pointer to struct msi_ml_data, as well as referencing board-specific
read functions from the per-board struct msi_ml_board initializers.
Move struct msi_ml_board below struct msi_ml_data, move the static
msi_ml_board pointer above msi_ml_probe(), and relocate the per-board
configuration data and DMI match table to the bottom of the file next
to msi_ml_table[]. This avoids forward declarations of struct
msi_ml_data and the per-board read callbacks in subsequent changes.
No functional change.
Cc: Tomasz Bojanowski <tomasz@bojanowski.me>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/msi_mystic_light.c | 80 ++++++++++++++++----------------
1 file changed, 41 insertions(+), 39 deletions(-)
diff --git a/drivers/hwmon/msi_mystic_light.c b/drivers/hwmon/msi_mystic_light.c
index a27bb9916588..a008999e7c06 100644
--- a/drivers/hwmon/msi_mystic_light.c
+++ b/drivers/hwmon/msi_mystic_light.c
@@ -44,45 +44,6 @@
#define MSI_ML_MAX_IN 3
#define MSI_ML_CACHE_TIME HZ
-struct msi_ml_board {
- int num_in;
- const char *const *in_label;
- /* little endian u16 in mV, offset at most MSI_ML_SENSOR_REPORT_SIZE - 2 */
- const u8 *in_offset;
-};
-
-/* MAG B850M MORTAR WIFI (MS-7E61) */
-static const char *const msi_ml_7e61_in_label[] = {
- "CPU 1P8", "CHIP Core", "VDD MISC",
-};
-
-static const u8 msi_ml_7e61_in_offset[] = { 23, 17, 25 };
-
-static_assert(ARRAY_SIZE(msi_ml_7e61_in_label) ==
- ARRAY_SIZE(msi_ml_7e61_in_offset));
-static_assert(ARRAY_SIZE(msi_ml_7e61_in_label) <= MSI_ML_MAX_IN);
-
-static const struct msi_ml_board msi_ml_7e61 = {
- .num_in = ARRAY_SIZE(msi_ml_7e61_in_label),
- .in_label = msi_ml_7e61_in_label,
- .in_offset = msi_ml_7e61_in_offset,
-};
-
-static const struct dmi_system_id msi_ml_dmi_table[] __initconst = {
- {
- .matches = {
- DMI_MATCH(DMI_BOARD_VENDOR, "Micro-Star International"),
- DMI_MATCH(DMI_BOARD_NAME, "MS-7E61"),
- },
- .driver_data = (void *)&msi_ml_7e61,
- },
- { }
-};
-MODULE_DEVICE_TABLE(dmi, msi_ml_dmi_table);
-
-/* Board matched by DMI, set once before the HID driver is registered */
-static const struct msi_ml_board *msi_ml_board;
-
struct msi_ml_data {
struct hid_device *hdev;
struct device *hwmon_dev;
@@ -93,6 +54,13 @@ struct msi_ml_data {
u64 updated; /* jiffies of the last successful read */
};
+struct msi_ml_board {
+ int num_in;
+ const char *const *in_label;
+ /* little endian u16 in mV, offset at most MSI_ML_SENSOR_REPORT_SIZE - 2 */
+ const u8 *in_offset;
+};
+
/*
* Read the sensor report. Called from probe before the hwmon device is
* registered, and afterwards only from the hwmon read callback, which the
@@ -199,6 +167,9 @@ static const struct hwmon_chip_info msi_ml_chip_info = {
.info = msi_ml_info,
};
+/* Board matched by DMI, set once before the HID driver is registered */
+static const struct msi_ml_board *msi_ml_board;
+
static int msi_ml_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
struct msi_ml_data *priv;
@@ -285,6 +256,37 @@ static void msi_ml_remove(struct hid_device *hdev)
hid_hw_stop(hdev);
}
+/* Per-board data */
+
+/* MAG B850M MORTAR WIFI (MS-7E61) */
+static const char *const msi_ml_7e61_in_label[] = {
+ "CPU 1P8", "CHIP Core", "VDD MISC",
+};
+
+static const u8 msi_ml_7e61_in_offset[] = { 23, 17, 25 };
+
+static_assert(ARRAY_SIZE(msi_ml_7e61_in_label) ==
+ ARRAY_SIZE(msi_ml_7e61_in_offset));
+static_assert(ARRAY_SIZE(msi_ml_7e61_in_label) <= MSI_ML_MAX_IN);
+
+static const struct msi_ml_board msi_ml_7e61 = {
+ .num_in = ARRAY_SIZE(msi_ml_7e61_in_label),
+ .in_label = msi_ml_7e61_in_label,
+ .in_offset = msi_ml_7e61_in_offset,
+};
+
+static const struct dmi_system_id msi_ml_dmi_table[] __initconst = {
+ {
+ .matches = {
+ DMI_MATCH(DMI_BOARD_VENDOR, "Micro-Star International"),
+ DMI_MATCH(DMI_BOARD_NAME, "MS-7E61"),
+ },
+ .driver_data = (void *)&msi_ml_7e61,
+ },
+ { }
+};
+MODULE_DEVICE_TABLE(dmi, msi_ml_dmi_table);
+
static const struct hid_device_id msi_ml_table[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_MSI_MB, USB_PRODUCT_ID_MYSTIC_LIGHT) },
{ }
--
2.45.2
next prev parent reply other threads:[~2026-11-08 0:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 0:01 [PATCH 0/4] hwmon: (msi_mystic_light) Add support for additional MSI motherboards Guenter Roeck
2026-11-08 0:01 ` Guenter Roeck [this message]
2026-11-08 0:01 ` [PATCH 2/4] hwmon: (msi_mystic_light) Stop calling hid_hw_power() Guenter Roeck
2026-11-08 0:01 ` [PATCH 3/4] hwmon: (msi_mystic_light) Make sensor read function board specific Guenter Roeck
2026-11-08 0:01 ` [PATCH 4/4] hwmon: (msi_mystic_light) Add support for additional boards Guenter Roeck
2026-11-08 8:14 ` [PATCH 0/4] hwmon: (msi_mystic_light) Add support for additional MSI motherboards Tomasz Bojanowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261108000131.1249664-2-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-hwmon@vger.kernel.org \
--cc=tomasz@bojanowski.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox