aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Fitzgerald <rf@opensource.wolfsonmicro.com>2015-10-02 08:29:13 -0400
committerLee Jones <lee.jones@linaro.org>2015-10-30 13:20:28 -0400
commitae05ea36d1c9bdc76a4539277d96f5bdf3d39f02 (patch)
treec9ad61d4f55c3070b4184ab7b75c238e1294bfc3
parent161ad30bd2ec4be7269b2f8748fa4e5d5847191e (diff)
mfd: arizona: Simplify adding subdevices
The code was using a switch on the code type to execute one of several mfd_add_devices() calls. We're already switching on the code type earlier in the function to select the correct patch function so we can roll selection of the mfd device table into the same switch. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--drivers/mfd/arizona-core.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index c3f88e57fe4a..39899bf18231 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -24,6 +24,7 @@
24#include <linux/regulator/consumer.h> 24#include <linux/regulator/consumer.h>
25#include <linux/regulator/machine.h> 25#include <linux/regulator/machine.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/platform_device.h>
27 28
28#include <linux/mfd/arizona/core.h> 29#include <linux/mfd/arizona/core.h>
29#include <linux/mfd/arizona/registers.h> 30#include <linux/mfd/arizona/registers.h>
@@ -965,7 +966,8 @@ int arizona_dev_init(struct arizona *arizona)
965 const char *type_name; 966 const char *type_name;
966 unsigned int reg, val, mask; 967 unsigned int reg, val, mask;
967 int (*apply_patch)(struct arizona *) = NULL; 968 int (*apply_patch)(struct arizona *) = NULL;
968 int ret, i; 969 const struct mfd_cell *subdevs = NULL;
970 int n_subdevs, ret, i;
969 971
970 dev_set_drvdata(arizona->dev, arizona); 972 dev_set_drvdata(arizona->dev, arizona);
971 mutex_init(&arizona->clk_lock); 973 mutex_init(&arizona->clk_lock);
@@ -1136,6 +1138,8 @@ int arizona_dev_init(struct arizona *arizona)
1136 } 1138 }
1137 apply_patch = wm5102_patch; 1139 apply_patch = wm5102_patch;
1138 arizona->rev &= 0x7; 1140 arizona->rev &= 0x7;
1141 subdevs = wm5102_devs;
1142 n_subdevs = ARRAY_SIZE(wm5102_devs);
1139 break; 1143 break;
1140#endif 1144#endif
1141#ifdef CONFIG_MFD_WM5110 1145#ifdef CONFIG_MFD_WM5110
@@ -1155,6 +1159,8 @@ int arizona_dev_init(struct arizona *arizona)
1155 break; 1159 break;
1156 } 1160 }
1157 apply_patch = wm5110_patch; 1161 apply_patch = wm5110_patch;
1162 subdevs = wm5110_devs;
1163 n_subdevs = ARRAY_SIZE(wm5110_devs);
1158 break; 1164 break;
1159#endif 1165#endif
1160#ifdef CONFIG_MFD_WM8997 1166#ifdef CONFIG_MFD_WM8997
@@ -1166,6 +1172,8 @@ int arizona_dev_init(struct arizona *arizona)
1166 arizona->type = WM8997; 1172 arizona->type = WM8997;
1167 } 1173 }
1168 apply_patch = wm8997_patch; 1174 apply_patch = wm8997_patch;
1175 subdevs = wm8997_devs;
1176 n_subdevs = ARRAY_SIZE(wm8997_devs);
1169 break; 1177 break;
1170#endif 1178#endif
1171#ifdef CONFIG_MFD_WM8998 1179#ifdef CONFIG_MFD_WM8998
@@ -1187,6 +1195,8 @@ int arizona_dev_init(struct arizona *arizona)
1187 } 1195 }
1188 1196
1189 apply_patch = wm8998_patch; 1197 apply_patch = wm8998_patch;
1198 subdevs = wm8998_devs;
1199 n_subdevs = ARRAY_SIZE(wm8998_devs);
1190 break; 1200 break;
1191#endif 1201#endif
1192 default: 1202 default:
@@ -1379,28 +1389,10 @@ int arizona_dev_init(struct arizona *arizona)
1379 arizona_request_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, "Underclocked", 1389 arizona_request_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, "Underclocked",
1380 arizona_underclocked, arizona); 1390 arizona_underclocked, arizona);
1381 1391
1382 switch (arizona->type) { 1392 ret = mfd_add_devices(arizona->dev, PLATFORM_DEVID_NONE,
1383 case WM5102: 1393 subdevs, n_subdevs, NULL, 0, NULL);
1384 ret = mfd_add_devices(arizona->dev, -1, wm5102_devs,
1385 ARRAY_SIZE(wm5102_devs), NULL, 0, NULL);
1386 break;
1387 case WM5110:
1388 case WM8280:
1389 ret = mfd_add_devices(arizona->dev, -1, wm5110_devs,
1390 ARRAY_SIZE(wm5110_devs), NULL, 0, NULL);
1391 break;
1392 case WM8997:
1393 ret = mfd_add_devices(arizona->dev, -1, wm8997_devs,
1394 ARRAY_SIZE(wm8997_devs), NULL, 0, NULL);
1395 break;
1396 case WM8998:
1397 case WM1814:
1398 ret = mfd_add_devices(arizona->dev, -1, wm8998_devs,
1399 ARRAY_SIZE(wm8998_devs), NULL, 0, NULL);
1400 break;
1401 }
1402 1394
1403 if (ret != 0) { 1395 if (ret) {
1404 dev_err(arizona->dev, "Failed to add subdevices: %d\n", ret); 1396 dev_err(arizona->dev, "Failed to add subdevices: %d\n", ret);
1405 goto err_irq; 1397 goto err_irq;
1406 } 1398 }