aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-01-13 12:51:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-01-13 12:51:08 -0500
commit72d657dd2115804b93bde4b77e426cc2de70eebf (patch)
tree13f5b1b6e7cebfe80187654563868457b29e9034
parentf7c1038bc7597af5d6809c5b3e0352627cef5c07 (diff)
parent735df0ff6ece7b8759a744158f5d246fae4739f4 (diff)
Merge tag 'driver-core-5.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core fixes from Greg KH: "Here is one small sysfs change, and a documentation update for 5.0-rc2 The sysfs change moves from using BUG_ON to WARN_ON, as discussed in an email thread on lkml while trying to track down another driver bug. sysfs should not be crashing and preventing people from seeing where they went wrong. Now it properly recovers and warns the developer. The documentation update removes the use of BUS_ATTR() as the kernel is moving away from this to use the specific BUS_ATTR_RW() and friends instead. There are pending patches in all of the different subsystems to remove the last users of this macro, but for now, don't advertise it should be used anymore to keep new ones from being introduced. Both have been in linux-next with no reported issues" * tag 'driver-core-5.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: Documentation: driver core: remove use of BUS_ATTR sysfs: convert BUG_ON to WARN_ON
-rw-r--r--Documentation/driver-model/bus.txt8
-rw-r--r--Documentation/filesystems/sysfs.txt4
-rw-r--r--fs/sysfs/dir.c3
-rw-r--r--fs/sysfs/file.c6
-rw-r--r--fs/sysfs/group.c3
-rw-r--r--fs/sysfs/symlink.c3
6 files changed, 17 insertions, 10 deletions
diff --git a/Documentation/driver-model/bus.txt b/Documentation/driver-model/bus.txt
index b577a45b93ea..c247b488a567 100644
--- a/Documentation/driver-model/bus.txt
+++ b/Documentation/driver-model/bus.txt
@@ -124,11 +124,11 @@ struct bus_attribute {
124 ssize_t (*store)(struct bus_type *, const char * buf, size_t count); 124 ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
125}; 125};
126 126
127Bus drivers can export attributes using the BUS_ATTR macro that works 127Bus drivers can export attributes using the BUS_ATTR_RW macro that works
128similarly to the DEVICE_ATTR macro for devices. For example, a definition 128similarly to the DEVICE_ATTR_RW macro for devices. For example, a
129like this: 129definition like this:
130 130
131static BUS_ATTR(debug,0644,show_debug,store_debug); 131static BUS_ATTR_RW(debug);
132 132
133is equivalent to declaring: 133is equivalent to declaring:
134 134
diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt
index a1426cabcef1..41411b0c60a3 100644
--- a/Documentation/filesystems/sysfs.txt
+++ b/Documentation/filesystems/sysfs.txt
@@ -344,7 +344,9 @@ struct bus_attribute {
344 344
345Declaring: 345Declaring:
346 346
347BUS_ATTR(_name, _mode, _show, _store) 347static BUS_ATTR_RW(name);
348static BUS_ATTR_RO(name);
349static BUS_ATTR_WO(name);
348 350
349Creation/Removal: 351Creation/Removal:
350 352
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index feeae8081c22..aa85f2874a9f 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -43,7 +43,8 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
43 kuid_t uid; 43 kuid_t uid;
44 kgid_t gid; 44 kgid_t gid;
45 45
46 BUG_ON(!kobj); 46 if (WARN_ON(!kobj))
47 return -EINVAL;
47 48
48 if (kobj->parent) 49 if (kobj->parent)
49 parent = kobj->parent->sd; 50 parent = kobj->parent->sd;
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index bb71db63c99c..51398457fe00 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -325,7 +325,8 @@ int sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr,
325 kuid_t uid; 325 kuid_t uid;
326 kgid_t gid; 326 kgid_t gid;
327 327
328 BUG_ON(!kobj || !kobj->sd || !attr); 328 if (WARN_ON(!kobj || !kobj->sd || !attr))
329 return -EINVAL;
329 330
330 kobject_get_ownership(kobj, &uid, &gid); 331 kobject_get_ownership(kobj, &uid, &gid);
331 return sysfs_add_file_mode_ns(kobj->sd, attr, false, attr->mode, 332 return sysfs_add_file_mode_ns(kobj->sd, attr, false, attr->mode,
@@ -537,7 +538,8 @@ int sysfs_create_bin_file(struct kobject *kobj,
537 kuid_t uid; 538 kuid_t uid;
538 kgid_t gid; 539 kgid_t gid;
539 540
540 BUG_ON(!kobj || !kobj->sd || !attr); 541 if (WARN_ON(!kobj || !kobj->sd || !attr))
542 return -EINVAL;
541 543
542 kobject_get_ownership(kobj, &uid, &gid); 544 kobject_get_ownership(kobj, &uid, &gid);
543 return sysfs_add_file_mode_ns(kobj->sd, &attr->attr, true, 545 return sysfs_add_file_mode_ns(kobj->sd, &attr->attr, true,
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 1eb2d6307663..57038604d4a8 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -112,7 +112,8 @@ static int internal_create_group(struct kobject *kobj, int update,
112 kgid_t gid; 112 kgid_t gid;
113 int error; 113 int error;
114 114
115 BUG_ON(!kobj || (!update && !kobj->sd)); 115 if (WARN_ON(!kobj || (!update && !kobj->sd)))
116 return -EINVAL;
116 117
117 /* Updates may happen before the object has been instantiated */ 118 /* Updates may happen before the object has been instantiated */
118 if (unlikely(update && !kobj->sd)) 119 if (unlikely(update && !kobj->sd))
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 215c225b2ca1..c4deecc80f67 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -23,7 +23,8 @@ static int sysfs_do_create_link_sd(struct kernfs_node *parent,
23{ 23{
24 struct kernfs_node *kn, *target = NULL; 24 struct kernfs_node *kn, *target = NULL;
25 25
26 BUG_ON(!name || !parent); 26 if (WARN_ON(!name || !parent))
27 return -EINVAL;
27 28
28 /* 29 /*
29 * We don't own @target_kobj and it may be removed at any time. 30 * We don't own @target_kobj and it may be removed at any time.