power: supply: max17042_battery: Always fall back to default platform-data
It is possible to have CONFIG_OF enabled on x86 builds, where we have no firmware provided max17042_platform_data. The CONFIG_OF implementation of max17042_get_pdata would return NULL in this case, causing the probe to fail. Instead always fallback to the default platform-data, as used on x86 sofar, when there is no firmware provided pdata, independent of CONFIG_OF. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
This commit is contained in:
Родитель
6e5ab19d54
Коммит
2d7e6a8376
|
@ -886,16 +886,13 @@ static void max17042_init_worker(struct work_struct *work)
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
static struct max17042_platform_data *
|
static struct max17042_platform_data *
|
||||||
max17042_get_pdata(struct max17042_chip *chip)
|
max17042_get_of_pdata(struct max17042_chip *chip)
|
||||||
{
|
{
|
||||||
struct device *dev = &chip->client->dev;
|
struct device *dev = &chip->client->dev;
|
||||||
struct device_node *np = dev->of_node;
|
struct device_node *np = dev->of_node;
|
||||||
u32 prop;
|
u32 prop;
|
||||||
struct max17042_platform_data *pdata;
|
struct max17042_platform_data *pdata;
|
||||||
|
|
||||||
if (!np)
|
|
||||||
return dev->platform_data;
|
|
||||||
|
|
||||||
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
|
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -920,7 +917,8 @@ max17042_get_pdata(struct max17042_chip *chip)
|
||||||
|
|
||||||
return pdata;
|
return pdata;
|
||||||
}
|
}
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
static struct max17042_reg_data max17047_default_pdata_init_regs[] = {
|
static struct max17042_reg_data max17047_default_pdata_init_regs[] = {
|
||||||
/*
|
/*
|
||||||
* Some firmwares do not set FullSOCThr, Enable End-of-Charge Detection
|
* Some firmwares do not set FullSOCThr, Enable End-of-Charge Detection
|
||||||
|
@ -930,15 +928,12 @@ static struct max17042_reg_data max17047_default_pdata_init_regs[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct max17042_platform_data *
|
static struct max17042_platform_data *
|
||||||
max17042_get_pdata(struct max17042_chip *chip)
|
max17042_get_default_pdata(struct max17042_chip *chip)
|
||||||
{
|
{
|
||||||
struct device *dev = &chip->client->dev;
|
struct device *dev = &chip->client->dev;
|
||||||
struct max17042_platform_data *pdata;
|
struct max17042_platform_data *pdata;
|
||||||
int ret, misc_cfg;
|
int ret, misc_cfg;
|
||||||
|
|
||||||
if (dev->platform_data)
|
|
||||||
return dev->platform_data;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The MAX17047 gets used on x86 where we might not have pdata, assume
|
* The MAX17047 gets used on x86 where we might not have pdata, assume
|
||||||
* the firmware will already have initialized the fuel-gauge and provide
|
* the firmware will already have initialized the fuel-gauge and provide
|
||||||
|
@ -971,7 +966,21 @@ max17042_get_pdata(struct max17042_chip *chip)
|
||||||
|
|
||||||
return pdata;
|
return pdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct max17042_platform_data *
|
||||||
|
max17042_get_pdata(struct max17042_chip *chip)
|
||||||
|
{
|
||||||
|
struct device *dev = &chip->client->dev;
|
||||||
|
|
||||||
|
#ifdef CONFIG_OF
|
||||||
|
if (dev->of_node)
|
||||||
|
return max17042_get_of_pdata(chip);
|
||||||
#endif
|
#endif
|
||||||
|
if (dev->platform_data)
|
||||||
|
return dev->platform_data;
|
||||||
|
|
||||||
|
return max17042_get_default_pdata(chip);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct regmap_config max17042_regmap_config = {
|
static const struct regmap_config max17042_regmap_config = {
|
||||||
.reg_bits = 8,
|
.reg_bits = 8,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче