From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: lee.jones@linaro.org
Cc: gwendal@chromium.org, drinkcat@chromium.org,
linux-kernel@vger.kernel.org, groeck@chromium.org,
kernel@collabora.com, bleung@chromium.org,
Olof Johansson <olof@lixom.net>
Subject: [PATCH v3 3/8] mfd / platform: cros_ec: move vbc attributes to its own driver.
Date: Tue, 27 Nov 2018 13:18:44 +0100 [thread overview]
Message-ID: <20181127121849.23975-4-enric.balletbo@collabora.com> (raw)
In-Reply-To: <20181127121849.23975-1-enric.balletbo@collabora.com>
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>
---
Changes in v3:
- Fixed build error as reported by the kbuild test robot.
Changes in v2:
- Removed unneeded check of ec_dev.
.../sysfs-class-chromeos-driver-cros-ec-vbc | 6 +++
drivers/mfd/cros_ec_dev.c | 2 +-
drivers/platform/chrome/Kconfig | 10 +++++
drivers/platform/chrome/Makefile | 3 +-
drivers/platform/chrome/cros_ec_vbc.c | 43 ++++++++++++++++++-
include/linux/mfd/cros_ec.h | 1 -
6 files changed, 61 insertions(+), 4 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-class-chromeos-driver-cros-ec-vbc
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..c256a2febf37
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-chromeos-driver-cros-ec-vbc
@@ -0,0 +1,6 @@
+What: /sys/class/chromeos/<cros-ec>/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.
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 614f888c9d6d..51325049690c 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -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,
};
@@ -391,6 +390,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)
diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
index 05bcefbe1926..29bd9837d520 100644
--- a/drivers/platform/chrome/Kconfig
+++ b/drivers/platform/chrome/Kconfig
@@ -121,4 +121,14 @@ 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
+ 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
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
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
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 @@
#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);
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
index b6beba3031ba..bbbe416fd573 100644
--- a/include/linux/mfd/cros_ec.h
+++ b/include/linux/mfd/cros_ec.h
@@ -325,7 +325,6 @@ u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev);
/* sysfs stuff */
extern struct attribute_group cros_ec_attr_group;
-extern struct attribute_group cros_ec_vbc_attr_group;
/* debugfs stuff */
int cros_ec_debugfs_init(struct cros_ec_dev *ec);
--
2.19.1
next prev parent reply other threads:[~2018-11-27 12:19 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-27 12:18 [PATCH v3 0/8] mfd / platform: cros_ec: move cros_ec sysfs attributes to its own drivers Enric Balletbo i Serra
2018-11-27 12:18 ` [PATCH v3 1/8] mfd / platform: cros_ec: use devm_mfd_add_devices Enric Balletbo i Serra
2018-11-29 23:30 ` Guenter Roeck
2018-12-03 10:32 ` Lee Jones
2018-12-03 22:13 ` Enric Balletbo i Serra
2018-12-04 9:22 ` Lee Jones
2018-11-27 12:18 ` [PATCH v3 2/8] mfd / platform: cros_ec: move lightbar attributes to its own driver Enric Balletbo i Serra
2018-11-29 23:34 ` Guenter Roeck
2018-12-03 10:36 ` Lee Jones
2018-12-03 22:21 ` Enric Balletbo i Serra
2018-12-04 9:21 ` Lee Jones
2018-12-04 11:52 ` Enric Balletbo i Serra
2018-12-04 16:57 ` Guenter Roeck
2018-12-05 8:09 ` Lee Jones
2018-12-05 7:25 ` Lee Jones
2018-11-27 12:18 ` Enric Balletbo i Serra [this message]
2018-11-29 23:36 ` [PATCH v3 3/8] mfd / platform: cros_ec: move vbc " Guenter Roeck
2018-12-03 10:42 ` Lee Jones
2018-11-27 12:18 ` [PATCH v3 4/8] mfd / platform: cros_ec: move debugfs " Enric Balletbo i Serra
2018-12-03 10:55 ` Lee Jones
2018-12-10 18:04 ` Guenter Roeck
2018-11-27 12:18 ` [PATCH v3 5/8] mfd / platform: cros_ec: move device sysfs " Enric Balletbo i Serra
2018-12-03 10:56 ` Lee Jones
2018-12-10 18:13 ` Guenter Roeck
2018-12-10 18:22 ` Enric Balletbo i Serra
2018-12-10 18:28 ` Guenter Roeck
2018-12-10 21:27 ` Enric Balletbo Serra
2018-12-10 21:50 ` Guenter Roeck
2018-12-10 22:11 ` Enric Balletbo Serra
2018-12-10 22:25 ` Guenter Roeck
2018-11-27 12:18 ` [PATCH v3 6/8] mfd / platform: cros_ec: instantiate only if th EC has a VBC NVRAM Enric Balletbo i Serra
2018-12-03 10:57 ` Lee Jones
2018-12-10 18:15 ` Guenter Roeck
2018-12-10 18:30 ` Guenter Roeck
2018-11-27 12:18 ` [PATCH v3 7/8] platform/chrome: cros_ec_lightbar: instantiate only if the EC has a lightbar Enric Balletbo i Serra
2018-12-10 18:20 ` Guenter Roeck
2018-12-11 11:18 ` Enric Balletbo i Serra
2018-11-27 12:18 ` [PATCH v3 8/8] mfd: cros_ec: add a dev_release empty method Enric Balletbo i Serra
2018-11-27 17:29 ` Guenter Roeck
2018-11-27 17:52 ` Greg Kroah-Hartman
2018-11-29 1:17 ` Guenter Roeck
2018-11-29 7:55 ` Greg Kroah-Hartman
2018-11-29 22:11 ` Enric Balletbo i Serra
2018-11-29 22:28 ` Guenter Roeck
2018-11-30 8:30 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181127121849.23975-4-enric.balletbo@collabora.com \
--to=enric.balletbo@collabora.com \
--cc=bleung@chromium.org \
--cc=drinkcat@chromium.org \
--cc=groeck@chromium.org \
--cc=gwendal@chromium.org \
--cc=kernel@collabora.com \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).