Skip to content

Commit f36c54f

Browse files
andy-shevakpm00
authored andcommitted
devres: switch to use dev_err_probe() for unification
Patch series "devres: A couple of cleanups". A couple of ad-hoc cleanups. No functional changes intended. This patch (of 2): The devm_*() APIs are supposed to be called during the ->probe() stage. Many drivers (especially new ones) have switched to use dev_err_probe() for error messaging for the sake of unification. Let's do the same in the devres APIs. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Philipp Stanner <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b157f0e commit f36c54f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/devres.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,13 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res,
125125
resource_size_t size;
126126
void __iomem *dest_ptr;
127127
char *pretty_name;
128+
int ret;
128129

129130
BUG_ON(!dev);
130131

131132
if (!res || resource_type(res) != IORESOURCE_MEM) {
132-
dev_err(dev, "invalid resource %pR\n", res);
133-
return IOMEM_ERR_PTR(-EINVAL);
133+
ret = dev_err_probe(dev, -EINVAL, "invalid resource %pR\n", res);
134+
return IOMEM_ERR_PTR(ret);
134135
}
135136

136137
if (type == DEVM_IOREMAP && res->flags & IORESOURCE_MEM_NONPOSTED)
@@ -144,20 +145,20 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res,
144145
else
145146
pretty_name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL);
146147
if (!pretty_name) {
147-
dev_err(dev, "can't generate pretty name for resource %pR\n", res);
148-
return IOMEM_ERR_PTR(-ENOMEM);
148+
ret = dev_err_probe(dev, -ENOMEM, "can't generate pretty name for resource %pR\n", res);
149+
return IOMEM_ERR_PTR(ret);
149150
}
150151

151152
if (!devm_request_mem_region(dev, res->start, size, pretty_name)) {
152-
dev_err(dev, "can't request region for resource %pR\n", res);
153-
return IOMEM_ERR_PTR(-EBUSY);
153+
ret = dev_err_probe(dev, -EBUSY, "can't request region for resource %pR\n", res);
154+
return IOMEM_ERR_PTR(ret);
154155
}
155156

156157
dest_ptr = __devm_ioremap(dev, res->start, size, type);
157158
if (!dest_ptr) {
158-
dev_err(dev, "ioremap failed for resource %pR\n", res);
159159
devm_release_mem_region(dev, res->start, size);
160-
dest_ptr = IOMEM_ERR_PTR(-ENOMEM);
160+
ret = dev_err_probe(dev, -ENOMEM, "ioremap failed for resource %pR\n", res);
161+
return IOMEM_ERR_PTR(ret);
161162
}
162163

163164
return dest_ptr;

0 commit comments

Comments
 (0)