The ultimate goal is to allow hwspinlock drivers outside of the hwspinlock directory. So, the public and the internal header get refactored into a more modern public provider/consumer pair. This patch creates the provider header. It is a plain move without functional changes. Only a now obsolete comment gets removed which explained why some functions do not have fallbacks if hwspinlock is not seleceted. All acutal providers are converted as well.
Signed-off-by: Wolfram Sang <[email protected]> --- MAINTAINERS | 1 + drivers/hwspinlock/hwspinlock_core.c | 3 +- drivers/hwspinlock/omap_hwspinlock.c | 4 +- drivers/hwspinlock/qcom_hwspinlock.c | 4 +- drivers/hwspinlock/sprd_hwspinlock.c | 4 +- drivers/hwspinlock/stm32_hwspinlock.c | 4 +- drivers/hwspinlock/sun6i_hwspinlock.c | 4 +- drivers/hwspinlock/u8500_hsem.c | 3 +- include/linux/hwspinlock.h | 14 ------- .../linux/hwspinlock/provider.h | 40 ++++++++++++------- 10 files changed, 33 insertions(+), 48 deletions(-) rename drivers/hwspinlock/hwspinlock_internal.h => include/linux/hwspinlock/provider.h (78%) diff --git a/MAINTAINERS b/MAINTAINERS index a56f8f00aebb..18f4991044ee 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11187,6 +11187,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc.git hw F: Documentation/devicetree/bindings/hwlock/ F: Documentation/locking/hwspinlock.rst F: drivers/hwspinlock/ +F: include/linux/hwspinlock/ F: include/linux/hwspinlock.h HARDWARE TRACING FACILITIES diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c index cc8e952a6772..3ee4f4357e01 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -18,12 +18,11 @@ #include <linux/jiffies.h> #include <linux/radix-tree.h> #include <linux/hwspinlock.h> +#include <linux/hwspinlock/provider.h> #include <linux/pm_runtime.h> #include <linux/mutex.h> #include <linux/of.h> -#include "hwspinlock_internal.h" - /* retry delay used in atomic context */ #define HWSPINLOCK_RETRY_DELAY_US 100 diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap_hwspinlock.c index 1832e0c3af6b..e2a8fe4ad96a 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -19,12 +19,10 @@ #include <linux/pm_runtime.h> #include <linux/slab.h> #include <linux/spinlock.h> -#include <linux/hwspinlock.h> +#include <linux/hwspinlock/provider.h> #include <linux/of.h> #include <linux/platform_device.h> -#include "hwspinlock_internal.h" - /* Spinlock register offsets */ #define SYSSTATUS_OFFSET 0x0014 #define LOCK_BASE_OFFSET 0x0800 diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c index 0390979fd765..1b5a0c2fadee 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -4,7 +4,7 @@ * Copyright (c) 2015, Sony Mobile Communications AB */ -#include <linux/hwspinlock.h> +#include <linux/hwspinlock/provider.h> #include <linux/io.h> #include <linux/kernel.h> #include <linux/mfd/syscon.h> @@ -14,8 +14,6 @@ #include <linux/platform_device.h> #include <linux/regmap.h> -#include "hwspinlock_internal.h" - #define QCOM_MUTEX_APPS_PROC_ID 1 #define QCOM_MUTEX_NUM_LOCKS 32 diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd_hwspinlock.c index 22e2ffb91743..62de2a551cee 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -7,7 +7,7 @@ #include <linux/clk.h> #include <linux/delay.h> #include <linux/device.h> -#include <linux/hwspinlock.h> +#include <linux/hwspinlock/provider.h> #include <linux/io.h> #include <linux/kernel.h> #include <linux/module.h> @@ -15,8 +15,6 @@ #include <linux/of_device.h> #include <linux/platform_device.h> -#include "hwspinlock_internal.h" - /* hwspinlock registers definition */ #define HWSPINLOCK_RECCTRL 0x4 #define HWSPINLOCK_MASTERID(_X_) (0x80 + 0x4 * (_X_)) diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm32_hwspinlock.c index bb5c7e5f7a80..7af8e4cc564c 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -6,7 +6,7 @@ #include <linux/clk.h> #include <linux/delay.h> -#include <linux/hwspinlock.h> +#include <linux/hwspinlock/provider.h> #include <linux/io.h> #include <linux/kernel.h> #include <linux/module.h> @@ -14,8 +14,6 @@ #include <linux/platform_device.h> #include <linux/pm_runtime.h> -#include "hwspinlock_internal.h" - #define STM32_MUTEX_COREID BIT(8) #define STM32_MUTEX_LOCK_BIT BIT(31) #define STM32_MUTEX_NUM_LOCKS 32 diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun6i_hwspinlock.c index c2d314588046..3c8c067e6312 100644 --- a/drivers/hwspinlock/sun6i_hwspinlock.c +++ b/drivers/hwspinlock/sun6i_hwspinlock.c @@ -7,7 +7,7 @@ #include <linux/clk.h> #include <linux/debugfs.h> #include <linux/errno.h> -#include <linux/hwspinlock.h> +#include <linux/hwspinlock/provider.h> #include <linux/io.h> #include <linux/module.h> #include <linux/of.h> @@ -17,8 +17,6 @@ #include <linux/spinlock.h> #include <linux/types.h> -#include "hwspinlock_internal.h" - #define DRIVER_NAME "sun6i_hwspinlock" #define SPINLOCK_BASE_ID 0 /* there is only one hwspinlock device per SoC */ diff --git a/drivers/hwspinlock/u8500_hsem.c b/drivers/hwspinlock/u8500_hsem.c index 5a2d8c3e0d80..ff0730613929 100644 --- a/drivers/hwspinlock/u8500_hsem.c +++ b/drivers/hwspinlock/u8500_hsem.c @@ -19,10 +19,9 @@ #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/hwspinlock.h> +#include <linux/hwspinlock/provider.h> #include <linux/platform_device.h> -#include "hwspinlock_internal.h" - /* * Implementation of STE's HSem protocol 1 without interrutps. * The only masterID we allow is '0x01' to force people to use diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index f35b42e8c5de..7f38960c7162 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -55,9 +55,6 @@ struct hwspinlock_pdata { #ifdef CONFIG_HWSPINLOCK -int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev, - const struct hwspinlock_ops *ops, int base_id, int num_locks); -int hwspin_lock_unregister(struct hwspinlock_device *bank); struct hwspinlock *hwspin_lock_request_specific(unsigned int id); int hwspin_lock_free(struct hwspinlock *hwlock); int of_hwspin_lock_get_id(struct device_node *np, int index); @@ -70,13 +67,6 @@ int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id); int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock); struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, unsigned int id); -int devm_hwspin_lock_unregister(struct device *dev, - struct hwspinlock_device *bank); -int devm_hwspin_lock_register(struct device *dev, - struct hwspinlock_device *bank, - const struct hwspinlock_ops *ops, - int base_id, int num_locks); - #else /* !CONFIG_HWSPINLOCK */ /* @@ -85,10 +75,6 @@ int devm_hwspin_lock_register(struct device *dev, * code path get compiled away. This way, if CONFIG_HWSPINLOCK is not * required on a given setup, users will still work. * - * The only exception is hwspin_lock_register/hwspin_lock_unregister, with which - * we _do_ want users to fail (no point in registering hwspinlock instances if - * the framework is not available). - * * Note: ERR_PTR(-ENODEV) will still be considered a success for NULL-checking * users. Others, which care, can still check this with IS_ERR. */ diff --git a/drivers/hwspinlock/hwspinlock_internal.h b/include/linux/hwspinlock/provider.h similarity index 78% rename from drivers/hwspinlock/hwspinlock_internal.h rename to include/linux/hwspinlock/provider.h index f298fc0ee5ad..d53bbacec744 100644 --- a/drivers/hwspinlock/hwspinlock_internal.h +++ b/include/linux/hwspinlock/provider.h @@ -7,14 +7,26 @@ * Contact: Ohad Ben-Cohen <[email protected]> */ -#ifndef __HWSPINLOCK_HWSPINLOCK_H -#define __HWSPINLOCK_HWSPINLOCK_H +#ifndef __LINUX_HWSPINLOCK_PROVIDER_H +#define __LINUX_HWSPINLOCK_PROVIDER_H #include <linux/spinlock.h> #include <linux/device.h> struct hwspinlock_device; +/** + * struct hwspinlock - this struct represents a single hwspinlock instance + * @bank: the hwspinlock_device structure which owns this lock + * @lock: initialized and used by hwspinlock core + * @priv: private data, owned by the underlying platform-specific hwspinlock drv + */ +struct hwspinlock { + struct hwspinlock_device *bank; + spinlock_t lock; + void *priv; +}; + /** * struct hwspinlock_ops - platform-specific hwspinlock handlers * @@ -34,18 +46,6 @@ struct hwspinlock_ops { void (*relax)(struct hwspinlock *lock); }; -/** - * struct hwspinlock - this struct represents a single hwspinlock instance - * @bank: the hwspinlock_device structure which owns this lock - * @lock: initialized and used by hwspinlock core - * @priv: private data, owned by the underlying platform-specific hwspinlock drv - */ -struct hwspinlock { - struct hwspinlock_device *bank; - spinlock_t lock; - void *priv; -}; - /** * struct hwspinlock_device - a device which usually spans numerous hwspinlocks * @dev: underlying device, will be used to invoke runtime PM api @@ -69,4 +69,14 @@ static inline int hwlock_to_id(struct hwspinlock *hwlock) return hwlock->bank->base_id + local_id; } -#endif /* __HWSPINLOCK_HWSPINLOCK_H */ +int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev, + const struct hwspinlock_ops *ops, int base_id, int num_locks); +int hwspin_lock_unregister(struct hwspinlock_device *bank); +int devm_hwspin_lock_register(struct device *dev, + struct hwspinlock_device *bank, + const struct hwspinlock_ops *ops, + int base_id, int num_locks); +int devm_hwspin_lock_unregister(struct device *dev, + struct hwspinlock_device *bank); + +#endif /* __LINUX_HWSPINLOCK_PROVIDER_H */ -- 2.47.3
