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

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

Pull driver core updates from Greg KH:
"Here is a small set of driver core updates and additions for 6.6-rc1.

Included in here are:

- stable kernel documentation updates

- class structure const work from Ivan on various subsystems

- kernfs tweaks

- driver core tests!

- kobject sanity cleanups

- kobject structure reordering to save space

- driver core error code handling fixups

- other minor driver core cleanups

All of these have been in linux-next for a while with no reported
problems"

* tag 'driver-core-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (32 commits)
driver core: Call in reversed order in device_platform_notify_remove()
driver core: Return proper error code when dev_set_name() fails
kobject: Remove redundant checks for whether ktype is NULL
kobject: Add sanity check for kset->kobj.ktype in kset_register()
drivers: base: test: Add missing MODULE_* macros to root device tests
drivers: base: test: Add missing MODULE_* macros for platform devices tests
drivers: base: Free devm resources when unregistering a device
drivers: base: Add basic devm tests for platform devices
drivers: base: Add basic devm tests for root devices
kernfs: fix missing kernfs_iattr_rwsem locking
docs: stable-kernel-rules: mention that regressions must be prevented
docs: stable-kernel-rules: fine-tune various details
docs: stable-kernel-rules: make the examples for option 1 a proper list
docs: stable-kernel-rules: move text around to improve flow
docs: stable-kernel-rules: improve structure by changing headlines
base/node: Remove duplicated include
kernfs: attach uuid for every kernfs and report it in fsid
kernfs: add stub helper for kernfs_generic_poll()
x86/resctrl: make pseudo_lock_class a static const structure
x86/MSR: make msr_class a static const structure
...

