diff options
author | Enric Balletbo i Serra <enric.balletbo@collabora.com> | 2018-12-12 12:33:58 -0500 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2019-02-01 03:09:27 -0500 |
commit | acb9900f9e8074858738f48bee9a705138961258 (patch) | |
tree | 981adb8f152f17e5bbbc2d89876ef4188418e03d | |
parent | ecf8a6cd949ef236ce435ae488ceb6b3354e677e (diff) |
mfd / platform: cros_ec: Move vbc attributes to its own driver
The entire way how cros sysfs attibutes are created is broken.
cros_ec_vbc should be its own driver and its attributes should be
associated with a vbc driver not the mfd driver. In order to retain
the path, the vbc attributes are attached to the cros_class.
The patch also adds the sysfs documentation.
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r-- | Documentation/ABI/testing/sysfs-class-chromeos-driver-cros-ec-vbc | 6 | ||||
-rw-r--r-- | drivers/mfd/cros_ec_dev.c | 2 | ||||
-rw-r--r-- | drivers/platform/chrome/Kconfig | 11 | ||||
-rw-r--r-- | drivers/platform/chrome/Makefile | 3 | ||||
-rw-r--r-- | drivers/platform/chrome/cros_ec_vbc.c | 43 | ||||
-rw-r--r-- | include/linux/mfd/cros_ec.h | 1 |
6 files changed, 62 insertions, 4 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-chromeos-driver-cros-ec-vbc b/Documentation/ABI/testing/sysfs-class-chromeos-driver-cros-ec-vbc new file mode 100644 index 000000000000..38c5aaaaa89a --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-chromeos-driver-cros-ec-vbc | |||
@@ -0,0 +1,6 @@ | |||
1 | What: /sys/class/chromeos/<ec-device-name>/vbc/vboot_context | ||
2 | Date: October 2015 | ||
3 | KernelVersion: 4.4 | ||
4 | Description: | ||
5 | Read/write the verified boot context data included on a | ||
6 | small nvram space on some EC implementations. | ||
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index b227718e0ec2..40c98808fa1c 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c | |||
@@ -36,7 +36,6 @@ static int ec_major; | |||
36 | 36 | ||
37 | static const struct attribute_group *cros_ec_groups[] = { | 37 | static const struct attribute_group *cros_ec_groups[] = { |
38 | &cros_ec_attr_group, | 38 | &cros_ec_attr_group, |
39 | &cros_ec_vbc_attr_group, | ||
40 | NULL, | 39 | NULL, |
41 | }; | 40 | }; |
42 | 41 | ||
@@ -396,6 +395,7 @@ static const struct mfd_cell cros_usbpd_charger_cells[] = { | |||
396 | 395 | ||
397 | static const struct mfd_cell cros_ec_platform_cells[] = { | 396 | static const struct mfd_cell cros_ec_platform_cells[] = { |
398 | { .name = "cros-ec-lightbar" }, | 397 | { .name = "cros-ec-lightbar" }, |
398 | { .name = "cros-ec-vbc" }, | ||
399 | }; | 399 | }; |
400 | 400 | ||
401 | static int ec_device_probe(struct platform_device *pdev) | 401 | static int ec_device_probe(struct platform_device *pdev) |
diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig index 6c05752a3334..1e9dc9626e84 100644 --- a/drivers/platform/chrome/Kconfig +++ b/drivers/platform/chrome/Kconfig | |||
@@ -122,4 +122,15 @@ config CROS_EC_LIGHTBAR | |||
122 | To compile this driver as a module, choose M here: the | 122 | To compile this driver as a module, choose M here: the |
123 | module will be called cros_ec_lightbar. | 123 | module will be called cros_ec_lightbar. |
124 | 124 | ||
125 | config CROS_EC_VBC | ||
126 | tristate "ChromeOS EC vboot context support" | ||
127 | depends on MFD_CROS_EC_CHARDEV && OF | ||
128 | default MFD_CROS_EC_CHARDEV | ||
129 | help | ||
130 | This option exposes the ChromeOS EC vboot context nvram to | ||
131 | userspace. | ||
132 | |||
133 | To compile this driver as a module, choose M here: the | ||
134 | module will be called cros_ec_vbc. | ||
135 | |||
125 | endif # CHROMEOS_PLATFORMS | 136 | endif # CHROMEOS_PLATFORMS |
diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile index 3c29a4b405d5..4081b7179df7 100644 --- a/drivers/platform/chrome/Makefile +++ b/drivers/platform/chrome/Makefile | |||
@@ -4,7 +4,7 @@ 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 \ | 6 | cros_ec_ctl-objs := cros_ec_sysfs.o \ |
7 | cros_ec_vbc.o cros_ec_debugfs.o | 7 | cros_ec_debugfs.o |
8 | obj-$(CONFIG_CROS_EC_CTL) += cros_ec_ctl.o | 8 | obj-$(CONFIG_CROS_EC_CTL) += cros_ec_ctl.o |
9 | obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o | 9 | obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o |
10 | obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o | 10 | obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o |
@@ -14,3 +14,4 @@ obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o | |||
14 | obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o | 14 | obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o |
15 | obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o | 15 | obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o |
16 | obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o | 16 | obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o |
17 | obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o | ||
diff --git a/drivers/platform/chrome/cros_ec_vbc.c b/drivers/platform/chrome/cros_ec_vbc.c index 5356f26bc022..da3bbf05e86f 100644 --- a/drivers/platform/chrome/cros_ec_vbc.c +++ b/drivers/platform/chrome/cros_ec_vbc.c | |||
@@ -22,8 +22,11 @@ | |||
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/mfd/cros_ec.h> | 23 | #include <linux/mfd/cros_ec.h> |
24 | #include <linux/mfd/cros_ec_commands.h> | 24 | #include <linux/mfd/cros_ec_commands.h> |
25 | #include <linux/module.h> | ||
25 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
26 | 27 | ||
28 | #define DRV_NAME "cros-ec-vbc" | ||
29 | |||
27 | static ssize_t vboot_context_read(struct file *filp, struct kobject *kobj, | 30 | static ssize_t vboot_context_read(struct file *filp, struct kobject *kobj, |
28 | struct bin_attribute *att, char *buf, | 31 | struct bin_attribute *att, char *buf, |
29 | loff_t pos, size_t count) | 32 | loff_t pos, size_t count) |
@@ -132,4 +135,42 @@ struct attribute_group cros_ec_vbc_attr_group = { | |||
132 | .bin_attrs = cros_ec_vbc_bin_attrs, | 135 | .bin_attrs = cros_ec_vbc_bin_attrs, |
133 | .is_bin_visible = cros_ec_vbc_is_visible, | 136 | .is_bin_visible = cros_ec_vbc_is_visible, |
134 | }; | 137 | }; |
135 | EXPORT_SYMBOL(cros_ec_vbc_attr_group); | 138 | |
139 | static int cros_ec_vbc_probe(struct platform_device *pd) | ||
140 | { | ||
141 | struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent); | ||
142 | struct device *dev = &pd->dev; | ||
143 | int ret; | ||
144 | |||
145 | ret = sysfs_create_group(&ec_dev->class_dev.kobj, | ||
146 | &cros_ec_vbc_attr_group); | ||
147 | if (ret < 0) | ||
148 | dev_err(dev, "failed to create %s attributes. err=%d\n", | ||
149 | cros_ec_vbc_attr_group.name, ret); | ||
150 | |||
151 | return ret; | ||
152 | } | ||
153 | |||
154 | static int cros_ec_vbc_remove(struct platform_device *pd) | ||
155 | { | ||
156 | struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent); | ||
157 | |||
158 | sysfs_remove_group(&ec_dev->class_dev.kobj, | ||
159 | &cros_ec_vbc_attr_group); | ||
160 | |||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static struct platform_driver cros_ec_vbc_driver = { | ||
165 | .driver = { | ||
166 | .name = DRV_NAME, | ||
167 | }, | ||
168 | .probe = cros_ec_vbc_probe, | ||
169 | .remove = cros_ec_vbc_remove, | ||
170 | }; | ||
171 | |||
172 | module_platform_driver(cros_ec_vbc_driver); | ||
173 | |||
174 | MODULE_LICENSE("GPL"); | ||
175 | MODULE_DESCRIPTION("Expose the vboot context nvram to userspace"); | ||
176 | MODULE_ALIAS("platform:" DRV_NAME); | ||
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h index 1e9b569564ea..fdc3152cca1d 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h | |||
@@ -327,7 +327,6 @@ u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev); | |||
327 | 327 | ||
328 | /* sysfs stuff */ | 328 | /* sysfs stuff */ |
329 | extern struct attribute_group cros_ec_attr_group; | 329 | extern struct attribute_group cros_ec_attr_group; |
330 | extern struct attribute_group cros_ec_vbc_attr_group; | ||
331 | 330 | ||
332 | /* debugfs stuff */ | 331 | /* debugfs stuff */ |
333 | int cros_ec_debugfs_init(struct cros_ec_dev *ec); | 332 | int cros_ec_debugfs_init(struct cros_ec_dev *ec); |