net/fec: fix compile error introduced by dt support

Message ID 1301037238-4031-1-git-send-email-shawn.guo@linaro.org
State New
Headers show

Commit Message

Shawn Guo March 25, 2011, 7:13 a.m.
After fec dt support is added, the following compile error will be
seen when building a pure non-dt kernel.

drivers/net/fec.c: In function ‘fec_probe’:
drivers/net/fec.c:1383: error: implicit declaration of function ‘of_match_device’
drivers/net/fec.c:1383: warning: assignment makes pointer from integer without a cast

This patch is to fix the error.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/net/fec.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

Comments

Grant Likely March 31, 2011, 4:09 p.m. | #1
On Fri, Mar 25, 2011 at 03:13:58PM +0800, Shawn Guo wrote:
> After fec dt support is added, the following compile error will be
> seen when building a pure non-dt kernel.
> 
> drivers/net/fec.c: In function ‘fec_probe’:
> drivers/net/fec.c:1383: error: implicit declaration of function ‘of_match_device’
> drivers/net/fec.c:1383: warning: assignment makes pointer from integer without a cast

Earlier today I suggested fixing this by adding an empty
implementation of of_match_device, but I forgot that an .of_match
pointer has been added to struct device for exactly this purpose.  You
can use that instead.

That change is currently in mainline, but it has not been backported
to the Linaro 2.6.38 tree (yet).

g.

> 
> This patch is to fix the error.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/net/fec.c |   13 ++++++++++++-
>  1 files changed, 12 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/fec.c b/drivers/net/fec.c
> index b57f879..ffb1e75 100644
> --- a/drivers/net/fec.c
> +++ b/drivers/net/fec.c
> @@ -85,8 +85,19 @@ static const struct of_device_id fec_dt_ids[] = {
>  	{ .compatible = "fsl,imx51-fec", .data = &fec_devtype[0], },
>  	{},
>  };
> +
> +static const struct of_device_id *
> +fec_get_of_device_id(struct platform_device *pdev)
> +{
> +	return of_match_device(fec_dt_ids, &pdev->dev);
> +}
>  #else
>  #define fec_dt_ids NULL
> +static inline struct of_device_id *
> +fec_get_of_device_id(struct platform_device *pdev)
> +{
> +	return NULL;
> +}
>  #endif
>  
>  static unsigned char macaddr[ETH_ALEN];
> @@ -1380,7 +1391,7 @@ fec_probe(struct platform_device *pdev)
>  	struct resource *r;
>  	const struct of_device_id *of_id;
>  
> -	of_id = of_match_device(fec_dt_ids, &pdev->dev);
> +	of_id = fec_get_of_device_id(pdev);
>  	if (of_id)
>  		pdev->id_entry = (struct platform_device_id *)of_id->data;
>  
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> linaro-dev mailing list
> linaro-dev@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-dev
Shawn Guo April 1, 2011, 7:49 a.m. | #2
On Thu, Mar 31, 2011 at 10:09:40AM -0600, Grant Likely wrote:
> On Fri, Mar 25, 2011 at 03:13:58PM +0800, Shawn Guo wrote:
> > After fec dt support is added, the following compile error will be
> > seen when building a pure non-dt kernel.
> > 
> > drivers/net/fec.c: In function ‘fec_probe’:
> > drivers/net/fec.c:1383: error: implicit declaration of function ‘of_match_device’
> > drivers/net/fec.c:1383: warning: assignment makes pointer from integer without a cast
> 
> Earlier today I suggested fixing this by adding an empty
> implementation of of_match_device, but I forgot that an .of_match
> pointer has been added to struct device for exactly this purpose.  You
> can use that instead.
> 
> That change is currently in mainline, but it has not been backported
> to the Linaro 2.6.38 tree (yet).
> 
This simply is a fix to commit 54898b86fa9813313b3eb981c44610ff483b0067
"net/fec: add device tree matching support", which only sits on branch
devicetree/test-2.6.38 right now.  However, .of_match is not available
on that tree yet.  So I can not do anything until ether this patch
shows on devicetree/test or .of_match is back ported on
devicetree/test-2.6.38.  Or you can simply ignore this patch since I
just want let you know such a compile error.
Grant Likely April 5, 2011, 4:54 a.m. | #3
On Fri, Apr 01, 2011 at 03:49:16PM +0800, Shawn Guo wrote:
> On Thu, Mar 31, 2011 at 10:09:40AM -0600, Grant Likely wrote:
> > On Fri, Mar 25, 2011 at 03:13:58PM +0800, Shawn Guo wrote:
> > > After fec dt support is added, the following compile error will be
> > > seen when building a pure non-dt kernel.
> > > 
> > > drivers/net/fec.c: In function ‘fec_probe’:
> > > drivers/net/fec.c:1383: error: implicit declaration of function ‘of_match_device’
> > > drivers/net/fec.c:1383: warning: assignment makes pointer from integer without a cast
> > 
> > Earlier today I suggested fixing this by adding an empty
> > implementation of of_match_device, but I forgot that an .of_match
> > pointer has been added to struct device for exactly this purpose.  You
> > can use that instead.
> > 
> > That change is currently in mainline, but it has not been backported
> > to the Linaro 2.6.38 tree (yet).
> > 
> This simply is a fix to commit 54898b86fa9813313b3eb981c44610ff483b0067
> "net/fec: add device tree matching support", which only sits on branch
> devicetree/test-2.6.38 right now.  However, .of_match is not available
> on that tree yet.  So I can not do anything until ether this patch
> shows on devicetree/test or .of_match is back ported on
> devicetree/test-2.6.38.  Or you can simply ignore this patch since I
> just want let you know such a compile error.

