From a19e3da5bc5fc6c10ab73f310bea80f3845b4531 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Tue, 8 Jun 2010 07:48:16 -0600 Subject: of/gpio: Kill of_gpio_chip and add members directly to gpio_chip The OF gpio infrastructure is great for describing GPIO connections within the device tree. However, using a GPIO binding still requires changes to the gpio controller just to add an of_gpio structure. In most cases, the gpio controller doesn't actually need any special support and the simple OF gpio mapping function is more than sufficient. Additional, the current scheme of using of_gpio_chip requires a convoluted scheme to maintain 1:1 mappings between of_gpio_chip and gpio_chip instances. If the struct of_gpio_chip data members were moved into struct gpio_chip, then it would simplify the processing of OF gpio bindings, and it would make it trivial to use device tree OF connections on existing gpiolib controller drivers. This patch eliminates the of_gpio_chip structure and moves the relevant fields into struct gpio_chip (conditional on CONFIG_OF_GPIO). This move simplifies the existing code and prepares for adding automatic device tree support to existing drivers. Signed-off-by: Grant Likely Cc: Andrew Morton Cc: Anton Vorontsov Cc: Grant Likely Cc: David Brownell Cc: Bill Gatliff Cc: Dmitry Eremin-Solenikov Cc: Benjamin Herrenschmidt Cc: Jean Delvare --- arch/powerpc/sysdev/cpm1.c | 12 ++++-------- arch/powerpc/sysdev/cpm_common.c | 6 ++---- arch/powerpc/sysdev/mpc8xxx_gpio.c | 6 ++---- arch/powerpc/sysdev/ppc4xx_gpio.c | 6 ++---- arch/powerpc/sysdev/qe_lib/gpio.c | 32 +++++++++++++++----------------- arch/powerpc/sysdev/simple_gpio.c | 6 ++---- 6 files changed, 27 insertions(+), 41 deletions(-) (limited to 'arch/powerpc/sysdev') diff --git a/arch/powerpc/sysdev/cpm1.c b/arch/powerpc/sysdev/cpm1.c index 8d103ca6d6ab..d5cf7d4ccf81 100644 --- a/arch/powerpc/sysdev/cpm1.c +++ b/arch/powerpc/sysdev/cpm1.c @@ -621,7 +621,6 @@ int cpm1_gpiochip_add16(struct device_node *np) { struct cpm1_gpio16_chip *cpm1_gc; struct of_mm_gpio_chip *mm_gc; - struct of_gpio_chip *of_gc; struct gpio_chip *gc; cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); @@ -631,11 +630,10 @@ int cpm1_gpiochip_add16(struct device_node *np) spin_lock_init(&cpm1_gc->lock); mm_gc = &cpm1_gc->mm_gc; - of_gc = &mm_gc->of_gc; - gc = &of_gc->gc; + gc = &mm_gc->gc; mm_gc->save_regs = cpm1_gpio16_save_regs; - of_gc->gpio_cells = 2; + gc->of_gpio_n_cells = 2; gc->ngpio = 16; gc->direction_input = cpm1_gpio16_dir_in; gc->direction_output = cpm1_gpio16_dir_out; @@ -745,7 +743,6 @@ int cpm1_gpiochip_add32(struct device_node *np) { struct cpm1_gpio32_chip *cpm1_gc; struct of_mm_gpio_chip *mm_gc; - struct of_gpio_chip *of_gc; struct gpio_chip *gc; cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); @@ -755,11 +752,10 @@ int cpm1_gpiochip_add32(struct device_node *np) spin_lock_init(&cpm1_gc->lock); mm_gc = &cpm1_gc->mm_gc; - of_gc = &mm_gc->of_gc; - gc = &of_gc->gc; + gc = &mm_gc->gc; mm_gc->save_regs = cpm1_gpio32_save_regs; - of_gc->gpio_cells = 2; + gc->of_gpio_n_cells = 2; gc->ngpio = 32; gc->direction_input = cpm1_gpio32_dir_in; gc->direction_output = cpm1_gpio32_dir_out; diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c index 88b9812c854f..67e9b47dcf8e 100644 --- a/arch/powerpc/sysdev/cpm_common.c +++ b/arch/powerpc/sysdev/cpm_common.c @@ -325,7 +325,6 @@ int cpm2_gpiochip_add32(struct device_node *np) { struct cpm2_gpio32_chip *cpm2_gc; struct of_mm_gpio_chip *mm_gc; - struct of_gpio_chip *of_gc; struct gpio_chip *gc; cpm2_gc = kzalloc(sizeof(*cpm2_gc), GFP_KERNEL); @@ -335,11 +334,10 @@ int cpm2_gpiochip_add32(struct device_node *np) spin_lock_init(&cpm2_gc->lock); mm_gc = &cpm2_gc->mm_gc; - of_gc = &mm_gc->of_gc; - gc = &of_gc->gc; + gc = &mm_gc->gc; mm_gc->save_regs = cpm2_gpio32_save_regs; - of_gc->gpio_cells = 2; + gc->of_gpio_n_cells = 2; gc->ngpio = 32; gc->direction_input = cpm2_gpio32_dir_in; gc->direction_output = cpm2_gpio32_dir_out; diff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c index 83f519655fac..ec8fcd42101e 100644 --- a/arch/powerpc/sysdev/mpc8xxx_gpio.c +++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c @@ -257,7 +257,6 @@ static void __init mpc8xxx_add_controller(struct device_node *np) { struct mpc8xxx_gpio_chip *mpc8xxx_gc; struct of_mm_gpio_chip *mm_gc; - struct of_gpio_chip *of_gc; struct gpio_chip *gc; unsigned hwirq; int ret; @@ -271,11 +270,10 @@ static void __init mpc8xxx_add_controller(struct device_node *np) spin_lock_init(&mpc8xxx_gc->lock); mm_gc = &mpc8xxx_gc->mm_gc; - of_gc = &mm_gc->of_gc; - gc = &of_gc->gc; + gc = &mm_gc->gc; mm_gc->save_regs = mpc8xxx_gpio_save_regs; - of_gc->gpio_cells = 2; + gc->of_gpio_n_cells = 2; gc->ngpio = MPC8XXX_GPIO_PINS; gc->direction_input = mpc8xxx_gpio_dir_in; gc->direction_output = mpc8xxx_gpio_dir_out; diff --git a/arch/powerpc/sysdev/ppc4xx_gpio.c b/arch/powerpc/sysdev/ppc4xx_gpio.c index 3812fc366bec..42e7a5eea665 100644 --- a/arch/powerpc/sysdev/ppc4xx_gpio.c +++ b/arch/powerpc/sysdev/ppc4xx_gpio.c @@ -181,7 +181,6 @@ static int __init ppc4xx_add_gpiochips(void) int ret; struct ppc4xx_gpio_chip *ppc4xx_gc; struct of_mm_gpio_chip *mm_gc; - struct of_gpio_chip *of_gc; struct gpio_chip *gc; ppc4xx_gc = kzalloc(sizeof(*ppc4xx_gc), GFP_KERNEL); @@ -193,10 +192,9 @@ static int __init ppc4xx_add_gpiochips(void) spin_lock_init(&ppc4xx_gc->lock); mm_gc = &ppc4xx_gc->mm_gc; - of_gc = &mm_gc->of_gc; - gc = &of_gc->gc; + gc = &mm_gc->gc; - of_gc->gpio_cells = 2; + gc->of_gpio_n_cells = 2; gc->ngpio = 32; gc->direction_input = ppc4xx_gpio_dir_in; gc->direction_output = ppc4xx_gpio_dir_out; diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c index dc8f8d618074..194478c2f4b4 100644 --- a/arch/powerpc/sysdev/qe_lib/gpio.c +++ b/arch/powerpc/sysdev/qe_lib/gpio.c @@ -138,8 +138,8 @@ struct qe_pin { struct qe_pin *qe_pin_request(struct device_node *np, int index) { struct qe_pin *qe_pin; - struct device_node *gc; - struct of_gpio_chip *of_gc = NULL; + struct device_node *gpio_np; + struct gpio_chip *gc; struct of_mm_gpio_chip *mm_gc; struct qe_gpio_chip *qe_gc; int err; @@ -155,40 +155,40 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index) } err = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, - &gc, &gpio_spec); + &gpio_np, &gpio_spec); if (err) { pr_debug("%s: can't parse gpios property\n", __func__); goto err0; } - if (!of_device_is_compatible(gc, "fsl,mpc8323-qe-pario-bank")) { + if (!of_device_is_compatible(gpio_np, "fsl,mpc8323-qe-pario-bank")) { pr_debug("%s: tried to get a non-qe pin\n", __func__); err = -EINVAL; goto err1; } - of_gc = gc->data; - if (!of_gc) { + gc = gpio_np->data; + if (!gc) { pr_debug("%s: gpio controller %s isn't registered\n", - np->full_name, gc->full_name); + np->full_name, gpio_np->full_name); err = -ENODEV; goto err1; } - gpio_cells = of_get_property(gc, "#gpio-cells", &size); + gpio_cells = of_get_property(gpio_np, "#gpio-cells", &size); if (!gpio_cells || size != sizeof(*gpio_cells) || - *gpio_cells != of_gc->gpio_cells) { + *gpio_cells != gc->of_gpio_n_cells) { pr_debug("%s: wrong #gpio-cells for %s\n", - np->full_name, gc->full_name); + np->full_name, gpio_np->full_name); err = -EINVAL; goto err1; } - err = of_gc->xlate(of_gc, np, gpio_spec, NULL); + err = gc->of_xlate(gc, np, gpio_spec, NULL); if (err < 0) goto err1; - mm_gc = to_of_mm_gpio_chip(&of_gc->gc); + mm_gc = to_of_mm_gpio_chip(gc); qe_gc = to_qe_gpio_chip(mm_gc); spin_lock_irqsave(&qe_gc->lock, flags); @@ -206,7 +206,7 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index) if (!err) return qe_pin; err1: - of_node_put(gc); + of_node_put(gpio_np); err0: kfree(qe_pin); pr_debug("%s failed with status %d\n", __func__, err); @@ -307,7 +307,6 @@ static int __init qe_add_gpiochips(void) int ret; struct qe_gpio_chip *qe_gc; struct of_mm_gpio_chip *mm_gc; - struct of_gpio_chip *of_gc; struct gpio_chip *gc; qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL); @@ -319,11 +318,10 @@ static int __init qe_add_gpiochips(void) spin_lock_init(&qe_gc->lock); mm_gc = &qe_gc->mm_gc; - of_gc = &mm_gc->of_gc; - gc = &of_gc->gc; + gc = &mm_gc->gc; mm_gc->save_regs = qe_gpio_save_regs; - of_gc->gpio_cells = 2; + gc->of_gpio_n_cells = 2; gc->ngpio = QE_PIO_PINS; gc->direction_input = qe_gpio_dir_in; gc->direction_output = qe_gpio_dir_out; diff --git a/arch/powerpc/sysdev/simple_gpio.c b/arch/powerpc/sysdev/simple_gpio.c index d5fb173e588c..b7559aa0c165 100644 --- a/arch/powerpc/sysdev/simple_gpio.c +++ b/arch/powerpc/sysdev/simple_gpio.c @@ -91,7 +91,6 @@ static int __init u8_simple_gpiochip_add(struct device_node *np) int ret; struct u8_gpio_chip *u8_gc; struct of_mm_gpio_chip *mm_gc; - struct of_gpio_chip *of_gc; struct gpio_chip *gc; u8_gc = kzalloc(sizeof(*u8_gc), GFP_KERNEL); @@ -101,11 +100,10 @@ static int __init u8_simple_gpiochip_add(struct device_node *np) spin_lock_init(&u8_gc->lock); mm_gc = &u8_gc->mm_gc; - of_gc = &mm_gc->of_gc; - gc = &of_gc->gc; + gc = &mm_gc->gc; mm_gc->save_regs = u8_gpio_save_regs; - of_gc->gpio_cells = 2; + gc->of_gpio_n_cells = 2; gc->ngpio = 8; gc->direction_input = u8_gpio_dir_in; gc->direction_output = u8_gpio_dir_out; -- cgit v1.2.3 From 594fa265e084073443390c5b93d5410fd28e9bcd Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Tue, 8 Jun 2010 07:48:16 -0600 Subject: of/gpio: stop using device_node data pointer to find gpio_chip Currently the kernel uses the struct device_node.data pointer to resolve a struct gpio_chip pointer from a device tree node. However, the .data member doesn't provide any type checking and there aren't any rules enforced on what it should be used for. There's no guarantee that the data stored in it actually points to an gpio_chip pointer. Instead of relying on the .data pointer, this patch modifies the code to add a lookup function which scans through the registered gpio_chips and returns the gpio_chip that has a pointer to the specified device_node. Signed-off-by: Grant Likely CC: Andrew Morton CC: Anton Vorontsov CC: Grant Likely CC: David Brownell CC: Bill Gatliff CC: Dmitry Eremin-Solenikov CC: Benjamin Herrenschmidt CC: Jean Delvare CC: linux-kernel@vger.kernel.org CC: devicetree-discuss@lists.ozlabs.org --- arch/microblaze/kernel/reset.c | 2 +- arch/powerpc/platforms/52xx/mpc52xx_gpt.c | 1 + arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c | 23 +++--------------- arch/powerpc/sysdev/qe_lib/gpio.c | 2 +- drivers/gpio/gpiolib.c | 32 ++++++++++++++++++++++++++ drivers/of/gpio.c | 15 +++++++++--- include/asm-generic/gpio.h | 3 +++ include/linux/of_gpio.h | 3 +++ 8 files changed, 56 insertions(+), 25 deletions(-) (limited to 'arch/powerpc/sysdev') diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c index 5476d3caf045..bd8ccab5ceff 100644 --- a/arch/microblaze/kernel/reset.c +++ b/arch/microblaze/kernel/reset.c @@ -39,7 +39,7 @@ static int of_reset_gpio_handle(void) goto err0; } - gc = gpio->data; + gc = of_node_to_gpiochip(gpio); if (!gc) { pr_debug("%s: gpio controller %s isn't registered\n", root->full_name, gpio->full_name); diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c index 3f2ee47f1d01..6e82bd27132c 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c @@ -350,6 +350,7 @@ mpc52xx_gpt_gpio_setup(struct mpc52xx_gpt_priv *gpt, struct device_node *node) gpt->gc.base = -1; gpt->gc.of_gpio_n_cells = 2; gpt->gc.of_xlate = of_gpio_simple_xlate; + gpt->gc.of_node = node; of_node_get(node); /* Setup external pin in GPIO mode */ diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c index e49f4bd2f991..f0dbace6185a 100644 --- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c +++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c @@ -35,7 +35,6 @@ struct mcu { struct mutex lock; - struct device_node *np; struct i2c_client *client; struct gpio_chip gc; u8 reg_ctrl; @@ -79,7 +78,6 @@ static int mcu_gpiochip_add(struct mcu *mcu) { struct device_node *np; struct gpio_chip *gc = &mcu->gc; - int ret; np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx"); if (!np) @@ -94,29 +92,14 @@ static int mcu_gpiochip_add(struct mcu *mcu) gc->direction_output = mcu_gpio_dir_out; gc->of_gpio_n_cells = 2; gc->of_xlate = of_gpio_simple_xlate; + gc->of_node = np; - mcu->np = np; - - /* - * We don't want to lose the node, its ->data and ->full_name... - * So, if succeeded, we don't put the node here. - */ - ret = gpiochip_add(gc); - if (ret) - of_node_put(np); - return ret; + return gpiochip_add(gc); } static int mcu_gpiochip_remove(struct mcu *mcu) { - int ret; - - ret = gpiochip_remove(&mcu->gc); - if (ret) - return ret; - of_node_put(mcu->np); - - return 0; + return gpiochip_remove(&mcu->gc); } static int __devinit mcu_probe(struct i2c_client *client, diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c index 194478c2f4b4..32e9440010a1 100644 --- a/arch/powerpc/sysdev/qe_lib/gpio.c +++ b/arch/powerpc/sysdev/qe_lib/gpio.c @@ -167,7 +167,7 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index) goto err1; } - gc = gpio_np->data; + gc = of_node_to_gpiochip(gpio_np); if (!gc) { pr_debug("%s: gpio controller %s isn't registered\n", np->full_name, gpio_np->full_name); diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 713ca0e37f23..73fd328f6fe4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1153,6 +1153,38 @@ int gpiochip_remove(struct gpio_chip *chip) } EXPORT_SYMBOL_GPL(gpiochip_remove); +/** + * gpiochip_find() - iterator for locating a specific gpio_chip + * @data: data to pass to match function + * @callback: Callback function to check gpio_chip + * + * Similar to bus_find_device. It returns a reference to a gpio_chip as + * determined by a user supplied @match callback. The callback should return + * 0 if the device doesn't match and non-zero if it does. If the callback is + * non-zero, this function will return to the caller and not iterate over any + * more gpio_chips. + */ +struct gpio_chip *gpiochip_find(void *data, + int (*match)(struct gpio_chip *chip, void *data)) +{ + struct gpio_chip *chip = NULL; + unsigned long flags; + int i; + + spin_lock_irqsave(&gpio_lock, flags); + for (i = 0; i < ARCH_NR_GPIOS; i++) { + if (!gpio_desc[i].chip) + continue; + + if (match(gpio_desc[i].chip, data)) { + chip = gpio_desc[i].chip; + break; + } + } + spin_unlock_irqrestore(&gpio_lock, flags); + + return chip; +} /* These "optional" allocation calls help prevent drivers from stomping * on each other, and help provide better diagnostics in debugfs. diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c index fde53a3a45a3..c8618d3282cf 100644 --- a/drivers/of/gpio.c +++ b/drivers/of/gpio.c @@ -46,7 +46,7 @@ int of_get_gpio_flags(struct device_node *np, int index, goto err0; } - gc = gpio_np->data; + gc = of_node_to_gpiochip(gpio_np); if (!gc) { pr_debug("%s: gpio controller %s isn't registered\n", np->full_name, gpio_np->full_name); @@ -193,7 +193,6 @@ int of_mm_gpiochip_add(struct device_node *np, if (mm_gc->save_regs) mm_gc->save_regs(mm_gc); - np->data = &mm_gc->gc; mm_gc->gc.of_node = np; ret = gpiochip_add(gc); @@ -207,7 +206,6 @@ int of_mm_gpiochip_add(struct device_node *np, np->full_name, gc->base); return 0; err2: - np->data = NULL; iounmap(mm_gc->regs); err1: kfree(gc->label); @@ -217,3 +215,14 @@ err0: return ret; } EXPORT_SYMBOL(of_mm_gpiochip_add); + +/* Private function for resolving node pointer to gpio_chip */ +static int of_gpiochip_is_match(struct gpio_chip *chip, void *data) +{ + return chip->of_node == data; +} + +struct gpio_chip *of_node_to_gpiochip(struct device_node *np) +{ + return gpiochip_find(np, of_gpiochip_is_match); +} diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index af2544ef0b59..c7376bf80b06 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -127,6 +127,9 @@ extern int __must_check gpiochip_reserve(int start, int ngpio); /* add/remove chips */ extern int gpiochip_add(struct gpio_chip *chip); extern int __must_check gpiochip_remove(struct gpio_chip *chip); +extern struct gpio_chip *gpiochip_find(void *data, + int (*match)(struct gpio_chip *chip, + void *data)); /* Always use the library code for GPIO management calls, diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index 460d6810c5eb..1020587efed1 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -54,6 +54,9 @@ extern int of_mm_gpiochip_add(struct device_node *np, struct of_mm_gpio_chip *mm_gc); extern int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, const void *gpio_spec, u32 *flags); + +extern struct gpio_chip *of_node_to_gpiochip(struct device_node *np); + #else /* CONFIG_OF_GPIO */ /* Drivers may not strictly depend on the GPIO support, so let them link. */ -- cgit v1.2.3 From 391c970c0dd1100e3b9e1681f7d0f20aac35455a Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Tue, 8 Jun 2010 07:48:17 -0600 Subject: of/gpio: add default of_xlate function if device has a node pointer Implement generic OF gpio hooks and thus make device-enabled GPIO chips (i.e. the ones that have gpio_chip->dev specified) automatically attach to the OpenFirmware subsystem. Which means that now we can handle I2C and SPI GPIO chips almost* transparently. * "Almost" because some chips still require platform data, and for these chips OF-glue is still needed, though with this change the glue will be much smaller. Signed-off-by: Anton Vorontsov Signed-off-by: Grant Likely Cc: David Brownell Cc: Bill Gatliff Cc: Dmitry Eremin-Solenikov Cc: Benjamin Herrenschmidt Cc: Jean Delvare Cc: Andrew Morton CC: linux-kernel@vger.kernel.org CC: devicetree-discuss@lists.ozlabs.org --- arch/powerpc/platforms/52xx/mpc52xx_gpio.c | 2 -- arch/powerpc/platforms/52xx/mpc52xx_gpt.c | 3 --- arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c | 2 -- arch/powerpc/sysdev/cpm1.c | 2 -- arch/powerpc/sysdev/cpm_common.c | 1 - arch/powerpc/sysdev/mpc8xxx_gpio.c | 1 - arch/powerpc/sysdev/ppc4xx_gpio.c | 1 - arch/powerpc/sysdev/qe_lib/gpio.c | 1 - arch/powerpc/sysdev/simple_gpio.c | 1 - drivers/gpio/gpiolib.c | 5 ++++ drivers/gpio/xilinx_gpio.c | 1 - drivers/of/gpio.c | 33 +++++++++++++++++++------- include/linux/of_gpio.h | 7 ++++-- 13 files changed, 34 insertions(+), 26 deletions(-) (limited to 'arch/powerpc/sysdev') diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c index fd0912eeffe2..0855e804fc0d 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c @@ -161,7 +161,6 @@ static int __devinit mpc52xx_wkup_gpiochip_probe(struct of_device *ofdev, gc = &chip->mmchip.gc; - gc->of_gpio_n_cells = 2; gc->ngpio = 8; gc->direction_input = mpc52xx_wkup_gpio_dir_in; gc->direction_output = mpc52xx_wkup_gpio_dir_out; @@ -325,7 +324,6 @@ static int __devinit mpc52xx_simple_gpiochip_probe(struct of_device *ofdev, gc = &chip->mmchip.gc; - gc->of_gpio_n_cells = 2; gc->ngpio = 32; gc->direction_input = mpc52xx_simple_gpio_dir_in; gc->direction_output = mpc52xx_simple_gpio_dir_out; diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c index 6e82bd27132c..5d7d607617cd 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c @@ -348,10 +348,7 @@ mpc52xx_gpt_gpio_setup(struct mpc52xx_gpt_priv *gpt, struct device_node *node) gpt->gc.get = mpc52xx_gpt_gpio_get; gpt->gc.set = mpc52xx_gpt_gpio_set; gpt->gc.base = -1; - gpt->gc.of_gpio_n_cells = 2; - gpt->gc.of_xlate = of_gpio_simple_xlate; gpt->gc.of_node = node; - of_node_get(node); /* Setup external pin in GPIO mode */ clrsetbits_be32(&gpt->regs->mode, MPC52xx_GPT_MODE_MS_MASK, diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c index f0dbace6185a..59b0ed1a56b1 100644 --- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c +++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c @@ -90,8 +90,6 @@ static int mcu_gpiochip_add(struct mcu *mcu) gc->base = -1; gc->set = mcu_gpio_set; gc->direction_output = mcu_gpio_dir_out; - gc->of_gpio_n_cells = 2; - gc->of_xlate = of_gpio_simple_xlate; gc->of_node = np; return gpiochip_add(gc); diff --git a/arch/powerpc/sysdev/cpm1.c b/arch/powerpc/sysdev/cpm1.c index d5cf7d4ccf81..00852124ff4a 100644 --- a/arch/powerpc/sysdev/cpm1.c +++ b/arch/powerpc/sysdev/cpm1.c @@ -633,7 +633,6 @@ int cpm1_gpiochip_add16(struct device_node *np) gc = &mm_gc->gc; mm_gc->save_regs = cpm1_gpio16_save_regs; - gc->of_gpio_n_cells = 2; gc->ngpio = 16; gc->direction_input = cpm1_gpio16_dir_in; gc->direction_output = cpm1_gpio16_dir_out; @@ -755,7 +754,6 @@ int cpm1_gpiochip_add32(struct device_node *np) gc = &mm_gc->gc; mm_gc->save_regs = cpm1_gpio32_save_regs; - gc->of_gpio_n_cells = 2; gc->ngpio = 32; gc->direction_input = cpm1_gpio32_dir_in; gc->direction_output = cpm1_gpio32_dir_out; diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c index 67e9b47dcf8e..2b69aa0315b3 100644 --- a/arch/powerpc/sysdev/cpm_common.c +++ b/arch/powerpc/sysdev/cpm_common.c @@ -337,7 +337,6 @@ int cpm2_gpiochip_add32(struct device_node *np) gc = &mm_gc->gc; mm_gc->save_regs = cpm2_gpio32_save_regs; - gc->of_gpio_n_cells = 2; gc->ngpio = 32; gc->direction_input = cpm2_gpio32_dir_in; gc->direction_output = cpm2_gpio32_dir_out; diff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c index ec8fcd42101e..2b69084d0f0c 100644 --- a/arch/powerpc/sysdev/mpc8xxx_gpio.c +++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c @@ -273,7 +273,6 @@ static void __init mpc8xxx_add_controller(struct device_node *np) gc = &mm_gc->gc; mm_gc->save_regs = mpc8xxx_gpio_save_regs; - gc->of_gpio_n_cells = 2; gc->ngpio = MPC8XXX_GPIO_PINS; gc->direction_input = mpc8xxx_gpio_dir_in; gc->direction_output = mpc8xxx_gpio_dir_out; diff --git a/arch/powerpc/sysdev/ppc4xx_gpio.c b/arch/powerpc/sysdev/ppc4xx_gpio.c index 42e7a5eea665..fc65ad1b3293 100644 --- a/arch/powerpc/sysdev/ppc4xx_gpio.c +++ b/arch/powerpc/sysdev/ppc4xx_gpio.c @@ -194,7 +194,6 @@ static int __init ppc4xx_add_gpiochips(void) mm_gc = &ppc4xx_gc->mm_gc; gc = &mm_gc->gc; - gc->of_gpio_n_cells = 2; gc->ngpio = 32; gc->direction_input = ppc4xx_gpio_dir_in; gc->direction_output = ppc4xx_gpio_dir_out; diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c index 32e9440010a1..36bf845df127 100644 --- a/arch/powerpc/sysdev/qe_lib/gpio.c +++ b/arch/powerpc/sysdev/qe_lib/gpio.c @@ -321,7 +321,6 @@ static int __init qe_add_gpiochips(void) gc = &mm_gc->gc; mm_gc->save_regs = qe_gpio_save_regs; - gc->of_gpio_n_cells = 2; gc->ngpio = QE_PIO_PINS; gc->direction_input = qe_gpio_dir_in; gc->direction_output = qe_gpio_dir_out; diff --git a/arch/powerpc/sysdev/simple_gpio.c b/arch/powerpc/sysdev/simple_gpio.c index b7559aa0c165..b6defda5ccc9 100644 --- a/arch/powerpc/sysdev/simple_gpio.c +++ b/arch/powerpc/sysdev/simple_gpio.c @@ -103,7 +103,6 @@ static int __init u8_simple_gpiochip_add(struct device_node *np) gc = &mm_gc->gc; mm_gc->save_regs = u8_gpio_save_regs; - gc->of_gpio_n_cells = 2; gc->ngpio = 8; gc->direction_input = u8_gpio_dir_in; gc->direction_output = u8_gpio_dir_out; diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 73fd328f6fe4..83cbc34e3a76 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -1099,6 +1100,8 @@ int gpiochip_add(struct gpio_chip *chip) } } + of_gpiochip_add(chip); + unlock: spin_unlock_irqrestore(&gpio_lock, flags); @@ -1133,6 +1136,8 @@ int gpiochip_remove(struct gpio_chip *chip) spin_lock_irqsave(&gpio_lock, flags); + of_gpiochip_remove(chip); + for (id = chip->base; id < chip->base + chip->ngpio; id++) { if (test_bit(FLAG_REQUESTED, &gpio_desc[id].flags)) { status = -EBUSY; diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c index 2993c40b48e1..709690995d0d 100644 --- a/drivers/gpio/xilinx_gpio.c +++ b/drivers/gpio/xilinx_gpio.c @@ -190,7 +190,6 @@ static int __devinit xgpio_of_probe(struct device_node *np) spin_lock_init(&chip->gpio_lock); - chip->mmchip.gc.of_gpio_n_cells = 2; chip->mmchip.gc.direction_input = xgpio_dir_in; chip->mmchip.gc.direction_output = xgpio_dir_out; chip->mmchip.gc.get = xgpio_get; diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c index c8618d3282cf..09f05a178668 100644 --- a/drivers/of/gpio.c +++ b/drivers/of/gpio.c @@ -125,8 +125,8 @@ EXPORT_SYMBOL(of_gpio_count); * gpio chips. This function performs only one sanity check: whether gpio * is less than ngpios (that is specified in the gpio_chip). */ -int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, - const void *gpio_spec, u32 *flags) +static int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, + const void *gpio_spec, u32 *flags) { const __be32 *gpio = gpio_spec; const u32 n = be32_to_cpup(gpio); @@ -150,7 +150,6 @@ int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, return n; } -EXPORT_SYMBOL(of_gpio_simple_xlate); /** * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank) @@ -187,9 +186,6 @@ int of_mm_gpiochip_add(struct device_node *np, gc->base = -1; - if (!gc->of_xlate) - gc->of_xlate = of_gpio_simple_xlate; - if (mm_gc->save_regs) mm_gc->save_regs(mm_gc); @@ -199,9 +195,6 @@ int of_mm_gpiochip_add(struct device_node *np, if (ret) goto err2; - /* We don't want to lose the node and its ->data */ - of_node_get(np); - pr_debug("%s: registered as generic GPIO chip, base is %d\n", np->full_name, gc->base); return 0; @@ -216,6 +209,28 @@ err0: } EXPORT_SYMBOL(of_mm_gpiochip_add); +void of_gpiochip_add(struct gpio_chip *chip) +{ + if ((!chip->of_node) && (chip->dev)) + chip->of_node = chip->dev->of_node; + + if (!chip->of_node) + return; + + if (!chip->of_xlate) { + chip->of_gpio_n_cells = 2; + chip->of_xlate = of_gpio_simple_xlate; + } + + of_node_get(chip->of_node); +} + +void of_gpiochip_remove(struct gpio_chip *chip) +{ + if (chip->of_node) + of_node_put(chip->of_node); +} + /* Private function for resolving node pointer to gpio_chip */ static int of_gpiochip_is_match(struct gpio_chip *chip, void *data) { diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index 1020587efed1..6598c04dab01 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -52,9 +52,9 @@ extern unsigned int of_gpio_count(struct device_node *np); extern int of_mm_gpiochip_add(struct device_node *np, struct of_mm_gpio_chip *mm_gc); -extern int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, - const void *gpio_spec, u32 *flags); +extern void of_gpiochip_add(struct gpio_chip *gc); +extern void of_gpiochip_remove(struct gpio_chip *gc); extern struct gpio_chip *of_node_to_gpiochip(struct device_node *np); #else /* CONFIG_OF_GPIO */ @@ -71,6 +71,9 @@ static inline unsigned int of_gpio_count(struct device_node *np) return 0; } +static inline void of_gpiochip_add(struct gpio_chip *gc) { } +static inline void of_gpiochip_remove(struct gpio_chip *gc) { } + #endif /* CONFIG_OF_GPIO */ /** -- cgit v1.2.3 From eca3930163ba8884060ce9d9ff5ef0d9b7c7b00f Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Tue, 8 Jun 2010 07:48:21 -0600 Subject: of: Merge of_platform_bus_type with platform_bus_type of_platform_bus was being used in the same manner as the platform_bus. The only difference being that of_platform_bus devices are generated from data in the device tree, and platform_bus devices are usually statically allocated in platform code. Having them separate causes the problem of device drivers having to be registered twice if it was possible for the same device to appear on either bus. This patch removes of_platform_bus_type and registers all of_platform bus devices and drivers on the platform bus instead. A previous patch made the of_device structure an alias for the platform_device structure, and a shim is used to adapt of_platform_drivers to the platform bus. After all of of_platform_bus drivers are converted to be normal platform drivers, the shim code can be removed. Signed-off-by: Grant Likely Acked-by: David S. Miller --- arch/microblaze/kernel/of_platform.c | 11 ------ arch/microblaze/kernel/setup.c | 6 --- arch/powerpc/kernel/dma-swiotlb.c | 8 ---- arch/powerpc/kernel/of_platform.c | 12 ------ arch/powerpc/kernel/setup-common.c | 7 ---- arch/powerpc/platforms/cell/beat_iommu.c | 2 +- arch/powerpc/platforms/cell/iommu.c | 2 +- arch/powerpc/sysdev/mv64x60_dev.c | 7 +--- arch/sparc/kernel/of_device_32.c | 21 +++------- arch/sparc/kernel/of_device_64.c | 21 +++------- arch/sparc/kernel/of_device_common.c | 3 -- drivers/base/platform.c | 6 +++ drivers/of/device.c | 5 +++ drivers/of/platform.c | 67 ++++++++++++++++++++++++++++++-- include/linux/of_device.h | 6 +++ include/linux/of_platform.h | 21 ++++------ 16 files changed, 102 insertions(+), 103 deletions(-) (limited to 'arch/powerpc/sysdev') diff --git a/arch/microblaze/kernel/of_platform.c b/arch/microblaze/kernel/of_platform.c index da79edf45420..fb2866104331 100644 --- a/arch/microblaze/kernel/of_platform.c +++ b/arch/microblaze/kernel/of_platform.c @@ -26,17 +26,6 @@ #include #include -struct bus_type of_platform_bus_type = { - .uevent = of_device_uevent, -}; -EXPORT_SYMBOL(of_platform_bus_type); - -static int __init of_bus_driver_init(void) -{ - return of_bus_type_init(&of_platform_bus_type, "of_platform"); -} -postcore_initcall(of_bus_driver_init); - /* * The list of OF IDs below is used for matching bus types in the * system whose devices are to be exposed as of_platform_devices. diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c index 17c98dbcec88..f5f768842354 100644 --- a/arch/microblaze/kernel/setup.c +++ b/arch/microblaze/kernel/setup.c @@ -213,15 +213,9 @@ static struct notifier_block dflt_plat_bus_notifier = { .priority = INT_MAX, }; -static struct notifier_block dflt_of_bus_notifier = { - .notifier_call = dflt_bus_notify, - .priority = INT_MAX, -}; - static int __init setup_bus_notifier(void) { bus_register_notifier(&platform_bus_type, &dflt_plat_bus_notifier); - bus_register_notifier(&of_platform_bus_type, &dflt_of_bus_notifier); return 0; } diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index 02f724f36753..4295e0b94b2d 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -82,17 +82,9 @@ static struct notifier_block ppc_swiotlb_plat_bus_notifier = { .priority = 0, }; -static struct notifier_block ppc_swiotlb_of_bus_notifier = { - .notifier_call = ppc_swiotlb_bus_notify, - .priority = 0, -}; - int __init swiotlb_setup_bus_notifier(void) { bus_register_notifier(&platform_bus_type, &ppc_swiotlb_plat_bus_notifier); - bus_register_notifier(&of_platform_bus_type, - &ppc_swiotlb_of_bus_notifier); - return 0; } diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c index 4e0a2f7c1dd3..d3497cd81e8a 100644 --- a/arch/powerpc/kernel/of_platform.c +++ b/arch/powerpc/kernel/of_platform.c @@ -52,18 +52,6 @@ const struct of_device_id of_default_bus_ids[] = { {}, }; -struct bus_type of_platform_bus_type = { - .uevent = of_device_uevent, -}; -EXPORT_SYMBOL(of_platform_bus_type); - -static int __init of_bus_driver_init(void) -{ - return of_bus_type_init(&of_platform_bus_type, "of_platform"); -} - -postcore_initcall(of_bus_driver_init); - static int of_dev_node_match(struct device *dev, void *data) { return to_of_device(dev)->dev.of_node == data; diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index b7e6c7e193ae..d1a5304b3ddd 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -701,16 +701,9 @@ static struct notifier_block ppc_dflt_plat_bus_notifier = { .priority = INT_MAX, }; -static struct notifier_block ppc_dflt_of_bus_notifier = { - .notifier_call = ppc_dflt_bus_notify, - .priority = INT_MAX, -}; - static int __init setup_bus_notifier(void) { bus_register_notifier(&platform_bus_type, &ppc_dflt_plat_bus_notifier); - bus_register_notifier(&of_platform_bus_type, &ppc_dflt_of_bus_notifier); - return 0; } diff --git a/arch/powerpc/platforms/cell/beat_iommu.c b/arch/powerpc/platforms/cell/beat_iommu.c index 39d361c5c6d2..beec405eb6f8 100644 --- a/arch/powerpc/platforms/cell/beat_iommu.c +++ b/arch/powerpc/platforms/cell/beat_iommu.c @@ -108,7 +108,7 @@ static int __init celleb_init_iommu(void) celleb_init_direct_mapping(); set_pci_dma_ops(&dma_direct_ops); ppc_md.pci_dma_dev_setup = celleb_pci_dma_dev_setup; - bus_register_notifier(&of_platform_bus_type, &celleb_of_bus_notifier); + bus_register_notifier(&platform_bus_type, &celleb_of_bus_notifier); return 0; } diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c index 3712900471ba..58b13ce3847e 100644 --- a/arch/powerpc/platforms/cell/iommu.c +++ b/arch/powerpc/platforms/cell/iommu.c @@ -1204,7 +1204,7 @@ static int __init cell_iommu_init(void) /* Register callbacks on OF platform device addition/removal * to handle linking them to the right DMA operations */ - bus_register_notifier(&of_platform_bus_type, &cell_of_bus_notifier); + bus_register_notifier(&platform_bus_type, &cell_of_bus_notifier); return 0; } diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c index 31acd3b1718b..1398bc454999 100644 --- a/arch/powerpc/sysdev/mv64x60_dev.c +++ b/arch/powerpc/sysdev/mv64x60_dev.c @@ -20,12 +20,7 @@ #include -/* - * These functions provide the necessary setup for the mv64x60 drivers. - * These drivers are unusual in that they work on both the MIPS and PowerPC - * architectures. Because of that, the drivers do not support the normal - * PowerPC of_platform_bus_type. They support platform_bus_type instead. - */ +/* These functions provide the necessary setup for the mv64x60 drivers. */ static struct of_device_id __initdata of_mv64x60_devices[] = { { .compatible = "marvell,mv64306-devctrl", }, diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c index 331de91ad2bc..75fc9d5cd7e6 100644 --- a/arch/sparc/kernel/of_device_32.c +++ b/arch/sparc/kernel/of_device_32.c @@ -424,7 +424,7 @@ build_resources: build_device_resources(op, parent); op->dev.parent = parent; - op->dev.bus = &of_platform_bus_type; + op->dev.bus = &platform_bus_type; if (!parent) dev_set_name(&op->dev, "root"); else @@ -452,30 +452,19 @@ static void __init scan_tree(struct device_node *dp, struct device *parent) } } -static void __init scan_of_devices(void) +static int __init scan_of_devices(void) { struct device_node *root = of_find_node_by_path("/"); struct of_device *parent; parent = scan_one_device(root, NULL); if (!parent) - return; + return 0; scan_tree(root->child, &parent->dev); + return 0; } - -static int __init of_bus_driver_init(void) -{ - int err; - - err = of_bus_type_init(&of_platform_bus_type, "of"); - if (!err) - scan_of_devices(); - - return err; -} - -postcore_initcall(of_bus_driver_init); +postcore_initcall(scan_of_devices); static int __init of_debug(char *str) { diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c index 5e8cbb942d3d..9743d1d9fa03 100644 --- a/arch/sparc/kernel/of_device_64.c +++ b/arch/sparc/kernel/of_device_64.c @@ -667,7 +667,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, op->archdata.irqs[i] = build_one_device_irq(op, parent, op->archdata.irqs[i]); op->dev.parent = parent; - op->dev.bus = &of_platform_bus_type; + op->dev.bus = &platform_bus_type; if (!parent) dev_set_name(&op->dev, "root"); else @@ -695,30 +695,19 @@ static void __init scan_tree(struct device_node *dp, struct device *parent) } } -static void __init scan_of_devices(void) +static int __init scan_of_devices(void) { struct device_node *root = of_find_node_by_path("/"); struct of_device *parent; parent = scan_one_device(root, NULL); if (!parent) - return; + return 0; scan_tree(root->child, &parent->dev); + return 0; } - -static int __init of_bus_driver_init(void) -{ - int err; - - err = of_bus_type_init(&of_platform_bus_type, "of"); - if (!err) - scan_of_devices(); - - return err; -} - -postcore_initcall(of_bus_driver_init); +postcore_initcall(scan_of_devices); static int __init of_debug(char *str) { diff --git a/arch/sparc/kernel/of_device_common.c b/arch/sparc/kernel/of_device_common.c index 016c947d4cae..01f380c7995c 100644 --- a/arch/sparc/kernel/of_device_common.c +++ b/arch/sparc/kernel/of_device_common.c @@ -64,9 +64,6 @@ void of_propagate_archdata(struct of_device *bus) } } -struct bus_type of_platform_bus_type; -EXPORT_SYMBOL(of_platform_bus_type); - static void get_cells(struct device_node *dp, int *addrc, int *sizec) { if (addrc) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index fac3633c7223..f699fabf403b 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -636,6 +636,12 @@ static struct device_attribute platform_dev_attrs[] = { static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) { struct platform_device *pdev = to_platform_device(dev); + int rc; + + /* Some devices have extra OF data and an OF-style MODALIAS */ + rc = of_device_uevent(dev,env); + if (rc != -ENODEV) + return rc; add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX, (pdev->id_entry) ? pdev->id_entry->name : pdev->name); diff --git a/drivers/of/device.c b/drivers/of/device.c index 5282a202f5a9..12a44b493511 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -104,6 +104,11 @@ int of_device_register(struct of_device *ofdev) device_initialize(&ofdev->dev); + /* name and id have to be set so that the platform bus doesn't get + * confused on matching */ + ofdev->name = dev_name(&ofdev->dev); + ofdev->id = -1; + /* device_add will assume that this device is on the same node as * the parent. If there is no parent defined, set the node * explicitly */ diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 9d3d932bcb6f..712dfd866df0 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -20,6 +20,54 @@ #include #include #include +#include + +static int platform_driver_probe_shim(struct platform_device *pdev) +{ + struct platform_driver *pdrv; + struct of_platform_driver *ofpdrv; + const struct of_device_id *match; + + pdrv = container_of(pdev->dev.driver, struct platform_driver, driver); + ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver); + match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev); + return ofpdrv->probe(pdev, match); +} + +static void platform_driver_shutdown_shim(struct platform_device *pdev) +{ + struct platform_driver *pdrv; + struct of_platform_driver *ofpdrv; + + pdrv = container_of(pdev->dev.driver, struct platform_driver, driver); + ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver); + ofpdrv->shutdown(pdev); +} + +/** + * of_register_platform_driver + */ +int of_register_platform_driver(struct of_platform_driver *drv) +{ + /* setup of_platform_driver to platform_driver adaptors */ + drv->platform_driver.driver = drv->driver; + if (drv->probe) + drv->platform_driver.probe = platform_driver_probe_shim; + drv->platform_driver.remove = drv->remove; + if (drv->shutdown) + drv->platform_driver.shutdown = platform_driver_shutdown_shim; + drv->platform_driver.suspend = drv->suspend; + drv->platform_driver.resume = drv->resume; + + return platform_driver_register(&drv->platform_driver); +} +EXPORT_SYMBOL(of_register_platform_driver); + +void of_unregister_platform_driver(struct of_platform_driver *drv) +{ + platform_driver_unregister(&drv->platform_driver); +} +EXPORT_SYMBOL(of_unregister_platform_driver); #if defined(CONFIG_PPC_DCR) #include @@ -392,16 +440,29 @@ int of_bus_type_init(struct bus_type *bus, const char *name) int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus) { - drv->driver.bus = bus; + /* + * Temporary: of_platform_bus used to be distinct from the platform + * bus. It isn't anymore, and so drivers on the platform bus need + * to be registered in a special way. + * + * After all of_platform_bus_type drivers are converted to + * platform_drivers, this exception can be removed. + */ + if (bus == &platform_bus_type) + return of_register_platform_driver(drv); /* register with core */ + drv->driver.bus = bus; return driver_register(&drv->driver); } EXPORT_SYMBOL(of_register_driver); void of_unregister_driver(struct of_platform_driver *drv) { - driver_unregister(&drv->driver); + if (drv->driver.bus == &platform_bus_type) + of_unregister_platform_driver(drv); + else + driver_unregister(&drv->driver); } EXPORT_SYMBOL(of_unregister_driver); @@ -548,7 +609,7 @@ struct of_device *of_platform_device_create(struct device_node *np, dev->archdata.dma_mask = 0xffffffffUL; #endif dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); - dev->dev.bus = &of_platform_bus_type; + dev->dev.bus = &platform_bus_type; /* We do not fill the DMA ops for platform devices by default. * This is currently the responsibility of the platform code diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 7d27f5a878f6..8cd1fe7864e3 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -65,6 +65,12 @@ static inline int of_driver_match_device(struct device *dev, return 0; } +static inline int of_device_uevent(struct device *dev, + struct kobj_uevent_env *env) +{ + return -ENODEV; +} + #endif /* CONFIG_OF_DEVICE */ #endif /* _LINUX_OF_DEVICE_H */ diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index a51fd30176aa..133ecf31a60f 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -17,19 +17,19 @@ #include #include #include +#include /* - * The of_platform_bus_type is a bus type used by drivers that do not - * attach to a macio or similar bus but still use OF probing - * mechanism + * of_platform_bus_type isn't it's own bus anymore. It's now just an alias + * for the platform bus. */ -extern struct bus_type of_platform_bus_type; +#define of_platform_bus_type platform_bus_type extern const struct of_device_id of_default_bus_ids[]; /* * An of_platform_driver driver is attached to a basic of_device on - * the "platform bus" (of_platform_bus_type). + * the "platform bus" (platform_bus_type). */ struct of_platform_driver { @@ -42,6 +42,7 @@ struct of_platform_driver int (*shutdown)(struct of_device* dev); struct device_driver driver; + struct platform_driver platform_driver; }; #define to_of_platform_driver(drv) \ container_of(drv,struct of_platform_driver, driver) @@ -51,14 +52,8 @@ extern int of_register_driver(struct of_platform_driver *drv, extern void of_unregister_driver(struct of_platform_driver *drv); /* Platform drivers register/unregister */ -static inline int of_register_platform_driver(struct of_platform_driver *drv) -{ - return of_register_driver(drv, &of_platform_bus_type); -} -static inline void of_unregister_platform_driver(struct of_platform_driver *drv) -{ - of_unregister_driver(drv); -} +extern int of_register_platform_driver(struct of_platform_driver *drv); +extern void of_unregister_platform_driver(struct of_platform_driver *drv); extern struct of_device *of_device_alloc(struct device_node *np, const char *bus_id, -- cgit v1.2.3 From a454dc50590c6d758abba016a303a221f2f1b4b8 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Thu, 22 Jul 2010 15:52:34 -0600 Subject: powerpc: remove references to of_device and to_of_device of_device is just a #define alias to platform_device. This patch replaces all references to it with platform_device. Signed-off-by: Grant Likely --- arch/powerpc/kernel/ibmebus.c | 8 ++++---- arch/powerpc/kernel/of_platform.c | 8 ++++---- arch/powerpc/platforms/512x/clock.c | 2 +- arch/powerpc/platforms/52xx/mpc52xx_gpio.c | 6 +++--- arch/powerpc/platforms/52xx/mpc52xx_gpt.c | 4 ++-- arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c | 6 +++--- arch/powerpc/platforms/82xx/ep8248e.c | 4 ++-- arch/powerpc/platforms/83xx/suspend.c | 6 +++--- arch/powerpc/platforms/cell/axon_msi.c | 4 ++-- arch/powerpc/platforms/pasemi/gpio_mdio.c | 4 ++-- arch/powerpc/sysdev/axonram.c | 12 ++++++------ arch/powerpc/sysdev/bestcomm/bestcomm.c | 7 +++---- arch/powerpc/sysdev/fsl_msi.c | 4 ++-- arch/powerpc/sysdev/fsl_pmc.c | 3 ++- arch/powerpc/sysdev/fsl_rio.c | 4 ++-- arch/powerpc/sysdev/pmi.c | 6 +++--- arch/powerpc/sysdev/qe_lib/qe.c | 5 +++-- 17 files changed, 47 insertions(+), 46 deletions(-) (limited to 'arch/powerpc/sysdev') diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c index 21266abfbda6..9b626cfffce1 100644 --- a/arch/powerpc/kernel/ibmebus.c +++ b/arch/powerpc/kernel/ibmebus.c @@ -140,19 +140,19 @@ 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)->dev.of_node; + struct device_node *dn = to_platform_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)->dev.of_node == data; + return to_platform_device(dev)->dev.of_node == data; } static int ibmebus_create_device(struct device_node *dn) { - struct of_device *dev; + struct platform_device *dev; int ret; dev = of_device_alloc(dn, NULL, &ibmebus_bus_device); @@ -298,7 +298,7 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus, if ((dev = bus_find_device(&ibmebus_bus_type, NULL, path, ibmebus_match_path))) { - of_device_unregister(to_of_device(dev)); + of_device_unregister(to_platform_device(dev)); kfree(path); return count; diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c index b093d4b1f09c..84439d1b7cb3 100644 --- a/arch/powerpc/kernel/of_platform.c +++ b/arch/powerpc/kernel/of_platform.c @@ -54,16 +54,16 @@ const struct of_device_id of_default_bus_ids[] = { static int of_dev_node_match(struct device *dev, void *data) { - return to_of_device(dev)->dev.of_node == data; + return to_platform_device(dev)->dev.of_node == data; } -struct of_device *of_find_device_by_node(struct device_node *np) +struct platform_device *of_find_device_by_node(struct device_node *np) { struct device *dev; dev = bus_find_device(&platform_bus_type, NULL, np, of_dev_node_match); if (dev) - return to_of_device(dev); + return to_platform_device(dev); return NULL; } EXPORT_SYMBOL(of_find_device_by_node); @@ -76,7 +76,7 @@ EXPORT_SYMBOL(of_find_device_by_node); * lacking some bits needed here. */ -static int __devinit of_pci_phb_probe(struct of_device *dev, +static int __devinit of_pci_phb_probe(struct platform_device *dev, const struct of_device_id *match) { struct pci_controller *phb; diff --git a/arch/powerpc/platforms/512x/clock.c b/arch/powerpc/platforms/512x/clock.c index 4c42246b86a7..65e2d6729c1b 100644 --- a/arch/powerpc/platforms/512x/clock.c +++ b/arch/powerpc/platforms/512x/clock.c @@ -660,7 +660,7 @@ static void psc_clks_init(void) { struct device_node *np; const u32 *cell_index; - struct of_device *ofdev; + struct platform_device *ofdev; for_each_compatible_node(np, NULL, "fsl,mpc5121-psc") { cell_index = of_get_property(np, "cell-index", NULL); diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c index 0855e804fc0d..0dad9a935eb5 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c @@ -147,7 +147,7 @@ mpc52xx_wkup_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) return 0; } -static int __devinit mpc52xx_wkup_gpiochip_probe(struct of_device *ofdev, +static int __devinit mpc52xx_wkup_gpiochip_probe(struct platform_device *ofdev, const struct of_device_id *match) { struct mpc52xx_gpiochip *chip; @@ -179,7 +179,7 @@ static int __devinit mpc52xx_wkup_gpiochip_probe(struct of_device *ofdev, return 0; } -static int mpc52xx_gpiochip_remove(struct of_device *ofdev) +static int mpc52xx_gpiochip_remove(struct platform_device *ofdev) { return -EBUSY; } @@ -310,7 +310,7 @@ mpc52xx_simple_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) return 0; } -static int __devinit mpc52xx_simple_gpiochip_probe(struct of_device *ofdev, +static int __devinit mpc52xx_simple_gpiochip_probe(struct platform_device *ofdev, const struct of_device_id *match) { struct mpc52xx_gpiochip *chip; diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c index 5d7d607617cd..fea833e18ad5 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c @@ -720,7 +720,7 @@ static inline int mpc52xx_gpt_wdt_setup(struct mpc52xx_gpt_priv *gpt, /* --------------------------------------------------------------------- * of_platform bus binding code */ -static int __devinit mpc52xx_gpt_probe(struct of_device *ofdev, +static int __devinit mpc52xx_gpt_probe(struct platform_device *ofdev, const struct of_device_id *match) { struct mpc52xx_gpt_priv *gpt; @@ -766,7 +766,7 @@ static int __devinit mpc52xx_gpt_probe(struct of_device *ofdev, return 0; } -static int mpc52xx_gpt_remove(struct of_device *ofdev) +static int mpc52xx_gpt_remove(struct platform_device *ofdev) { return -EBUSY; } diff --git a/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c b/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c index e86aec644501..f4ac213c89c0 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c @@ -436,8 +436,8 @@ void mpc52xx_lpbfifo_abort(struct mpc52xx_lpbfifo_request *req) } EXPORT_SYMBOL(mpc52xx_lpbfifo_abort); -static int __devinit -mpc52xx_lpbfifo_probe(struct of_device *op, const struct of_device_id *match) +static int __devinit mpc52xx_lpbfifo_probe(struct platform_device *op, + const struct of_device_id *match) { struct resource res; int rc = -ENOMEM; @@ -507,7 +507,7 @@ mpc52xx_lpbfifo_probe(struct of_device *op, const struct of_device_id *match) } -static int __devexit mpc52xx_lpbfifo_remove(struct of_device *op) +static int __devexit mpc52xx_lpbfifo_remove(struct platform_device *op) { if (lpbfifo.dev != &op->dev) return 0; diff --git a/arch/powerpc/platforms/82xx/ep8248e.c b/arch/powerpc/platforms/82xx/ep8248e.c index 9f2e52b36f91..1565e0446dc8 100644 --- a/arch/powerpc/platforms/82xx/ep8248e.c +++ b/arch/powerpc/platforms/82xx/ep8248e.c @@ -111,7 +111,7 @@ static struct mdiobb_ctrl ep8248e_mdio_ctrl = { .ops = &ep8248e_mdio_ops, }; -static int __devinit ep8248e_mdio_probe(struct of_device *ofdev, +static int __devinit ep8248e_mdio_probe(struct platform_device *ofdev, const struct of_device_id *match) { struct mii_bus *bus; @@ -154,7 +154,7 @@ err_free_bus: return ret; } -static int ep8248e_mdio_remove(struct of_device *ofdev) +static int ep8248e_mdio_remove(struct platform_device *ofdev) { BUG(); return 0; diff --git a/arch/powerpc/platforms/83xx/suspend.c b/arch/powerpc/platforms/83xx/suspend.c index ebe6c3537209..75ae77f1af6a 100644 --- a/arch/powerpc/platforms/83xx/suspend.c +++ b/arch/powerpc/platforms/83xx/suspend.c @@ -99,7 +99,7 @@ struct pmc_type { int has_deep_sleep; }; -static struct of_device *pmc_dev; +static struct platform_device *pmc_dev; static int has_deep_sleep, deep_sleeping; static int pmc_irq; static struct mpc83xx_pmc __iomem *pmc_regs; @@ -318,7 +318,7 @@ static struct platform_suspend_ops mpc83xx_suspend_ops = { .end = mpc83xx_suspend_end, }; -static int pmc_probe(struct of_device *ofdev, +static int pmc_probe(struct platform_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -396,7 +396,7 @@ out: return ret; } -static int pmc_remove(struct of_device *ofdev) +static int pmc_remove(struct platform_device *ofdev) { return -EPERM; }; diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c index 6257e5378615..97085530aa63 100644 --- a/arch/powerpc/platforms/cell/axon_msi.c +++ b/arch/powerpc/platforms/cell/axon_msi.c @@ -328,7 +328,7 @@ static struct irq_host_ops msic_host_ops = { .map = msic_host_map, }; -static int axon_msi_shutdown(struct of_device *device) +static int axon_msi_shutdown(struct platform_device *device) { struct axon_msic *msic = dev_get_drvdata(&device->dev); u32 tmp; @@ -342,7 +342,7 @@ static int axon_msi_shutdown(struct of_device *device) return 0; } -static int axon_msi_probe(struct of_device *device, +static int axon_msi_probe(struct platform_device *device, const struct of_device_id *device_id) { struct device_node *dn = device->dev.of_node; diff --git a/arch/powerpc/platforms/pasemi/gpio_mdio.c b/arch/powerpc/platforms/pasemi/gpio_mdio.c index 627ee089e75d..a5d907b5a4c2 100644 --- a/arch/powerpc/platforms/pasemi/gpio_mdio.c +++ b/arch/powerpc/platforms/pasemi/gpio_mdio.c @@ -216,7 +216,7 @@ static int gpio_mdio_reset(struct mii_bus *bus) } -static int __devinit gpio_mdio_probe(struct of_device *ofdev, +static int __devinit gpio_mdio_probe(struct platform_device *ofdev, const struct of_device_id *match) { struct device *dev = &ofdev->dev; @@ -275,7 +275,7 @@ out: } -static int gpio_mdio_remove(struct of_device *dev) +static int gpio_mdio_remove(struct platform_device *dev) { struct mii_bus *bus = dev_get_drvdata(&dev->dev); diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c index 402d2212162f..2659a60bd7b8 100644 --- a/arch/powerpc/sysdev/axonram.c +++ b/arch/powerpc/sysdev/axonram.c @@ -60,7 +60,7 @@ static int azfs_major, azfs_minor; struct axon_ram_bank { - struct of_device *device; + struct platform_device *device; struct gendisk *disk; unsigned int irq_id; unsigned long ph_addr; @@ -72,7 +72,7 @@ struct axon_ram_bank { static ssize_t axon_ram_sysfs_ecc(struct device *dev, struct device_attribute *attr, char *buf) { - struct of_device *device = to_of_device(dev); + struct platform_device *device = to_platform_device(dev); struct axon_ram_bank *bank = device->dev.platform_data; BUG_ON(!bank); @@ -90,7 +90,7 @@ static DEVICE_ATTR(ecc, S_IRUGO, axon_ram_sysfs_ecc, NULL); static irqreturn_t axon_ram_irq_handler(int irq, void *dev) { - struct of_device *device = dev; + struct platform_device *device = dev; struct axon_ram_bank *bank = device->dev.platform_data; BUG_ON(!bank); @@ -174,8 +174,8 @@ static const struct block_device_operations axon_ram_devops = { * axon_ram_probe - probe() method for platform driver * @device, @device_id: see of_platform_driver method */ -static int -axon_ram_probe(struct of_device *device, const struct of_device_id *device_id) +static int axon_ram_probe(struct platform_device *device, + const struct of_device_id *device_id) { static int axon_ram_bank_id = -1; struct axon_ram_bank *bank; @@ -304,7 +304,7 @@ failed: * @device: see of_platform_driver method */ static int -axon_ram_remove(struct of_device *device) +axon_ram_remove(struct platform_device *device) { struct axon_ram_bank *bank = device->dev.platform_data; diff --git a/arch/powerpc/sysdev/bestcomm/bestcomm.c b/arch/powerpc/sysdev/bestcomm/bestcomm.c index a7c5c470af14..650256115064 100644 --- a/arch/powerpc/sysdev/bestcomm/bestcomm.c +++ b/arch/powerpc/sysdev/bestcomm/bestcomm.c @@ -365,8 +365,8 @@ bcom_engine_cleanup(void) /* OF platform driver */ /* ======================================================================== */ -static int __devinit -mpc52xx_bcom_probe(struct of_device *op, const struct of_device_id *match) +static int __devinit mpc52xx_bcom_probe(struct platform_device *op, + const struct of_device_id *match) { struct device_node *ofn_sram; struct resource res_bcom; @@ -461,8 +461,7 @@ error_ofput: } -static int -mpc52xx_bcom_remove(struct of_device *op) +static int mpc52xx_bcom_remove(struct platform_device *op) { /* Clean up the engine */ bcom_engine_cleanup(); diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c index 962c2d8dd8d9..87991d3abbab 100644 --- a/arch/powerpc/sysdev/fsl_msi.c +++ b/arch/powerpc/sysdev/fsl_msi.c @@ -250,7 +250,7 @@ unlock: raw_spin_unlock(&desc->lock); } -static int fsl_of_msi_remove(struct of_device *ofdev) +static int fsl_of_msi_remove(struct platform_device *ofdev) { struct fsl_msi *msi = ofdev->dev.platform_data; int virq, i; @@ -274,7 +274,7 @@ static int fsl_of_msi_remove(struct of_device *ofdev) return 0; } -static int __devinit fsl_of_msi_probe(struct of_device *dev, +static int __devinit fsl_of_msi_probe(struct platform_device *dev, const struct of_device_id *match) { struct fsl_msi *msi; diff --git a/arch/powerpc/sysdev/fsl_pmc.c b/arch/powerpc/sysdev/fsl_pmc.c index 9082eb921ad9..44de8559c975 100644 --- a/arch/powerpc/sysdev/fsl_pmc.c +++ b/arch/powerpc/sysdev/fsl_pmc.c @@ -58,7 +58,8 @@ static struct platform_suspend_ops pmc_suspend_ops = { .enter = pmc_suspend_enter, }; -static int pmc_probe(struct of_device *ofdev, const struct of_device_id *id) +static int pmc_probe(struct platform_device *ofdev, + const struct of_device_id *id) { pmc_regs = of_iomap(ofdev->dev.of_node, 0); if (!pmc_regs) diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c index 30e1626b2e85..8bd86530ee25 100644 --- a/arch/powerpc/sysdev/fsl_rio.c +++ b/arch/powerpc/sysdev/fsl_rio.c @@ -1338,7 +1338,7 @@ static inline void fsl_rio_info(struct device *dev, u32 ccsr) * master port with system-specific info, and registers the * master port with the RapidIO subsystem. */ -int fsl_rio_setup(struct of_device *dev) +int fsl_rio_setup(struct platform_device *dev) { struct rio_ops *ops; struct rio_mport *port; @@ -1536,7 +1536,7 @@ err_ops: /* The probe function for RapidIO peer-to-peer network. */ -static int __devinit fsl_of_rio_rpn_probe(struct of_device *dev, +static int __devinit fsl_of_rio_rpn_probe(struct platform_device *dev, const struct of_device_id *match) { int rc; diff --git a/arch/powerpc/sysdev/pmi.c b/arch/powerpc/sysdev/pmi.c index d07137a07d75..24a0bb955b18 100644 --- a/arch/powerpc/sysdev/pmi.c +++ b/arch/powerpc/sysdev/pmi.c @@ -43,7 +43,7 @@ struct pmi_data { struct mutex msg_mutex; pmi_message_t msg; struct completion *completion; - struct of_device *dev; + struct platform_device *dev; int irq; u8 __iomem *pmi_reg; struct work_struct work; @@ -121,7 +121,7 @@ static void pmi_notify_handlers(struct work_struct *work) spin_unlock(&data->handler_spinlock); } -static int pmi_of_probe(struct of_device *dev, +static int pmi_of_probe(struct platform_device *dev, const struct of_device_id *match) { struct device_node *np = dev->dev.of_node; @@ -185,7 +185,7 @@ out: return rc; } -static int pmi_of_remove(struct of_device *dev) +static int pmi_of_remove(struct platform_device *dev) { struct pmi_handler *handler, *tmp; diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c index 093e0ae1a941..3da8014931c9 100644 --- a/arch/powerpc/sysdev/qe_lib/qe.c +++ b/arch/powerpc/sysdev/qe_lib/qe.c @@ -651,14 +651,15 @@ unsigned int qe_get_num_of_snums(void) EXPORT_SYMBOL(qe_get_num_of_snums); #if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC_85xx) -static int qe_resume(struct of_device *ofdev) +static int qe_resume(struct platform_device *ofdev) { if (!qe_alive_during_sleep()) qe_reset(); return 0; } -static int qe_probe(struct of_device *ofdev, const struct of_device_id *id) +static int qe_probe(struct platform_device *ofdev, + const struct of_device_id *id) { return 0; } -- cgit v1.2.3 From 22ae782f86b726f9cea752c0f269ff6dcdf2f6e1 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Thu, 29 Jul 2010 11:49:01 -0600 Subject: of/address: Clean up function declarations This patch moves the declaration of of_get_address(), of_get_pci_address(), and of_pci_address_to_resource() out of arch code and into the common linux/of_address header file. This patch also fixes some of the asm/prom.h ordering issues. It still includes some header files that it ideally shouldn't be, but at least the ordering is consistent now so that of_* overrides work. Signed-off-by: Grant Likely --- arch/microblaze/include/asm/prom.h | 33 +++++++-------------- arch/powerpc/include/asm/prom.h | 49 +++++++------------------------ arch/powerpc/kernel/legacy_serial.c | 1 + arch/powerpc/kernel/pci-common.c | 1 + arch/powerpc/platforms/52xx/lite5200.c | 1 + arch/powerpc/platforms/amigaone/setup.c | 3 +- arch/powerpc/platforms/iseries/mf.c | 1 + arch/powerpc/platforms/powermac/feature.c | 2 ++ arch/powerpc/sysdev/bestcomm/sram.c | 1 + arch/powerpc/sysdev/fsl_gtm.c | 1 + drivers/char/bsr.c | 1 + drivers/net/fsl_pq_mdio.c | 1 + drivers/net/xilinx_emaclite.c | 2 +- drivers/serial/uartlite.c | 1 + drivers/spi/mpc512x_psc_spi.c | 1 + drivers/spi/mpc52xx_psc_spi.c | 1 + drivers/spi/xilinx_spi_of.c | 1 + drivers/usb/gadget/fsl_qe_udc.c | 1 + drivers/video/controlfb.c | 2 ++ drivers/video/offb.c | 3 +- include/linux/of_address.h | 32 ++++++++++++++++++++ 21 files changed, 76 insertions(+), 63 deletions(-) (limited to 'arch/powerpc/sysdev') diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h index cb9c3dd9a23b..101fa098f62a 100644 --- a/arch/microblaze/include/asm/prom.h +++ b/arch/microblaze/include/asm/prom.h @@ -20,11 +20,6 @@ #ifndef __ASSEMBLY__ #include -#include -#include -#include -#include -#include #include #include @@ -52,25 +47,9 @@ extern void pci_create_OF_bus_map(void); * OF address retreival & translation */ -/* Extract an address from a device, returns the region size and - * the address space flags too. The PCI version uses a BAR number - * instead of an absolute index - */ -extern const u32 *of_get_address(struct device_node *dev, int index, - u64 *size, unsigned int *flags); -extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, - u64 *size, unsigned int *flags); - -extern int of_pci_address_to_resource(struct device_node *dev, int bar, - struct resource *r); - #ifdef CONFIG_PCI extern unsigned long pci_address_to_pio(phys_addr_t address); -#else -static inline unsigned long pci_address_to_pio(phys_addr_t address) -{ - return (unsigned long)-1; -} +#define pci_address_to_pio pci_address_to_pio #endif /* CONFIG_PCI */ /* Parse the ibm,dma-window property of an OF node into the busno, phys and @@ -99,8 +78,18 @@ extern const void *of_get_mac_address(struct device_node *np); * resolving using the OF tree walking. */ struct pci_dev; +struct of_irq; extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); #endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ + +/* These includes are put at the bottom because they may contain things + * that are overridden by this file. Ideally they shouldn't be included + * by this file, but there are a bunch of .c files that currently depend + * on it. Eventually they will be cleaned up. */ +#include +#include +#include + #endif /* _ASM_MICROBLAZE_PROM_H */ diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h index 55bccc0a21c3..ae26f2efd089 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h @@ -17,11 +17,6 @@ * 2 of the License, or (at your option) any later version. */ #include -#include -#include -#include -#include -#include #include #include @@ -49,41 +44,9 @@ extern void pci_create_OF_bus_map(void); extern u64 of_translate_dma_address(struct device_node *dev, const u32 *in_addr); -/* Extract an address from a device, returns the region size and - * the address space flags too. The PCI version uses a BAR number - * instead of an absolute index - */ -extern const u32 *of_get_address(struct device_node *dev, int index, - u64 *size, unsigned int *flags); -#ifdef CONFIG_PCI -extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, - u64 *size, unsigned int *flags); -#else -static inline const u32 *of_get_pci_address(struct device_node *dev, - int bar_no, u64 *size, unsigned int *flags) -{ - return NULL; -} -#endif /* CONFIG_PCI */ - -#ifdef CONFIG_PCI -extern int of_pci_address_to_resource(struct device_node *dev, int bar, - struct resource *r); -#else -static inline int of_pci_address_to_resource(struct device_node *dev, int bar, - struct resource *r) -{ - return -ENOSYS; -} -#endif /* CONFIG_PCI */ - #ifdef CONFIG_PCI extern unsigned long pci_address_to_pio(phys_addr_t address); -#else -static inline unsigned long pci_address_to_pio(phys_addr_t address) -{ - return (unsigned long)-1; -} +#define pci_address_to_pio pci_address_to_pio #endif /* CONFIG_PCI */ /* Parse the ibm,dma-window property of an OF node into the busno, phys and @@ -122,9 +85,19 @@ static inline int of_node_to_nid(struct device_node *device) { return 0; } * resolving using the OF tree walking. */ struct pci_dev; +struct of_irq; extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); extern void of_instantiate_rtc(void); +/* These includes are put at the bottom because they may contain things + * that are overridden by this file. Ideally they shouldn't be included + * by this file, but there are a bunch of .c files that currently depend + * on it. Eventually they will be cleaned up. */ +#include +#include +#include +#include + #endif /* __KERNEL__ */ #endif /* _POWERPC_PROM_H */ diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c index 035ada5443ee..c1fd0f9658fd 100644 --- a/arch/powerpc/kernel/legacy_serial.c +++ b/arch/powerpc/kernel/legacy_serial.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 5b38f6ae2b29..9021c4ad4bbd 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/powerpc/platforms/52xx/lite5200.c b/arch/powerpc/platforms/52xx/lite5200.c index 6d584f4e3c9a..de55bc0584b5 100644 --- a/arch/powerpc/platforms/52xx/lite5200.c +++ b/arch/powerpc/platforms/52xx/lite5200.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/powerpc/platforms/amigaone/setup.c b/arch/powerpc/platforms/amigaone/setup.c index fb4eb0df054c..03aabc0e16ac 100644 --- a/arch/powerpc/platforms/amigaone/setup.c +++ b/arch/powerpc/platforms/amigaone/setup.c @@ -13,12 +13,13 @@ */ #include +#include +#include #include #include #include #include -#include #include #include #include diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c index d2c1d497846e..33e5fc7334fc 100644 --- a/arch/powerpc/platforms/iseries/mf.c +++ b/arch/powerpc/platforms/iseries/mf.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c index 9e1b9fd75206..75eec031e7a2 100644 --- a/arch/powerpc/platforms/powermac/feature.c +++ b/arch/powerpc/platforms/powermac/feature.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/arch/powerpc/sysdev/bestcomm/sram.c b/arch/powerpc/sysdev/bestcomm/sram.c index 5d74ef7a651f..1225012a681a 100644 --- a/arch/powerpc/sysdev/bestcomm/sram.c +++ b/arch/powerpc/sysdev/bestcomm/sram.c @@ -11,6 +11,7 @@ * kind, whether express or implied. */ +#include #include #include #include diff --git a/arch/powerpc/sysdev/fsl_gtm.c b/arch/powerpc/sysdev/fsl_gtm.c index eca4545dd52e..7dd2885321ad 100644 --- a/arch/powerpc/sysdev/fsl_gtm.c +++ b/arch/powerpc/sysdev/fsl_gtm.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c index 89d871ef8c2f..91917133ae0a 100644 --- a/drivers/char/bsr.c +++ b/drivers/char/bsr.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c index b4c41d72c423..f53f850b6418 100644 --- a/drivers/net/fsl_pq_mdio.c +++ b/drivers/net/fsl_pq_mdio.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index d04c5b262050..b2c2f391b29d 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -20,7 +20,7 @@ #include #include #include - +#include #include #include #include diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c index 8acccd564378..caf085d3a76a 100644 --- a/drivers/serial/uartlite.c +++ b/drivers/serial/uartlite.c @@ -21,6 +21,7 @@ #include #if defined(CONFIG_OF) && (defined(CONFIG_PPC32) || defined(CONFIG_MICROBLAZE)) #include +#include #include #include diff --git a/drivers/spi/mpc512x_psc_spi.c b/drivers/spi/mpc512x_psc_spi.c index 1bb4315f5f84..10baac3f8ea5 100644 --- a/drivers/spi/mpc512x_psc_spi.c +++ b/drivers/spi/mpc512x_psc_spi.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index bd81ff90cfb3..66d170147dcc 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/spi/xilinx_spi_of.c b/drivers/spi/xilinx_spi_of.c index 87cda0956a83..f53d3f6b9f61 100644 --- a/drivers/spi/xilinx_spi_of.c +++ b/drivers/spi/xilinx_spi_of.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index 82506ca297d5..9648b75f0283 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/video/controlfb.c b/drivers/video/controlfb.c index 49fcbe8f18ac..c225dcce89e7 100644 --- a/drivers/video/controlfb.c +++ b/drivers/video/controlfb.c @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/drivers/video/offb.c b/drivers/video/offb.c index 46dda7d8aaee..cb163a5397be 100644 --- a/drivers/video/offb.c +++ b/drivers/video/offb.c @@ -19,13 +19,14 @@ #include #include #include +#include +#include #include #include #include #include #include #include -#include #ifdef CONFIG_PPC64 #include diff --git a/include/linux/of_address.h b/include/linux/of_address.h index cc567df9a00d..8aea06f0564c 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -8,5 +8,37 @@ extern int of_address_to_resource(struct device_node *dev, int index, struct resource *r); extern void __iomem *of_iomap(struct device_node *device, int index); +/* Extract an address from a device, returns the region size and + * the address space flags too. The PCI version uses a BAR number + * instead of an absolute index + */ +extern const u32 *of_get_address(struct device_node *dev, int index, + u64 *size, unsigned int *flags); + +#ifndef pci_address_to_pio +static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; } +#define pci_address_to_pio pci_address_to_pio +#endif + +#ifdef CONFIG_PCI +extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, + u64 *size, unsigned int *flags); +extern int of_pci_address_to_resource(struct device_node *dev, int bar, + struct resource *r); +#else /* CONFIG_PCI */ +static inline int of_pci_address_to_resource(struct device_node *dev, int bar, + struct resource *r) +{ + return -ENOSYS; +} + +static inline const u32 *of_get_pci_address(struct device_node *dev, + int bar_no, u64 *size, unsigned int *flags) +{ + return NULL; +} +#endif /* CONFIG_PCI */ + + #endif /* __OF_ADDRESS_H */ -- cgit v1.2.3