drivers: Push down BKL into various drivers
[safe/jmp/linux-2.6] / drivers / sh / pfc.c
index 448ba23..cf0303a 100644 (file)
@@ -7,7 +7,6 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  */
-
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
@@ -72,11 +71,9 @@ static void gpio_write_bit(struct pinmux_data_reg *dr,
 
        pos = dr->reg_width - (in_pos + 1);
 
-#ifdef DEBUG
-       pr_info("write_bit addr = %lx, value = %ld, pos = %ld, "
-               "r_width = %ld\n",
-               dr->reg, !!value, pos, dr->reg_width);
-#endif
+       pr_debug("write_bit addr = %lx, value = %d, pos = %ld, "
+                "r_width = %ld\n",
+                dr->reg, !!value, pos, dr->reg_width);
 
        if (value)
                set_bit(pos, &dr->reg_shadow);
@@ -95,11 +92,9 @@ static int gpio_read_reg(unsigned long reg, unsigned long reg_width,
        mask = (1 << field_width) - 1;
        pos = reg_width - ((in_pos + 1) * field_width);
 
-#ifdef DEBUG
-       pr_info("read_reg: addr = %lx, pos = %ld, "
-               "r_width = %ld, f_width = %ld\n",
-               reg, pos, reg_width, field_width);
-#endif
+       pr_debug("read_reg: addr = %lx, pos = %ld, "
+                "r_width = %ld, f_width = %ld\n",
+                reg, pos, reg_width, field_width);
 
        data = gpio_read_raw_reg(reg, reg_width);
        return (data >> pos) & mask;
@@ -114,11 +109,9 @@ static void gpio_write_reg(unsigned long reg, unsigned long reg_width,
        mask = (1 << field_width) - 1;
        pos = reg_width - ((in_pos + 1) * field_width);
 
-#ifdef DEBUG
-       pr_info("write_reg addr = %lx, value = %ld, pos = %ld, "
-               "r_width = %ld, f_width = %ld\n",
-               reg, value, pos, reg_width, field_width);
-#endif
+       pr_debug("write_reg addr = %lx, value = %ld, pos = %ld, "
+                "r_width = %ld, f_width = %ld\n",
+                reg, value, pos, reg_width, field_width);
 
        mask = ~(mask << pos);
        value = value << pos;
@@ -344,12 +337,39 @@ static int pinmux_config_gpio(struct pinmux_info *gpioc, unsigned gpio,
                if (!enum_id)
                        break;
 
+               /* first check if this is a function enum */
                in_range = enum_in_range(enum_id, &gpioc->function);
-               if (!in_range && range) {
-                       in_range = enum_in_range(enum_id, range);
-
-                       if (in_range && enum_id == range->force)
-                               continue;
+               if (!in_range) {
+                       /* not a function enum */
+                       if (range) {
+                               /*
+                                * other range exists, so this pin is
+                                * a regular GPIO pin that now is being
+                                * bound to a specific direction.
+                                *
+                                * for this case we only allow function enums
+                                * and the enums that match the other range.
+                                */
+                               in_range = enum_in_range(enum_id, range);
+
+                               /*
+                                * special case pass through for fixed
+                                * input-only or output-only pins without
+                                * function enum register association.
+                                */
+                               if (in_range && enum_id == range->force)
+                                       continue;
+                       } else {
+                               /*
+                                * no other range exists, so this pin
+                                * must then be of the function type.
+                                *
+                                * allow function type pins to select
+                                * any combination of function/in/out
+                                * in their MARK lists.
+                                */
+                               in_range = 1;
+                       }
                }
 
                if (!in_range)