Commit acb9900f authored by Enric Balletbo i Serra's avatar Enric Balletbo i Serra Committed by Lee Jones
Browse files

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: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: default avatarGuenter Roeck <groeck@chromium.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent ecf8a6cd
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
What:		/sys/class/chromeos/<ec-device-name>/vbc/vboot_context
Date:		October 2015
KernelVersion:	4.4
Description:
		Read/write the verified boot context data included on a
		small nvram space on some EC implementations.
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ static int ec_major;

static const struct attribute_group *cros_ec_groups[] = {
	&cros_ec_attr_group,
	&cros_ec_vbc_attr_group,
	NULL,
};

@@ -396,6 +395,7 @@ static const struct mfd_cell cros_usbpd_charger_cells[] = {

static const struct mfd_cell cros_ec_platform_cells[] = {
	{ .name = "cros-ec-lightbar" },
	{ .name = "cros-ec-vbc" },
};

static int ec_device_probe(struct platform_device *pdev)
+11 −0
Original line number Diff line number Diff line
@@ -122,4 +122,15 @@ config CROS_EC_LIGHTBAR
	  To compile this driver as a module, choose M here: the
	  module will be called cros_ec_lightbar.

config CROS_EC_VBC
	tristate "ChromeOS EC vboot context support"
	depends on MFD_CROS_EC_CHARDEV && OF
	default MFD_CROS_EC_CHARDEV
	help
	  This option exposes the ChromeOS EC vboot context nvram to
	  userspace.

	  To compile this driver as a module, choose M here: the
	  module will be called cros_ec_vbc.

endif # CHROMEOS_PLATFORMS
+2 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o
obj-$(CONFIG_CHROMEOS_PSTORE)		+= chromeos_pstore.o
obj-$(CONFIG_CHROMEOS_TBMC)		+= chromeos_tbmc.o
cros_ec_ctl-objs			:= cros_ec_sysfs.o \
					   cros_ec_vbc.o cros_ec_debugfs.o
					   cros_ec_debugfs.o
obj-$(CONFIG_CROS_EC_CTL)		+= cros_ec_ctl.o
obj-$(CONFIG_CROS_EC_I2C)		+= cros_ec_i2c.o
obj-$(CONFIG_CROS_EC_SPI)		+= cros_ec_spi.o
@@ -14,3 +14,4 @@ obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o
obj-$(CONFIG_CROS_EC_PROTO)		+= cros_ec_proto.o
obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT)	+= cros_kbd_led_backlight.o
obj-$(CONFIG_CROS_EC_LIGHTBAR)		+= cros_ec_lightbar.o
obj-$(CONFIG_CROS_EC_VBC)		+= cros_ec_vbc.o
+42 −1
Original line number Diff line number Diff line
@@ -22,8 +22,11 @@
#include <linux/platform_device.h>
#include <linux/mfd/cros_ec.h>
#include <linux/mfd/cros_ec_commands.h>
#include <linux/module.h>
#include <linux/slab.h>

#define DRV_NAME "cros-ec-vbc"

static ssize_t vboot_context_read(struct file *filp, struct kobject *kobj,
				  struct bin_attribute *att, char *buf,
				  loff_t pos, size_t count)
@@ -132,4 +135,42 @@ struct attribute_group cros_ec_vbc_attr_group = {
	.bin_attrs = cros_ec_vbc_bin_attrs,
	.is_bin_visible = cros_ec_vbc_is_visible,
};
EXPORT_SYMBOL(cros_ec_vbc_attr_group);

static int cros_ec_vbc_probe(struct platform_device *pd)
{
	struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);
	struct device *dev = &pd->dev;
	int ret;

	ret = sysfs_create_group(&ec_dev->class_dev.kobj,
				 &cros_ec_vbc_attr_group);
	if (ret < 0)
		dev_err(dev, "failed to create %s attributes. err=%d\n",
			cros_ec_vbc_attr_group.name, ret);

	return ret;
}

static int cros_ec_vbc_remove(struct platform_device *pd)
{
	struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);

	sysfs_remove_group(&ec_dev->class_dev.kobj,
			   &cros_ec_vbc_attr_group);

	return 0;
}

static struct platform_driver cros_ec_vbc_driver = {
	.driver = {
		.name = DRV_NAME,
	},
	.probe = cros_ec_vbc_probe,
	.remove = cros_ec_vbc_remove,
};

module_platform_driver(cros_ec_vbc_driver);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Expose the vboot context nvram to userspace");
MODULE_ALIAS("platform:" DRV_NAME);
Loading