Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0324e745 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'driver-core-3.13-rc1' of...

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

Pull driver core / sysfs patches from Greg KH:
 "Here's the big driver core / sysfs update for 3.13-rc1.

  There's lots of dev_groups updates for different subsystems, as they
  all get slowly migrated over to the safe versions of the attribute
  groups (removing userspace races with the creation of the sysfs
  files.) Also in here are some kobject updates, devres expansions, and
  the first round of Tejun's sysfs reworking to enable it to be used by
  other subsystems as a backend for an in-kernel filesystem.

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

* tag 'driver-core-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (83 commits)
  sysfs: rename sysfs_assoc_lock and explain what it's about
  sysfs: use generic_file_llseek() for sysfs_file_operations
  sysfs: return correct error code on unimplemented mmap()
  mdio_bus: convert bus code to use dev_groups
  device: Make dev_WARN/dev_WARN_ONCE print device as well as driver name
  sysfs: separate out dup filename warning into a separate function
  sysfs: move sysfs_hash_and_remove() to fs/sysfs/dir.c
  sysfs: remove unused sysfs_get_dentry() prototype
  sysfs: honor bin_attr.attr.ignore_lockdep
  sysfs: merge sysfs_elem_bin_attr into sysfs_elem_attr
  devres: restore zeroing behavior of devres_alloc()
  sysfs: fix sysfs_write_file for bin file
  input: gameport: convert bus code to use dev_groups
  input: serio: remove bus usage of dev_attrs
  input: serio: use DEVICE_ATTR_RO()
  i2o: convert bus code to use dev_groups
  memstick: convert bus code to use dev_groups
  tifm: convert bus code to use dev_groups
  virtio: convert bus code to use dev_groups
  ipack: convert bus code to use dev_groups
  ...
parents 1071ec7b 0cae60f9
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -91,7 +91,6 @@
     <title>The Filesystem for Exporting Kernel Objects</title>
     <title>The Filesystem for Exporting Kernel Objects</title>
!Efs/sysfs/file.c
!Efs/sysfs/file.c
!Efs/sysfs/symlink.c
!Efs/sysfs/symlink.c
!Efs/sysfs/bin.c
  </chapter>
  </chapter>


  <chapter id="debugfs">
  <chapter id="debugfs">
+8 −6
Original line number Original line Diff line number Diff line
@@ -292,6 +292,7 @@ static ssize_t ibmebus_store_probe(struct bus_type *bus,
		return rc;
		return rc;
	return count;
	return count;
}
}
static BUS_ATTR(probe, S_IWUSR, NULL, ibmebus_store_probe);


static ssize_t ibmebus_store_remove(struct bus_type *bus,
static ssize_t ibmebus_store_remove(struct bus_type *bus,
				    const char *buf, size_t count)
				    const char *buf, size_t count)
@@ -317,13 +318,14 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus,
		return -ENODEV;
		return -ENODEV;
	}
	}
}
}
static BUS_ATTR(remove, S_IWUSR, NULL, ibmebus_store_remove);



static struct attribute *ibmbus_bus_attrs[] = {
static struct bus_attribute ibmebus_bus_attrs[] = {
	&bus_attr_probe.attr,
	__ATTR(probe, S_IWUSR, NULL, ibmebus_store_probe),
	&bus_attr_remove.attr,
	__ATTR(remove, S_IWUSR, NULL, ibmebus_store_remove),
	NULL,
	__ATTR_NULL
};
};
ATTRIBUTE_GROUPS(ibmbus_bus);


