2018-04-16 02:35:00

by Ryder Lee

[permalink] [raw]
Subject: [PATCH] i2c: 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 mtk_i2c_probe() is to match an entry in
mtk_i2c_of_match[], so of_id cannot be NULL.

Signed-off-by: Ryder Lee <[email protected]>
---
drivers/i2c/busses/i2c-mt65xx.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index cf23a74..1e57f58 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -27,6 +27,7 @@
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <linux/scatterlist.h>
@@ -734,7 +735,6 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c)

static int mtk_i2c_probe(struct platform_device *pdev)
{
- const struct of_device_id *of_id;
int ret = 0;
struct mtk_i2c *i2c;
struct clk *clk;
@@ -761,11 +761,7 @@ static int mtk_i2c_probe(struct platform_device *pdev)

init_completion(&i2c->msg_complete);

- of_id = of_match_node(mtk_i2c_of_match, pdev->dev.of_node);
- if (!of_id)
- return -EINVAL;
-
- i2c->dev_comp = of_id->data;
+ i2c->dev_comp = of_device_get_match_data(&pdev->dev);
i2c->adap.dev.of_node = pdev->dev.of_node;
i2c->dev = &pdev->dev;
i2c->adap.dev.parent = &pdev->dev;
--
1.9.1



2018-04-16 02:35:18

by Ryder Lee

[permalink] [raw]
Subject: [PATCH] spi: 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 mtk_spi_probe() is to match an entry in
mtk_spi_of_match[], so of_id cannot be NULL.

Signed-off-by: Ryder Lee <[email protected]>
---
drivers/spi/spi-mt65xx.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 86bf456..3edc183 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -20,6 +20,7 @@
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/platform_device.h>
#include <linux/platform_data/spi-mt65xx.h>
@@ -578,7 +579,6 @@ static int mtk_spi_probe(struct platform_device *pdev)
{
struct spi_master *master;
struct mtk_spi *mdata;
- const struct of_device_id *of_id;
struct resource *res;
int i, irq, ret;

@@ -598,15 +598,9 @@ static int mtk_spi_probe(struct platform_device *pdev)
master->can_dma = mtk_spi_can_dma;
master->setup = mtk_spi_setup;

- of_id = of_match_node(mtk_spi_of_match, pdev->dev.of_node);
- if (!of_id) {
- dev_err(&pdev->dev, "failed to probe of_node\n");
- ret = -EINVAL;
- goto err_put_master;
- }
-
mdata = spi_master_get_devdata(master);
- mdata->dev_comp = of_id->data;
+ mdata->dev_comp = of_device_get_match_data(&pdev->dev);
+
if (mdata->dev_comp->must_tx)
master->flags = SPI_MASTER_MUST_TX;

--
1.9.1


2018-04-16 02:35:50

by Ryder Lee

[permalink] [raw]
Subject: [PATCH] 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 <[email protected]>
---
drivers/soc/mediatek/mtk-pmic-wrap.c | 13 +++----------
drivers/soc/mediatek/mtk-scpsys.c | 4 +---
2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
index e9e054a..2afae64 100644
--- a/drivers/soc/mediatek/mtk-pmic-wrap.c
+++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
@@ -1458,19 +1458,12 @@ static int pwrap_probe(struct platform_device *pdev)
int ret, irq;
struct pmic_wrapper *wrp;
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;
struct resource *res;

- if (!of_id) {
- dev_err(&pdev->dev, "Error: No device match found\n");
- return -ENODEV;
- }
+ if (np->child)
+ of_slave_id = of_match_node(of_slave_match_tbl, np->child);

- 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) {
dev_dbg(&pdev->dev, "slave pmic should be defined in dts\n");
return -EINVAL;
@@ -1482,7 +1475,7 @@ static int pwrap_probe(struct platform_device *pdev)

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->dev = &pdev->dev;

diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
index 435ce5e..a02a18e 100644
--- a/drivers/soc/mediatek/mtk-scpsys.c
+++ b/drivers/soc/mediatek/mtk-scpsys.c
@@ -973,15 +973,13 @@ static void mtk_register_power_domains(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_soc_data *soc;
struct scp *scp;
struct genpd_onecell_data *pd_data;
int i, ret;

- match = of_match_device(of_scpsys_match_tbl, &pdev->dev);
- soc = (const struct scp_soc_data *)match->data;
+ soc = of_device_get_match_data(&pdev->dev);

scp = init_scp(pdev, soc->domains, soc->num_domains, &soc->regs,
soc->bus_prot_reg_update);
--
1.9.1


2018-04-16 02:35:50

by Ryder Lee

[permalink] [raw]
Subject: [PATCH] mmc: 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 msdc_drv_probe() is to match an entry in
msdc_of_ids[], so of_id cannot be NULL.

Signed-off-by: Ryder Lee <[email protected]>
---
drivers/mmc/host/mtk-sd.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 6457a7d..67e9b57 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -19,6 +19,7 @@
#include <linux/ioport.h>
#include <linux/irq.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/of_irq.h>
#include <linux/of_gpio.h>
#include <linux/pinctrl/consumer.h>
@@ -1808,7 +1809,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
struct mmc_host *mmc;
struct msdc_host *host;
struct resource *res;
- const struct of_device_id *of_id;
int ret;

if (!pdev->dev.of_node) {
@@ -1816,9 +1816,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
return -EINVAL;
}

- of_id = of_match_node(msdc_of_ids, pdev->dev.of_node);
- if (!of_id)
- return -EINVAL;
/* Allocate MMC host for this device */
mmc = mmc_alloc_host(sizeof(struct msdc_host), &pdev->dev);
if (!mmc)
@@ -1887,7 +1884,7 @@ static int msdc_drv_probe(struct platform_device *pdev)
msdc_of_property_parse(pdev, host);

host->dev = &pdev->dev;
- host->dev_comp = of_id->data;
+ host->dev_comp = of_device_get_match_data(&pdev->dev);
host->mmc = mmc;
host->src_clk_freq = clk_get_rate(host->src_clk);
/* Set host parameters to mmc */
--
1.9.1


2018-04-16 02:36:09

by Ryder Lee

[permalink] [raw]
Subject: [PATCH] net: 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 mtk_probe() is to match an entry in
of_mtk_match[], so match cannot be NULL.

Signed-off-by: Ryder Lee <[email protected]>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index e0b72bf..d8ebf0a 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2503,7 +2503,6 @@ static int mtk_probe(struct platform_device *pdev)
{
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct device_node *mac_np;
- const struct of_device_id *match;
struct mtk_eth *eth;
int err;
int i;
@@ -2512,8 +2511,7 @@ static int mtk_probe(struct platform_device *pdev)
if (!eth)
return -ENOMEM;

- match = of_match_device(of_mtk_match, &pdev->dev);
- eth->soc = (struct mtk_soc_data *)match->data;
+ eth->soc = of_device_get_match_data(&pdev->dev);

eth->dev = &pdev->dev;
eth->base = devm_ioremap_resource(&pdev->dev, res);
--
1.9.1


2018-04-16 02:36:32

by Ryder Lee

[permalink] [raw]
Subject: [PATCH] thermal: 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 mtk_thermal_probe() is to match an entry in
mtk_thermal_of_match[], so of_id cannot be NULL.

Signed-off-by: Ryder Lee <[email protected]>
---
drivers/thermal/mtk_thermal.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index c75661a..12c3bc4 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -642,7 +642,6 @@ static int mtk_thermal_probe(struct platform_device *pdev)
struct device_node *auxadc, *apmixedsys, *np = pdev->dev.of_node;
struct mtk_thermal *mt;
struct resource *res;
- const struct of_device_id *of_id;
u64 auxadc_phys_base, apmixed_phys_base;
struct thermal_zone_device *tzdev;

@@ -650,9 +649,7 @@ static int mtk_thermal_probe(struct platform_device *pdev)
if (!mt)
return -ENOMEM;

- of_id = of_match_device(mtk_thermal_of_match, &pdev->dev);
- if (of_id)
- mt->conf = (const struct mtk_thermal_data *)of_id->data;
+ mt->conf = of_device_get_match_data(&pdev->dev);

mt->clk_peri_therm = devm_clk_get(&pdev->dev, "therm");
if (IS_ERR(mt->clk_peri_therm))
--
1.9.1


2018-04-16 02:36:35

by Ryder Lee

[permalink] [raw]
Subject: [PATCH] media: rc: mtk-cir: use of_device_get_match_data()

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

Signed-off-by: Ryder Lee <[email protected]>
---
drivers/media/rc/mtk-cir.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/rc/mtk-cir.c b/drivers/media/rc/mtk-cir.c
index e88eb64..e42efd9 100644
--- a/drivers/media/rc/mtk-cir.c
+++ b/drivers/media/rc/mtk-cir.c
@@ -299,8 +299,6 @@ static int mtk_ir_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *dn = dev->of_node;
- const struct of_device_id *of_id =
- of_match_device(mtk_ir_match, &pdev->dev);
struct resource *res;
struct mtk_ir *ir;
u32 val;
@@ -312,7 +310,7 @@ static int mtk_ir_probe(struct platform_device *pdev)
return -ENOMEM;

ir->dev = dev;
- ir->data = of_id->data;
+ ir->data = of_device_get_match_data(dev);

ir->clk = devm_clk_get(dev, "clk");
if (IS_ERR(ir->clk)) {
--
1.9.1


2018-04-16 02:36:58

by Ryder Lee

[permalink] [raw]
Subject: [PATCH] mtd: nand: mtk: 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 .probe() is to match an entry in
.of_match_table[], so of_device_id cannot be NULL.

Signed-off-by: Ryder Lee <[email protected]>
---
drivers/mtd/nand/raw/mtk_ecc.c | 7 +------
drivers/mtd/nand/raw/mtk_nand.c | 10 +---------
2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c
index 40d86a8..6432bd7 100644
--- a/drivers/mtd/nand/raw/mtk_ecc.c
+++ b/drivers/mtd/nand/raw/mtk_ecc.c
@@ -500,7 +500,6 @@ static int mtk_ecc_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct mtk_ecc *ecc;
struct resource *res;
- const struct of_device_id *of_ecc_id = NULL;
u32 max_eccdata_size;
int irq, ret;

@@ -508,11 +507,7 @@ static int mtk_ecc_probe(struct platform_device *pdev)
if (!ecc)
return -ENOMEM;

- of_ecc_id = of_match_device(mtk_ecc_dt_match, &pdev->dev);
- if (!of_ecc_id)
- return -ENODEV;
-
- ecc->caps = of_ecc_id->data;
+ ecc->caps = of_device_get_match_data(dev);

max_eccdata_size = ecc->caps->num_ecc_strength - 1;
max_eccdata_size = ecc->caps->ecc_strength[max_eccdata_size];
diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c
index 6977da3..75c845a 100644
--- a/drivers/mtd/nand/raw/mtk_nand.c
+++ b/drivers/mtd/nand/raw/mtk_nand.c
@@ -1434,7 +1434,6 @@ static int mtk_nfc_probe(struct platform_device *pdev)
struct device_node *np = dev->of_node;
struct mtk_nfc *nfc;
struct resource *res;
- const struct of_device_id *of_nfc_id = NULL;
int ret, irq;

nfc = devm_kzalloc(dev, sizeof(*nfc), GFP_KERNEL);
@@ -1452,6 +1451,7 @@ static int mtk_nfc_probe(struct platform_device *pdev)
else if (!nfc->ecc)
return -ENODEV;

+ nfc->caps = of_device_get_match_data(dev);
nfc->dev = dev;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1498,14 +1498,6 @@ static int mtk_nfc_probe(struct platform_device *pdev)
goto clk_disable;
}

- of_nfc_id = of_match_device(mtk_nfc_id_table, &pdev->dev);
- if (!of_nfc_id) {
- ret = -ENODEV;
- goto clk_disable;
- }
-
- nfc->caps = of_nfc_id->data;
-
platform_set_drvdata(pdev, nfc);

ret = mtk_nfc_nand_chips_init(dev, nfc);
--
1.9.1


2018-04-16 04:29:42

by xiaolei li

[permalink] [raw]
Subject: Re: [PATCH] mtd: nand: mtk: use of_device_get_match_data()

On Mon, 2018-04-16 at 10:33 +0800, Ryder Lee wrote:
> The usage of of_device_get_match_data() reduce the code size a bit.
>
> Also, the only way to call .probe() is to match an entry in
> .of_match_table[], so of_device_id cannot be NULL.
>
> Signed-off-by: Ryder Lee <[email protected]>
> ---
> drivers/mtd/nand/raw/mtk_ecc.c | 7 +------
> drivers/mtd/nand/raw/mtk_nand.c | 10 +---------
> 2 files changed, 2 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c
> index 40d86a8..6432bd7 100644
> --- a/drivers/mtd/nand/raw/mtk_ecc.c
> +++ b/drivers/mtd/nand/raw/mtk_ecc.c
> @@ -500,7 +500,6 @@ static int mtk_ecc_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct mtk_ecc *ecc;
> struct resource *res;
> - const struct of_device_id *of_ecc_id = NULL;
> u32 max_eccdata_size;
> int irq, ret;
>
> @@ -508,11 +507,7 @@ static int mtk_ecc_probe(struct platform_device *pdev)
> if (!ecc)
> return -ENOMEM;
>
> - of_ecc_id = of_match_device(mtk_ecc_dt_match, &pdev->dev);
> - if (!of_ecc_id)
> - return -ENODEV;
> -
> - ecc->caps = of_ecc_id->data;
> + ecc->caps = of_device_get_match_data(dev);
>
Thanks.

Reviewed-by: Xiaolei Li <[email protected]>

> max_eccdata_size = ecc->caps->num_ecc_strength - 1;
> max_eccdata_size = ecc->caps->ecc_strength[max_eccdata_size];
> diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c
> index 6977da3..75c845a 100644
> --- a/drivers/mtd/nand/raw/mtk_nand.c
> +++ b/drivers/mtd/nand/raw/mtk_nand.c
> @@ -1434,7 +1434,6 @@ static int mtk_nfc_probe(struct platform_device *pdev)
> struct device_node *np = dev->of_node;
> struct mtk_nfc *nfc;
> struct resource *res;
> - const struct of_device_id *of_nfc_id = NULL;
> int ret, irq;
>
> nfc = devm_kzalloc(dev, sizeof(*nfc), GFP_KERNEL);
> @@ -1452,6 +1451,7 @@ static int mtk_nfc_probe(struct platform_device *pdev)
> else if (!nfc->ecc)
> return -ENODEV;
>
> + nfc->caps = of_device_get_match_data(dev);
> nfc->dev = dev;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -1498,14 +1498,6 @@ static int mtk_nfc_probe(struct platform_device *pdev)
> goto clk_disable;
> }
>
> - of_nfc_id = of_match_device(mtk_nfc_id_table, &pdev->dev);
> - if (!of_nfc_id) {
> - ret = -ENODEV;
> - goto clk_disable;
> - }
> -
> - nfc->caps = of_nfc_id->data;
> -
> platform_set_drvdata(pdev, nfc);
>
> ret = mtk_nfc_nand_chips_init(dev, nfc);



2018-04-16 17:45:21

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] net: mediatek: use of_device_get_match_data()

From: Ryder Lee <[email protected]>
Date: Mon, 16 Apr 2018 10:33:41 +0800

> The usage of of_device_get_match_data() reduce the code size a bit.
>
> Also, the only way to call mtk_probe() is to match an entry in
> of_mtk_match[], so match cannot be NULL.
>
> Signed-off-by: Ryder Lee <[email protected]>

Applied to net-next.

2018-04-17 04:00:08

by Sean Wang

[permalink] [raw]
Subject: Re: [PATCH] media: rc: mtk-cir: use of_device_get_match_data()

On Mon, 2018-04-16 at 10:34 +0800, Ryder Lee wrote:
> The usage of of_device_get_match_data() reduce the code size a bit.
>
> Signed-off-by: Ryder Lee <[email protected]>
> ---
> drivers/media/rc/mtk-cir.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/media/rc/mtk-cir.c b/drivers/media/rc/mtk-cir.c
> index e88eb64..e42efd9 100644
> --- a/drivers/media/rc/mtk-cir.c
> +++ b/drivers/media/rc/mtk-cir.c
> @@ -299,8 +299,6 @@ static int mtk_ir_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct device_node *dn = dev->of_node;
> - const struct of_device_id *of_id =
> - of_match_device(mtk_ir_match, &pdev->dev);
> struct resource *res;
> struct mtk_ir *ir;
> u32 val;
> @@ -312,7 +310,7 @@ static int mtk_ir_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> ir->dev = dev;
> - ir->data = of_id->data;
> + ir->data = of_device_get_match_data(dev);
>
> ir->clk = devm_clk_get(dev, "clk");
> if (IS_ERR(ir->clk)) {


Acked-by: Sean Wang <[email protected]>



2018-04-17 14:39:28

by Matthias Brugger

[permalink] [raw]
Subject: Re: [PATCH] soc: mediatek: use of_device_get_match_data()



On 04/16/2018 04:33 AM, Ryder Lee wrote:
> 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 <[email protected]>
> ---

Applied to v4.17-next/soc

Thanks.

> drivers/soc/mediatek/mtk-pmic-wrap.c | 13 +++----------
> drivers/soc/mediatek/mtk-scpsys.c | 4 +---
> 2 files changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
> index e9e054a..2afae64 100644
> --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
> +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
> @@ -1458,19 +1458,12 @@ static int pwrap_probe(struct platform_device *pdev)
> int ret, irq;
> struct pmic_wrapper *wrp;
> 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;
> struct resource *res;
>
> - if (!of_id) {
> - dev_err(&pdev->dev, "Error: No device match found\n");
> - return -ENODEV;
> - }
> + if (np->child)
> + of_slave_id = of_match_node(of_slave_match_tbl, np->child);
>
> - 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) {
> dev_dbg(&pdev->dev, "slave pmic should be defined in dts\n");
> return -EINVAL;
> @@ -1482,7 +1475,7 @@ static int pwrap_probe(struct platform_device *pdev)
>
> 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->dev = &pdev->dev;
>
> diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
> index 435ce5e..a02a18e 100644
> --- a/drivers/soc/mediatek/mtk-scpsys.c
> +++ b/drivers/soc/mediatek/mtk-scpsys.c
> @@ -973,15 +973,13 @@ static void mtk_register_power_domains(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_soc_data *soc;
> struct scp *scp;
> struct genpd_onecell_data *pd_data;
> int i, ret;
>
> - match = of_match_device(of_scpsys_match_tbl, &pdev->dev);
> - soc = (const struct scp_soc_data *)match->data;
> + soc = of_device_get_match_data(&pdev->dev);
>
> scp = init_scp(pdev, soc->domains, soc->num_domains, &soc->regs,
> soc->bus_prot_reg_update);
>

2018-04-19 13:20:24

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH] mmc: mediatek: use of_device_get_match_data()

On 16 April 2018 at 04:33, Ryder Lee <[email protected]> wrote:
> The usage of of_device_get_match_data() reduce the code size a bit.
>
> Also, the only way to call msdc_drv_probe() is to match an entry in
> msdc_of_ids[], so of_id cannot be NULL.
>
> Signed-off-by: Ryder Lee <[email protected]>

Thanks, applied for next!

Kind regards
Uffe

> ---
> drivers/mmc/host/mtk-sd.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index 6457a7d..67e9b57 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -19,6 +19,7 @@
> #include <linux/ioport.h>
> #include <linux/irq.h>
> #include <linux/of_address.h>
> +#include <linux/of_device.h>
> #include <linux/of_irq.h>
> #include <linux/of_gpio.h>
> #include <linux/pinctrl/consumer.h>
> @@ -1808,7 +1809,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
> struct mmc_host *mmc;
> struct msdc_host *host;
> struct resource *res;
> - const struct of_device_id *of_id;
> int ret;
>
> if (!pdev->dev.of_node) {
> @@ -1816,9 +1816,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
> return -EINVAL;
> }
>
> - of_id = of_match_node(msdc_of_ids, pdev->dev.of_node);
> - if (!of_id)
> - return -EINVAL;
> /* Allocate MMC host for this device */
> mmc = mmc_alloc_host(sizeof(struct msdc_host), &pdev->dev);
> if (!mmc)
> @@ -1887,7 +1884,7 @@ static int msdc_drv_probe(struct platform_device *pdev)
> msdc_of_property_parse(pdev, host);
>
> host->dev = &pdev->dev;
> - host->dev_comp = of_id->data;
> + host->dev_comp = of_device_get_match_data(&pdev->dev);
> host->mmc = mmc;
> host->src_clk_freq = clk_get_rate(host->src_clk);
> /* Set host parameters to mmc */
> --
> 1.9.1
>

2018-04-22 17:29:32

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH] mtd: nand: mtk: use of_device_get_match_data()

On Mon, 16 Apr 2018 10:33:54 +0800
Ryder Lee <[email protected]> wrote:

> The usage of of_device_get_match_data() reduce the code size a bit.
>
> Also, the only way to call .probe() is to match an entry in
> .of_match_table[], so of_device_id cannot be NULL.
>
> Signed-off-by: Ryder Lee <[email protected]>
> ---
> drivers/mtd/nand/raw/mtk_ecc.c | 7 +------
> drivers/mtd/nand/raw/mtk_nand.c | 10 +---------

Applied to nand/next after fixing the subject prefix.

Thanks,

Boris

> 2 files changed, 2 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c
> index 40d86a8..6432bd7 100644
> --- a/drivers/mtd/nand/raw/mtk_ecc.c
> +++ b/drivers/mtd/nand/raw/mtk_ecc.c
> @@ -500,7 +500,6 @@ static int mtk_ecc_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct mtk_ecc *ecc;
> struct resource *res;
> - const struct of_device_id *of_ecc_id = NULL;
> u32 max_eccdata_size;
> int irq, ret;
>
> @@ -508,11 +507,7 @@ static int mtk_ecc_probe(struct platform_device *pdev)
> if (!ecc)
> return -ENOMEM;
>
> - of_ecc_id = of_match_device(mtk_ecc_dt_match, &pdev->dev);
> - if (!of_ecc_id)
> - return -ENODEV;
> -
> - ecc->caps = of_ecc_id->data;
> + ecc->caps = of_device_get_match_data(dev);
>
> max_eccdata_size = ecc->caps->num_ecc_strength - 1;
> max_eccdata_size = ecc->caps->ecc_strength[max_eccdata_size];
> diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c
> index 6977da3..75c845a 100644
> --- a/drivers/mtd/nand/raw/mtk_nand.c
> +++ b/drivers/mtd/nand/raw/mtk_nand.c
> @@ -1434,7 +1434,6 @@ static int mtk_nfc_probe(struct platform_device *pdev)
> struct device_node *np = dev->of_node;
> struct mtk_nfc *nfc;
> struct resource *res;
> - const struct of_device_id *of_nfc_id = NULL;
> int ret, irq;
>
> nfc = devm_kzalloc(dev, sizeof(*nfc), GFP_KERNEL);
> @@ -1452,6 +1451,7 @@ static int mtk_nfc_probe(struct platform_device *pdev)
> else if (!nfc->ecc)
> return -ENODEV;
>
> + nfc->caps = of_device_get_match_data(dev);
> nfc->dev = dev;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -1498,14 +1498,6 @@ static int mtk_nfc_probe(struct platform_device *pdev)
> goto clk_disable;
> }
>
> - of_nfc_id = of_match_device(mtk_nfc_id_table, &pdev->dev);
> - if (!of_nfc_id) {
> - ret = -ENODEV;
> - goto clk_disable;
> - }
> -
> - nfc->caps = of_nfc_id->data;
> -
> platform_set_drvdata(pdev, nfc);
>
> ret = mtk_nfc_nand_chips_init(dev, nfc);


2018-04-28 13:13:54

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH] i2c: mediatek: use of_device_get_match_data()

