]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
platform/x86: alienware-wmi: Move Lighting Control State
authorKurt Borja <kuurtb@gmail.com>
Sun, 5 Jan 2025 15:30:02 +0000 (10:30 -0500)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 9 Jan 2025 11:40:32 +0000 (13:40 +0200)
Place Lighting Control State logic next to other attributes of the same
sysfs group.

While at it, rename:

store_control_state() -> lighting_control_state_store()
show_control_state() -> lighting_control_state_show()

Replace DEVICE_ATTR() with DEVICE_ATTR_RW() and do a general style
cleanup.

Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20250105153019.19206-4-kuurtb@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/dell/alienware-wmi.c

index 7212d75396b9b8361e39cd81a09e88aed11d7cdc..ec64a8f22301c42f4190432b745b96f276f497d9 100644 (file)
@@ -545,6 +545,45 @@ static ssize_t zone_set(struct device *dev, struct device_attribute *attr,
        return ret ? ret : count;
 }
 
+/*
+ * Lighting control state device attribute (Global)
+ */
+static ssize_t lighting_control_state_show(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       if (lighting_control_state == LEGACY_BOOTING)
+               return sysfs_emit(buf, "[booting] running suspend\n");
+       else if (lighting_control_state == LEGACY_SUSPEND)
+               return sysfs_emit(buf, "booting running [suspend]\n");
+
+       return sysfs_emit(buf, "booting [running] suspend\n");
+}
+
+static ssize_t lighting_control_state_store(struct device *dev,
+                                           struct device_attribute *attr,
+                                           const char *buf, size_t count)
+{
+       u8 val;
+
+       if (strcmp(buf, "booting\n") == 0)
+               val = LEGACY_BOOTING;
+       else if (strcmp(buf, "suspend\n") == 0)
+               val = LEGACY_SUSPEND;
+       else if (interface == LEGACY)
+               val = LEGACY_RUNNING;
+       else
+               val = WMAX_RUNNING;
+
+       lighting_control_state = val;
+       pr_debug("alienware-wmi: updated control state to %d\n",
+                lighting_control_state);
+
+       return count;
+}
+
+static DEVICE_ATTR_RW(lighting_control_state);
+
 /*
  * LED Brightness (Global)
  */
@@ -589,41 +628,6 @@ static struct led_classdev global_led = {
        .name = "alienware::global_brightness",
 };
 
-/*
- * Lighting control state device attribute (Global)
- */
-static ssize_t show_control_state(struct device *dev,
-                                 struct device_attribute *attr, char *buf)
-{
-       if (lighting_control_state == LEGACY_BOOTING)
-               return sysfs_emit(buf, "[booting] running suspend\n");
-       else if (lighting_control_state == LEGACY_SUSPEND)
-               return sysfs_emit(buf, "booting running [suspend]\n");
-       return sysfs_emit(buf, "booting [running] suspend\n");
-}
-
-static ssize_t store_control_state(struct device *dev,
-                                  struct device_attribute *attr,
-                                  const char *buf, size_t count)
-{
-       long unsigned int val;
-       if (strcmp(buf, "booting\n") == 0)
-               val = LEGACY_BOOTING;
-       else if (strcmp(buf, "suspend\n") == 0)
-               val = LEGACY_SUSPEND;
-       else if (interface == LEGACY)
-               val = LEGACY_RUNNING;
-       else
-               val = WMAX_RUNNING;
-       lighting_control_state = val;
-       pr_debug("alienware-wmi: updated control state to %d\n",
-                lighting_control_state);
-       return count;
-}
-
-static DEVICE_ATTR(lighting_control_state, 0644, show_control_state,
-                  store_control_state);
-
 static int alienware_zone_init(struct platform_device *dev)
 {
        u8 zone;