net: dsa: microchip: ksz8795: Don't use phy_port_cnt in VLAN table lookup
[linux-2.6-block.git] / drivers / gpio / gpio-regmap.c
index 134cedf151a7e98100458d5cf9947d21ab9ec71e..69c219742083a6cd45035997988a585ec809668a 100644 (file)
@@ -178,12 +178,6 @@ static int gpio_regmap_direction_output(struct gpio_chip *chip,
        return gpio_regmap_set_direction(chip, offset, true);
 }
 
-void gpio_regmap_set_drvdata(struct gpio_regmap *gpio, void *data)
-{
-       gpio->driver_data = data;
-}
-EXPORT_SYMBOL_GPL(gpio_regmap_set_drvdata);
-
 void *gpio_regmap_get_drvdata(struct gpio_regmap *gpio)
 {
        return gpio->driver_data;
@@ -226,6 +220,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
                return ERR_PTR(-ENOMEM);
 
        gpio->parent = config->parent;
+       gpio->driver_data = config->drvdata;
        gpio->regmap = config->regmap;
        gpio->ngpio_per_reg = config->ngpio_per_reg;
        gpio->reg_stride = config->reg_stride;
@@ -311,9 +306,9 @@ void gpio_regmap_unregister(struct gpio_regmap *gpio)
 }
 EXPORT_SYMBOL_GPL(gpio_regmap_unregister);
 
-static void devm_gpio_regmap_unregister(struct device *dev, void *res)
+static void devm_gpio_regmap_unregister(void *res)
 {
-       gpio_regmap_unregister(*(struct gpio_regmap **)res);
+       gpio_regmap_unregister(res);
 }
 
 /**
@@ -330,20 +325,17 @@ static void devm_gpio_regmap_unregister(struct device *dev, void *res)
 struct gpio_regmap *devm_gpio_regmap_register(struct device *dev,
                                              const struct gpio_regmap_config *config)
 {
-       struct gpio_regmap **ptr, *gpio;
-
-       ptr = devres_alloc(devm_gpio_regmap_unregister, sizeof(*ptr),
-                          GFP_KERNEL);
-       if (!ptr)
-               return ERR_PTR(-ENOMEM);
+       struct gpio_regmap *gpio;
+       int ret;
 
        gpio = gpio_regmap_register(config);
-       if (!IS_ERR(gpio)) {
-               *ptr = gpio;
-               devres_add(dev, ptr);
-       } else {
-               devres_free(ptr);
-       }
+
+       if (IS_ERR(gpio))
+               return gpio;
+
+       ret = devm_add_action_or_reset(dev, devm_gpio_regmap_unregister, gpio);
+       if (ret)
+               return ERR_PTR(ret);
 
        return gpio;
 }