Skip to content

Commit 4dc1d1b

Browse files
committed
Merge tag 'mfd-fixes-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
Pull MFD fix from Lee Jones: - Fix syscon users not specifying the "syscon" compatible * tag 'mfd-fixes-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
2 parents 09fbf3d + 5728c92 commit 4dc1d1b

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

drivers/mfd/syscon.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
159159
}
160160

161161
static struct regmap *device_node_get_regmap(struct device_node *np,
162+
bool create_regmap,
162163
bool check_res)
163164
{
164165
struct syscon *entry, *syscon = NULL;
@@ -172,7 +173,7 @@ static struct regmap *device_node_get_regmap(struct device_node *np,
172173
}
173174

174175
if (!syscon) {
175-
if (of_device_is_compatible(np, "syscon"))
176+
if (create_regmap)
176177
syscon = of_syscon_register(np, check_res);
177178
else
178179
syscon = ERR_PTR(-EINVAL);
@@ -233,15 +234,37 @@ int of_syscon_register_regmap(struct device_node *np, struct regmap *regmap)
233234
}
234235
EXPORT_SYMBOL_GPL(of_syscon_register_regmap);
235236

237+
/**
238+
* device_node_to_regmap() - Get or create a regmap for specified device node
239+
* @np: Device tree node
240+
*
241+
* Get a regmap for the specified device node. If there's not an existing
242+
* regmap, then one is instantiated. This function should not be used if the
243+
* device node has a custom regmap driver or has resources (clocks, resets) to
244+
* be managed. Use syscon_node_to_regmap() instead for those cases.
245+
*
246+
* Return: regmap ptr on success, negative error code on failure.
247+
*/
236248
struct regmap *device_node_to_regmap(struct device_node *np)
237249
{
238-
return device_node_get_regmap(np, false);
250+
return device_node_get_regmap(np, true, false);
239251
}
240252
EXPORT_SYMBOL_GPL(device_node_to_regmap);
241253

254+
/**
255+
* syscon_node_to_regmap() - Get or create a regmap for specified syscon device node
256+
* @np: Device tree node
257+
*
258+
* Get a regmap for the specified device node. If there's not an existing
259+
* regmap, then one is instantiated if the node is a generic "syscon". This
260+
* function is safe to use for a syscon registered with
261+
* of_syscon_register_regmap().
262+
*
263+
* Return: regmap ptr on success, negative error code on failure.
264+
*/
242265
struct regmap *syscon_node_to_regmap(struct device_node *np)
243266
{
244-
return device_node_get_regmap(np, true);
267+
return device_node_get_regmap(np, of_device_is_compatible(np, "syscon"), true);
245268
}
246269
EXPORT_SYMBOL_GPL(syscon_node_to_regmap);
247270

0 commit comments

Comments
 (0)