diff options
-rw-r--r-- | drivers/mfd/sm501.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index 107215b28805..2dfb41aabcaf 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c | |||
@@ -999,7 +999,7 @@ static int __devinit sm501_gpio_register_chip(struct sm501_devdata *sm, | |||
999 | struct gpio_chip *gchip = &chip->gpio; | 999 | struct gpio_chip *gchip = &chip->gpio; |
1000 | int base = pdata->gpio_base; | 1000 | int base = pdata->gpio_base; |
1001 | 1001 | ||
1002 | memcpy(chip, &gpio_chip_template, sizeof(struct gpio_chip)); | 1002 | chip->gpio = gpio_chip_template; |
1003 | 1003 | ||
1004 | if (chip == &gpio->high) { | 1004 | if (chip == &gpio->high) { |
1005 | if (base > 0) | 1005 | if (base > 0) |
@@ -1039,7 +1039,7 @@ static int sm501_register_gpio(struct sm501_devdata *sm) | |||
1039 | if (gpio->regs == NULL) { | 1039 | if (gpio->regs == NULL) { |
1040 | dev_err(sm->dev, "gpio: failed to remap registers\n"); | 1040 | dev_err(sm->dev, "gpio: failed to remap registers\n"); |
1041 | ret = -ENXIO; | 1041 | ret = -ENXIO; |
1042 | goto err_mapped; | 1042 | goto err_claimed; |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | /* Register both our chips. */ | 1045 | /* Register both our chips. */ |
@@ -1068,6 +1068,9 @@ static int sm501_register_gpio(struct sm501_devdata *sm) | |||
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | err_mapped: | 1070 | err_mapped: |
1071 | iounmap(gpio->regs); | ||
1072 | |||
1073 | err_claimed: | ||
1071 | release_resource(gpio->regs_res); | 1074 | release_resource(gpio->regs_res); |
1072 | kfree(gpio->regs_res); | 1075 | kfree(gpio->regs_res); |
1073 | 1076 | ||
@@ -1076,33 +1079,38 @@ static int sm501_register_gpio(struct sm501_devdata *sm) | |||
1076 | 1079 | ||
1077 | static void sm501_gpio_remove(struct sm501_devdata *sm) | 1080 | static void sm501_gpio_remove(struct sm501_devdata *sm) |
1078 | { | 1081 | { |
1082 | struct sm501_gpio *gpio = &sm->gpio; | ||
1079 | int ret; | 1083 | int ret; |
1080 | 1084 | ||
1081 | ret = gpiochip_remove(&sm->gpio.low.gpio); | 1085 | ret = gpiochip_remove(&gpio->low.gpio); |
1082 | if (ret) | 1086 | if (ret) |
1083 | dev_err(sm->dev, "cannot remove low chip, cannot tidy up\n"); | 1087 | dev_err(sm->dev, "cannot remove low chip, cannot tidy up\n"); |
1084 | 1088 | ||
1085 | ret = gpiochip_remove(&sm->gpio.high.gpio); | 1089 | ret = gpiochip_remove(&gpio->high.gpio); |
1086 | if (ret) | 1090 | if (ret) |
1087 | dev_err(sm->dev, "cannot remove high chip, cannot tidy up\n"); | 1091 | dev_err(sm->dev, "cannot remove high chip, cannot tidy up\n"); |
1092 | |||
1093 | iounmap(gpio->regs); | ||
1094 | release_resource(gpio->regs_res); | ||
1095 | kfree(gpio->regs_res); | ||
1088 | } | 1096 | } |
1089 | 1097 | ||
1090 | static int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin) | 1098 | static inline int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin) |
1091 | { | 1099 | { |
1092 | struct sm501_gpio *gpio = &sm->gpio; | 1100 | struct sm501_gpio *gpio = &sm->gpio; |
1093 | return pin + (pin < 32) ? gpio->low.gpio.base : gpio->high.gpio.base; | 1101 | return pin + (pin < 32) ? gpio->low.gpio.base : gpio->high.gpio.base; |
1094 | } | 1102 | } |
1095 | #else | 1103 | #else |
1096 | static int sm501_register_gpio(struct sm501_devdata *sm) | 1104 | static inline int sm501_register_gpio(struct sm501_devdata *sm) |
1097 | { | 1105 | { |
1098 | return 0; | 1106 | return 0; |
1099 | } | 1107 | } |
1100 | 1108 | ||
1101 | static void sm501_gpio_remove(struct sm501_devdata *sm) | 1109 | static inline void sm501_gpio_remove(struct sm501_devdata *sm) |
1102 | { | 1110 | { |
1103 | } | 1111 | } |
1104 | 1112 | ||
1105 | static int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin) | 1113 | static inline int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin) |
1106 | { | 1114 | { |
1107 | return -1; | 1115 | return -1; |
1108 | } | 1116 | } |