aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnric Balletbo i Serra <enric.balletbo@collabora.com>2018-12-12 12:34:01 -0500
committerLee Jones <lee.jones@linaro.org>2019-02-01 03:09:27 -0500
commit0545625baa5981bb0a583e6a6045155936d3ea95 (patch)
treeee4adec16869b918a08c69a0fa09aaab2c5d2982
parent6fd7f2bbd4422e7635bc771cd1ec440378158cb1 (diff)
mfd / platform: cros_ec_vbc: Instantiate only if the EC has a VBC NVRAM
The cros-ec-vbc driver is DT-only and there is a DT property that indicates if the EC has the VCB NVRAM, in such case instantiate the driver but don't instantiate on the other cases. To do this move the check code to its parent instead of play with the attribute group visibility. This changes a bit the actual behaviour. Before the patch if an EC doesn't have a VBC NVRAM an empty vbc folder is created in /sys/class/chromeos/<ec-device-name>, after the patch the empty folder is not created, so, the folder is only created if the vbc is set. 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--drivers/mfd/cros_ec_dev.c19
-rw-r--r--drivers/platform/chrome/cros_ec_vbc.c16
2 files changed, 18 insertions, 17 deletions
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index b9ec2a798dbb..ed809fc97df8 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -21,6 +21,7 @@
21#include <linux/mfd/core.h> 21#include <linux/mfd/core.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/mod_devicetable.h> 23#include <linux/mod_devicetable.h>
24#include <linux/of_platform.h>
24#include <linux/platform_device.h> 25#include <linux/platform_device.h>
25#include <linux/pm.h> 26#include <linux/pm.h>
26#include <linux/slab.h> 27#include <linux/slab.h>
@@ -391,12 +392,16 @@ static const struct mfd_cell cros_ec_platform_cells[] = {
391 { .name = "cros-ec-debugfs" }, 392 { .name = "cros-ec-debugfs" },
392 { .name = "cros-ec-lightbar" }, 393 { .name = "cros-ec-lightbar" },
393 { .name = "cros-ec-sysfs" }, 394 { .name = "cros-ec-sysfs" },
394 { .name = "cros-ec-vbc" }, 395};
396
397static const struct mfd_cell cros_ec_vbc_cells[] = {
398 { .name = "cros-ec-vbc" }
395}; 399};
396 400
397static int ec_device_probe(struct platform_device *pdev) 401static int ec_device_probe(struct platform_device *pdev)
398{ 402{
399 int retval = -ENOMEM; 403 int retval = -ENOMEM;
404 struct device_node *node;
400 struct device *dev = &pdev->dev; 405 struct device *dev = &pdev->dev;
401 struct cros_ec_platform *ec_platform = dev_get_platdata(dev); 406 struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
402 struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL); 407 struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
@@ -485,6 +490,18 @@ static int ec_device_probe(struct platform_device *pdev)
485 "failed to add cros-ec platform devices: %d\n", 490 "failed to add cros-ec platform devices: %d\n",
486 retval); 491 retval);
487 492
493 /* Check whether this EC instance has a VBC NVRAM */
494 node = ec->ec_dev->dev->of_node;
495 if (of_property_read_bool(node, "google,has-vbc-nvram")) {
496 retval = mfd_add_devices(ec->dev, PLATFORM_DEVID_AUTO,
497 cros_ec_vbc_cells,
498 ARRAY_SIZE(cros_ec_vbc_cells),
499 NULL, 0, NULL);
500 if (retval)
501 dev_warn(ec->dev, "failed to add VBC devices: %d\n",
502 retval);
503 }
504
488 return 0; 505 return 0;
489 506
490failed: 507failed:
diff --git a/drivers/platform/chrome/cros_ec_vbc.c b/drivers/platform/chrome/cros_ec_vbc.c
index da3bbf05e86f..af9bfe6f385c 100644
--- a/drivers/platform/chrome/cros_ec_vbc.c
+++ b/drivers/platform/chrome/cros_ec_vbc.c
@@ -108,21 +108,6 @@ static ssize_t vboot_context_write(struct file *filp, struct kobject *kobj,
108 return data_sz; 108 return data_sz;
109} 109}
110 110
111static umode_t cros_ec_vbc_is_visible(struct kobject *kobj,
112 struct bin_attribute *a, int n)
113{
114 struct device *dev = container_of(kobj, struct device, kobj);
115 struct cros_ec_dev *ec = to_cros_ec_dev(dev);
116 struct device_node *np = ec->ec_dev->dev->of_node;
117
118 if (IS_ENABLED(CONFIG_OF) && np) {
119 if (of_property_read_bool(np, "google,has-vbc-nvram"))
120 return a->attr.mode;
121 }
122
123 return 0;
124}
125
126static BIN_ATTR_RW(vboot_context, 16); 111static BIN_ATTR_RW(vboot_context, 16);
127 112
128static struct bin_attribute *cros_ec_vbc_bin_attrs[] = { 113static struct bin_attribute *cros_ec_vbc_bin_attrs[] = {
@@ -133,7 +118,6 @@ static struct bin_attribute *cros_ec_vbc_bin_attrs[] = {
133struct attribute_group cros_ec_vbc_attr_group = { 118struct attribute_group cros_ec_vbc_attr_group = {
134 .name = "vbc", 119 .name = "vbc",
135 .bin_attrs = cros_ec_vbc_bin_attrs, 120 .bin_attrs = cros_ec_vbc_bin_attrs,
136 .is_bin_visible = cros_ec_vbc_is_visible,
137}; 121};
138 122
139static int cros_ec_vbc_probe(struct platform_device *pd) 123static int cros_ec_vbc_probe(struct platform_device *pd)