Skip to content

Commit b313403

Browse files
Uwe Kleine-KönigLi Yang
authored andcommitted
bus: fsl-mc: fsl-mc-allocator: Improve error reporting
Instead of silently returning an error in the remove callback (which yields a generic and little informing error message), annotate each error path of fsl_mc_resource_pool_remove_device() with an error message and return zero in the remove callback to suppress the error message. Note that changing the return value has no other effect than suppressing the error message by the fsl_mc bus driver. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com> Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com> # sanity checks Reviewed-by: Laurentiu Tudor <laurentiu.tudor@nxp.com> Tested-by: Laurentiu Tudor <laurentiu.tudor@nxp.com> Signed-off-by: Li Yang <leoyang.li@nxp.com>
1 parent e0ac893 commit b313403

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

drivers/bus/fsl-mc/fsl-mc-allocator.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,30 @@ static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device
104104
int error = -EINVAL;
105105

106106
resource = mc_dev->resource;
107-
if (!resource || resource->data != mc_dev)
107+
if (!resource || resource->data != mc_dev) {
108+
dev_err(&mc_bus_dev->dev, "resource mismatch\n");
108109
goto out;
110+
}
109111

110112
mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
111113
mc_bus = to_fsl_mc_bus(mc_bus_dev);
112114
res_pool = resource->parent_pool;
113-
if (res_pool != &mc_bus->resource_pools[resource->type])
115+
if (res_pool != &mc_bus->resource_pools[resource->type]) {
116+
dev_err(&mc_bus_dev->dev, "pool mismatch\n");
114117
goto out;
118+
}
115119

116120
mutex_lock(&res_pool->mutex);
117121

118-
if (res_pool->max_count <= 0)
122+
if (res_pool->max_count <= 0) {
123+
dev_err(&mc_bus_dev->dev, "max_count underflow\n");
119124
goto out_unlock;
125+
}
120126
if (res_pool->free_count <= 0 ||
121-
res_pool->free_count > res_pool->max_count)
127+
res_pool->free_count > res_pool->max_count) {
128+
dev_err(&mc_bus_dev->dev, "free_count mismatch\n");
122129
goto out_unlock;
130+
}
123131

124132
/*
125133
* If the device is currently allocated, its resource is not
@@ -613,7 +621,7 @@ static int fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev)
613621
if (mc_dev->resource) {
614622
error = fsl_mc_resource_pool_remove_device(mc_dev);
615623
if (error < 0)
616-
return error;
624+
return 0;
617625
}
618626

619627
dev_dbg(&mc_dev->dev,

0 commit comments

Comments
 (0)