Okay, of_match is in my devicetree/test branch now since I've rebased
to 2.6.38-rc1.  I'll happily take a fixup patch from you now.  :-)

g.

> 
> -- 
> Regards,
> Shawn
>
Shawn Guo May 5, 2011, 3:20 p.m. | #4
On Mon, Apr 04, 2011 at 10:54:00PM -0600, Grant Likely wrote:
> On Fri, Apr 01, 2011 at 03:49:16PM +0800, Shawn Guo wrote:
> > On Thu, Mar 31, 2011 at 10:09:40AM -0600, Grant Likely wrote:
> > > On Fri, Mar 25, 2011 at 03:13:58PM +0800, Shawn Guo wrote:
> > > > After fec dt support is added, the following compile error will be
> > > > seen when building a pure non-dt kernel.
> > > > 
> > > > drivers/net/fec.c: In function ‘fec_probe’:
> > > > drivers/net/fec.c:1383: error: implicit declaration of function ‘of_match_device’
> > > > drivers/net/fec.c:1383: warning: assignment makes pointer from integer without a cast
> > > 
> > > Earlier today I suggested fixing this by adding an empty
> > > implementation of of_match_device, but I forgot that an .of_match
> > > pointer has been added to struct device for exactly this purpose.  You
> > > can use that instead.
> > > 
> > > That change is currently in mainline, but it has not been backported
> > > to the Linaro 2.6.38 tree (yet).
> > > 
> > This simply is a fix to commit 54898b86fa9813313b3eb981c44610ff483b0067
> > "net/fec: add device tree matching support", which only sits on branch
> > devicetree/test-2.6.38 right now.  However, .of_match is not available
> > on that tree yet.  So I can not do anything until ether this patch
> > shows on devicetree/test or .of_match is back ported on
> > devicetree/test-2.6.38.  Or you can simply ignore this patch since I
> > just want let you know such a compile error.
> 
> Okay, of_match is in my devicetree/test branch now since I've rebased
> to 2.6.38-rc1.  I'll happily take a fixup patch from you now.  :-)
> 
Sorry, Grant.  I overlooked this reply, and noticed it when re-visiting
the thread today.  I just sent an updated patch.  Please take a look.

Patch

diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index b57f879..ffb1e75 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -85,8 +85,19 @@  static const struct of_device_id fec_dt_ids[] = {
 	{ .compatible = "fsl,imx51-fec", .data = &fec_devtype[0], },
 	{},
 };
+
+static const struct of_device_id *
+fec_get_of_device_id(struct platform_device *pdev)
+{
+	return of_match_device(fec_dt_ids, &pdev->dev);
+}
 #else
 #define fec_dt_ids NULL
+static inline struct of_device_id *
+fec_get_of_device_id(struct platform_device *pdev)
+{
+	return NULL;
+}
 #endif
 
 static unsigned char macaddr[ETH_ALEN];
@@ -1380,7 +1391,7 @@  fec_probe(struct platform_device *pdev)
 	struct resource *r;
 	const struct of_device_id *of_id;
 
-	of_id = of_match_device(fec_dt_ids, &pdev->dev);
+	of_id = fec_get_of_device_id(pdev);
 	if (of_id)
 		pdev->id_entry = (struct platform_device_id *)of_id->data;