mfd: arizona: factor out DCVDD isolation control
Subsystems (2)
PATCH v2 1/6 mfd: arizona: factor out DCVDD isolation control
From: Richard Fitzgerald <[email protected]>
Currently DCVDD isolation is enabled and disabled for runtime_suspend and runtime_resume. Future codecs will not have the isolation control so to prepare for these codecs this patch factors out the isolation control allowing it to be called as needed in the existing codec-specific switch cases.
--- drivers/mfd/arizona-core.c | 108 +++++++++++++++++++++++++------------------- 1 files changed, 62 insertions(+), 46 deletions(-)
drivers/mfd/arizona-core.c +62 -46
@@ -460,6 +460,33 @@ static int wm5102_clear_write_sequencer(struct arizona *arizona) }#ifdef CONFIG_PM +static int arizona_isolate_dcvdd (struct arizona *arizona) +{ +int ret; + + ret =regmap_update_bits (arizona->regmap, +ARIZONA_ISOLATION_CONTROL , +ARIZONA_ISOLATE_DCVDD1 , +ARIZONA_ISOLATE_DCVDD1 ); +if (ret !=0 ) +dev_err (arizona->dev,"Failed to isolate DCVDD: %d\n" , ret); + +return ret; +} + +static int arizona_connect_dcvdd (struct arizona *arizona) +{ +int ret; + + ret =regmap_update_bits (arizona->regmap, +ARIZONA_ISOLATION_CONTROL , +ARIZONA_ISOLATE_DCVDD1 ,0 ); +if (ret !=0 ) +dev_err (arizona->dev,"Failed to connect DCVDD: %d\n" , ret); + +return ret; +} +static int arizona_runtime_resume (struct device *dev) {struct arizona *arizona =dev_get_drvdata (dev);
@@ -499,14 +526,9 @@ static int arizona_runtime_resume(struct device *dev)switch (arizona->type) {case WM5102 :if (arizona->external_dcvdd) { - ret =regmap_update_bits (arizona->regmap, -ARIZONA_ISOLATION_CONTROL , -ARIZONA_ISOLATE_DCVDD1 ,0 ); -if (ret !=0 ) { -dev_err (arizona->dev, -"Failed to connect DCVDD: %d\n" , ret); + ret =arizona_connect_dcvdd (arizona); +if (ret !=0 ) goto err; - } } ret =wm5102_patch (arizona);
@@ -531,14 +553,9 @@ static int arizona_runtime_resume(struct device *dev) goto err;if (arizona->external_dcvdd) { - ret =regmap_update_bits (arizona->regmap, -ARIZONA_ISOLATION_CONTROL , -ARIZONA_ISOLATE_DCVDD1 ,0 ); -if (ret) { -dev_err (arizona->dev, -"Failed to connect DCVDD: %d\n" , ret); + ret =arizona_connect_dcvdd (arizona); +if (ret !=0 ) goto err; - } }else {/* * As this is only called for the internal regulator
@@ -569,14 +586,9 @@ static int arizona_runtime_resume(struct device *dev) goto err;if (arizona->external_dcvdd) { - ret =regmap_update_bits (arizona->regmap, -ARIZONA_ISOLATION_CONTROL , -ARIZONA_ISOLATE_DCVDD1 ,0 ); -if (ret !=0 ) { -dev_err (arizona->dev, -"Failed to connect DCVDD: %d\n" , ret); + ret =arizona_connect_dcvdd (arizona); +if (ret !=0 ) goto err; - } }break ; }
@@ -609,37 +621,36 @@ static int arizona_runtime_suspend(struct device *dev)return ret; } -if (arizona->external_dcvdd) { - ret =regmap_update_bits (arizona->regmap, -ARIZONA_ISOLATION_CONTROL , -ARIZONA_ISOLATE_DCVDD1 , -ARIZONA_ISOLATE_DCVDD1 ); -if (ret !=0 ) { -dev_err (arizona->dev,"Failed to isolate DCVDD: %d\n" , - ret); -return ret; - } - } -switch (arizona->type) {case WM5110 :case WM8280 : -if (arizona->external_dcvdd) -break ; - -/* -* As this is only called for the internal regulator -* (where we know voltage ranges available) it is ok -* to request an exact range. -*/ - ret =regulator_set_voltage (arizona->dcvdd,1175000 ,1175000 ); -if (ret <0 ) { -dev_err (arizona->dev, -"Failed to set suspend voltage: %d\n" , ret); -return ret; +if (arizona->external_dcvdd) { + ret =arizona_isolate_dcvdd (arizona); +if (ret !=0 ) +return ret; + }else { +/* +* As this is only called for the internal regulator +* (where we know voltage ranges available) it is ok +* to request an exact range. +*/ + ret =regulator_set_voltage (arizona->dcvdd, +1175000 ,1175000 ); +if (ret <0 ) { +dev_err (arizona->dev, +"Failed to set suspend voltage: %d\n" , + ret); +return ret; + } }break ;case WM5102 : +if (arizona->external_dcvdd) { + ret =arizona_isolate_dcvdd (arizona); +if (ret !=0 ) +return ret; + } +if (!(val &ARIZONA_JD1_ENA )) { ret =regmap_write (arizona->regmap,ARIZONA_WRITE_SEQUENCER_CTRL_3 ,0x0 );
@@ -652,6 +663,11 @@ static int arizona_runtime_suspend(struct device *dev) }break ;default : +if (arizona->external_dcvdd) { + ret =arizona_isolate_dcvdd (arizona); +if (ret !=0 ) +return ret; + }break ; }
Signature · 1 line
1.7.2.5
PATCH v2 2/6 mfd: arizona: factor out checking of jack detection state
From: Richard Fitzgerald <[email protected]>
Currently runtime_suspend will fully power off the codec if the jack detection is not enabled. Not all future codecs will have jack detection so to prepare for these codecs this patch factors out the check so that it be called as needed in the existing codec-specific switch cases.
--- drivers/mfd/arizona-core.c | 41 ++++++++++++++++++++++++++++++++--------- 1 files changed, 32 insertions(+), 9 deletions(-)
drivers/mfd/arizona-core.c +32 -9
@@ -487,6 +487,23 @@ static int arizona_connect_dcvdd(struct arizona *arizona)return ret; } +static int arizona_is_jack_det_active (struct arizona *arizona) +{ +unsigned int val; +int ret; + + ret =regmap_read (arizona->regmap,ARIZONA_JACK_DETECT_ANALOGUE , &val); +if (ret) { +dev_err (arizona->dev, +"Failed to check jack det status: %d\n" , ret); +return ret; + }else if (val &ARIZONA_JD1_ENA ) { +return 1 ; + }else { +return 0 ; + } +} +static int arizona_runtime_resume (struct device *dev) {struct arizona *arizona =dev_get_drvdata (dev);
@@ -610,20 +627,18 @@ err:static int arizona_runtime_suspend (struct device *dev) {struct arizona *arizona =dev_get_drvdata (dev); -unsigned int val; +unsigned int jd_active =0 ;int ret;dev_dbg (arizona->dev,"Entering AoD mode\n" ); - ret =regmap_read (arizona->regmap,ARIZONA_JACK_DETECT_ANALOGUE , &val); -if (ret) { -dev_err (dev,"Failed to check jack det status: %d\n" , ret); -return ret; - } -switch (arizona->type) {case WM5110 :case WM8280 : + jd_active =arizona_is_jack_det_active (arizona); +if (jd_active <0 ) +return jd_active; +if (arizona->external_dcvdd) { ret =arizona_isolate_dcvdd (arizona);if (ret !=0 )
@@ -645,13 +660,17 @@ static int arizona_runtime_suspend(struct device *dev) }break ;case WM5102 : + jd_active =arizona_is_jack_det_active (arizona); +if (jd_active <0 ) +return jd_active; +if (arizona->external_dcvdd) { ret =arizona_isolate_dcvdd (arizona);if (ret !=0 )return ret; } -if (!(val &ARIZONA_JD1_ENA )) { +if (!jd_active) { ret =regmap_write (arizona->regmap,ARIZONA_WRITE_SEQUENCER_CTRL_3 ,0x0 );if (ret) {
@@ -663,6 +682,10 @@ static int arizona_runtime_suspend(struct device *dev) }break ;default : + jd_active =arizona_is_jack_det_active (arizona); +if (jd_active <0 ) +return jd_active; +if (arizona->external_dcvdd) { ret =arizona_isolate_dcvdd (arizona);if (ret !=0 )
@@ -676,7 +699,7 @@ static int arizona_runtime_suspend(struct device *dev)regulator_disable (arizona->dcvdd);/* Allow us to completely power down if no jack detection */ -if (!(val &ARIZONA_JD1_ENA )) { +if (!jd_active) {dev_dbg (arizona->dev,"Fully powering off\n" ); arizona->has_fully_powered_off = true;
Signature · 1 line
1.7.2.5
Lee Jones
AppliedRe: [PATCH v2 2/6] mfd: arizona: factor out checking of jack detection state
Quoted 8 lines · Charles Keepax
From: Richard Fitzgerald <[email protected]>
Currently
runtime_suspendwill fully power off the codec if the jack detection is not enabled. Not all future codecs will have jack detection so to prepare for these codecs this patch factors out the check so that it be called as needed in the existing codec-specific switch cases.
Quoted 6 lines
Signed-off-by Richard Fitzgerald <[email protected]>Acked-by Lee Jones <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-core.c | 41 ++++++++++++++++++++++++++++++++--------- 1 files changed, 32 insertions(+), 9 deletions(-)
Applied, thanks.
Quoted 93 lines
drivers/mfd/arizona-core.c +32
-9@@ -487,6 +487,23 @@ static int arizona_connect_dcvdd(struct arizona *arizona)return ret; } +static int arizona_is_jack_det_active (struct arizona *arizona) +{ +unsigned int val; +int ret; + + ret =regmap_read (arizona->regmap,ARIZONA_JACK_DETECT_ANALOGUE , &val); +if (ret) { +dev_err (arizona->dev, +"Failed to check jack det status: %d\n" , ret); +return ret; + }else if (val &ARIZONA_JD1_ENA ) { +return 1 ; + }else { +return 0 ; + } +} +static int arizona_runtime_resume (struct device *dev) {struct arizona *arizona =dev_get_drvdata (dev);@@ -610,20 +627,18 @@ err:static int arizona_runtime_suspend (struct device *dev) {struct arizona *arizona =dev_get_drvdata (dev); -unsigned int val; +unsigned int jd_active =0 ;int ret;dev_dbg (arizona->dev,"Entering AoD mode\n" ); - ret =regmap_read (arizona->regmap,ARIZONA_JACK_DETECT_ANALOGUE , &val); -if (ret) { -dev_err (dev,"Failed to check jack det status: %d\n" , ret); -return ret; - } -switch (arizona->type) {case WM5110 :case WM8280 : + jd_active =arizona_is_jack_det_active (arizona); +if (jd_active <0 ) +return jd_active; +if (arizona->external_dcvdd) { ret =arizona_isolate_dcvdd (arizona);if (ret !=0 )@@ -645,13 +660,17 @@ static int arizona_runtime_suspend(struct device *dev) }break ;case WM5102 : + jd_active =arizona_is_jack_det_active (arizona); +if (jd_active <0 ) +return jd_active; +if (arizona->external_dcvdd) { ret =arizona_isolate_dcvdd (arizona);if (ret !=0 )return ret; } -if (!(val &ARIZONA_JD1_ENA )) { +if (!jd_active) { ret =regmap_write (arizona->regmap,ARIZONA_WRITE_SEQUENCER_CTRL_3 ,0x0 );if (ret) {@@ -663,6 +682,10 @@ static int arizona_runtime_suspend(struct device *dev) }break ;default : + jd_active =arizona_is_jack_det_active (arizona); +if (jd_active <0 ) +return jd_active; +if (arizona->external_dcvdd) { ret =arizona_isolate_dcvdd (arizona);if (ret !=0 )@@ -676,7 +699,7 @@ static int arizona_runtime_suspend(struct device *dev)regulator_disable (arizona->dcvdd);/* Allow us to completely power down if no jack detection */ -if (!(val &ARIZONA_JD1_ENA )) { +if (!jd_active) {dev_dbg (arizona->dev,"Fully powering off\n" ); arizona->has_fully_powered_off = true;
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v2 3/6 mfd: arizona: Downgrade type mismatch messages to dev_warn
In reply to Charles KeepaxFrom: Richard Fitzgerald <[email protected]>
If the declared codec type doesn't match the detected type we issue a log message but carry on registering the device, so a dev_warn() is appropriate rather than a dev_err()
--- drivers/mfd/arizona-core.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
drivers/mfd/arizona-core.c +8 -8
@@ -1130,8 +1130,8 @@ int arizona_dev_init(struct arizona *arizona)case 0x5102 : type_name ="WM5102" ;if (arizona->type !=WM5102 ) { -dev_err (arizona->dev,"WM5102 registered as %d\n" , - arizona->type); +dev_warn (arizona->dev,"WM5102 registered as %d\n" , + arizona->type); arizona->type =WM5102 ; } apply_patch = wm5102_patch;
@@ -1149,8 +1149,8 @@ int arizona_dev_init(struct arizona *arizona)break ;default : type_name ="WM5110" ; -dev_err (arizona->dev,"WM5110 registered as %d\n" , - arizona->type); +dev_warn (arizona->dev,"WM5110 registered as %d\n" , + arizona->type); arizona->type =WM5110 ;break ; }
@@ -1161,8 +1161,8 @@ int arizona_dev_init(struct arizona *arizona)case 0x8997 : type_name ="WM8997" ;if (arizona->type !=WM8997 ) { -dev_err (arizona->dev,"WM8997 registered as %d\n" , - arizona->type); +dev_warn (arizona->dev,"WM8997 registered as %d\n" , + arizona->type); arizona->type =WM8997 ; } apply_patch = wm8997_patch;
@@ -1181,8 +1181,8 @@ int arizona_dev_init(struct arizona *arizona)default : type_name ="WM8998" ; -dev_err (arizona->dev,"WM8998 registered as %d\n" , - arizona->type); +dev_warn (arizona->dev,"WM8998 registered as %d\n" , + arizona->type); arizona->type =WM8998 ; }
Signature · 1 line
1.7.2.5
Lee Jones
AppliedRe: [PATCH v2 3/6] mfd: arizona: Downgrade type mismatch messages to dev_warn
Quoted 6 lines · Charles Keepax
From: Richard Fitzgerald <[email protected]>
If the declared codec type doesn't match the detected type we issue a log message but carry on registering the device, so a
dev_warn()is appropriate rather than adev_err()
Quoted 6 lines
Signed-off-by Richard Fitzgerald <[email protected]>Acked-by Lee Jones <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-core.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
Applied, thanks.
Quoted 48 lines
drivers/mfd/arizona-core.c +8
-8@@ -1130,8 +1130,8 @@ int arizona_dev_init(struct arizona *arizona)case 0x5102 : type_name ="WM5102" ;if (arizona->type !=WM5102 ) { -dev_err (arizona->dev,"WM5102 registered as %d\n" , - arizona->type); +dev_warn (arizona->dev,"WM5102 registered as %d\n" , + arizona->type); arizona->type =WM5102 ; } apply_patch = wm5102_patch;@@ -1149,8 +1149,8 @@ int arizona_dev_init(struct arizona *arizona)break ;default : type_name ="WM5110" ; -dev_err (arizona->dev,"WM5110 registered as %d\n" , - arizona->type); +dev_warn (arizona->dev,"WM5110 registered as %d\n" , + arizona->type); arizona->type =WM5110 ;break ; }@@ -1161,8 +1161,8 @@ int arizona_dev_init(struct arizona *arizona)case 0x8997 : type_name ="WM8997" ;if (arizona->type !=WM8997 ) { -dev_err (arizona->dev,"WM8997 registered as %d\n" , - arizona->type); +dev_warn (arizona->dev,"WM8997 registered as %d\n" , + arizona->type); arizona->type =WM8997 ; } apply_patch = wm8997_patch;@@ -1181,8 +1181,8 @@ int arizona_dev_init(struct arizona *arizona)default : type_name ="WM8998" ; -dev_err (arizona->dev,"WM8998 registered as %d\n" , - arizona->type); +dev_warn (arizona->dev,"WM8998 registered as %d\n" , + arizona->type); arizona->type =WM8998 ; }
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v2 4/6 mfd: arizona: Simplify adding subdevices
In reply to Charles KeepaxFrom: Richard Fitzgerald <[email protected]>
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.
--- drivers/mfd/arizona-core.c | 36 ++++++++++++++---------------------- 1 files changed, 14 insertions(+), 22 deletions(-)
drivers/mfd/arizona-core.c +14 -22
@@ -24,6 +24,7 @@#include <linux/regulator/consumer.h> #include <linux/regulator/machine.h> #include <linux/slab.h> +#include <linux/platform_device.h> #include <linux/mfd/arizona/core.h> #include <linux/mfd/arizona/registers.h>
@@ -965,7 +966,8 @@ int arizona_dev_init(struct arizona *arizona)const char *type_name;unsigned int reg, val, mask;int (*apply_patch)(struct arizona *) =NULL ; -int ret, i; +const struct mfd_cell *subdevs =NULL ; +int n_subdevs, ret, i;dev_set_drvdata (arizona->dev, arizona);mutex_init (&arizona->clk_lock);
@@ -1136,6 +1138,8 @@ int arizona_dev_init(struct arizona *arizona) } apply_patch = wm5102_patch; arizona->rev &=0x7 ; + subdevs = wm5102_devs; + n_subdevs =ARRAY_SIZE (wm5102_devs);break ;#endif #ifdef CONFIG_MFD_WM5110
@@ -1155,6 +1159,8 @@ int arizona_dev_init(struct arizona *arizona) break; } apply_patch = wm5110_patch; + subdevs = wm5110_devs; + n_subdevs =ARRAY_SIZE (wm5110_devs);break ;#endif #ifdef CONFIG_MFD_WM8997
@@ -1166,6 +1172,8 @@ int arizona_dev_init(struct arizona *arizona) arizona->type = WM8997; } apply_patch = wm8997_patch; + subdevs = wm8997_devs; + n_subdevs =ARRAY_SIZE (wm8997_devs);break ;#endif #ifdef CONFIG_MFD_WM8998
@@ -1187,6 +1195,8 @@ int arizona_dev_init(struct arizona *arizona) } apply_patch = wm8998_patch; + subdevs = wm8998_devs; + n_subdevs =ARRAY_SIZE (wm8998_devs);break ;#endif default :
@@ -1379,28 +1389,10 @@ int arizona_dev_init(struct arizona *arizona)arizona_request_irq (arizona,ARIZONA_IRQ_UNDERCLOCKED ,"Underclocked" , arizona_underclocked, arizona); -switch (arizona->type) { -case WM5102 : - ret =mfd_add_devices (arizona->dev,-1 , wm5102_devs, -ARRAY_SIZE (wm5102_devs),NULL ,0 ,NULL ); -break ; -case WM5110 : -case WM8280 : - ret =mfd_add_devices (arizona->dev,-1 , wm5110_devs, -ARRAY_SIZE (wm5110_devs),NULL ,0 ,NULL ); -break ; -case WM8997 : - ret =mfd_add_devices (arizona->dev,-1 , wm8997_devs, -ARRAY_SIZE (wm8997_devs),NULL ,0 ,NULL ); -break ; -case WM8998 : -case WM1814 : - ret =mfd_add_devices (arizona->dev,-1 , wm8998_devs, -ARRAY_SIZE (wm8998_devs),NULL ,0 ,NULL ); -break ; - } + ret =mfd_add_devices (arizona->dev,PLATFORM_DEVID_NONE , + subdevs, n_subdevs,NULL ,0 ,NULL ); -if (ret !=0 ) { +if (ret) {dev_err (arizona->dev,"Failed to add subdevices: %d\n" , ret); goto err_irq; }
Signature · 1 line
1.7.2.5
Lee Jones
AppliedRe: [PATCH v2 4/6] mfd: arizona: Simplify adding subdevices
Quoted 8 lines · Charles Keepax
From: Richard Fitzgerald <[email protected]>
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.
Quoted 6 lines
Signed-off-by Richard Fitzgerald <[email protected]>Acked-by Lee Jones <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-core.c | 36 ++++++++++++++---------------------- 1 files changed, 14 insertions(+), 22 deletions(-)
Applied, thanks.
Quoted 90 lines
drivers/mfd/arizona-core.c +14
-22@@ -24,6 +24,7 @@#include <linux/regulator/consumer.h> #include <linux/regulator/machine.h> #include <linux/slab.h> +#include <linux/platform_device.h> #include <linux/mfd/arizona/core.h> #include <linux/mfd/arizona/registers.h> @@ -965,7 +966,8 @@ int arizona_dev_init(struct arizona *arizona)const char *type_name;unsigned int reg, val, mask;int (*apply_patch)(struct arizona *) =NULL ; -int ret, i; +const struct mfd_cell *subdevs =NULL ; +int n_subdevs, ret, i;dev_set_drvdata (arizona->dev, arizona);mutex_init (&arizona->clk_lock);@@ -1136,6 +1138,8 @@ int arizona_dev_init(struct arizona *arizona) } apply_patch = wm5102_patch; arizona->rev &=0x7 ; + subdevs = wm5102_devs; + n_subdevs =ARRAY_SIZE (wm5102_devs);break ;#endif #ifdef CONFIG_MFD_WM5110 @@ -1155,6 +1159,8 @@ int arizona_dev_init(struct arizona *arizona) break; } apply_patch = wm5110_patch; + subdevs = wm5110_devs; + n_subdevs =ARRAY_SIZE (wm5110_devs);break ;#endif #ifdef CONFIG_MFD_WM8997 @@ -1166,6 +1172,8 @@ int arizona_dev_init(struct arizona *arizona) arizona->type = WM8997; } apply_patch = wm8997_patch; + subdevs = wm8997_devs; + n_subdevs =ARRAY_SIZE (wm8997_devs);break ;#endif #ifdef CONFIG_MFD_WM8998 @@ -1187,6 +1195,8 @@ int arizona_dev_init(struct arizona *arizona) } apply_patch = wm8998_patch; + subdevs = wm8998_devs; + n_subdevs =ARRAY_SIZE (wm8998_devs);break ;#endif default :@@ -1379,28 +1389,10 @@ int arizona_dev_init(struct arizona *arizona)arizona_request_irq (arizona,ARIZONA_IRQ_UNDERCLOCKED ,"Underclocked" , arizona_underclocked, arizona); -switch (arizona->type) { -case WM5102 : - ret =mfd_add_devices (arizona->dev,-1 , wm5102_devs, -ARRAY_SIZE (wm5102_devs),NULL ,0 ,NULL ); -break ; -case WM5110 : -case WM8280 : - ret =mfd_add_devices (arizona->dev,-1 , wm5110_devs, -ARRAY_SIZE (wm5110_devs),NULL ,0 ,NULL ); -break ; -case WM8997 : - ret =mfd_add_devices (arizona->dev,-1 , wm8997_devs, -ARRAY_SIZE (wm8997_devs),NULL ,0 ,NULL ); -break ; -case WM8998 : -case WM1814 : - ret =mfd_add_devices (arizona->dev,-1 , wm8998_devs, -ARRAY_SIZE (wm8998_devs),NULL ,0 ,NULL ); -break ; - } + ret =mfd_add_devices (arizona->dev,PLATFORM_DEVID_NONE , + subdevs, n_subdevs,NULL ,0 ,NULL ); -if (ret !=0 ) { +if (ret) {dev_err (arizona->dev,"Failed to add subdevices: %d\n" , ret); goto err_irq; }
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v2 5/6 mfd: arizona: Remove use of codec build config #ifdefs
In reply to Charles KeepaxFrom: Richard Fitzgerald <[email protected]>
Remove the use of #ifdefs around each case statement of the chip ID and type validation switches.
We must ensure that the contained code still compiles to nothing if support for that codec was not built into the kernel, to prevent creation of link references to missing functions. So the ifdefs are replaced with a use of the IS_ENABLED() macro.
---
Changes since v1:
- Changed IS_ENABLED if statements such that they wrap all code that we want eliminated, to ensure that it does indeed get eliminated.
Thanks,
Charles
drivers/mfd/arizona-core.c | 129 ++++++++++++++++++++++++-------------------- drivers/mfd/arizona-i2c.c | 28 +++++----- drivers/mfd/arizona-spi.c | 18 ++++--- 3 files changed, 97 insertions(+), 78 deletions(-)
drivers/mfd/arizona-core.c +71 -58
@@ -1128,82 +1128,95 @@ int arizona_dev_init(struct arizona *arizona) arizona->rev &=ARIZONA_DEVICE_REVISION_MASK ;switch (reg) { -#ifdef CONFIG_MFD_WM5102 case 0x5102 : - type_name ="WM5102" ; -if (arizona->type !=WM5102 ) { -dev_warn (arizona->dev,"WM5102 registered as %d\n" , - arizona->type); - arizona->type =WM5102 ; +if (IS_ENABLED (CONFIG_MFD_WM5102 )) { + type_name ="WM5102" ; +if (arizona->type !=WM5102 ) { +dev_warn (arizona->dev, +"WM5102 registered as %d\n" , + arizona->type); + arizona->type =WM5102 ; + } + + apply_patch = wm5102_patch; + arizona->rev &=0x7 ; + subdevs = wm5102_devs; + n_subdevs =ARRAY_SIZE (wm5102_devs); } - apply_patch = wm5102_patch; - arizona->rev &=0x7 ; - subdevs = wm5102_devs; - n_subdevs =ARRAY_SIZE (wm5102_devs);break ; -#endif -#ifdef CONFIG_MFD_WM5110 case 0x5110 : -switch (arizona->type) { -case WM5110 : - type_name ="WM5110" ; -break ; -case WM8280 : - type_name ="WM8280" ; -break ; -default : - type_name ="WM5110" ; -dev_warn (arizona->dev,"WM5110 registered as %d\n" , - arizona->type); - arizona->type =WM5110 ; -break ; +if (IS_ENABLED (CONFIG_MFD_WM5110 )) { +switch (arizona->type) { +case WM5110 : + type_name ="WM5110" ; +break ; +case WM8280 : + type_name ="WM8280" ; +break ; +default : + type_name ="WM5110" ; +dev_warn (arizona->dev, +"WM5110 registered as %d\n" , + arizona->type); + arizona->type =WM5110 ; +break ; + } + + apply_patch = wm5110_patch; + subdevs = wm5110_devs; + n_subdevs =ARRAY_SIZE (wm5110_devs); } - apply_patch = wm5110_patch; - subdevs = wm5110_devs; - n_subdevs =ARRAY_SIZE (wm5110_devs);break ; -#endif -#ifdef CONFIG_MFD_WM8997 case 0x8997 : - type_name ="WM8997" ; -if (arizona->type !=WM8997 ) { -dev_warn (arizona->dev,"WM8997 registered as %d\n" , - arizona->type); - arizona->type =WM8997 ; +if (IS_ENABLED (CONFIG_MFD_WM8997 )) { + type_name ="WM8997" ; +if (arizona->type !=WM8997 ) { +dev_warn (arizona->dev, +"WM8997 registered as %d\n" , + arizona->type); + arizona->type =WM8997 ; + } + + apply_patch = wm8997_patch; + subdevs = wm8997_devs; + n_subdevs =ARRAY_SIZE (wm8997_devs); } - apply_patch = wm8997_patch; - subdevs = wm8997_devs; - n_subdevs =ARRAY_SIZE (wm8997_devs);break ; -#endif -#ifdef CONFIG_MFD_WM8998 case 0x6349 : -switch (arizona->type) { -case WM8998 : - type_name ="WM8998" ; -break ; - -case WM1814 : - type_name ="WM1814" ; -break ; +if (IS_ENABLED (CONFIG_MFD_WM8998 )) { +switch (arizona->type) { +case WM8998 : + type_name ="WM8998" ; +break ; + +case WM1814 : + type_name ="WM1814" ; +break ; + +default : + type_name ="WM8998" ; +dev_warn (arizona->dev, +"WM8998 registered as %d\n" , + arizona->type); + arizona->type =WM8998 ; + } -default : - type_name ="WM8998" ; -dev_warn (arizona->dev,"WM8998 registered as %d\n" , - arizona->type); - arizona->type =WM8998 ; + apply_patch = wm8998_patch; + subdevs = wm8998_devs; + n_subdevs =ARRAY_SIZE (wm8998_devs); } - - apply_patch = wm8998_patch; - subdevs = wm8998_devs; - n_subdevs =ARRAY_SIZE (wm8998_devs);break ; -#endif default :dev_err (arizona->dev,"Unknown device ID %x\n" , reg); goto err_reset; } +if (!subdevs) { +dev_err (arizona->dev, +"No kernel support for device ID %x\n" , reg); + goto err_reset; + } +dev_info (dev,"%s revision %c\n" , type_name, arizona->rev +'A' );if (apply_patch) {
drivers/mfd/arizona-i2c.c +15 -13
@@ -27,7 +27,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) {struct arizona *arizona; -const struct regmap_config *regmap_config; +const struct regmap_config *regmap_config =NULL ;unsigned long type;int ret;
@@ -37,34 +37,36 @@ static int arizona_i2c_probe(struct i2c_client *i2c, type = id->driver_data;switch (type) { -#ifdef CONFIG_MFD_WM5102 case WM5102 : - regmap_config = &wm5102_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5102 )) + regmap_config = &wm5102_i2c_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM5110 case WM5110 :case WM8280 : - regmap_config = &wm5110_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5110 )) + regmap_config = &wm5110_i2c_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM8997 case WM8997 : - regmap_config = &wm8997_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM8997 )) + regmap_config = &wm8997_i2c_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM8998 case WM8998 :case WM1814 : - regmap_config = &wm8998_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM8998 )) + regmap_config = &wm8998_i2c_regmap;break ; -#endif default :dev_err (&i2c->dev,"Unknown device type %ld\n" , id->driver_data);return -EINVAL ; } +if (!regmap_config) { +dev_err (&i2c->dev, +"No kernel support for device type %ld\n" , type); +return -EINVAL ; + } + arizona =devm_kzalloc (&i2c->dev,sizeof (*arizona),GFP_KERNEL );if (arizona ==NULL )return -ENOMEM ;
drivers/mfd/arizona-spi.c +11 -7
@@ -27,7 +27,7 @@ static int arizona_spi_probe(struct spi_device *spi) {const struct spi_device_id *id =spi_get_device_id (spi);struct arizona *arizona; -const struct regmap_config *regmap_config; +const struct regmap_config *regmap_config =NULL ;unsigned long type;int ret;
@@ -37,23 +37,27 @@ static int arizona_spi_probe(struct spi_device *spi) type = id->driver_data;switch (type) { -#ifdef CONFIG_MFD_WM5102 case WM5102 : - regmap_config = &wm5102_spi_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5102 )) + regmap_config = &wm5102_spi_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM5110 case WM5110 :case WM8280 : - regmap_config = &wm5110_spi_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5110 )) + regmap_config = &wm5110_spi_regmap;break ; -#endif default :dev_err (&spi->dev,"Unknown device type %ld\n" , id->driver_data);return -EINVAL ; } +if (!regmap_config) { +dev_err (&spi->dev, +"No kernel support for device type %ld\n" , type); +return -EINVAL ; + } + arizona =devm_kzalloc (&spi->dev,sizeof (*arizona),GFP_KERNEL );if (arizona ==NULL )return -ENOMEM ;
Signature · 1 line
1.7.2.5
Re: [PATCH v2 5/6] mfd: arizona: Remove use of codec build config #ifdefs
Quoted 19 lines · Charles Keepax
From: Richard Fitzgerald <[email protected]>
Remove the use of #ifdefs around each case statement of the chip ID and type validation switches.
We must ensure that the contained code still compiles to nothing if support for that codec was not built into the kernel, to prevent creation of link references to missing functions. So the ifdefs are replaced with a use of the
IS_ENABLED()macro.Signed-off-by Richard Fitzgerald <[email protected]>Signed-off-by Charles Keepax <[email protected]>---
Changes since v1:
- ChangedIS_ENABLEDif statements such that they wrap all code that we want eliminated, to ensure that it does indeed get eliminated.
Quoted 7 lines
Thanks,
Charlesdrivers/mfd/arizona-core.c | 129 ++++++++++++++++++++++++-------------------- drivers/mfd/arizona-i2c.c | 28 +++++----- drivers/mfd/arizona-spi.c | 18 ++++--- 3 files changed, 97 insertions(+), 78 deletions(-)
Quoted 267 lines
drivers/mfd/arizona-core.c +71
-58@@ -1128,82 +1128,95 @@ int arizona_dev_init(struct arizona *arizona) arizona->rev &=ARIZONA_DEVICE_REVISION_MASK ;switch (reg) { -#ifdef CONFIG_MFD_WM5102 case 0x5102 : - type_name ="WM5102" ; -if (arizona->type !=WM5102 ) { -dev_warn (arizona->dev,"WM5102 registered as %d\n" , - arizona->type); - arizona->type =WM5102 ; +if (IS_ENABLED (CONFIG_MFD_WM5102 )) { + type_name ="WM5102" ; +if (arizona->type !=WM5102 ) { +dev_warn (arizona->dev, +"WM5102 registered as %d\n" , + arizona->type); + arizona->type =WM5102 ; + } + + apply_patch = wm5102_patch; + arizona->rev &=0x7 ; + subdevs = wm5102_devs; + n_subdevs =ARRAY_SIZE (wm5102_devs); } - apply_patch = wm5102_patch; - arizona->rev &=0x7 ; - subdevs = wm5102_devs; - n_subdevs =ARRAY_SIZE (wm5102_devs);break ; -#endif -#ifdef CONFIG_MFD_WM5110 case 0x5110 : -switch (arizona->type) { -case WM5110 : - type_name ="WM5110" ; -break ; -case WM8280 : - type_name ="WM8280" ; -break ; -default : - type_name ="WM5110" ; -dev_warn (arizona->dev,"WM5110 registered as %d\n" , - arizona->type); - arizona->type =WM5110 ; -break ; +if (IS_ENABLED (CONFIG_MFD_WM5110 )) { +switch (arizona->type) { +case WM5110 : + type_name ="WM5110" ; +break ; +case WM8280 : + type_name ="WM8280" ; +break ; +default : + type_name ="WM5110" ; +dev_warn (arizona->dev, +"WM5110 registered as %d\n" , + arizona->type); + arizona->type =WM5110 ; +break ; + } + + apply_patch = wm5110_patch; + subdevs = wm5110_devs; + n_subdevs =ARRAY_SIZE (wm5110_devs); } - apply_patch = wm5110_patch; - subdevs = wm5110_devs; - n_subdevs =ARRAY_SIZE (wm5110_devs);break ; -#endif -#ifdef CONFIG_MFD_WM8997 case 0x8997 : - type_name ="WM8997" ; -if (arizona->type !=WM8997 ) { -dev_warn (arizona->dev,"WM8997 registered as %d\n" , - arizona->type); - arizona->type =WM8997 ; +if (IS_ENABLED (CONFIG_MFD_WM8997 )) { + type_name ="WM8997" ; +if (arizona->type !=WM8997 ) { +dev_warn (arizona->dev, +"WM8997 registered as %d\n" , + arizona->type); + arizona->type =WM8997 ; + } + + apply_patch = wm8997_patch; + subdevs = wm8997_devs; + n_subdevs =ARRAY_SIZE (wm8997_devs); } - apply_patch = wm8997_patch; - subdevs = wm8997_devs; - n_subdevs =ARRAY_SIZE (wm8997_devs);break ; -#endif -#ifdef CONFIG_MFD_WM8998 case 0x6349 : -switch (arizona->type) { -case WM8998 : - type_name ="WM8998" ; -break ; - -case WM1814 : - type_name ="WM1814" ; -break ; +if (IS_ENABLED (CONFIG_MFD_WM8998 )) { +switch (arizona->type) { +case WM8998 : + type_name ="WM8998" ; +break ; + +case WM1814 : + type_name ="WM1814" ; +break ; + +default : + type_name ="WM8998" ; +dev_warn (arizona->dev, +"WM8998 registered as %d\n" , + arizona->type); + arizona->type =WM8998 ; + } -default : - type_name ="WM8998" ; -dev_warn (arizona->dev,"WM8998 registered as %d\n" , - arizona->type); - arizona->type =WM8998 ; + apply_patch = wm8998_patch; + subdevs = wm8998_devs; + n_subdevs =ARRAY_SIZE (wm8998_devs); } - - apply_patch = wm8998_patch; - subdevs = wm8998_devs; - n_subdevs =ARRAY_SIZE (wm8998_devs);break ; -#endif default :dev_err (arizona->dev,"Unknown device ID %x\n" , reg); goto err_reset; } +if (!subdevs) { +dev_err (arizona->dev, +"No kernel support for device ID %x\n" , reg); + goto err_reset; + } +dev_info (dev,"%s revision %c\n" , type_name, arizona->rev +'A' );if (apply_patch) {drivers/mfd/arizona-i2c.c +15
-13@@ -27,7 +27,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) {struct arizona *arizona; -const struct regmap_config *regmap_config; +const struct regmap_config *regmap_config =NULL ;unsigned long type;int ret;@@ -37,34 +37,36 @@ static int arizona_i2c_probe(struct i2c_client *i2c, type = id->driver_data;switch (type) { -#ifdef CONFIG_MFD_WM5102 case WM5102 : - regmap_config = &wm5102_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5102 )) + regmap_config = &wm5102_i2c_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM5110 case WM5110 :case WM8280 : - regmap_config = &wm5110_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5110 )) + regmap_config = &wm5110_i2c_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM8997 case WM8997 : - regmap_config = &wm8997_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM8997 )) + regmap_config = &wm8997_i2c_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM8998 case WM8998 :case WM1814 : - regmap_config = &wm8998_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM8998 )) + regmap_config = &wm8998_i2c_regmap;break ; -#endif default :dev_err (&i2c->dev,"Unknown device type %ld\n" , id->driver_data);return -EINVAL ; } +if (!regmap_config) { +dev_err (&i2c->dev, +"No kernel support for device type %ld\n" , type); +return -EINVAL ; + } + arizona =devm_kzalloc (&i2c->dev,sizeof (*arizona),GFP_KERNEL );if (arizona ==NULL )return -ENOMEM ;drivers/mfd/arizona-spi.c +11
-7@@ -27,7 +27,7 @@ static int arizona_spi_probe(struct spi_device *spi) {const struct spi_device_id *id =spi_get_device_id (spi);struct arizona *arizona; -const struct regmap_config *regmap_config; +const struct regmap_config *regmap_config =NULL ;unsigned long type;int ret;@@ -37,23 +37,27 @@ static int arizona_spi_probe(struct spi_device *spi) type = id->driver_data;switch (type) { -#ifdef CONFIG_MFD_WM5102 case WM5102 : - regmap_config = &wm5102_spi_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5102 )) + regmap_config = &wm5102_spi_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM5110 case WM5110 :case WM8280 : - regmap_config = &wm5110_spi_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5110 )) + regmap_config = &wm5110_spi_regmap;break ; -#endif default :dev_err (&spi->dev,"Unknown device type %ld\n" , id->driver_data);return -EINVAL ; } +if (!regmap_config) { +dev_err (&spi->dev, +"No kernel support for device type %ld\n" , type); +return -EINVAL ; + } + arizona =devm_kzalloc (&spi->dev,sizeof (*arizona),GFP_KERNEL );if (arizona ==NULL )return -ENOMEM ;
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Lee Jones
AppliedRe: [PATCH v2 5/6] mfd: arizona: Remove use of codec build config #ifdefs
In reply to Charles KeepaxQuoted 19 lines · Charles Keepax
From: Richard Fitzgerald <[email protected]>
Remove the use of #ifdefs around each case statement of the chip ID and type validation switches.
We must ensure that the contained code still compiles to nothing if support for that codec was not built into the kernel, to prevent creation of link references to missing functions. So the ifdefs are replaced with a use of the
IS_ENABLED()macro.Signed-off-by Richard Fitzgerald <[email protected]>Signed-off-by Charles Keepax <[email protected]>---
Changes since v1:
- ChangedIS_ENABLEDif statements such that they wrap all code that we want eliminated, to ensure that it does indeed get eliminated.
Quoted 7 lines
Thanks,
Charlesdrivers/mfd/arizona-core.c | 129 ++++++++++++++++++++++++-------------------- drivers/mfd/arizona-i2c.c | 28 +++++----- drivers/mfd/arizona-spi.c | 18 ++++--- 3 files changed, 97 insertions(+), 78 deletions(-)
Applied, thanks.
Quoted 267 lines
drivers/mfd/arizona-core.c +71
-58@@ -1128,82 +1128,95 @@ int arizona_dev_init(struct arizona *arizona) arizona->rev &=ARIZONA_DEVICE_REVISION_MASK ;switch (reg) { -#ifdef CONFIG_MFD_WM5102 case 0x5102 : - type_name ="WM5102" ; -if (arizona->type !=WM5102 ) { -dev_warn (arizona->dev,"WM5102 registered as %d\n" , - arizona->type); - arizona->type =WM5102 ; +if (IS_ENABLED (CONFIG_MFD_WM5102 )) { + type_name ="WM5102" ; +if (arizona->type !=WM5102 ) { +dev_warn (arizona->dev, +"WM5102 registered as %d\n" , + arizona->type); + arizona->type =WM5102 ; + } + + apply_patch = wm5102_patch; + arizona->rev &=0x7 ; + subdevs = wm5102_devs; + n_subdevs =ARRAY_SIZE (wm5102_devs); } - apply_patch = wm5102_patch; - arizona->rev &=0x7 ; - subdevs = wm5102_devs; - n_subdevs =ARRAY_SIZE (wm5102_devs);break ; -#endif -#ifdef CONFIG_MFD_WM5110 case 0x5110 : -switch (arizona->type) { -case WM5110 : - type_name ="WM5110" ; -break ; -case WM8280 : - type_name ="WM8280" ; -break ; -default : - type_name ="WM5110" ; -dev_warn (arizona->dev,"WM5110 registered as %d\n" , - arizona->type); - arizona->type =WM5110 ; -break ; +if (IS_ENABLED (CONFIG_MFD_WM5110 )) { +switch (arizona->type) { +case WM5110 : + type_name ="WM5110" ; +break ; +case WM8280 : + type_name ="WM8280" ; +break ; +default : + type_name ="WM5110" ; +dev_warn (arizona->dev, +"WM5110 registered as %d\n" , + arizona->type); + arizona->type =WM5110 ; +break ; + } + + apply_patch = wm5110_patch; + subdevs = wm5110_devs; + n_subdevs =ARRAY_SIZE (wm5110_devs); } - apply_patch = wm5110_patch; - subdevs = wm5110_devs; - n_subdevs =ARRAY_SIZE (wm5110_devs);break ; -#endif -#ifdef CONFIG_MFD_WM8997 case 0x8997 : - type_name ="WM8997" ; -if (arizona->type !=WM8997 ) { -dev_warn (arizona->dev,"WM8997 registered as %d\n" , - arizona->type); - arizona->type =WM8997 ; +if (IS_ENABLED (CONFIG_MFD_WM8997 )) { + type_name ="WM8997" ; +if (arizona->type !=WM8997 ) { +dev_warn (arizona->dev, +"WM8997 registered as %d\n" , + arizona->type); + arizona->type =WM8997 ; + } + + apply_patch = wm8997_patch; + subdevs = wm8997_devs; + n_subdevs =ARRAY_SIZE (wm8997_devs); } - apply_patch = wm8997_patch; - subdevs = wm8997_devs; - n_subdevs =ARRAY_SIZE (wm8997_devs);break ; -#endif -#ifdef CONFIG_MFD_WM8998 case 0x6349 : -switch (arizona->type) { -case WM8998 : - type_name ="WM8998" ; -break ; - -case WM1814 : - type_name ="WM1814" ; -break ; +if (IS_ENABLED (CONFIG_MFD_WM8998 )) { +switch (arizona->type) { +case WM8998 : + type_name ="WM8998" ; +break ; + +case WM1814 : + type_name ="WM1814" ; +break ; + +default : + type_name ="WM8998" ; +dev_warn (arizona->dev, +"WM8998 registered as %d\n" , + arizona->type); + arizona->type =WM8998 ; + } -default : - type_name ="WM8998" ; -dev_warn (arizona->dev,"WM8998 registered as %d\n" , - arizona->type); - arizona->type =WM8998 ; + apply_patch = wm8998_patch; + subdevs = wm8998_devs; + n_subdevs =ARRAY_SIZE (wm8998_devs); } - - apply_patch = wm8998_patch; - subdevs = wm8998_devs; - n_subdevs =ARRAY_SIZE (wm8998_devs);break ; -#endif default :dev_err (arizona->dev,"Unknown device ID %x\n" , reg); goto err_reset; } +if (!subdevs) { +dev_err (arizona->dev, +"No kernel support for device ID %x\n" , reg); + goto err_reset; + } +dev_info (dev,"%s revision %c\n" , type_name, arizona->rev +'A' );if (apply_patch) {drivers/mfd/arizona-i2c.c +15
-13@@ -27,7 +27,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) {struct arizona *arizona; -const struct regmap_config *regmap_config; +const struct regmap_config *regmap_config =NULL ;unsigned long type;int ret;@@ -37,34 +37,36 @@ static int arizona_i2c_probe(struct i2c_client *i2c, type = id->driver_data;switch (type) { -#ifdef CONFIG_MFD_WM5102 case WM5102 : - regmap_config = &wm5102_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5102 )) + regmap_config = &wm5102_i2c_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM5110 case WM5110 :case WM8280 : - regmap_config = &wm5110_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5110 )) + regmap_config = &wm5110_i2c_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM8997 case WM8997 : - regmap_config = &wm8997_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM8997 )) + regmap_config = &wm8997_i2c_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM8998 case WM8998 :case WM1814 : - regmap_config = &wm8998_i2c_regmap; +if (IS_ENABLED (CONFIG_MFD_WM8998 )) + regmap_config = &wm8998_i2c_regmap;break ; -#endif default :dev_err (&i2c->dev,"Unknown device type %ld\n" , id->driver_data);return -EINVAL ; } +if (!regmap_config) { +dev_err (&i2c->dev, +"No kernel support for device type %ld\n" , type); +return -EINVAL ; + } + arizona =devm_kzalloc (&i2c->dev,sizeof (*arizona),GFP_KERNEL );if (arizona ==NULL )return -ENOMEM ;drivers/mfd/arizona-spi.c +11
-7@@ -27,7 +27,7 @@ static int arizona_spi_probe(struct spi_device *spi) {const struct spi_device_id *id =spi_get_device_id (spi);struct arizona *arizona; -const struct regmap_config *regmap_config; +const struct regmap_config *regmap_config =NULL ;unsigned long type;int ret;@@ -37,23 +37,27 @@ static int arizona_spi_probe(struct spi_device *spi) type = id->driver_data;switch (type) { -#ifdef CONFIG_MFD_WM5102 case WM5102 : - regmap_config = &wm5102_spi_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5102 )) + regmap_config = &wm5102_spi_regmap;break ; -#endif -#ifdef CONFIG_MFD_WM5110 case WM5110 :case WM8280 : - regmap_config = &wm5110_spi_regmap; +if (IS_ENABLED (CONFIG_MFD_WM5110 )) + regmap_config = &wm5110_spi_regmap;break ; -#endif default :dev_err (&spi->dev,"Unknown device type %ld\n" , id->driver_data);return -EINVAL ; } +if (!regmap_config) { +dev_err (&spi->dev, +"No kernel support for device type %ld\n" , type); +return -EINVAL ; + } + arizona =devm_kzalloc (&spi->dev,sizeof (*arizona),GFP_KERNEL );if (arizona ==NULL )return -ENOMEM ;
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v2 6/6 mfd: arizona: use correct type ID for device tree config
In reply to Charles KeepaxFrom: Richard Fitzgerald <[email protected]>
In the case of a device tree config the code uses the device ID from the DT entry to check which codec is required but when storing the ID into struct arizona it was always using the non-DT SPI device table to get an ID.
This patch changes the code to store the correct ID into struct arizona.
--- drivers/mfd/arizona-i2c.c | 5 ++--- drivers/mfd/arizona-spi.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/mfd/arizona-i2c.c +2 -3
@@ -56,8 +56,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c, regmap_config = &wm8998_i2c_regmap;break ;default : -dev_err (&i2c->dev,"Unknown device type %ld\n" , - id->driver_data); +dev_err (&i2c->dev,"Unknown device type %ld\n" , type);return -EINVAL ; }
@@ -79,7 +78,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,return ret; } - arizona->type = id->driver_data; + arizona->type = type; arizona->dev = &i2c->dev; arizona->irq = i2c->irq;
drivers/mfd/arizona-spi.c +2 -3
@@ -47,8 +47,7 @@ static int arizona_spi_probe(struct spi_device *spi) regmap_config = &wm5110_spi_regmap;break ;default : -dev_err (&spi->dev,"Unknown device type %ld\n" , - id->driver_data); +dev_err (&spi->dev,"Unknown device type %ld\n" , type);return -EINVAL ; }
@@ -70,7 +69,7 @@ static int arizona_spi_probe(struct spi_device *spi)return ret; } - arizona->type = id->driver_data; + arizona->type = type; arizona->dev = &spi->dev; arizona->irq = spi->irq;
Signature · 1 line
1.7.2.5
Lee Jones
AppliedRe: [PATCH v2 6/6] mfd: arizona: use correct type ID for device tree config
Quoted 9 lines · Charles Keepax
From: Richard Fitzgerald <[email protected]>
In the case of a device tree config the code uses the device ID from the DT entry to check which codec is required but when storing the ID into struct arizona it was always using the non-DT SPI device table to get an ID.
This patch changes the code to store the correct ID into struct arizona.
Quoted 7 lines
Signed-off-by Richard Fitzgerald <[email protected]>Acked-by Lee Jones <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-i2c.c | 5 ++--- drivers/mfd/arizona-spi.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)
Applied, thanks.
Quoted 46 lines
drivers/mfd/arizona-i2c.c +2
-3@@ -56,8 +56,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c, regmap_config = &wm8998_i2c_regmap;break ;default : -dev_err (&i2c->dev,"Unknown device type %ld\n" , - id->driver_data); +dev_err (&i2c->dev,"Unknown device type %ld\n" , type);return -EINVAL ; }@@ -79,7 +78,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,return ret; } - arizona->type = id->driver_data; + arizona->type = type; arizona->dev = &i2c->dev; arizona->irq = i2c->irq;drivers/mfd/arizona-spi.c +2
-3@@ -47,8 +47,7 @@ static int arizona_spi_probe(struct spi_device *spi) regmap_config = &wm5110_spi_regmap;break ;default : -dev_err (&spi->dev,"Unknown device type %ld\n" , - id->driver_data); +dev_err (&spi->dev,"Unknown device type %ld\n" , type);return -EINVAL ; }@@ -70,7 +69,7 @@ static int arizona_spi_probe(struct spi_device *spi)return ret; } - arizona->type = id->driver_data; + arizona->type = type; arizona->dev = &spi->dev; arizona->irq = spi->irq;
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Lee Jones
AppliedQuoted 8 lines · Charles Keepax
From: Richard Fitzgerald <[email protected]>
Currently DCVDD isolation is enabled and disabled for
runtime_suspendandruntime_resume. Future codecs will not have the isolation control so to prepare for these codecs this patch factors out the isolation control allowing it to be called as needed in the existing codec-specific switch cases.
Quoted 6 lines
Signed-off-by Richard Fitzgerald <[email protected]>Acked-by Lee Jones <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-core.c | 108 +++++++++++++++++++++++++------------------- 1 files changed, 62 insertions(+), 46 deletions(-)
Applied, thanks.
Quoted 163 lines
drivers/mfd/arizona-core.c +62
-46@@ -460,6 +460,33 @@ static int wm5102_clear_write_sequencer(struct arizona *arizona) }#ifdef CONFIG_PM +static int arizona_isolate_dcvdd (struct arizona *arizona) +{ +int ret; + + ret =regmap_update_bits (arizona->regmap, +ARIZONA_ISOLATION_CONTROL , +ARIZONA_ISOLATE_DCVDD1 , +ARIZONA_ISOLATE_DCVDD1 ); +if (ret !=0 ) +dev_err (arizona->dev,"Failed to isolate DCVDD: %d\n" , ret); + +return ret; +} + +static int arizona_connect_dcvdd (struct arizona *arizona) +{ +int ret; + + ret =regmap_update_bits (arizona->regmap, +ARIZONA_ISOLATION_CONTROL , +ARIZONA_ISOLATE_DCVDD1 ,0 ); +if (ret !=0 ) +dev_err (arizona->dev,"Failed to connect DCVDD: %d\n" , ret); + +return ret; +} +static int arizona_runtime_resume (struct device *dev) {struct arizona *arizona =dev_get_drvdata (dev);@@ -499,14 +526,9 @@ static int arizona_runtime_resume(struct device *dev)switch (arizona->type) {case WM5102 :if (arizona->external_dcvdd) { - ret =regmap_update_bits (arizona->regmap, -ARIZONA_ISOLATION_CONTROL , -ARIZONA_ISOLATE_DCVDD1 ,0 ); -if (ret !=0 ) { -dev_err (arizona->dev, -"Failed to connect DCVDD: %d\n" , ret); + ret =arizona_connect_dcvdd (arizona); +if (ret !=0 ) goto err; - } } ret =wm5102_patch (arizona);@@ -531,14 +553,9 @@ static int arizona_runtime_resume(struct device *dev) goto err;if (arizona->external_dcvdd) { - ret =regmap_update_bits (arizona->regmap, -ARIZONA_ISOLATION_CONTROL , -ARIZONA_ISOLATE_DCVDD1 ,0 ); -if (ret) { -dev_err (arizona->dev, -"Failed to connect DCVDD: %d\n" , ret); + ret =arizona_connect_dcvdd (arizona); +if (ret !=0 ) goto err; - } }else {/* * As this is only called for the internal regulator @@ -569,14 +586,9 @@ static int arizona_runtime_resume(struct device *dev) goto err;if (arizona->external_dcvdd) { - ret =regmap_update_bits (arizona->regmap, -ARIZONA_ISOLATION_CONTROL , -ARIZONA_ISOLATE_DCVDD1 ,0 ); -if (ret !=0 ) { -dev_err (arizona->dev, -"Failed to connect DCVDD: %d\n" , ret); + ret =arizona_connect_dcvdd (arizona); +if (ret !=0 ) goto err; - } }break ; }@@ -609,37 +621,36 @@ static int arizona_runtime_suspend(struct device *dev)return ret; } -if (arizona->external_dcvdd) { - ret =regmap_update_bits (arizona->regmap, -ARIZONA_ISOLATION_CONTROL , -ARIZONA_ISOLATE_DCVDD1 , -ARIZONA_ISOLATE_DCVDD1 ); -if (ret !=0 ) { -dev_err (arizona->dev,"Failed to isolate DCVDD: %d\n" , - ret); -return ret; - } - } -switch (arizona->type) {case WM5110 :case WM8280 : -if (arizona->external_dcvdd) -break ; - -/* -* As this is only called for the internal regulator -* (where we know voltage ranges available) it is ok -* to request an exact range. -*/ - ret =regulator_set_voltage (arizona->dcvdd,1175000 ,1175000 ); -if (ret <0 ) { -dev_err (arizona->dev, -"Failed to set suspend voltage: %d\n" , ret); -return ret; +if (arizona->external_dcvdd) { + ret =arizona_isolate_dcvdd (arizona); +if (ret !=0 ) +return ret; + }else { +/* +* As this is only called for the internal regulator +* (where we know voltage ranges available) it is ok +* to request an exact range. +*/ + ret =regulator_set_voltage (arizona->dcvdd, +1175000 ,1175000 ); +if (ret <0 ) { +dev_err (arizona->dev, +"Failed to set suspend voltage: %d\n" , + ret); +return ret; + } }break ;case WM5102 : +if (arizona->external_dcvdd) { + ret =arizona_isolate_dcvdd (arizona); +if (ret !=0 ) +return ret; + } +if (!(val &ARIZONA_JD1_ENA )) { ret =regmap_write (arizona->regmap,ARIZONA_WRITE_SEQUENCER_CTRL_3 ,0x0 );@@ -652,6 +663,11 @@ static int arizona_runtime_suspend(struct device *dev) }break ;default : +if (arizona->external_dcvdd) { + ret =arizona_isolate_dcvdd (arizona); +if (ret !=0 ) +return ret; + }break ; }
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog