Re: [PATCH v3 3/5] i2c: pca-platform: add devicetree awareness

From: Andy Shevchenko
Date: Wed Jun 28 2017 - 05:20:52 EST


On Mon, Jun 26, 2017 at 3:44 AM, Chris Packham
<chris.packham@xxxxxxxxxxxxxxxxxxx> wrote:
> Allow devices that use this driver to be registered via a
> devicetree.

Device Tree

Wolfram was being a bit faster to apply it...
> +#include <linux/of.h>
> +#include <linux/of_device.h>

> + struct device_node *np = pdev->dev.of_node;

> /* If irq is 0, we do polling. */
> + if (irq < 0)
> + irq = 0;

This does not belong to what is written in commit message. Looks like
a separate fix.

> + i2c->adap.dev.of_node = np;

> + } else if (np) {

> + i2c->adap.timeout = HZ;
> + i2c->gpio = devm_gpiod_get_optional(&pdev->dev, "reset-gpios", GPIOD_OUT_LOW);
> + if (IS_ERR(i2c->gpio))
> + return PTR_ERR(i2c->gpio);
> + of_property_read_u32_index(np, "clock-frequency", 0,
> + &i2c->algo_data.i2c_clock);

And what prevents you to use device_property_read_*() here and get rid
of OFstuff?

> +#ifdef CONFIG_OF

Better not to put it...

> + .of_match_table = of_match_ptr(i2c_pca_of_match_table),

...and get rid of of_match_ptr().

--
With Best Regards,
Andy Shevchenko