Hi, Appana Durga Kedareswara Rao wrote: > Hi Marc, > > -----Original Message----- > From: Marc Kleine-Budde [mailto:m...@pengutronix.de] > Sent: Thursday, November 13, 2014 4:16 PM > To: Appana Durga Kedareswara Rao; w...@grandegger.com; Michal Simek; Soren > Brinkmann; grant.lik...@linaro.org; robh...@kernel.org > Cc: linux-...@vger.kernel.org; net...@vger.kernel.org; > linux-arm-ker...@lists.infradead.org; linux-kernel@vger.kernel.org; > devicet...@vger.kernel.org; Appana Durga Kedareswara Rao > Subject: Re: [PATCH] can: Fix bug in suspend/resume > > On 11/13/2014 11:15 AM, Marc Kleine-Budde wrote: > > On 11/13/2014 07:58 AM, Kedareswara rao Appana wrote: > >> When accessing the priv structure use container_of instead of > >> dev_get_drvdata. > > > > Why? > > The drvdata here is the struct net_device, not the platform device. > Please state this in the commit message. > > If I understand the code correct, you can make use of the existing helper > function to_platform_device(): > > http://lxr.free-electrons.com/source/include/linux/platform_device.h#L42 > > Thanks for the suggestion. > Will use this macro(to_platform_device) . > > > > >> Enable the clocks in the suspend before accessing the registers of the CAN. > >> > >> Signed-off-by: Kedareswara rao Appana <appa...@xilinx.com> > >> --- > >> drivers/net/can/xilinx_can.c | 20 ++++++++++++++++++-- > >> 1 files changed, 18 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/net/can/xilinx_can.c > >> b/drivers/net/can/xilinx_can.c index 5e8b560..63ef645 100644 > >> --- a/drivers/net/can/xilinx_can.c > >> +++ b/drivers/net/can/xilinx_can.c > >> @@ -972,15 +972,30 @@ static const struct net_device_ops xcan_netdev_ops = > >> { > >> */ > >> static int __maybe_unused xcan_suspend(struct device *dev) { > >> - struct platform_device *pdev = dev_get_drvdata(dev); > >> + struct platform_device *pdev = container_of(dev, > >> + struct platform_device, dev); > >> struct net_device *ndev = platform_get_drvdata(pdev); > >> struct xcan_priv *priv = netdev_priv(ndev); > Why not simply: struct net_device *ndev = dev_get_drvdata(dev);
There is no need for a struct platform_device* at all. Lothar Waßmann -- ___________________________________________________________ Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Geschäftsführer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | i...@karo-electronics.de ___________________________________________________________ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/