From patchwork Thu Jan 4 15:45:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 185054 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5691010dyb; Thu, 4 Jan 2024 07:46:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEv6TZiF4gYbGnwtbKP0NtMZSfvcwxKt7aYPrjfI+4dU8koCML1/8YippoQg0QS34LtsePh X-Received: by 2002:aa7:8589:0:b0:6d9:bce7:d8e3 with SMTP id w9-20020aa78589000000b006d9bce7d8e3mr748100pfn.24.1704383200216; Thu, 04 Jan 2024 07:46:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704383200; cv=none; d=google.com; s=arc-20160816; b=axwuqexYyQeWrfrXWO0xebZ7TW2amRwj/fGAzdyxpEB3OfmHkRooKwHakoOyILn65k dgTmbc8RM2j7oR6yHo7VYkDPrBTxMgGlS5rb6+hDtfZR5/adKdhEFPAqATgi5VjY2YbV 3VMat+vyyzeg04/BUHFQ5jXstaeYiYTXtdR1k5iUTqEYS4MGE61gPdbu0fIz+6cyne9Z MhquZ2YEuPgLGs/xGbzowVrbD9yd3OI/bIwxThPOwvuJNmEuEQzzh9+CBxkjkNZMDSTU D84M2BijxAGmUTbNyO8I/ZaAp8UBToaJNRfB3vZF4BNOc346vUTtL/eCZodb4x/K8Au2 qLxA== ARC-Message-Signature: i=1; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=SS4qp3FbuwSqV8rxN86fLN4iZLCeCkhuyatEDQHR1cc=; fh=+X1Cf9SyJlg5zvVqn0eAXHzZQfabkHWxlWEL9DjfXNc=; b=O6C9mZ6zVrYr1a8DEYa5QCah0YQfVHrYKieADksvYVkCBsDqDqVSNknYEGlyQosuyN 87l2T9DMGgzm+YxRyrWVnewu+60udFxuhanKF0iR2FgyyjIPPdTUXfyolqEDnspMUbGo FdVILX1/wqb+oeu1XI++pt0STcyxrdWTDL7w4eIbuAh2kyLPUTOPFNZbY8Mk2mvk5xqX MzMl5FsRS3BeppspG0rd4rH8TulW018Rf67eAfnkDF46AsMCdaoUgDoTMYy9bh4uTkYo Pli64wZhQAYgUq4BiRA4neDumKL+zIZAzSSd+gO+sxgMzjvgbfSoQkApqKC4xLKMU/6T tqLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MdBhR7cS; spf=pass (google.com: domain of linux-kernel+bounces-16876-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16876-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l30-20020a63571e000000b005c6260b688esi23633088pgb.606.2024.01.04.07.46.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 07:46:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16876-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=@ti.com header.s=ti-com-17Q1 header.b=MdBhR7cS; spf=pass (google.com: domain of linux-kernel+bounces-16876-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16876-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com 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 A199EB23536 for ; Thu, 4 Jan 2024 15:46:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 677C124A1A; Thu, 4 Jan 2024 15:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="MdBhR7cS" X-Original-To: linux-kernel@vger.kernel.org Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1568E23762; Thu, 4 Jan 2024 15:46:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 404Fjrmm105829; Thu, 4 Jan 2024 09:45:53 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1704383153; bh=SS4qp3FbuwSqV8rxN86fLN4iZLCeCkhuyatEDQHR1cc=; h=From:To:CC:Subject:Date; b=MdBhR7cSqxkMrjuQdnmh/n+7M2JbB/mhh51pbpt1J4QJLWRy6hBFU64466rBMISF7 nSQTRZJEvbpRtqL55lfOlNGX16A+QQf/GnOMuYvSqg7wAlpp0XtptdOxmTex90lCzT fQ0wnVTg88Hj2rqhmRjDmlxjjlSahhXfNKLyEX5g= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 404Fjrhu077332 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 4 Jan 2024 09:45:53 -0600 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 4 Jan 2024 09:45:53 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 4 Jan 2024 09:45:53 -0600 Received: from lelvsmtp5.itg.ti.com ([10.249.40.136]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 404FjqGQ040462; Thu, 4 Jan 2024 09:45:53 -0600 From: Andrew Davis To: Peter Rosin , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Nishanth Menon , Vignesh Raghavendra CC: , , Andrew Davis Subject: [PATCH v6] mux: mmio: use reg property when parent device is not a syscon Date: Thu, 4 Jan 2024 09:45:52 -0600 Message-ID: <20240104154552.17852-1-afd@ti.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787175318156626763 X-GMAIL-MSGID: 1787175318156626763 The DT binding for the reg-mux compatible states it can be used when the "parent device of mux controller is not syscon device". It also allows for a reg property. When the reg property is provided, use that to identify the address space for this mux. If not provided fallback to using the parent device as a regmap provider. While here use dev_err_probe() in the error path to prevent printing a message on probe defer which now can happen in extra ways. Signed-off-by: Andrew Davis Reviewed-by: Nishanth Menon Acked-by: Peter Rosin --- Changes from v5: - Rebased on next-20240104 Changes from v4: - Shorten comment and code lines - Remove extra ret assignment Changes from v3: - Check for probe defer Changes from v2: - Rebased on v6.6-rc1 Changes from v1: - Flip logic as suggested in v1[0] [0] https://lore.kernel.org/lkml/1c27d9d4-b1cc-c158-90f7-f7e47e02c424@ti.com/T/ drivers/mux/mmio.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c index fd1d121a584ba..30a952c34365f 100644 --- a/drivers/mux/mmio.c +++ b/drivers/mux/mmio.c @@ -44,15 +44,20 @@ static int mux_mmio_probe(struct platform_device *pdev) int ret; int i; - if (of_device_is_compatible(np, "mmio-mux")) + if (of_device_is_compatible(np, "mmio-mux")) { regmap = syscon_node_to_regmap(np->parent); - else - regmap = dev_get_regmap(dev->parent, NULL) ?: ERR_PTR(-ENODEV); - if (IS_ERR(regmap)) { - ret = PTR_ERR(regmap); - dev_err(dev, "failed to get regmap: %d\n", ret); - return ret; + } else { + regmap = device_node_to_regmap(np); + /* Fallback to checking the parent node on "real" errors. */ + if (IS_ERR(regmap) && regmap != ERR_PTR(-EPROBE_DEFER)) { + regmap = dev_get_regmap(dev->parent, NULL); + if (!regmap) + regmap = ERR_PTR(-ENODEV); + } } + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), + "failed to get regmap\n"); ret = of_property_count_u32_elems(np, "mux-reg-masks"); if (ret == 0 || ret % 2)