Hi Max,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20240131]
[cannot apply to mkp-scsi/for-next jejb-scsi/for-next axboe-block/for-next linus/master v6.8-rc2 v6.8-rc1 v6.7 v6.8-rc2]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Max-Kellermann/include-add-missing-includes/20240131-231042
base: next-20240131
patch link: https://lore.kernel.org/r/20240131145008.1345531-17-max.kellermann%40ionos.com
patch subject: [PATCH 16/28] device.h: move declarations to device_types.h
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240203/202402030708.WgadrfjA-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240203/202402030708.WgadrfjA-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402030708.WgadrfjA-lkp@intel.com/
All warnings (new ones prefixed by >>):
| ^~~~~
mm/slub.c:6327:14: error: 'slabs' undeclared here (not in a function); did you mean 'slab'?
6327 | SLAB_ATTR_RO(slabs);
| ^~~~~
mm/slub.c:6132:68: note: in definition of macro 'SLAB_ATTR_RO'
6132 | static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
| ^~~~~
mm/slub.c:6333:14: error: 'total_objects' undeclared here (not in a function); did you mean 'oo_objects'?
6333 | SLAB_ATTR_RO(total_objects);
| ^~~~~~~~~~~~~
mm/slub.c:6132:68: note: in definition of macro 'SLAB_ATTR_RO'
6132 | static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
| ^~~~~
mm/slub.c:6339:14: error: 'objects' undeclared here (not in a function); did you mean 'kobject'?
6339 | SLAB_ATTR_RO(objects);
| ^~~~~~~
mm/slub.c:6132:68: note: in definition of macro 'SLAB_ATTR_RO'
6132 | static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
| ^~~~~
mm/slub.c:6345:14: error: 'sanity_checks' undeclared here (not in a function); did you mean 'sanity_checks_attr'?
6345 | SLAB_ATTR_RO(sanity_checks);
| ^~~~~~~~~~~~~
mm/slub.c:6132:68: note: in definition of macro 'SLAB_ATTR_RO'
6132 | static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
| ^~~~~
mm/slub.c:6132:53: error: invalid initializer
6132 | static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
| ^~~~~~~~~~~~~~
mm/slub.c:6351:1: note: in expansion of macro 'SLAB_ATTR_RO'
6351 | SLAB_ATTR_RO(trace);
| ^~~~~~~~~~~~
mm/slub.c:6358:14: error: 'red_zone' undeclared here (not in a function)
6358 | SLAB_ATTR_RO(red_zone);
| ^~~~~~~~
mm/slub.c:6132:68: note: in definition of macro 'SLAB_ATTR_RO'
6132 | static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
| ^~~~~
mm/slub.c:6365:14: error: 'poison' undeclared here (not in a function)
6365 | SLAB_ATTR_RO(poison);
| ^~~~~~
mm/slub.c:6132:68: note: in definition of macro 'SLAB_ATTR_RO'
6132 | static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
| ^~~~~
mm/slub.c:6372:14: error: 'store_user' undeclared here (not in a function); did you mean 'pte_user'?
6372 | SLAB_ATTR_RO(store_user);
| ^~~~~~~~~~
mm/slub.c:6132:68: note: in definition of macro 'SLAB_ATTR_RO'
6132 | static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
| ^~~~~
mm/slub.c:6391:11: error: 'validate' undeclared here (not in a function); did you mean 'key_validate'?
6391 | SLAB_ATTR(validate);
| ^~~~~~~~
mm/slub.c:6135:68: note: in definition of macro 'SLAB_ATTR'
6135 | static struct slab_attribute _name##_attr = __ATTR_RW_MODE(_name, 0600)
| ^~~~~
mm/slub.c:6431:11: error: 'shrink' undeclared here (not in a function); did you mean 'shrinker'?
6431 | SLAB_ATTR(shrink);
| ^~~~~~
mm/slub.c:6135:68: note: in definition of macro 'SLAB_ATTR'
6135 | static struct slab_attribute _name##_attr = __ATTR_RW_MODE(_name, 0600)
| ^~~~~
mm/slub.c:6455:11: error: 'remote_node_defrag_ratio' undeclared here (not in a function); did you mean 'remote_node_defrag_ratio_attr'?
6455 | SLAB_ATTR(remote_node_defrag_ratio);
| ^~~~~~~~~~~~~~~~~~~~~~~~
mm/slub.c:6135:68: note: in definition of macro 'SLAB_ATTR'
6135 | static struct slab_attribute _name##_attr = __ATTR_RW_MODE(_name, 0600)
| ^~~~~
mm/slub.c:6682:21: error: variable 'slab_sysfs_ops' has initializer but incomplete type
6682 | static const struct sysfs_ops slab_sysfs_ops = {
| ^~~~~~~~~
mm/slub.c:6683:10: error: 'const struct sysfs_ops' has no member named 'show'
6683 | .show = slab_attr_show,
| ^~~~
mm/slub.c:6683:17: warning: excess elements in struct initializer
6683 | .show = slab_attr_show,
| ^~~~~~~~~~~~~~
mm/slub.c:6683:17: note: (near initialization for 'slab_sysfs_ops')
mm/slub.c:6684:10: error: 'const struct sysfs_ops' has no member named 'store'
6684 | .store = slab_attr_store,
| ^~~~~
mm/slub.c:6684:18: warning: excess elements in struct initializer
6684 | .store = slab_attr_store,
| ^~~~~~~~~~~~~~~
mm/slub.c:6684:18: note: (near initialization for 'slab_sysfs_ops')
mm/slub.c: In function 'sysfs_slab_add':
mm/slub.c:6760:17: error: implicit declaration of function 'sysfs_remove_link' [-Werror=implicit-function-declaration]
6760 | sysfs_remove_link(&slab_kset->kobj, s->name);
| ^~~~~~~~~~~~~~~~~
mm/slub.c:6777:15: error: implicit declaration of function 'sysfs_create_group' [-Werror=implicit-function-declaration]
6777 | err = sysfs_create_group(&s->kobj, &slab_attr_group);
| ^~~~~~~~~~~~~~~~~~
mm/slub.c: In function 'sysfs_slab_alias':
mm/slub.c:6827:24: error: implicit declaration of function 'sysfs_create_link'; did you mean 'kernfs_create_link'? [-Werror=implicit-function-declaration]
6827 | return sysfs_create_link(&slab_kset->kobj, &s->kobj, name);
| ^~~~~~~~~~~~~~~~~
| kernfs_create_link
mm/slub.c: At top level:
mm/slub.c:6682:31: error: storage size of 'slab_sysfs_ops' isn't known
6682 | static const struct sysfs_ops slab_sysfs_ops = {
| ^~~~~~~~~~~~~~
>> mm/slub.c:6439:16: warning: 'remote_node_defrag_ratio_store' defined but not used [-Wunused-function]
6439 | static ssize_t remote_node_defrag_ratio_store(struct kmem_cache *s,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> mm/slub.c:6434:16: warning: 'remote_node_defrag_ratio_show' defined but not used [-Wunused-function]
6434 | static ssize_t remote_node_defrag_ratio_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/slub.c:6422:16: warning: 'shrink_store' defined but not used [-Wunused-function]
6422 | static ssize_t shrink_store(struct kmem_cache *s,
| ^~~~~~~~~~~~
mm/slub.c:6417:16: warning: 'shrink_show' defined but not used [-Wunused-function]
6417 | static ssize_t shrink_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~
mm/slub.c:6379:16: warning: 'validate_store' defined but not used [-Wunused-function]
6379 | static ssize_t validate_store(struct kmem_cache *s,
| ^~~~~~~~~~~~~~
mm/slub.c:6374:16: warning: 'validate_show' defined but not used [-Wunused-function]
6374 | static ssize_t validate_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~
mm/slub.c:6367:16: warning: 'store_user_show' defined but not used [-Wunused-function]
6367 | static ssize_t store_user_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~
mm/slub.c:6360:16: warning: 'poison_show' defined but not used [-Wunused-function]
6360 | static ssize_t poison_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~
mm/slub.c:6353:16: warning: 'red_zone_show' defined but not used [-Wunused-function]
6353 | static ssize_t red_zone_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~
mm/slub.c:6347:16: warning: 'trace_show' defined but not used [-Wunused-function]
6347 | static ssize_t trace_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~
mm/slub.c:6341:16: warning: 'sanity_checks_show' defined but not used [-Wunused-function]
6341 | static ssize_t sanity_checks_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~~~
mm/slub.c:6335:16: warning: 'objects_show' defined but not used [-Wunused-function]
6335 | static ssize_t objects_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~
mm/slub.c:6329:16: warning: 'total_objects_show' defined but not used [-Wunused-function]
6329 | static ssize_t total_objects_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~~~
mm/slub.c:6323:16: warning: 'slabs_show' defined but not used [-Wunused-function]
6323 | static ssize_t slabs_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~
mm/slub.c:6316:16: warning: 'destroy_by_rcu_show' defined but not used [-Wunused-function]
6316 | static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~~~~
mm/slub.c:6301:16: warning: 'cache_dma_show' defined but not used [-Wunused-function]
6301 | static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~
mm/slub.c:6294:16: warning: 'hwcache_align_show' defined but not used [-Wunused-function]
6294 | static ssize_t hwcache_align_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~~~
mm/slub.c:6288:16: warning: 'reclaim_account_show' defined but not used [-Wunused-function]
6288 | static ssize_t reclaim_account_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~~~~~
mm/slub.c:6247:16: warning: 'slabs_cpu_partial_show' defined but not used [-Wunused-function]
6247 | static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~~~~~~~
mm/slub.c:6241:16: warning: 'objects_partial_show' defined but not used [-Wunused-function]
6241 | static ssize_t objects_partial_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~~~~~
mm/slub.c:6235:16: warning: 'cpu_slabs_show' defined but not used [-Wunused-function]
6235 | static ssize_t cpu_slabs_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~
mm/slub.c:6229:16: warning: 'partial_show' defined but not used [-Wunused-function]
6229 | static ssize_t partial_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~
mm/slub.c:6223:16: warning: 'aliases_show' defined but not used [-Wunused-function]
6223 | static ssize_t aliases_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~
mm/slub.c:6215:16: warning: 'ctor_show' defined but not used [-Wunused-function]
6215 | static ssize_t ctor_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~
mm/slub.c:6197:16: warning: 'cpu_partial_store' defined but not used [-Wunused-function]
6197 | static ssize_t cpu_partial_store(struct kmem_cache *s, const char *buf,
| ^~~~~~~~~~~~~~~~~
mm/slub.c:6187:16: warning: 'cpu_partial_show' defined but not used [-Wunused-function]
6187 | static ssize_t cpu_partial_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~
mm/slub.c:6172:16: warning: 'min_partial_store' defined but not used [-Wunused-function]
6172 | static ssize_t min_partial_store(struct kmem_cache *s, const char *buf,
| ^~~~~~~~~~~~~~~~~
mm/slub.c:6167:16: warning: 'min_partial_show' defined but not used [-Wunused-function]
6167 | static ssize_t min_partial_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~
mm/slub.c:6161:16: warning: 'order_show' defined but not used [-Wunused-function]
6161 | static ssize_t order_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~
mm/slub.c:6155:16: warning: 'objs_per_slab_show' defined but not used [-Wunused-function]
6155 | static ssize_t objs_per_slab_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~~~
mm/slub.c:6149:16: warning: 'object_size_show' defined but not used [-Wunused-function]
6149 | static ssize_t object_size_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~~~
mm/slub.c:6143:16: warning: 'align_show' defined but not used [-Wunused-function]
6143 | static ssize_t align_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~
mm/slub.c:6137:16: warning: 'slab_size_show' defined but not used [-Wunused-function]
6137 | static ssize_t slab_size_show(struct kmem_cache *s, char *buf)
| ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/remote_node_defrag_ratio_store +6439 mm/slub.c
2086d26a05a4b5 Christoph Lameter 2007-05-06 6432
81819f0fc8285a Christoph Lameter 2007-05-06 6433 #ifdef CONFIG_NUMA
9824601ead957a Christoph Lameter 2008-01-07 @6434 static ssize_t remote_node_defrag_ratio_show(struct kmem_cache *s, char *buf)
81819f0fc8285a Christoph Lameter 2007-05-06 6435 {
bf16d19aabd8f5 Joe Perches 2020-12-14 6436 return sysfs_emit(buf, "%u\n", s->remote_node_defrag_ratio / 10);
81819f0fc8285a Christoph Lameter 2007-05-06 6437 }
81819f0fc8285a Christoph Lameter 2007-05-06 6438
9824601ead957a Christoph Lameter 2008-01-07 @6439 static ssize_t remote_node_defrag_ratio_store(struct kmem_cache *s,
81819f0fc8285a Christoph Lameter 2007-05-06 6440 const char *buf, size_t length)
81819f0fc8285a Christoph Lameter 2007-05-06 6441 {
eb7235eb842043 Alexey Dobriyan 2018-04-05 6442 unsigned int ratio;
0121c619d03820 Christoph Lameter 2008-04-29 6443 int err;
0121c619d03820 Christoph Lameter 2008-04-29 6444
eb7235eb842043 Alexey Dobriyan 2018-04-05 6445 err = kstrtouint(buf, 10, &ratio);
0121c619d03820 Christoph Lameter 2008-04-29 6446 if (err)
0121c619d03820 Christoph Lameter 2008-04-29 6447 return err;
eb7235eb842043 Alexey Dobriyan 2018-04-05 6448 if (ratio > 100)
eb7235eb842043 Alexey Dobriyan 2018-04-05 6449 return -ERANGE;
0121c619d03820 Christoph Lameter 2008-04-29 6450
0121c619d03820 Christoph Lameter 2008-04-29 6451 s->remote_node_defrag_ratio = ratio * 10;
81819f0fc8285a Christoph Lameter 2007-05-06 6452
81819f0fc8285a Christoph Lameter 2007-05-06 6453 return length;
81819f0fc8285a Christoph Lameter 2007-05-06 6454 }
9824601ead957a Christoph Lameter 2008-01-07 6455 SLAB_ATTR(remote_node_defrag_ratio);
81819f0fc8285a Christoph Lameter 2007-05-06 6456 #endif
81819f0fc8285a Christoph Lameter 2007-05-06 6457
@@ -5,6 +5,7 @@
#include <linux/export.h>
#include <linux/moduleparam.h>
#include <linux/blkdev.h>
+#include <linux/device.h>
#include <linux/kobject.h>
#include "blk.h"
@@ -5,6 +5,7 @@
*/
#include <linux/blkdev.h>
#include <linux/ctype.h>
+#include <linux/device.h>
struct uuidcmp {
const char *uuid;
@@ -9,6 +9,7 @@
#include <linux/major.h>
#include <linux/slab.h>
#include <linux/ctype.h>
+#include <linux/device.h>
#include <linux/vmalloc.h>
#include <linux/raid/detect.h>
#include "check.h"
@@ -5,6 +5,7 @@
*/
#include <linux/cdev.h>
#include <linux/counter.h>
+#include <linux/device.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/export.h>
@@ -7,6 +7,7 @@
#include <linux/libnvdimm.h>
#include <linux/bitfield.h>
#include <linux/bitops.h>
+#include <linux/device_types.h>
#include <linux/device/driver.h>
#include <linux/log2.h>
#include <linux/node.h>
@@ -9,6 +9,7 @@
*/
#include <linux/devfreq-event.h>
+#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/init.h>
@@ -2,7 +2,7 @@
#ifndef __LINUX_EXTCON_INTERNAL_H__
#define __LINUX_EXTCON_INTERNAL_H__
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/extcon-provider.h>
/**
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/clk-provider.h>
+#include <linux/device.h> // for devm_kzalloc()
#include <linux/io.h>
#include <linux/regulator/consumer.h>
@@ -7,6 +7,7 @@
* Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
*/
+#include <linux/device.h> // for dev_dbg()
#include <linux/export.h>
#include <linux/of.h>
@@ -13,6 +13,8 @@
#include <drm/drm_probe_helper.h>
#include <drm/drm_writeback.h>
+#include <linux/device.h> // for dev_dbg()
+
#include "rcar_du_crtc.h"
#include "rcar_du_drv.h"
#include "rcar_du_kms.h"
@@ -11,6 +11,8 @@
#include <drm/drm_blend.h>
#include <drm/drm_gem_atomic_helper.h>
+#include <linux/device.h> // for devm_kzalloc()
+
#include "sun4i_backend.h"
#include "sun4i_frontend.h"
#include "sun4i_layer.h"
@@ -7,6 +7,7 @@
*/
#include <linux/clk-provider.h>
+#include <linux/device.h> // for devm_kzalloc()
#include <linux/regmap.h>
#include "sun4i_tcon.h"
@@ -4,6 +4,7 @@
* Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
*/
+#include <linux/device.h> // for dev_dbg()
#include <linux/export.h>
#include <drm/drm_atomic_helper.h>
@@ -11,6 +11,7 @@
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_atomic_helper.h>
+#include <linux/device.h> // for dev_dbg()
#include "tidss_crtc.h"
#include "tidss_dispc.h"
@@ -11,7 +11,7 @@
#include <linux/errno.h>
#include <linux/ioport.h> /* for struct resource */
#include <linux/resource_ext.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
#include <linux/uuid.h>
@@ -9,7 +9,7 @@
#ifndef _LINUX_BACKLIGHT_H
#define _LINUX_BACKLIGHT_H
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/fb.h>
#include <linux/mutex.h>
#include <linux/notifier.h>
@@ -8,7 +8,7 @@
#include <linux/types.h>
#include <linux/bvec_types.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/ktime.h>
struct bio_set;
@@ -8,7 +8,7 @@
#include <linux/types.h>
#include <linux/fs.h> // for inode_unhashed()
#include <linux/blk_types.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/list.h>
#include <linux/minmax.h>
#include <linux/timer_types.h>
@@ -9,7 +9,7 @@
#ifndef _LINUX_CONTAINER_H
#define _LINUX_CONTAINER_H
-#include <linux/device.h>
+#include <linux/device_types.h>
/* drivers/base/power/container.c */
extern const struct bus_type container_subsys;
@@ -8,7 +8,7 @@
#include <linux/amba/bus.h>
#include <linux/clk.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/io.h>
#include <linux/perf_event.h>
#include <linux/sched.h>
@@ -7,7 +7,7 @@
#define _COUNTER_H_
#include <linux/cdev.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/kernel.h>
#include <linux/kfifo.h>
#include <linux/mutex_types.h>
@@ -9,7 +9,7 @@
#ifndef __LINUX_DEVFREQ_EVENT_H__
#define __LINUX_DEVFREQ_EVENT_H__
-#include <linux/device.h>
+#include <linux/device_types.h>
/**
* struct devfreq_event_dev - the devfreq-event device
@@ -10,7 +10,7 @@
#ifndef __LINUX_DEVFREQ_H__
#define __LINUX_DEVFREQ_H__
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/notifier.h>
#include <linux/pm_opp.h>
#include <linux/pm_qos.h>
@@ -12,6 +12,7 @@
#ifndef _DEVICE_H_
#define _DEVICE_H_
+#include <linux/device_types.h>
#include <linux/dev_printk.h>
#include <linux/energy_model.h>
#include <linux/ioport.h>
@@ -30,7 +31,6 @@
#include <linux/device/driver.h>
#include <linux/cleanup.h>
#include <linux/sysfs.h> // for __ATTR_*
-#include <asm/device.h>
struct device;
struct device_private;
@@ -46,27 +46,6 @@ struct dev_pin_info;
struct dev_iommu;
struct msi_device_data;
-/**
- * struct subsys_interface - interfaces to device functions
- * @name: name of the device function
- * @subsys: subsystem of the devices to attach to
- * @node: the list of functions registered at the subsystem
- * @add_dev: device hookup to device function handler
- * @remove_dev: device hookup to device function handler
- *
- * Simple interfaces attached to a subsystem. Multiple interfaces can
- * attach to a subsystem and its devices. Unlike drivers, they do not
- * exclusively claim or control devices. Interfaces usually represent
- * a specific functionality of a subsystem/class of devices.
- */
-struct subsys_interface {
- const char *name;
- const struct bus_type *subsys;
- struct list_head node;
- int (*add_dev)(struct device *dev, struct subsys_interface *sif);
- void (*remove_dev)(struct device *dev, struct subsys_interface *sif);
-};
-
int subsys_interface_register(struct subsys_interface *sif);
void subsys_interface_unregister(struct subsys_interface *sif);
@@ -75,50 +54,6 @@ int subsys_system_register(const struct bus_type *subsys,
int subsys_virtual_register(const struct bus_type *subsys,
const struct attribute_group **groups);
-/*
- * The type of device, "struct device" is embedded in. A class
- * or bus can contain devices of different types
- * like "partitions" and "disks", "mouse" and "event".
- * This identifies the device type and carries type-specific
- * information, equivalent to the kobj_type of a kobject.
- * If "name" is specified, the uevent will contain it in
- * the DEVTYPE variable.
- */
-struct device_type {
- const char *name;
- const struct attribute_group **groups;
- int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
- char *(*devnode)(const struct device *dev, umode_t *mode,
- kuid_t *uid, kgid_t *gid);
- void (*release)(struct device *dev);
-
- const struct dev_pm_ops *pm;
-};
-
-/**
- * struct device_attribute - Interface for exporting device attributes.
- * @attr: sysfs attribute definition.
- * @show: Show handler.
- * @store: Store handler.
- */
-struct device_attribute {
- struct attribute attr;
- ssize_t (*show)(struct device *dev, struct device_attribute *attr,
- char *buf);
- ssize_t (*store)(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count);
-};
-
-/**
- * struct dev_ext_attribute - Exported device attribute with extra context.
- * @attr: Exported device attribute.
- * @var: Pointer to context.
- */
-struct dev_ext_attribute {
- struct device_attribute attr;
- void *var;
-};
-
ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
char *buf);
ssize_t device_store_ulong(struct device *dev, struct device_attribute *attr,
@@ -423,34 +358,6 @@ void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
size_t align);
void devm_free_percpu(struct device *dev, void __percpu *pdata);
-struct device_dma_parameters {
- /*
- * a low level driver may set these to teach IOMMU code about
- * sg limitations.
- */
- unsigned int max_segment_size;
- unsigned int min_align_mask;
- unsigned long segment_boundary_mask;
-};
-
-/**
- * enum device_link_state - Device link states.
- * @DL_STATE_NONE: The presence of the drivers is not being tracked.
- * @DL_STATE_DORMANT: None of the supplier/consumer drivers is present.
- * @DL_STATE_AVAILABLE: The supplier driver is present, but the consumer is not.
- * @DL_STATE_CONSUMER_PROBE: The consumer is probing (supplier driver present).
- * @DL_STATE_ACTIVE: Both the supplier and consumer drivers are present.
- * @DL_STATE_SUPPLIER_UNBIND: The supplier driver is unbinding.
- */
-enum device_link_state {
- DL_STATE_NONE = -1,
- DL_STATE_DORMANT = 0,
- DL_STATE_AVAILABLE,
- DL_STATE_CONSUMER_PROBE,
- DL_STATE_ACTIVE,
- DL_STATE_SUPPLIER_UNBIND,
-};
-
/*
* Device link flags.
*
@@ -475,363 +382,6 @@ enum device_link_state {
#define DL_FLAG_INFERRED BIT(8)
#define DL_FLAG_CYCLE BIT(9)
-/**
- * enum dl_dev_state - Device driver presence tracking information.
- * @DL_DEV_NO_DRIVER: There is no driver attached to the device.
- * @DL_DEV_PROBING: A driver is probing.
- * @DL_DEV_DRIVER_BOUND: The driver has been bound to the device.
- * @DL_DEV_UNBINDING: The driver is unbinding from the device.
- */
-enum dl_dev_state {
- DL_DEV_NO_DRIVER = 0,
- DL_DEV_PROBING,
- DL_DEV_DRIVER_BOUND,
- DL_DEV_UNBINDING,
-};
-
-/**
- * enum device_removable - Whether the device is removable. The criteria for a
- * device to be classified as removable is determined by its subsystem or bus.
- * @DEVICE_REMOVABLE_NOT_SUPPORTED: This attribute is not supported for this
- * device (default).
- * @DEVICE_REMOVABLE_UNKNOWN: Device location is Unknown.
- * @DEVICE_FIXED: Device is not removable by the user.
- * @DEVICE_REMOVABLE: Device is removable by the user.
- */
-enum device_removable {
- DEVICE_REMOVABLE_NOT_SUPPORTED = 0, /* must be 0 */
- DEVICE_REMOVABLE_UNKNOWN,
- DEVICE_FIXED,
- DEVICE_REMOVABLE,
-};
-
-/**
- * struct dev_links_info - Device data related to device links.
- * @suppliers: List of links to supplier devices.
- * @consumers: List of links to consumer devices.
- * @defer_sync: Hook to global list of devices that have deferred sync_state.
- * @status: Driver status information.
- */
-struct dev_links_info {
- struct list_head suppliers;
- struct list_head consumers;
- struct list_head defer_sync;
- enum dl_dev_state status;
-};
-
-/**
- * struct dev_msi_info - Device data related to MSI
- * @domain: The MSI interrupt domain associated to the device
- * @data: Pointer to MSI device data
- */
-struct dev_msi_info {
-#ifdef CONFIG_GENERIC_MSI_IRQ
- struct irq_domain *domain;
- struct msi_device_data *data;
-#endif
-};
-
-/**
- * enum device_physical_location_panel - Describes which panel surface of the
- * system's housing the device connection point resides on.
- * @DEVICE_PANEL_TOP: Device connection point is on the top panel.
- * @DEVICE_PANEL_BOTTOM: Device connection point is on the bottom panel.
- * @DEVICE_PANEL_LEFT: Device connection point is on the left panel.
- * @DEVICE_PANEL_RIGHT: Device connection point is on the right panel.
- * @DEVICE_PANEL_FRONT: Device connection point is on the front panel.
- * @DEVICE_PANEL_BACK: Device connection point is on the back panel.
- * @DEVICE_PANEL_UNKNOWN: The panel with device connection point is unknown.
- */
-enum device_physical_location_panel {
- DEVICE_PANEL_TOP,
- DEVICE_PANEL_BOTTOM,
- DEVICE_PANEL_LEFT,
- DEVICE_PANEL_RIGHT,
- DEVICE_PANEL_FRONT,
- DEVICE_PANEL_BACK,
- DEVICE_PANEL_UNKNOWN,
-};
-
-/**
- * enum device_physical_location_vertical_position - Describes vertical
- * position of the device connection point on the panel surface.
- * @DEVICE_VERT_POS_UPPER: Device connection point is at upper part of panel.
- * @DEVICE_VERT_POS_CENTER: Device connection point is at center part of panel.
- * @DEVICE_VERT_POS_LOWER: Device connection point is at lower part of panel.
- */
-enum device_physical_location_vertical_position {
- DEVICE_VERT_POS_UPPER,
- DEVICE_VERT_POS_CENTER,
- DEVICE_VERT_POS_LOWER,
-};
-
-/**
- * enum device_physical_location_horizontal_position - Describes horizontal
- * position of the device connection point on the panel surface.
- * @DEVICE_HORI_POS_LEFT: Device connection point is at left part of panel.
- * @DEVICE_HORI_POS_CENTER: Device connection point is at center part of panel.
- * @DEVICE_HORI_POS_RIGHT: Device connection point is at right part of panel.
- */
-enum device_physical_location_horizontal_position {
- DEVICE_HORI_POS_LEFT,
- DEVICE_HORI_POS_CENTER,
- DEVICE_HORI_POS_RIGHT,
-};
-
-/**
- * struct device_physical_location - Device data related to physical location
- * of the device connection point.
- * @panel: Panel surface of the system's housing that the device connection
- * point resides on.
- * @vertical_position: Vertical position of the device connection point within
- * the panel.
- * @horizontal_position: Horizontal position of the device connection point
- * within the panel.
- * @dock: Set if the device connection point resides in a docking station or
- * port replicator.
- * @lid: Set if this device connection point resides on the lid of laptop
- * system.
- */
-struct device_physical_location {
- enum device_physical_location_panel panel;
- enum device_physical_location_vertical_position vertical_position;
- enum device_physical_location_horizontal_position horizontal_position;
- bool dock;
- bool lid;
-};
-
-/**
- * struct device - The basic device structure
- * @parent: The device's "parent" device, the device to which it is attached.
- * In most cases, a parent device is some sort of bus or host
- * controller. If parent is NULL, the device, is a top-level device,
- * which is not usually what you want.
- * @p: Holds the private data of the driver core portions of the device.
- * See the comment of the struct device_private for detail.
- * @kobj: A top-level, abstract class from which other classes are derived.
- * @init_name: Initial name of the device.
- * @type: The type of device.
- * This identifies the device type and carries type-specific
- * information.
- * @mutex: Mutex to synchronize calls to its driver.
- * @bus: Type of bus device is on.
- * @driver: Which driver has allocated this
- * @platform_data: Platform data specific to the device.
- * Example: For devices on custom boards, as typical of embedded
- * and SOC based hardware, Linux often uses platform_data to point
- * to board-specific structures describing devices and how they
- * are wired. That can include what ports are available, chip
- * variants, which GPIO pins act in what additional roles, and so
- * on. This shrinks the "Board Support Packages" (BSPs) and
- * minimizes board-specific #ifdefs in drivers.
- * @driver_data: Private pointer for driver specific info.
- * @links: Links to suppliers and consumers of this device.
- * @power: For device power management.
- * See Documentation/driver-api/pm/devices.rst for details.
- * @pm_domain: Provide callbacks that are executed during system suspend,
- * hibernation, system resume and during runtime PM transitions
- * along with subsystem-level and driver-level callbacks.
- * @em_pd: device's energy model performance domain
- * @pins: For device pin management.
- * See Documentation/driver-api/pin-control.rst for details.
- * @msi: MSI related data
- * @numa_node: NUMA node this device is close to.
- * @dma_ops: DMA mapping operations for this device.
- * @dma_mask: Dma mask (if dma'ble device).
- * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all
- * hardware supports 64-bit addresses for consistent allocations
- * such descriptors.
- * @bus_dma_limit: Limit of an upstream bridge or bus which imposes a smaller
- * DMA limit than the device itself supports.
- * @dma_range_map: map for DMA memory ranges relative to that of RAM
- * @dma_parms: A low level driver may set these to teach IOMMU code about
- * segment limitations.
- * @dma_pools: Dma pools (if dma'ble device).
- * @dma_mem: Internal for coherent mem override.
- * @cma_area: Contiguous memory area for dma allocations
- * @dma_io_tlb_mem: Software IO TLB allocator. Not for driver use.
- * @dma_io_tlb_pools: List of transient swiotlb memory pools.
- * @dma_io_tlb_lock: Protects changes to the list of active pools.
- * @dma_uses_io_tlb: %true if device has used the software IO TLB.
- * @archdata: For arch-specific additions.
- * @of_node: Associated device tree node.
- * @fwnode: Associated device node supplied by platform firmware.
- * @devt: For creating the sysfs "dev".
- * @id: device instance
- * @devres_lock: Spinlock to protect the resource of the device.
- * @devres_head: The resources list of the device.
- * @class: The class of the device.
- * @groups: Optional attribute groups.
- * @release: Callback to free the device after all references have
- * gone away. This should be set by the allocator of the
- * device (i.e. the bus driver that discovered the device).
- * @iommu_group: IOMMU group the device belongs to.
- * @iommu: Per device generic IOMMU runtime data
- * @physical_location: Describes physical location of the device connection
- * point in the system housing.
- * @removable: Whether the device can be removed from the system. This
- * should be set by the subsystem / bus driver that discovered
- * the device.
- *
- * @offline_disabled: If set, the device is permanently online.
- * @offline: Set after successful invocation of bus type's .offline().
- * @of_node_reused: Set if the device-tree node is shared with an ancestor
- * device.
- * @state_synced: The hardware state of this device has been synced to match
- * the software state of this device by calling the driver/bus
- * sync_state() callback.
- * @can_match: The device has matched with a driver at least once or it is in
- * a bus (like AMBA) which can't check for matching drivers until
- * other devices probe successfully.
- * @dma_coherent: this particular device is dma coherent, even if the
- * architecture supports non-coherent devices.
- * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the
- * streaming DMA operations (->map_* / ->unmap_* / ->sync_*),
- * and optionall (if the coherent mask is large enough) also
- * for dma allocations. This flag is managed by the dma ops
- * instance from ->dma_supported.
- *
- * At the lowest level, every device in a Linux system is represented by an
- * instance of struct device. The device structure contains the information
- * that the device model core needs to model the system. Most subsystems,
- * however, track additional information about the devices they host. As a
- * result, it is rare for devices to be represented by bare device structures;
- * instead, that structure, like kobject structures, is usually embedded within
- * a higher-level representation of the device.
- */
-struct device {
- struct kobject kobj;
- struct device *parent;
-
- struct device_private *p;
-
- const char *init_name; /* initial name of the device */
- const struct device_type *type;
-
- const struct bus_type *bus; /* type of bus device is on */
- struct device_driver *driver; /* which driver has allocated this
- device */
- void *platform_data; /* Platform specific data, device
- core doesn't touch it */
- void *driver_data; /* Driver data, set and get with
- dev_set_drvdata/dev_get_drvdata */
- struct mutex mutex; /* mutex to synchronize calls to
- * its driver.
- */
-
- struct dev_links_info links;
- struct dev_pm_info power;
- struct dev_pm_domain *pm_domain;
-
-#ifdef CONFIG_ENERGY_MODEL
- struct em_perf_domain *em_pd;
-#endif
-
-#ifdef CONFIG_PINCTRL
- struct dev_pin_info *pins;
-#endif
- struct dev_msi_info msi;
-#ifdef CONFIG_DMA_OPS
- const struct dma_map_ops *dma_ops;
-#endif
- u64 *dma_mask; /* dma mask (if dma'able device) */
- u64 coherent_dma_mask;/* Like dma_mask, but for
- alloc_coherent mappings as
- not all hardware supports
- 64 bit addresses for consistent
- allocations such descriptors. */
- u64 bus_dma_limit; /* upstream dma constraint */
- const struct bus_dma_region *dma_range_map;
-
- struct device_dma_parameters *dma_parms;
-
- struct list_head dma_pools; /* dma pools (if dma'ble) */
-
-#ifdef CONFIG_DMA_DECLARE_COHERENT
- struct dma_coherent_mem *dma_mem; /* internal for coherent mem
- override */
-#endif
-#ifdef CONFIG_DMA_CMA
- struct cma *cma_area; /* contiguous memory area for dma
- allocations */
-#endif
-#ifdef CONFIG_SWIOTLB
- struct io_tlb_mem *dma_io_tlb_mem;
-#endif
-#ifdef CONFIG_SWIOTLB_DYNAMIC
- struct list_head dma_io_tlb_pools;
- spinlock_t dma_io_tlb_lock;
- bool dma_uses_io_tlb;
-#endif
- /* arch specific additions */
- struct dev_archdata archdata;
-
- struct device_node *of_node; /* associated device tree node */
- struct fwnode_handle *fwnode; /* firmware device node */
-
-#ifdef CONFIG_NUMA
- int numa_node; /* NUMA node this device is close to */
-#endif
- dev_t devt; /* dev_t, creates the sysfs "dev" */
- u32 id; /* device instance */
-
- spinlock_t devres_lock;
- struct list_head devres_head;
-
- const struct class *class;
- const struct attribute_group **groups; /* optional groups */
-
- void (*release)(struct device *dev);
- struct iommu_group *iommu_group;
- struct dev_iommu *iommu;
-
- struct device_physical_location *physical_location;
-
- enum device_removable removable;
-
- bool offline_disabled:1;
- bool offline:1;
- bool of_node_reused:1;
- bool state_synced:1;
- bool can_match:1;
-#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
- defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
- defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
- bool dma_coherent:1;
-#endif
-#ifdef CONFIG_DMA_OPS_BYPASS
- bool dma_ops_bypass : 1;
-#endif
-};
-
-/**
- * struct device_link - Device link representation.
- * @supplier: The device on the supplier end of the link.
- * @s_node: Hook to the supplier device's list of links to consumers.
- * @consumer: The device on the consumer end of the link.
- * @c_node: Hook to the consumer device's list of links to suppliers.
- * @link_dev: device used to expose link details in sysfs
- * @status: The state of the link (with respect to the presence of drivers).
- * @flags: Link flags.
- * @rpm_active: Whether or not the consumer device is runtime-PM-active.
- * @kref: Count repeated addition of the same link.
- * @rm_work: Work structure used for removing the link.
- * @supplier_preactivated: Supplier has been made active before consumer probe.
- */
-struct device_link {
- struct device *supplier;
- struct list_head s_node;
- struct device *consumer;
- struct list_head c_node;
- struct device link_dev;
- enum device_link_state status;
- u32 flags;
- refcount_t rpm_active;
- struct kref kref;
- struct work_struct rm_work;
- bool supplier_preactivated; /* Owned by consumer probe. */
-};
-
#define kobj_to_dev(__kobj) container_of_const(__kobj, struct device, kobj)
/**
@@ -847,20 +397,6 @@ static inline bool device_iommu_mapped(struct device *dev)
/* Get the wakeup routines, which depend on struct device */
#include <linux/pm_wakeup.h>
-/**
- * dev_name - Return a device's name.
- * @dev: Device with name to get.
- * Return: The kobject name of the device, or its initial name if unavailable.
- */
-static inline const char *dev_name(const struct device *dev)
-{
- /* Use the init name until the kobject becomes available */
- if (dev->init_name)
- return dev->init_name;
-
- return kobject_name(&dev->kobj);
-}
-
/**
* dev_bus_name - Return a device's bus/class name, if at all possible
* @dev: struct device to get the bus/class name of
new file mode 100644
@@ -0,0 +1,500 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * device.h - generic, centralized driver model
+ *
+ * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
+ * Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de>
+ * Copyright (c) 2008-2009 Novell Inc.
+ *
+ * See Documentation/driver-api/driver-model/ for more information.
+ */
+
+#ifndef _DEVICE_TYPES_H_
+#define _DEVICE_TYPES_H_
+
+#include <linux/kobject_types.h>
+#include <linux/pm.h>
+#include <linux/sysfs_types.h>
+#include <linux/uidgid_types.h>
+#include <asm/device.h>
+
+struct device;
+struct device_private;
+struct device_driver;
+struct driver_private;
+struct module;
+struct class;
+struct subsys_private;
+struct device_node;
+struct fwnode_handle;
+struct iommu_group;
+struct dev_pin_info;
+struct dev_iommu;
+struct msi_device_data;
+struct kobj_uevent_env;
+
+/**
+ * struct subsys_interface - interfaces to device functions
+ * @name: name of the device function
+ * @subsys: subsystem of the devices to attach to
+ * @node: the list of functions registered at the subsystem
+ * @add_dev: device hookup to device function handler
+ * @remove_dev: device hookup to device function handler
+ *
+ * Simple interfaces attached to a subsystem. Multiple interfaces can
+ * attach to a subsystem and its devices. Unlike drivers, they do not
+ * exclusively claim or control devices. Interfaces usually represent
+ * a specific functionality of a subsystem/class of devices.
+ */
+struct subsys_interface {
+ const char *name;
+ const struct bus_type *subsys;
+ struct list_head node;
+ int (*add_dev)(struct device *dev, struct subsys_interface *sif);
+ void (*remove_dev)(struct device *dev, struct subsys_interface *sif);
+};
+
+/*
+ * The type of device, "struct device" is embedded in. A class
+ * or bus can contain devices of different types
+ * like "partitions" and "disks", "mouse" and "event".
+ * This identifies the device type and carries type-specific
+ * information, equivalent to the kobj_type of a kobject.
+ * If "name" is specified, the uevent will contain it in
+ * the DEVTYPE variable.
+ */
+struct device_type {
+ const char *name;
+ const struct attribute_group **groups;
+ int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
+ char *(*devnode)(const struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid);
+ void (*release)(struct device *dev);
+
+ const struct dev_pm_ops *pm;
+};
+
+/**
+ * struct device_attribute - Interface for exporting device attributes.
+ * @attr: sysfs attribute definition.
+ * @show: Show handler.
+ * @store: Store handler.
+ */
+struct device_attribute {
+ struct attribute attr;
+ ssize_t (*show)(struct device *dev, struct device_attribute *attr,
+ char *buf);
+ ssize_t (*store)(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count);
+};
+
+/**
+ * struct dev_ext_attribute - Exported device attribute with extra context.
+ * @attr: Exported device attribute.
+ * @var: Pointer to context.
+ */
+struct dev_ext_attribute {
+ struct device_attribute attr;
+ void *var;
+};
+
+struct device_dma_parameters {
+ /*
+ * a low level driver may set these to teach IOMMU code about
+ * sg limitations.
+ */
+ unsigned int max_segment_size;
+ unsigned int min_align_mask;
+ unsigned long segment_boundary_mask;
+};
+
+/**
+ * enum device_link_state - Device link states.
+ * @DL_STATE_NONE: The presence of the drivers is not being tracked.
+ * @DL_STATE_DORMANT: None of the supplier/consumer drivers is present.
+ * @DL_STATE_AVAILABLE: The supplier driver is present, but the consumer is not.
+ * @DL_STATE_CONSUMER_PROBE: The consumer is probing (supplier driver present).
+ * @DL_STATE_ACTIVE: Both the supplier and consumer drivers are present.
+ * @DL_STATE_SUPPLIER_UNBIND: The supplier driver is unbinding.
+ */
+enum device_link_state {
+ DL_STATE_NONE = -1,
+ DL_STATE_DORMANT = 0,
+ DL_STATE_AVAILABLE,
+ DL_STATE_CONSUMER_PROBE,
+ DL_STATE_ACTIVE,
+ DL_STATE_SUPPLIER_UNBIND,
+};
+
+/**
+ * enum dl_dev_state - Device driver presence tracking information.
+ * @DL_DEV_NO_DRIVER: There is no driver attached to the device.
+ * @DL_DEV_PROBING: A driver is probing.
+ * @DL_DEV_DRIVER_BOUND: The driver has been bound to the device.
+ * @DL_DEV_UNBINDING: The driver is unbinding from the device.
+ */
+enum dl_dev_state {
+ DL_DEV_NO_DRIVER = 0,
+ DL_DEV_PROBING,
+ DL_DEV_DRIVER_BOUND,
+ DL_DEV_UNBINDING,
+};
+
+/**
+ * enum device_removable - Whether the device is removable. The criteria for a
+ * device to be classified as removable is determined by its subsystem or bus.
+ * @DEVICE_REMOVABLE_NOT_SUPPORTED: This attribute is not supported for this
+ * device (default).
+ * @DEVICE_REMOVABLE_UNKNOWN: Device location is Unknown.
+ * @DEVICE_FIXED: Device is not removable by the user.
+ * @DEVICE_REMOVABLE: Device is removable by the user.
+ */
+enum device_removable {
+ DEVICE_REMOVABLE_NOT_SUPPORTED = 0, /* must be 0 */
+ DEVICE_REMOVABLE_UNKNOWN,
+ DEVICE_FIXED,
+ DEVICE_REMOVABLE,
+};
+
+/**
+ * struct dev_links_info - Device data related to device links.
+ * @suppliers: List of links to supplier devices.
+ * @consumers: List of links to consumer devices.
+ * @defer_sync: Hook to global list of devices that have deferred sync_state.
+ * @status: Driver status information.
+ */
+struct dev_links_info {
+ struct list_head suppliers;
+ struct list_head consumers;
+ struct list_head defer_sync;
+ enum dl_dev_state status;
+};
+
+/**
+ * struct dev_msi_info - Device data related to MSI
+ * @domain: The MSI interrupt domain associated to the device
+ * @data: Pointer to MSI device data
+ */
+struct dev_msi_info {
+#ifdef CONFIG_GENERIC_MSI_IRQ
+ struct irq_domain *domain;
+ struct msi_device_data *data;
+#endif
+};
+
+/**
+ * enum device_physical_location_panel - Describes which panel surface of the
+ * system's housing the device connection point resides on.
+ * @DEVICE_PANEL_TOP: Device connection point is on the top panel.
+ * @DEVICE_PANEL_BOTTOM: Device connection point is on the bottom panel.
+ * @DEVICE_PANEL_LEFT: Device connection point is on the left panel.
+ * @DEVICE_PANEL_RIGHT: Device connection point is on the right panel.
+ * @DEVICE_PANEL_FRONT: Device connection point is on the front panel.
+ * @DEVICE_PANEL_BACK: Device connection point is on the back panel.
+ * @DEVICE_PANEL_UNKNOWN: The panel with device connection point is unknown.
+ */
+enum device_physical_location_panel {
+ DEVICE_PANEL_TOP,
+ DEVICE_PANEL_BOTTOM,
+ DEVICE_PANEL_LEFT,
+ DEVICE_PANEL_RIGHT,
+ DEVICE_PANEL_FRONT,
+ DEVICE_PANEL_BACK,
+ DEVICE_PANEL_UNKNOWN,
+};
+
+/**
+ * enum device_physical_location_vertical_position - Describes vertical
+ * position of the device connection point on the panel surface.
+ * @DEVICE_VERT_POS_UPPER: Device connection point is at upper part of panel.
+ * @DEVICE_VERT_POS_CENTER: Device connection point is at center part of panel.
+ * @DEVICE_VERT_POS_LOWER: Device connection point is at lower part of panel.
+ */
+enum device_physical_location_vertical_position {
+ DEVICE_VERT_POS_UPPER,
+ DEVICE_VERT_POS_CENTER,
+ DEVICE_VERT_POS_LOWER,
+};
+
+/**
+ * enum device_physical_location_horizontal_position - Describes horizontal
+ * position of the device connection point on the panel surface.
+ * @DEVICE_HORI_POS_LEFT: Device connection point is at left part of panel.
+ * @DEVICE_HORI_POS_CENTER: Device connection point is at center part of panel.
+ * @DEVICE_HORI_POS_RIGHT: Device connection point is at right part of panel.
+ */
+enum device_physical_location_horizontal_position {
+ DEVICE_HORI_POS_LEFT,
+ DEVICE_HORI_POS_CENTER,
+ DEVICE_HORI_POS_RIGHT,
+};
+
+/**
+ * struct device_physical_location - Device data related to physical location
+ * of the device connection point.
+ * @panel: Panel surface of the system's housing that the device connection
+ * point resides on.
+ * @vertical_position: Vertical position of the device connection point within
+ * the panel.
+ * @horizontal_position: Horizontal position of the device connection point
+ * within the panel.
+ * @dock: Set if the device connection point resides in a docking station or
+ * port replicator.
+ * @lid: Set if this device connection point resides on the lid of laptop
+ * system.
+ */
+struct device_physical_location {
+ enum device_physical_location_panel panel;
+ enum device_physical_location_vertical_position vertical_position;
+ enum device_physical_location_horizontal_position horizontal_position;
+ bool dock;
+ bool lid;
+};
+
+/**
+ * struct device - The basic device structure
+ * @parent: The device's "parent" device, the device to which it is attached.
+ * In most cases, a parent device is some sort of bus or host
+ * controller. If parent is NULL, the device, is a top-level device,
+ * which is not usually what you want.
+ * @p: Holds the private data of the driver core portions of the device.
+ * See the comment of the struct device_private for detail.
+ * @kobj: A top-level, abstract class from which other classes are derived.
+ * @init_name: Initial name of the device.
+ * @type: The type of device.
+ * This identifies the device type and carries type-specific
+ * information.
+ * @mutex: Mutex to synchronize calls to its driver.
+ * @bus: Type of bus device is on.
+ * @driver: Which driver has allocated this
+ * @platform_data: Platform data specific to the device.
+ * Example: For devices on custom boards, as typical of embedded
+ * and SOC based hardware, Linux often uses platform_data to point
+ * to board-specific structures describing devices and how they
+ * are wired. That can include what ports are available, chip
+ * variants, which GPIO pins act in what additional roles, and so
+ * on. This shrinks the "Board Support Packages" (BSPs) and
+ * minimizes board-specific #ifdefs in drivers.
+ * @driver_data: Private pointer for driver specific info.
+ * @links: Links to suppliers and consumers of this device.
+ * @power: For device power management.
+ * See Documentation/driver-api/pm/devices.rst for details.
+ * @pm_domain: Provide callbacks that are executed during system suspend,
+ * hibernation, system resume and during runtime PM transitions
+ * along with subsystem-level and driver-level callbacks.
+ * @em_pd: device's energy model performance domain
+ * @pins: For device pin management.
+ * See Documentation/driver-api/pin-control.rst for details.
+ * @msi: MSI related data
+ * @numa_node: NUMA node this device is close to.
+ * @dma_ops: DMA mapping operations for this device.
+ * @dma_mask: Dma mask (if dma'ble device).
+ * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all
+ * hardware supports 64-bit addresses for consistent allocations
+ * such descriptors.
+ * @bus_dma_limit: Limit of an upstream bridge or bus which imposes a smaller
+ * DMA limit than the device itself supports.
+ * @dma_range_map: map for DMA memory ranges relative to that of RAM
+ * @dma_parms: A low level driver may set these to teach IOMMU code about
+ * segment limitations.
+ * @dma_pools: Dma pools (if dma'ble device).
+ * @dma_mem: Internal for coherent mem override.
+ * @cma_area: Contiguous memory area for dma allocations
+ * @dma_io_tlb_mem: Software IO TLB allocator. Not for driver use.
+ * @dma_io_tlb_pools: List of transient swiotlb memory pools.
+ * @dma_io_tlb_lock: Protects changes to the list of active pools.
+ * @dma_uses_io_tlb: %true if device has used the software IO TLB.
+ * @archdata: For arch-specific additions.
+ * @of_node: Associated device tree node.
+ * @fwnode: Associated device node supplied by platform firmware.
+ * @devt: For creating the sysfs "dev".
+ * @id: device instance
+ * @devres_lock: Spinlock to protect the resource of the device.
+ * @devres_head: The resources list of the device.
+ * @class: The class of the device.
+ * @groups: Optional attribute groups.
+ * @release: Callback to free the device after all references have
+ * gone away. This should be set by the allocator of the
+ * device (i.e. the bus driver that discovered the device).
+ * @iommu_group: IOMMU group the device belongs to.
+ * @iommu: Per device generic IOMMU runtime data
+ * @physical_location: Describes physical location of the device connection
+ * point in the system housing.
+ * @removable: Whether the device can be removed from the system. This
+ * should be set by the subsystem / bus driver that discovered
+ * the device.
+ *
+ * @offline_disabled: If set, the device is permanently online.
+ * @offline: Set after successful invocation of bus type's .offline().
+ * @of_node_reused: Set if the device-tree node is shared with an ancestor
+ * device.
+ * @state_synced: The hardware state of this device has been synced to match
+ * the software state of this device by calling the driver/bus
+ * sync_state() callback.
+ * @can_match: The device has matched with a driver at least once or it is in
+ * a bus (like AMBA) which can't check for matching drivers until
+ * other devices probe successfully.
+ * @dma_coherent: this particular device is dma coherent, even if the
+ * architecture supports non-coherent devices.
+ * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the
+ * streaming DMA operations (->map_* / ->unmap_* / ->sync_*),
+ * and optionall (if the coherent mask is large enough) also
+ * for dma allocations. This flag is managed by the dma ops
+ * instance from ->dma_supported.
+ *
+ * At the lowest level, every device in a Linux system is represented by an
+ * instance of struct device. The device structure contains the information
+ * that the device model core needs to model the system. Most subsystems,
+ * however, track additional information about the devices they host. As a
+ * result, it is rare for devices to be represented by bare device structures;
+ * instead, that structure, like kobject structures, is usually embedded within
+ * a higher-level representation of the device.
+ */
+struct device {
+ struct kobject kobj;
+ struct device *parent;
+
+ struct device_private *p;
+
+ const char *init_name; /* initial name of the device */
+ const struct device_type *type;
+
+ const struct bus_type *bus; /* type of bus device is on */
+ struct device_driver *driver; /* which driver has allocated this
+ device */
+ void *platform_data; /* Platform specific data, device
+ core doesn't touch it */
+ void *driver_data; /* Driver data, set and get with
+ dev_set_drvdata/dev_get_drvdata */
+ struct mutex mutex; /* mutex to synchronize calls to
+ * its driver.
+ */
+
+ struct dev_links_info links;
+ struct dev_pm_info power;
+ struct dev_pm_domain *pm_domain;
+
+#ifdef CONFIG_ENERGY_MODEL
+ struct em_perf_domain *em_pd;
+#endif
+
+#ifdef CONFIG_PINCTRL
+ struct dev_pin_info *pins;
+#endif
+ struct dev_msi_info msi;
+#ifdef CONFIG_DMA_OPS
+ const struct dma_map_ops *dma_ops;
+#endif
+ u64 *dma_mask; /* dma mask (if dma'able device) */
+ u64 coherent_dma_mask;/* Like dma_mask, but for
+ alloc_coherent mappings as
+ not all hardware supports
+ 64 bit addresses for consistent
+ allocations such descriptors. */
+ u64 bus_dma_limit; /* upstream dma constraint */
+ const struct bus_dma_region *dma_range_map;
+
+ struct device_dma_parameters *dma_parms;
+
+ struct list_head dma_pools; /* dma pools (if dma'ble) */
+
+#ifdef CONFIG_DMA_DECLARE_COHERENT
+ struct dma_coherent_mem *dma_mem; /* internal for coherent mem
+ override */
+#endif
+#ifdef CONFIG_DMA_CMA
+ struct cma *cma_area; /* contiguous memory area for dma
+ allocations */
+#endif
+#ifdef CONFIG_SWIOTLB
+ struct io_tlb_mem *dma_io_tlb_mem;
+#endif
+#ifdef CONFIG_SWIOTLB_DYNAMIC
+ struct list_head dma_io_tlb_pools;
+ spinlock_t dma_io_tlb_lock;
+ bool dma_uses_io_tlb;
+#endif
+ /* arch specific additions */
+ struct dev_archdata archdata;
+
+ struct device_node *of_node; /* associated device tree node */
+ struct fwnode_handle *fwnode; /* firmware device node */
+
+#ifdef CONFIG_NUMA
+ int numa_node; /* NUMA node this device is close to */
+#endif
+ dev_t devt; /* dev_t, creates the sysfs "dev" */
+ u32 id; /* device instance */
+
+ spinlock_t devres_lock;
+ struct list_head devres_head;
+
+ const struct class *class;
+ const struct attribute_group **groups; /* optional groups */
+
+ void (*release)(struct device *dev);
+ struct iommu_group *iommu_group;
+ struct dev_iommu *iommu;
+
+ struct device_physical_location *physical_location;
+
+ enum device_removable removable;
+
+ bool offline_disabled:1;
+ bool offline:1;
+ bool of_node_reused:1;
+ bool state_synced:1;
+ bool can_match:1;
+#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
+ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
+ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
+ bool dma_coherent:1;
+#endif
+#ifdef CONFIG_DMA_OPS_BYPASS
+ bool dma_ops_bypass : 1;
+#endif
+};
+
+/**
+ * struct device_link - Device link representation.
+ * @supplier: The device on the supplier end of the link.
+ * @s_node: Hook to the supplier device's list of links to consumers.
+ * @consumer: The device on the consumer end of the link.
+ * @c_node: Hook to the consumer device's list of links to suppliers.
+ * @link_dev: device used to expose link details in sysfs
+ * @status: The state of the link (with respect to the presence of drivers).
+ * @flags: Link flags.
+ * @rpm_active: Whether or not the consumer device is runtime-PM-active.
+ * @kref: Count repeated addition of the same link.
+ * @rm_work: Work structure used for removing the link.
+ * @supplier_preactivated: Supplier has been made active before consumer probe.
+ */
+struct device_link {
+ struct device *supplier;
+ struct list_head s_node;
+ struct device *consumer;
+ struct list_head c_node;
+ struct device link_dev;
+ enum device_link_state status;
+ u32 flags;
+ refcount_t rpm_active;
+ struct kref kref;
+ struct work_struct rm_work;
+ bool supplier_preactivated; /* Owned by consumer probe. */
+};
+
+/**
+ * dev_name - Return a device's name.
+ * @dev: Device with name to get.
+ * Return: The kobject name of the device, or its initial name if unavailable.
+ */
+static inline const char *dev_name(const struct device *dev)
+{
+ /* Use the init name until the kobject becomes available */
+ if (dev->init_name)
+ return dev->init_name;
+
+ return kobject_name(&dev->kobj);
+}
+
+#endif /* _DEVICE_TYPES_H_ */
@@ -5,7 +5,7 @@
#ifndef LINUX_DMAENGINE_H
#define LINUX_DMAENGINE_H
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/err.h>
#include <linux/idr.h> // for struct ida
#include <linux/uio.h>
@@ -13,7 +13,7 @@
#define _LINUX_EDAC_H_
#include <linux/atomic.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/completion_types.h>
#include <linux/workqueue_types.h>
#include <linux/debugfs.h>
@@ -12,7 +12,7 @@
#ifndef _LINUX_ENCLOSURE_H_
#define _LINUX_ENCLOSURE_H_
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/list.h>
/* A few generic types ... taken from ses-2 */
@@ -3,7 +3,7 @@
#ifndef _LINUX_FPGA_BRIDGE_H
#define _LINUX_FPGA_BRIDGE_H
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/fpga/fpga-mgr.h>
struct fpga_bridge;
@@ -3,7 +3,7 @@
#ifndef _FPGA_REGION_H
#define _FPGA_REGION_H
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/fpga/fpga-mgr.h>
#include <linux/fpga/fpga-bridge.h>
@@ -14,7 +14,7 @@
#include <linux/mutex_types.h>
#include <linux/notifier.h>
#include <linux/of.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/workqueue_types.h>
/**
@@ -25,7 +25,7 @@
#define __LINUX_HDMI_H_
#include <linux/types.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
enum hdmi_packet_type {
HDMI_PACKET_TYPE_NULL = 0x00,
@@ -7,7 +7,7 @@
#ifndef _LINUX_HWMON_SYSFS_H
#define _LINUX_HWMON_SYSFS_H
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/kstrtox.h>
struct sensor_device_attribute{
@@ -7,7 +7,7 @@
#ifndef _INDUSTRIAL_IO_H_
#define _INDUSTRIAL_IO_H_
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/slab.h>
@@ -9,7 +9,7 @@
#ifndef _LINUX_LCD_H
#define _LINUX_LCD_H
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/mutex.h>
#include <linux/notifier.h>
#include <linux/fb.h>
@@ -15,7 +15,7 @@
#ifndef _LINUX_NODE_H_
#define _LINUX_NODE_H_
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/cpumask.h>
#include <linux/list.h>
#include <linux/mmzone.h> // for enum meminit_context
@@ -8,7 +8,7 @@
#ifndef _LINUX_PM_CLOCK_H
#define _LINUX_PM_CLOCK_H
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/notifier.h>
struct pm_clk_notifier_block {
@@ -8,7 +8,7 @@
#ifndef _LINUX_PM_DOMAIN_H
#define _LINUX_PM_DOMAIN_H
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/ktime.h>
#include <linux/mutex_types.h>
#include <linux/pm.h>
@@ -14,7 +14,7 @@
#include <linux/plist.h>
#include <linux/notifier.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
enum pm_qos_flags_status {
PM_QOS_FLAGS_UNDEFINED = -1,
@@ -12,7 +12,7 @@
#ifndef __LINUX_POWER_SUPPLY_H__
#define __LINUX_POWER_SUPPLY_H__
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/workqueue_types.h>
#include <linux/leds.h>
#include <linux/spinlock_types.h>
@@ -7,7 +7,7 @@
#ifndef __POWERCAP_H__
#define __POWERCAP_H__
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/idr.h>
/*
@@ -34,7 +34,7 @@ static inline time64_t rtc_tm_sub(struct rtc_time *lhs, struct rtc_time *rhs)
return rtc_tm_to_time64(lhs) - rtc_tm_to_time64(rhs);
}
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/seq_file.h>
#include <linux/cdev.h>
#include <linux/poll.h>
@@ -2,7 +2,7 @@
#ifndef __LINUX_SWIOTLB_H
#define __LINUX_SWIOTLB_H
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/dma-direction.h>
#include <linux/init.h>
#include <linux/types.h>
@@ -10,7 +10,6 @@
#include <linux/spinlock_types.h>
#include <linux/workqueue_types.h>
-struct device;
struct page;
struct scatterlist;
@@ -12,7 +12,7 @@
#include <linux/of.h>
#include <linux/idr.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/sysfs_types.h>
#include <linux/workqueue_types.h>
#include <uapi/linux/thermal.h>
@@ -6,7 +6,7 @@
#ifndef __LINUX_W1_H
#define __LINUX_W1_H
-#include <linux/device.h>
+#include <linux/device_types.h>
/**
* struct w1_reg_num - broken out slave device id
@@ -11,7 +11,7 @@
#include <linux/poll.h>
#include <linux/fs.h>
#include <linux/debugfs.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/cdev.h>
#include <linux/kthread.h>
#include <linux/cec-funcs.h>
@@ -18,7 +18,7 @@
#include <linux/poll.h>
#include <linux/fs.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/cdev.h>
struct media_device;
@@ -12,7 +12,7 @@
#define __NET_NFC_H
#include <linux/nfc.h>
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/skbuff.h>
#define nfc_dbg(dev, fmt, ...) dev_dbg((dev), "NFC: " fmt, ##__VA_ARGS__)
@@ -12,7 +12,7 @@
#ifndef _LINUX_SS_H
#define _LINUX_SS_H
-#include <linux/device.h>
+#include <linux/device_types.h>
#include <linux/sched.h> /* task_struct, completion */
#include <linux/mutex_types.h>
@@ -2,6 +2,7 @@
#ifndef _SCSI_SCSI_DEVICE_H
#define _SCSI_SCSI_DEVICE_H
+#include <linux/device.h> // for device_reprobe()
#include <linux/list.h>
#include <linux/spinlock_types.h>
#include <linux/workqueue_types.h>
@@ -14,6 +14,7 @@
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/debugfs.h>
+#include <linux/device.h>
#include <linux/export.h>
#include <linux/time.h>
#include <linux/uaccess.h>