]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge branch 'samsung' into for-next
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 22 Oct 2012 09:08:36 +0000 (11:08 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 22 Oct 2012 09:08:36 +0000 (11:08 +0200)
1  2 
drivers/pinctrl/pinctrl-samsung.c

index 861cd5f04d5e12ba2aa497cc39934a56b0680a7b,0db88bbbb2bb295bf7f167932dcdd1270328be1d..fc34cac8a1b054ca4cc9095cedce2afd2273e17b
@@@ -728,34 -768,41 +768,41 @@@ static int __devinit samsung_pinctrl_re
        return 0;
  }
  
+ static const struct gpio_chip samsung_gpiolib_chip = {
+       .set = samsung_gpio_set,
+       .get = samsung_gpio_get,
+       .direction_input = samsung_gpio_direction_input,
+       .direction_output = samsung_gpio_direction_output,
+       .to_irq = samsung_gpio_to_irq,
+       .owner = THIS_MODULE,
+ };
  /* register the gpiolib interface with the gpiolib subsystem */
 -static int __init samsung_gpiolib_register(struct platform_device *pdev,
 +static int __devinit samsung_gpiolib_register(struct platform_device *pdev,
                                struct samsung_pinctrl_drv_data *drvdata)
  {
+       struct samsung_pin_ctrl *ctrl = drvdata->ctrl;
+       struct samsung_pin_bank *bank = ctrl->pin_banks;
        struct gpio_chip *gc;
        int ret;
-       gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
-       if (!gc) {
-               dev_err(&pdev->dev, "mem alloc for gpio_chip failed\n");
-               return -ENOMEM;
-       }
-       drvdata->gc = gc;
-       gc->base = drvdata->ctrl->base;
-       gc->ngpio = drvdata->ctrl->nr_pins;
-       gc->dev = &pdev->dev;
-       gc->set = samsung_gpio_set;
-       gc->get = samsung_gpio_get;
-       gc->direction_input = samsung_gpio_direction_input;
-       gc->direction_output = samsung_gpio_direction_output;
-       gc->label = drvdata->ctrl->label;
-       gc->owner = THIS_MODULE;
-       ret = gpiochip_add(gc);
-       if (ret) {
-               dev_err(&pdev->dev, "failed to register gpio_chip %s, error "
-                                       "code: %d\n", gc->label, ret);
-               return ret;
+       int i;
+       for (i = 0; i < ctrl->nr_banks; ++i, ++bank) {
+               bank->gpio_chip = samsung_gpiolib_chip;
+               gc = &bank->gpio_chip;
+               gc->base = ctrl->base + bank->pin_base;
+               gc->ngpio = bank->nr_pins;
+               gc->dev = &pdev->dev;
+               gc->of_node = bank->of_node;
+               gc->label = bank->name;
+               ret = gpiochip_add(gc);
+               if (ret) {
+                       dev_err(&pdev->dev, "failed to register gpio_chip %s, error code: %d\n",
+                                                       gc->label, ret);
+                       goto fail;
+               }
        }
  
        return 0;
@@@ -762,15 -816,21 +816,21 @@@ fail
  }
  
  /* unregister the gpiolib interface with the gpiolib subsystem */
 -static int __init samsung_gpiolib_unregister(struct platform_device *pdev,
 +static int __devinit samsung_gpiolib_unregister(struct platform_device *pdev,
                                struct samsung_pinctrl_drv_data *drvdata)
  {
-       int ret = gpiochip_remove(drvdata->gc);
-       if (ret) {
+       struct samsung_pin_ctrl *ctrl = drvdata->ctrl;
+       struct samsung_pin_bank *bank = ctrl->pin_banks;
+       int ret = 0;
+       int i;
+       for (i = 0; !ret && i < ctrl->nr_banks; ++i, ++bank)
+               ret = gpiochip_remove(&bank->gpio_chip);
+       if (ret)
                dev_err(&pdev->dev, "gpio chip remove failed\n");
-               return ret;
-       }
-       return 0;
+       return ret;
  }
  
  static const struct of_device_id samsung_pinctrl_dt_match[];