On Mon, Apr 16, 2018 at 10:32:52AM +0800, Ryder Lee wrote:
> The usage of of_device_get_match_data() reduce the code size a bit.
>
> Also, the only way to call mtk_i2c_probe() is to match an entry in
> mtk_i2c_of_match[], so of_id cannot be NULL.
>
> Signed-off-by: Ryder Lee <[email protected]>

Applied to for-next, thanks!

Does somebody from Mediatek maybe want to maintain this driver?


Attachments:
(No filename) (411.00 B)
signature.asc (849.00 B)
Download all attachments

2018-04-30 07:27:17

by Ryder Lee

[permalink] [raw]
Subject: Re: [PATCH] spi: mediatek: Use of_device_get_match_data()

Hi Mark,

Is it okay with you?

On Mon, 2018-04-16 at 10:33 +0800, Ryder Lee (李庚?V) wrote:
> The usage of of_device_get_match_data() reduce the code size a bit.
>
> Also, the only way to call mtk_spi_probe() is to match an entry in
> mtk_spi_of_match[], so of_id cannot be NULL.
>
> Signed-off-by: Ryder Lee <[email protected]>
> ---
> drivers/spi/spi-mt65xx.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>




2018-05-01 20:36:36

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] spi: mediatek: Use of_device_get_match_data()

On Mon, Apr 30, 2018 at 03:26:36PM +0800, Ryder Lee wrote:
> Hi Mark,
>
> Is it okay with you?
>
> On Mon, 2018-04-16 at 10:33 +0800, Ryder Lee (李庚?V) wrote:
> > The usage of of_device_get_match_data() reduce the code size a bit.

Please don't send content free pings and please allow a reasonable time
for review. People get busy, go on holiday, attend conferences and so
on so unless there is some reason for urgency (like critical bug fixes)
please allow at least a couple of weeks for review. If there have been
review comments then people may be waiting for those to be addressed.
Sending content free pings just adds to the mail volume (if they are
seen at all) and if something has gone wrong you'll have to resend the
patches anyway.


Attachments:
(No filename) (767.00 B)
signature.asc (499.00 B)
Download all attachments