aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwspinlock/omap_hwspinlock.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-02-04 09:04:37 +0000
committerLinus Torvalds <torvalds@linux-foundation.org>2020-02-04 09:04:37 +0000
commit685097986b5ef8b8c4b19dbb6a1d6069c3626ba2 (patch)
tree3222af0faac431c264b9c6baf4cf59020b400e5e /drivers/hwspinlock/omap_hwspinlock.c
parentMerge branch 'akpm' (patches from Andrew) (diff)
parenthwspinlock: sirf: Use devm_hwspin_lock_register() to register hwlock controller (diff)
downloadlinux-dev-685097986b5ef8b8c4b19dbb6a1d6069c3626ba2.tar.xz
linux-dev-685097986b5ef8b8c4b19dbb6a1d6069c3626ba2.zip
Merge tag 'hwlock-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc
Pull hwspinlock updates from Bjorn Andersson: "This continues the transition of drivers to device managed resources and removal of unnecessary PM runtime integration, with cleanups to the SIRF, OMAP and Qualcomm hwspinlock drivers. It also adds Baolin as reviewer in MAINTAINERS" * tag 'hwlock-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc: hwspinlock: sirf: Use devm_hwspin_lock_register() to register hwlock controller hwspinlock: sirf: Remove redundant PM runtime functions hwspinlock: sirf: Change to use devm_platform_ioremap_resource() hwspinlock: omap: Use devm_kzalloc() to allocate memory hwspinlock: omap: Change to use devm_platform_ioremap_resource() hwspinlock: qcom: Use devm_hwspin_lock_register() to register hwlock controller hwspinlock: qcom: Remove redundant PM runtime functions hwspinlock: stm32: convert to devm_platform_ioremap_resource MAINTAINERS: Add myself as reviewer for the hwspinlock subsystem
Diffstat (limited to 'drivers/hwspinlock/omap_hwspinlock.c')
-rw-r--r--drivers/hwspinlock/omap_hwspinlock.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap_hwspinlock.c
index 14e1a532ebb5..3b05560456ea 100644
--- a/drivers/hwspinlock/omap_hwspinlock.c
+++ b/drivers/hwspinlock/omap_hwspinlock.c
@@ -76,7 +76,6 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
struct device_node *node = pdev->dev.of_node;
struct hwspinlock_device *bank;
struct hwspinlock *hwlock;
- struct resource *res;
void __iomem *io_base;
int num_locks, i, ret;
/* Only a single hwspinlock block device is supported */
@@ -85,13 +84,9 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
if (!node)
return -ENODEV;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -ENODEV;
-
- io_base = ioremap(res->start, resource_size(res));
- if (!io_base)
- return -ENOMEM;
+ io_base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(io_base))
+ return PTR_ERR(io_base);
/*
* make sure the module is enabled and clocked before reading
@@ -101,7 +96,7 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
ret = pm_runtime_get_sync(&pdev->dev);
if (ret < 0) {
pm_runtime_put_noidle(&pdev->dev);
- goto iounmap_base;
+ goto runtime_err;
}
/* Determine number of locks */
@@ -114,20 +109,21 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
*/
ret = pm_runtime_put(&pdev->dev);
if (ret < 0)
- goto iounmap_base;
+ goto runtime_err;
/* one of the four lsb's must be set, and nothing else */
if (hweight_long(i & 0xf) != 1 || i > 8) {
ret = -EINVAL;
- goto iounmap_base;
+ goto runtime_err;
}
num_locks = i * 32; /* actual number of locks in this device */
- bank = kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL);
+ bank = devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks),
+ GFP_KERNEL);
if (!bank) {
ret = -ENOMEM;
- goto iounmap_base;
+ goto runtime_err;
}
platform_set_drvdata(pdev, bank);
@@ -138,25 +134,21 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
ret = hwspin_lock_register(bank, &pdev->dev, &omap_hwspinlock_ops,
base_id, num_locks);
if (ret)
- goto reg_fail;
+ goto runtime_err;
dev_dbg(&pdev->dev, "Registered %d locks with HwSpinlock core\n",
num_locks);
return 0;
-reg_fail:
- kfree(bank);
-iounmap_base:
+runtime_err:
pm_runtime_disable(&pdev->dev);
- iounmap(io_base);
return ret;
}
static int omap_hwspinlock_remove(struct platform_device *pdev)
{
struct hwspinlock_device *bank = platform_get_drvdata(pdev);
- void __iomem *io_base = bank->lock[0].priv - LOCK_BASE_OFFSET;
int ret;
ret = hwspin_lock_unregister(bank);
@@ -166,8 +158,6 @@ static int omap_hwspinlock_remove(struct platform_device *pdev)
}
pm_runtime_disable(&pdev->dev);
- iounmap(io_base);
- kfree(bank);
return 0;
}