History

mfd / platform: cros_ec: Move device sysfs attributes to its own driver

The entire way how cros debugfs attibutes are created is broken. cros_ec_sysfs should be its own driver and its attributes should be associated with the sysfs driver not the mfd driver. The patch also adds the sysfs documentation.

Enric Balletbo i Serra committed 7 years ago

Commit 6fd7f2b1 parent 6fce0a28 files · +81 −17Browse files

Unified · Split

8 files
  1. Documentation/ABI/testing/sysfs-class-chromeos +32 −0
  2. drivers/mfd/Kconfig +0 −1
  3. drivers/mfd/cros_ec_dev.c +1 −6
  4. drivers/platform/chrome/Kconfig +11 −3
  5. drivers/platform/chrome/Makefile +1 −2
  6. drivers/platform/chrome/cros_ec_lightbar.c +1 −1
  7. drivers/platform/chrome/cros_ec_sysfs.c +35 −1
  8. include/linux/mfd/cros_ec.h +0 −3
Documentation/ABI/testing/sysfs-class-chromeos+32−0
@@ -0,0 +1,32 @@
1+What: /sys/class/chromeos/<ec-device-name>/flashinfo
2+Date: August 2015
3+KernelVersion: 4.2
4+Description:
5+ Show the EC flash information.
6+
7+What: /sys/class/chromeos/<ec-device-name>/kb_wake_angle
8+Date: March 2018
9+KernelVersion: 4.17
10+Description:
11+ Control the keyboard wake lid angle. Values are between
12+ 0 and 360. This file will also show the keyboard wake lid
13+ angle by querying the hardware.
14+
15+What: /sys/class/chromeos/<ec-device-name>/reboot
16+Date: August 2015
17+KernelVersion: 4.2
18+Description:
19+ Tell the EC to reboot in various ways. Options are:
20+ "cancel": Cancel a pending reboot.
21+ "ro": Jump to RO without rebooting.
22+ "rw": Jump to RW without rebooting.
23+ "cold": Cold reboot.
24+ "disable-jump": Disable jump until next reboot.
25+ "hibernate": Hibernate the EC.
26+ "at-shutdown": Reboot after an AP shutdown.
27+
28+What: /sys/class/chromeos/<ec-device-name>/version
29+Date: August 2015
30+KernelVersion: 4.2
31+Description:
32+ Show the information about the EC software and hardware.
drivers/mfd/Kconfig+0−1
@@ -215,7 +215,6 @@ config MFD_CROS_EC · 214 unmodified lines
215215 config MFD_CROS_EC_CHARDEV
216216 tristate "Chrome OS Embedded Controller userspace device interface"
217217 depends on MFD_CROS_EC
218− select CROS_EC_CTL
219218 ---help---
220219 This driver adds support to talk with the ChromeOS EC from userspace.
221220
drivers/mfd/cros_ec_dev.c+1−6
@@ -34,15 +34,9 @@ · 33 unmodified lines
3434 #define CROS_MAX_DEV 128
3535 static int ec_major;
3636
37−static const struct attribute_group *cros_ec_groups[] = {
38− &cros_ec_attr_group,
39− NULL,
40−};
41−
4237 static struct class cros_class = {
4338 .owner = THIS_MODULE,
4439 .name = "chromeos",
45− .dev_groups = cros_ec_groups,
4640 };
4741
4842 /* Basic communication */
@@ -396,6 +390,7 @@ static const struct mfd_cell cros_usbpd_charger_cells[] = { · 347 unmodified lines
396390 static const struct mfd_cell cros_ec_platform_cells[] = {
397391 { .name = "cros-ec-debugfs" },
398392 { .name = "cros-ec-lightbar" },
393+ { .name = "cros-ec-sysfs" },
399394 { .name = "cros-ec-vbc" },
400395 };
401396
drivers/platform/chrome/Kconfig+11−3
@@ -49,9 +49,6 @@ config CHROMEOS_TBMC · 48 unmodified lines
4949 To compile this driver as a module, choose M here: the
5050 module will be called chromeos_tbmc.
5151
52−config CROS_EC_CTL
53− tristate
54−
5552 config CROS_EC_I2C
5653 tristate "ChromeOS Embedded Controller (I2C)"
5754 depends on MFD_CROS_EC && I2C
@@ -144,4 +141,15 @@ config CROS_EC_DEBUGFS · 86 unmodified lines
144141 To compile this driver as a module, choose M here: the
145142 module will be called cros_ec_debugfs.
146143
144+config CROS_EC_SYSFS
145+ tristate "ChromeOS EC control and information through sysfs"
146+ depends on MFD_CROS_EC_CHARDEV && SYSFS
147+ default MFD_CROS_EC_CHARDEV
148+ help
149+ This option exposes some sysfs attributes to control and get
150+ information from ChromeOS EC.
151+
152+ To compile this driver as a module, choose M here: the
153+ module will be called cros_ec_sysfs.
154+
147155 endif # CHROMEOS_PLATFORMS
drivers/platform/chrome/Makefile+1−2
@@ -3,8 +3,6 @@ · 2 unmodified lines
33 obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o
44 obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o
55 obj-$(CONFIG_CHROMEOS_TBMC) += chromeos_tbmc.o
6−cros_ec_ctl-objs := cros_ec_sysfs.o
7−obj-$(CONFIG_CROS_EC_CTL) += cros_ec_ctl.o
86 obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o
97 obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
108 cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_reg.o
@@ -15,3 +13,4 @@ obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o · 4 unmodified lines
1513 obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o
1614 obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o
1715 obj-$(CONFIG_CROS_EC_DEBUGFS) += cros_ec_debugfs.o
16+obj-$(CONFIG_CROS_EC_SYSFS) += cros_ec_sysfs.o
drivers/platform/chrome/cros_ec_lightbar.c+1−1
@@ -594,7 +594,7 @@ static umode_t cros_ec_lightbar_attrs_are_visible(struct kobject *kobj, · 593 unmodified lines
594594 return 0;
595595 }
596596
597−struct attribute_group cros_ec_lightbar_attr_group = {
597+static struct attribute_group cros_ec_lightbar_attr_group = {
598598 .name = "lightbar",
599599 .attrs = __lb_cmds_attrs,
600600 .is_visible = cros_ec_lightbar_attrs_are_visible,
drivers/platform/chrome/cros_ec_sysfs.c+35−1
@@ -34,6 +34,8 @@ · 33 unmodified lines
3434 #include <linux/types.h>
3535 #include <linux/uaccess.h>
3636
37+#define DRV_NAME "cros-ec-sysfs"
38+
3739 /* Accessor functions */
3840
3941 static ssize_t reboot_show(struct device *dev,
@@ -353,7 +355,39 @@ struct attribute_group cros_ec_attr_group = { · 313 unmodified lines
353355 .attrs = __ec_attrs,
354356 .is_visible = cros_ec_ctrl_visible,
355357 };
356−EXPORT_SYMBOL(cros_ec_attr_group);
358+
359+static int cros_ec_sysfs_probe(struct platform_device *pd)
360+{
361+ struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);
362+ struct device *dev = &pd->dev;
363+ int ret;
364+
365+ ret = sysfs_create_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group);
366+ if (ret < 0)
367+ dev_err(dev, "failed to create attributes. err=%d\n", ret);
368+
369+ return ret;
370+}
371+
372+static int cros_ec_sysfs_remove(struct platform_device *pd)
373+{
374+ struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);
375+
376+ sysfs_remove_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group);
377+
378+ return 0;
379+}
380+
381+static struct platform_driver cros_ec_sysfs_driver = {
382+ .driver = {
383+ .name = DRV_NAME,
384+ },
385+ .probe = cros_ec_sysfs_probe,
386+ .remove = cros_ec_sysfs_remove,
387+};
388+
389+module_platform_driver(cros_ec_sysfs_driver);
357390
358391 MODULE_LICENSE("GPL");
359392 MODULE_DESCRIPTION("ChromeOS EC control driver");
393+MODULE_ALIAS("platform:" DRV_NAME);
include/linux/mfd/cros_ec.h+0−3
@@ -325,7 +325,4 @@ int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event); · 324 unmodified lines
325325 */
326326 u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev);
327327
328−/* sysfs stuff */
329−extern struct attribute_group cros_ec_attr_group;
330−
331328 #endif /* __LINUX_MFD_CROS_EC_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t