@@ -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
@@ -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
@@ -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
@@ -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
@@ -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_))
@@ -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
@@ -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 */
@@ -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
@@ -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.
*/
similarity index 78%
rename from drivers/hwspinlock/hwspinlock_internal.h
rename to include/linux/hwspinlock/provider.h
@@ -7,14 +7,26 @@
* Contact: Ohad Ben-Cohen <ohad@wizery.com>
*/
-#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 */