mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-07 00:59:06 +00:00
mfd: pm8008: Remove driver data structure pm8008_data
[ Upstream commit915696927c
] Maintaining a local driver data structure that is never shared outside of the core device is an unnecessary complexity. Half of the attributes were not used outside of a single function, one of which was not used at all. The remaining 2 are generic and can be passed around as required. Signed-off-by: Lee Jones <lee.jones@linaro.org> Stable-dep-of:14f8c55d48
("mfd: pm8008: Fix return value check in pm8008_probe()") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
38959417d3
commit
ec10848e26
1 changed files with 20 additions and 33 deletions
|
@ -54,13 +54,6 @@ enum {
|
||||||
|
|
||||||
#define PM8008_PERIPH_OFFSET(paddr) (paddr - PM8008_PERIPH_0_BASE)
|
#define PM8008_PERIPH_OFFSET(paddr) (paddr - PM8008_PERIPH_0_BASE)
|
||||||
|
|
||||||
struct pm8008_data {
|
|
||||||
struct device *dev;
|
|
||||||
struct regmap *regmap;
|
|
||||||
int irq;
|
|
||||||
struct regmap_irq_chip_data *irq_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned int p0_offs[] = {PM8008_PERIPH_OFFSET(PM8008_PERIPH_0_BASE)};
|
static unsigned int p0_offs[] = {PM8008_PERIPH_OFFSET(PM8008_PERIPH_0_BASE)};
|
||||||
static unsigned int p1_offs[] = {PM8008_PERIPH_OFFSET(PM8008_PERIPH_1_BASE)};
|
static unsigned int p1_offs[] = {PM8008_PERIPH_OFFSET(PM8008_PERIPH_1_BASE)};
|
||||||
static unsigned int p2_offs[] = {PM8008_PERIPH_OFFSET(PM8008_PERIPH_2_BASE)};
|
static unsigned int p2_offs[] = {PM8008_PERIPH_OFFSET(PM8008_PERIPH_2_BASE)};
|
||||||
|
@ -150,7 +143,7 @@ static struct regmap_config qcom_mfd_regmap_cfg = {
|
||||||
.max_register = 0xFFFF,
|
.max_register = 0xFFFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int pm8008_init(struct pm8008_data *chip)
|
static int pm8008_init(struct regmap *regmap)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -160,34 +153,31 @@ static int pm8008_init(struct pm8008_data *chip)
|
||||||
* This is required to enable the writing of TYPE registers in
|
* This is required to enable the writing of TYPE registers in
|
||||||
* regmap_irq_sync_unlock().
|
* regmap_irq_sync_unlock().
|
||||||
*/
|
*/
|
||||||
rc = regmap_write(chip->regmap,
|
rc = regmap_write(regmap, (PM8008_TEMP_ALARM_ADDR | INT_SET_TYPE_OFFSET), BIT(0));
|
||||||
(PM8008_TEMP_ALARM_ADDR | INT_SET_TYPE_OFFSET),
|
|
||||||
BIT(0));
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Do the same for GPIO1 and GPIO2 peripherals */
|
/* Do the same for GPIO1 and GPIO2 peripherals */
|
||||||
rc = regmap_write(chip->regmap,
|
rc = regmap_write(regmap, (PM8008_GPIO1_ADDR | INT_SET_TYPE_OFFSET), BIT(0));
|
||||||
(PM8008_GPIO1_ADDR | INT_SET_TYPE_OFFSET), BIT(0));
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
rc = regmap_write(chip->regmap,
|
rc = regmap_write(regmap, (PM8008_GPIO2_ADDR | INT_SET_TYPE_OFFSET), BIT(0));
|
||||||
(PM8008_GPIO2_ADDR | INT_SET_TYPE_OFFSET), BIT(0));
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pm8008_probe_irq_peripherals(struct pm8008_data *chip,
|
static int pm8008_probe_irq_peripherals(struct device *dev,
|
||||||
|
struct regmap *regmap,
|
||||||
int client_irq)
|
int client_irq)
|
||||||
{
|
{
|
||||||
int rc, i;
|
int rc, i;
|
||||||
struct regmap_irq_type *type;
|
struct regmap_irq_type *type;
|
||||||
struct regmap_irq_chip_data *irq_data;
|
struct regmap_irq_chip_data *irq_data;
|
||||||
|
|
||||||
rc = pm8008_init(chip);
|
rc = pm8008_init(regmap);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(chip->dev, "Init failed: %d\n", rc);
|
dev_err(dev, "Init failed: %d\n", rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,10 +197,10 @@ static int pm8008_probe_irq_peripherals(struct pm8008_data *chip,
|
||||||
IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW);
|
IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = devm_regmap_add_irq_chip(chip->dev, chip->regmap, client_irq,
|
rc = devm_regmap_add_irq_chip(dev, regmap, client_irq,
|
||||||
IRQF_SHARED, 0, &pm8008_irq_chip, &irq_data);
|
IRQF_SHARED, 0, &pm8008_irq_chip, &irq_data);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(chip->dev, "Failed to add IRQ chip: %d\n", rc);
|
dev_err(dev, "Failed to add IRQ chip: %d\n", rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,26 +210,23 @@ static int pm8008_probe_irq_peripherals(struct pm8008_data *chip,
|
||||||
static int pm8008_probe(struct i2c_client *client)
|
static int pm8008_probe(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct pm8008_data *chip;
|
struct device *dev;
|
||||||
|
struct regmap *regmap;
|
||||||
|
|
||||||
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
|
dev = &client->dev;
|
||||||
if (!chip)
|
regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg);
|
||||||
return -ENOMEM;
|
if (!regmap)
|
||||||
|
|
||||||
chip->dev = &client->dev;
|
|
||||||
chip->regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg);
|
|
||||||
if (!chip->regmap)
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
i2c_set_clientdata(client, chip);
|
i2c_set_clientdata(client, regmap);
|
||||||
|
|
||||||
if (of_property_read_bool(chip->dev->of_node, "interrupt-controller")) {
|
if (of_property_read_bool(dev->of_node, "interrupt-controller")) {
|
||||||
rc = pm8008_probe_irq_peripherals(chip, client->irq);
|
rc = pm8008_probe_irq_peripherals(dev, regmap, client->irq);
|
||||||
if (rc)
|
if (rc)
|
||||||
dev_err(chip->dev, "Failed to probe irq periphs: %d\n", rc);
|
dev_err(dev, "Failed to probe irq periphs: %d\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return devm_of_platform_populate(chip->dev);
|
return devm_of_platform_populate(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id pm8008_match[] = {
|
static const struct of_device_id pm8008_match[] = {
|
||||||
|
|
Loading…
Reference in a new issue