From patchwork Wed Jan 4 06:08:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13088186 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 7BB00637 for ; Wed, 4 Jan 2023 06:09:01 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id h192so16744822pgc.7 for ; Tue, 03 Jan 2023 22:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=u7z3aK6JYwkPs6rlnGUEdEtPieaIcdnszYZ0OhEZgdE=; b=A6I+o74xCrRkH0h+QHiX6jGt3VZxCmIfjp+jxfvdOhYCl6RW/k93Mmi0I0nO7daPzJ HG9L0rIiILKq/9Gn8C4SNJwqjFUMeEQRB7ZzwoeiX0QK/BzX6cKjiTZeXz6VVSB+rbg0 2js3EAqQVR7NoJK0w5e6E9fqqUBt06R0g1pQM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u7z3aK6JYwkPs6rlnGUEdEtPieaIcdnszYZ0OhEZgdE=; b=RYr/CHdeIECiLNCLlSFLnl8e87LXtHxIGpUYfVEZq1HR+r7D9hUEl6i0USY08j4EG/ fUM+nnL5kWUD/ekwg+lqGdbq/u16aL2dtb2GfpjSZcmx6Ni678wmTVgXyzdNvfcTQu+T 66WyO4Sf2G5r39vKN8cfRmimNYpcmH7KIu6FfsnBEXCuMphoEVVIlNteuNMsxKmrsxZJ 5bzRfPCUdaJ9Z0vjr6G2bHZvZPIXzBdidcSR4GU3iO7k2YriwkB854jYVP1DTX6PmVqg +D1KykxAGw9sD3X7G6EAyWrniippkZmNqtaKe9D9vIoPcp+x1nVIFH+Zm/Wjk7iQPADe P5+g== X-Gm-Message-State: AFqh2kopMQhNZ3T8gzBRV/hu5UGkbn6Hdp0Tb2LZx1Ols9QPZr17TdGH LPlneWDz2GzBIorJFFT8g1XbJg== X-Google-Smtp-Source: AMrXdXt0PaJnwyroJBMafonPPYnzD/kMJKo9ipb60mRVcLKLwEEk/JuOmREFcOFP4O2lCg9Tli0dkg== X-Received: by 2002:aa7:870c:0:b0:581:c9cf:3807 with SMTP id b12-20020aa7870c000000b00581c9cf3807mr22602868pfo.29.1672812540812; Tue, 03 Jan 2023 22:09:00 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id v27-20020aa799db000000b00577c5915138sm124660pfi.128.2023.01.03.22.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 22:09:00 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: Prashant Malani , Benson Leung Subject: [PATCH 1/2] platform/chrome: cros_typec_switch: Use fwnode* prop check Date: Wed, 4 Jan 2023 06:08:44 +0000 Message-Id: <20230104060846.112216-1-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Using device_property_present() multiple times on an ACPI device leads to kernel panics on Chromebook systems. This happens when there is > 1 boolean property in an ACPI device which is created dynamically by the BIOS as part of SSDT[1] on Chromebook systems Since fwnode_* can handle simple device tree properties equally well, switch to using the fwnode_property_present() function version. This will avoid panics and make the usage consistent when we introduce a check for the 2nd property in a subsequent patch. [1] https://wiki.osdev.org/SSDT Signed-off-by: Prashant Malani Reviewed-by: Benson Leung --- drivers/platform/chrome/cros_typec_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c index a26219e97c93..2536bda03bf3 100644 --- a/drivers/platform/chrome/cros_typec_switch.c +++ b/drivers/platform/chrome/cros_typec_switch.c @@ -254,7 +254,7 @@ static int cros_typec_register_switches(struct cros_typec_switch_data *sdata) dev_dbg(dev, "Retimer switch registered for index %llu\n", index); - if (!device_property_present(fwnode->dev, "mode-switch")) + if (!fwnode_property_present(fwnode, "mode-switch")) continue; ret = cros_typec_register_mode_switch(port, fwnode); From patchwork Wed Jan 4 06:08:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13088187 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 D9D4E637 for ; Wed, 4 Jan 2023 06:09:03 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id 18so9941262pfx.7 for ; Tue, 03 Jan 2023 22:09:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=ugbM9GhIHqb4MVhnuzFZlbylgderdj1/9nzv3BJLAfw=; b=XN7UcaT/R6KMixGU1AD3M9jb1Wnx1YjmLA6GSFhzDoKqrQ8IupYAFh37F9qL6LDrIO nNdnBX+ndVgeatZ1K0YRNlFN6b+/VkggE7paFRmF/E8CTVJl1Yqob9cGfI/+K8vhGjkF onos9srhmZfOYjwy/OPJyHLxYB5ZRpdSwTGBQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ugbM9GhIHqb4MVhnuzFZlbylgderdj1/9nzv3BJLAfw=; b=0wAuNdtnHM7Daxhcg+t956BnBGfQMZNCcxTUX1fl1dXE+7Qg6wpO1kjc223YMy39/C CfN2B2hwQQypXwMu3bu5o/uRVBSQzIYpOYktJ4OIuIxh9x+nLXZgQWNA10Cmr1YYxm3Z Ns19rsbAYEqm0hib/ilvOgaKlwSXDkJNLrdh4kOEfHJuDbExpRWD+V010Yv5aHxycobB NMMxM4WQr8D3zRaQSilVEfACjCCfHpw8v4aJ+2Dgl5oqV8XIaded4lb2GxJY4eeHDo4H subFxijBdgnhzeDI24FhY5rMEOH65N/SteBfTCArp+Z6oM8ojRBz4VSrf/e5+CBq2C29 lIAA== X-Gm-Message-State: AFqh2kq9JODIF7lyiAHBNAii1JHmxMJwBE/v8wb0+X5I3oeJ4+ZQFX33 9fv5MSpTWxfql8HgpIYug0K/xUmXLOb8yAU7 X-Google-Smtp-Source: AMrXdXtggieJeeDwqXLkoF+peCXfavToOZMjMTl9uWWSTSP3J9bSXdHxt52TTKfZ8IcoA8KPzARU9g== X-Received: by 2002:aa7:88c3:0:b0:580:963d:8064 with SMTP id k3-20020aa788c3000000b00580963d8064mr59521363pff.20.1672812543417; Tue, 03 Jan 2023 22:09:03 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id v27-20020aa799db000000b00577c5915138sm124660pfi.128.2023.01.03.22.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 22:09:03 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: Prashant Malani , Benson Leung Subject: [PATCH 2/2] platform/chrome: cros_typec_switch: Check for retimer flag Date: Wed, 4 Jan 2023 06:08:45 +0000 Message-Id: <20230104060846.112216-2-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230104060846.112216-1-pmalani@chromium.org> References: <20230104060846.112216-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Not all ports have retimers. Only register a retimer switch if the "retimer-switch" property is present for that port's mux device. Signed-off-by: Prashant Malani Reviewed-by: Benson Leung --- drivers/platform/chrome/cros_typec_switch.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c index 2536bda03bf3..9ed1605f4071 100644 --- a/drivers/platform/chrome/cros_typec_switch.c +++ b/drivers/platform/chrome/cros_typec_switch.c @@ -246,14 +246,16 @@ static int cros_typec_register_switches(struct cros_typec_switch_data *sdata) port->port_num = index; sdata->ports[index] = port; - ret = cros_typec_register_retimer(port, fwnode); - if (ret) { - dev_err(dev, "Retimer switch register failed\n"); - goto err_switch; + if (fwnode_property_present(fwnode, "retimer-switch")) { + ret = cros_typec_register_retimer(port, fwnode); + if (ret) { + dev_err(dev, "Retimer switch register failed\n"); + goto err_switch; + } + + dev_dbg(dev, "Retimer switch registered for index %llu\n", index); } - dev_dbg(dev, "Retimer switch registered for index %llu\n", index); - if (!fwnode_property_present(fwnode, "mode-switch")) continue;