Skip to content

Commit

Permalink
Merge tag 'hwlock-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Linus Torvalds committed Feb 4, 2020
2 parents cc12071 + cb36017 commit 6850979
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 89 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -7378,6 +7378,7 @@ F: drivers/hwtracing/
HARDWARE SPINLOCK CORE
M: Ohad Ben-Cohen <ohad@wizery.com>
M: Bjorn Andersson <bjorn.andersson@linaro.org>
R: Baolin Wang <baolin.wang7@gmail.com>
L: linux-remoteproc@vger.kernel.org
S: Maintained
T: git git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc.git hwspinlock-next
Expand Down
32 changes: 11 additions & 21 deletions drivers/hwspinlock/omap_hwspinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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
Expand All @@ -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 */
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down
28 changes: 2 additions & 26 deletions drivers/hwspinlock/qcom_hwspinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>

#include "hwspinlock_internal.h"
Expand Down Expand Up @@ -122,35 +121,12 @@ static int qcom_hwspinlock_probe(struct platform_device *pdev)
regmap, field);
}

pm_runtime_enable(&pdev->dev);

ret = hwspin_lock_register(bank, &pdev->dev, &qcom_hwspinlock_ops,
0, QCOM_MUTEX_NUM_LOCKS);
if (ret)
pm_runtime_disable(&pdev->dev);

return ret;
}

static int qcom_hwspinlock_remove(struct platform_device *pdev)
{
struct hwspinlock_device *bank = platform_get_drvdata(pdev);
int ret;

ret = hwspin_lock_unregister(bank);
if (ret) {
dev_err(&pdev->dev, "%s failed: %d\n", __func__, ret);
return ret;
}

pm_runtime_disable(&pdev->dev);

return 0;
return devm_hwspin_lock_register(&pdev->dev, bank, &qcom_hwspinlock_ops,
0, QCOM_MUTEX_NUM_LOCKS);
}

static struct platform_driver qcom_hwspinlock_driver = {
.probe = qcom_hwspinlock_probe,
.remove = qcom_hwspinlock_remove,
.driver = {
.name = "qcom_hwspinlock",
.of_match_table = qcom_hwspinlock_of_match,
Expand Down
46 changes: 7 additions & 39 deletions drivers/hwspinlock/sirf_hwspinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <linux/module.h>
#include <linux/device.h>
#include <linux/io.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/hwspinlock.h>
Expand Down Expand Up @@ -56,7 +55,7 @@ static int sirf_hwspinlock_probe(struct platform_device *pdev)
{
struct sirf_hwspinlock *hwspin;
struct hwspinlock *hwlock;
int idx, ret;
int idx;

if (!pdev->dev.of_node)
return -ENODEV;
Expand All @@ -69,9 +68,9 @@ static int sirf_hwspinlock_probe(struct platform_device *pdev)
return -ENOMEM;

/* retrieve io base */
hwspin->io_base = of_iomap(pdev->dev.of_node, 0);
if (!hwspin->io_base)
return -ENOMEM;
hwspin->io_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(hwspin->io_base))
return PTR_ERR(hwspin->io_base);

for (idx = 0; idx < HW_SPINLOCK_NUMBER; idx++) {
hwlock = &hwspin->bank.lock[idx];
Expand All @@ -80,39 +79,9 @@ static int sirf_hwspinlock_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, hwspin);

pm_runtime_enable(&pdev->dev);

ret = hwspin_lock_register(&hwspin->bank, &pdev->dev,
&sirf_hwspinlock_ops, 0,
HW_SPINLOCK_NUMBER);
if (ret)
goto reg_failed;

return 0;

reg_failed:
pm_runtime_disable(&pdev->dev);
iounmap(hwspin->io_base);

return ret;
}

static int sirf_hwspinlock_remove(struct platform_device *pdev)
{
struct sirf_hwspinlock *hwspin = platform_get_drvdata(pdev);
int ret;

ret = hwspin_lock_unregister(&hwspin->bank);
if (ret) {
dev_err(&pdev->dev, "%s failed: %d\n", __func__, ret);
return ret;
}

pm_runtime_disable(&pdev->dev);

iounmap(hwspin->io_base);

return 0;
return devm_hwspin_lock_register(&pdev->dev, &hwspin->bank,
&sirf_hwspinlock_ops, 0,
HW_SPINLOCK_NUMBER);
}

static const struct of_device_id sirf_hwpinlock_ids[] = {
Expand All @@ -123,7 +92,6 @@ MODULE_DEVICE_TABLE(of, sirf_hwpinlock_ids);

static struct platform_driver sirf_hwspinlock_driver = {
.probe = sirf_hwspinlock_probe,
.remove = sirf_hwspinlock_remove,
.driver = {
.name = "atlas7_hwspinlock",
.of_match_table = of_match_ptr(sirf_hwpinlock_ids),
Expand Down
4 changes: 1 addition & 3 deletions drivers/hwspinlock/stm32_hwspinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ static int stm32_hwspinlock_probe(struct platform_device *pdev)
{
struct stm32_hwspinlock *hw;
void __iomem *io_base;
struct resource *res;
size_t array_size;
int i, ret;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
io_base = devm_ioremap_resource(&pdev->dev, res);
io_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(io_base))
return PTR_ERR(io_base);

Expand Down

0 comments on commit 6850979

Please sign in to comment.