Chrome platform driver development
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: Benson Leung <bleung@chromium.org>
Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev,
	Lee Jones <lee.jones@linaro.org>,
	Daisuke Nojiri <dnojiri@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	chrome-platform@lists.linux.dev
Subject: [PATCH 3/3] power: supply: PCHG: Use cros_ec_pchg_port_count()
Date: Thu, 14 Apr 2022 17:32:53 -0700	[thread overview]
Message-ID: <20220415003253.1973106-4-swboyd@chromium.org> (raw)
In-Reply-To: <20220415003253.1973106-1-swboyd@chromium.org>

Use the common function cros_ec_pchg_port_count() now that we only
register this device when there are a non-zero number of peripheral
charger ports.

Cc: Lee Jones <lee.jones@linaro.org>
Cc: Daisuke Nojiri <dnojiri@chromium.org>
Cc: Benson Leung <bleung@chromium.org>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: <chrome-platform@lists.linux.dev>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 .../power/supply/cros_peripheral_charger.c    | 29 +------------------
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/drivers/power/supply/cros_peripheral_charger.c b/drivers/power/supply/cros_peripheral_charger.c
index 9fe6d826148d..98cae6580eed 100644
--- a/drivers/power/supply/cros_peripheral_charger.c
+++ b/drivers/power/supply/cros_peripheral_charger.c
@@ -104,22 +104,6 @@ static bool cros_pchg_cmd_ver_check(const struct charger_data *charger)
 	return !!(rsp.version_mask & BIT(pchg_cmd_version));
 }
 
-static int cros_pchg_port_count(const struct charger_data *charger)
-{
-	struct ec_response_pchg_count rsp;
-	int ret;
-
-	ret = cros_pchg_ec_command(charger, 0, EC_CMD_PCHG_COUNT,
-				   NULL, 0, &rsp, sizeof(rsp));
-	if (ret < 0) {
-		dev_warn(charger->dev,
-			 "Unable to get number or ports (err:%d)\n", ret);
-		return ret;
-	}
-
-	return rsp.port_count;
-}
-
 static int cros_pchg_get_status(struct port_data *port)
 {
 	struct charger_data *charger = port->charger;
@@ -281,24 +265,13 @@ static int cros_pchg_probe(struct platform_device *pdev)
 	charger->ec_dev = ec_dev;
 	charger->ec_device = ec_device;
 
-	ret = cros_pchg_port_count(charger);
-	if (ret <= 0) {
-		/*
-		 * This feature is enabled by the EC and the kernel driver is
-		 * included by default for CrOS devices. Don't need to be loud
-		 * since this error can be normal.
-		 */
-		dev_info(dev, "No peripheral charge ports (err:%d)\n", ret);
-		return -ENODEV;
-	}
-
 	if (!cros_pchg_cmd_ver_check(charger)) {
 		dev_err(dev, "EC_CMD_PCHG version %d isn't available.\n",
 			pchg_cmd_version);
 		return -EOPNOTSUPP;
 	}
 
-	num_ports = ret;
+	num_ports = cros_ec_pchg_port_count(ec_dev);
 	if (num_ports > EC_PCHG_MAX_PORTS) {
 		dev_err(dev, "Too many peripheral charge ports (%d)\n",
 			num_ports);
-- 
https://chromeos.dev


  parent reply	other threads:[~2022-04-15  0:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-15  0:32 [PATCH 0/3] platform/chrome: Only register PCHG if present Stephen Boyd
2022-04-15  0:32 ` [PATCH 1/3] platform/chrome: cros_ec_proto: Add peripheral charger count API Stephen Boyd
2022-04-18  3:23   ` Tzung-Bi Shih
2022-04-18 19:43     ` Stephen Boyd
2022-04-18 23:08   ` Prashant Malani
2022-04-18 23:16     ` Stephen Boyd
2022-04-18 23:21       ` Prashant Malani
2022-04-18 23:29         ` Stephen Boyd
2022-04-18 23:31           ` Prashant Malani
2022-04-18 23:41             ` Stephen Boyd
2022-04-15  0:32 ` [PATCH 2/3] mfd: cros_ec_dev: Only register PCHG device if present Stephen Boyd
2022-04-18  3:25   ` Tzung-Bi Shih
2022-04-15  0:32 ` Stephen Boyd [this message]
2022-04-18  3:26   ` [PATCH 3/3] power: supply: PCHG: Use cros_ec_pchg_port_count() Tzung-Bi Shih

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=20220415003253.1973106-4-swboyd@chromium.org \
    --to=swboyd@chromium.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dnojiri@chromium.org \
    --cc=groeck@chromium.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox