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 @@
1What: /sys/class/chromeos/<ec-device-name>/flashinfo
2Date: August 2015
3KernelVersion: 4.2
4Description:
5 Show the EC flash information.
6
7What: /sys/class/chromeos/<ec-device-name>/kb_wake_angle
8Date: March 2018
9KernelVersion: 4.17
10Description:
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
15What: /sys/class/chromeos/<ec-device-name>/reboot
16Date: August 2015
17KernelVersion: 4.2
18Description:
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
28What: /sys/class/chromeos/<ec-device-name>/version
29Date: August 2015
30KernelVersion: 4.2
31Description:
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
215config MFD_CROS_EC_CHARDEV215config 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_EC217 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
drivers/mfd/cros_ec_dev.c+1−6
@@ -34,15 +34,9 @@ · 33 unmodified lines
34#define CROS_MAX_DEV 12834#define CROS_MAX_DEV 128
35static int ec_major;35static int ec_major;
36 36
37static const struct attribute_group *cros_ec_groups[] = {
38 &cros_ec_attr_group,
39 NULL,
40};
41
42static struct class cros_class = {37static 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
396static const struct mfd_cell cros_ec_platform_cells[] = {390static 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
drivers/platform/chrome/Kconfig+11−3
@@ -49,9 +49,6 @@ config CHROMEOS_TBMC · 48 unmodified lines
49 To compile this driver as a module, choose M here: the49 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
52config CROS_EC_CTL
53 tristate
54
55config CROS_EC_I2C52config CROS_EC_I2C
56 tristate "ChromeOS Embedded Controller (I2C)"53 tristate "ChromeOS Embedded Controller (I2C)"
57 depends on MFD_CROS_EC && I2C54 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: the141 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
144config 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
147endif # CHROMEOS_PLATFORMS155endif # CHROMEOS_PLATFORMS
drivers/platform/chrome/Makefile+1−2
@@ -3,8 +3,6 @@ · 2 unmodified lines
3obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o3obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o
4obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o4obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o
5obj-$(CONFIG_CHROMEOS_TBMC) += chromeos_tbmc.o5obj-$(CONFIG_CHROMEOS_TBMC) += chromeos_tbmc.o
6cros_ec_ctl-objs := cros_ec_sysfs.o
7obj-$(CONFIG_CROS_EC_CTL) += cros_ec_ctl.o
8obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o6obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o
9obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o7obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
10cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_reg.o8cros_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
15obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o13obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o
16obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o14obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o
17obj-$(CONFIG_CROS_EC_DEBUGFS) += cros_ec_debugfs.o15obj-$(CONFIG_CROS_EC_DEBUGFS) += cros_ec_debugfs.o
16obj-$(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
594 return 0;594 return 0;
595}595}
596 596
597struct attribute_group cros_ec_lightbar_attr_group = {597static 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,
drivers/platform/chrome/cros_ec_sysfs.c+35−1
@@ -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
39static ssize_t reboot_show(struct device *dev,41static 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};
356EXPORT_SYMBOL(cros_ec_attr_group);358
359static 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
372static 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
381static 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
389module_platform_driver(cros_ec_sysfs_driver);
357 390
358MODULE_LICENSE("GPL");391MODULE_LICENSE("GPL");
359MODULE_DESCRIPTION("ChromeOS EC control driver");392MODULE_DESCRIPTION("ChromeOS EC control driver");
393MODULE_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
325 */325 */
326u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev);326u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev);
327 327
328/* sysfs stuff */
329extern struct attribute_group cros_ec_attr_group;
330
331#endif /* __LINUX_MFD_CROS_EC_H */328#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