aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2013-04-02 08:24:20 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-03 13:40:28 -0400
commitda45edc7f8e6930eb32e316bed3936bd05deeedd (patch)
tree7b7b8b48b5ce2beb17be1925d087f34f4f1318ba
parentc4e67bbc99ce661808c3ee77b0bb5779d0df11ca (diff)
regulator: ab8500: Shuffle init functions into a more logical order
The ab*_match[] arrays should be moved out of the way, instead of bunched in the middle of the initialisation functions. This patch moves all initialisation code which currently resides above these arrays down to be grouped with the others. This makes the whole thing slightly easier to read. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/regulator/ab8500.c170
1 files changed, 85 insertions, 85 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index bb574bfaac30..535a94f6a4f1 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -2916,91 +2916,6 @@ static struct ab8500_reg_init ab8540_reg_init[] = {
2916 REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07), 2916 REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07),
2917}; 2917};
2918 2918
2919static struct {
2920 struct ab8500_regulator_info *info;
2921 int info_size;
2922 struct ab8500_reg_init *init;
2923 int init_size;
2924 struct of_regulator_match *match;
2925 int match_size;
2926} abx500_regulator;
2927
2928static int ab8500_regulator_init_registers(struct platform_device *pdev,
2929 int id, int mask, int value)
2930{
2931 struct ab8500_reg_init *reg_init = abx500_regulator.init;
2932 int err;
2933
2934 BUG_ON(value & ~mask);
2935 BUG_ON(mask & ~reg_init[id].mask);
2936
2937 /* initialize register */
2938 err = abx500_mask_and_set_register_interruptible(
2939 &pdev->dev,
2940 reg_init[id].bank,
2941 reg_init[id].addr,
2942 mask, value);
2943 if (err < 0) {
2944 dev_err(&pdev->dev,
2945 "Failed to initialize 0x%02x, 0x%02x.\n",
2946 reg_init[id].bank,
2947 reg_init[id].addr);
2948 return err;
2949 }
2950 dev_vdbg(&pdev->dev,
2951 " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
2952 reg_init[id].bank,
2953 reg_init[id].addr,
2954 mask, value);
2955
2956 return 0;
2957}
2958
2959static int ab8500_regulator_register(struct platform_device *pdev,
2960 struct regulator_init_data *init_data,
2961 int id, struct device_node *np)
2962{
2963 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
2964 struct ab8500_regulator_info *info = NULL;
2965 struct regulator_config config = { };
2966 int err;
2967
2968 /* assign per-regulator data */
2969 info = &abx500_regulator.info[id];
2970 info->dev = &pdev->dev;
2971
2972 config.dev = &pdev->dev;
2973 config.init_data = init_data;
2974 config.driver_data = info;
2975 config.of_node = np;
2976
2977 /* fix for hardware before ab8500v2.0 */
2978 if (is_ab8500_1p1_or_earlier(ab8500)) {
2979 if (info->desc.id == AB8500_LDO_AUX3) {
2980 info->desc.n_voltages =
2981 ARRAY_SIZE(ldo_vauxn_voltages);
2982 info->desc.volt_table = ldo_vauxn_voltages;
2983 info->voltage_mask = 0xf;
2984 }
2985 }
2986
2987 /* register regulator with framework */
2988 info->regulator = regulator_register(&info->desc, &config);
2989 if (IS_ERR(info->regulator)) {
2990 err = PTR_ERR(info->regulator);
2991 dev_err(&pdev->dev, "failed to register regulator %s\n",
2992 info->desc.name);
2993 /* when we fail, un-register all earlier regulators */
2994 while (--id >= 0) {
2995 info = &abx500_regulator.info[id];
2996 regulator_unregister(info->regulator);
2997 }
2998 return err;
2999 }
3000
3001 return 0;
3002}
3003
3004static struct of_regulator_match ab8500_regulator_match[] = { 2919static struct of_regulator_match ab8500_regulator_match[] = {
3005 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, }, 2920 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
3006 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, }, 2921 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
@@ -3061,6 +2976,15 @@ static struct of_regulator_match ab9540_regulator_match[] = {
3061 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, }, 2976 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, },
3062}; 2977};
3063 2978
2979static struct {
2980 struct ab8500_regulator_info *info;
2981 int info_size;
2982 struct ab8500_reg_init *init;
2983 int init_size;
2984 struct of_regulator_match *match;
2985 int match_size;
2986} abx500_regulator;
2987
3064static void abx500_get_regulator_info(struct ab8500 *ab8500) 2988static void abx500_get_regulator_info(struct ab8500 *ab8500)
3065{ 2989{
3066 if (is_ab9540(ab8500)) { 2990 if (is_ab9540(ab8500)) {
@@ -3094,6 +3018,82 @@ static void abx500_get_regulator_info(struct ab8500 *ab8500)
3094 } 3018 }
3095} 3019}
3096 3020
3021static int ab8500_regulator_init_registers(struct platform_device *pdev,
3022 int id, int mask, int value)
3023{
3024 struct ab8500_reg_init *reg_init = abx500_regulator.init;
3025 int err;
3026
3027 BUG_ON(value & ~mask);
3028 BUG_ON(mask & ~reg_init[id].mask);
3029
3030 /* initialize register */
3031 err = abx500_mask_and_set_register_interruptible(
3032 &pdev->dev,
3033 reg_init[id].bank,
3034 reg_init[id].addr,
3035 mask, value);
3036 if (err < 0) {
3037 dev_err(&pdev->dev,
3038 "Failed to initialize 0x%02x, 0x%02x.\n",
3039 reg_init[id].bank,
3040 reg_init[id].addr);
3041 return err;
3042 }
3043 dev_vdbg(&pdev->dev,
3044 " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
3045 reg_init[id].bank,
3046 reg_init[id].addr,
3047 mask, value);
3048
3049 return 0;
3050}
3051
3052static int ab8500_regulator_register(struct platform_device *pdev,
3053 struct regulator_init_data *init_data,
3054 int id, struct device_node *np)
3055{
3056 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
3057 struct ab8500_regulator_info *info = NULL;
3058 struct regulator_config config = { };
3059 int err;
3060
3061 /* assign per-regulator data */
3062 info = &abx500_regulator.info[id];
3063 info->dev = &pdev->dev;
3064
3065 config.dev = &pdev->dev;
3066 config.init_data = init_data;
3067 config.driver_data = info;
3068 config.of_node = np;
3069
3070 /* fix for hardware before ab8500v2.0 */
3071 if (is_ab8500_1p1_or_earlier(ab8500)) {
3072 if (info->desc.id == AB8500_LDO_AUX3) {
3073 info->desc.n_voltages =
3074 ARRAY_SIZE(ldo_vauxn_voltages);
3075 info->desc.volt_table = ldo_vauxn_voltages;
3076 info->voltage_mask = 0xf;
3077 }
3078 }
3079
3080 /* register regulator with framework */
3081 info->regulator = regulator_register(&info->desc, &config);
3082 if (IS_ERR(info->regulator)) {
3083 err = PTR_ERR(info->regulator);
3084 dev_err(&pdev->dev, "failed to register regulator %s\n",
3085 info->desc.name);
3086 /* when we fail, un-register all earlier regulators */
3087 while (--id >= 0) {
3088 info = &abx500_regulator.info[id];
3089 regulator_unregister(info->regulator);
3090 }
3091 return err;
3092 }
3093
3094 return 0;
3095}
3096
3097static int 3097static int
3098ab8500_regulator_of_probe(struct platform_device *pdev, 3098ab8500_regulator_of_probe(struct platform_device *pdev,
3099 struct device_node *np) 3099 struct device_node *np)