2020-02-20 15:59:43

by Enric Balletbo i Serra

[permalink] [raw]
Subject: [PATCH 2/8] Input: cros_ec_keyb: Use cros_ec_cmd_xfer_status helper

This patch makes use of cros_ec_cmd_xfer_status() instead of
cros_ec_cmd_xfer(). In this case there is no advantage of doing this
apart from that we want to make cros_ec_cmd_xfer() a private function
for the EC protocol and let people only use the
cros_ec_cmd_xfer_status() to return Linux standard error codes.

Signed-off-by: Enric Balletbo i Serra <[email protected]>
---

drivers/input/keyboard/cros_ec_keyb.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index 2b71c5a51f90..fc1793ca2f17 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -347,18 +347,14 @@ static int cros_ec_keyb_info(struct cros_ec_device *ec_dev,
params->info_type = info_type;
params->event_type = event_type;

- ret = cros_ec_cmd_xfer(ec_dev, msg);
- if (ret < 0) {
- dev_warn(ec_dev->dev, "Transfer error %d/%d: %d\n",
- (int)info_type, (int)event_type, ret);
- } else if (msg->result == EC_RES_INVALID_VERSION) {
+ ret = cros_ec_cmd_xfer_status(ec_dev, msg);
+ if (ret == -ENOTSUPP) {
/* With older ECs we just return 0 for everything */
memset(result, 0, result_size);
ret = 0;
- } else if (msg->result != EC_RES_SUCCESS) {
- dev_warn(ec_dev->dev, "Error getting info %d/%d: %d\n",
- (int)info_type, (int)event_type, msg->result);
- ret = -EPROTO;
+ } else if (ret < 0) {
+ dev_warn(ec_dev->dev, "Transfer error %d/%d: %d\n",
+ (int)info_type, (int)event_type, ret);
} else if (ret != result_size) {
dev_warn(ec_dev->dev, "Wrong size %d/%d: %d != %zu\n",
(int)info_type, (int)event_type,
--
2.25.0


2020-03-02 10:09:02

by Enric Balletbo i Serra

[permalink] [raw]
Subject: Re: [PATCH 2/8] Input: cros_ec_keyb: Use cros_ec_cmd_xfer_status helper

Hi Dmitry,

Gentle ping, I'd like feedback from you on this series, and are you fine with
this change?

Thanks,
Enric

On 20/2/20 16:58, Enric Balletbo i Serra wrote:
> This patch makes use of cros_ec_cmd_xfer_status() instead of
> cros_ec_cmd_xfer(). In this case there is no advantage of doing this
> apart from that we want to make cros_ec_cmd_xfer() a private function
> for the EC protocol and let people only use the
> cros_ec_cmd_xfer_status() to return Linux standard error codes.
>
> Signed-off-by: Enric Balletbo i Serra <[email protected]>
> ---
>
> drivers/input/keyboard/cros_ec_keyb.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
> index 2b71c5a51f90..fc1793ca2f17 100644
> --- a/drivers/input/keyboard/cros_ec_keyb.c
> +++ b/drivers/input/keyboard/cros_ec_keyb.c
> @@ -347,18 +347,14 @@ static int cros_ec_keyb_info(struct cros_ec_device *ec_dev,
> params->info_type = info_type;
> params->event_type = event_type;
>
> - ret = cros_ec_cmd_xfer(ec_dev, msg);
> - if (ret < 0) {
> - dev_warn(ec_dev->dev, "Transfer error %d/%d: %d\n",
> - (int)info_type, (int)event_type, ret);
> - } else if (msg->result == EC_RES_INVALID_VERSION) {
> + ret = cros_ec_cmd_xfer_status(ec_dev, msg);
> + if (ret == -ENOTSUPP) {
> /* With older ECs we just return 0 for everything */
> memset(result, 0, result_size);
> ret = 0;
> - } else if (msg->result != EC_RES_SUCCESS) {
> - dev_warn(ec_dev->dev, "Error getting info %d/%d: %d\n",
> - (int)info_type, (int)event_type, msg->result);
> - ret = -EPROTO;
> + } else if (ret < 0) {
> + dev_warn(ec_dev->dev, "Transfer error %d/%d: %d\n",
> + (int)info_type, (int)event_type, ret);
> } else if (ret != result_size) {
> dev_warn(ec_dev->dev, "Wrong size %d/%d: %d != %zu\n",
> (int)info_type, (int)event_type,
>