Skip to content

Commit

Permalink
Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6
Browse files Browse the repository at this point in the history
* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6:
  of: change of_match_device to work with struct device
  of: Remove duplicate fields from of_platform_driver
  drivercore: Add of_match_table to the common device drivers
  arch/microblaze: Move dma_mask from of_device into pdev_archdata
  arch/powerpc: Move dma_mask from of_device into pdev_archdata
  of: eliminate of_device->node and dev_archdata->{of,prom}_node
  of: Always use 'struct device.of_node' to get device node pointer.
  i2c/of: Allow device node to be passed via i2c_board_info
  driver-core: Add device node pointer to struct device
  of: protect contents of of_platform.h and of_device.h
  of/flattree: Make unflatten_device_tree() safe to call from any arch
  of/flattree: make of_fdt.h safe to unconditionally include.
  • Loading branch information
Linus Torvalds committed May 24, 2010
2 parents cedfb2d + cf9b59e commit 62a11ae
Show file tree
Hide file tree
Showing 211 changed files with 1,254 additions and 974 deletions.
16 changes: 1 addition & 15 deletions arch/microblaze/include/asm/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,15 @@
struct device_node;

struct dev_archdata {
/* Optional pointer to an OF device node */
struct device_node *of_node;

/* DMA operations on that device */
struct dma_map_ops *dma_ops;
void *dma_data;
};

struct pdev_archdata {
u64 dma_mask;
};

static inline void dev_archdata_set_node(struct dev_archdata *ad,
struct device_node *np)
{
ad->of_node = np;
}

static inline struct device_node *
dev_archdata_get_node(const struct dev_archdata *ad)
{
return ad->of_node;
}

#endif /* _ASM_MICROBLAZE_DEVICE_H */


3 changes: 1 addition & 2 deletions arch/microblaze/include/asm/of_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
* probed using OF properties.
*/
struct of_device {
struct device_node *node; /* to be obsoleted */
u64 dma_mask; /* DMA mask */
struct device dev; /* Generic device interface */
struct pdev_archdata archdata;
};

