Skip to content

Commit 60a1d45

Browse files
robherringfrank-w
authored andcommitted
mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
Commit ba5095e ("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: ba5095e ("mfd: syscon: Allow syscon nodes without a "syscon" compatible") Cc: Will McVicker <[email protected]> Cc: John Madieu <[email protected]> Cc: Nishanth Menon <[email protected]> Reported-by: Vaishnav Achath <[email protected]> Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent 8be1d95 commit 60a1d45

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

drivers/mfd/syscon.c

+26-3
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)