Skip to content

Commit b34e5c1

Browse files
committed
Merge tag 'driver-core-5.6-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core and debugfs fixes from Greg KH: "Here are four small driver core / debugfs patches for 5.6-rc3: - debugfs api cleanup now that all debugfs_create_regset32() callers have been fixed up. This was waiting until after the -rc1 merge as these fixes came in through different trees - driver core sync state fixes based on reports of minor issues found in the feature All of these have been in linux-next with no reported issues" * tag 'driver-core-5.6-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: driver core: Skip unnecessary work when device doesn't have sync_state() driver core: Add dev_has_sync_state() driver core: Call sync_state() even if supplier has no consumers debugfs: remove return value of debugfs_create_regset32()
2 parents cc432ae + 7703616 commit b34e5c1

File tree

5 files changed

+44
-30
lines changed

5 files changed

+44
-30
lines changed

Documentation/filesystems/debugfs.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ file.
164164
void __iomem *base;
165165
};
166166

167-
struct dentry *debugfs_create_regset32(const char *name, umode_t mode,
168-
struct dentry *parent,
169-
struct debugfs_regset32 *regset);
167+
debugfs_create_regset32(const char *name, umode_t mode,
168+
struct dentry *parent,
169+
struct debugfs_regset32 *regset);
170170

171171
void debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs,
172172
int nregs, void __iomem *base, char *prefix);

