From: "eric miao" Subject: i2c-pxa: Remove hardcoded #ifdef and use cpu_is_pxa27x remove #ifdef CONFIG_PXA27x .. #endif and use cpu_is_pxaXXXX() macros so that a single binary can support PXA25x/PXA27x/PXA3xx at run-time. Signed-off-by: eric miao Signed-off-by: Jean Delvare --- drivers/i2c/busses/i2c-pxa.c | 58 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) --- linux-2.6.24-rc1.orig/drivers/i2c/busses/i2c-pxa.c 2007-10-24 09:59:28.000000000 +0200 +++ linux-2.6.24-rc1/drivers/i2c/busses/i2c-pxa.c 2007-11-06 11:39:30.000000000 +0100 @@ -840,6 +840,32 @@ static const struct i2c_algorithm i2c_px .functionality = i2c_pxa_functionality, }; +static void i2c_pxa_enable(struct platform_device *dev) +{ + if (cpu_is_pxa27x()) { + switch (dev->id) { + case 0: + pxa_gpio_mode(GPIO117_I2CSCL_MD); + pxa_gpio_mode(GPIO118_I2CSDA_MD); + break; + case 1: + local_irq_disable(); + PCFR |= PCFR_PI2CEN; + local_irq_enable(); + break; + } + } +} + +static void i2c_pxa_disable(struct platform_device *dev) +{ + if (cpu_is_pxa27x() && dev->id == 1) { + local_irq_disable(); + PCFR &= ~PCFR_PI2CEN; + local_irq_enable(); + } +} + #define res_len(r) ((r)->end - (r)->start + 1) static int i2c_pxa_probe(struct platform_device *dev) { @@ -899,25 +925,13 @@ static int i2c_pxa_probe(struct platform #endif clk_enable(i2c->clk); -#ifdef CONFIG_PXA27x - switch (dev->id) { - case 0: - pxa_gpio_mode(GPIO117_I2CSCL_MD); - pxa_gpio_mode(GPIO118_I2CSDA_MD); - break; - case 1: - local_irq_disable(); - PCFR |= PCFR_PI2CEN; - local_irq_enable(); - } -#endif + i2c_pxa_enable(dev); ret = request_irq(irq, i2c_pxa_handler, IRQF_DISABLED, i2c->adap.name, i2c); if (ret) goto ereqirq; - i2c_pxa_reset(i2c); i2c->adap.algo_data = i2c; @@ -955,14 +969,7 @@ eadapt: free_irq(irq, i2c); ereqirq: clk_disable(i2c->clk); - -#ifdef CONFIG_PXA27x - if (dev->id == 1) { - local_irq_disable(); - PCFR &= ~PCFR_PI2CEN; - local_irq_enable(); - } -#endif + i2c_pxa_disable(dev); eremap: clk_put(i2c->clk); eclk: @@ -983,14 +990,7 @@ static int i2c_pxa_remove(struct platfor clk_disable(i2c->clk); clk_put(i2c->clk); - -#ifdef CONFIG_PXA27x - if (dev->id == 1) { - local_irq_disable(); - PCFR &= ~PCFR_PI2CEN; - local_irq_enable(); - } -#endif + i2c_pxa_disable(dev); release_mem_region(i2c->iobase, i2c->iosize); kfree(i2c);