Immutable branch between MFD and Platform due for the v5.1 merge window
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAlxUAA4ACgkQUa+KL4f8
d2HeRA/9HOEGYv79zfrN/+cVtUf6LUGzIzPQtGi5Q9aWyF32mbqwRvnO6FTsFlJS
iKE0pi2UhaFcVXOSlAYKOoFpCuqSIiH5AQNuDMn4T1vvlsHjN+ygRRoO+2XVCVHU
tUbVbV1GxOLvl9P/urviJW4Db8LAXPI5gR5j0IyaZG6m7EPY+lnSDUp4nVqSby23
hLrfBX4m70wsteXyKrKnHr6fwrFxadOWkhRbbDFfJnq8z7acjF4rYtyO3v8wMAqa
YGzvtlYOvWkg0SS/gkL+ATYbJAagtxs6GRecc7wyCbo/gUEO0PNK5UyFyQOfpigl
t4JoKBwGA/eAxMFHDW3lQYBQUTgkscssh/VP1Z5Tp5wwp7hEFw2WgcGfZDrWpR0d
HGEQG+yl4KsXvuPbWQ1BlOwbIP3pMI/heKliKBLNEtxghchb+C7rA3jN7CMF9UsA
c8dTQF3QA7sPyfRQVNwvgkLHqqXOTY3w82w1RsMwUuccXH1UY6bDt8vNAHqt2L0U
Uu7r1hf93dkWGSQlhwHT1TwbkshwmVZrUC23VEs7ftjaLT5i1e1Jm+de0Qo8/hPS
CGdN0LZcJaI3dej4QT3AfjYwJNnVmYTGZ/1zU8C9k8FWDf4mfkM96Ndk7wAXs29g
9Qx6ejfoZUlfEZ6tNn5zVbfqY2COdMe4pU0AnhiK1K4AFecDs4M=
=lQ+1
-----END PGP SIGNATURE-----
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>
1 file changed