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()

Changed files
+44 -30
Documentation
filesystems
drivers
base
fs
debugfs
include
+3 -3
Documentation/filesystems/debugfs.txt
··· 164 164 void __iomem *base; 165 165 }; 166 166 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); 170 170 171 171 void debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs, 172 172 int nregs, void __iomem *base, char *prefix);
+20 -7
drivers/base/core.c
··· 718 718 { 719 719 struct device_link *link; 720 720 721 + if (!dev_has_sync_state(dev)) 722 + return; 721 723 if (dev->state_synced) 722 724 return; 723 725 ··· 747 745 /** 748 746 * device_links_flush_sync_list - Call sync_state() on a list of devices 749 747 * @list: List of devices to call sync_state() on 748 + * @dont_lock_dev: Device for which lock is already held by the caller 750 749 * 751 750 * Calls sync_state() on all the devices that have been queued for it. This 752 - * function is used in conjunction with __device_links_queue_sync_state(). 751 + * function is used in conjunction with __device_links_queue_sync_state(). The 752 + * @dont_lock_dev parameter is useful when this function is called from a 753 + * context where a device lock is already held. 753 754 */ 754 - static void device_links_flush_sync_list(struct list_head *list) 755 + static void device_links_flush_sync_list(struct list_head *list, 756 + struct device *dont_lock_dev) 755 757 { 756 758 struct device *dev, *tmp; 757 759 758 760 list_for_each_entry_safe(dev, tmp, list, links.defer_sync) { 759 761 list_del_init(&dev->links.defer_sync); 760 762 761 - device_lock(dev); 763 + if (dev != dont_lock_dev) 764 + device_lock(dev); 762 765 763 766 if (dev->bus->sync_state) 764 767 dev->bus->sync_state(dev); 765 768 else if (dev->driver && dev->driver->sync_state) 766 769 dev->driver->sync_state(dev); 767 770 768 - device_unlock(dev); 771 + if (dev != dont_lock_dev) 772 + device_unlock(dev); 769 773 770 774 put_device(dev); 771 775 } ··· 809 801 out: 810 802 device_links_write_unlock(); 811 803 812 - device_links_flush_sync_list(&sync_list); 804 + device_links_flush_sync_list(&sync_list, NULL); 813 805 } 814 806 815 807 static int sync_state_resume_initcall(void) ··· 821 813 822 814 static void __device_links_supplier_defer_sync(struct device *sup) 823 815 { 824 - if (list_empty(&sup->links.defer_sync)) 816 + if (list_empty(&sup->links.defer_sync) && dev_has_sync_state(sup)) 825 817 list_add_tail(&sup->links.defer_sync, &deferred_sync); 826 818 } 827 819 ··· 873 865 driver_deferred_probe_add(link->consumer); 874 866 } 875 867 868 + if (defer_sync_state_count) 869 + __device_links_supplier_defer_sync(dev); 870 + else 871 + __device_links_queue_sync_state(dev, &sync_list); 872 + 876 873 list_for_each_entry(link, &dev->links.suppliers, c_node) { 877 874 if (!(link->flags & DL_FLAG_MANAGED)) 878 875 continue; ··· 896 883 897 884 device_links_write_unlock(); 898 885 899 - device_links_flush_sync_list(&sync_list); 886 + device_links_flush_sync_list(&sync_list, dev); 900 887 } 901 888 902 889 static void device_link_drop_managed(struct device_link *link)
+4 -13
fs/debugfs/file.c
··· 1090 1090 * This function creates a file in debugfs with the given name that reports 1091 1091 * the names and values of a set of 32-bit registers. If the @mode variable 1092 1092 * 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. 1102 1093 */ 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) 1106 1097 { 1107 - return debugfs_create_file(name, mode, parent, regset, &fops_regset32); 1098 + debugfs_create_file(name, mode, parent, regset, &fops_regset32); 1108 1099 } 1109 1100 EXPORT_SYMBOL_GPL(debugfs_create_regset32); 1110 1101
+6 -7
include/linux/debugfs.h
··· 127 127 struct dentry *parent, 128 128 struct debugfs_blob_wrapper *blob); 129 129 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); 133 133 134 134 void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, 135 135 int nregs, void __iomem *base, char *prefix); ··· 304 304 return ERR_PTR(-ENODEV); 305 305 } 306 306 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) 310 310 { 311 - return ERR_PTR(-ENODEV); 312 311 } 313 312 314 313 static inline void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
+11
include/linux/device.h
··· 798 798 return dev->of_node; 799 799 } 800 800 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 + 801 812 /* 802 813 * High level routines for use by the bus drivers 803 814 */