From: Guenter Roeck <linux@roeck-us.net>
To: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Cc: lee.jones@linaro.org, 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: Re: [PATCH 7/7] platform/chrome: cros_ec_lightbar: instantiate only if the EC has a lightbar.
Date: Thu, 22 Nov 2018 11:25:44 -0800 [thread overview]
Message-ID: <20181122192544.GA2410@roeck-us.net> (raw)
In-Reply-To: <20181122113356.23610-8-enric.balletbo@collabora.com>
On Thu, Nov 22, 2018 at 12:33:56PM +0100, Enric Balletbo i Serra wrote:
> Due to the way attribute groups visibility work, the function
> cros_ec_lightbar_attrs_are_visible is called multiple times, once per
> attribute, and each of these calls makes an EC transaction. For what is
> worth the EC log reports multiple errors on boot when the lightbar is
> not available. Instead, check if the EC has a lightbar in the probe
> function and only instantiate the device.
>
> Ideally we should have instantiate the driver only if the
> EC_FEATURE_LIGHTBAR is defined, but that's not possible because that flag
> is not in the very first Pixel Chromebook (Link), only on Samus. So, the
> driver is instantiated by his parent always.
>
> This patch changes a bit the actual behaviour. Before the patch if an EC
> doesn't have a lightbar an empty lightbar 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 lightbar exists.
>
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Guess this is the answer to the suggestion I had before. Maybe the two patches
should be merged together ? Or do others think that they should be kept
separate ?
Additional comment below.
Thanks,
Guenter
> ---
>
> drivers/platform/chrome/cros_ec_lightbar.c | 29 +++++++++-------------
> 1 file changed, 12 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c
> index 31d22f594fac..d255264eb082 100644
> --- a/drivers/platform/chrome/cros_ec_lightbar.c
> +++ b/drivers/platform/chrome/cros_ec_lightbar.c
> @@ -567,37 +567,28 @@ static struct attribute *__lb_cmds_attrs[] = {
> NULL,
> };
>
> -static bool ec_has_lightbar(struct cros_ec_dev *ec)
> +static bool cros_ec_has_lightbar(struct cros_ec_dev *ec_dev)
> {
> - return !!get_lightbar_version(ec, NULL, NULL);
> -}
> -
> -static umode_t cros_ec_lightbar_attrs_are_visible(struct kobject *kobj,
> - struct attribute *a, int n)
> -{
> - struct device *dev = container_of(kobj, struct device, kobj);
> - struct cros_ec_dev *ec = to_cros_ec_dev(dev);
> - struct platform_device *pdev = to_platform_device(ec->dev);
> + struct platform_device *pdev = to_platform_device(ec_dev->dev);
> struct cros_ec_platform *pdata = pdev->dev.platform_data;
> int is_cros_ec;
>
> is_cros_ec = strcmp(pdata->ec_name, CROS_EC_DEV_NAME);
>
Can this now ever be false ?
> if (is_cros_ec != 0)
> - return 0;
> + return false;
>
> - /* Only instantiate this stuff if the EC has a lightbar */
> - if (ec_has_lightbar(ec)) {
> - ec_with_lightbar = ec;
> - return a->mode;
> + if (!!get_lightbar_version(ec_dev, NULL, NULL)) {
> + ec_with_lightbar = ec_dev;
Is this variable (and the associated check in lb_manual_suspend_ctrl)
still necessary ?
> + return true;
> }
> - return 0;
> +
> + return false;
> }
>
> struct attribute_group cros_ec_lightbar_attr_group = {
> .name = "lightbar",
> .attrs = __lb_cmds_attrs,
> - .is_visible = cros_ec_lightbar_attrs_are_visible,
> };
>
> static int cros_ec_lightbar_probe(struct platform_device *pd)
> @@ -611,6 +602,10 @@ static int cros_ec_lightbar_probe(struct platform_device *pd)
> return -EINVAL;
> }
>
> + /* Only instantiate this stuff if the EC has a lightbar */
> + if (!cros_ec_has_lightbar(ec_dev))
> + return -ENODEV;
> +
> /* Take control of the lightbar from the EC. */
> lb_manual_suspend_ctrl(ec_dev, 1);
>
next prev parent reply other threads:[~2018-11-22 19:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-22 11:33 [PATCH 0/7] mfd / platform: cros_ec: move cros_ec sysfs attributes to its own drivers Enric Balletbo i Serra
2018-11-22 11:33 ` [PATCH 1/7] mfd: cros_ec: use devm_mfd_add_devices Enric Balletbo i Serra
2018-11-22 11:33 ` [PATCH 2/7] mfd / platform: cros_ec: move lightbar attributes to its own driver Enric Balletbo i Serra
2018-11-22 17:41 ` Guenter Roeck
2018-11-23 11:52 ` Enric Balletbo i Serra
2018-11-23 12:03 ` Guenter Roeck
2018-11-22 11:33 ` [PATCH 3/7] mfd / platform: cros_ec: move vbc " Enric Balletbo i Serra
2018-11-22 11:33 ` [PATCH 4/7] mfd / platform: cros_ec: move debugfs " Enric Balletbo i Serra
2018-11-22 18:52 ` Guenter Roeck
2018-11-22 11:33 ` [PATCH 5/7] mfd / platform: cros_ec: move device sysfs " Enric Balletbo i Serra
2018-11-22 19:09 ` Guenter Roeck
2018-11-29 11:21 ` Dan Carpenter
2018-11-29 14:43 ` Enric Balletbo i Serra
2018-11-29 14:56 ` Dan Carpenter
2018-11-22 11:33 ` [PATCH 6/7] mfd / platform: cros_ec: instantiate only if th EC has a VBC NVRAM Enric Balletbo i Serra
2018-11-22 19:14 ` Guenter Roeck
2018-11-23 10:37 ` Enric Balletbo i Serra
2018-11-22 11:33 ` [PATCH 7/7] platform/chrome: cros_ec_lightbar: instantiate only if the EC has a lightbar Enric Balletbo i Serra
2018-11-22 19:25 ` Guenter Roeck [this message]
2018-11-23 11:10 ` Enric Balletbo i Serra
2018-11-23 11:39 ` Guenter Roeck
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=20181122192544.GA2410@roeck-us.net \
--to=linux@roeck-us.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.