summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorVarun Wadekar <vwadekar@nvidia.com>2011-12-01 10:46:30 +0530
committerVarun Wadekar <vwadekar@nvidia.com>2011-12-09 14:00:38 +0530
commit46c08ea5cb8e40c44a25b91204c09a721c9896fb (patch)
tree41a0fa0340f9f91b0fc9c0382f0ffdfd0d2175dc /drivers/power
parenta56026d14c2d68497124ddd2bf59a0bb749bf87e (diff)
power: bq20z75: copy pdata to the driver context
Generally boards define platform data structs as __initdata. Due to this, it is not available in the driver as a pointer. The driver needs to copy the platform data to its context in order to use it after _probe exits. Change-Id: If6a4944f0f3cbb835e56d915cf5eee34d0de374d Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/bq20z75.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/power/bq20z75.c b/drivers/power/bq20z75.c
index e231dd8bbeb0..7f9dfbf61cde 100644
--- a/drivers/power/bq20z75.c
+++ b/drivers/power/bq20z75.c
@@ -147,7 +147,7 @@ static enum power_supply_property bq20z75_properties[] = {
struct bq20z75_info {
struct i2c_client *client;
struct power_supply power_supply;
- struct bq20z75_platform_data *pdata;
+ struct bq20z75_platform_data plat_data;
bool is_present;
bool gpio_detect;
bool enable_detection;
@@ -164,8 +164,7 @@ static int bq20z75_read_word_data(struct i2c_client *client, u8 address)
s32 ret = 0;
int retries = 1;
- if (bq20z75_device->pdata)
- retries = max(bq20z75_device->pdata->i2c_retry_count + 1, 1);
+ retries = max(bq20z75_device->plat_data.i2c_retry_count + 1, 1);
while (retries > 0) {
ret = i2c_smbus_read_word_data(client, address);
@@ -191,8 +190,7 @@ static int bq20z75_write_word_data(struct i2c_client *client, u8 address,
s32 ret = 0;
int retries = 1;
- if (bq20z75_device->pdata)
- retries = max(bq20z75_device->pdata->i2c_retry_count + 1, 1);
+ retries = max(bq20z75_device->plat_data.i2c_retry_count + 1, 1);
while (retries > 0) {
ret = i2c_smbus_write_word_data(client, address,
@@ -222,8 +220,8 @@ static int bq20z75_get_battery_presence_and_health(
if (psp == POWER_SUPPLY_PROP_PRESENT &&
bq20z75_device->gpio_detect) {
ret = gpio_get_value(
- bq20z75_device->pdata->battery_detect);
- if (ret == bq20z75_device->pdata->battery_detect_present)
+ bq20z75_device->plat_data.battery_detect);
+ if (ret == bq20z75_device->plat_data.battery_detect_present)
val->intval = 1;
else
val->intval = 0;
@@ -574,7 +572,7 @@ static void bq20z75_external_power_changed(struct power_supply *psy)
cancel_delayed_work_sync(&bq20z75_device->work);
schedule_delayed_work(&bq20z75_device->work, HZ);
- bq20z75_device->poll_time = bq20z75_device->pdata->poll_retry_count;
+ bq20z75_device->poll_time = bq20z75_device->plat_data.poll_retry_count;
}
static void bq20z75_delayed_work(struct work_struct *work)
@@ -645,7 +643,7 @@ static int __devinit bq20z75_probe(struct i2c_client *client,
if (pdata) {
bq20z75_device->gpio_detect =
gpio_is_valid(pdata->battery_detect);
- bq20z75_device->pdata = pdata;
+ memcpy(&bq20z75_device->plat_data, pdata, sizeof(struct bq20z75_platform_data));
}
i2c_set_clientdata(client, bq20z75_device);
@@ -724,7 +722,7 @@ static int __devexit bq20z75_remove(struct i2c_client *client)
if (bq20z75_device->irq)
free_irq(bq20z75_device->irq, &bq20z75_device->power_supply);
if (bq20z75_device->gpio_detect)
- gpio_free(bq20z75_device->pdata->battery_detect);
+ gpio_free(bq20z75_device->plat_data.battery_detect);
power_supply_unregister(&bq20z75_device->power_supply);