static int ibmebus_bus_bus_match(struct device *dev, struct device_driver *drv)
static int ibmebus_bus_bus_match(struct device *dev, struct device_driver *drv)
{
{
@@ -713,7 +715,7 @@ static struct dev_pm_ops ibmebus_bus_dev_pm_ops = {
struct bus_type ibmebus_bus_type = {
struct bus_type ibmebus_bus_type = {
	.name      = "ibmebus",
	.name      = "ibmebus",
	.uevent    = of_device_uevent_modalias,
	.uevent    = of_device_uevent_modalias,
	.bus_attrs = ibmebus_bus_attrs,
	.bus_groups = ibmbus_bus_groups,
	.match     = ibmebus_bus_bus_match,
	.match     = ibmebus_bus_bus_match,
	.probe     = ibmebus_bus_device_probe,
	.probe     = ibmebus_bus_device_probe,
	.remove    = ibmebus_bus_device_remove,
	.remove    = ibmebus_bus_device_remove,
+36 −30
Original line number Original line Diff line number Diff line
@@ -997,20 +997,35 @@ static struct device_attribute vio_cmo_dev_attrs[] = {
/* sysfs bus functions and data structures for CMO */
/* sysfs bus functions and data structures for CMO */


#define viobus_cmo_rd_attr(name)                                        \
#define viobus_cmo_rd_attr(name)                                        \
static ssize_t                                                          \
static ssize_t cmo_##name##_show(struct bus_type *bt, char *buf)        \
viobus_cmo_##name##_show(struct bus_type *bt, char *buf)                \
{                                                                       \
{                                                                       \
	return sprintf(buf, "%lu\n", vio_cmo.name);                     \
	return sprintf(buf, "%lu\n", vio_cmo.name);                     \
}
}                                                                       \
static BUS_ATTR_RO(cmo_##name)


#define viobus_cmo_pool_rd_attr(name, var)                              \
#define viobus_cmo_pool_rd_attr(name, var)                              \
static ssize_t                                                          \
static ssize_t                                                          \
viobus_cmo_##name##_pool_show_##var(struct bus_type *bt, char *buf)     \
cmo_##name##_##var##_show(struct bus_type *bt, char *buf)               \
{                                                                       \
{                                                                       \
	return sprintf(buf, "%lu\n", vio_cmo.name.var);                 \
	return sprintf(buf, "%lu\n", vio_cmo.name.var);                 \
}                                                                       \
static BUS_ATTR_RO(cmo_##name##_##var)

viobus_cmo_rd_attr(entitled);
viobus_cmo_rd_attr(spare);
viobus_cmo_rd_attr(min);
viobus_cmo_rd_attr(desired);
viobus_cmo_rd_attr(curr);
viobus_cmo_pool_rd_attr(reserve, size);
viobus_cmo_pool_rd_attr(excess, size);
viobus_cmo_pool_rd_attr(excess, free);

static ssize_t cmo_high_show(struct bus_type *bt, char *buf)
{
	return sprintf(buf, "%lu\n", vio_cmo.high);
}
}


static ssize_t viobus_cmo_high_reset(struct bus_type *bt, const char *buf,
static ssize_t cmo_high_store(struct bus_type *bt, const char *buf,
			      size_t count)
			      size_t count)
{
{
	unsigned long flags;
	unsigned long flags;
@@ -1021,35 +1036,26 @@ static ssize_t viobus_cmo_high_reset(struct bus_type *bt, const char *buf,


	return count;
	return count;
}
}

static BUS_ATTR_RW(cmo_high);
viobus_cmo_rd_attr(entitled);

viobus_cmo_pool_rd_attr(reserve, size);
static struct attribute *vio_bus_attrs[] = {
viobus_cmo_pool_rd_attr(excess, size);
	&bus_attr_cmo_entitled.attr,
viobus_cmo_pool_rd_attr(excess, free);
	&bus_attr_cmo_spare.attr,
viobus_cmo_rd_attr(spare);
	&bus_attr_cmo_min.attr,
viobus_cmo_rd_attr(min);
	&bus_attr_cmo_desired.attr,
viobus_cmo_rd_attr(desired);
	&bus_attr_cmo_curr.attr,
viobus_cmo_rd_attr(curr);
	&bus_attr_cmo_high.attr,
viobus_cmo_rd_attr(high);
	&bus_attr_cmo_reserve_size.attr,

	&bus_attr_cmo_excess_size.attr,
static struct bus_attribute vio_cmo_bus_attrs[] = {
	&bus_attr_cmo_excess_free.attr,
	__ATTR(cmo_entitled, S_IRUGO, viobus_cmo_entitled_show, NULL),
	NULL,
	__ATTR(cmo_reserve_size, S_IRUGO, viobus_cmo_reserve_pool_show_size, NULL),
	__ATTR(cmo_excess_size, S_IRUGO, viobus_cmo_excess_pool_show_size, NULL),
	__ATTR(cmo_excess_free, S_IRUGO, viobus_cmo_excess_pool_show_free, NULL),
	__ATTR(cmo_spare,   S_IRUGO, viobus_cmo_spare_show,   NULL),
	__ATTR(cmo_min,     S_IRUGO, viobus_cmo_min_show,     NULL),
	__ATTR(cmo_desired, S_IRUGO, viobus_cmo_desired_show, NULL),
	__ATTR(cmo_curr,    S_IRUGO, viobus_cmo_curr_show,    NULL),
	__ATTR(cmo_high,    S_IWUSR|S_IRUSR|S_IWGRP|S_IRGRP|S_IROTH,
	       viobus_cmo_high_show, viobus_cmo_high_reset),
	__ATTR_NULL
};
};
ATTRIBUTE_GROUPS(vio_bus);


static void vio_cmo_sysfs_init(void)
static void vio_cmo_sysfs_init(void)
{
{
	vio_bus_type.dev_attrs = vio_cmo_dev_attrs;
	vio_bus_type.dev_attrs = vio_cmo_dev_attrs;
	vio_bus_type.bus_attrs = vio_cmo_bus_attrs;
	vio_bus_type.bus_groups = vio_bus_groups;
}
}
#else /* CONFIG_PPC_SMLPAR */
#else /* CONFIG_PPC_SMLPAR */
int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; }
int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; }
+2 −80
Original line number Original line Diff line number Diff line
@@ -591,37 +591,6 @@ void bus_remove_device(struct device *dev)
	bus_put(dev->bus);
	bus_put(dev->bus);
}
}


static int driver_add_attrs(struct bus_type *bus, struct device_driver *drv)
{
	int error = 0;
	int i;

	if (bus->drv_attrs) {
		for (i = 0; bus->drv_attrs[i].attr.name; i++) {
			error = driver_create_file(drv, &bus->drv_attrs[i]);
			if (error)
				goto err;
		}
	}
done:
	return error;
err:
	while (--i >= 0)
		driver_remove_file(drv, &bus->drv_attrs[i]);
	goto done;
}

static void driver_remove_attrs(struct bus_type *bus,
				struct device_driver *drv)
{
	int i;

	if (bus->drv_attrs) {
		for (i = 0; bus->drv_attrs[i].attr.name; i++)
			driver_remove_file(drv, &bus->drv_attrs[i]);
	}
}

static int __must_check add_bind_files(struct device_driver *drv)
static int __must_check add_bind_files(struct device_driver *drv)
{
{
	int ret;
	int ret;
@@ -720,16 +689,12 @@ int bus_add_driver(struct device_driver *drv)
		printk(KERN_ERR "%s: uevent attr (%s) failed\n",
		printk(KERN_ERR "%s: uevent attr (%s) failed\n",
			__func__, drv->name);
			__func__, drv->name);
	}
	}
	error = driver_add_attrs(bus, drv);
	error = driver_add_groups(drv, bus->drv_groups);
	if (error) {
	if (error) {
		/* How the hell do we get out of this pickle? Give up */
		/* How the hell do we get out of this pickle? Give up */
		printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n",
			__func__, drv->name);
	}
	error = driver_add_groups(drv, bus->drv_groups);
	if (error)
		printk(KERN_ERR "%s: driver_create_groups(%s) failed\n",
		printk(KERN_ERR "%s: driver_create_groups(%s) failed\n",
			__func__, drv->name);
			__func__, drv->name);
	}


	if (!drv->suppress_bind_attrs) {
	if (!drv->suppress_bind_attrs) {
		error = add_bind_files(drv);
		error = add_bind_files(drv);
@@ -766,7 +731,6 @@ void bus_remove_driver(struct device_driver *drv)


	if (!drv->suppress_bind_attrs)
	if (!drv->suppress_bind_attrs)
		remove_bind_files(drv);
		remove_bind_files(drv);
	driver_remove_attrs(drv->bus, drv);
	driver_remove_groups(drv, drv->bus->drv_groups);
	driver_remove_groups(drv, drv->bus->drv_groups);
	driver_remove_file(drv, &driver_attr_uevent);
	driver_remove_file(drv, &driver_attr_uevent);
	klist_remove(&drv->p->knode_bus);
	klist_remove(&drv->p->knode_bus);
@@ -846,42 +810,6 @@ struct bus_type *find_bus(char *name)
}
}
#endif  /*  0  */
#endif  /*  0  */



/**
 * bus_add_attrs - Add default attributes for this bus.
 * @bus: Bus that has just been registered.
 */

static int bus_add_attrs(struct bus_type *bus)
{
	int error = 0;
	int i;

	if (bus->bus_attrs) {
		for (i = 0; bus->bus_attrs[i].attr.name; i++) {
			error = bus_create_file(bus, &bus->bus_attrs[i]);
			if (error)
				goto err;
		}
	}
done:
	return error;
err:
	while (--i >= 0)
		bus_remove_file(bus, &bus->bus_attrs[i]);
	goto done;
}

static void bus_remove_attrs(struct bus_type *bus)
{
	int i;

	if (bus->bus_attrs) {
		for (i = 0; bus->bus_attrs[i].attr.name; i++)
			bus_remove_file(bus, &bus->bus_attrs[i]);
	}
}

static int bus_add_groups(struct bus_type *bus,
static int bus_add_groups(struct bus_type *bus,
			  const struct attribute_group **groups)
			  const struct attribute_group **groups)
{
{
@@ -983,9 +911,6 @@ int bus_register(struct bus_type *bus)
	if (retval)
	if (retval)
		goto bus_probe_files_fail;
		goto bus_probe_files_fail;


	retval = bus_add_attrs(bus);
	if (retval)
		goto bus_attrs_fail;
	retval = bus_add_groups(bus, bus->bus_groups);
	retval = bus_add_groups(bus, bus->bus_groups);
	if (retval)
	if (retval)
		goto bus_groups_fail;
		goto bus_groups_fail;
@@ -994,8 +919,6 @@ int bus_register(struct bus_type *bus)
	return 0;
	return 0;


bus_groups_fail:
bus_groups_fail:
	bus_remove_attrs(bus);
bus_attrs_fail:
	remove_probe_files(bus);
	remove_probe_files(bus);
bus_probe_files_fail:
bus_probe_files_fail:
	kset_unregister(bus->p->drivers_kset);
	kset_unregister(bus->p->drivers_kset);
@@ -1024,7 +947,6 @@ void bus_unregister(struct bus_type *bus)
	pr_debug("bus: '%s': unregistering\n", bus->name);
	pr_debug("bus: '%s': unregistering\n", bus->name);
	if (bus->dev_root)
	if (bus->dev_root)
		device_unregister(bus->dev_root);
		device_unregister(bus->dev_root);
	bus_remove_attrs(bus);
	bus_remove_groups(bus, bus->bus_groups);
	bus_remove_groups(bus, bus->bus_groups);
	remove_probe_files(bus);
	remove_probe_files(bus);
	kset_unregister(bus->p->drivers_kset);
	kset_unregister(bus->p->drivers_kset);
+9 −20
Original line number Original line Diff line number Diff line
@@ -47,18 +47,6 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
	return ret;
	return ret;
}
}


static const void *class_attr_namespace(struct kobject *kobj,
					const struct attribute *attr)
{
	struct class_attribute *class_attr = to_class_attr(attr);
	struct subsys_private *cp = to_subsys_private(kobj);
	const void *ns = NULL;

	if (class_attr->namespace)
		ns = class_attr->namespace(cp->class, class_attr);
	return ns;
}

static void class_release(struct kobject *kobj)
static void class_release(struct kobject *kobj)
{
{
	struct subsys_private *cp = to_subsys_private(kobj);
	struct subsys_private *cp = to_subsys_private(kobj);
@@ -86,7 +74,6 @@ static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject
static const struct sysfs_ops class_sysfs_ops = {
static const struct sysfs_ops class_sysfs_ops = {
	.show	   = class_attr_show,
	.show	   = class_attr_show,
	.store	   = class_attr_store,
	.store	   = class_attr_store,
	.namespace = class_attr_namespace,
};
};


static struct kobj_type class_ktype = {
static struct kobj_type class_ktype = {
@@ -99,21 +86,23 @@ static struct kobj_type class_ktype = {
static struct kset *class_kset;
static struct kset *class_kset;




int class_create_file(struct class *cls, const struct class_attribute *attr)
int class_create_file_ns(struct class *cls, const struct class_attribute *attr,
			 const void *ns)
{
{
	int error;
	int error;
	if (cls)
	if (cls)
		error = sysfs_create_file(&cls->p->subsys.kobj,
		error = sysfs_create_file_ns(&cls->p->subsys.kobj,
					  &attr->attr);
					     &attr->attr, ns);
	else
	else
		error = -EINVAL;
		error = -EINVAL;
	return error;
	return error;
}
}


void class_remove_file(struct class *cls, const struct class_attribute *attr)
void class_remove_file_ns(struct class *cls, const struct class_attribute *attr,
			  const void *ns)
{
{
	if (cls)
	if (cls)
		sysfs_remove_file(&cls->p->subsys.kobj, &attr->attr);
		sysfs_remove_file_ns(&cls->p->subsys.kobj, &attr->attr, ns);
}
}


static struct class *class_get(struct class *cls)
static struct class *class_get(struct class *cls)
@@ -600,8 +589,8 @@ int __init classes_init(void)
	return 0;
	return 0;
}
}


EXPORT_SYMBOL_GPL(class_create_file);
EXPORT_SYMBOL_GPL(class_create_file_ns);
EXPORT_SYMBOL_GPL(class_remove_file);
EXPORT_SYMBOL_GPL(class_remove_file_ns);
EXPORT_SYMBOL_GPL(class_unregister);
EXPORT_SYMBOL_GPL(class_unregister);
EXPORT_SYMBOL_GPL(class_destroy);
EXPORT_SYMBOL_GPL(class_destroy);


Loading