platform/chrome: cros_ec_lightbar: Instantiate only if the EC has a lightbar
authorEnric Balletbo i Serra <enric.balletbo@collabora.com>
Wed, 12 Dec 2018 17:34:02 +0000 (18:34 +0100)
committerLee Jones <lee.jones@linaro.org>
Fri, 1 Feb 2019 08:09:27 +0000 (08:09 +0000)
commitfd68bd0f5d4c2090c95f84e27b05d0836bcd6c0c
tree2da97f30022aaaf7397236ee87935532945e86d0
parent0545625baa5981bb0a583e6a6045155936d3ea95
platform/chrome: cros_ec_lightbar: Instantiate only if the EC has a lightbar

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-name>, 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>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/platform/chrome/cros_ec_lightbar.c