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

Commit 5e655772 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Linus Torvalds
Browse files

[PATCH] openfirmware: generate device table for userspace

This converts the usage of struct of_match to struct of_device_id,
similar to pci_device_id.  This allows a device table to be generated,
which can be parsed by depmod(8) to generate a map file for module
loading.

In order for hotplug to work with macio devices, patches to
module-init-tools and hotplug must be applied.  Those patches are
available at:

 ftp://ftp.suse.com/pub/people/jeffm/linux/macio-hotplug/



Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 159f597a
Loading
Loading
Loading
Loading
+8 −7
Original line number Original line Diff line number Diff line
@@ -3,6 +3,7 @@
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <asm/errno.h>
#include <asm/errno.h>
#include <asm/of_device.h>
#include <asm/of_device.h>


@@ -15,20 +16,20 @@
 * Used by a driver to check whether an of_device present in the
 * Used by a driver to check whether an of_device present in the
 * system is in its list of supported devices.
 * system is in its list of supported devices.
 */
 */
const struct of_match * of_match_device(const struct of_match *matches,
const struct of_device_id * of_match_device(const struct of_device_id *matches,
					const struct of_device *dev)
					const struct of_device *dev)
{
{
	if (!dev->node)
	if (!dev->node)
		return NULL;
		return NULL;
	while (matches->name || matches->type || matches->compatible) {
	while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
		int match = 1;
		int match = 1;
		if (matches->name && matches->name != OF_ANY_MATCH)
		if (matches->name[0])
			match &= dev->node->name
			match &= dev->node->name
				&& !strcmp(matches->name, dev->node->name);
				&& !strcmp(matches->name, dev->node->name);
		if (matches->type && matches->type != OF_ANY_MATCH)
		if (matches->type[0])
			match &= dev->node->type
			match &= dev->node->type
				&& !strcmp(matches->type, dev->node->type);
				&& !strcmp(matches->type, dev->node->type);
		if (matches->compatible && matches->compatible != OF_ANY_MATCH)
		if (matches->compatible[0])
			match &= device_is_compatible(dev->node,
			match &= device_is_compatible(dev->node,
				matches->compatible);
				matches->compatible);
		if (match)
		if (match)
@@ -42,7 +43,7 @@ static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
{
{
	struct of_device * of_dev = to_of_device(dev);
	struct of_device * of_dev = to_of_device(dev);
	struct of_platform_driver * of_drv = to_of_platform_driver(drv);
	struct of_platform_driver * of_drv = to_of_platform_driver(drv);
	const struct of_match * matches = of_drv->match_table;
	const struct of_device_id * matches = of_drv->match_table;


	if (!matches)
	if (!matches)
		return 0;
		return 0;
@@ -75,7 +76,7 @@ static int of_device_probe(struct device *dev)
	int error = -ENODEV;
	int error = -ENODEV;
	struct of_platform_driver *drv;
	struct of_platform_driver *drv;
	struct of_device *of_dev;
	struct of_device *of_dev;
	const struct of_match *match;
	const struct of_device_id *match;


	drv = to_of_platform_driver(dev->driver);
	drv = to_of_platform_driver(dev->driver);
	of_dev = to_of_device(dev);
	of_dev = to_of_device(dev);
+8 −7
Original line number Original line Diff line number Diff line
@@ -3,6 +3,7 @@
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <asm/errno.h>
#include <asm/errno.h>
#include <asm/of_device.h>
#include <asm/of_device.h>


@@ -15,20 +16,20 @@
 * Used by a driver to check whether an of_device present in the
 * Used by a driver to check whether an of_device present in the
 * system is in its list of supported devices.
 * system is in its list of supported devices.
 */
 */
const struct of_match * of_match_device(const struct of_match *matches,
const struct of_device_id *of_match_device(const struct of_device_id *matches,
					const struct of_device *dev)
					const struct of_device *dev)
{
{
	if (!dev->node)
	if (!dev->node)
		return NULL;
		return NULL;
	while (matches->name || matches->type || matches->compatible) {
	while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
		int match = 1;
		int match = 1;
		if (matches->name && matches->name != OF_ANY_MATCH)
		if (matches->name[0])
			match &= dev->node->name
			match &= dev->node->name
				&& !strcmp(matches->name, dev->node->name);
				&& !strcmp(matches->name, dev->node->name);
		if (matches->type && matches->type != OF_ANY_MATCH)
		if (matches->type[0])
			match &= dev->node->type
			match &= dev->node->type
				&& !strcmp(matches->type, dev->node->type);
				&& !strcmp(matches->type, dev->node->type);
		if (matches->compatible && matches->compatible != OF_ANY_MATCH)
		if (matches->compatible[0])
			match &= device_is_compatible(dev->node,
			match &= device_is_compatible(dev->node,
				matches->compatible);
				matches->compatible);
		if (match)
		if (match)
@@ -42,7 +43,7 @@ static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
{
{
	struct of_device * of_dev = to_of_device(dev);
	struct of_device * of_dev = to_of_device(dev);
	struct of_platform_driver * of_drv = to_of_platform_driver(drv);
	struct of_platform_driver * of_drv = to_of_platform_driver(drv);
	const struct of_match * matches = of_drv->match_table;
	const struct of_device_id * matches = of_drv->match_table;


	if (!matches)
	if (!matches)
		return 0;
		return 0;
@@ -75,7 +76,7 @@ static int of_device_probe(struct device *dev)
	int error = -ENODEV;
	int error = -ENODEV;
	struct of_platform_driver *drv;
	struct of_platform_driver *drv;
	struct of_device *of_dev;
	struct of_device *of_dev;
	const struct of_match *match;
	const struct of_device_id *match;


	drv = to_of_platform_driver(dev->driver);
	drv = to_of_platform_driver(dev->driver);
	of_dev = to_of_device(dev);
	of_dev = to_of_device(dev);
+3 −4
Original line number Original line Diff line number Diff line
@@ -698,7 +698,7 @@ dispose_iface(struct device *dev)
}
}


static int
static int
create_iface_macio(struct macio_dev* dev, const struct of_match *match)
create_iface_macio(struct macio_dev* dev, const struct of_device_id *match)
{
{
	return create_iface(dev->ofdev.node, &dev->ofdev.dev);
	return create_iface(dev->ofdev.node, &dev->ofdev.dev);
}
}
@@ -710,7 +710,7 @@ dispose_iface_macio(struct macio_dev* dev)
}
}


static int
static int
create_iface_of_platform(struct of_device* dev, const struct of_match *match)
create_iface_of_platform(struct of_device* dev, const struct of_device_id *match)
{
{
	return create_iface(dev->node, &dev->dev);
	return create_iface(dev->node, &dev->dev);
}
}
@@ -721,10 +721,9 @@ dispose_iface_of_platform(struct of_device* dev)
	return dispose_iface(&dev->dev);
	return dispose_iface(&dev->dev);
}
}


static struct of_match i2c_keywest_match[] = 
static struct of_device_id i2c_keywest_match[] = 
{
{
	{
	{
	.name 		= OF_ANY_MATCH,
	.type		= "i2c",
	.type		= "i2c",
	.compatible	= "keywest"
	.compatible	= "keywest"
	},
	},
+2 −10
Original line number Original line Diff line number Diff line
@@ -1419,7 +1419,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
 * Attach to a macio probed interface
 * Attach to a macio probed interface
 */
 */
static int __devinit
static int __devinit
pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_match *match)
pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
{
{
	void __iomem *base;
	void __iomem *base;
	unsigned long regbase;
	unsigned long regbase;
@@ -1637,27 +1637,19 @@ pmac_ide_pci_resume(struct pci_dev *pdev)
	return rc;
	return rc;
}
}


static struct of_match pmac_ide_macio_match[] = 
static struct of_device_id pmac_ide_macio_match[] = 
{
{
	{
	{
	.name 		= "IDE",
	.name 		= "IDE",
	.type		= OF_ANY_MATCH,
	.compatible	= OF_ANY_MATCH
	},
	},
	{
	{
	.name 		= "ATA",
	.name 		= "ATA",
	.type		= OF_ANY_MATCH,
	.compatible	= OF_ANY_MATCH
	},
	},
	{
	{
	.name 		= OF_ANY_MATCH,
	.type		= "ide",
	.type		= "ide",
	.compatible	= OF_ANY_MATCH
	},
	},
	{
	{
	.name 		= OF_ANY_MATCH,
	.type		= "ata",
	.type		= "ata",
	.compatible	= OF_ANY_MATCH
	},
	},
	{},
	{},
};
};
+2 −2
Original line number Original line Diff line number Diff line
@@ -33,7 +33,7 @@ static int macio_bus_match(struct device *dev, struct device_driver *drv)
{
{
	struct macio_dev * macio_dev = to_macio_device(dev);
	struct macio_dev * macio_dev = to_macio_device(dev);
	struct macio_driver * macio_drv = to_macio_driver(drv);
	struct macio_driver * macio_drv = to_macio_driver(drv);
	const struct of_match * matches = macio_drv->match_table;
	const struct of_device_id * matches = macio_drv->match_table;


	if (!matches) 
	if (!matches) 
		return 0;
		return 0;
@@ -66,7 +66,7 @@ static int macio_device_probe(struct device *dev)
	int error = -ENODEV;
	int error = -ENODEV;
	struct macio_driver *drv;
	struct macio_driver *drv;
	struct macio_dev *macio_dev;
	struct macio_dev *macio_dev;
	const struct of_match *match;
	const struct of_device_id *match;


	drv = to_macio_driver(dev->driver);
	drv = to_macio_driver(dev->driver);
	macio_dev = to_macio_device(dev);
	macio_dev = to_macio_device(dev);
Loading