ARM: OMAP: Make plat-omap/i2c.c port checks local
authorTony Lindgren <tony@atomide.com>
Mon, 29 Oct 2012 23:17:59 +0000 (16:17 -0700)
committerTony Lindgren <tony@atomide.com>
Wed, 31 Oct 2012 22:37:13 +0000 (15:37 -0700)
The common code should not have any omap1 or omap2+
specific code, and should not need to call the cpu_is_omap
macros.

The only remaining user for cpu_is_omap macros is
omap_i2c_nr_ports(). Let's make those checks in
the omap specific implementation of omap_i2c_add_bus()
instead in order to remove cpu_is_omap usage from
the common code.

Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap1/i2c.c
arch/arm/mach-omap2/i2c.c
arch/arm/plat-omap/i2c.c

index 32bcbb8d6c736868fe9bee84d6e9b35c7c1e2005..54097a29f4329f5d802daec59cadc46932e9ccd3 100644 (file)
@@ -54,6 +54,9 @@ int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *pdata,
        struct platform_device *pdev;
        struct resource *res;
 
+       if (bus_id > 1)
+               return -EINVAL;
+
        omap1_i2c_mux_pins(bus_id);
 
        pdev = &omap_i2c_devices[bus_id - 1];
index ad55b943108fcfc17de50d471ce9afd034105d55..4e63097e3cd8b708104f68123be1e633856ee2e9 100644 (file)
@@ -109,6 +109,19 @@ int omap_i2c_reset(struct omap_hwmod *oh)
        return 0;
 }
 
+static int __init omap_i2c_nr_ports(void)
+{
+       int ports = 0;
+
+       if (cpu_is_omap24xx())
+               ports = 2;
+       else if (cpu_is_omap34xx())
+               ports = 3;
+       else if (cpu_is_omap44xx())
+               ports = 4;
+       return ports;
+}
+
 static const char name[] = "omap_i2c";
 
 int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata,
@@ -121,6 +134,9 @@ int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata,
        struct omap_i2c_bus_platform_data *pdata;
        struct omap_i2c_dev_attr *dev_attr;
 
+       if (bus_id > omap_i2c_nr_ports())
+               return -EINVAL;
+
        omap2_i2c_mux_pins(bus_id);
 
        l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id);
index be6deb7c12ec8fe9df3bef6315814b6e1206ed68..d094273b9df58edabe1091efdf46b9165e3f0447 100644 (file)
@@ -33,9 +33,6 @@
 
 #include <mach/irqs.h>
 
-#include "../mach-omap1/soc.h"
-#include "../mach-omap2/soc.h"
-
 #include "i2c.h"
 
 #define OMAP_I2C_MAX_CONTROLLERS 4
@@ -43,22 +40,6 @@ static struct omap_i2c_bus_platform_data i2c_pdata[OMAP_I2C_MAX_CONTROLLERS];
 
 #define OMAP_I2C_CMDLINE_SETUP (BIT(31))
 
-static int __init omap_i2c_nr_ports(void)
-{
-       int ports = 0;
-
-       if (cpu_class_is_omap1())
-               ports = 1;
-       else if (cpu_is_omap24xx())
-               ports = 2;
-       else if (cpu_is_omap34xx())
-               ports = 3;
-       else if (cpu_is_omap44xx())
-               ports = 4;
-
-       return ports;
-}
-
 /**
  * omap_i2c_bus_setup - Process command line options for the I2C bus speed
  * @str: String of options
@@ -72,12 +53,11 @@ static int __init omap_i2c_nr_ports(void)
  */
 static int __init omap_i2c_bus_setup(char *str)
 {
-       int ports;
        int ints[3];
 
-       ports = omap_i2c_nr_ports();
        get_options(str, 3, ints);
-       if (ints[0] < 2 || ints[1] < 1 || ints[1] > ports)
+       if (ints[0] < 2 || ints[1] < 1 ||
+                       ints[1] > OMAP_I2C_MAX_CONTROLLERS)
                return 0;
        i2c_pdata[ints[1] - 1].clkrate = ints[2];
        i2c_pdata[ints[1] - 1].clkrate |= OMAP_I2C_CMDLINE_SETUP;
@@ -122,7 +102,7 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
 {
        int err;
 
-       BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports());
+       BUG_ON(bus_id < 1 || bus_id > OMAP_I2C_MAX_CONTROLLERS);
 
        if (info) {
                err = i2c_register_board_info(bus_id, info, len);