Commit 0c3ae04b authored by Chris Lapa's avatar Chris Lapa Committed by Sebastian Reichel

max8903: store pointer to pdata instead of copying it.

Stores pointer to pdata because it easily allows pdata to reference
either platform data or in the future device tree data.
Signed-off-by: default avatarChris Lapa <chris@lapa.com.au>
Reviewed-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 411ef2be
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <linux/power/max8903_charger.h> #include <linux/power/max8903_charger.h>
struct max8903_data { struct max8903_data {
struct max8903_pdata pdata; struct max8903_pdata *pdata;
struct device *dev; struct device *dev;
struct power_supply *psy; struct power_supply *psy;
struct power_supply_desc psy_desc; struct power_supply_desc psy_desc;
...@@ -53,8 +53,8 @@ static int max8903_get_property(struct power_supply *psy, ...@@ -53,8 +53,8 @@ static int max8903_get_property(struct power_supply *psy,
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_STATUS: case POWER_SUPPLY_PROP_STATUS:
val->intval = POWER_SUPPLY_STATUS_UNKNOWN; val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
if (data->pdata.chg) { if (data->pdata->chg) {
if (gpio_get_value(data->pdata.chg) == 0) if (gpio_get_value(data->pdata->chg) == 0)
val->intval = POWER_SUPPLY_STATUS_CHARGING; val->intval = POWER_SUPPLY_STATUS_CHARGING;
else if (data->usb_in || data->ta_in) else if (data->usb_in || data->ta_in)
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
...@@ -81,7 +81,7 @@ static int max8903_get_property(struct power_supply *psy, ...@@ -81,7 +81,7 @@ static int max8903_get_property(struct power_supply *psy,
static irqreturn_t max8903_dcin(int irq, void *_data) static irqreturn_t max8903_dcin(int irq, void *_data)
{ {
struct max8903_data *data = _data; struct max8903_data *data = _data;
struct max8903_pdata *pdata = &data->pdata; struct max8903_pdata *pdata = data->pdata;
bool ta_in; bool ta_in;
enum power_supply_type old_type; enum power_supply_type old_type;
...@@ -122,7 +122,7 @@ static irqreturn_t max8903_dcin(int irq, void *_data) ...@@ -122,7 +122,7 @@ static irqreturn_t max8903_dcin(int irq, void *_data)
static irqreturn_t max8903_usbin(int irq, void *_data) static irqreturn_t max8903_usbin(int irq, void *_data)
{ {
struct max8903_data *data = _data; struct max8903_data *data = _data;
struct max8903_pdata *pdata = &data->pdata; struct max8903_pdata *pdata = data->pdata;
bool usb_in; bool usb_in;
enum power_supply_type old_type; enum power_supply_type old_type;
...@@ -161,7 +161,7 @@ static irqreturn_t max8903_usbin(int irq, void *_data) ...@@ -161,7 +161,7 @@ static irqreturn_t max8903_usbin(int irq, void *_data)
static irqreturn_t max8903_fault(int irq, void *_data) static irqreturn_t max8903_fault(int irq, void *_data)
{ {
struct max8903_data *data = _data; struct max8903_data *data = _data;
struct max8903_pdata *pdata = &data->pdata; struct max8903_pdata *pdata = data->pdata;
bool fault; bool fault;
fault = gpio_get_value(pdata->flt) ? false : true; fault = gpio_get_value(pdata->flt) ? false : true;
...@@ -190,12 +190,18 @@ static int max8903_probe(struct platform_device *pdev) ...@@ -190,12 +190,18 @@ static int max8903_probe(struct platform_device *pdev)
int ta_in = 0; int ta_in = 0;
int usb_in = 0; int usb_in = 0;
if (pdata == NULL) {
dev_err(dev, "No platform data.\n");
return -EINVAL;
}
data = devm_kzalloc(dev, sizeof(struct max8903_data), GFP_KERNEL); data = devm_kzalloc(dev, sizeof(struct max8903_data), GFP_KERNEL);
if (data == NULL) { if (data == NULL) {
dev_err(dev, "Cannot allocate memory.\n"); dev_err(dev, "Cannot allocate memory.\n");
return -ENOMEM; return -ENOMEM;
} }
memcpy(&data->pdata, pdata, sizeof(struct max8903_pdata));
data->pdata = pdev->dev.platform_data;
data->dev = dev; data->dev = dev;
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment