[PATCH] i2c: tegra: Fix compile when !CONFIG_OF

Grant Likely grant.likely at secretlab.ca
Thu Jul 14 08:48:25 EST 2011


On Thu, Jul 14, 2011 at 5:36 AM, Stephen Warren <swarren at nvidia.com> wrote:
> When !CONFIG_OF, <linux/of.h> doesn't prototype of_get_property(), which
> causes i2c-tegra.c to fail to compile. Make the references to this
> function conditional to solve this.
>
> Signed-off-by: Stephen Warren <swarren at nvidia.com>
> ---
> Grant, is this the correct way to solve this? Other solutions I can see are:
> a) Make ARM or Tegra select CONFIG_OF, now that ARM is moving to Device Tree.
> b) Make <linux/of.h> provide dummy inline versions of its functions when
>   !CONFIG_OF.

The solution you chose is sufficient for now, but turning on CONFIG_OF
unconditionally for Tegra would be fine too since I hope to get the
tegra board-dt patch merged for 3.1 (I hope to have the patch cleaned
up and posted in the next 24 hrs).  I've been avoiding creating a
dummy inline of of_get_property(), but not for any particularly strong
reason other than to avoid bloating linux/of.h.  I probably would
accept a patch that added it.

Acked-by: Grant Likely <grant.likely at secretlab.ca>

g.

>
>  drivers/i2c/busses/i2c-tegra.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index 2440b74..5a18d6d 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -610,12 +610,15 @@ static int tegra_i2c_probe(struct platform_device *pdev)
>        if (pdata) {
>                i2c_dev->bus_clk_rate = pdata->bus_clk_rate;
>
> -       } else if (i2c_dev->dev->of_node) {    /* if there is a device tree node ... */
> +       }
> +#ifdef CONFIG_OF
> +       else if (i2c_dev->dev->of_node) {    /* if there is a device tree node ... */
>                prop = of_get_property(i2c_dev->dev->of_node,
>                                "clock-frequency", NULL);
>                if (prop)
>                        i2c_dev->bus_clk_rate = be32_to_cpup(prop);
>        }
> +#endif
>
>        if (pdev->id == 3)
>                i2c_dev->is_dvc = 1;
> --
> 1.7.0.4
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.


More information about the devicetree-discuss mailing list