Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754382AbdFWWMo (ORCPT ); Fri, 23 Jun 2017 18:12:44 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:34383 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751488AbdFWWMn (ORCPT ); Fri, 23 Jun 2017 18:12:43 -0400 Subject: Re: [PATCH RESEND 12/13] platform/chrome: cros_ec_lightbar - Add userspace lightbar control bit to EC To: Enric Balletbo i Serra , olof@lixom.net, bleung@chromium.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, Eric Caruso , Guenter Roeck References: <20170516161319.13257-1-enric.balletbo@collabora.com> <20170516161319.13257-13-enric.balletbo@collabora.com> From: Benson Leung Organization: Google Message-ID: <4540f1c2-b045-b535-1559-4d15ed60030b@google.com> Date: Fri, 23 Jun 2017 15:12:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170516161319.13257-13-enric.balletbo@collabora.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dV5ouwiDN0iW2sAIh2q5k8OlN8jXscj0O" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5307 Lines: 168 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --dV5ouwiDN0iW2sAIh2q5k8OlN8jXscj0O Content-Type: multipart/mixed; boundary="u9WNPV2f7hc3FakTtuN0G2n8pNAlSIJaR"; protected-headers="v1" From: Benson Leung To: Enric Balletbo i Serra , olof@lixom.net, bleung@chromium.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, Eric Caruso , Guenter Roeck Message-ID: <4540f1c2-b045-b535-1559-4d15ed60030b@google.com> Subject: Re: [PATCH RESEND 12/13] platform/chrome: cros_ec_lightbar - Add userspace lightbar control bit to EC References: <20170516161319.13257-1-enric.balletbo@collabora.com> <20170516161319.13257-13-enric.balletbo@collabora.com> In-Reply-To: <20170516161319.13257-13-enric.balletbo@collabora.com> --u9WNPV2f7hc3FakTtuN0G2n8pNAlSIJaR Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi Enric, Looks good. On 05/16/2017 09:13 AM, Enric Balletbo i Serra wrote: > From: Eric Caruso >=20 > Some devices might want to turn off the lightbar if e.g. the > system turns the screen off due to idleness. This prevents the > kernel from going through its normal suspend/resume pathways. >=20 > Signed-off-by: Eric Caruso > Signed-off-by: Guenter Roeck > Signed-off-by: Enric Balletbo i Serra Signed-off-by: Benson Leung Applied. > --- > drivers/platform/chrome/cros_ec_lightbar.c | 38 ++++++++++++++++++++++= ++++++++ > 1 file changed, 38 insertions(+) >=20 > diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platf= orm/chrome/cros_ec_lightbar.c > index 4df379d..e570c1e 100644 > --- a/drivers/platform/chrome/cros_ec_lightbar.c > +++ b/drivers/platform/chrome/cros_ec_lightbar.c > @@ -38,6 +38,12 @@ > /* Rate-limit the lightbar interface to prevent DoS. */ > static unsigned long lb_interval_jiffies =3D 50 * HZ / 1000; > =20 > +/* > + * Whether or not we have given userspace control of the lightbar. > + * If this is true, we won't do anything during suspend/resume. > + */ > +static bool userspace_control; > + > static ssize_t interval_msec_show(struct device *dev, > struct device_attribute *attr, char *buf) > { > @@ -407,11 +413,17 @@ int lb_manual_suspend_ctrl(struct cros_ec_dev *ec= , uint8_t enable) > =20 > int lb_suspend(struct cros_ec_dev *ec) > { > + if (userspace_control) > + return 0; > + > return lb_send_empty_cmd(ec, LIGHTBAR_CMD_SUSPEND); > } > =20 > int lb_resume(struct cros_ec_dev *ec) > { > + if (userspace_control) > + return 0; > + > return lb_send_empty_cmd(ec, LIGHTBAR_CMD_RESUME); > } > =20 > @@ -528,6 +540,30 @@ static ssize_t program_store(struct device *dev, s= truct device_attribute *attr, > return ret; > } > =20 > +static ssize_t userspace_control_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + return scnprintf(buf, PAGE_SIZE, "%d\n", userspace_control); > +} > + > +static ssize_t userspace_control_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, > + size_t count) > +{ > + bool enable; > + int ret; > + > + ret =3D strtobool(buf, &enable); > + if (ret < 0) > + return ret; > + > + userspace_control =3D enable; > + > + return count; > +} > + > /* Module initialization */ > =20 > static DEVICE_ATTR_RW(interval_msec); > @@ -536,6 +572,7 @@ static DEVICE_ATTR_WO(brightness); > static DEVICE_ATTR_WO(led_rgb); > static DEVICE_ATTR_RW(sequence); > static DEVICE_ATTR_WO(program); > +static DEVICE_ATTR_RW(userspace_control); > =20 > static struct attribute *__lb_cmds_attrs[] =3D { > &dev_attr_interval_msec.attr, > @@ -544,6 +581,7 @@ static struct attribute *__lb_cmds_attrs[] =3D { > &dev_attr_led_rgb.attr, > &dev_attr_sequence.attr, > &dev_attr_program.attr, > + &dev_attr_userspace_control.attr, > NULL, > }; > =20 >=20 --=20 Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. bleung@google.com Chromium OS Project bleung@chromium.org --u9WNPV2f7hc3FakTtuN0G2n8pNAlSIJaR-- --dV5ouwiDN0iW2sAIh2q5k8OlN8jXscj0O Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBCgAGBQJZTZJXAAoJEB8J9XsKL+ZYOsUQAJ3+qggfOHip9oMtvDFVrkvc AAmox3+nID2ygYZ0NHJuUVA0Fbp+sn6eHAy3dOCfFU05qOiTZJtg8gylArgJlUsR s9sZHy68KjlLnokppbmPQS550FOiL4hH+ZzHFiXuEnK4RK48Rk07Ck5dFQw6CoX5 XUrnNhgmq0v+DdSws7v5kfOAevTdFT9Zv7VfGCvt3b4aYgBpKAOCv5qt6Js3BVE6 D7odMZTE/GGB+QaEmrYd0OX/L0wxVnty0D+IDrrr/qyky9LdhkPQ0v4NwikCRAqR nFQ8Nic2t5REUhc++aFiVrxMt5GjnRCzyUky+LpsUyDjNIw6RaxfABOrpswX8mXX Ae7gZa/bfteCtFwdDrgx26MGBPglPAJU9B+l5ZJi7/IPYg74Ai1jRNmsyYbnYVtq URP0sLUuNdLGIs+sJoew8l+r5Mqova+m502Zs0gY2EqWCge6ZNlq2nv55J3Vs5t6 whzNZjmU05iifFGpWckyCbQFVNOON7WqDOac8g+NSM4YLk/yNa9gWTJ93j7el4FQ icqGYp8mouTh/678/ZHVQW+GHhoquumoaVwrrkq7CgFwFcYtHwC64NNKr2KBISBF U2rBDhwH37k/B9bN6mbii2LARA04CsHTQUwtcefospopAXpyQ7UJuUz5dZFw3M99 gIdLfS+k/Iy+DfWE4Kky =RSjN -----END PGP SIGNATURE----- --dV5ouwiDN0iW2sAIh2q5k8OlN8jXscj0O--