[PATCH 4/4] platform/x86: system76_acpi: Use DEV_ATTR macro for kb_led_color

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Update kb_led_color to use the attr macro instead of manually making the
struct. While touching it, also change its show method to use
sysfs_emit() instead of sprintf().

Signed-off-by: Tim Crawford <tcrawford@xxxxxxxxxxxx>
---
 drivers/platform/x86/system76_acpi.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c
index 5c525c242211..dd00eb2663d6 100644
--- a/drivers/platform/x86/system76_acpi.c
+++ b/drivers/platform/x86/system76_acpi.c
@@ -354,7 +354,7 @@ static ssize_t kb_led_color_show(
 
 	led = (struct led_classdev *)dev->driver_data;
 	data = container_of(led, struct system76_data, kb_led);
-	return sprintf(buf, "%06X\n", data->kb_color);
+	return sysfs_emit(buf, "%06X\n", data->kb_color);
 }
 
 // Set the keyboard LED color
@@ -382,14 +382,7 @@ static ssize_t kb_led_color_store(
 	return size;
 }
 
-static const struct device_attribute kb_led_color_dev_attr = {
-	.attr = {
-		.name = "color",
-		.mode = 0644,
-	},
-	.show = kb_led_color_show,
-	.store = kb_led_color_store,
-};
+static DEVICE_ATTR_RW(kb_led_color);
 
 // Notify that the keyboard LED was changed by hardware
 static void kb_led_notify(struct system76_data *data)
@@ -669,10 +662,7 @@ static int system76_add(struct acpi_device *acpi_dev)
 		return err;
 
 	if (data->kb_color >= 0) {
-		err = device_create_file(
-			data->kb_led.dev,
-			&kb_led_color_dev_attr
-		);
+		err = device_create_file(data->kb_led.dev, &dev_attr_kb_led_color);
 		if (err)
 			return err;
 	}
@@ -716,7 +706,7 @@ static int system76_remove(struct acpi_device *acpi_dev)
 	system76_battery_exit();
 
 	if (data->kb_color >= 0)
-		device_remove_file(data->kb_led.dev, &kb_led_color_dev_attr);
+		device_remove_file(data->kb_led.dev, &dev_attr_kb_led_color);
 
 	devm_led_classdev_unregister(&acpi_dev->dev, &data->ap_led);
 	devm_led_classdev_unregister(&acpi_dev->dev, &data->kb_led);
-- 
2.31.1




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux