From patchwork Sat Feb 10 07:09:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 199222 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1338852dyd; Fri, 9 Feb 2024 23:20:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhPzBgri6ByBo92CHAaFN/5VfZCBaQUPoCv3Dpc3cMBv4P58M13RE1+aUXyxOxivNWmoIW X-Received: by 2002:a05:6870:ebc5:b0:218:5017:af07 with SMTP id cr5-20020a056870ebc500b002185017af07mr1714470oab.0.1707549626277; Fri, 09 Feb 2024 23:20:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707549626; cv=pass; d=google.com; s=arc-20160816; b=xAljKAKx4bov/Hp8whRsZW7yeLBVUxLvwK1QsbvaUrlx6j9WcyjBVSdEEDNoyn+npA Lw0nt+7Ogf8HwjcLvs+vdRlBH3p+00XBq9VWwykDU/eCoKM1VgKdeYpzr8Kc4jYEaQqP dpA404Ct0oYLQVDFved+KmpJcZqsiHKAp8yvhPJncm6t1eSPGfe4TqMWvF0uaDTdelVD QoXS0RR6qmrxai2g1twhdHfNURAuSpQOw2FI/7BdHtLQgx7WxCdMvCKUX1IcbPaGmMTF 9LLLJ+p3igS60zZyrZDhHkNJ7ivC+nBrDXOa7Z1QgDbMjslevkYU4XxD70X6EARwC8xa y5mg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=o6rwt10FSsSf9ZLI/+GmfDcWiK/rJgtd/StxIlWC43k=; fh=f1H57yfhL/v3eExeLNOvFj/J5MC1PfDu6MBY9PFdOx8=; b=La3/9GxW0Ay/ThBpTkosGgeetCZ+ZQJ3OtBVV28CLrg4f1J592U4bqLevEvMdp+FlF ZFMU8CXKdF8rL6sJr/5HF7hhZDCR434eeFevFm3r14isBLBRRGqo3OHJV/O23BYlj3yH o/h5wQeNDcpR7UlzRacf++nD/GcO8M0AlCU37lwCh70+gplHfZprv4p6VuAjG6SX2EW9 zGt2QQlr0M8nPfY801zxpncJb7/MCaXXRdqex+vfJ3mrz1AexuqR7Apq6nOL8kMbyAIi BSRZSyztWTQaxp8Ab1LHG7ryzYOiQ0vlYkqRsn/Aq+SMmgwnPkuJwoHRAOyTFDqtdUWJ IQHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=g7IbOi+R; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60317-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60317-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCUg2rL333APz1RkMLwK08cOYiumnf/zI2P1YXvfFvnJD65WNVnK6goM70MvuomFeluWH9hv6dq48QlLWpPLztJddHulpg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e4-20020a656884000000b005d798062b8csi3098859pgt.499.2024.02.09.23.20.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 23:20:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60317-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=g7IbOi+R; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60317-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60317-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C265EB22621 for ; Sat, 10 Feb 2024 07:14:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56D493B191; Sat, 10 Feb 2024 07:10:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="g7IbOi+R" Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 1A81439FFB for ; Sat, 10 Feb 2024 07:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707549001; cv=none; b=pWTgP1EOcWiYTVJ6EQXhUbV9P+kHpCKLc9tx5ZLTY/QXVyI25EdXapno4uFT/xr6/qio091GLRLVrld5pBUxknCPyMLUGpeliQG50RN3fW1Aovw+EC51q5OT3z14RncB7HN1VDs/N49gaCAFuttjH1PcA0ezs7+uaDIizHuNBBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707549001; c=relaxed/simple; bh=XNvI42j+7FmHqNECdaZBEQBh8CeG71yHi4CBUyp0EFE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tlVVvLM6syYufm6tiFFD7/J4ZMKj4pT29HSeIbpph4lH4WIEo8kdp764LyaiwZ6jwR9tR2+zNVXL3SuvKjwEC8PMngwmWvVRAWGQADoi+Rs6OB2B4JmDpbdpzjBPsFjRDewZpX94KsZJlKAPiq6UBWzh970dZynjM+Z995qm7Co= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=g7IbOi+R; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d7232dcb3eso14438815ad.2 for ; Fri, 09 Feb 2024 23:09:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707548998; x=1708153798; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o6rwt10FSsSf9ZLI/+GmfDcWiK/rJgtd/StxIlWC43k=; b=g7IbOi+Ra2rUoZ7bDPpUvDqlna2c3MLNh80mv0pomgcpD3xiJJwxXySjFl7VpELmfO VLpUqRx+JRb49StXfst3hmXJHSvO4QGfaj7fKSdk/NDjbMWFuLaXX1I4lui06sdArmgz Pp8isuJ257fauNoY82viDVOI8l70y4iVGvJ3w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707548998; x=1708153798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o6rwt10FSsSf9ZLI/+GmfDcWiK/rJgtd/StxIlWC43k=; b=VOvmS4898ljQYDBkt8ZnJUpm1/3pMsH4VhmxrqcoXfiBmbC9FmsKKNKqp+Vm5Ka+rA Y5jPgrfjDN0wVfx+384rqKUOUkME3zWnXoBDZGQaUv2pvJ8eI2YGAN/bBk0lj6bOsrmn YmrYr2q+WXmXQE2J/6jffEi8ipgCaTadjyXnJ+Q4J+5qvpmL/6LQzvchFTNrUIeOcdyI 4idysIoB+vnuHW+lGFfq4QwqIKDQX/spyn68yROgA7OmB5yVOeT+n6QZJvIQwmc/yMbi zquZwLpJIMZvfQV/xC56SmMKVW9dbUczvjVBRHJ7GjW4BB09pU23plc0r70AhkkHz2Hg b9WA== X-Gm-Message-State: AOJu0YzpUBZMODMF34DEkrm+IlIWsIBxDuxCOneHFqSFFF6Ae5b3RrhZ epOXbh/N/GvIX0Na6GU85o1FDUT6nHRrsx8dnOoWEl4OedrU+YBOPrbxXgcPDg== X-Received: by 2002:a17:902:cec8:b0:1d7:15ea:4249 with SMTP id d8-20020a170902cec800b001d715ea4249mr1845301plg.7.1707548998453; Fri, 09 Feb 2024 23:09:58 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWPZfxVECZHV+IGwDF6uOIynzL9NdXLQpNK0tbkQ2Mz94NuD0bNKUXlIQOfURhM40ViSH6Y1bQHXrsL8QcTVDOpfp9IhmOli0B86t20P56YmH7Rr4fAmaobUBFshZ4oU90czIyB424aoMm1H+P2EVicSoFANLiOl5FkWrmppBq5oc36Xrf4nuB7SdV1JThyyJ8z8JM5+TKC2pJ+AgoekkFkutv2sLbDR0scg1x1psNNG/JpJjSZyNS2qmYHXz0+MRY2R7QDIVzqnbQfrb+vVDMMCUdks9KrCwRtZlhhWcLOnkjyz56KiF+ALWd/V9lMy2R1pN7E8cNV2PDc0DG3Q5t8Jx8/7dBqnRYs7yLTySXvmKsPondkLQ== Received: from localhost (175.199.125.34.bc.googleusercontent.com. [34.125.199.175]) by smtp.gmail.com with UTF8SMTPSA id h9-20020a170902f2c900b001d921bcc621sm2478144plc.243.2024.02.09.23.09.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Feb 2024 23:09:57 -0800 (PST) From: Stephen Boyd To: chrome-platform@lists.linux.dev Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, Douglas Anderson , Pin-yen Lin , Prashant Malani , Benson Leung , Tzung-Bi Shih Subject: [PATCH 11/22] platform/chrome: cros_typec_switch: Use fwnode instead of ACPI APIs Date: Fri, 9 Feb 2024 23:09:22 -0800 Message-ID: <20240210070934.2549994-12-swboyd@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210070934.2549994-1-swboyd@chromium.org> References: <20240210070934.2549994-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790495556840525257 X-GMAIL-MSGID: 1790495556840525257 Use fwnode APIs instead of ACPI ones because this driver will soon support devicetree firmwares. Using fwnode APIs makes it easier to support either ACPI or DT. Cc: Prashant Malani Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Signed-off-by: Stephen Boyd --- drivers/platform/chrome/cros_typec_switch.c | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c index 1a718b661203..373e0e86ebfc 100644 --- a/drivers/platform/chrome/cros_typec_switch.c +++ b/drivers/platform/chrome/cros_typec_switch.c @@ -207,29 +207,31 @@ static int cros_typec_register_port(struct cros_typec_switch_data *sdata, struct cros_typec_port *port; struct device *dev = sdata->dev; struct acpi_device *adev; - unsigned long long index; + u32 index; int ret; + const char *prop_name; port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); if (!port) return -ENOMEM; adev = to_acpi_device_node(fwnode); - if (adev) { - ret = acpi_evaluate_integer(adev->handle, "_ADR", NULL, &index); - if (ACPI_FAILURE(ret)) { - dev_err(fwnode->dev, "_ADR wasn't evaluated\n"); - return -ENODATA; - } - } + if (adev) + prop_name = "_ADR"; if (!adev) { dev_err(fwnode->dev, "Couldn't get ACPI handle\n"); return -ENODEV; } + ret = fwnode_property_read_u32(fwnode, prop_name, &index); + if (ret) { + dev_err(fwnode->dev, "%s property wasn't found\n", prop_name); + return ret; + } + if (index >= EC_USB_PD_MAX_PORTS) { - dev_err(fwnode->dev, "Invalid port index number: %llu\n", index); + dev_err(fwnode->dev, "Invalid port index number: %u\n", index); return -EINVAL; } port->sdata = sdata; @@ -243,7 +245,7 @@ static int cros_typec_register_port(struct cros_typec_switch_data *sdata, return ret; } - dev_dbg(dev, "Retimer switch registered for index %llu\n", index); + dev_dbg(dev, "Retimer switch registered for index %u\n", index); } if (!fwnode_property_present(fwnode, "mode-switch")) @@ -255,7 +257,7 @@ static int cros_typec_register_port(struct cros_typec_switch_data *sdata, return ret; } - dev_dbg(dev, "Mode switch registered for index %llu\n", index); + dev_dbg(dev, "Mode switch registered for index %u\n", index); return ret; }