mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
hwspinlock: omap: Change to use devm_platform_ioremap_resource()
Use the new helper that wraps the calls to platform_get_resource() and devm_ioremap_resource() together, which can simpify the code. Meanwhile renaming the error label to make more sense after removing iounmap(). Signed-off-by: Baolin Wang <baolin.wang7@gmail.com> Link: https://lore.kernel.org/r/6c09c5034a7e68fdfc22d2cb5daa375bccb33a66.1578453062.git.baolin.wang7@gmail.com Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
parent
ed0611a604
commit
bf2740068a
1 changed files with 8 additions and 16 deletions
|
@ -76,7 +76,6 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
|
||||||
struct device_node *node = pdev->dev.of_node;
|
struct device_node *node = pdev->dev.of_node;
|
||||||
struct hwspinlock_device *bank;
|
struct hwspinlock_device *bank;
|
||||||
struct hwspinlock *hwlock;
|
struct hwspinlock *hwlock;
|
||||||
struct resource *res;
|
|
||||||
void __iomem *io_base;
|
void __iomem *io_base;
|
||||||
int num_locks, i, ret;
|
int num_locks, i, ret;
|
||||||
/* Only a single hwspinlock block device is supported */
|
/* Only a single hwspinlock block device is supported */
|
||||||
|
@ -85,13 +84,9 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
|
||||||
if (!node)
|
if (!node)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
io_base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
if (!res)
|
if (IS_ERR(io_base))
|
||||||
return -ENODEV;
|
return PTR_ERR(io_base);
|
||||||
|
|
||||||
io_base = ioremap(res->start, resource_size(res));
|
|
||||||
if (!io_base)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* make sure the module is enabled and clocked before reading
|
* 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);
|
ret = pm_runtime_get_sync(&pdev->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
pm_runtime_put_noidle(&pdev->dev);
|
pm_runtime_put_noidle(&pdev->dev);
|
||||||
goto iounmap_base;
|
goto runtime_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine number of locks */
|
/* Determine number of locks */
|
||||||
|
@ -114,12 +109,12 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
|
||||||
*/
|
*/
|
||||||
ret = pm_runtime_put(&pdev->dev);
|
ret = pm_runtime_put(&pdev->dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto iounmap_base;
|
goto runtime_err;
|
||||||
|
|
||||||
/* one of the four lsb's must be set, and nothing else */
|
/* one of the four lsb's must be set, and nothing else */
|
||||||
if (hweight_long(i & 0xf) != 1 || i > 8) {
|
if (hweight_long(i & 0xf) != 1 || i > 8) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto iounmap_base;
|
goto runtime_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_locks = i * 32; /* actual number of locks in this device */
|
num_locks = i * 32; /* actual number of locks in this device */
|
||||||
|
@ -127,7 +122,7 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
|
||||||
bank = kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL);
|
bank = kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL);
|
||||||
if (!bank) {
|
if (!bank) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto iounmap_base;
|
goto runtime_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, bank);
|
platform_set_drvdata(pdev, bank);
|
||||||
|
@ -147,16 +142,14 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
reg_fail:
|
reg_fail:
|
||||||
kfree(bank);
|
kfree(bank);
|
||||||
iounmap_base:
|
runtime_err:
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
iounmap(io_base);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int omap_hwspinlock_remove(struct platform_device *pdev)
|
static int omap_hwspinlock_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct hwspinlock_device *bank = platform_get_drvdata(pdev);
|
struct hwspinlock_device *bank = platform_get_drvdata(pdev);
|
||||||
void __iomem *io_base = bank->lock[0].priv - LOCK_BASE_OFFSET;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = hwspin_lock_unregister(bank);
|
ret = hwspin_lock_unregister(bank);
|
||||||
|
@ -166,7 +159,6 @@ static int omap_hwspinlock_remove(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
iounmap(io_base);
|
|
||||||
kfree(bank);
|
kfree(bank);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue