From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5E32ACA64 for ; Fri, 24 Jan 2025 19:17:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737746228; cv=none; b=NDrA5DyV485+dtDriPhq8haVm6nyA4/g7RZ3m1QYq1atT/y9F1vzvVKweQQVuUkNebRI3Eadm2BLxW4Ivw9GOA/jZyCmOZHvJRbhIeQzwAafUMKMk2vdqGZ2VH8qEuZipRC9RUpRtxIzqFYR6q0MD8d7P6xiQ/fd6X8r1gZcI4w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737746228; c=relaxed/simple; bh=na62wdtR8lOCwIQClYxcjiMTBiLkRa2huiAoLl7vaPc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Bpm00QGwQ1JsvwhxFlZQZAWzdQz1h+wgQn8Fg/DlBoh92ouZgF/j8AcHcI95dJToixDRAwOgLnsIUSFuDj7pLY6uVmY4t8bIua3YKePKLX9D961lvJj7bPe4U7iQt3dbakN6fWMrnGpC4NFKD0eR6U7r9lfV3BH0EDVpDSpNsCg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H1rmguA2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H1rmguA2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0EC0C4CED2; Fri, 24 Jan 2025 19:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737746227; bh=na62wdtR8lOCwIQClYxcjiMTBiLkRa2huiAoLl7vaPc=; h=From:To:Cc:Subject:Date:From; b=H1rmguA27Kwyx8xJfvVcVDggXvPd8yn3FYWcahJnZZDJyoYeEA7OlmqQGJ7kfJC7m X72Ej6jbjyZp6n0Kkox9OV4ilw4+1C5xPlBtdL9fuUeuNYTLDf7gSUzPsvWHifbQPp igNIEsZfReMoI5j/JE8e9RymxeYCRsQMxi8rQIV+HaMH2wgvYqd7cTFTGKVHXqcPc4 P2d5etpUFj509zKfJf83nNZ41YpgjlfNHby9UdgTGFeAs/3Fo1WTRkpYcJ61bAYZFb tTipUXXu8zJGzxTcwrF4i2POhmpCpHAIHQDLT03CJNTfvOJiEZ+ZnlIhOzos8ONE3A 6jABTXxWfd3/Q== From: "Rob Herring (Arm)" To: Lee Jones , Arnd Bergmann , Krzysztof Kozlowski , Pankaj Dubey Cc: Will McVicker , John Madieu , Nishanth Menon , Vaishnav Achath , linux-kernel@vger.kernel.org Subject: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Date: Fri, 24 Jan 2025 13:16:44 -0600 Message-ID: <20250124191644.2309790-1-robh@kernel.org> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible") broke drivers which call device_node_to_regmap() on nodes without a "syscon" compatible. Restore the prior behavior for device_node_to_regmap(). This also makes using device_node_to_regmap() incompatible with of_syscon_register_regmap() again, so add kerneldoc for device_node_to_regmap() and syscon_node_to_regmap() to make it clear how and when each one should be used. Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible") Cc: Will McVicker Cc: John Madieu Cc: Nishanth Menon Reported-by: Vaishnav Achath Signed-off-by: Rob Herring (Arm) --- drivers/mfd/syscon.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index 226915ca3c93..aa4a9940b569 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -159,6 +159,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res) } static struct regmap *device_node_get_regmap(struct device_node *np, + bool create_regmap, bool check_res) { struct syscon *entry, *syscon = NULL; @@ -172,7 +173,7 @@ static struct regmap *device_node_get_regmap(struct device_node *np, } if (!syscon) { - if (of_device_is_compatible(np, "syscon")) + if (create_regmap) syscon = of_syscon_register(np, check_res); else syscon = ERR_PTR(-EINVAL); @@ -233,15 +234,37 @@ int of_syscon_register_regmap(struct device_node *np, struct regmap *regmap) } EXPORT_SYMBOL_GPL(of_syscon_register_regmap); +/** + * device_node_to_regmap() - Get or create a regmap for specified device node + * @np: Device tree node + * + * Get a regmap for the specified device node. If there's not an existing + * regmap, then one is instantiated. This function should not be used if the + * device node has a custom regmap driver or has resources (clocks, resets) to + * be managed. Use syscon_node_to_regmap() instead for those cases. + * + * Return: regmap ptr on success, negative error code on failure. + */ struct regmap *device_node_to_regmap(struct device_node *np) { - return device_node_get_regmap(np, false); + return device_node_get_regmap(np, true, false); } EXPORT_SYMBOL_GPL(device_node_to_regmap); +/** + * syscon_node_to_regmap() - Get or create a regmap for specified syscon device node + * @np: Device tree node + * + * Get a regmap for the specified device node. If there's not an existing + * regmap, then one is instantiated if the node is a generic "syscon". This + * function is safe to use for a syscon registered with + * of_syscon_register_regmap(). + * + * Return: regmap ptr on success, negative error code on failure. + */ struct regmap *syscon_node_to_regmap(struct device_node *np) { - return device_node_get_regmap(np, true); + return device_node_get_regmap(np, of_device_is_compatible(np, "syscon"), true); } EXPORT_SYMBOL_GPL(syscon_node_to_regmap); -- 2.45.2