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

Commit 4db8e282 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Revert "driver core: move knode_bus into private structure"



This reverts commit b9daa99e.

Turns out that device_initialize shouldn't fail silently.
This series needs to be reworked in order to get into proper
shape.

Reported-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 73d59314
Loading
Loading
Loading
Loading
+0 −4
Original line number Original line Diff line number Diff line
@@ -69,7 +69,6 @@ struct class_private {
 * @klist_children - klist containing all children of this device
 * @klist_children - klist containing all children of this device
 * @knode_parent - node in sibling list
 * @knode_parent - node in sibling list
 * @knode_driver - node in driver list
 * @knode_driver - node in driver list
 * @knode_bus - node in bus list
 * @device - pointer back to the struct class that this structure is
 * @device - pointer back to the struct class that this structure is
 * associated with.
 * associated with.
 *
 *
@@ -79,15 +78,12 @@ struct device_private {
	struct klist klist_children;
	struct klist klist_children;
	struct klist_node knode_parent;
	struct klist_node knode_parent;
	struct klist_node knode_driver;
	struct klist_node knode_driver;
	struct klist_node knode_bus;
	struct device *device;
	struct device *device;
};
};
#define to_device_private_parent(obj)	\
#define to_device_private_parent(obj)	\
	container_of(obj, struct device_private, knode_parent)
	container_of(obj, struct device_private, knode_parent)
#define to_device_private_driver(obj)	\
#define to_device_private_driver(obj)	\
	container_of(obj, struct device_private, knode_driver)
	container_of(obj, struct device_private, knode_driver)
#define to_device_private_bus(obj)	\
	container_of(obj, struct device_private, knode_bus)


