aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/stmpe.c60
1 files changed, 21 insertions, 39 deletions
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index ba157d45192d..c0df4b9d51c3 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -1052,17 +1052,17 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
1052 int ret; 1052 int ret;
1053 1053
1054 if (!pdata) { 1054 if (!pdata) {
1055 if (np) { 1055 if (!np)
1056 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
1057 if (!pdata)
1058 return -ENOMEM;
1059
1060 stmpe_of_probe(pdata, np);
1061 } else
1062 return -EINVAL; 1056 return -EINVAL;
1057
1058 pdata = devm_kzalloc(ci->dev, sizeof(*pdata), GFP_KERNEL);
1059 if (!pdata)
1060 return -ENOMEM;
1061
1062 stmpe_of_probe(pdata, np);
1063 } 1063 }
1064 1064
1065 stmpe = kzalloc(sizeof(struct stmpe), GFP_KERNEL); 1065 stmpe = devm_kzalloc(ci->dev, sizeof(struct stmpe), GFP_KERNEL);
1066 if (!stmpe) 1066 if (!stmpe)
1067 return -ENOMEM; 1067 return -ENOMEM;
1068 1068
@@ -1084,11 +1084,12 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
1084 ci->init(stmpe); 1084 ci->init(stmpe);
1085 1085
1086 if (pdata->irq_over_gpio) { 1086 if (pdata->irq_over_gpio) {
1087 ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe"); 1087 ret = devm_gpio_request_one(ci->dev, pdata->irq_gpio,
1088 GPIOF_DIR_IN, "stmpe");
1088 if (ret) { 1089 if (ret) {
1089 dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n", 1090 dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n",
1090 ret); 1091 ret);
1091 goto out_free; 1092 return ret;
1092 } 1093 }
1093 1094
1094 stmpe->irq = gpio_to_irq(pdata->irq_gpio); 1095 stmpe->irq = gpio_to_irq(pdata->irq_gpio);
@@ -1105,48 +1106,37 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
1105 dev_err(stmpe->dev, 1106 dev_err(stmpe->dev,
1106 "%s does not support no-irq mode!\n", 1107 "%s does not support no-irq mode!\n",
1107 stmpe->variant->name); 1108 stmpe->variant->name);
1108 ret = -ENODEV; 1109 return -ENODEV;
1109 goto free_gpio;
1110 } 1110 }
1111 stmpe->variant = stmpe_noirq_variant_info[stmpe->partnum]; 1111 stmpe->variant = stmpe_noirq_variant_info[stmpe->partnum];
1112 } 1112 }
1113 1113
1114 ret = stmpe_chip_init(stmpe); 1114 ret = stmpe_chip_init(stmpe);
1115 if (ret) 1115 if (ret)
1116 goto free_gpio; 1116 return ret;
1117 1117
1118 if (stmpe->irq >= 0) { 1118 if (stmpe->irq >= 0) {
1119 ret = stmpe_irq_init(stmpe, np); 1119 ret = stmpe_irq_init(stmpe, np);
1120 if (ret) 1120 if (ret)
1121 goto free_gpio; 1121 return ret;
1122 1122
1123 ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq, 1123 ret = devm_request_threaded_irq(ci->dev, stmpe->irq, NULL,
1124 pdata->irq_trigger | IRQF_ONESHOT, 1124 stmpe_irq, pdata->irq_trigger | IRQF_ONESHOT,
1125 "stmpe", stmpe); 1125 "stmpe", stmpe);
1126 if (ret) { 1126 if (ret) {
1127 dev_err(stmpe->dev, "failed to request IRQ: %d\n", 1127 dev_err(stmpe->dev, "failed to request IRQ: %d\n",
1128 ret); 1128 ret);
1129 goto free_gpio; 1129 return ret;
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 ret = stmpe_devices_init(stmpe); 1133 ret = stmpe_devices_init(stmpe);
1134 if (ret) { 1134 if (!ret)
1135 dev_err(stmpe->dev, "failed to add children\n"); 1135 return 0;
1136 goto out_removedevs;
1137 }
1138
1139 return 0;
1140 1136
1141out_removedevs: 1137 dev_err(stmpe->dev, "failed to add children\n");
1142 mfd_remove_devices(stmpe->dev); 1138 mfd_remove_devices(stmpe->dev);
1143 if (stmpe->irq >= 0) 1139
1144 free_irq(stmpe->irq, stmpe);
1145free_gpio:
1146 if (pdata->irq_over_gpio)
1147 gpio_free(pdata->irq_gpio);
1148out_free:
1149 kfree(stmpe);
1150 return ret; 1140 return ret;
1151} 1141}
1152 1142
@@ -1154,14 +1144,6 @@ int stmpe_remove(struct stmpe *stmpe)
1154{ 1144{
1155 mfd_remove_devices(stmpe->dev); 1145 mfd_remove_devices(stmpe->dev);
1156 1146
1157 if (stmpe->irq >= 0)
1158 free_irq(stmpe->irq, stmpe);
1159
1160 if (stmpe->pdata->irq_over_gpio)
1161 gpio_free(stmpe->pdata->irq_gpio);
1162
1163 kfree(stmpe);
1164
1165 return 0; 1147 return 0;
1166} 1148}
1167 1149