diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-18 14:44:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-18 14:44:53 -0400 |
commit | a18d783fedfe6f9b720afe901db9501ce116ed81 (patch) | |
tree | 12e100b5b31657d11bfc5dc3e2ddd124f3690cb3 /fs/sysfs | |
parent | d5acba26bfa097a618be425522b1ec4269d3edaf (diff) | |
parent | d2fc88a61b4ea99f574bde16e92718e22f312136 (diff) |
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
...
Diffstat (limited to 'fs/sysfs')
-rw-r--r-- | fs/sysfs/group.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index c7a716c4acc9..1eb2d6307663 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c | |||
@@ -124,13 +124,22 @@ static int internal_create_group(struct kobject *kobj, int update, | |||
124 | } | 124 | } |
125 | kobject_get_ownership(kobj, &uid, &gid); | 125 | kobject_get_ownership(kobj, &uid, &gid); |
126 | if (grp->name) { | 126 | if (grp->name) { |
127 | kn = kernfs_create_dir_ns(kobj->sd, grp->name, | 127 | if (update) { |
128 | S_IRWXU | S_IRUGO | S_IXUGO, | 128 | kn = kernfs_find_and_get(kobj->sd, grp->name); |
129 | uid, gid, kobj, NULL); | 129 | if (!kn) { |
130 | if (IS_ERR(kn)) { | 130 | pr_warn("Can't update unknown attr grp name: %s/%s\n", |
131 | if (PTR_ERR(kn) == -EEXIST) | 131 | kobj->name, grp->name); |
132 | sysfs_warn_dup(kobj->sd, grp->name); | 132 | return -EINVAL; |
133 | return PTR_ERR(kn); | 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 | } else | 144 | } else |
136 | kn = kobj->sd; | 145 | kn = kobj->sd; |
@@ -141,6 +150,10 @@ static int internal_create_group(struct kobject *kobj, int update, | |||
141 | kernfs_remove(kn); | 150 | kernfs_remove(kn); |
142 | } | 151 | } |
143 | kernfs_put(kn); | 152 | kernfs_put(kn); |
153 | |||
154 | if (grp->name && update) | ||
155 | kernfs_put(kn); | ||
156 | |||
144 | return error; | 157 | return error; |
145 | } | 158 | } |
146 | 159 | ||
@@ -205,7 +218,8 @@ EXPORT_SYMBOL_GPL(sysfs_create_groups); | |||
205 | * of the attribute files being created already exist. Furthermore, | 218 | * of the attribute files being created already exist. Furthermore, |
206 | * if the visibility of the files has changed through the is_visible() | 219 | * if the visibility of the files has changed through the is_visible() |
207 | * callback, it will update the permissions and add or remove the | 220 | * callback, it will update the permissions and add or remove the |
208 | * relevant files. | 221 | * relevant files. Changing a group's name (subdirectory name under |
222 | * kobj's directory in sysfs) is not allowed. | ||
209 | * | 223 | * |
210 | * The primary use for this function is to call it after making a change | 224 | * The primary use for this function is to call it after making a change |
211 | * that affects group visibility. | 225 | * that affects group visibility. |