From patchwork Fri Apr 15 00:32:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 12814163 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FA8618E for ; Fri, 15 Apr 2022 00:32:59 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id e8-20020a17090a118800b001cb13402ea2so7207461pja.0 for ; Thu, 14 Apr 2022 17:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u5uNblHgSOrswPeO9jURL3NSLbtduvbh6ZJ+Qdg6lQI=; b=FL9PZa7rqg/FQc24DKxyR99Opmvgy6c3zIdZDaBfP4n8HTZ/yB2BYuvSBSFQXOcAZd uEHYiNbQmPVoRnkfuIxaz3XeEJ8J6ZPZ3z2WRzpYo7g5KAzE2lyNiu7Fr89hF9l8lZTG /4B9a+qm1khvB+hDLkK+xXPYs9ZguwZPEysNw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u5uNblHgSOrswPeO9jURL3NSLbtduvbh6ZJ+Qdg6lQI=; b=mce0193hyaD7B7wuk3P2aGLxFXQ/9XaLyQMxNBnNI4BdfmXti8N9qQ9xTS5+qfMdRA iNdRHoa5ih4dsLKdl83Tb6Ilif92FJtQGOjcXzHkATg0aLCEWr83evB4UemgZH5zCezM V1+bOfb8n5g/+B1AMpGrjV9qVlivhTzMv9qnNe664yGxqq/cLnfPt3Sv5GZ83fABjirz BfluqHV/Jw6pIYB/G72QJbsi5VIQI0rxcWlIqMaHd3DwvqOtTDKRImsCv++iTakRYGfE Eq1EnNxGLSBfAGcRMDOqC2h4lxeuSlkpFPYWKOekQUf0mzPnIYwGBVPR14qdNdSCH7o+ GfXQ== X-Gm-Message-State: AOAM531a0aMsTArH8IJtuQHv9n3kwcWW1P1scNsBTIFiNne2PU11cD6z 07GXHdA1UZcTI6K3NjWrAerm0g== X-Google-Smtp-Source: ABdhPJy092wIOMpHMCaiCRG/f784cDQMvZyv6Zy3Qf2VuKU9u3jvUIyk6bF/0bpYWpLFKq3UGLiVqA== X-Received: by 2002:a17:902:b941:b0:14d:af72:3f23 with SMTP id h1-20020a170902b94100b0014daf723f23mr50652474pls.6.1649982778661; Thu, 14 Apr 2022 17:32:58 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:201:e3e0:734:f81a:d2c1]) by smtp.gmail.com with ESMTPSA id p12-20020a63ab0c000000b00381f7577a5csm2830187pgf.17.2022.04.14.17.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 17:32:58 -0700 (PDT) From: Stephen Boyd To: Benson Leung Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Lee Jones , Daisuke Nojiri , Guenter Roeck , 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 Message-Id: <20220415003253.1973106-4-swboyd@chromium.org> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220415003253.1973106-1-swboyd@chromium.org> References: <20220415003253.1973106-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Cc: Daisuke Nojiri Cc: Benson Leung Cc: Guenter Roeck Cc: Signed-off-by: Stephen Boyd Reviewed-by: Tzung-Bi Shih --- .../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);