Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'driver-core-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
"Here are all of the driver core and related patches for 4.19-rc1.

Nothing huge here, just a number of small cleanups and the ability to
now stop the deferred probing after init happens.

All of these have been in linux-next for a while with only a merge
issue reported"

* tag 'driver-core-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (21 commits)
base: core: Remove WARN_ON from link dependencies check
drivers/base: stop new probing during shutdown
drivers: core: Remove glue dirs from sysfs earlier
driver core: remove unnecessary function extern declare
sysfs.h: fix non-kernel-doc comment
PM / Domains: Stop deferring probe at the end of initcall
iommu: Remove IOMMU_OF_DECLARE
iommu: Stop deferring probe at end of initcalls
pinctrl: Support stopping deferred probe after initcalls
dt-bindings: pinctrl: add a 'pinctrl-use-default' property
driver core: allow stopping deferred probe after init
driver core: add a debugfs entry to show deferred devices
sysfs: Fix internal_create_group() for named group updates
base: fix order of OF initialization
linux/device.h: fix kernel-doc notation warning
Documentation: update firmware loader fallback reference
kobject: Replace strncpy with memcpy
drivers: base: cacheinfo: use OF property_read_u32 instead of get_property,read_number
kernfs: Replace strncpy with memcpy
device: Add #define dev_fmt similar to #define pr_fmt
...