+749 -298
+114 -83
Documentation/process/stable-kernel-rules.rst
··· 6 6 Rules on what kind of patches are accepted, and which ones are not, into the 7 7 "-stable" tree: 8 8 9 + - It or an equivalent fix must already exist in Linus' tree (upstream). 9 10 - It must be obviously correct and tested. 10 11 - It cannot be bigger than 100 lines, with context. 11 - - It must fix only one thing. 12 - - It must fix a real bug that bothers people (not a, "This could be a 13 - problem..." type thing). 14 - - It must fix a problem that causes a build error (but not for things 15 - marked CONFIG_BROKEN), an oops, a hang, data corruption, a real 16 - security issue, or some "oh, that's not good" issue. In short, something 17 - critical. 18 - - Serious issues as reported by a user of a distribution kernel may also 19 - be considered if they fix a notable performance or interactivity issue. 20 - As these fixes are not as obvious and have a higher risk of a subtle 21 - regression they should only be submitted by a distribution kernel 22 - maintainer and include an addendum linking to a bugzilla entry if it 23 - exists and additional information on the user-visible impact. 24 - - New device IDs and quirks are also accepted. 25 - - No "theoretical race condition" issues, unless an explanation of how the 26 - race can be exploited is also provided. 27 - - It cannot contain any "trivial" fixes in it (spelling changes, 28 - whitespace cleanups, etc). 29 12 - It must follow the 30 13 :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` 31 14 rules. 32 - - It or an equivalent fix must already exist in Linus' tree (upstream). 15 + - It must either fix a real bug that bothers people or just add a device ID. 16 + To elaborate on the former: 17 + 18 + - It fixes a problem like an oops, a hang, data corruption, a real security 19 + issue, a hardware quirk, a build error (but not for things marked 20 + CONFIG_BROKEN), or some "oh, that's not good" issue. 21 + - Serious issues as reported by a user of a distribution kernel may also 22 + be considered if they fix a notable performance or interactivity issue. 23 + As these fixes are not as obvious and have a higher risk of a subtle 24 + regression they should only be submitted by a distribution kernel 25 + maintainer and include an addendum linking to a bugzilla entry if it 26 + exists and additional information on the user-visible impact. 27 + - No "This could be a problem..." type of things like a "theoretical race 28 + condition", unless an explanation of how the bug can be exploited is also 29 + provided. 30 + - No "trivial" fixes without benefit for users (spelling changes, whitespace 31 + cleanups, etc). 33 32 34 33 35 34 Procedure for submitting patches to the -stable tree ··· 40 41 process but should follow the procedures in 41 42 :ref:`Documentation/process/security-bugs.rst <securitybugs>`. 42 43 43 - For all other submissions, choose one of the following procedures 44 - ----------------------------------------------------------------- 44 + There are three options to submit a change to -stable trees: 45 + 46 + 1. Add a 'stable tag' to the description of a patch you then submit for 47 + mainline inclusion. 48 + 2. Ask the stable team to pick up a patch already mainlined. 49 + 3. Submit a patch to the stable team that is equivalent to a change already 50 + mainlined. 51 + 52 + The sections below describe each of the options in more detail. 53 + 54 + :ref:`option_1` is **strongly** preferred, it is the easiest and most common. 55 + :ref:`option_2` is mainly meant for changes where backporting was not considered 56 + at the time of submission. :ref:`option_3` is an alternative to the two earlier 57 + options for cases where a mainlined patch needs adjustments to apply in older 58 + series (for example due to API changes). 59 + 60 + When using option 2 or 3 you can ask for your change to be included in specific 61 + stable series. When doing so, ensure the fix or an equivalent is applicable, 62 + submitted, or already present in all newer stable trees still supported. This is 63 + meant to prevent regressions that users might later encounter on updating, if 64 + e.g. a fix merged for 5.19-rc1 would be backported to 5.10.y, but not to 5.15.y. 45 65 46 66 .. _option_1: 47 67 48 68 Option 1 49 69 ******** 50 70 51 - To have the patch automatically included in the stable tree, add the tag 71 + To have a patch you submit for mainline inclusion later automatically picked up 72 + for stable trees, add the tag 52 73 53 74 .. code-block:: none 54 75 55 76 Cc: stable@vger.kernel.org 56 77 57 - in the sign-off area. Once the patch is merged it will be applied to 58 - the stable tree without anything else needing to be done by the author 59 - or subsystem maintainer. 78 + in the sign-off area. Once the patch is mainlined it will be applied to the 79 + stable tree without anything else needing to be done by the author or 80 + subsystem maintainer. 81 + 82 + To sent additional instructions to the stable team, use a shell-style inline 83 + comment: 84 + 85 + * To specify any additional patch prerequisites for cherry picking use the 86 + following format in the sign-off area: 87 + 88 + .. code-block:: none 89 + 90 + Cc: <stable@vger.kernel.org> # 3.3.x: a1f84a3: sched: Check for idle 91 + Cc: <stable@vger.kernel.org> # 3.3.x: 1b9508f: sched: Rate-limit newidle 92 + Cc: <stable@vger.kernel.org> # 3.3.x: fd21073: sched: Fix affinity logic 93 + Cc: <stable@vger.kernel.org> # 3.3.x 94 + Signed-off-by: Ingo Molnar <mingo@elte.hu> 95 + 96 + The tag sequence has the meaning of: 97 + 98 + .. code-block:: none 99 + 100 + git cherry-pick a1f84a3 101 + git cherry-pick 1b9508f 102 + git cherry-pick fd21073 103 + git cherry-pick <this commit> 104 + 105 + * For patches that may have kernel version prerequisites specify them using 106 + the following format in the sign-off area: 107 + 108 + .. code-block:: none 109 + 110 + Cc: <stable@vger.kernel.org> # 3.3.x 111 + 112 + The tag has the meaning of: 113 + 114 + .. code-block:: none 115 + 116 + git cherry-pick <this commit> 117 + 118 + For each "-stable" tree starting with the specified version. 119 + 120 + Note, such tagging is unnecessary if the stable team can derive the 121 + appropriate versions from Fixes: tags. 122 + 123 + * To delay pick up of patches, use the following format: 124 + 125 + .. code-block:: none 126 + 127 + Cc: <stable@vger.kernel.org> # after 4 weeks in mainline 128 + 129 + * For any other requests, just add a note to the stable tag. This for example 130 + can be used to point out known problems: 131 + 132 + .. code-block:: none 133 + 134 + Cc: <stable@vger.kernel.org> # see patch description, needs adjustments for <= 6.3 60 135 61 136 .. _option_2: 62 137 63 138 Option 2 64 139 ******** 65 140 66 - After the patch has been merged to Linus' tree, send an email to 141 + If the patch already has been merged to mainline, send an email to 67 142 stable@vger.kernel.org containing the subject of the patch, the commit ID, 68 - why you think it should be applied, and what kernel version you wish it to 143 + why you think it should be applied, and what kernel versions you wish it to 69 144 be applied to. 70 145 71 146 .. _option_3: ··· 148 75 ******** 149 76 150 77 Send the patch, after verifying that it follows the above rules, to 151 - stable@vger.kernel.org. You must note the upstream commit ID in the 152 - changelog of your submission, as well as the kernel version you wish 153 - it to be applied to. 154 - 155 - :ref:`option_1` is **strongly** preferred, is the easiest and most common. 156 - :ref:`option_2` and :ref:`option_3` are more useful if the patch isn't deemed 157 - worthy at the time it is applied to a public git tree (for instance, because 158 - it deserves more regression testing first). :ref:`option_3` is especially 159 - useful if the original upstream patch needs to be backported (for example 160 - the backport needs some special handling due to e.g. API changes). 161 - 162 - Note that for :ref:`option_3`, if the patch deviates from the original 163 - upstream patch (for example because it had to be backported) this must be very 164 - clearly documented and justified in the patch description. 165 - 166 - The upstream commit ID must be specified with a separate line above the commit 167 - text, like this: 78 + stable@vger.kernel.org and mention the kernel versions you wish it to be applied 79 + to. When doing so, you must note the upstream commit ID in the changelog of your 80 + submission with a separate line above the commit text, like this: 168 81 169 82 .. code-block:: none 170 83 ··· 162 103 163 104 [ Upstream commit <sha1> ] 164 105 165 - Additionally, some patches submitted via :ref:`option_1` may have additional 166 - patch prerequisites which can be cherry-picked. This can be specified in the 167 - following format in the sign-off area: 106 + If the submitted patch deviates from the original upstream patch (for example 107 + because it had to be adjusted for the older API), this must be very clearly 108 + documented and justified in the patch description. 168 109 169 - .. code-block:: none 170 110 171 - Cc: <stable@vger.kernel.org> # 3.3.x: a1f84a3: sched: Check for idle 172 - Cc: <stable@vger.kernel.org> # 3.3.x: 1b9508f: sched: Rate-limit newidle 173 - Cc: <stable@vger.kernel.org> # 3.3.x: fd21073: sched: Fix affinity logic 174 - Cc: <stable@vger.kernel.org> # 3.3.x 175 - Signed-off-by: Ingo Molnar <mingo@elte.hu> 111 + Following the submission 112 + ------------------------ 176 113 177 - The tag sequence has the meaning of: 114 + The sender will receive an ACK when the patch has been accepted into the 115 + queue, or a NAK if the patch is rejected. This response might take a few 116 + days, according to the schedules of the stable team members. 178 117 179 - .. code-block:: none 180 - 181 - git cherry-pick a1f84a3 182 - git cherry-pick 1b9508f 183 - git cherry-pick fd21073 184 - git cherry-pick <this commit> 185 - 186 - Also, some patches may have kernel version prerequisites. This can be 187 - specified in the following format in the sign-off area: 188 - 189 - .. code-block:: none 190 - 191 - Cc: <stable@vger.kernel.org> # 3.3.x 192 - 193 - The tag has the meaning of: 194 - 195 - .. code-block:: none 196 - 197 - git cherry-pick <this commit> 198 - 199 - For each "-stable" tree starting with the specified version. 200 - 201 - Following the submission: 202 - 203 - - The sender will receive an ACK when the patch has been accepted into the 204 - queue, or a NAK if the patch is rejected. This response might take a few 205 - days, according to the developer's schedules. 206 - - If accepted, the patch will be added to the -stable queue, for review by 207 - other developers and by the relevant subsystem maintainer. 118 + If accepted, the patch will be added to the -stable queue, for review by other 119 + developers and by the relevant subsystem maintainer. 208 120 209 121 210 122 Review cycle ··· 203 173 - Security patches will be accepted into the -stable tree directly from the 204 174 security kernel team, and not go through the normal review cycle. 205 175 Contact the kernel security team for more details on this procedure. 176 + 206 177 207 178 Trees 208 179 -----
+21 -20
arch/x86/kernel/cpu/resctrl/pseudo_lock.c
··· 45 45 */ 46 46 static unsigned int pseudo_lock_major; 47 47 static unsigned long pseudo_lock_minor_avail = GENMASK(MINORBITS, 0); 48 - static struct class *pseudo_lock_class; 48 + 49 + static char *pseudo_lock_devnode(const struct device *dev, umode_t *mode) 50 + { 51 + const struct rdtgroup *rdtgrp; 52 + 53 + rdtgrp = dev_get_drvdata(dev); 54 + if (mode) 55 + *mode = 0600; 56 + return kasprintf(GFP_KERNEL, "pseudo_lock/%s", rdtgrp->kn->name); 57 + } 58 + 59 + static const struct class pseudo_lock_class = { 60 + .name = "pseudo_lock", 61 + .devnode = pseudo_lock_devnode, 62 + }; 49 63 50 64 /** 51 65 * get_prefetch_disable_bits - prefetch disable bits of supported platforms ··· 1367 1353 &pseudo_measure_fops); 1368 1354 } 1369 1355 1370 - dev = device_create(pseudo_lock_class, NULL, 1356 + dev = device_create(&pseudo_lock_class, NULL, 1371 1357 MKDEV(pseudo_lock_major, new_minor), 1372 1358 rdtgrp, "%s", rdtgrp->kn->name); 1373 1359 ··· 1397 1383 goto out; 1398 1384 1399 1385 out_device: 1400 - device_destroy(pseudo_lock_class, MKDEV(pseudo_lock_major, new_minor)); 1386 + device_destroy(&pseudo_lock_class, MKDEV(pseudo_lock_major, new_minor)); 1401 1387 out_debugfs: 1402 1388 debugfs_remove_recursive(plr->debugfs_dir); 1403 1389 pseudo_lock_minor_release(new_minor); ··· 1438 1424 1439 1425 pseudo_lock_cstates_relax(plr); 1440 1426 debugfs_remove_recursive(rdtgrp->plr->debugfs_dir); 1441 - device_destroy(pseudo_lock_class, MKDEV(pseudo_lock_major, plr->minor)); 1427 + device_destroy(&pseudo_lock_class, MKDEV(pseudo_lock_major, plr->minor)); 1442 1428 pseudo_lock_minor_release(plr->minor); 1443 1429 1444 1430 free: ··· 1574 1560 .mmap = pseudo_lock_dev_mmap, 1575 1561 }; 1576 1562 1577 - static char *pseudo_lock_devnode(const struct device *dev, umode_t *mode) 1578 - { 1579 - const struct rdtgroup *rdtgrp; 1580 - 1581 - rdtgrp = dev_get_drvdata(dev); 1582 - if (mode) 1583 - *mode = 0600; 1584 - return kasprintf(GFP_KERNEL, "pseudo_lock/%s", rdtgrp->kn->name); 1585 - } 1586 - 1587 1563 int rdt_pseudo_lock_init(void) 1588 1564 { 1589 1565 int ret; ··· 1584 1580 1585 1581 pseudo_lock_major = ret; 1586 1582 1587 - pseudo_lock_class = class_create("pseudo_lock"); 1588 - if (IS_ERR(pseudo_lock_class)) { 1589 - ret = PTR_ERR(pseudo_lock_class); 1583 + ret = class_register(&pseudo_lock_class); 1584 + if (ret) { 1590 1585 unregister_chrdev(pseudo_lock_major, "pseudo_lock"); 1591 1586 return ret; 1592 1587 } 1593 1588 1594 - pseudo_lock_class->devnode = pseudo_lock_devnode; 1595 1589 return 0; 1596 1590 } 1597 1591 1598 1592 void rdt_pseudo_lock_release(void) 1599 1593 { 1600 - class_destroy(pseudo_lock_class); 1601 - pseudo_lock_class = NULL; 1594 + class_unregister(&pseudo_lock_class); 1602 1595 unregister_chrdev(pseudo_lock_major, "pseudo_lock"); 1603 1596 pseudo_lock_major = 0; 1604 1597 }
+16 -15
arch/x86/kernel/cpuid.c
··· 40 40 #include <asm/processor.h> 41 41 #include <asm/msr.h> 42 42 43 - static struct class *cpuid_class; 44 43 static enum cpuhp_state cpuhp_cpuid_state; 45 44 46 45 struct cpuid_regs_done { ··· 123 124 .open = cpuid_open, 124 125 }; 125 126 127 + static char *cpuid_devnode(const struct device *dev, umode_t *mode) 128 + { 129 + return kasprintf(GFP_KERNEL, "cpu/%u/cpuid", MINOR(dev->devt)); 130 + } 131 + 132 + static const struct class cpuid_class = { 133 + .name = "cpuid", 134 + .devnode = cpuid_devnode, 135 + }; 136 + 126 137 static int cpuid_device_create(unsigned int cpu) 127 138 { 128 139 struct device *dev; 129 140 130 - dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), NULL, 141 + dev = device_create(&cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), NULL, 131 142 "cpu%d", cpu); 132 143 return PTR_ERR_OR_ZERO(dev); 133 144 } 134 145 135 146 static int cpuid_device_destroy(unsigned int cpu) 136 147 { 137 - device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); 148 + device_destroy(&cpuid_class, MKDEV(CPUID_MAJOR, cpu)); 138 149 return 0; 139 - } 140 - 141 - static char *cpuid_devnode(const struct device *dev, umode_t *mode) 142 - { 143 - return kasprintf(GFP_KERNEL, "cpu/%u/cpuid", MINOR(dev->devt)); 144 150 } 145 151 146 152 static int __init cpuid_init(void) ··· 158 154 CPUID_MAJOR); 159 155 return -EBUSY; 160 156 } 161 - cpuid_class = class_create("cpuid"); 162 - if (IS_ERR(cpuid_class)) { 163 - err = PTR_ERR(cpuid_class); 157 + err = class_register(&cpuid_class); 158 + if (err) 164 159 goto out_chrdev; 165 - } 166 - cpuid_class->devnode = cpuid_devnode; 167 160 168 161 err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/cpuid:online", 169 162 cpuid_device_create, cpuid_device_destroy); ··· 171 170 return 0; 172 171 173 172 out_class: 174 - class_destroy(cpuid_class); 173 + class_unregister(&cpuid_class); 175 174 out_chrdev: 176 175 __unregister_chrdev(CPUID_MAJOR, 0, NR_CPUS, "cpu/cpuid"); 177 176 return err; ··· 181 180 static void __exit cpuid_exit(void) 182 181 { 183 182 cpuhp_remove_state(cpuhp_cpuid_state); 184 - class_destroy(cpuid_class); 183 + class_unregister(&cpuid_class); 185 184 __unregister_chrdev(CPUID_MAJOR, 0, NR_CPUS, "cpu/cpuid"); 186 185 } 187 186 module_exit(cpuid_exit);
+16 -15
arch/x86/kernel/msr.c
··· 39 39 #include <asm/cpufeature.h> 40 40 #include <asm/msr.h> 41 41 42 - static struct class *msr_class; 43 42 static enum cpuhp_state cpuhp_msr_state; 44 43 45 44 enum allow_write_msrs { ··· 234 235 .compat_ioctl = msr_ioctl, 235 236 }; 236 237 238 + static char *msr_devnode(const struct device *dev, umode_t *mode) 239 + { 240 + return kasprintf(GFP_KERNEL, "cpu/%u/msr", MINOR(dev->devt)); 241 + } 242 + 243 + static const struct class msr_class = { 244 + .name = "msr", 245 + .devnode = msr_devnode, 246 + }; 247 + 237 248 static int msr_device_create(unsigned int cpu) 238 249 { 239 250 struct device *dev; 240 251 241 - dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), NULL, 252 + dev = device_create(&msr_class, NULL, MKDEV(MSR_MAJOR, cpu), NULL, 242 253 "msr%d", cpu); 243 254 return PTR_ERR_OR_ZERO(dev); 244 255 } 245 256 246 257 static int msr_device_destroy(unsigned int cpu) 247 258 { 248 - device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu)); 259 + device_destroy(&msr_class, MKDEV(MSR_MAJOR, cpu)); 249 260 return 0; 250 - } 251 - 252 - static char *msr_devnode(const struct device *dev, umode_t *mode) 253 - { 254 - return kasprintf(GFP_KERNEL, "cpu/%u/msr", MINOR(dev->devt)); 255 261 } 256 262 257 263 static int __init msr_init(void) ··· 267 263 pr_err("unable to get major %d for msr\n", MSR_MAJOR); 268 264 return -EBUSY; 269 265 } 270 - msr_class = class_create("msr"); 271 - if (IS_ERR(msr_class)) { 272 - err = PTR_ERR(msr_class); 266 + err = class_register(&msr_class); 267 + if (err) 273 268 goto out_chrdev; 274 - } 275 - msr_class->devnode = msr_devnode; 276 269 277 270 err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/msr:online", 278 271 msr_device_create, msr_device_destroy); ··· 279 278 return 0; 280 279 281 280 out_class: 282 - class_destroy(msr_class); 281 + class_unregister(&msr_class); 283 282 out_chrdev: 284 283 __unregister_chrdev(MSR_MAJOR, 0, NR_CPUS, "cpu/msr"); 285 284 return err; ··· 289 288 static void __exit msr_exit(void) 290 289 { 291 290 cpuhp_remove_state(cpuhp_msr_state); 292 - class_destroy(msr_class); 291 + class_unregister(&msr_class); 293 292 __unregister_chrdev(MSR_MAJOR, 0, NR_CPUS, "cpu/msr"); 294 293 } 295 294 module_exit(msr_exit)
+20 -10
drivers/base/core.c
··· 2306 2306 2307 2307 static void device_platform_notify_remove(struct device *dev) 2308 2308 { 2309 - acpi_device_notify_remove(dev); 2309 + if (platform_notify_remove) 2310 + platform_notify_remove(dev); 2310 2311 2311 2312 software_node_notify_remove(dev); 2312 2313 2313 - if (platform_notify_remove) 2314 - platform_notify_remove(dev); 2314 + acpi_device_notify_remove(dev); 2315 2315 } 2316 2316 2317 2317 /** ··· 3528 3528 * the name, and force the use of dev_name() 3529 3529 */ 3530 3530 if (dev->init_name) { 3531 - dev_set_name(dev, "%s", dev->init_name); 3531 + error = dev_set_name(dev, "%s", dev->init_name); 3532 3532 dev->init_name = NULL; 3533 3533 } 3534 3534 3535 + if (dev_name(dev)) 3536 + error = 0; 3535 3537 /* subsystems can specify simple device enumeration */ 3536 - if (!dev_name(dev) && dev->bus && dev->bus->dev_name) 3537 - dev_set_name(dev, "%s%u", dev->bus->dev_name, dev->id); 3538 - 3539 - if (!dev_name(dev)) { 3540 - error = -EINVAL; 3538 + else if (dev->bus && dev->bus->dev_name) 3539 + error = dev_set_name(dev, "%s%u", dev->bus->dev_name, dev->id); 3540 + if (error) 3541 3541 goto name_error; 3542 - } 3543 3542 3544 3543 pr_debug("device: '%s': %s\n", dev_name(dev), __func__); 3545 3544 ··· 3813 3814 driver_deferred_probe_del(dev); 3814 3815 device_platform_notify_remove(dev); 3815 3816 device_links_purge(dev); 3817 + 3818 + /* 3819 + * If a device does not have a driver attached, we need to clean 3820 + * up any managed resources. We do this in device_release(), but 3821 + * it's never called (and we leak the device) if a managed 3822 + * resource holds a reference to the device. So release all 3823 + * managed resources here, like we do in driver_detach(). We 3824 + * still need to do so again in device_release() in case someone 3825 + * adds a new resource after this point, though. 3826 + */ 3827 + devres_release_all(dev); 3816 3828 3817 3829 bus_notify(dev, BUS_NOTIFY_REMOVED_DEVICE); 3818 3830 kobject_uevent(&dev->kobj, KOBJ_REMOVE);
+19
drivers/base/cpu.c
··· 19 19 #include <linux/cpufeature.h> 20 20 #include <linux/tick.h> 21 21 #include <linux/pm_qos.h> 22 + #include <linux/delay.h> 22 23 #include <linux/sched/isolation.h> 23 24 24 25 #include "base.h" ··· 51 50 int cpuid = dev->id; 52 51 int from_nid, to_nid; 53 52 int ret; 53 + int retries = 0; 54 54 55 55 from_nid = cpu_to_node(cpuid); 56 56 if (from_nid == NUMA_NO_NODE) 57 57 return -ENODEV; 58 58 59 + retry: 59 60 ret = cpu_device_up(dev); 61 + 62 + /* 63 + * If -EBUSY is returned, it is likely that hotplug is temporarily 64 + * disabled when cpu_hotplug_disable() was called. This condition is 65 + * transient. So we retry after waiting for an exponentially 66 + * increasing delay up to a total of at least 620ms as some PCI 67 + * device initialization can take quite a while. 68 + */ 69 + if (ret == -EBUSY) { 70 + retries++; 71 + if (retries > 5) 72 + return ret; 73 + msleep(10 * (1 << retries)); 74 + goto retry; 75 + } 76 + 60 77 /* 61 78 * When hot adding memory to memoryless node and enabling a cpu 62 79 * on the node, node number of the cpu may internally change.
+2
drivers/base/dd.c
··· 693 693 694 694 device_remove(dev); 695 695 driver_sysfs_remove(dev); 696 + if (dev->bus && dev->bus->dma_cleanup) 697 + dev->bus->dma_cleanup(dev); 696 698 device_unbind_cleanup(dev); 697 699 698 700 goto re_probe;
-1
drivers/base/node.c
··· 20 20 #include <linux/pm_runtime.h> 21 21 #include <linux/swap.h> 22 22 #include <linux/slab.h> 23 - #include <linux/hugetlb.h> 24 23 25 24 static struct bus_type node_subsys = { 26 25 .name = "node",
+2
drivers/base/test/.kunitconfig
··· 1 + CONFIG_KUNIT=y 2 + CONFIG_DM_KUNIT_TEST=y
+4
drivers/base/test/Kconfig
··· 9 9 10 10 If unsure say N. 11 11 12 + config DM_KUNIT_TEST 13 + tristate "KUnit Tests for the device model" if !KUNIT_ALL_TESTS 14 + depends on KUNIT 15 + 12 16 config DRIVER_PE_KUNIT_TEST 13 17 bool "KUnit Tests for property entry API" if !KUNIT_ALL_TESTS 14 18 depends on KUNIT=y
+3
drivers/base/test/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 obj-$(CONFIG_TEST_ASYNC_DRIVER_PROBE) += test_async_driver_probe.o 3 3 4 + obj-$(CONFIG_DM_KUNIT_TEST) += root-device-test.o 5 + obj-$(CONFIG_DM_KUNIT_TEST) += platform-device-test.o 6 + 4 7 obj-$(CONFIG_DRIVER_PE_KUNIT_TEST) += property-entry-test.o 5 8 CFLAGS_property-entry-test.o += $(DISABLE_STRUCTLEAK_PLUGIN)
+224
drivers/base/test/platform-device-test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <kunit/resource.h> 4 + 5 + #include <linux/device.h> 6 + #include <linux/platform_device.h> 7 + 8 + #define DEVICE_NAME "test" 9 + 10 + struct test_priv { 11 + bool probe_done; 12 + bool release_done; 13 + wait_queue_head_t probe_wq; 14 + wait_queue_head_t release_wq; 15 + struct device *dev; 16 + }; 17 + 18 + static int platform_device_devm_init(struct kunit *test) 19 + { 20 + struct test_priv *priv; 21 + 22 + priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); 23 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv); 24 + init_waitqueue_head(&priv->probe_wq); 25 + init_waitqueue_head(&priv->release_wq); 26 + 27 + test->priv = priv; 28 + 29 + return 0; 30 + } 31 + 32 + static void devm_device_action(void *ptr) 33 + { 34 + struct test_priv *priv = ptr; 35 + 36 + priv->release_done = true; 37 + wake_up_interruptible(&priv->release_wq); 38 + } 39 + 40 + static void devm_put_device_action(void *ptr) 41 + { 42 + struct test_priv *priv = ptr; 43 + 44 + put_device(priv->dev); 45 + priv->release_done = true; 46 + wake_up_interruptible(&priv->release_wq); 47 + } 48 + 49 + #define RELEASE_TIMEOUT_MS 100 50 + 51 + /* 52 + * Tests that a platform bus, non-probed device will run its 53 + * device-managed actions when unregistered. 54 + */ 55 + static void platform_device_devm_register_unregister_test(struct kunit *test) 56 + { 57 + struct platform_device *pdev; 58 + struct test_priv *priv = test->priv; 59 + int ret; 60 + 61 + pdev = platform_device_alloc(DEVICE_NAME, PLATFORM_DEVID_NONE); 62 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev); 63 + 64 + ret = platform_device_add(pdev); 65 + KUNIT_ASSERT_EQ(test, ret, 0); 66 + 67 + priv->dev = &pdev->dev; 68 + 69 + ret = devm_add_action_or_reset(priv->dev, devm_device_action, priv); 70 + KUNIT_ASSERT_EQ(test, ret, 0); 71 + 72 + platform_device_unregister(pdev); 73 + 74 + ret = wait_event_interruptible_timeout(priv->release_wq, priv->release_done, 75 + msecs_to_jiffies(RELEASE_TIMEOUT_MS)); 76 + KUNIT_EXPECT_GT(test, ret, 0); 77 + } 78 + 79 + /* 80 + * Tests that a platform bus, non-probed device will run its 81 + * device-managed actions when unregistered, even if someone still holds 82 + * a reference to it. 83 + */ 84 + static void platform_device_devm_register_get_unregister_with_devm_test(struct kunit *test) 85 + { 86 + struct platform_device *pdev; 87 + struct test_priv *priv = test->priv; 88 + int ret; 89 + 90 + pdev = platform_device_alloc(DEVICE_NAME, PLATFORM_DEVID_NONE); 91 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev); 92 + 93 + ret = platform_device_add(pdev); 94 + KUNIT_ASSERT_EQ(test, ret, 0); 95 + 96 + priv->dev = &pdev->dev; 97 + 98 + get_device(priv->dev); 99 + 100 + ret = devm_add_action_or_reset(priv->dev, devm_put_device_action, priv); 101 + KUNIT_ASSERT_EQ(test, ret, 0); 102 + 103 + platform_device_unregister(pdev); 104 + 105 + ret = wait_event_interruptible_timeout(priv->release_wq, priv->release_done, 106 + msecs_to_jiffies(RELEASE_TIMEOUT_MS)); 107 + KUNIT_EXPECT_GT(test, ret, 0); 108 + } 109 + 110 + static int fake_probe(struct platform_device *pdev) 111 + { 112 + struct test_priv *priv = platform_get_drvdata(pdev); 113 + 114 + priv->probe_done = true; 115 + wake_up_interruptible(&priv->probe_wq); 116 + 117 + return 0; 118 + } 119 + 120 + static struct platform_driver fake_driver = { 121 + .probe = fake_probe, 122 + .driver = { 123 + .name = DEVICE_NAME, 124 + }, 125 + }; 126 + 127 + /* 128 + * Tests that a platform bus, probed device will run its device-managed 129 + * actions when unregistered. 130 + */ 131 + static void probed_platform_device_devm_register_unregister_test(struct kunit *test) 132 + { 133 + struct platform_device *pdev; 134 + struct test_priv *priv = test->priv; 135 + int ret; 136 + 137 + ret = platform_driver_register(&fake_driver); 138 + KUNIT_ASSERT_EQ(test, ret, 0); 139 + 140 + pdev = platform_device_alloc(DEVICE_NAME, PLATFORM_DEVID_NONE); 141 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev); 142 + 143 + priv->dev = &pdev->dev; 144 + platform_set_drvdata(pdev, priv); 145 + 146 + ret = platform_device_add(pdev); 147 + KUNIT_ASSERT_EQ(test, ret, 0); 148 + 149 + ret = wait_event_interruptible_timeout(priv->probe_wq, priv->probe_done, 150 + msecs_to_jiffies(RELEASE_TIMEOUT_MS)); 151 + KUNIT_ASSERT_GT(test, ret, 0); 152 + 153 + ret = devm_add_action_or_reset(priv->dev, devm_device_action, priv); 154 + KUNIT_ASSERT_EQ(test, ret, 0); 155 + 156 + platform_device_unregister(pdev); 157 + 158 + ret = wait_event_interruptible_timeout(priv->release_wq, priv->release_done, 159 + msecs_to_jiffies(RELEASE_TIMEOUT_MS)); 160 + KUNIT_EXPECT_GT(test, ret, 0); 161 + 162 + platform_driver_unregister(&fake_driver); 163 + } 164 + 165 + /* 166 + * Tests that a platform bus, probed device will run its device-managed 167 + * actions when unregistered, even if someone still holds a reference to 168 + * it. 169 + */ 170 + static void probed_platform_device_devm_register_get_unregister_with_devm_test(struct kunit *test) 171 + { 172 + struct platform_device *pdev; 173 + struct test_priv *priv = test->priv; 174 + int ret; 175 + 176 + ret = platform_driver_register(&fake_driver); 177 + KUNIT_ASSERT_EQ(test, ret, 0); 178 + 179 + pdev = platform_device_alloc(DEVICE_NAME, PLATFORM_DEVID_NONE); 180 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev); 181 + 182 + priv->dev = &pdev->dev; 183 + platform_set_drvdata(pdev, priv); 184 + 185 + ret = platform_device_add(pdev); 186 + KUNIT_ASSERT_EQ(test, ret, 0); 187 + 188 + ret = wait_event_interruptible_timeout(priv->probe_wq, priv->probe_done, 189 + msecs_to_jiffies(RELEASE_TIMEOUT_MS)); 190 + KUNIT_ASSERT_GT(test, ret, 0); 191 + 192 + get_device(priv->dev); 193 + 194 + ret = devm_add_action_or_reset(priv->dev, devm_put_device_action, priv); 195 + KUNIT_ASSERT_EQ(test, ret, 0); 196 + 197 + platform_device_unregister(pdev); 198 + 199 + ret = wait_event_interruptible_timeout(priv->release_wq, priv->release_done, 200 + msecs_to_jiffies(RELEASE_TIMEOUT_MS)); 201 + KUNIT_EXPECT_GT(test, ret, 0); 202 + 203 + platform_driver_unregister(&fake_driver); 204 + } 205 + 206 + static struct kunit_case platform_device_devm_tests[] = { 207 + KUNIT_CASE(platform_device_devm_register_unregister_test), 208 + KUNIT_CASE(platform_device_devm_register_get_unregister_with_devm_test), 209 + KUNIT_CASE(probed_platform_device_devm_register_unregister_test), 210 + KUNIT_CASE(probed_platform_device_devm_register_get_unregister_with_devm_test), 211 + {} 212 + }; 213 + 214 + static struct kunit_suite platform_device_devm_test_suite = { 215 + .name = "platform-device-devm", 216 + .init = platform_device_devm_init, 217 + .test_cases = platform_device_devm_tests, 218 + }; 219 + 220 + kunit_test_suite(platform_device_devm_test_suite); 221 + 222 + MODULE_DESCRIPTION("Test module for platform devices"); 223 + MODULE_AUTHOR("Maxime Ripard <mripard@kernel.org>"); 224 + MODULE_LICENSE("GPL");
+112
drivers/base/test/root-device-test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // Copyright 2023 Maxime Ripard <mripard@kernel.org> 3 + 4 + #include <kunit/resource.h> 5 + 6 + #include <linux/device.h> 7 + 8 + #define DEVICE_NAME "test" 9 + 10 + struct test_priv { 11 + bool probe_done; 12 + bool release_done; 13 + wait_queue_head_t release_wq; 14 + struct device *dev; 15 + }; 16 + 17 + static int root_device_devm_init(struct kunit *test) 18 + { 19 + struct test_priv *priv; 20 + 21 + priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); 22 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv); 23 + init_waitqueue_head(&priv->release_wq); 24 + 25 + test->priv = priv; 26 + 27 + return 0; 28 + } 29 + 30 + static void devm_device_action(void *ptr) 31 + { 32 + struct test_priv *priv = ptr; 33 + 34 + priv->release_done = true; 35 + wake_up_interruptible(&priv->release_wq); 36 + } 37 + 38 + #define RELEASE_TIMEOUT_MS 100 39 + 40 + /* 41 + * Tests that a bus-less, non-probed device will run its device-managed 42 + * actions when unregistered. 43 + */ 44 + static void root_device_devm_register_unregister_test(struct kunit *test) 45 + { 46 + struct test_priv *priv = test->priv; 47 + int ret; 48 + 49 + priv->dev = root_device_register(DEVICE_NAME); 50 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->dev); 51 + 52 + ret = devm_add_action_or_reset(priv->dev, devm_device_action, priv); 53 + KUNIT_ASSERT_EQ(test, ret, 0); 54 + 55 + root_device_unregister(priv->dev); 56 + 57 + ret = wait_event_interruptible_timeout(priv->release_wq, priv->release_done, 58 + msecs_to_jiffies(RELEASE_TIMEOUT_MS)); 59 + KUNIT_EXPECT_GT(test, ret, 0); 60 + } 61 + 62 + static void devm_put_device_action(void *ptr) 63 + { 64 + struct test_priv *priv = ptr; 65 + 66 + put_device(priv->dev); 67 + priv->release_done = true; 68 + wake_up_interruptible(&priv->release_wq); 69 + } 70 + 71 + /* 72 + * Tests that a bus-less, non-probed device will run its device-managed 73 + * actions when unregistered, even if someone still holds a reference to 74 + * it. 75 + */ 76 + static void root_device_devm_register_get_unregister_with_devm_test(struct kunit *test) 77 + { 78 + struct test_priv *priv = test->priv; 79 + int ret; 80 + 81 + priv->dev = root_device_register(DEVICE_NAME); 82 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->dev); 83 + 84 + get_device(priv->dev); 85 + 86 + ret = devm_add_action_or_reset(priv->dev, devm_put_device_action, priv); 87 + KUNIT_ASSERT_EQ(test, ret, 0); 88 + 89 + root_device_unregister(priv->dev); 90 + 91 + ret = wait_event_interruptible_timeout(priv->release_wq, priv->release_done, 92 + msecs_to_jiffies(RELEASE_TIMEOUT_MS)); 93 + KUNIT_EXPECT_GT(test, ret, 0); 94 + } 95 + 96 + static struct kunit_case root_device_devm_tests[] = { 97 + KUNIT_CASE(root_device_devm_register_unregister_test), 98 + KUNIT_CASE(root_device_devm_register_get_unregister_with_devm_test), 99 + {} 100 + }; 101 + 102 + static struct kunit_suite root_device_devm_test_suite = { 103 + .name = "root-device-devm", 104 + .init = root_device_devm_init, 105 + .test_cases = root_device_devm_tests, 106 + }; 107 + 108 + kunit_test_suite(root_device_devm_test_suite); 109 + 110 + MODULE_DESCRIPTION("Test module for root devices"); 111 + MODULE_AUTHOR("Maxime Ripard <mripard@kernel.org>"); 112 + MODULE_LICENSE("GPL");
+1 -1
drivers/base/test/test_async_driver_probe.c
··· 84 84 85 85 pdev = platform_device_alloc(name, id); 86 86 if (!pdev) 87 - return NULL; 87 + return ERR_PTR(-ENOMEM); 88 88 89 89 if (nid != NUMA_NO_NODE) 90 90 set_dev_node(&pdev->dev, nid);
+8 -3
drivers/char/tpm/tpm-chip.c
··· 28 28 DEFINE_IDR(dev_nums_idr); 29 29 static DEFINE_MUTEX(idr_lock); 30 30 31 - struct class *tpm_class; 32 - struct class *tpmrm_class; 31 + const struct class tpm_class = { 32 + .name = "tpm", 33 + .shutdown_pre = tpm_class_shutdown, 34 + }; 35 + const struct class tpmrm_class = { 36 + .name = "tmprm", 37 + }; 33 38 dev_t tpm_devt; 34 39 35 40 static int tpm_request_locality(struct tpm_chip *chip) ··· 341 336 342 337 device_initialize(&chip->dev); 343 338 344 - chip->dev.class = tpm_class; 339 + chip->dev.class = &tpm_class; 345 340 chip->dev.release = tpm_dev_release; 346 341 chip->dev.parent = pdev; 347 342 chip->dev.groups = chip->groups;
+9 -12
drivers/char/tpm/tpm-interface.c
··· 476 476 { 477 477 int rc; 478 478 479 - tpm_class = class_create("tpm"); 480 - if (IS_ERR(tpm_class)) { 479 + rc = class_register(&tpm_class); 480 + if (rc) { 481 481 pr_err("couldn't create tpm class\n"); 482 - return PTR_ERR(tpm_class); 482 + return rc; 483 483 } 484 484 485 - tpm_class->shutdown_pre = tpm_class_shutdown; 486 - 487 - tpmrm_class = class_create("tpmrm"); 488 - if (IS_ERR(tpmrm_class)) { 485 + rc = class_register(&tpmrm_class); 486 + if (rc) { 489 487 pr_err("couldn't create tpmrm class\n"); 490 - rc = PTR_ERR(tpmrm_class); 491 488 goto out_destroy_tpm_class; 492 489 } 493 490 ··· 505 508 out_unreg_chrdev: 506 509 unregister_chrdev_region(tpm_devt, 2 * TPM_NUM_DEVICES); 507 510 out_destroy_tpmrm_class: 508 - class_destroy(tpmrm_class); 511 + class_unregister(&tpmrm_class); 509 512 out_destroy_tpm_class: 510 - class_destroy(tpm_class); 513 + class_unregister(&tpm_class); 511 514 512 515 return rc; 513 516 } ··· 515 518 static void __exit tpm_exit(void) 516 519 { 517 520 idr_destroy(&dev_nums_idr); 518 - class_destroy(tpm_class); 519 - class_destroy(tpmrm_class); 521 + class_unregister(&tpm_class); 522 + class_unregister(&tpmrm_class); 520 523 unregister_chrdev_region(tpm_devt, 2*TPM_NUM_DEVICES); 521 524 tpm_dev_common_exit(); 522 525 }
+2 -2
drivers/char/tpm/tpm.h
··· 230 230 * compiler warnings about stack frame size. */ 231 231 #define TPM_MAX_RNG_DATA 128 232 232 233 - extern struct class *tpm_class; 234 - extern struct class *tpmrm_class; 233 + extern const struct class tpm_class; 234 + extern const struct class tpmrm_class; 235 235 extern dev_t tpm_devt; 236 236 extern const struct file_operations tpm_fops; 237 237 extern const struct file_operations tpmrm_fops;
+1 -1
drivers/char/tpm/tpm2-space.c
··· 606 606 607 607 device_initialize(&chip->devs); 608 608 chip->devs.parent = chip->dev.parent; 609 - chip->devs.class = tpmrm_class; 609 + chip->devs.class = &tpmrm_class; 610 610 611 611 /* 612 612 * Get extra reference on main device to hold on behalf of devs.
+11 -9
drivers/hid/hid-roccat-arvo.c
··· 23 23 #include "hid-roccat-common.h" 24 24 #include "hid-roccat-arvo.h" 25 25 26 - static struct class *arvo_class; 27 - 28 26 static ssize_t arvo_sysfs_show_mode_key(struct device *dev, 29 27 struct device_attribute *attr, char *buf) 30 28 { ··· 266 268 NULL, 267 269 }; 268 270 271 + static const struct class arvo_class = { 272 + .name = "arvo", 273 + .dev_groups = arvo_groups, 274 + }; 275 + 269 276 static int arvo_init_arvo_device_struct(struct usb_device *usb_dev, 270 277 struct arvo_device *arvo) 271 278 { ··· 312 309 goto exit_free; 313 310 } 314 311 315 - retval = roccat_connect(arvo_class, hdev, 312 + retval = roccat_connect(&arvo_class, hdev, 316 313 sizeof(struct arvo_roccat_report)); 317 314 if (retval < 0) { 318 315 hid_err(hdev, "couldn't init char dev\n"); ··· 436 433 { 437 434 int retval; 438 435 439 - arvo_class = class_create("arvo"); 440 - if (IS_ERR(arvo_class)) 441 - return PTR_ERR(arvo_class); 442 - arvo_class->dev_groups = arvo_groups; 436 + retval = class_register(&arvo_class); 437 + if (retval) 438 + return retval; 443 439 444 440 retval = hid_register_driver(&arvo_driver); 445 441 if (retval) 446 - class_destroy(arvo_class); 442 + class_unregister(&arvo_class); 447 443 return retval; 448 444 } 449 445 450 446 static void __exit arvo_exit(void) 451 447 { 452 448 hid_unregister_driver(&arvo_driver); 453 - class_destroy(arvo_class); 449 + class_unregister(&arvo_class); 454 450 } 455 451 456 452 module_init(arvo_init);
+12 -9
drivers/hid/hid-roccat-isku.c
··· 23 23 #include "hid-roccat-common.h" 24 24 #include "hid-roccat-isku.h" 25 25 26 - static struct class *isku_class; 27 - 28 26 static void isku_profile_activated(struct isku_device *isku, uint new_profile) 29 27 { 30 28 isku->actual_profile = new_profile; ··· 246 248 NULL, 247 249 }; 248 250 251 + static const struct class isku_class = { 252 + .name = "isku", 253 + .dev_groups = isku_groups, 254 + }; 255 + 249 256 static int isku_init_isku_device_struct(struct usb_device *usb_dev, 250 257 struct isku_device *isku) 251 258 { ··· 292 289 goto exit_free; 293 290 } 294 291 295 - retval = roccat_connect(isku_class, hdev, 292 + retval = roccat_connect(&isku_class, hdev, 296 293 sizeof(struct isku_roccat_report)); 297 294 if (retval < 0) { 298 295 hid_err(hdev, "couldn't init char dev\n"); ··· 438 435 static int __init isku_init(void) 439 436 { 440 437 int retval; 441 - isku_class = class_create("isku"); 442 - if (IS_ERR(isku_class)) 443 - return PTR_ERR(isku_class); 444 - isku_class->dev_groups = isku_groups; 438 + 439 + retval = class_register(&isku_class); 440 + if (retval) 441 + return retval; 445 442 446 443 retval = hid_register_driver(&isku_driver); 447 444 if (retval) 448 - class_destroy(isku_class); 445 + class_unregister(&isku_class); 449 446 return retval; 450 447 } 451 448 452 449 static void __exit isku_exit(void) 453 450 { 454 451 hid_unregister_driver(&isku_driver); 455 - class_destroy(isku_class); 452 + class_unregister(&isku_class); 456 453 } 457 454 458 455 module_init(isku_init);
+13 -11
drivers/hid/hid-roccat-kone.c
··· 89 89 return ((len < 0) ? len : ((len != size) ? -EIO : 0)); 90 90 } 91 91 92 - /* kone_class is used for creating sysfs attributes via roccat char device */ 93 - static struct class *kone_class; 94 - 95 92 static void kone_set_settings_checksum(struct kone_settings *settings) 96 93 { 97 94 uint16_t checksum = 0; ··· 654 657 NULL, 655 658 }; 656 659 660 + /* kone_class is used for creating sysfs attributes via roccat char device */ 661 + static const struct class kone_class = { 662 + .name = "kone", 663 + .dev_groups = kone_groups, 664 + }; 665 + 657 666 static int kone_init_kone_device_struct(struct usb_device *usb_dev, 658 667 struct kone_device *kone) 659 668 { ··· 715 712 goto exit_free; 716 713 } 717 714 718 - retval = roccat_connect(kone_class, hdev, 719 - sizeof(struct kone_roccat_report)); 715 + retval = roccat_connect(&kone_class, hdev, 716 + sizeof(struct kone_roccat_report)); 720 717 if (retval < 0) { 721 718 hid_err(hdev, "couldn't init char dev\n"); 722 719 /* be tolerant about not getting chrdev */ ··· 893 890 int retval; 894 891 895 892 /* class name has to be same as driver name */ 896 - kone_class = class_create("kone"); 897 - if (IS_ERR(kone_class)) 898 - return PTR_ERR(kone_class); 899 - kone_class->dev_groups = kone_groups; 893 + retval = class_register(&kone_class); 894 + if (retval) 895 + return retval; 900 896 901 897 retval = hid_register_driver(&kone_driver); 902 898 if (retval) 903 - class_destroy(kone_class); 899 + class_unregister(&kone_class); 904 900 return retval; 905 901 } 906 902 907 903 static void __exit kone_exit(void) 908 904 { 909 905 hid_unregister_driver(&kone_driver); 910 - class_destroy(kone_class); 906 + class_unregister(&kone_class); 911 907 } 912 908 913 909 module_init(kone_init);
+12 -10
drivers/hid/hid-roccat-koneplus.c
··· 26 26 27 27 static uint profile_numbers[5] = {0, 1, 2, 3, 4}; 28 28 29 - static struct class *koneplus_class; 30 - 31 29 static void koneplus_profile_activated(struct koneplus_device *koneplus, 32 30 uint new_profile) 33 31 { ··· 354 356 NULL, 355 357 }; 356 358 359 + static const struct class koneplus_class = { 360 + .name = "koneplus", 361 + .dev_groups = koneplus_groups, 362 + }; 363 + 357 364 static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, 358 365 struct koneplus_device *koneplus) 359 366 { ··· 397 394 goto exit_free; 398 395 } 399 396 400 - retval = roccat_connect(koneplus_class, hdev, 401 - sizeof(struct koneplus_roccat_report)); 397 + retval = roccat_connect(&koneplus_class, hdev, 398 + sizeof(struct koneplus_roccat_report)); 402 399 if (retval < 0) { 403 400 hid_err(hdev, "couldn't init char dev\n"); 404 401 } else { ··· 552 549 int retval; 553 550 554 551 /* class name has to be same as driver name */ 555 - koneplus_class = class_create("koneplus"); 556 - if (IS_ERR(koneplus_class)) 557 - return PTR_ERR(koneplus_class); 558 - koneplus_class->dev_groups = koneplus_groups; 552 + retval = class_register(&koneplus_class); 553 + if (retval) 554 + return retval; 559 555 560 556 retval = hid_register_driver(&koneplus_driver); 561 557 if (retval) 562 - class_destroy(koneplus_class); 558 + class_unregister(&koneplus_class); 563 559 return retval; 564 560 } 565 561 566 562 static void __exit koneplus_exit(void) 567 563 { 568 564 hid_unregister_driver(&koneplus_driver); 569 - class_destroy(koneplus_class); 565 + class_unregister(&koneplus_class); 570 566 } 571 567 572 568 module_init(koneplus_init);
+12 -10
drivers/hid/hid-roccat-konepure.c
··· 36 36 uint8_t unknown[2]; 37 37 } __packed; 38 38 39 - static struct class *konepure_class; 40 - 41 39 ROCCAT_COMMON2_BIN_ATTRIBUTE_W(control, 0x04, 0x03); 42 40 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(actual_profile, 0x05, 0x03); 43 41 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(profile_settings, 0x06, 0x1f); ··· 70 72 NULL, 71 73 }; 72 74 75 + static const struct class konepure_class = { 76 + .name = "konepure", 77 + .dev_groups = konepure_groups, 78 + }; 79 + 73 80 static int konepure_init_specials(struct hid_device *hdev) 74 81 { 75 82 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); ··· 101 98 goto exit_free; 102 99 } 103 100 104 - retval = roccat_connect(konepure_class, hdev, 105 - sizeof(struct konepure_mouse_report_button)); 101 + retval = roccat_connect(&konepure_class, hdev, 102 + sizeof(struct konepure_mouse_report_button)); 106 103 if (retval < 0) { 107 104 hid_err(hdev, "couldn't init char dev\n"); 108 105 } else { ··· 210 207 { 211 208 int retval; 212 209 213 - konepure_class = class_create("konepure"); 214 - if (IS_ERR(konepure_class)) 215 - return PTR_ERR(konepure_class); 216 - konepure_class->dev_groups = konepure_groups; 210 + retval = class_register(&konepure_class); 211 + if (retval) 212 + return retval; 217 213 218 214 retval = hid_register_driver(&konepure_driver); 219 215 if (retval) 220 - class_destroy(konepure_class); 216 + class_unregister(&konepure_class); 221 217 return retval; 222 218 } 223 219 224 220 static void __exit konepure_exit(void) 225 221 { 226 222 hid_unregister_driver(&konepure_driver); 227 - class_destroy(konepure_class); 223 + class_unregister(&konepure_class); 228 224 } 229 225 230 226 module_init(konepure_init);
+12 -10
drivers/hid/hid-roccat-kovaplus.c
··· 24 24 25 25 static uint profile_numbers[5] = {0, 1, 2, 3, 4}; 26 26 27 - static struct class *kovaplus_class; 28 - 29 27 static uint kovaplus_convert_event_cpi(uint value) 30 28 { 31 29 return (value == 7 ? 4 : (value == 4 ? 3 : value)); ··· 407 409 NULL, 408 410 }; 409 411 412 + static const struct class kovaplus_class = { 413 + .name = "kovaplus", 414 + .dev_groups = kovaplus_groups, 415 + }; 416 + 410 417 static int kovaplus_init_kovaplus_device_struct(struct usb_device *usb_dev, 411 418 struct kovaplus_device *kovaplus) 412 419 { ··· 466 463 goto exit_free; 467 464 } 468 465 469 - retval = roccat_connect(kovaplus_class, hdev, 470 - sizeof(struct kovaplus_roccat_report)); 466 + retval = roccat_connect(&kovaplus_class, hdev, 467 + sizeof(struct kovaplus_roccat_report)); 471 468 if (retval < 0) { 472 469 hid_err(hdev, "couldn't init char dev\n"); 473 470 } else { ··· 641 638 { 642 639 int retval; 643 640 644 - kovaplus_class = class_create("kovaplus"); 645 - if (IS_ERR(kovaplus_class)) 646 - return PTR_ERR(kovaplus_class); 647 - kovaplus_class->dev_groups = kovaplus_groups; 641 + retval = class_register(&kovaplus_class); 642 + if (retval) 643 + return retval; 648 644 649 645 retval = hid_register_driver(&kovaplus_driver); 650 646 if (retval) 651 - class_destroy(kovaplus_class); 647 + class_unregister(&kovaplus_class); 652 648 return retval; 653 649 } 654 650 655 651 static void __exit kovaplus_exit(void) 656 652 { 657 653 hid_unregister_driver(&kovaplus_driver); 658 - class_destroy(kovaplus_class); 654 + class_unregister(&kovaplus_class); 659 655 } 660 656 661 657 module_init(kovaplus_init);
+12 -10
drivers/hid/hid-roccat-pyra.c
··· 26 26 27 27 static uint profile_numbers[5] = {0, 1, 2, 3, 4}; 28 28 29 - /* pyra_class is used for creating sysfs attributes via roccat char device */ 30 - static struct class *pyra_class; 31 - 32 29 static void profile_activated(struct pyra_device *pyra, 33 30 unsigned int new_profile) 34 31 { ··· 363 366 NULL, 364 367 }; 365 368 369 + /* pyra_class is used for creating sysfs attributes via roccat char device */ 370 + static const struct class pyra_class = { 371 + .name = "pyra", 372 + .dev_groups = pyra_groups, 373 + }; 374 + 366 375 static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, 367 376 struct pyra_device *pyra) 368 377 { ··· 416 413 goto exit_free; 417 414 } 418 415 419 - retval = roccat_connect(pyra_class, hdev, 416 + retval = roccat_connect(&pyra_class, hdev, 420 417 sizeof(struct pyra_roccat_report)); 421 418 if (retval < 0) { 422 419 hid_err(hdev, "couldn't init char dev\n"); ··· 588 585 int retval; 589 586 590 587 /* class name has to be same as driver name */ 591 - pyra_class = class_create("pyra"); 592 - if (IS_ERR(pyra_class)) 593 - return PTR_ERR(pyra_class); 594 - pyra_class->dev_groups = pyra_groups; 588 + retval = class_register(&pyra_class); 589 + if (retval) 590 + return retval; 595 591 596 592 retval = hid_register_driver(&pyra_driver); 597 593 if (retval) 598 - class_destroy(pyra_class); 594 + class_unregister(&pyra_class); 599 595 return retval; 600 596 } 601 597 602 598 static void __exit pyra_exit(void) 603 599 { 604 600 hid_unregister_driver(&pyra_driver); 605 - class_destroy(pyra_class); 601 + class_unregister(&pyra_class); 606 602 } 607 603 608 604 module_init(pyra_init);
+11 -9
drivers/hid/hid-roccat-ryos.c
··· 28 28 uint8_t data[4]; 29 29 } __packed; 30 30 31 - static struct class *ryos_class; 32 - 33 31 ROCCAT_COMMON2_BIN_ATTRIBUTE_W(control, 0x04, 0x03); 34 32 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(profile, 0x05, 0x03); 35 33 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(keys_primary, 0x06, 0x7d); ··· 78 80 NULL, 79 81 }; 80 82 83 + static const struct class ryos_class = { 84 + .name = "ryos", 85 + .dev_groups = ryos_groups, 86 + }; 87 + 81 88 static int ryos_init_specials(struct hid_device *hdev) 82 89 { 83 90 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); ··· 109 106 goto exit_free; 110 107 } 111 108 112 - retval = roccat_connect(ryos_class, hdev, 109 + retval = roccat_connect(&ryos_class, hdev, 113 110 sizeof(struct ryos_report_special)); 114 111 if (retval < 0) { 115 112 hid_err(hdev, "couldn't init char dev\n"); ··· 219 216 { 220 217 int retval; 221 218 222 - ryos_class = class_create("ryos"); 223 - if (IS_ERR(ryos_class)) 224 - return PTR_ERR(ryos_class); 225 - ryos_class->dev_groups = ryos_groups; 219 + retval = class_register(&ryos_class); 220 + if (retval) 221 + return retval; 226 222 227 223 retval = hid_register_driver(&ryos_driver); 228 224 if (retval) 229 - class_destroy(ryos_class); 225 + class_unregister(&ryos_class); 230 226 return retval; 231 227 } 232 228 233 229 static void __exit ryos_exit(void) 234 230 { 235 231 hid_unregister_driver(&ryos_driver); 236 - class_destroy(ryos_class); 232 + class_unregister(&ryos_class); 237 233 } 238 234 239 235 module_init(ryos_init);
+11 -9
drivers/hid/hid-roccat-savu.c
··· 22 22 #include "hid-roccat-common.h" 23 23 #include "hid-roccat-savu.h" 24 24 25 - static struct class *savu_class; 26 - 27 25 ROCCAT_COMMON2_BIN_ATTRIBUTE_W(control, 0x4, 0x03); 28 26 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(profile, 0x5, 0x03); 29 27 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(general, 0x6, 0x10); ··· 50 52 NULL, 51 53 }; 52 54 55 + static const struct class savu_class = { 56 + .name = "savu", 57 + .dev_groups = savu_groups, 58 + }; 59 + 53 60 static int savu_init_specials(struct hid_device *hdev) 54 61 { 55 62 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); ··· 81 78 goto exit_free; 82 79 } 83 80 84 - retval = roccat_connect(savu_class, hdev, 81 + retval = roccat_connect(&savu_class, hdev, 85 82 sizeof(struct savu_roccat_report)); 86 83 if (retval < 0) { 87 84 hid_err(hdev, "couldn't init char dev\n"); ··· 207 204 { 208 205 int retval; 209 206 210 - savu_class = class_create("savu"); 211 - if (IS_ERR(savu_class)) 212 - return PTR_ERR(savu_class); 213 - savu_class->dev_groups = savu_groups; 207 + retval = class_register(&savu_class); 208 + if (retval) 209 + return retval; 214 210 215 211 retval = hid_register_driver(&savu_driver); 216 212 if (retval) 217 - class_destroy(savu_class); 213 + class_unregister(&savu_class); 218 214 return retval; 219 215 } 220 216 221 217 static void __exit savu_exit(void) 222 218 { 223 219 hid_unregister_driver(&savu_driver); 224 - class_destroy(savu_class); 220 + class_unregister(&savu_class); 225 221 } 226 222 227 223 module_init(savu_init);
+1 -1
drivers/hid/hid-roccat.c
··· 295 295 * Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on 296 296 * success, a negative error code on failure. 297 297 */ 298 - int roccat_connect(struct class *klass, struct hid_device *hid, int report_size) 298 + int roccat_connect(const struct class *klass, struct hid_device *hid, int report_size) 299 299 { 300 300 unsigned int minor; 301 301 struct roccat_device *device;
+9 -9
drivers/hid/hidraw.c
··· 32 32 33 33 static int hidraw_major; 34 34 static struct cdev hidraw_cdev; 35 - static struct class *hidraw_class; 35 + static const struct class hidraw_class = { 36 + .name = "hidraw", 37 + }; 36 38 static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES]; 37 39 static DECLARE_RWSEM(minors_rwsem); 38 40 ··· 331 329 hid_hw_close(hidraw->hid); 332 330 wake_up_interruptible(&hidraw->wait); 333 331 } 334 - device_destroy(hidraw_class, 332 + device_destroy(&hidraw_class, 335 333 MKDEV(hidraw_major, hidraw->minor)); 336 334 } else { 337 335 --hidraw->open; ··· 571 569 goto out; 572 570 } 573 571 574 - dev->dev = device_create(hidraw_class, &hid->dev, MKDEV(hidraw_major, minor), 572 + dev->dev = device_create(&hidraw_class, &hid->dev, MKDEV(hidraw_major, minor), 575 573 NULL, "%s%d", "hidraw", minor); 576 574 577 575 if (IS_ERR(dev->dev)) { ··· 625 623 626 624 hidraw_major = MAJOR(dev_id); 627 625 628 - hidraw_class = class_create("hidraw"); 629 - if (IS_ERR(hidraw_class)) { 630 - result = PTR_ERR(hidraw_class); 626 + result = class_register(&hidraw_class); 627 + if (result) 631 628 goto error_cdev; 632 - } 633 629 634 630 cdev_init(&hidraw_cdev, &hidraw_ops); 635 631 result = cdev_add(&hidraw_cdev, dev_id, HIDRAW_MAX_DEVICES); ··· 639 639 return result; 640 640 641 641 error_class: 642 - class_destroy(hidraw_class); 642 + class_unregister(&hidraw_class); 643 643 error_cdev: 644 644 unregister_chrdev_region(dev_id, HIDRAW_MAX_DEVICES); 645 645 goto out; ··· 650 650 dev_t dev_id = MKDEV(hidraw_major, 0); 651 651 652 652 cdev_del(&hidraw_cdev); 653 - class_destroy(hidraw_class); 653 + class_unregister(&hidraw_class); 654 654 unregister_chrdev_region(dev_id, HIDRAW_MAX_DEVICES); 655 655 656 656 }
+4
fs/kernfs/dir.c
··· 383 383 rb_insert_color(&kn->rb, &kn->parent->dir.children); 384 384 385 385 /* successfully added, account subdir number */ 386 + down_write(&kernfs_root(kn)->kernfs_iattr_rwsem); 386 387 if (kernfs_type(kn) == KERNFS_DIR) 387 388 kn->parent->dir.subdirs++; 388 389 kernfs_inc_rev(kn->parent); 390 + up_write(&kernfs_root(kn)->kernfs_iattr_rwsem); 389 391 390 392 return 0; 391 393 } ··· 410 408 if (RB_EMPTY_NODE(&kn->rb)) 411 409 return false; 412 410 411 + down_write(&kernfs_root(kn)->kernfs_iattr_rwsem); 413 412 if (kernfs_type(kn) == KERNFS_DIR) 414 413 kn->parent->dir.subdirs--; 415 414 kernfs_inc_rev(kn->parent); 415 + up_write(&kernfs_root(kn)->kernfs_iattr_rwsem); 416 416 417 417 rb_erase(&kn->rb, &kn->parent->dir.children); 418 418 RB_CLEAR_NODE(&kn->rb);
+12 -1
fs/kernfs/mount.c
··· 16 16 #include <linux/namei.h> 17 17 #include <linux/seq_file.h> 18 18 #include <linux/exportfs.h> 19 + #include <linux/uuid.h> 20 + #include <linux/statfs.h> 19 21 20 22 #include "kernfs-internal.h" 21 23 ··· 47 45 return 0; 48 46 } 49 47 48 + static int kernfs_statfs(struct dentry *dentry, struct kstatfs *buf) 49 + { 50 + simple_statfs(dentry, buf); 51 + buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b); 52 + return 0; 53 + } 54 + 50 55 const struct super_operations kernfs_sops = { 51 - .statfs = simple_statfs, 56 + .statfs = kernfs_statfs, 52 57 .drop_inode = generic_delete_inode, 53 58 .evict_inode = kernfs_evict_inode, 54 59 ··· 359 350 return error; 360 351 } 361 352 sb->s_flags |= SB_ACTIVE; 353 + 354 + uuid_gen(&sb->s_uuid); 362 355 363 356 down_write(&root->kernfs_supers_rwsem); 364 357 list_add(&info->node, &info->root->supers);
+2
include/linux/dev_printk.h
··· 274 274 WARN_ONCE(condition, "%s %s: " format, \ 275 275 dev_driver_string(dev), dev_name(dev), ## arg) 276 276 277 + __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...); 278 + 277 279 #endif /* _DEVICE_PRINTK_H_ */
-2
include/linux/device.h
··· 1249 1249 void device_links_supplier_sync_state_pause(void); 1250 1250 void device_links_supplier_sync_state_resume(void); 1251 1251 1252 - __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...); 1253 - 1254 1252 /* Create alias, so I can be autoloaded. */ 1255 1253 #define MODULE_ALIAS_CHARDEV(major,minor) \ 1256 1254 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
+1 -1
include/linux/hid-roccat.h
··· 16 16 17 17 #ifdef __KERNEL__ 18 18 19 - int roccat_connect(struct class *klass, struct hid_device *hid, 19 + int roccat_connect(const struct class *klass, struct hid_device *hid, 20 20 int report_size); 21 21 void roccat_disconnect(int minor); 22 22 int roccat_report_event(int minor, u8 const *data);
+4
include/linux/kernfs.h
··· 550 550 const struct iattr *iattr) 551 551 { return -ENOSYS; } 552 552 553 + static inline __poll_t kernfs_generic_poll(struct kernfs_open_file *of, 554 + struct poll_table_struct *pt) 555 + { return -ENOSYS; } 556 + 553 557 static inline void kernfs_notify(struct kernfs_node *kn) { } 554 558 555 559 static inline int kernfs_xattr_get(struct kernfs_node *kn, const char *name,
+5 -3
include/linux/kobject.h
··· 69 69 const struct kobj_type *ktype; 70 70 struct kernfs_node *sd; /* sysfs directory entry */ 71 71 struct kref kref; 72 - #ifdef CONFIG_DEBUG_KOBJECT_RELEASE 73 - struct delayed_work release; 74 - #endif 72 + 75 73 unsigned int state_initialized:1; 76 74 unsigned int state_in_sysfs:1; 77 75 unsigned int state_add_uevent_sent:1; 78 76 unsigned int state_remove_uevent_sent:1; 79 77 unsigned int uevent_suppress:1; 78 + 79 + #ifdef CONFIG_DEBUG_KOBJECT_RELEASE 80 + struct delayed_work release; 81 + #endif 80 82 }; 81 83 82 84 __printf(2, 3) int kobject_set_name(struct kobject *kobj, const char *name, ...);
+31 -31
lib/kobject.c
··· 56 56 kobj->ktype->get_ownership(kobj, uid, gid); 57 57 } 58 58 59 + static bool kobj_ns_type_is_valid(enum kobj_ns_type type) 60 + { 61 + if ((type <= KOBJ_NS_TYPE_NONE) || (type >= KOBJ_NS_TYPES)) 62 + return false; 63 + 64 + return true; 65 + } 66 + 59 67 static int create_dir(struct kobject *kobj) 60 68 { 61 69 const struct kobj_type *ktype = get_ktype(kobj); ··· 74 66 if (error) 75 67 return error; 76 68 77 - if (ktype) { 78 - error = sysfs_create_groups(kobj, ktype->default_groups); 79 - if (error) { 80 - sysfs_remove_dir(kobj); 81 - return error; 82 - } 69 + error = sysfs_create_groups(kobj, ktype->default_groups); 70 + if (error) { 71 + sysfs_remove_dir(kobj); 72 + return error; 83 73 } 84 74 85 75 /* ··· 92 86 */ 93 87 ops = kobj_child_ns_ops(kobj); 94 88 if (ops) { 95 - BUG_ON(ops->type <= KOBJ_NS_TYPE_NONE); 96 - BUG_ON(ops->type >= KOBJ_NS_TYPES); 89 + BUG_ON(!kobj_ns_type_is_valid(ops->type)); 97 90 BUG_ON(!kobj_ns_type_registered(ops->type)); 98 91 99 92 sysfs_enable_ns(kobj->sd); ··· 589 584 sd = kobj->sd; 590 585 ktype = get_ktype(kobj); 591 586 592 - if (ktype) 593 - sysfs_remove_groups(kobj, ktype->default_groups); 587 + sysfs_remove_groups(kobj, ktype->default_groups); 594 588 595 589 /* send "remove" if the caller did not do it but sent "add" */ 596 590 if (kobj->state_add_uevent_sent && !kobj->state_remove_uevent_sent) { ··· 666 662 pr_debug("'%s' (%p): %s, parent %p\n", 667 663 kobject_name(kobj), kobj, __func__, kobj->parent); 668 664 669 - if (t && !t->release) 670 - pr_debug("'%s' (%p): does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.\n", 671 - kobject_name(kobj), kobj); 672 - 673 665 /* remove from sysfs if the caller did not do it */ 674 666 if (kobj->state_in_sysfs) { 675 667 pr_debug("'%s' (%p): auto cleanup kobject_del\n", ··· 676 676 parent = NULL; 677 677 } 678 678 679 - if (t && t->release) { 679 + if (t->release) { 680 680 pr_debug("'%s' (%p): calling ktype release\n", 681 681 kobject_name(kobj), kobj); 682 682 t->release(kobj); 683 + } else { 684 + pr_debug("'%s' (%p): does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.\n", 685 + kobject_name(kobj), kobj); 683 686 } 684 687 685 688 /* free name if we allocated it */ ··· 857 854 if (!k) 858 855 return -EINVAL; 859 856 857 + if (!k->kobj.ktype) { 858 + pr_err("must have a ktype to be initialized properly!\n"); 859 + return -EINVAL; 860 + } 861 + 860 862 kset_init(k); 861 863 err = kobject_add_internal(&k->kobj); 862 864 if (err) { ··· 1025 1017 spin_lock(&kobj_ns_type_lock); 1026 1018 1027 1019 error = -EINVAL; 1028 - if (type >= KOBJ_NS_TYPES) 1029 - goto out; 1030 - 1031 - error = -EINVAL; 1032 - if (type <= KOBJ_NS_TYPE_NONE) 1020 + if (!kobj_ns_type_is_valid(type)) 1033 1021 goto out; 1034 1022 1035 1023 error = -EBUSY; ··· 1045 1041 int registered = 0; 1046 1042 1047 1043 spin_lock(&kobj_ns_type_lock); 1048 - if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES)) 1044 + if (kobj_ns_type_is_valid(type)) 1049 1045 registered = kobj_ns_ops_tbl[type] != NULL; 1050 1046 spin_unlock(&kobj_ns_type_lock); 1051 1047 ··· 1056 1052 { 1057 1053 const struct kobj_ns_type_operations *ops = NULL; 1058 1054 1059 - if (parent && parent->ktype && parent->ktype->child_ns_type) 1055 + if (parent && parent->ktype->child_ns_type) 1060 1056 ops = parent->ktype->child_ns_type(parent); 1061 1057 1062 1058 return ops; ··· 1072 1068 bool may_mount = true; 1073 1069 1074 1070 spin_lock(&kobj_ns_type_lock); 1075 - if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) && 1076 - kobj_ns_ops_tbl[type]) 1071 + if (kobj_ns_type_is_valid(type) && kobj_ns_ops_tbl[type]) 1077 1072 may_mount = kobj_ns_ops_tbl[type]->current_may_mount(); 1078 1073 spin_unlock(&kobj_ns_type_lock); 1079 1074 ··· 1084 1081 void *ns = NULL; 1085 1082 1086 1083 spin_lock(&kobj_ns_type_lock); 1087 - if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) && 1088 - kobj_ns_ops_tbl[type]) 1084 + if (kobj_ns_type_is_valid(type) && kobj_ns_ops_tbl[type]) 1089 1085 ns = kobj_ns_ops_tbl[type]->grab_current_ns(); 1090 1086 spin_unlock(&kobj_ns_type_lock); 1091 1087 ··· 1097 1095 const void *ns = NULL; 1098 1096 1099 1097 spin_lock(&kobj_ns_type_lock); 1100 - if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) && 1101 - kobj_ns_ops_tbl[type]) 1098 + if (kobj_ns_type_is_valid(type) && kobj_ns_ops_tbl[type]) 1102 1099 ns = kobj_ns_ops_tbl[type]->netlink_ns(sk); 1103 1100 spin_unlock(&kobj_ns_type_lock); 1104 1101 ··· 1109 1108 const void *ns = NULL; 1110 1109 1111 1110 spin_lock(&kobj_ns_type_lock); 1112 - if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) && 1113 - kobj_ns_ops_tbl[type]) 1111 + if (kobj_ns_type_is_valid(type) && kobj_ns_ops_tbl[type]) 1114 1112 ns = kobj_ns_ops_tbl[type]->initial_ns(); 1115 1113 spin_unlock(&kobj_ns_type_lock); 1116 1114 ··· 1119 1119 void kobj_ns_drop(enum kobj_ns_type type, void *ns) 1120 1120 { 1121 1121 spin_lock(&kobj_ns_type_lock); 1122 - if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) && 1122 + if (kobj_ns_type_is_valid(type) && 1123 1123 kobj_ns_ops_tbl[type] && kobj_ns_ops_tbl[type]->drop_ns) 1124 1124 kobj_ns_ops_tbl[type]->drop_ns(ns); 1125 1125 spin_unlock(&kobj_ns_type_lock);