From 38e9e21dac33082f0440d24aefb3466bb18bfed6 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Fri, 18 Mar 2011 10:21:28 -0600 Subject: dt: Refactor of_platform_bus_probe() The current implementation uses three copies of of basically identical code. This patch consolidates them to make the code simpler. Signed-off-by: Grant Likely diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 1ce4c45..f489e36 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -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 + * 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,7 +243,7 @@ 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 * @parent: parent to hook devices from, NULL for toplevel @@ -258,7 +256,6 @@ 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)) @@ -277,31 +274,15 @@ int of_platform_bus_probe(struct device_node *root, * 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; } -- cgit v0.10.2 From a52f07ecd143baee51623b063be5007585748a4f Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Fri, 18 Mar 2011 10:21:29 -0600 Subject: dt: protect against NULL matches passed to of_match_node() There are a few use cases where it is convenient to pass NULL to of_match_node() and have it fail gracefully. The patch adds a null check to the beginning so taht it does so. Signed-off-by: Grant Likely diff --git a/drivers/of/base.c b/drivers/of/base.c index 710b53b..632ebae 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -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]) -- cgit v0.10.2 From 1eed4c077c31450bfcd0249aebb21d96fc5d5d3c Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Fri, 18 Mar 2011 10:21:29 -0600 Subject: dt: eliminate OF_NO_DEEP_PROBE and test for NULL match table There are no users of OF_NO_DEEP_PROBE, and of_match_node() now gracefully handles being passed a NULL pointer, so the checks at the top of of_platform_bus_probe can be dropped. While at it, consolidate the root node pointer check to be easier to read and tidy up related comments. Signed-off-by: Grant Likely diff --git a/drivers/of/platform.c b/drivers/of/platform.c index f489e36..63d3cb7 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -212,7 +212,7 @@ EXPORT_SYMBOL(of_platform_device_create); /** * 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 + * @matches: match table for bus nodes * disallow recursive creation of child buses * @parent: parent for new device, or NULL for top level. * @@ -245,7 +245,7 @@ static int of_platform_bus_create(struct device_node *bus, /** * 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,21 +258,14 @@ int of_platform_bus_probe(struct device_node *root, struct device_node *child; 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)) { rc = of_platform_bus_create(root, matches, parent); } else for_each_child_of_node(root, child) { diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 17c7e21..fb51ae3 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -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); -- cgit v0.10.2 From a7006c9747ef225ab070d96c054e85682a09a13e Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 17 Mar 2011 17:32:35 -0700 Subject: of/flattree: minor cleanups - static-ize some functions - add some additional comments Signed-off-by: Andres Salomon Signed-off-by: Grant Likely diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index af824e7..c9db49c 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -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)) { -- cgit v0.10.2 From 95c5c3ab7db0dcaeebeb771b90152cd47aa27243 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Mon, 21 Mar 2011 16:27:30 +0200 Subject: spi/omap_mcspi: Fix broken last word xfer Commit adef658 "spi/omap_mcspi: catch xfers of non-multiple SPI word size" broke the transmission of last word in cases where access is multiple of word size and word size is 16 or 32 bits. Fix this by replacing the test "c > (word_len>>3)" in do-while loops with "c >= 'pointer increment size'". This ensures that the last word is transmitted in above case and still allow to break the loop and prevent variable c underflow in cases where word size != 'pointer increment size'. Signed-off-by: Jarkko Nikula Tested-by: Sourav Poddar Acked-by: Michael Jones Signed-off-by: Grant Likely diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index 3a5ed06..6f86ba0 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c @@ -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 */ -- cgit v0.10.2 From 06fb01fd1dc624d891cbe039a88a44bc8a8a9ec1 Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Wed, 23 Mar 2011 11:05:16 +0100 Subject: spi/pl022: Add loopback support for the SPI on 5500 Extend the vendor data with a loopback field, and add new amba-pl022 vendor data for the DB5500 pl023, as the pl023 on db8500 and db5500 vary. Signed-off-by: Prajadevi H Signed-off-by: Philippe Langlais Signed-off-by: Linus Walleij Signed-off-by: Grant Likely diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c index 5c2b092..5a4e0af 100644 --- a/drivers/spi/amba-pl022.c +++ b/drivers/spi/amba-pl022.c @@ -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 }, }; -- cgit v0.10.2