mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-02 02:34:05 +08:00
mfd: mt6397: Trim probe function to support different chips more cleanly
Add new struct members for mfd-cells and irq initial function, so we can call devm_mfd_add_devices() only once. Signed-off-by: Hsin-Hsiung Wang <hsin-hsiung.wang@mediatek.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
parent
4e2e7cfec1
commit
d0c7347dc7
@ -103,22 +103,31 @@ static const struct mfd_cell mt6397_devs[] = {
|
|||||||
struct chip_data {
|
struct chip_data {
|
||||||
u32 cid_addr;
|
u32 cid_addr;
|
||||||
u32 cid_shift;
|
u32 cid_shift;
|
||||||
|
const struct mfd_cell *cells;
|
||||||
|
int cell_size;
|
||||||
|
int (*irq_init)(struct mt6397_chip *chip);
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct chip_data mt6323_core = {
|
static const struct chip_data mt6323_core = {
|
||||||
.cid_addr = MT6323_CID,
|
.cid_addr = MT6323_CID,
|
||||||
.cid_shift = 0,
|
.cid_shift = 0,
|
||||||
|
.cells = mt6323_devs,
|
||||||
|
.cell_size = ARRAY_SIZE(mt6323_devs),
|
||||||
|
.irq_init = mt6397_irq_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct chip_data mt6397_core = {
|
static const struct chip_data mt6397_core = {
|
||||||
.cid_addr = MT6397_CID,
|
.cid_addr = MT6397_CID,
|
||||||
.cid_shift = 0,
|
.cid_shift = 0,
|
||||||
|
.cells = mt6397_devs,
|
||||||
|
.cell_size = ARRAY_SIZE(mt6397_devs),
|
||||||
|
.irq_init = mt6397_irq_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mt6397_probe(struct platform_device *pdev)
|
static int mt6397_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int id;
|
unsigned int id = 0;
|
||||||
struct mt6397_chip *pmic;
|
struct mt6397_chip *pmic;
|
||||||
const struct chip_data *pmic_core;
|
const struct chip_data *pmic_core;
|
||||||
|
|
||||||
@ -154,29 +163,13 @@ static int mt6397_probe(struct platform_device *pdev)
|
|||||||
if (pmic->irq <= 0)
|
if (pmic->irq <= 0)
|
||||||
return pmic->irq;
|
return pmic->irq;
|
||||||
|
|
||||||
ret = mt6397_irq_init(pmic);
|
ret = pmic_core->irq_init(pmic);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
switch (pmic->chip_id) {
|
ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
|
||||||
case MT6323_CHIP_ID:
|
pmic_core->cells, pmic_core->cell_size,
|
||||||
ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
|
NULL, 0, pmic->irq_domain);
|
||||||
mt6323_devs, ARRAY_SIZE(mt6323_devs),
|
|
||||||
NULL, 0, pmic->irq_domain);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MT6391_CHIP_ID:
|
|
||||||
case MT6397_CHIP_ID:
|
|
||||||
ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
|
|
||||||
mt6397_devs, ARRAY_SIZE(mt6397_devs),
|
|
||||||
NULL, 0, pmic->irq_domain);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
dev_err(&pdev->dev, "unsupported chip: %d\n", pmic->chip_id);
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
irq_domain_remove(pmic->irq_domain);
|
irq_domain_remove(pmic->irq_domain);
|
||||||
dev_err(&pdev->dev, "failed to add child devices: %d\n", ret);
|
dev_err(&pdev->dev, "failed to add child devices: %d\n", ret);
|
||||||
|
Loading…
Reference in New Issue
Block a user