aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorJonas Bonn <jonas.bonn@gmail.com>2008-11-19 17:11:01 +0000
committerAndy Green <agreen@pads.home.warmcat.com>2008-11-19 17:11:01 +0000
commitbc36163fe957c334c87b3c8ad0816ee9417531d2 (patch)
treef90d2c64d20a9570efb7ddd839b8af8a9616e7d6 /arch
parent2105065cd9220517b7c64a598730c1a53bcce098 (diff)
Config: Ifdef cleanups
This patch removes a large number of #ifdefs that switch on machine model. Where applicable, the machine_is_* idiom is favoured; this mainly makes the code easier to read, but it does have some other advantages, too. Signed-off-by: Jonas Bonn <jonas.bonn@gmail.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/plat-s3c24xx/neo1973_memconfig.c7
-rw-r--r--arch/arm/plat-s3c24xx/neo1973_pm_bt.c97
-rw-r--r--arch/arm/plat-s3c24xx/neo1973_pm_gps.c34
-rw-r--r--arch/arm/plat-s3c24xx/neo1973_pm_gsm.c65
4 files changed, 51 insertions, 152 deletions
diff --git a/arch/arm/plat-s3c24xx/neo1973_memconfig.c b/arch/arm/plat-s3c24xx/neo1973_memconfig.c
index 99e11333c17..6f623f179f3 100644
--- a/arch/arm/plat-s3c24xx/neo1973_memconfig.c
+++ b/arch/arm/plat-s3c24xx/neo1973_memconfig.c
@@ -140,13 +140,8 @@ static int __init neo1973_memconfig_probe(struct platform_device *pdev)
{
dev_info(&pdev->dev, "starting\n");
- switch (machine_arch_type) {
-#ifdef CONFIG_MACH_NEO1973_GTA01
- case MACH_TYPE_NEO1973_GTA01:
+ if (machine_is_neo1973_gta01()) {
return -EINVAL;
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
- default:
- break;
}
return sysfs_create_group(&pdev->dev.kobj,
diff --git a/arch/arm/plat-s3c24xx/neo1973_pm_bt.c b/arch/arm/plat-s3c24xx/neo1973_pm_bt.c
index 3d4021cd794..ce8d420398a 100644
--- a/arch/arm/plat-s3c24xx/neo1973_pm_bt.c
+++ b/arch/arm/plat-s3c24xx/neo1973_pm_bt.c
@@ -20,15 +20,13 @@
#include <asm/mach-types.h>
#include <asm/plat-s3c24xx/neo1973.h>
-#ifdef CONFIG_MACH_NEO1973_GTA01
+/* For GTA01 */
#include <asm/arch/gta01.h>
#include <linux/pcf50606.h>
-#endif
-#ifdef CONFIG_MACH_NEO1973_GTA02
+/* For GTA02 */
#include <asm/arch/gta02.h>
#include <linux/pcf50633.h>
-#endif
#define DRVMSG "FIC Neo1973 Bluetooth Power Management"
@@ -36,65 +34,45 @@
static ssize_t bt_read(struct device *dev, struct device_attribute *attr,
char *buf)
{
+ int ret = 0;
+
if (!strcmp(attr->attr.name, "power_on")) {
- switch (machine_arch_type) {
-#ifdef CONFIG_MACH_NEO1973_GTA01
- case MACH_TYPE_NEO1973_GTA01:
+ if (machine_is_neo1973_gta01()) {
if (pcf50606_onoff_get(pcf50606_global,
PCF50606_REGULATOR_D1REG) &&
pcf50606_voltage_get(pcf50606_global,
PCF50606_REGULATOR_D1REG) == 3100)
- goto out_1;
- break;
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-
-#ifdef CONFIG_MACH_NEO1973_GTA02
- case MACH_TYPE_NEO1973_GTA02:
+ ret = 1;
+ } else if (machine_is_neo1973_gta02()) {
if (s3c2410_gpio_getpin(GTA02_GPIO_BT_EN))
- goto out_1;
- break;
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
-
+ ret = 1;
}
} else if (!strcmp(attr->attr.name, "reset")) {
- switch (machine_arch_type) {
-
-#ifdef CONFIG_MACH_NEO1973_GTA01
- case MACH_TYPE_NEO1973_GTA01:
+ if (machine_is_neo1973_gta01()) {
if (s3c2410_gpio_getpin(GTA01_GPIO_BT_EN) == 0)
- goto out_1;
- break;
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-
-#ifdef CONFIG_MACH_NEO1973_GTA02
- case MACH_TYPE_NEO1973_GTA02:
+ ret = 1;
+ } else if (machine_is_neo1973_gta02()) {
if (s3c2410_gpio_getpin(GTA02_GPIO_BT_EN) == 0)
- goto out_1;
- break;
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
-
+ ret = 1;
}
}
- return strlcpy(buf, "0\n", 3);
-out_1:
- return strlcpy(buf, "1\n", 3);
+ if (!ret) {
+ return strlcpy(buf, "0\n", 3);
+ } else {
+ return strlcpy(buf, "1\n", 3);
+ }
}
static ssize_t bt_write(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
unsigned long on = simple_strtoul(buf, NULL, 10);
-#ifdef CONFIG_MACH_NEO1973_GTA02
unsigned int vol;
-#endif
if (!strcmp(attr->attr.name, "power_on")) {
- switch (machine_arch_type) {
-
-#ifdef CONFIG_MACH_NEO1973_GTA01
- case MACH_TYPE_NEO1973_GTA01:
+ if (machine_is_neo1973_gta01()) {
/* if we are powering up, assert reset, then power,
* then release reset */
if (on) {
@@ -106,13 +84,9 @@ static ssize_t bt_write(struct device *dev, struct device_attribute *attr,
pcf50606_onoff_set(pcf50606_global,
PCF50606_REGULATOR_D1REG, on);
neo1973_gpb_setpin(GTA01_GPIO_BT_EN, on);
- break;
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-
-#ifdef CONFIG_MACH_NEO1973_GTA02
- case MACH_TYPE_NEO1973_GTA02:
+ } else if (machine_is_neo1973_gta02()) {
if (s3c2410_gpio_getpin(GTA02_GPIO_BT_EN) == on)
- break;
+ return count;
neo1973_gpb_setpin(GTA02_GPIO_BT_EN, !on);
pcf50633_voltage_set(pcf50633_global,
PCF50633_REGULATOR_LDO4, on ? 3200 : 0);
@@ -122,26 +96,13 @@ static ssize_t bt_write(struct device *dev, struct device_attribute *attr,
PCF50633_REGULATOR_LDO4);
dev_info(dev, "GTA02 Set PCF50633 LDO4 = %d\n", vol);
neo1973_gpb_setpin(GTA02_GPIO_BT_EN, on);
- break;
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
-
}
} else if (!strcmp(attr->attr.name, "reset")) {
/* reset is low-active, so we need to invert */
- switch (machine_arch_type) {
-
-#ifdef CONFIG_MACH_NEO1973_GTA01
- case MACH_TYPE_NEO1973_GTA01:
+ if (machine_is_neo1973_gta01()) {
neo1973_gpb_setpin(GTA01_GPIO_BT_EN, on ? 0 : 1);
- break;
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-
-#ifdef CONFIG_MACH_NEO1973_GTA02
- case MACH_TYPE_NEO1973_GTA02:
+ } else if (machine_is_neo1973_gta02()) {
neo1973_gpb_setpin(GTA02_GPIO_BT_EN, on ? 0 : 1);
- break;
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
-
}
}
@@ -188,30 +149,20 @@ static int __init gta01_bt_probe(struct platform_device *pdev)
{
dev_info(&pdev->dev, DRVMSG ": starting\n");
- switch (machine_arch_type) {
-
-#ifdef CONFIG_MACH_NEO1973_GTA01
- case MACH_TYPE_NEO1973_GTA01:
+ if (machine_is_neo1973_gta01()) {
/* we make sure that the voltage is off */
pcf50606_onoff_set(pcf50606_global,
PCF50606_REGULATOR_D1REG, 0);
/* we pull reset to low to make sure that the chip doesn't
* drain power through the reset line */
neo1973_gpb_setpin(GTA01_GPIO_BT_EN, 0);
- break;
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-
-#ifdef CONFIG_MACH_NEO1973_GTA02
- case MACH_TYPE_NEO1973_GTA02:
+ } else if (machine_is_neo1973_gta02()) {
/* we make sure that the voltage is off */
pcf50633_onoff_set(pcf50633_global,
PCF50633_REGULATOR_LDO4, 0);
/* we pull reset to low to make sure that the chip doesn't
* drain power through the reset line */
neo1973_gpb_setpin(GTA02_GPIO_BT_EN, 0);
- break;
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
-
}
return sysfs_create_group(&pdev->dev.kobj, &gta01_bt_attr_group);
diff --git a/arch/arm/plat-s3c24xx/neo1973_pm_gps.c b/arch/arm/plat-s3c24xx/neo1973_pm_gps.c
index 3c307c7626a..f8dd2ef4194 100644
--- a/arch/arm/plat-s3c24xx/neo1973_pm_gps.c
+++ b/arch/arm/plat-s3c24xx/neo1973_pm_gps.c
@@ -23,15 +23,13 @@
#include <asm/plat-s3c24xx/neo1973.h>
-#ifdef CONFIG_MACH_NEO1973_GTA01
+/* For GTA01 */
#include <asm/arch/gta01.h>
#include <linux/pcf50606.h>
-#endif
-#ifdef CONFIG_MACH_NEO1973_GTA02
+/* For GTA02 */
#include <asm/arch/gta02.h>
#include <linux/pcf50633.h>
-#endif
struct neo1973_pm_gps_data {
int power_was_on;
@@ -277,12 +275,9 @@ static void gps_pwron_set(int on)
neo1973_gps.power_was_on = !!on;
-#ifdef CONFIG_MACH_NEO1973_GTA01
if (machine_is_neo1973_gta01())
neo1973_gpb_setpin(GTA01_GPIO_GPS_PWRON, on);
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-#ifdef CONFIG_MACH_NEO1973_GTA02
if (machine_is_neo1973_gta02()) {
if (on) {
pcf50633_voltage_set(pcf50633_global,
@@ -304,21 +299,16 @@ static void gps_pwron_set(int on)
pcf50633_onoff_set(pcf50633_global,
PCF50633_REGULATOR_LDO5, on);
}
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
}
static int gps_pwron_get(void)
{
-#ifdef CONFIG_MACH_NEO1973_GTA01
if (machine_is_neo1973_gta01())
return !!s3c2410_gpio_getpin(GTA01_GPIO_GPS_PWRON);
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-#ifdef CONFIG_MACH_NEO1973_GTA02
if (machine_is_neo1973_gta02())
return !!pcf50633_onoff_get(pcf50633_global,
PCF50633_REGULATOR_LDO5);
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
return -1;
}
@@ -517,34 +507,26 @@ static DEVICE_ATTR(power_sequence, 0644, power_sequence_read,
static int gta01_pm_gps_suspend(struct platform_device *pdev,
pm_message_t state)
{
-#ifdef CONFIG_MACH_NEO1973_GTA01
if (machine_is_neo1973_gta01()) {
/* FIXME */
gps_power_sequence_down();
}
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-#ifdef CONFIG_MACH_NEO1973_GTA02
if (machine_is_neo1973_gta02())
gps_pwron_set(0);
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
return 0;
}
static int gta01_pm_gps_resume(struct platform_device *pdev)
{
-#ifdef CONFIG_MACH_NEO1973_GTA01
if (machine_is_neo1973_gta01())
if (neo1973_gps.power_was_on)
gps_power_sequence_up();
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-#ifdef CONFIG_MACH_NEO1973_GTA02
if (machine_is_neo1973_gta02())
if (neo1973_gps.power_was_on)
gps_pwron_set(1);
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
return 0;
}
@@ -556,7 +538,6 @@ static int gta01_pm_gps_resume(struct platform_device *pdev)
static DEVICE_ATTR(pwron, 0644, power_gps_read, power_gps_write);
-#ifdef CONFIG_MACH_NEO1973_GTA01
static struct attribute *gta01_gps_sysfs_entries[] = {
&dev_attr_power_avdd_3v.attr,
&dev_attr_pwron.attr,
@@ -573,9 +554,7 @@ static struct attribute_group gta01_gps_attr_group = {
.name = NULL,
.attrs = gta01_gps_sysfs_entries,
};
-#endif
-#ifdef CONFIG_MACH_NEO1973_GTA02
static struct attribute *gta02_gps_sysfs_entries[] = {
&dev_attr_pwron.attr,
NULL
@@ -585,11 +564,9 @@ static struct attribute_group gta02_gps_attr_group = {
.name = NULL,
.attrs = gta02_gps_sysfs_entries,
};
-#endif
static int __init gta01_pm_gps_probe(struct platform_device *pdev)
{
-#ifdef CONFIG_MACH_NEO1973_GTA01
if (machine_is_neo1973_gta01()) {
s3c2410_gpio_cfgpin(GTA01_GPIO_GPS_PWRON, S3C2410_GPIO_OUTPUT);
@@ -636,9 +613,7 @@ static int __init gta01_pm_gps_probe(struct platform_device *pdev)
return sysfs_create_group(&pdev->dev.kobj, &gta01_gps_attr_group);
}
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-#ifdef CONFIG_MACH_NEO1973_GTA02
if (machine_is_neo1973_gta02()) {
switch (system_rev) {
case GTA02v2_SYSTEM_REV:
@@ -662,25 +637,20 @@ static int __init gta01_pm_gps_probe(struct platform_device *pdev)
}
return sysfs_create_group(&pdev->dev.kobj, &gta02_gps_attr_group);
}
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
return -1;
}
static int gta01_pm_gps_remove(struct platform_device *pdev)
{
-#ifdef CONFIG_MACH_NEO1973_GTA01
if (machine_is_neo1973_gta01()) {
gps_power_sequence_down();
sysfs_remove_group(&pdev->dev.kobj, &gta01_gps_attr_group);
}
-#endif /* CONFIG_MACH_NEO1973_GTA01 */
-#ifdef CONFIG_MACH_NEO1973_GTA02
if (machine_is_neo1973_gta02()) {
pcf50633_onoff_set(pcf50633_global, PCF50633_REGULATOR_LDO5, 0);
sysfs_remove_group(&pdev->dev.kobj, &gta02_gps_attr_group);
}
-#endif /* CONFIG_MACH_NEO1973_GTA02 */
return 0;
}
diff --git a/arch/arm/plat-s3c24xx/neo1973_pm_gsm.c b/arch/arm/plat-s3c24xx/neo1973_pm_gsm.c
index 5d721f38dd3..4669d9d16fe 100644
--- a/arch/arm/plat-s3c24xx/neo1973_pm_gsm.c
+++ b/arch/arm/plat-s3c24xx/neo1973_pm_gsm.c
@@ -27,12 +27,11 @@
#include <mach/hardware.h>
-#ifdef CONFIG_MACH_NEO1973_GTA02
+/* For GTA02 */
#include <asm/arch/gta02.h>
#include <linux/pcf50633.h>
#include <mach/regs-gpio.h>
#include <mach/regs-gpioj.h>
-#endif
int gta_gsm_interrupts;
EXPORT_SYMBOL(gta_gsm_interrupts);
@@ -73,19 +72,15 @@ static ssize_t gsm_read(struct device *dev, struct device_attribute *attr,
} else if (!strcmp(attr->attr.name, "reset")) {
if (machine_is_neo1973_gta01() && s3c2410_gpio_getpin(GTA01_GPIO_MODEM_RST))
goto out_1;
-#ifdef CONFIG_MACH_NEO1973_GTA02
else if (machine_is_neo1973_gta02() && s3c2410_gpio_getpin(GTA02_GPIO_MODEM_RST))
goto out_1;
-#endif
} else if (!strcmp(attr->attr.name, "download")) {
if (machine_is_neo1973_gta01()) {
if (s3c2410_gpio_getpin(GTA01_GPIO_MODEM_DNLOAD))
goto out_1;
-#ifdef CONFIG_MACH_NEO1973_GTA02
} else if (machine_is_neo1973_gta02()) {
if (!s3c2410_gpio_getpin(GTA02_GPIO_nDL_GSM))
goto out_1;
-#endif
}
} else if (!strcmp(attr->attr.name, "flowcontrolled")) {
if (s3c2410_gpio_getcfg(S3C2410_GPH1) == S3C2410_GPIO_OUTPUT)
@@ -115,34 +110,34 @@ static ssize_t gsm_write(struct device *dev, struct device_attribute *attr,
if (gta01_gsm.gpio_ngsm_en)
s3c2410_gpio_setpin(gta01_gsm.gpio_ngsm_en, 0);
- switch (system_rev) {
-#ifdef CONFIG_MACH_NEO1973_GTA02
- case GTA02v2_SYSTEM_REV:
- case GTA02v3_SYSTEM_REV:
- case GTA02v4_SYSTEM_REV:
- case GTA02v5_SYSTEM_REV:
- case GTA02v6_SYSTEM_REV:
- pcf50633_gpio_set(pcf50633_global,
- PCF50633_GPIO2, 1);
- break;
-#endif
+ if (machine_is_neo1973_gta02()) {
+ switch (system_rev) {
+ case GTA02v2_SYSTEM_REV:
+ case GTA02v3_SYSTEM_REV:
+ case GTA02v4_SYSTEM_REV:
+ case GTA02v5_SYSTEM_REV:
+ case GTA02v6_SYSTEM_REV:
+ pcf50633_gpio_set(pcf50633_global,
+ PCF50633_GPIO2, 1);
+ break;
+ }
}
neo1973_gpb_setpin(GTA01_GPIO_MODEM_ON, 1);
} else {
neo1973_gpb_setpin(GTA01_GPIO_MODEM_ON, 0);
- switch (system_rev) {
-#ifdef CONFIG_MACH_NEO1973_GTA02
- case GTA02v2_SYSTEM_REV:
- case GTA02v3_SYSTEM_REV:
- case GTA02v4_SYSTEM_REV:
- case GTA02v5_SYSTEM_REV:
- case GTA02v6_SYSTEM_REV:
- pcf50633_gpio_set(pcf50633_global,
- PCF50633_GPIO2, 0);
- break;
-#endif
+ if (machine_is_neo1973_gta02()) {
+ switch (system_rev) {
+ case GTA02v2_SYSTEM_REV:
+ case GTA02v3_SYSTEM_REV:
+ case GTA02v4_SYSTEM_REV:
+ case GTA02v5_SYSTEM_REV:
+ case GTA02v6_SYSTEM_REV:
+ pcf50633_gpio_set(pcf50633_global,
+ PCF50633_GPIO2, 0);
+ break;
+ }
}
if (gta01_gsm.gpio_ngsm_en)
@@ -159,15 +154,12 @@ static ssize_t gsm_write(struct device *dev, struct device_attribute *attr,
} else if (!strcmp(attr->attr.name, "reset")) {
if (machine_is_neo1973_gta01())
neo1973_gpb_setpin(GTA01_GPIO_MODEM_RST, on);
-#ifdef CONFIG_MACH_NEO1973_GTA02
else if (machine_is_neo1973_gta02())
neo1973_gpb_setpin(GTA02_GPIO_MODEM_RST, on);
-#endif
} else if (!strcmp(attr->attr.name, "download")) {
if (machine_is_neo1973_gta01())
s3c2410_gpio_setpin(GTA01_GPIO_MODEM_DNLOAD, on);
-#ifdef CONFIG_MACH_NEO1973_GTA02
if (machine_is_neo1973_gta02()) {
/*
* the keyboard / buttons driver requests and enables
@@ -191,7 +183,6 @@ static ssize_t gsm_write(struct device *dev, struct device_attribute *attr,
gta01_gsm.gpio_ndl_gsm = !on;
s3c2410_gpio_setpin(GTA02_GPIO_nDL_GSM, !on);
}
-#endif
} else if (!strcmp(attr->attr.name, "flowcontrolled")) {
if (on) {
gta_gsm_interrupts = 0;
@@ -224,10 +215,8 @@ static int gta01_gsm_suspend(struct platform_device *pdev, pm_message_t state)
}
/* disable DL GSM to prevent jack_insert becoming 'floating' */
-#ifdef CONFIG_MACH_NEO1973_GTA02
if (machine_is_neo1973_gta02())
s3c2410_gpio_setpin(GTA02_GPIO_nDL_GSM, 1);
-#endif
return 0;
busy:
@@ -255,10 +244,8 @@ static int gta01_gsm_resume(struct platform_device *pdev)
if (gta01_gsm.con && s3c2410_gpio_getpin(GTA01_GPIO_MODEM_ON))
console_stop(gta01_gsm.con);
-#ifdef CONFIG_MACH_NEO1973_GTA02
if (machine_is_neo1973_gta02())
s3c2410_gpio_setpin(GTA02_GPIO_nDL_GSM, gta01_gsm.gpio_ndl_gsm);
-#endif
return 0;
}
@@ -266,7 +253,7 @@ static int gta01_gsm_resume(struct platform_device *pdev)
#define gta01_gsm_suspend NULL
#define gta01_gsm_suspend_late NULL
#define gta01_gsm_resume NULL
-#endif
+#endif /* CONFIG_PM */
static struct attribute *gta01_gsm_sysfs_entries[] = {
&dev_attr_power_on.attr,
@@ -296,7 +283,6 @@ static int __init gta01_gsm_probe(struct platform_device *pdev)
gta01_gsm.gpio_ngsm_en = GTA01Bv2_GPIO_nGSM_EN;
s3c2410_gpio_setpin(GTA01v3_GPIO_nGSM_EN, 0);
break;
-#ifdef CONFIG_MACH_NEO1973_GTA02
case GTA02v1_SYSTEM_REV:
case GTA02v2_SYSTEM_REV:
case GTA02v3_SYSTEM_REV:
@@ -305,7 +291,6 @@ static int __init gta01_gsm_probe(struct platform_device *pdev)
case GTA02v6_SYSTEM_REV:
gta01_gsm.gpio_ngsm_en = 0;
break;
-#endif
default:
dev_warn(&pdev->dev, "Unknown Neo1973 Revision 0x%x, "
"some PM features not available!!!\n",
@@ -333,10 +318,8 @@ static int __init gta01_gsm_probe(struct platform_device *pdev)
/* note that download initially disabled, and enforce that */
gta01_gsm.gpio_ndl_gsm = 1;
-#ifdef CONFIG_MACH_NEO1973_GTA02
if (machine_is_neo1973_gta02())
s3c2410_gpio_setpin(GTA02_GPIO_nDL_GSM, 1);
-#endif
return sysfs_create_group(&pdev->dev.kobj, &gta01_gsm_attr_group);
}