Merge branch 'devicetree/merge' of git://git.secretlab.ca/git/linux-2.6

* 'devicetree/merge' of git://git.secretlab.ca/git/linux-2.6:
  spi/pl022: Add loopback support for the SPI on 5500
  spi/omap_mcspi: Fix broken last word xfer
  of/flattree: minor cleanups
  dt: eliminate OF_NO_DEEP_PROBE and test for NULL match table
  dt: protect against NULL matches passed to of_match_node()
  dt: Refactor of_platform_bus_probe()
This commit is contained in:
Linus Torvalds 2011-03-24 09:30:20 -07:00
commit e264ac8cad
6 changed files with 52 additions and 58 deletions

View File

@ -496,6 +496,9 @@ EXPORT_SYMBOL(of_find_node_with_property);
const struct of_device_id *of_match_node(const struct of_device_id *matches,
const struct device_node *node)
{
if (!matches)
return NULL;
while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
int match = 1;
if (matches->name[0])

View File

@ -139,12 +139,13 @@ static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size,
/**
* unflatten_dt_node - Alloc and populate a device_node from the flat tree
* @blob: The parent device tree blob
* @mem: Memory chunk to use for allocating device nodes and properties
* @p: pointer to node in flat tree
* @dad: Parent struct device_node
* @allnextpp: pointer to ->allnext from last allocated device_node
* @fpsize: Size of the node path up at the current depth.
*/
unsigned long unflatten_dt_node(struct boot_param_header *blob,
static unsigned long unflatten_dt_node(struct boot_param_header *blob,
unsigned long mem,
unsigned long *p,
struct device_node *dad,
@ -230,6 +231,7 @@ unsigned long unflatten_dt_node(struct boot_param_header *blob,
}
kref_init(&np->kref);
}
/* process properties */
while (1) {
u32 sz, noff;
char *pname;
@ -351,7 +353,7 @@ unsigned long unflatten_dt_node(struct boot_param_header *blob,
* @dt_alloc: An allocator that provides a virtual address to memory
* for the resulting tree
*/
void __unflatten_device_tree(struct boot_param_header *blob,
static void __unflatten_device_tree(struct boot_param_header *blob,
struct device_node **mynodes,
void * (*dt_alloc)(u64 size, u64 align))
{

View File

@ -210,13 +210,16 @@ struct platform_device *of_platform_device_create(struct device_node *np,
EXPORT_SYMBOL(of_platform_device_create);
/**
* of_platform_bus_create - Create an OF device for a bus node and all its
* children. Optionally recursively instantiate matching busses.
* of_platform_bus_create() - Create a device for a node and its children.
* @bus: device node of the bus to instantiate
* @matches: match table, NULL to use the default, OF_NO_DEEP_PROBE to
* disallow recursive creation of child busses
* @matches: match table for bus nodes
* disallow recursive creation of child buses
* @parent: parent for new device, or NULL for top level.
*
* Creates a platform_device for the provided device_node, and optionally
* recursively create devices for all the child nodes.
*/
static int of_platform_bus_create(const struct device_node *bus,
static int of_platform_bus_create(struct device_node *bus,
const struct of_device_id *matches,
struct device *parent)
{
@ -224,18 +227,13 @@ static int of_platform_bus_create(const struct device_node *bus,
struct platform_device *dev;
int rc = 0;
dev = of_platform_device_create(bus, NULL, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
for_each_child_of_node(bus, child) {
pr_debug(" create child: %s\n", child->full_name);
dev = of_platform_device_create(child, NULL, parent);
if (dev == NULL)
continue;
if (!of_match_node(matches, child))
continue;
if (rc == 0) {
pr_debug(" and sub busses\n");
rc = of_platform_bus_create(child, matches, &dev->dev);
}
rc = of_platform_bus_create(child, matches, &dev->dev);
if (rc) {
of_node_put(child);
break;
@ -245,9 +243,9 @@ static int of_platform_bus_create(const struct device_node *bus,
}
/**
* of_platform_bus_probe - Probe the device-tree for platform busses
* of_platform_bus_probe() - Probe the device-tree for platform buses
* @root: parent of the first level to probe or NULL for the root of the tree
* @matches: match table, NULL to use the default
* @matches: match table for bus nodes
* @parent: parent to hook devices from, NULL for toplevel
*
* Note that children of the provided root are not instantiated as devices
@ -258,50 +256,26 @@ int of_platform_bus_probe(struct device_node *root,
struct device *parent)
{
struct device_node *child;
struct platform_device *dev;
int rc = 0;
if (WARN_ON(!matches || matches == OF_NO_DEEP_PROBE))
return -EINVAL;
if (root == NULL)
root = of_find_node_by_path("/");
else
of_node_get(root);
if (root == NULL)
root = root ? of_node_get(root) : of_find_node_by_path("/");
if (!root)
return -EINVAL;
pr_debug("of_platform_bus_probe()\n");
pr_debug(" starting at: %s\n", root->full_name);
/* Do a self check of bus type, if there's a match, create
* children
*/
/* Do a self check of bus type, if there's a match, create children */
if (of_match_node(matches, root)) {
pr_debug(" root match, create all sub devices\n");
dev = of_platform_device_create(root, NULL, parent);
if (dev == NULL)
goto bail;
pr_debug(" create all sub busses\n");
rc = of_platform_bus_create(root, matches, &dev->dev);
goto bail;
}
for_each_child_of_node(root, child) {
rc = of_platform_bus_create(root, matches, parent);
} else for_each_child_of_node(root, child) {
if (!of_match_node(matches, child))
continue;
pr_debug(" match: %s\n", child->full_name);
dev = of_platform_device_create(child, NULL, parent);
if (dev == NULL)
continue;
rc = of_platform_bus_create(child, matches, &dev->dev);
if (rc) {
of_node_put(child);
rc = of_platform_bus_create(child, matches, parent);
if (rc)
break;
}
}
bail:
of_node_put(root);
return rc;
}

View File

@ -324,6 +324,7 @@ struct vendor_data {
bool unidir;
bool extended_cr;
bool pl023;
bool loopback;
};
/**
@ -1983,7 +1984,7 @@ static int pl022_setup(struct spi_device *spi)
SSP_WRITE_BITS(chip->cr0, clk_freq.scr, SSP_CR0_MASK_SCR, 8);
/* Loopback is available on all versions except PL023 */
if (!pl022->vendor->pl023) {
if (pl022->vendor->loopback) {
if (spi->mode & SPI_LOOP)
tmp = LOOPBACK_ENABLED;
else
@ -2233,6 +2234,7 @@ static struct vendor_data vendor_arm = {
.unidir = false,
.extended_cr = false,
.pl023 = false,
.loopback = true,
};
@ -2242,6 +2244,7 @@ static struct vendor_data vendor_st = {
.unidir = false,
.extended_cr = true,
.pl023 = false,
.loopback = true,
};
static struct vendor_data vendor_st_pl023 = {
@ -2250,6 +2253,16 @@ static struct vendor_data vendor_st_pl023 = {
.unidir = false,
.extended_cr = true,
.pl023 = true,
.loopback = false,
};
static struct vendor_data vendor_db5500_pl023 = {
.fifodepth = 32,
.max_bpw = 32,
.unidir = false,
.extended_cr = true,
.pl023 = true,
.loopback = true,
};
static struct amba_id pl022_ids[] = {
@ -2283,6 +2296,11 @@ static struct amba_id pl022_ids[] = {
.mask = 0xffffffff,
.data = &vendor_st_pl023,
},
{
.id = 0x10080023,
.mask = 0xffffffff,
.data = &vendor_db5500_pl023,
},
{ 0, 0 },
};

View File

@ -517,7 +517,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
dev_vdbg(&spi->dev, "read-%d %02x\n",
word_len, *(rx - 1));
}
} while (c > (word_len>>3));
} while (c);
} else if (word_len <= 16) {
u16 *rx;
const u16 *tx;
@ -564,7 +564,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
dev_vdbg(&spi->dev, "read-%d %04x\n",
word_len, *(rx - 1));
}
} while (c > (word_len>>3));
} while (c >= 2);
} else if (word_len <= 32) {
u32 *rx;
const u32 *tx;
@ -611,7 +611,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
dev_vdbg(&spi->dev, "read-%d %08x\n",
word_len, *(rx - 1));
}
} while (c > (word_len>>3));
} while (c >= 4);
}
/* for TX_ONLY mode, be sure all words have shifted out */

View File

@ -52,9 +52,6 @@ extern struct platform_device *of_platform_device_create(struct device_node *np,
const char *bus_id,
struct device *parent);
/* pseudo "matches" value to not do deep probe */
#define OF_NO_DEEP_PROBE ((struct of_device_id *)-1)
extern int of_platform_bus_probe(struct device_node *root,
const struct of_device_id *matches,
struct device *parent);