Skip to content

Commit

Permalink
lib: devres: Simplify API devm_ioport_unmap() implementation
Browse files Browse the repository at this point in the history
Simplify devm_ioport_unmap() implementation by dedicated API
devres_release(), compared with current solution, namely
ioport_unmap() + devres_destroy(), devres_release() has below advantages:

- it is simpler if devm_ioport_unmap()'s parameter @addr was ever
  returned by devm_ioport_map().

- it can avoid unnecessary ioport_unmap(@addr) if @addr was not
  ever returned by devm_ioport_map().

Signed-off-by: Zijun Hu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
zijun-hu authored and gregkh committed Oct 14, 2024
1 parent 0ee4dca commit 9bd133f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/devres.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ EXPORT_SYMBOL(devm_ioport_map);
*/
void devm_ioport_unmap(struct device *dev, void __iomem *addr)
{
ioport_unmap(addr);
WARN_ON(devres_destroy(dev, devm_ioport_map_release,
WARN_ON(devres_release(dev, devm_ioport_map_release,
devm_ioport_map_match, (__force void *)addr));
}
EXPORT_SYMBOL(devm_ioport_unmap);
Expand Down

0 comments on commit 9bd133f

Please sign in to comment.