drivers/base/core.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ static void __device_links_queue_sync_state(struct device *dev,
718718
{
719719
struct device_link *link;
720720

721+
if (!dev_has_sync_state(dev))
722+
return;
721723
if (dev->state_synced)
722724
return;
723725

@@ -745,25 +747,31 @@ static void __device_links_queue_sync_state(struct device *dev,
745747
/**
746748
* device_links_flush_sync_list - Call sync_state() on a list of devices
747749
* @list: List of devices to call sync_state() on
750+
* @dont_lock_dev: Device for which lock is already held by the caller
748751
*
749752
* Calls sync_state() on all the devices that have been queued for it. This
750-
* function is used in conjunction with __device_links_queue_sync_state().
753+
* function is used in conjunction with __device_links_queue_sync_state(). The
754+
* @dont_lock_dev parameter is useful when this function is called from a
755+
* context where a device lock is already held.
751756
*/
752-
static void device_links_flush_sync_list(struct list_head *list)
757+
static void device_links_flush_sync_list(struct list_head *list,
758+
struct device *dont_lock_dev)
753759
{
754760
struct device *dev, *tmp;
755761

756762
list_for_each_entry_safe(dev, tmp, list, links.defer_sync) {
757763
list_del_init(&dev->links.defer_sync);
758764

759-
device_lock(dev);
765+
if (dev != dont_lock_dev)
766+
device_lock(dev);
760767

761768
if (dev->bus->sync_state)
762769
dev->bus->sync_state(dev);
763770
else if (dev->driver && dev->driver->sync_state)
764771
dev->driver->sync_state(dev);
765772

766-
device_unlock(dev);
773+
if (dev != dont_lock_dev)
774+
device_unlock(dev);
767775

768776
put_device(dev);
769777
}
@@ -801,7 +809,7 @@ void device_links_supplier_sync_state_resume(void)
801809
out:
802810
device_links_write_unlock();
803811

804-
device_links_flush_sync_list(&sync_list);
812+
device_links_flush_sync_list(&sync_list, NULL);
805813
}
806814

807815
static int sync_state_resume_initcall(void)
@@ -813,7 +821,7 @@ late_initcall(sync_state_resume_initcall);
813821

814822
static void __device_links_supplier_defer_sync(struct device *sup)
815823
{
816-
if (list_empty(&sup->links.defer_sync))
824+
if (list_empty(&sup->links.defer_sync) && dev_has_sync_state(sup))
817825
list_add_tail(&sup->links.defer_sync, &deferred_sync);
818826
}
819827

@@ -865,6 +873,11 @@ void device_links_driver_bound(struct device *dev)
865873
driver_deferred_probe_add(link->consumer);
866874
}
867875

876+
if (defer_sync_state_count)
877+
__device_links_supplier_defer_sync(dev);
878+
else
879+
__device_links_queue_sync_state(dev, &sync_list);
880+
868881
list_for_each_entry(link, &dev->links.suppliers, c_node) {
869882
if (!(link->flags & DL_FLAG_MANAGED))
870883
continue;
@@ -883,7 +896,7 @@ void device_links_driver_bound(struct device *dev)
883896

884897
device_links_write_unlock();
885898

886-
device_links_flush_sync_list(&sync_list);
899+
device_links_flush_sync_list(&sync_list, dev);
887900
}
888901

889902
static void device_link_drop_managed(struct device_link *link)

fs/debugfs/file.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,21 +1090,12 @@ static const struct file_operations fops_regset32 = {
10901090
* This function creates a file in debugfs with the given name that reports
10911091
* the names and values of a set of 32-bit registers. If the @mode variable
10921092
* is so set it can be read from. Writing is not supported.
1093-
*
1094-
* This function will return a pointer to a dentry if it succeeds. This
1095-
* pointer must be passed to the debugfs_remove() function when the file is
1096-
* to be removed (no automatic cleanup happens if your module is unloaded,
1097-
* you are responsible here.) If an error occurs, ERR_PTR(-ERROR) will be
1098-
* returned.
1099-
*
1100-
* If debugfs is not enabled in the kernel, the value ERR_PTR(-ENODEV) will
1101-
* be returned.
11021093
*/
1103-
struct dentry *debugfs_create_regset32(const char *name, umode_t mode,
1104-
struct dentry *parent,
1105-
struct debugfs_regset32 *regset)
1094+
void debugfs_create_regset32(const char *name, umode_t mode,
1095+
struct dentry *parent,
1096+
struct debugfs_regset32 *regset)
11061097
{
1107-
return debugfs_create_file(name, mode, parent, regset, &fops_regset32);
1098+
debugfs_create_file(name, mode, parent, regset, &fops_regset32);
11081099
}
11091100
EXPORT_SYMBOL_GPL(debugfs_create_regset32);
11101101

include/linux/debugfs.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode,
127127
struct dentry *parent,
128128
struct debugfs_blob_wrapper *blob);
129129

130-
struct dentry *debugfs_create_regset32(const char *name, umode_t mode,
131-
struct dentry *parent,
132-
struct debugfs_regset32 *regset);
130+
void debugfs_create_regset32(const char *name, umode_t mode,
131+
struct dentry *parent,
132+
struct debugfs_regset32 *regset);
133133

134134
void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
135135
int nregs, void __iomem *base, char *prefix);
@@ -304,11 +304,10 @@ static inline struct dentry *debugfs_create_blob(const char *name, umode_t mode,
304304
return ERR_PTR(-ENODEV);
305305
}
306306

307-
static inline struct dentry *debugfs_create_regset32(const char *name,
308-
umode_t mode, struct dentry *parent,
309-
struct debugfs_regset32 *regset)
307+
static inline void debugfs_create_regset32(const char *name, umode_t mode,
308+
struct dentry *parent,
309+
struct debugfs_regset32 *regset)
310310
{
311-
return ERR_PTR(-ENODEV);
312311
}
313312

314313
static inline void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,

include/linux/device.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,17 @@ static inline struct device_node *dev_of_node(struct device *dev)
798798
return dev->of_node;
799799
}
800800

801+
static inline bool dev_has_sync_state(struct device *dev)
802+
{
803+
if (!dev)
804+
return false;
805+
if (dev->driver && dev->driver->sync_state)
806+
return true;
807+
if (dev->bus && dev->bus->sync_state)
808+
return true;
809+
return false;
810+
}
811+
801812
/*
802813
* High level routines for use by the bus drivers
803814
*/

0 commit comments

Comments
 (0)