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.
Unified · Split
| @@ -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. | ||
| @@ -215,7 +215,6 @@ config MFD_CROS_EC · 214 unmodified lines | |||
| 215 | config MFD_CROS_EC_CHARDEV | 215 | config MFD_CROS_EC_CHARDEV |
| 216 | tristate "Chrome OS Embedded Controller userspace device interface" | 216 | tristate "Chrome OS Embedded Controller userspace device interface" |
| 217 | depends on MFD_CROS_EC | 217 | depends on MFD_CROS_EC |
| 218 | select CROS_EC_CTL | ||
| 219 | ---help--- | 218 | ---help--- |
| 220 | This driver adds support to talk with the ChromeOS EC from userspace. | 219 | This driver adds support to talk with the ChromeOS EC from userspace. |
| 221 | 220 | ||
| @@ -34,15 +34,9 @@ · 33 unmodified lines | |||
| 34 | #define CROS_MAX_DEV 128 | 34 | #define CROS_MAX_DEV 128 |
| 35 | static int ec_major; | 35 | static int ec_major; |
| 36 | 36 | ||
| 37 | static const struct attribute_group *cros_ec_groups[] = { | ||
| 38 | &cros_ec_attr_group, | ||
| 39 | NULL, | ||
| 40 | }; | ||
| 41 | |||
| 42 | static struct class cros_class = { | 37 | static struct class cros_class = { |
| 43 | .owner = THIS_MODULE, | 38 | .owner = THIS_MODULE, |
| 44 | .name = "chromeos", | 39 | .name = "chromeos", |
| 45 | .dev_groups = cros_ec_groups, | ||
| 46 | }; | 40 | }; |
| 47 | 41 | ||
| 48 | /* Basic communication */ | 42 | /* Basic communication */ |
| @@ -396,6 +390,7 @@ static const struct mfd_cell cros_usbpd_charger_cells[] = { · 347 unmodified lines | |||
| 396 | static const struct mfd_cell cros_ec_platform_cells[] = { | 390 | static const struct mfd_cell cros_ec_platform_cells[] = { |
| 397 | { .name = "cros-ec-debugfs" }, | 391 | { .name = "cros-ec-debugfs" }, |
| 398 | { .name = "cros-ec-lightbar" }, | 392 | { .name = "cros-ec-lightbar" }, |
| 393 | { .name = "cros-ec-sysfs" }, | ||
| 399 | { .name = "cros-ec-vbc" }, | 394 | { .name = "cros-ec-vbc" }, |
| 400 | }; | 395 | }; |
| 401 | 396 | ||
| @@ -49,9 +49,6 @@ config CHROMEOS_TBMC · 48 unmodified lines | |||
| 49 | To compile this driver as a module, choose M here: the | 49 | To compile this driver as a module, choose M here: the |
| 50 | module will be called chromeos_tbmc. | 50 | module will be called chromeos_tbmc. |
| 51 | 51 | ||
| 52 | config CROS_EC_CTL | ||
| 53 | tristate | ||
| 54 | |||
| 55 | config CROS_EC_I2C | 52 | config CROS_EC_I2C |
| 56 | tristate "ChromeOS Embedded Controller (I2C)" | 53 | tristate "ChromeOS Embedded Controller (I2C)" |
| 57 | depends on MFD_CROS_EC && I2C | 54 | depends on MFD_CROS_EC && I2C |
| @@ -144,4 +141,15 @@ config CROS_EC_DEBUGFS · 86 unmodified lines | |||
| 144 | To compile this driver as a module, choose M here: the | 141 | To compile this driver as a module, choose M here: the |
| 145 | module will be called cros_ec_debugfs. | 142 | module will be called cros_ec_debugfs. |
| 146 | 143 | ||
| 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 | |||
| 147 | endif # CHROMEOS_PLATFORMS | 155 | endif # CHROMEOS_PLATFORMS |
| @@ -3,8 +3,6 @@ · 2 unmodified lines | |||
| 3 | obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o | 3 | obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o |
| 4 | obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o | 4 | obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o |
| 5 | obj-$(CONFIG_CHROMEOS_TBMC) += chromeos_tbmc.o | 5 | 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 | ||
| 8 | obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o | 6 | obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o |
| 9 | obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o | 7 | obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o |
| 10 | cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_reg.o | 8 | 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 | |||
| 15 | obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o | 13 | obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o |
| 16 | obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o | 14 | obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o |
| 17 | obj-$(CONFIG_CROS_EC_DEBUGFS) += cros_ec_debugfs.o | 15 | obj-$(CONFIG_CROS_EC_DEBUGFS) += cros_ec_debugfs.o |
| 16 | obj-$(CONFIG_CROS_EC_SYSFS) += cros_ec_sysfs.o | ||
| @@ -594,7 +594,7 @@ static umode_t cros_ec_lightbar_attrs_are_visible(struct kobject *kobj, · 593 unmodified lines | |||
| 594 | return 0; | 594 | return 0; |
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | struct attribute_group cros_ec_lightbar_attr_group = { | 597 | static struct attribute_group cros_ec_lightbar_attr_group = { |
| 598 | .name = "lightbar", | 598 | .name = "lightbar", |
| 599 | .attrs = __lb_cmds_attrs, | 599 | .attrs = __lb_cmds_attrs, |
| 600 | .is_visible = cros_ec_lightbar_attrs_are_visible, | 600 | .is_visible = cros_ec_lightbar_attrs_are_visible, |
| @@ -34,6 +34,8 @@ · 33 unmodified lines | |||
| 34 | #include <linux/types.h> | 34 | #include <linux/types.h> |
| 35 | #include <linux/uaccess.h> | 35 | #include <linux/uaccess.h> |
| 36 | 36 | ||
| 37 | #define DRV_NAME "cros-ec-sysfs" | ||
| 38 | |||
| 37 | /* Accessor functions */ | 39 | /* Accessor functions */ |
| 38 | 40 | ||
| 39 | static ssize_t reboot_show(struct device *dev, | 41 | static ssize_t reboot_show(struct device *dev, |
| @@ -353,7 +355,39 @@ struct attribute_group cros_ec_attr_group = { · 313 unmodified lines | |||
| 353 | .attrs = __ec_attrs, | 355 | .attrs = __ec_attrs, |
| 354 | .is_visible = cros_ec_ctrl_visible, | 356 | .is_visible = cros_ec_ctrl_visible, |
| 355 | }; | 357 | }; |
| 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); | ||
| 357 | 390 | ||
| 358 | MODULE_LICENSE("GPL"); | 391 | MODULE_LICENSE("GPL"); |
| 359 | MODULE_DESCRIPTION("ChromeOS EC control driver"); | 392 | MODULE_DESCRIPTION("ChromeOS EC control driver"); |
| 393 | MODULE_ALIAS("platform:" DRV_NAME); | ||
| @@ -325,7 +325,4 @@ int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event); · 324 unmodified lines | |||
| 325 | */ | 325 | */ |
| 326 | u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev); | 326 | u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev); |
| 327 | 327 | ||
| 328 | /* sysfs stuff */ | ||
| 329 | extern struct attribute_group cros_ec_attr_group; | ||
| 330 | |||
| 331 | #endif /* __LINUX_MFD_CROS_EC_H */ | 328 | #endif /* __LINUX_MFD_CROS_EC_H */ |