aboutsummaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorAndy Green <andy@openmoko.com>2008-11-19 17:10:58 +0000
committerAndy Green <andy@openmoko.com>2008-11-19 17:10:58 +0000
commita78ba7c56f9d932b388e567d76a053137043ede0 (patch)
tree9acbca8fafef70e40b94092d7463ea0a8fef49b9 /drivers/power
parente2798d4b07398d3db58f0be3f5cc98fdb58dfd0c (diff)
tracking-2.6.27-rc9-hdq-ordering.patch
Signed-off-by: Andy Green <andy@openmoko.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/gta02_hdq.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/power/gta02_hdq.c b/drivers/power/gta02_hdq.c
index 97cc2188f99..6f65b367a67 100644
--- a/drivers/power/gta02_hdq.c
+++ b/drivers/power/gta02_hdq.c
@@ -37,6 +37,9 @@ int gta02hdq_read(int address)
int count_sleeps = 5;
int ret = -ETIME;
+ if (!fiq_ipc.hdq_probed)
+ return -EINVAL;
+
mutex_lock(&fiq_ipc.hdq_lock);
fiq_ipc.hdq_ads = address | HDQ_READ;
@@ -72,6 +75,9 @@ int gta02hdq_write(int address, u8 data)
int count_sleeps = 5;
int ret = -ETIME;
+ if (!fiq_ipc.hdq_probed)
+ return -EINVAL;
+
mutex_lock(&fiq_ipc.hdq_lock);
fiq_ipc.hdq_ads = address | HDQ_WRITE;
@@ -110,6 +116,9 @@ static ssize_t hdq_sysfs_dump(struct device *dev, struct device_attribute *attr,
u8 u8a[128]; /* whole address space for HDQ */
char *end = buf;
+ if (!fiq_ipc.hdq_probed)
+ return -EINVAL;
+
/* the dump does not take care about 16 bit regs, because at this
* bus level we don't know about the chip details
*/
@@ -143,6 +152,9 @@ static ssize_t hdq_sysfs_write(struct device *dev,
const char *end = buf + count;
int address = atoi(buf);
+ if (!fiq_ipc.hdq_probed)
+ return -EINVAL;
+
while ((buf != end) && (*buf != ' '))
buf++;
if (buf >= end)
@@ -192,8 +204,9 @@ static int gta02hdq_resume(struct platform_device *pdev)
static int __init gta02hdq_probe(struct platform_device *pdev)
{
struct resource *r = platform_get_resource(pdev, 0, 0);
-
- if (!machine_is_neo1973_gta02())
+ int ret;
+
+ if (!machine_is_neo1973_gta02())
return -EIO;
if (!r)
@@ -214,9 +227,13 @@ static int __init gta02hdq_probe(struct platform_device *pdev)
s3c2410_gpio_setpin(fiq_ipc.hdq_gpio_pin, 1);
s3c2410_gpio_cfgpin(fiq_ipc.hdq_gpio_pin, S3C2410_GPIO_OUTPUT);
+ ret = sysfs_create_group(&pdev->dev.kobj, &gta02hdq_attr_group);
+ if (ret)
+ return ret;
+
fiq_ipc.hdq_probed = 1; /* we are ready to do stuff now */
- return sysfs_create_group(&pdev->dev.kobj, &gta02hdq_attr_group);
+ return 0;
}
static int gta02hdq_remove(struct platform_device *pdev)