[PATCH v2 5/6] ARM: mxs: add usb phy operations
Lin Tony-B19295
B19295 at freescale.com
Mon Jul 25 22:05:31 EDT 2011
> -----Original Message-----
> From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
> Sent: Monday, July 25, 2011 4:24 PM
> To: Lothar Waßmann
> Cc: Lin Tony-B19295; koen.beel.barco at gmail.com; linux-usb at vger.kernel.org;
> stern at rowland.harvard.edu; linux-arm-kernel at lists.infradead.org
> Subject: Re: [PATCH v2 5/6] ARM: mxs: add usb phy operations
>
> On Mon, Jul 25, 2011 at 09:15:23AM +0200, Lothar Waßmann wrote:
> > > + if (WARN_ON(ppriv->internal_phy_clk_already_on < 0))
> > > + printk(KERN_ERR "please check phy clock ON/OFF sequence\n"); }
>
> And there should be a blank line here.
>
> > > +static int fsl_usb_host_init(struct platform_device *pdev) {
> > > + struct mxc_usbh_platform_data *pdata = pdev->dev.platform_data;
> > > + struct mxs_usb_private_date *ppriv = pdata->ppriv;
> > > +
> > > + ppriv->phy_regs = ioremap(MX28_USBPHY1_BASE_ADDR, SZ_8K);
> > > + if (ppriv->phy_regs == NULL)
> > > + return -ENOMEM;
> > > +
> > > + ppriv->ctrl_regs = ioremap(MX28_USBCTRL1_BASE_ADDR, SZ_8K);
> > > + if (ppriv->ctrl_regs == NULL)
> > > + return -ENOMEM;
> > > +
> > What about proper cleanup in the error case?
>
> Doing something like this is probably easiest:
>
> ppriv->phy_regs = ioremap(MX28_USBPHY1_BASE_ADDR, SZ_8K);
> ppriv->ctrl_regs = ioremap(MX28_USBCTRL1_BASE_ADDR, SZ_8K);
> if (!ppriv->phy_regs || !ppriv_ctrl_regs) {
> iounmap(ppriv->phy_regs);
> iounmap(ppriv->ctrl_regs);
> return -ENOMEM;
> }
>
> As iounmap ignores NULL pointers.
good suggestion, thank you.
More information about the linux-arm-kernel
mailing list