aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/linux/device.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux/device.h')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/device.h55
1 files changed, 42 insertions, 13 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h
index df6f10bd573b..7dd6340746d2 100644
--- a/sys/compat/linuxkpi/common/include/linux/device.h
+++ b/sys/compat/linuxkpi/common/include/linux/device.h
@@ -4,7 +4,7 @@
* Copyright (c) 2010 Panasas, Inc.
* Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
* All rights reserved.
- * Copyright (c) 2021-2022 The FreeBSD Foundation
+ * Copyright (c) 2021-2025 The FreeBSD Foundation
*
* Portions of this software were developed by Björn Zeeb
* under sponsorship from the FreeBSD Foundation.
@@ -29,8 +29,6 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _LINUXKPI_LINUX_DEVICE_H_
#define _LINUXKPI_LINUX_DEVICE_H_
@@ -47,6 +45,7 @@
#include <linux/backlight.h>
#include <linux/pm.h>
#include <linux/idr.h>
+#include <linux/overflow.h>
#include <linux/ratelimit.h> /* via linux/dev_printk.h */
#include <linux/fwnode.h>
#include <asm/atomic.h>
@@ -58,7 +57,6 @@ struct device;
struct class {
const char *name;
- struct module *owner;
struct kobject kobj;
devclass_t bsdclass;
const struct dev_pm_ops *pm;
@@ -83,6 +81,7 @@ struct dev_pm_ops {
int (*poweroff_late)(struct device *dev);
int (*restore)(struct device *dev);
int (*restore_early)(struct device *dev);
+ int (*suspend_noirq)(struct device *dev);
int (*runtime_suspend)(struct device *dev);
int (*runtime_resume)(struct device *dev);
int (*runtime_idle)(struct device *dev);
@@ -91,6 +90,8 @@ struct dev_pm_ops {
struct device_driver {
const char *name;
const struct dev_pm_ops *pm;
+
+ void (*shutdown) (struct device *);
};
struct device_type {
@@ -189,15 +190,17 @@ show_class_attr_string(struct class *class,
struct class_attribute_string class_attr_##_name = \
_CLASS_ATTR_STRING(_name, _mode, _str)
-#define dev_err(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
-#define dev_crit(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
-#define dev_warn(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
-#define dev_info(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
-#define dev_notice(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
-#define dev_emerg(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
-#define dev_dbg(dev, fmt, ...) do { } while (0)
#define dev_printk(lvl, dev, fmt, ...) \
- device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+ device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+
+#define dev_emerg(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+#define dev_alert(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+#define dev_crit(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+#define dev_err(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+#define dev_warn(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+#define dev_notice(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+#define dev_info(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+#define dev_dbg(dev, fmt, ...) do { } while (0)
#define dev_WARN(dev, fmt, ...) \
device_printf((dev)->bsddev, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__)
@@ -237,6 +240,14 @@ show_class_attr_string(struct class *class,
} \
} while (0)
+#define dev_dbg_once(dev, ...) do { \
+ static bool __dev_dbg_once; \
+ if (!__dev_dbg_once) { \
+ __dev_dbg_once = 1; \
+ dev_dbg(dev, __VA_ARGS__); \
+ } \
+} while (0)
+
#define dev_err_ratelimited(dev, ...) do { \
static linux_ratelimit_t __ratelimited; \
if (linux_ratelimited(&__ratelimited)) \
@@ -273,6 +284,8 @@ int lkpi_devres_destroy(struct device *, void(*release)(struct device *, void *)
void lkpi_devres_release_free_list(struct device *);
void lkpi_devres_unlink(struct device *, void *);
void lkpi_devm_kmalloc_release(struct device *, void *);
+void lkpi_devm_kfree(struct device *, const void *);
+#define devm_kfree(_d, _p) lkpi_devm_kfree(_d, _p)
static inline const char *
dev_driver_string(const struct device *dev)
@@ -320,6 +333,13 @@ dev_name(const struct device *dev)
return kobject_name(&dev->kobj);
}
+static inline bool
+dev_is_removable(struct device *dev)
+{
+
+ return (false);
+}
+
#define dev_set_name(_dev, _fmt, ...) \
kobject_set_name(&(_dev)->kobj, (_fmt), ##__VA_ARGS__)
@@ -331,7 +351,12 @@ put_device(struct device *dev)
kobject_put(&dev->kobj);
}
-struct class *class_create(struct module *owner, const char *name);
+struct class *lkpi_class_create(const char *name);
+#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 60400
+#define class_create(name) lkpi_class_create(name)
+#else
+#define class_create(owner, name) lkpi_class_create(name)
+#endif
static inline int
class_register(struct class *class)
@@ -687,4 +712,8 @@ int lkpi_devm_add_action_or_reset(struct device *dev, void (*action)(void *), vo
#define devm_add_action_or_reset(dev, action, data) \
lkpi_devm_add_action_or_reset(dev, action, data)
+int lkpi_devm_device_add_group(struct device *dev, const struct attribute_group *group);
+#define devm_device_add_group(dev, group) \
+ lkpi_devm_device_add_group(dev, group)
+
#endif /* _LINUXKPI_LINUX_DEVICE_H_ */