soc: mediatek: use of_device_get_match_data()

The usage of of_device_get_match_data() reduce the code size a bit.

Also, the only way to call pwrap_probe() is to match an entry in
of_pwrap_match_tbl[], so of_id cannot be NULL.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
This commit is contained in:
Ryder Lee 2018-04-16 10:33:34 +08:00 committed by Matthias Brugger
parent 60cc43fc88
commit 38d19752a7
2 changed files with 4 additions and 13 deletions

View File

@ -1458,19 +1458,12 @@ static int pwrap_probe(struct platform_device *pdev)
int ret, irq; int ret, irq;
struct pmic_wrapper *wrp; struct pmic_wrapper *wrp;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
const struct of_device_id *of_id =
of_match_device(of_pwrap_match_tbl, &pdev->dev);
const struct of_device_id *of_slave_id = NULL; const struct of_device_id *of_slave_id = NULL;
struct resource *res; struct resource *res;
if (!of_id) { if (np->child)
dev_err(&pdev->dev, "Error: No device match found\n"); of_slave_id = of_match_node(of_slave_match_tbl, np->child);
return -ENODEV;
}
if (pdev->dev.of_node->child)
of_slave_id = of_match_node(of_slave_match_tbl,
pdev->dev.of_node->child);
if (!of_slave_id) { if (!of_slave_id) {
dev_dbg(&pdev->dev, "slave pmic should be defined in dts\n"); dev_dbg(&pdev->dev, "slave pmic should be defined in dts\n");
return -EINVAL; return -EINVAL;
@ -1482,7 +1475,7 @@ static int pwrap_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, wrp); platform_set_drvdata(pdev, wrp);
wrp->master = of_id->data; wrp->master = of_device_get_match_data(&pdev->dev);
wrp->slave = of_slave_id->data; wrp->slave = of_slave_id->data;
wrp->dev = &pdev->dev; wrp->dev = &pdev->dev;

View File

@ -1067,15 +1067,13 @@ static const struct of_device_id of_scpsys_match_tbl[] = {
static int scpsys_probe(struct platform_device *pdev) static int scpsys_probe(struct platform_device *pdev)
{ {
const struct of_device_id *match;
const struct scp_subdomain *sd; const struct scp_subdomain *sd;
const struct scp_soc_data *soc; const struct scp_soc_data *soc;
struct scp *scp; struct scp *scp;
struct genpd_onecell_data *pd_data; struct genpd_onecell_data *pd_data;
int i, ret; int i, ret;
match = of_match_device(of_scpsys_match_tbl, &pdev->dev); soc = of_device_get_match_data(&pdev->dev);
soc = (const struct scp_soc_data *)match->data;
scp = init_scp(pdev, soc->domains, soc->num_domains, &soc->regs, scp = init_scp(pdev, soc->domains, soc->num_domains, &soc->regs,
soc->bus_prot_reg_update); soc->bus_prot_reg_update);