extern ssize_t of_device_get_modalias(struct of_device *ofdev,
Expand Down
13 changes: 6 additions & 7 deletions arch/microblaze/kernel/of_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
void of_device_make_bus_id(struct of_device *dev)
{
static atomic_t bus_no_reg_magic;
struct device_node *node = dev->node;
struct device_node *node = dev->dev.of_node;
const u32 *reg;
u64 addr;
int magic;
Expand Down Expand Up @@ -49,11 +49,10 @@ struct of_device *of_device_alloc(struct device_node *np,
if (!dev)
return NULL;

dev->node = of_node_get(np);
dev->dev.dma_mask = &dev->dma_mask;
dev->dev.of_node = of_node_get(np);
dev->dev.dma_mask = &dev->archdata.dma_mask;
dev->dev.parent = parent;
dev->dev.release = of_release_dev;
dev->dev.archdata.of_node = np;

if (bus_id)
dev_set_name(&dev->dev, bus_id);
Expand All @@ -75,17 +74,17 @@ int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)

ofdev = to_of_device(dev);

if (add_uevent_var(env, "OF_NAME=%s", ofdev->node->name))
if (add_uevent_var(env, "OF_NAME=%s", ofdev->dev.of_node->name))
return -ENOMEM;

if (add_uevent_var(env, "OF_TYPE=%s", ofdev->node->type))
if (add_uevent_var(env, "OF_TYPE=%s", ofdev->dev.of_node->type))
return -ENOMEM;

/* Since the compatible field can contain pretty much anything
* it's not really legal to split it out with commas. We split it
* up using a number of environment variables instead. */

compat = of_get_property(ofdev->node, "compatible", &cplen);
compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen);
while (compat && *compat && cplen > 0) {
if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat))
return -ENOMEM;
Expand Down
6 changes: 3 additions & 3 deletions arch/microblaze/kernel/of_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct of_device *of_platform_device_create(struct device_node *np,
if (!dev)
return NULL;

dev->dma_mask = 0xffffffffUL;
dev->archdata.dma_mask = 0xffffffffUL;
dev->dev.bus = &of_platform_bus_type;

/* We do not fill the DMA ops for platform devices by default.
Expand Down Expand Up @@ -166,7 +166,7 @@ EXPORT_SYMBOL(of_platform_bus_probe);

static int of_dev_node_match(struct device *dev, void *data)
{
return to_of_device(dev)->node == data;
return to_of_device(dev)->dev.of_node == data;
}

struct of_device *of_find_device_by_node(struct device_node *np)
Expand All @@ -184,7 +184,7 @@ EXPORT_SYMBOL(of_find_device_by_node);
static int of_dev_phandle_match(struct device *dev, void *data)
{
phandle *ph = data;
return to_of_device(dev)->node->phandle == *ph;
return to_of_device(dev)->dev.of_node->phandle == *ph;
}

struct of_device *of_find_device_by_phandle(phandle ph)
Expand Down
16 changes: 1 addition & 15 deletions arch/powerpc/include/asm/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ struct dma_map_ops;
struct device_node;

struct dev_archdata {
/* Optional pointer to an OF device node */
struct device_node *of_node;

/* DMA operations on that device */
struct dma_map_ops *dma_ops;

Expand All @@ -30,19 +27,8 @@ struct dev_archdata {
#endif
};

static inline void dev_archdata_set_node(struct dev_archdata *ad,
struct device_node *np)
{
ad->of_node = np;
}

static inline struct device_node *
dev_archdata_get_node(const struct dev_archdata *ad)
{
return ad->of_node;
}

struct pdev_archdata {
u64 dma_mask;
};

#endif /* _ASM_POWERPC_DEVICE_H */
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/macio.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static inline void* macio_get_drvdata(struct macio_dev *dev)

static inline struct device_node *macio_get_of_node(struct macio_dev *mdev)
{
return mdev->ofdev.node;
return mdev->ofdev.dev.of_node;
}

#ifdef CONFIG_PCI
Expand Down
3 changes: 1 addition & 2 deletions arch/powerpc/include/asm/of_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
*/
struct of_device
{
struct device_node *node; /* to be obsoleted */
u64 dma_mask; /* DMA mask */
struct device dev; /* Generic device interface */
struct pdev_archdata archdata;
};

extern struct of_device *of_device_alloc(struct device_node *np,
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/kernel/ibmebus.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ static struct dma_map_ops ibmebus_dma_ops = {

static int ibmebus_match_path(struct device *dev, void *data)
{
struct device_node *dn = to_of_device(dev)->node;
struct device_node *dn = to_of_device(dev)->dev.of_node;
return (dn->full_name &&
(strcasecmp((char *)data, dn->full_name) == 0));
}

static int ibmebus_match_node(struct device *dev, void *data)
{
return to_of_device(dev)->node == data;
return to_of_device(dev)->dev.of_node == data;
}

static int ibmebus_create_device(struct device_node *dn)
Expand Down Expand Up @@ -202,7 +202,7 @@ static int ibmebus_create_devices(const struct of_device_id *matches)
int ibmebus_register_driver(struct of_platform_driver *drv)
{
/* If the driver uses devices that ibmebus doesn't know, add them */
ibmebus_create_devices(drv->match_table);
ibmebus_create_devices(drv->driver.of_match_table);

return of_register_driver(drv, &ibmebus_bus_type);
}
Expand Down
13 changes: 6 additions & 7 deletions arch/powerpc/kernel/of_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
static void of_device_make_bus_id(struct of_device *dev)
{
static atomic_t bus_no_reg_magic;
struct device_node *node = dev->node;
struct device_node *node = dev->dev.of_node;
const u32 *reg;
u64 addr;
int magic;
Expand Down Expand Up @@ -69,11 +69,10 @@ struct of_device *of_device_alloc(struct device_node *np,
if (!dev)
return NULL;

dev->node = of_node_get(np);
dev->dev.dma_mask = &dev->dma_mask;
dev->dev.of_node = of_node_get(np);
dev->dev.dma_mask = &dev->archdata.dma_mask;
dev->dev.parent = parent;
dev->dev.release = of_release_dev;
dev->dev.archdata.of_node = np;

if (bus_id)
dev_set_name(&dev->dev, "%s", bus_id);
Expand All @@ -95,17 +94,17 @@ int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)

ofdev = to_of_device(dev);

if (add_uevent_var(env, "OF_NAME=%s", ofdev->node->name))
if (add_uevent_var(env, "OF_NAME=%s", ofdev->dev.of_node->name))
return -ENOMEM;

if (add_uevent_var(env, "OF_TYPE=%s", ofdev->node->type))
if (add_uevent_var(env, "OF_TYPE=%s", ofdev->dev.of_node->type))
return -ENOMEM;

/* Since the compatible field can contain pretty much anything
* it's not really legal to split it out with commas. We split it
* up using a number of environment variables instead. */

compat = of_get_property(ofdev->node, "compatible", &cplen);
compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen);
while (compat && *compat && cplen > 0) {
if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat))
return -ENOMEM;
Expand Down
21 changes: 11 additions & 10 deletions arch/powerpc/kernel/of_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct of_device* of_platform_device_create(struct device_node *np,
if (!dev)
return NULL;

dev->dma_mask = 0xffffffffUL;
dev->archdata.dma_mask = 0xffffffffUL;
dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);

dev->dev.bus = &of_platform_bus_type;
Expand Down Expand Up @@ -195,7 +195,7 @@ EXPORT_SYMBOL(of_platform_bus_probe);

static int of_dev_node_match(struct device *dev, void *data)
{
return to_of_device(dev)->node == data;
return to_of_device(dev)->dev.of_node == data;
}

struct of_device *of_find_device_by_node(struct device_node *np)
Expand All @@ -213,7 +213,7 @@ EXPORT_SYMBOL(of_find_device_by_node);
static int of_dev_phandle_match(struct device *dev, void *data)
{
phandle *ph = data;
return to_of_device(dev)->node->phandle == *ph;
return to_of_device(dev)->dev.of_node->phandle == *ph;
}

struct of_device *of_find_device_by_phandle(phandle ph)
Expand Down Expand Up @@ -246,10 +246,10 @@ static int __devinit of_pci_phb_probe(struct of_device *dev,
if (ppc_md.pci_setup_phb == NULL)
return -ENODEV;

printk(KERN_INFO "Setting up PCI bus %s\n", dev->node->full_name);
pr_info("Setting up PCI bus %s\n", dev->dev.of_node->full_name);

/* Alloc and setup PHB data structure */
phb = pcibios_alloc_controller(dev->node);
phb = pcibios_alloc_controller(dev->dev.of_node);
if (!phb)
return -ENODEV;

Expand All @@ -263,19 +263,19 @@ static int __devinit of_pci_phb_probe(struct of_device *dev,
}

/* Process "ranges" property */
pci_process_bridge_OF_ranges(phb, dev->node, 0);
pci_process_bridge_OF_ranges(phb, dev->dev.of_node, 0);

/* Init pci_dn data structures */
pci_devs_phb_init_dynamic(phb);

/* Register devices with EEH */
#ifdef CONFIG_EEH
if (dev->node->child)
eeh_add_device_tree_early(dev->node);
if (dev->dev.of_node->child)
eeh_add_device_tree_early(dev->dev.of_node);
#endif /* CONFIG_EEH */

/* Scan the bus */
pcibios_scan_phb(phb, dev->node);
pcibios_scan_phb(phb, dev->dev.of_node);
if (phb->bus == NULL)
return -ENXIO;

Expand Down Expand Up @@ -306,10 +306,11 @@ static struct of_device_id of_pci_phb_ids[] = {
};

static struct of_platform_driver of_pci_phb_driver = {
.match_table = of_pci_phb_ids,
.probe = of_pci_phb_probe,
.driver = {
.name = "of-pci",
.owner = THIS_MODULE,
.of_match_table = of_pci_phb_ids,
},
};

Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/kernel/pci-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,8 +1097,8 @@ void __devinit pcibios_setup_bus_devices(struct pci_bus *bus)
if (dev->is_added)
continue;

/* Setup OF node pointer in archdata */
sd->of_node = pci_device_to_OF_node(dev);
/* Setup OF node pointer in the device */
dev->dev.of_node = pci_device_to_OF_node(dev);

/* Fixup NUMA node as it may not be setup yet by the generic
* code and is needed by the DMA init
Expand Down
Loading

0 comments on commit 62a11ae

Please sign in to comment.