Commit 0545625b authored by Enric Balletbo i Serra's avatar Enric Balletbo i Serra Committed by Lee Jones

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: 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 6fd7f2bb
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -391,12 +392,16 @@ static const struct mfd_cell cros_ec_platform_cells[] = { ...@@ -391,12 +392,16 @@ static const struct mfd_cell cros_ec_platform_cells[] = {
{ .name = "cros-ec-debugfs" }, { .name = "cros-ec-debugfs" },
{ .name = "cros-ec-lightbar" }, { .name = "cros-ec-lightbar" },
{ .name = "cros-ec-sysfs" }, { .name = "cros-ec-sysfs" },
{ .name = "cros-ec-vbc" }, };
static const struct mfd_cell cros_ec_vbc_cells[] = {
{ .name = "cros-ec-vbc" }
}; };
static int ec_device_probe(struct platform_device *pdev) static int ec_device_probe(struct platform_device *pdev)
{ {
int retval = -ENOMEM; int retval = -ENOMEM;
struct device_node *node;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct cros_ec_platform *ec_platform = dev_get_platdata(dev); struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL); struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
...@@ -485,6 +490,18 @@ static int ec_device_probe(struct platform_device *pdev) ...@@ -485,6 +490,18 @@ static int ec_device_probe(struct platform_device *pdev)
"failed to add cros-ec platform devices: %d\n", "failed to add cros-ec platform devices: %d\n",
retval); retval);
/* Check whether this EC instance has a VBC NVRAM */
node = ec->ec_dev->dev->of_node;
if (of_property_read_bool(node, "google,has-vbc-nvram")) {
retval = mfd_add_devices(ec->dev, PLATFORM_DEVID_AUTO,
cros_ec_vbc_cells,
ARRAY_SIZE(cros_ec_vbc_cells),
NULL, 0, NULL);
if (retval)
dev_warn(ec->dev, "failed to add VBC devices: %d\n",
retval);
}
return 0; return 0;
failed: failed:
......
...@@ -108,21 +108,6 @@ static ssize_t vboot_context_write(struct file *filp, struct kobject *kobj, ...@@ -108,21 +108,6 @@ static ssize_t vboot_context_write(struct file *filp, struct kobject *kobj,
return data_sz; return data_sz;
} }
static umode_t cros_ec_vbc_is_visible(struct kobject *kobj,
struct bin_attribute *a, int n)
{
struct device *dev = container_of(kobj, struct device, kobj);
struct cros_ec_dev *ec = to_cros_ec_dev(dev);
struct device_node *np = ec->ec_dev->dev->of_node;
if (IS_ENABLED(CONFIG_OF) && np) {
if (of_property_read_bool(np, "google,has-vbc-nvram"))
return a->attr.mode;
}
return 0;
}
static BIN_ATTR_RW(vboot_context, 16); static BIN_ATTR_RW(vboot_context, 16);
static struct bin_attribute *cros_ec_vbc_bin_attrs[] = { static struct bin_attribute *cros_ec_vbc_bin_attrs[] = {
...@@ -133,7 +118,6 @@ static struct bin_attribute *cros_ec_vbc_bin_attrs[] = { ...@@ -133,7 +118,6 @@ static struct bin_attribute *cros_ec_vbc_bin_attrs[] = {
struct attribute_group cros_ec_vbc_attr_group = { struct attribute_group cros_ec_vbc_attr_group = {
.name = "vbc", .name = "vbc",
.bin_attrs = cros_ec_vbc_bin_attrs, .bin_attrs = cros_ec_vbc_bin_attrs,
.is_bin_visible = cros_ec_vbc_is_visible,
}; };
static int cros_ec_vbc_probe(struct platform_device *pd) static int cros_ec_vbc_probe(struct platform_device *pd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment