Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Enric Balletbo i Serra and committed by
Lee Jones
acb9900f ecf8a6cd

+62 -4
+6
Documentation/ABI/testing/sysfs-class-chromeos-driver-cros-ec-vbc
··· 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.
+1 -1
drivers/mfd/cros_ec_dev.c
··· 36 36 37 37 static const struct attribute_group *cros_ec_groups[] = { 38 38 &cros_ec_attr_group, 39 - &cros_ec_vbc_attr_group, 40 39 NULL, 41 40 }; 42 41 ··· 395 396 396 397 static const struct mfd_cell cros_ec_platform_cells[] = { 397 398 { .name = "cros-ec-lightbar" }, 399 + { .name = "cros-ec-vbc" }, 398 400 }; 399 401 400 402 static int ec_device_probe(struct platform_device *pdev)
+11
drivers/platform/chrome/Kconfig
··· 122 122 To compile this driver as a module, choose M here: the 123 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 136 endif # CHROMEOS_PLATFORMS
+2 -1
drivers/platform/chrome/Makefile
··· 4 4 obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o 5 5 obj-$(CONFIG_CHROMEOS_TBMC) += chromeos_tbmc.o 6 6 cros_ec_ctl-objs := cros_ec_sysfs.o \ 7 - cros_ec_vbc.o cros_ec_debugfs.o 7 + cros_ec_debugfs.o 8 8 obj-$(CONFIG_CROS_EC_CTL) += cros_ec_ctl.o 9 9 obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o 10 10 obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o ··· 14 14 obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o 15 15 obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o 16 16 obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o 17 + obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o
+42 -1
drivers/platform/chrome/cros_ec_vbc.c
··· 22 22 #include <linux/platform_device.h> 23 23 #include <linux/mfd/cros_ec.h> 24 24 #include <linux/mfd/cros_ec_commands.h> 25 + #include <linux/module.h> 25 26 #include <linux/slab.h> 27 + 28 + #define DRV_NAME "cros-ec-vbc" 26 29 27 30 static ssize_t vboot_context_read(struct file *filp, struct kobject *kobj, 28 31 struct bin_attribute *att, char *buf, ··· 135 132 .bin_attrs = cros_ec_vbc_bin_attrs, 136 133 .is_bin_visible = cros_ec_vbc_is_visible, 137 134 }; 138 - EXPORT_SYMBOL(cros_ec_vbc_attr_group); 135 + 136 + static int cros_ec_vbc_probe(struct platform_device *pd) 137 + { 138 + struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent); 139 + struct device *dev = &pd->dev; 140 + int ret; 141 + 142 + ret = sysfs_create_group(&ec_dev->class_dev.kobj, 143 + &cros_ec_vbc_attr_group); 144 + if (ret < 0) 145 + dev_err(dev, "failed to create %s attributes. err=%d\n", 146 + cros_ec_vbc_attr_group.name, ret); 147 + 148 + return ret; 149 + } 150 + 151 + static int cros_ec_vbc_remove(struct platform_device *pd) 152 + { 153 + struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent); 154 + 155 + sysfs_remove_group(&ec_dev->class_dev.kobj, 156 + &cros_ec_vbc_attr_group); 157 + 158 + return 0; 159 + } 160 + 161 + static struct platform_driver cros_ec_vbc_driver = { 162 + .driver = { 163 + .name = DRV_NAME, 164 + }, 165 + .probe = cros_ec_vbc_probe, 166 + .remove = cros_ec_vbc_remove, 167 + }; 168 + 169 + module_platform_driver(cros_ec_vbc_driver); 170 + 171 + MODULE_LICENSE("GPL"); 172 + MODULE_DESCRIPTION("Expose the vboot context nvram to userspace"); 173 + MODULE_ALIAS("platform:" DRV_NAME);
-1
include/linux/mfd/cros_ec.h
··· 327 327 328 328 /* sysfs stuff */ 329 329 extern struct attribute_group cros_ec_attr_group; 330 - extern struct attribute_group cros_ec_vbc_attr_group; 331 330 332 331 /* debugfs stuff */ 333 332 int cros_ec_debugfs_init(struct cros_ec_dev *ec);