diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-03-31 11:33:15 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-03-31 17:45:07 +0200 |
commit | d6bdbbdfb0d45a92407b90209e377bf8c0ed49e9 (patch) | |
tree | 64b78543a47209b219b96ac442b9b411b0c23a36 /drivers/base/base.h | |
parent | driver core: class: remove subsystem private pointer from struct class (diff) | |
download | linux-d6bdbbdfb0d45a92407b90209e377bf8c0ed49e9.tar.xz linux-d6bdbbdfb0d45a92407b90209e377bf8c0ed49e9.zip |
driver core: clean up the logic to determine which /sys/dev/ directory to use
When a dev_t is set in a struct device, an symlink in /sys/dev/ is
created for it either under /sys/dev/block/ or /sys/dev/char/ depending
on the device type.
The logic to determine this would trigger off of the class of the
object, and the kobj_type set in that location. But it turns out that
this deep nesting isn't needed at all, as it's either a choice of block
or "everything else" which is a char device. So make the logic a lot
more simple and obvious, and remove the incorrect comments in the code
that tried to document something that was not happening at all (it is
impossible to set class->dev_kobj to NULL as the class core prevented
that from happening.
This removes the only place that class->dev_kobj was being used, so
after this, it can be removed entirely.
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230331093318.82288-4-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/base.h')
-rw-r--r-- | drivers/base/base.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index 6296164bb7f3..4660e1159ee0 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -209,6 +209,16 @@ int devtmpfs_init(void); static inline int devtmpfs_init(void) { return 0; } #endif +#ifdef CONFIG_BLOCK +extern struct class block_class; +static inline bool is_blockdev(struct device *dev) +{ + return dev->class == &block_class; +} +#else +static inline bool is_blockdev(struct device *dev) { return false; } +#endif + /* Device links support */ int device_links_read_lock(void); void device_links_read_unlock(int idx); |