History

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

Linus Torvalds committed 7 years ago

Commit 72d657d2 parents f7c1038 735df0f6 files · +17 −10Browse files

Unified · Split

6 files
  1. Documentation/driver-model/bus.txt +4 −4
  2. Documentation/filesystems/sysfs.txt +3 −1
  3. fs/sysfs/dir.c +2 −1
  4. fs/sysfs/file.c +4 −2
  5. fs/sysfs/group.c +2 −1
  6. fs/sysfs/symlink.c +2 −1
Documentation/driver-model/bus.txt+4−4
@@ -124,11 +124,11 @@ struct bus_attribute { · 123 unmodified lines
124124 ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
125125 };
126126
127−Bus drivers can export attributes using the BUS_ATTR macro that works
128−similarly to the DEVICE_ATTR macro for devices. For example, a definition
129−like this:
127+Bus drivers can export attributes using the BUS_ATTR_RW macro that works
128+similarly to the DEVICE_ATTR_RW macro for devices. For example, a
129+definition like this:
130130
131−static BUS_ATTR(debug,0644,show_debug,store_debug);
131+static BUS_ATTR_RW(debug);
132132
133133 is equivalent to declaring:
134134
Documentation/filesystems/sysfs.txt+3−1
@@ -344,7 +344,9 @@ struct bus_attribute { · 343 unmodified lines
344344
345345 Declaring:
346346
347−BUS_ATTR(_name, _mode, _show, _store)
347+static BUS_ATTR_RW(name);
348+static BUS_ATTR_RO(name);
349+static BUS_ATTR_WO(name);
348350
349351 Creation/Removal:
350352
fs/sysfs/dir.c+2−1
@@ -43,7 +43,8 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) · 42 unmodified lines
4343 kuid_t uid;
4444 kgid_t gid;
4545
46− BUG_ON(!kobj);
46+ if (WARN_ON(!kobj))
47+ return -EINVAL;
4748
4849 if (kobj->parent)
4950 parent = kobj->parent->sd;
fs/sysfs/file.c+4−2
@@ -325,7 +325,8 @@ int sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr, · 324 unmodified lines
325325 kuid_t uid;
326326 kgid_t gid;
327327
328− BUG_ON(!kobj || !kobj->sd || !attr);
328+ if (WARN_ON(!kobj || !kobj->sd || !attr))
329+ return -EINVAL;
329330
330331 kobject_get_ownership(kobj, &uid, &gid);
331332 return sysfs_add_file_mode_ns(kobj->sd, attr, false, attr->mode,
@@ -537,7 +538,8 @@ int sysfs_create_bin_file(struct kobject *kobj, · 205 unmodified lines
537538 kuid_t uid;
538539 kgid_t gid;
539540
540− BUG_ON(!kobj || !kobj->sd || !attr);
541+ if (WARN_ON(!kobj || !kobj->sd || !attr))
542+ return -EINVAL;
541543
542544 kobject_get_ownership(kobj, &uid, &gid);
543545 return sysfs_add_file_mode_ns(kobj->sd, &attr->attr, true,
fs/sysfs/group.c+2−1
@@ -112,7 +112,8 @@ static int internal_create_group(struct kobject *kobj, int update, · 111 unmodified lines
112112 kgid_t gid;
113113 int error;
114114
115− BUG_ON(!kobj || (!update && !kobj->sd));
115+ if (WARN_ON(!kobj || (!update && !kobj->sd)))
116+ return -EINVAL;
116117
117118 /* Updates may happen before the object has been instantiated */
118119 if (unlikely(update && !kobj->sd))
fs/sysfs/symlink.c+2−1
@@ -23,7 +23,8 @@ static int sysfs_do_create_link_sd(struct kernfs_node *parent, · 22 unmodified lines
2323 {
2424 struct kernfs_node *kn, *target = NULL;
2525
26− BUG_ON(!name || !parent);
26+ if (WARN_ON(!name || !parent))
27+ return -EINVAL;
2728
2829 /*
2930 * We don't own @target_kobj and it may be removed at any time.