From: Guenter Roeck <groeck@google.com>
To: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Cc: Lee Jones <lee.jones@linaro.org>,
Gwendal Grignou <gwendal@chromium.org>,
Nicolas Boichat <drinkcat@chromium.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Guenter Roeck <groeck@chromium.org>,
kernel@collabora.com, Benson Leung <bleung@chromium.org>,
Olof Johansson <olof@lixom.net>
Subject: Re: [PATCH v3 6/8] mfd / platform: cros_ec: instantiate only if th EC has a VBC NVRAM.
Date: Mon, 10 Dec 2018 10:30:49 -0800 [thread overview]
Message-ID: <CABXOdTdQ74KTn-GKGdw=KEwwHXhY3uyO-e_CA9=rMAi_eLkaBg@mail.gmail.com> (raw)
In-Reply-To: <CABXOdTd3_KGfJG-E7UBgnxKJcyFNVZ2FqdqH6y-G0gkEUZjk0Q@mail.gmail.com>
On Mon, Dec 10, 2018 at 10:15 AM Guenter Roeck <groeck@google.com> wrote:
>
> On Tue, Nov 27, 2018 at 4:19 AM Enric Balletbo i Serra
> <enric.balletbo@collabora.com> wrote:
> >
> > 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>, 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>
>
Forgot to mention: It would be nice if the subject would mention what
is only instantiated if there is a VBC NVRAM, and there is a typo (th
instead of the).
Guenter
> > ---
> >
> > Changes in v3:
> > - Fixed build error as reported by kbuild test robot.
> >
> > Changes in v2:
> > - Remove unnecessary IS_ENABLED.
> > - Remove dev_err message telling that VBC is found.
> > - Use dev_warn instead of dev_err as the error is ignored.
> >
> > drivers/mfd/cros_ec_dev.c | 19 ++++++++++++++++++-
> > drivers/platform/chrome/cros_ec_vbc.c | 16 ----------------
> > 2 files changed, 18 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
> > index d9b16ce79319..1ba98a32715e 100644
> > --- a/drivers/mfd/cros_ec_dev.c
> > +++ b/drivers/mfd/cros_ec_dev.c
> > @@ -21,6 +21,7 @@
> > #include <linux/mfd/core.h>
> > #include <linux/module.h>
> > #include <linux/mod_devicetable.h>
> > +#include <linux/of_platform.h>
> > #include <linux/platform_device.h>
> > #include <linux/pm.h>
> > #include <linux/slab.h>
> > @@ -386,12 +387,16 @@ static const struct mfd_cell cros_ec_platform_cells[] = {
> > { .name = "cros-ec-debugfs" },
> > { .name = "cros-ec-lightbar" },
> > { .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)
> > {
> > int retval = -ENOMEM;
> > + struct device_node *node;
> > struct device *dev = &pdev->dev;
> > struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
> > struct cros_ec_dev *ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL);
> > @@ -479,6 +484,18 @@ static int ec_device_probe(struct platform_device *pdev)
> > "failed to add cros-ec platform devices: %d\n",
> > 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;
> >
> > failed:
> > 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,
> > 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 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 = {
> > .name = "vbc",
> > .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)
> > --
> > 2.19.1
> >
next prev parent reply other threads:[~2018-12-10 18:31 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 ` [PATCH v3 3/8] mfd / platform: cros_ec: move vbc " Enric Balletbo i Serra
2018-11-29 23:36 ` 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 [this message]
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='CABXOdTdQ74KTn-GKGdw=KEwwHXhY3uyO-e_CA9=rMAi_eLkaBg@mail.gmail.com' \
--to=groeck@google.com \
--cc=bleung@chromium.org \
--cc=drinkcat@chromium.org \
--cc=enric.balletbo@collabora.com \
--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).