+272 -161
+9
Documentation/admin-guide/kernel-parameters.txt
··· 812 812 Defaults to the default architecture's huge page size 813 813 if not specified. 814 814 815 + deferred_probe_timeout= 816 + [KNL] Debugging option to set a timeout in seconds for 817 + deferred probe to give up waiting on dependencies to 818 + probe. Only specific dependencies (subsystems or 819 + drivers) that have opted in will be ignored. A timeout of 0 820 + will timeout at the end of initcalls. This option will also 821 + dump out devices still on the deferred probe list after 822 + retrying. 823 + 815 824 dhash_entries= [KNL] 816 825 Set number of hash buckets for dentry cache. 817 826
+6
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
··· 103 103 #pinctrl-cells: Number of pin control cells in addition to the index within the 104 104 pin controller device instance 105 105 106 + pinctrl-use-default: Boolean. Indicates that the OS can use the boot default 107 + pin configuration. This allows using an OS that does not have a 108 + driver for the pin controller. This property can be set either 109 + globally for the pin controller or in child nodes for individual 110 + pin group control. 111 + 106 112 Pin controller devices should contain the pin configuration nodes that client 107 113 devices reference. 108 114
+6 -1
Documentation/driver-api/firmware/fallback-mechanisms.rst
··· 92 92 93 93 The firmware device used to help load firmware using sysfs is only created if 94 94 direct firmware loading fails and if the fallback mechanism is enabled for your 95 - firmware request, this is set up with fw_load_from_user_helper(). It is 95 + firmware request, this is set up with :c:func:`firmware_fallback_sysfs`. It is 96 96 important to re-iterate that no device is created if a direct filesystem lookup 97 97 succeeded. 98 98 ··· 107 107 firmware_data_read() and firmware_loading_show() are just provided for the 108 108 test_firmware driver for testing, they are not called in normal use or 109 109 expected to be used regularly by userspace. 110 + 111 + firmware_fallback_sysfs 112 + ----------------------- 113 + .. kernel-doc:: drivers/base/firmware_loader/fallback.c 114 + :functions: firmware_fallback_sysfs 110 115 111 116 Firmware kobject uevent fallback mechanism 112 117 ==========================================
-2
drivers/base/base.h
··· 84 84 #define to_device_private_bus(obj) \ 85 85 container_of(obj, struct device_private, knode_bus) 86 86 87 - extern int device_private_init(struct device *dev); 88 - 89 87 /* initialisation functions */ 90 88 extern int devices_init(void); 91 89 extern int buses_init(void);
+10 -14
drivers/base/cacheinfo.c
··· 74 74 static void cache_size(struct cacheinfo *this_leaf, struct device_node *np) 75 75 { 76 76 const char *propname; 77 - const __be32 *cache_size; 78 77 int ct_idx; 79 78 80 79 ct_idx = get_cacheinfo_idx(this_leaf->type); 81 80 propname = cache_type_info[ct_idx].size_prop; 82 81 83 - cache_size = of_get_property(np, propname, NULL); 84 - if (cache_size) 85 - this_leaf->size = of_read_number(cache_size, 1); 82 + if (of_property_read_u32(np, propname, &this_leaf->size)) 83 + this_leaf->size = 0; 86 84 } 87 85 88 86 /* not cache_line_size() because that's a macro in include/linux/cache.h */ 89 87 static void cache_get_line_size(struct cacheinfo *this_leaf, 90 88 struct device_node *np) 91 89 { 92 - const __be32 *line_size; 93 90 int i, lim, ct_idx; 94 91 95 92 ct_idx = get_cacheinfo_idx(this_leaf->type); 96 93 lim = ARRAY_SIZE(cache_type_info[ct_idx].line_size_props); 97 94 98 95 for (i = 0; i < lim; i++) { 96 + int ret; 97 + u32 line_size; 99 98 const char *propname; 100 99 101 100 propname = cache_type_info[ct_idx].line_size_props[i]; 102 - line_size = of_get_property(np, propname, NULL); 103 - if (line_size) 101 + ret = of_property_read_u32(np, propname, &line_size); 102 + if (!ret) { 103 + this_leaf->coherency_line_size = line_size; 104 104 break; 105 + } 105 106 } 106 - 107 - if (line_size) 108 - this_leaf->coherency_line_size = of_read_number(line_size, 1); 109 107 } 110 108 111 109 static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np) 112 110 { 113 111 const char *propname; 114 - const __be32 *nr_sets; 115 112 int ct_idx; 116 113 117 114 ct_idx = get_cacheinfo_idx(this_leaf->type); 118 115 propname = cache_type_info[ct_idx].nr_sets_prop; 119 116 120 - nr_sets = of_get_property(np, propname, NULL); 121 - if (nr_sets) 122 - this_leaf->number_of_sets = of_read_number(nr_sets, 1); 117 + if (of_property_read_u32(np, propname, &this_leaf->number_of_sets)) 118 + this_leaf->number_of_sets = 0; 123 119 } 124 120 125 121 static void cache_associativity(struct cacheinfo *this_leaf)
+14 -9
drivers/base/core.c
··· 105 105 struct device_link *link; 106 106 int ret; 107 107 108 - if (WARN_ON(dev == target)) 108 + if (dev == target) 109 109 return 1; 110 110 111 111 ret = device_for_each_child(dev, target, device_is_dependent); ··· 113 113 return ret; 114 114 115 115 list_for_each_entry(link, &dev->links.consumers, s_node) { 116 - if (WARN_ON(link->consumer == target)) 116 + if (link->consumer == target) 117 117 return 1; 118 118 119 119 ret = device_is_dependent(link->consumer, target); ··· 1647 1647 return; 1648 1648 1649 1649 mutex_lock(&gdp_mutex); 1650 + if (!kobject_has_children(glue_dir)) 1651 + kobject_del(glue_dir); 1650 1652 kobject_put(glue_dir); 1651 1653 mutex_unlock(&gdp_mutex); 1652 1654 } ··· 1788 1786 } 1789 1787 } 1790 1788 1791 - int device_private_init(struct device *dev) 1789 + static int device_private_init(struct device *dev) 1792 1790 { 1793 1791 dev->p = kzalloc(sizeof(*dev->p), GFP_KERNEL); 1794 1792 if (!dev->p) ··· 2861 2859 { 2862 2860 struct device *dev, *parent; 2863 2861 2862 + wait_for_device_probe(); 2863 + device_block_probing(); 2864 + 2864 2865 spin_lock(&devices_kset->list_lock); 2865 2866 /* 2866 2867 * Walk the devices list backward, shutting down each in turn. ··· 3057 3052 } \ 3058 3053 EXPORT_SYMBOL(func); 3059 3054 3060 - define_dev_printk_level(dev_emerg, KERN_EMERG); 3061 - define_dev_printk_level(dev_alert, KERN_ALERT); 3062 - define_dev_printk_level(dev_crit, KERN_CRIT); 3063 - define_dev_printk_level(dev_err, KERN_ERR); 3064 - define_dev_printk_level(dev_warn, KERN_WARNING); 3065 - define_dev_printk_level(dev_notice, KERN_NOTICE); 3055 + define_dev_printk_level(_dev_emerg, KERN_EMERG); 3056 + define_dev_printk_level(_dev_alert, KERN_ALERT); 3057 + define_dev_printk_level(_dev_crit, KERN_CRIT); 3058 + define_dev_printk_level(_dev_err, KERN_ERR); 3059 + define_dev_printk_level(_dev_warn, KERN_WARNING); 3060 + define_dev_printk_level(_dev_notice, KERN_NOTICE); 3066 3061 define_dev_printk_level(_dev_info, KERN_INFO); 3067 3062 3068 3063 #endif
+108 -26
drivers/base/dd.c
··· 16 16 * Copyright (c) 2007-2009 Novell Inc. 17 17 */ 18 18 19 + #include <linux/debugfs.h> 19 20 #include <linux/device.h> 20 21 #include <linux/delay.h> 21 22 #include <linux/dma-mapping.h> ··· 54 53 static LIST_HEAD(deferred_probe_pending_list); 55 54 static LIST_HEAD(deferred_probe_active_list); 56 55 static atomic_t deferred_trigger_count = ATOMIC_INIT(0); 56 + static struct dentry *deferred_devices; 57 57 static bool initcalls_done; 58 58 59 59 /* ··· 63 61 * Once defer_all_probes is true all drivers probes will be forcibly deferred. 64 62 */ 65 63 static bool defer_all_probes; 66 - 67 - /* 68 - * For initcall_debug, show the deferred probes executed in late_initcall 69 - * processing. 70 - */ 71 - static void deferred_probe_debug(struct device *dev) 72 - { 73 - ktime_t calltime, delta, rettime; 74 - unsigned long long duration; 75 - 76 - printk(KERN_DEBUG "deferred probe %s @ %i\n", dev_name(dev), 77 - task_pid_nr(current)); 78 - calltime = ktime_get(); 79 - bus_probe_device(dev); 80 - rettime = ktime_get(); 81 - delta = ktime_sub(rettime, calltime); 82 - duration = (unsigned long long) ktime_to_ns(delta) >> 10; 83 - printk(KERN_DEBUG "deferred probe %s returned after %lld usecs\n", 84 - dev_name(dev), duration); 85 - } 86 64 87 65 /* 88 66 * deferred_probe_work_func() - Retry probing devices in the active list. ··· 107 125 device_pm_move_to_tail(dev); 108 126 109 127 dev_dbg(dev, "Retrying from deferred list\n"); 110 - if (initcall_debug && !initcalls_done) 111 - deferred_probe_debug(dev); 112 - else 113 - bus_probe_device(dev); 114 - 128 + bus_probe_device(dev); 115 129 mutex_lock(&deferred_probe_mutex); 116 130 117 131 put_device(dev); ··· 202 224 driver_deferred_probe_trigger(); 203 225 } 204 226 227 + /* 228 + * deferred_devs_show() - Show the devices in the deferred probe pending list. 229 + */ 230 + static int deferred_devs_show(struct seq_file *s, void *data) 231 + { 232 + struct device_private *curr; 233 + 234 + mutex_lock(&deferred_probe_mutex); 235 + 236 + list_for_each_entry(curr, &deferred_probe_pending_list, deferred_probe) 237 + seq_printf(s, "%s\n", dev_name(curr->device)); 238 + 239 + mutex_unlock(&deferred_probe_mutex); 240 + 241 + return 0; 242 + } 243 + DEFINE_SHOW_ATTRIBUTE(deferred_devs); 244 + 245 + static int deferred_probe_timeout = -1; 246 + static int __init deferred_probe_timeout_setup(char *str) 247 + { 248 + deferred_probe_timeout = simple_strtol(str, NULL, 10); 249 + return 1; 250 + } 251 + __setup("deferred_probe_timeout=", deferred_probe_timeout_setup); 252 + 253 + /** 254 + * driver_deferred_probe_check_state() - Check deferred probe state 255 + * @dev: device to check 256 + * 257 + * Returns -ENODEV if init is done and all built-in drivers have had a chance 258 + * to probe (i.e. initcalls are done), -ETIMEDOUT if deferred probe debug 259 + * timeout has expired, or -EPROBE_DEFER if none of those conditions are met. 260 + * 261 + * Drivers or subsystems can opt-in to calling this function instead of directly 262 + * returning -EPROBE_DEFER. 263 + */ 264 + int driver_deferred_probe_check_state(struct device *dev) 265 + { 266 + if (initcalls_done) { 267 + if (!deferred_probe_timeout) { 268 + dev_WARN(dev, "deferred probe timeout, ignoring dependency"); 269 + return -ETIMEDOUT; 270 + } 271 + dev_warn(dev, "ignoring dependency for device, assuming no driver"); 272 + return -ENODEV; 273 + } 274 + return -EPROBE_DEFER; 275 + } 276 + 277 + static void deferred_probe_timeout_work_func(struct work_struct *work) 278 + { 279 + struct device_private *private, *p; 280 + 281 + deferred_probe_timeout = 0; 282 + driver_deferred_probe_trigger(); 283 + flush_work(&deferred_probe_work); 284 + 285 + list_for_each_entry_safe(private, p, &deferred_probe_pending_list, deferred_probe) 286 + dev_info(private->device, "deferred probe pending"); 287 + } 288 + static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func); 289 + 205 290 /** 206 291 * deferred_probe_initcall() - Enable probing of deferred devices 207 292 * ··· 274 233 */ 275 234 static int deferred_probe_initcall(void) 276 235 { 236 + deferred_devices = debugfs_create_file("devices_deferred", 0444, NULL, 237 + NULL, &deferred_devs_fops); 238 + 277 239 driver_deferred_probe_enable = true; 278 240 driver_deferred_probe_trigger(); 279 241 /* Sort as many dependencies as possible before exiting initcalls */ 280 242 flush_work(&deferred_probe_work); 281 243 initcalls_done = true; 244 + 245 + /* 246 + * Trigger deferred probe again, this time we won't defer anything 247 + * that is optional 248 + */ 249 + driver_deferred_probe_trigger(); 250 + flush_work(&deferred_probe_work); 251 + 252 + if (deferred_probe_timeout > 0) { 253 + schedule_delayed_work(&deferred_probe_timeout_work, 254 + deferred_probe_timeout * HZ); 255 + } 282 256 return 0; 283 257 } 284 258 late_initcall(deferred_probe_initcall); 259 + 260 + static void __exit deferred_probe_exit(void) 261 + { 262 + debugfs_remove_recursive(deferred_devices); 263 + } 264 + __exitcall(deferred_probe_exit); 285 265 286 266 /** 287 267 * device_is_bound() - Check if device is bound to a driver ··· 581 519 return ret; 582 520 } 583 521 522 + /* 523 + * For initcall_debug, show the driver probe time. 524 + */ 525 + static int really_probe_debug(struct device *dev, struct device_driver *drv) 526 + { 527 + ktime_t calltime, delta, rettime; 528 + int ret; 529 + 530 + calltime = ktime_get(); 531 + ret = really_probe(dev, drv); 532 + rettime = ktime_get(); 533 + delta = ktime_sub(rettime, calltime); 534 + printk(KERN_DEBUG "probe of %s returned %d after %lld usecs\n", 535 + dev_name(dev), ret, (s64) ktime_to_us(delta)); 536 + return ret; 537 + } 538 + 584 539 /** 585 540 * driver_probe_done 586 541 * Determine if the probe sequence is finished or not. ··· 656 577 pm_runtime_get_sync(dev->parent); 657 578 658 579 pm_runtime_barrier(dev); 659 - ret = really_probe(dev, drv); 580 + if (initcall_debug) 581 + ret = really_probe_debug(dev, drv); 582 + else 583 + ret = really_probe(dev, drv); 660 584 pm_request_idle(dev); 661 585 662 586 if (dev->parent)
+1 -1
drivers/base/init.c
··· 30 30 /* These are also core pieces, but must come after the 31 31 * core core pieces. 32 32 */ 33 + of_core_init(); 33 34 platform_bus_init(); 34 35 cpu_dev_init(); 35 36 memory_dev_init(); 36 37 container_dev_init(); 37 - of_core_init(); 38 38 }
+1 -1
drivers/base/power/domain.c
··· 2253 2253 mutex_unlock(&gpd_list_lock); 2254 2254 dev_dbg(dev, "%s() failed to find PM domain: %ld\n", 2255 2255 __func__, PTR_ERR(pd)); 2256 - return -EPROBE_DEFER; 2256 + return driver_deferred_probe_check_state(dev); 2257 2257 } 2258 2258 2259 2259 dev_dbg(dev, "adding to PM domain %s\n", pd->name);
-2
drivers/iommu/arm-smmu-v3.c
··· 2915 2915 }; 2916 2916 module_platform_driver(arm_smmu_driver); 2917 2917 2918 - IOMMU_OF_DECLARE(arm_smmuv3, "arm,smmu-v3"); 2919 - 2920 2918 MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations"); 2921 2919 MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>"); 2922 2920 MODULE_LICENSE("GPL v2");
-7
drivers/iommu/arm-smmu.c
··· 2211 2211 }; 2212 2212 module_platform_driver(arm_smmu_driver); 2213 2213 2214 - IOMMU_OF_DECLARE(arm_smmuv1, "arm,smmu-v1"); 2215 - IOMMU_OF_DECLARE(arm_smmuv2, "arm,smmu-v2"); 2216 - IOMMU_OF_DECLARE(arm_mmu400, "arm,mmu-400"); 2217 - IOMMU_OF_DECLARE(arm_mmu401, "arm,mmu-401"); 2218 - IOMMU_OF_DECLARE(arm_mmu500, "arm,mmu-500"); 2219 - IOMMU_OF_DECLARE(cavium_smmuv2, "cavium,smmu-v2"); 2220 - 2221 2214 MODULE_DESCRIPTION("IOMMU API for ARM architected SMMU implementations"); 2222 2215 MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>"); 2223 2216 MODULE_LICENSE("GPL v2");
-2
drivers/iommu/exynos-iommu.c
··· 1390 1390 return ret; 1391 1391 } 1392 1392 core_initcall(exynos_iommu_init); 1393 - 1394 - IOMMU_OF_DECLARE(exynos_iommu_of, "samsung,exynos-sysmmu");
-3
drivers/iommu/ipmmu-vmsa.c
··· 1108 1108 subsys_initcall(ipmmu_init); 1109 1109 module_exit(ipmmu_exit); 1110 1110 1111 - IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "renesas,ipmmu-vmsa"); 1112 - IOMMU_OF_DECLARE(ipmmu_r8a7795_iommu_of, "renesas,ipmmu-r8a7795"); 1113 - 1114 1111 MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU"); 1115 1112 MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>"); 1116 1113 MODULE_LICENSE("GPL v2");
-2
drivers/iommu/msm_iommu.c
··· 877 877 subsys_initcall(msm_iommu_driver_init); 878 878 module_exit(msm_iommu_driver_exit); 879 879 880 - IOMMU_OF_DECLARE(msm_iommu_of, "qcom,apq8064-iommu"); 881 - 882 880 MODULE_LICENSE("GPL v2"); 883 881 MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");
+2 -19
drivers/iommu/of_iommu.c
··· 27 27 28 28 #define NO_IOMMU 1 29 29 30 - static const struct of_device_id __iommu_of_table_sentinel 31 - __used __section(__iommu_of_table_end); 32 - 33 30 /** 34 31 * of_get_dma_window - Parse *dma-window property and returns 0 if found. 35 32 * ··· 95 98 } 96 99 EXPORT_SYMBOL_GPL(of_get_dma_window); 97 100 98 - static bool of_iommu_driver_present(struct device_node *np) 99 - { 100 - /* 101 - * If the IOMMU still isn't ready by the time we reach init, assume 102 - * it never will be. We don't want to defer indefinitely, nor attempt 103 - * to dereference __iommu_of_table after it's been freed. 104 - */ 105 - if (system_state >= SYSTEM_RUNNING) 106 - return false; 107 - 108 - return of_match_node(&__iommu_of_table, np); 109 - } 110 - 111 101 static int of_iommu_xlate(struct device *dev, 112 102 struct of_phandle_args *iommu_spec) 113 103 { ··· 104 120 105 121 ops = iommu_ops_from_fwnode(fwnode); 106 122 if ((ops && !ops->of_xlate) || 107 - !of_device_is_available(iommu_spec->np) || 108 - (!ops && !of_iommu_driver_present(iommu_spec->np))) 123 + !of_device_is_available(iommu_spec->np)) 109 124 return NO_IOMMU; 110 125 111 126 err = iommu_fwspec_init(dev, &iommu_spec->np->fwnode, ops); ··· 116 133 * a proper probe-ordering dependency mechanism in future. 117 134 */ 118 135 if (!ops) 119 - return -EPROBE_DEFER; 136 + return driver_deferred_probe_check_state(dev); 120 137 121 138 return ops->of_xlate(dev, iommu_spec); 122 139 }
-2
drivers/iommu/qcom_iommu.c
··· 945 945 module_init(qcom_iommu_init); 946 946 module_exit(qcom_iommu_exit); 947 947 948 - IOMMU_OF_DECLARE(qcom_iommu_dev, "qcom,msm-iommu-v1"); 949 - 950 948 MODULE_DESCRIPTION("IOMMU API for QCOM IOMMU v1 implementations"); 951 949 MODULE_LICENSE("GPL v2");
-2
drivers/iommu/rockchip-iommu.c
··· 1284 1284 } 1285 1285 subsys_initcall(rk_iommu_init); 1286 1286 1287 - IOMMU_OF_DECLARE(rk_iommu_of, "rockchip,iommu"); 1288 - 1289 1287 MODULE_DESCRIPTION("IOMMU API for Rockchip"); 1290 1288 MODULE_AUTHOR("Simon Xue <xxm@rock-chips.com> and Daniel Kurtz <djkurtz@chromium.org>"); 1291 1289 MODULE_ALIAS("platform:rockchip-iommu");
+11 -4
drivers/pinctrl/devicetree.c
··· 111 111 int ret; 112 112 struct pinctrl_map *map; 113 113 unsigned num_maps; 114 + bool allow_default = false; 114 115 115 116 /* Find the pin controller containing np_config */ 116 117 np_pctldev = of_node_get(np_config); 117 118 for (;;) { 119 + if (!allow_default) 120 + allow_default = of_property_read_bool(np_pctldev, 121 + "pinctrl-use-default"); 122 + 118 123 np_pctldev = of_get_next_parent(np_pctldev); 119 124 if (!np_pctldev || of_node_is_root(np_pctldev)) { 120 - dev_info(p->dev, "could not find pctldev for node %pOF, deferring probe\n", 121 - np_config); 122 125 of_node_put(np_pctldev); 123 - /* OK let's just assume this will appear later then */ 124 - return -EPROBE_DEFER; 126 + ret = driver_deferred_probe_check_state(p->dev); 127 + /* keep deferring if modules are enabled unless we've timed out */ 128 + if (IS_ENABLED(CONFIG_MODULES) && !allow_default && ret == -ENODEV) 129 + ret = -EPROBE_DEFER; 130 + 131 + return ret; 125 132 } 126 133 /* If we're creating a hog we can use the passed pctldev */ 127 134 if (hog_pctldev && (np_pctldev == p->dev->of_node)) {
+1 -1
fs/kernfs/symlink.c
··· 97 97 int slen = strlen(kn->name); 98 98 99 99 len -= slen; 100 - strncpy(s + len, kn->name, slen); 100 + memcpy(s + len, kn->name, slen); 101 101 if (len) 102 102 s[--len] = '/'; 103 103
+22 -8
fs/sysfs/group.c
··· 124 124 } 125 125 kobject_get_ownership(kobj, &uid, &gid); 126 126 if (grp->name) { 127 - kn = kernfs_create_dir_ns(kobj->sd, grp->name, 128 - S_IRWXU | S_IRUGO | S_IXUGO, 129 - uid, gid, kobj, NULL); 130 - if (IS_ERR(kn)) { 131 - if (PTR_ERR(kn) == -EEXIST) 132 - sysfs_warn_dup(kobj->sd, grp->name); 133 - return PTR_ERR(kn); 127 + if (update) { 128 + kn = kernfs_find_and_get(kobj->sd, grp->name); 129 + if (!kn) { 130 + pr_warn("Can't update unknown attr grp name: %s/%s\n", 131 + kobj->name, grp->name); 132 + return -EINVAL; 133 + } 134 + } else { 135 + kn = kernfs_create_dir_ns(kobj->sd, grp->name, 136 + S_IRWXU | S_IRUGO | S_IXUGO, 137 + uid, gid, kobj, NULL); 138 + if (IS_ERR(kn)) { 139 + if (PTR_ERR(kn) == -EEXIST) 140 + sysfs_warn_dup(kobj->sd, grp->name); 141 + return PTR_ERR(kn); 142 + } 134 143 } 135 144 } else 136 145 kn = kobj->sd; ··· 150 141 kernfs_remove(kn); 151 142 } 152 143 kernfs_put(kn); 144 + 145 + if (grp->name && update) 146 + kernfs_put(kn); 147 + 153 148 return error; 154 149 } 155 150 ··· 218 205 * of the attribute files being created already exist. Furthermore, 219 206 * if the visibility of the files has changed through the is_visible() 220 207 * callback, it will update the permissions and add or remove the 221 - * relevant files. 208 + * relevant files. Changing a group's name (subdirectory name under 209 + * kobj's directory in sysfs) is not allowed. 222 210 * 223 211 * The primary use for this function is to call it after making a change 224 212 * that affects group visibility.
-2
include/asm-generic/vmlinux.lds.h
··· 218 218 #define TIMER_OF_TABLES() OF_TABLE(CONFIG_TIMER_OF, timer) 219 219 #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip) 220 220 #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) 221 - #define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu) 222 221 #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) 223 222 #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) 224 223 #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method) ··· 600 601 CLK_OF_TABLES() \ 601 602 RESERVEDMEM_OF_TABLES() \ 602 603 TIMER_OF_TABLES() \ 603 - IOMMU_OF_TABLES() \ 604 604 CPU_METHOD_OF_TABLES() \ 605 605 CPUIDLE_METHOD_OF_TABLES() \ 606 606 KERNEL_DTB() \
+60 -45
include/linux/device.h
··· 339 339 struct device *start, void *data, 340 340 int (*match)(struct device *dev, void *data)); 341 341 342 + int driver_deferred_probe_check_state(struct device *dev); 343 + 342 344 /** 343 345 * struct subsys_interface - interfaces to device functions 344 346 * @name: name of the device function ··· 1331 1329 void device_link_del(struct device_link *link); 1332 1330 void device_link_remove(void *consumer, struct device *supplier); 1333 1331 1332 + #ifndef dev_fmt 1333 + #define dev_fmt(fmt) fmt 1334 + #endif 1335 + 1334 1336 #ifdef CONFIG_PRINTK 1335 1337 1336 - extern __printf(3, 0) 1338 + __printf(3, 0) 1337 1339 int dev_vprintk_emit(int level, const struct device *dev, 1338 1340 const char *fmt, va_list args); 1339 - extern __printf(3, 4) 1341 + __printf(3, 4) 1340 1342 int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...); 1341 1343 1342 - extern __printf(3, 4) 1344 + __printf(3, 4) 1343 1345 void dev_printk(const char *level, const struct device *dev, 1344 1346 const char *fmt, ...); 1345 - extern __printf(2, 3) 1346 - void dev_emerg(const struct device *dev, const char *fmt, ...); 1347 - extern __printf(2, 3) 1348 - void dev_alert(const struct device *dev, const char *fmt, ...); 1349 - extern __printf(2, 3) 1350 - void dev_crit(const struct device *dev, const char *fmt, ...); 1351 - extern __printf(2, 3) 1352 - void dev_err(const struct device *dev, const char *fmt, ...); 1353 - extern __printf(2, 3) 1354 - void dev_warn(const struct device *dev, const char *fmt, ...); 1355 - extern __printf(2, 3) 1356 - void dev_notice(const struct device *dev, const char *fmt, ...); 1357 - extern __printf(2, 3) 1347 + __printf(2, 3) 1348 + void _dev_emerg(const struct device *dev, const char *fmt, ...); 1349 + __printf(2, 3) 1350 + void _dev_alert(const struct device *dev, const char *fmt, ...); 1351 + __printf(2, 3) 1352 + void _dev_crit(const struct device *dev, const char *fmt, ...); 1353 + __printf(2, 3) 1354 + void _dev_err(const struct device *dev, const char *fmt, ...); 1355 + __printf(2, 3) 1356 + void _dev_warn(const struct device *dev, const char *fmt, ...); 1357 + __printf(2, 3) 1358 + void _dev_notice(const struct device *dev, const char *fmt, ...); 1359 + __printf(2, 3) 1358 1360 void _dev_info(const struct device *dev, const char *fmt, ...); 1359 1361 1360 1362 #else ··· 1376 1370 {} 1377 1371 static inline __printf(3, 4) 1378 1372 void dev_printk(const char *level, const struct device *dev, 1379 - const char *fmt, ...) 1373 + const char *fmt, ...) 1380 1374 {} 1381 1375 1382 1376 static inline __printf(2, 3) 1383 - void dev_emerg(const struct device *dev, const char *fmt, ...) 1377 + void _dev_emerg(const struct device *dev, const char *fmt, ...) 1384 1378 {} 1385 1379 static inline __printf(2, 3) 1386 - void dev_crit(const struct device *dev, const char *fmt, ...) 1380 + void _dev_crit(const struct device *dev, const char *fmt, ...) 1387 1381 {} 1388 1382 static inline __printf(2, 3) 1389 - void dev_alert(const struct device *dev, const char *fmt, ...) 1383 + void _dev_alert(const struct device *dev, const char *fmt, ...) 1390 1384 {} 1391 1385 static inline __printf(2, 3) 1392 - void dev_err(const struct device *dev, const char *fmt, ...) 1386 + void _dev_err(const struct device *dev, const char *fmt, ...) 1393 1387 {} 1394 1388 static inline __printf(2, 3) 1395 - void dev_warn(const struct device *dev, const char *fmt, ...) 1389 + void _dev_warn(const struct device *dev, const char *fmt, ...) 1396 1390 {} 1397 1391 static inline __printf(2, 3) 1398 - void dev_notice(const struct device *dev, const char *fmt, ...) 1392 + void _dev_notice(const struct device *dev, const char *fmt, ...) 1399 1393 {} 1400 1394 static inline __printf(2, 3) 1401 1395 void _dev_info(const struct device *dev, const char *fmt, ...) ··· 1404 1398 #endif 1405 1399 1406 1400 /* 1407 - * Stupid hackaround for existing uses of non-printk uses dev_info 1408 - * 1409 - * Note that the definition of dev_info below is actually _dev_info 1410 - * and a macro is used to avoid redefining dev_info 1401 + * #defines for all the dev_<level> macros to prefix with whatever 1402 + * possible use of #define dev_fmt(fmt) ... 1411 1403 */ 1412 1404 1413 - #define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg) 1405 + #define dev_emerg(dev, fmt, ...) \ 1406 + _dev_emerg(dev, dev_fmt(fmt), ##__VA_ARGS__) 1407 + #define dev_crit(dev, fmt, ...) \ 1408 + _dev_crit(dev, dev_fmt(fmt), ##__VA_ARGS__) 1409 + #define dev_alert(dev, fmt, ...) \ 1410 + _dev_alert(dev, dev_fmt(fmt), ##__VA_ARGS__) 1411 + #define dev_err(dev, fmt, ...) \ 1412 + _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__) 1413 + #define dev_warn(dev, fmt, ...) \ 1414 + _dev_warn(dev, dev_fmt(fmt), ##__VA_ARGS__) 1415 + #define dev_notice(dev, fmt, ...) \ 1416 + _dev_notice(dev, dev_fmt(fmt), ##__VA_ARGS__) 1417 + #define dev_info(dev, fmt, ...) \ 1418 + _dev_info(dev, dev_fmt(fmt), ##__VA_ARGS__) 1414 1419 1415 1420 #if defined(CONFIG_DYNAMIC_DEBUG) 1416 - #define dev_dbg(dev, format, ...) \ 1417 - do { \ 1418 - dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ 1419 - } while (0) 1421 + #define dev_dbg(dev, fmt, ...) \ 1422 + dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__) 1420 1423 #elif defined(DEBUG) 1421 - #define dev_dbg(dev, format, arg...) \ 1422 - dev_printk(KERN_DEBUG, dev, format, ##arg) 1424 + #define dev_dbg(dev, fmt, ...) \ 1425 + dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) 1423 1426 #else 1424 - #define dev_dbg(dev, format, arg...) \ 1425 - ({ \ 1426 - if (0) \ 1427 - dev_printk(KERN_DEBUG, dev, format, ##arg); \ 1427 + #define dev_dbg(dev, fmt, ...) \ 1428 + ({ \ 1429 + if (0) \ 1430 + dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ 1428 1431 }) 1429 1432 #endif 1430 1433 ··· 1505 1490 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ 1506 1491 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ 1507 1492 __ratelimit(&_rs)) \ 1508 - __dynamic_dev_dbg(&descriptor, dev, fmt, \ 1493 + __dynamic_dev_dbg(&descriptor, dev, dev_fmt(fmt), \ 1509 1494 ##__VA_ARGS__); \ 1510 1495 } while (0) 1511 1496 #elif defined(DEBUG) ··· 1515 1500 DEFAULT_RATELIMIT_INTERVAL, \ 1516 1501 DEFAULT_RATELIMIT_BURST); \ 1517 1502 if (__ratelimit(&_rs)) \ 1518 - dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ 1503 + dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ 1519 1504 } while (0) 1520 1505 #else 1521 1506 #define dev_dbg_ratelimited(dev, fmt, ...) \ 1522 1507 do { \ 1523 1508 if (0) \ 1524 - dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ 1509 + dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ 1525 1510 } while (0) 1526 1511 #endif 1527 1512 1528 1513 #ifdef VERBOSE_DEBUG 1529 1514 #define dev_vdbg dev_dbg 1530 1515 #else 1531 - #define dev_vdbg(dev, format, arg...) \ 1532 - ({ \ 1533 - if (0) \ 1534 - dev_printk(KERN_DEBUG, dev, format, ##arg); \ 1516 + #define dev_vdbg(dev, fmt, ...) \ 1517 + ({ \ 1518 + if (0) \ 1519 + dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ 1535 1520 }) 1536 1521 #endif 1537 1522
+17
include/linux/kobject.h
··· 119 119 kuid_t *uid, kgid_t *gid); 120 120 extern char *kobject_get_path(struct kobject *kobj, gfp_t flag); 121 121 122 + /** 123 + * kobject_has_children - Returns whether a kobject has children. 124 + * @kobj: the object to test 125 + * 126 + * This will return whether a kobject has other kobjects as children. 127 + * 128 + * It does NOT account for the presence of attribute files, only sub 129 + * directories. It also assumes there is no concurrent addition or 130 + * removal of such children, and thus relies on external locking. 131 + */ 132 + static inline bool kobject_has_children(struct kobject *kobj) 133 + { 134 + WARN_ON_ONCE(kref_read(&kobj->kref) == 0); 135 + 136 + return kobj->sd && kobj->sd->dir.subdirs; 137 + } 138 + 122 139 struct kobj_type { 123 140 void (*release)(struct kobject *kobj); 124 141 const struct sysfs_ops *sysfs_ops;
-4
include/linux/of_iommu.h
··· 32 32 33 33 #endif /* CONFIG_OF_IOMMU */ 34 34 35 - extern struct of_device_id __iommu_of_table; 36 - 37 - #define IOMMU_OF_DECLARE(name, compat) OF_DECLARE_1(iommu, name, compat, NULL) 38 - 39 35 #endif /* __OF_IOMMU_H */
+3 -3
include/linux/sysfs.h
··· 91 91 struct bin_attribute **bin_attrs; 92 92 }; 93 93 94 - /** 95 - * Use these macros to make defining attributes easier. See include/linux/device.h 96 - * for examples.. 94 + /* 95 + * Use these macros to make defining attributes easier. 96 + * See include/linux/device.h for examples.. 97 97 */ 98 98 99 99 #define SYSFS_PREALLOC 010000
+1 -1
lib/kobject.c
··· 144 144 int cur = strlen(kobject_name(parent)); 145 145 /* back up enough to print this name with '/' */ 146 146 length -= cur; 147 - strncpy(path + length, kobject_name(parent), cur); 147 + memcpy(path + length, kobject_name(parent), cur); 148 148 *(path + --length) = '/'; 149 149 } 150 150