/* initialisation functions */
/* initialisation functions */
extern int devices_init(void);
extern int devices_init(void);
+13 −27
Original line number Original line Diff line number Diff line
@@ -253,14 +253,7 @@ static ssize_t store_drivers_probe(struct bus_type *bus,
static struct device *next_device(struct klist_iter *i)
static struct device *next_device(struct klist_iter *i)
{
{
	struct klist_node *n = klist_next(i);
	struct klist_node *n = klist_next(i);
	struct device *dev = NULL;
	return n ? container_of(n, struct device, knode_bus) : NULL;
	struct device_private *dev_prv;

	if (n) {
		dev_prv = to_device_private_bus(n);
		dev = dev_prv->device;
	}
	return dev;
}
}


/**
/**
@@ -293,7 +286,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start,
		return -EINVAL;
		return -EINVAL;


	klist_iter_init_node(&bus->p->klist_devices, &i,
	klist_iter_init_node(&bus->p->klist_devices, &i,
			     (start ? &start->p->knode_bus : NULL));
			     (start ? &start->knode_bus : NULL));
	while ((dev = next_device(&i)) && !error)
	while ((dev = next_device(&i)) && !error)
		error = fn(dev, data);
		error = fn(dev, data);
	klist_iter_exit(&i);
	klist_iter_exit(&i);
@@ -327,7 +320,7 @@ struct device *bus_find_device(struct bus_type *bus,
		return NULL;
		return NULL;


	klist_iter_init_node(&bus->p->klist_devices, &i,
	klist_iter_init_node(&bus->p->klist_devices, &i,
			     (start ? &start->p->knode_bus : NULL));
			     (start ? &start->knode_bus : NULL));
	while ((dev = next_device(&i)))
	while ((dev = next_device(&i)))
		if (match(dev, data) && get_device(dev))
		if (match(dev, data) && get_device(dev))
			break;
			break;
@@ -514,8 +507,7 @@ void bus_attach_device(struct device *dev)
			ret = device_attach(dev);
			ret = device_attach(dev);
		WARN_ON(ret < 0);
		WARN_ON(ret < 0);
		if (ret >= 0)
		if (ret >= 0)
			klist_add_tail(&dev->p->knode_bus,
			klist_add_tail(&dev->knode_bus, &bus->p->klist_devices);
				       &bus->p->klist_devices);
	}
	}
}
}


@@ -536,8 +528,8 @@ void bus_remove_device(struct device *dev)
		sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
		sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
				  dev_name(dev));
				  dev_name(dev));
		device_remove_attrs(dev->bus, dev);
		device_remove_attrs(dev->bus, dev);
		if (klist_node_attached(&dev->p->knode_bus))
		if (klist_node_attached(&dev->knode_bus))
			klist_del(&dev->p->knode_bus);
			klist_del(&dev->knode_bus);


		pr_debug("bus: '%s': remove device %s\n",
		pr_debug("bus: '%s': remove device %s\n",
			 dev->bus->name, dev_name(dev));
			 dev->bus->name, dev_name(dev));
@@ -839,16 +831,14 @@ static void bus_remove_attrs(struct bus_type *bus)


static void klist_devices_get(struct klist_node *n)
static void klist_devices_get(struct klist_node *n)
{
{
	struct device_private *dev_prv = to_device_private_bus(n);
	struct device *dev = container_of(n, struct device, knode_bus);
	struct device *dev = dev_prv->device;


	get_device(dev);
	get_device(dev);
}
}


static void klist_devices_put(struct klist_node *n)
static void klist_devices_put(struct klist_node *n)
{
{
	struct device_private *dev_prv = to_device_private_bus(n);
	struct device *dev = container_of(n, struct device, knode_bus);
	struct device *dev = dev_prv->device;


	put_device(dev);
	put_device(dev);
}
}
@@ -1003,20 +993,18 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list
{
{
	struct list_head *pos;
	struct list_head *pos;
	struct klist_node *n;
	struct klist_node *n;
	struct device_private *dev_prv;
	struct device *b;
	struct device *b;


	list_for_each(pos, list) {
	list_for_each(pos, list) {
		n = container_of(pos, struct klist_node, n_node);
		n = container_of(pos, struct klist_node, n_node);
		dev_prv = to_device_private_bus(n);
		b = container_of(n, struct device, knode_bus);
		b = dev_prv->device;
		if (compare(a, b) <= 0) {
		if (compare(a, b) <= 0) {
			list_move_tail(&a->p->knode_bus.n_node,
			list_move_tail(&a->knode_bus.n_node,
				       &b->p->knode_bus.n_node);
				       &b->knode_bus.n_node);
			return;
			return;
		}
		}
	}
	}
	list_move_tail(&a->p->knode_bus.n_node, list);
	list_move_tail(&a->knode_bus.n_node, list);
}
}


void bus_sort_breadthfirst(struct bus_type *bus,
void bus_sort_breadthfirst(struct bus_type *bus,
@@ -1026,7 +1014,6 @@ void bus_sort_breadthfirst(struct bus_type *bus,
	LIST_HEAD(sorted_devices);
	LIST_HEAD(sorted_devices);
	struct list_head *pos, *tmp;
	struct list_head *pos, *tmp;
	struct klist_node *n;
	struct klist_node *n;
	struct device_private *dev_prv;
	struct device *dev;
	struct device *dev;
	struct klist *device_klist;
	struct klist *device_klist;


@@ -1035,8 +1022,7 @@ void bus_sort_breadthfirst(struct bus_type *bus,
	spin_lock(&device_klist->k_lock);
	spin_lock(&device_klist->k_lock);
	list_for_each_safe(pos, tmp, &device_klist->k_list) {
	list_for_each_safe(pos, tmp, &device_klist->k_list) {
		n = container_of(pos, struct klist_node, n_node);
		n = container_of(pos, struct klist_node, n_node);
		dev_prv = to_device_private_bus(n);
		dev = container_of(n, struct device, knode_bus);
		dev = dev_prv->device;
		device_insertion_sort_klist(dev, &sorted_devices, compare);
		device_insertion_sort_klist(dev, &sorted_devices, compare);
	}
	}
	list_splice(&sorted_devices, &device_klist->k_list);
	list_splice(&sorted_devices, &device_klist->k_list);
+1 −0
Original line number Original line Diff line number Diff line
@@ -366,6 +366,7 @@ struct device_dma_parameters {
};
};


struct device {
struct device {
	struct klist_node	knode_bus;
	struct device		*parent;
	struct device		*parent;


	struct device_private	*p;
	struct device_private	*p;