Skip to content

Commit

Permalink
i2c: mediatek: use of_device_get_match_data()
Browse files Browse the repository at this point in the history
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 <ryder.lee@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
  • Loading branch information
Ryder Lee authored and Wolfram Sang committed Apr 30, 2018
1 parent 952cfd1 commit 6e29577
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/i2c/busses/i2c-mt65xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 6e29577

Please sign in to comment.