linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Josh Boyer <jwboyer@linux.vnet.ibm.com>
To: Rupjyoti Sarmah <rsarmah@amcc.com>
Cc: linuxppc-dev@ozlabs.org, rsarmah@apm.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5] ppc44x:PHY fixup for USB on canyonlands board
Date: Fri, 10 Dec 2010 08:39:05 -0500	[thread overview]
Message-ID: <20101210133905.GE1903@zod.rchland.ibm.com> (raw)
In-Reply-To: <201012090424.oB94O1DV006463@amcc.com>

On Thu, Dec 09, 2010 at 09:54:01AM +0530, Rupjyoti Sarmah wrote:

A few error path issues, plus one leak in the good case.  I'll wait to
see if there are any more comments for a couple of days.

>+static int __init ppc460ex_canyonlands_fixup(void)
>+{
>+	u8 __iomem *bcsr ;
>+	void __iomem *vaddr;
>+	struct device_node *np;
>+	int ret = 0;
>+
>+	np = of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-bcsr");
>+	if (!np) {
>+		printk(KERN_ERR "failed did not find amcc, ppc460ex bcsr node\n");
>+		return -ENODEV;
>+	}
>+
>+	bcsr = of_iomap(np, 0);
>+	of_node_put(np);
>+
>+	if (!bcsr) {
>+		printk(KERN_CRIT "Could not remap bcsr\n");
>+		ret = -ENODEV;
>+	}
>+
>+	np = of_find_compatible_node(NULL, NULL, "ibm,ppc4xx-gpio");

This can fail if you boot a new kernel on a board with an old FDT that
lacks the gpio node.  Calling of_iomap with a NULL np seems like it
would work without crashing anything, so maybe that's not a huge issue.

>+	vaddr = of_iomap(np, 0);
>+	if (!vaddr) {
>+		printk(KERN_CRIT "Could not get gpio node address\n");
>+		ret = -ENODEV;
>+		goto err_bcsr;
>+	}

A reference count is leaked for the node in this error case because
of_node_put isn't called for the gpio node.  Also, iounmap is never
called on vaddr.

>+	/* Disable USB, through the BCSR7 bits */
>+	setbits8(&bcsr[7], BCSR_USB_EN);
>+
>+	/* Wait for a while after reset */
>+	msleep(100);
>+
>+	/* Enable USB here */
>+	clrbits8(&bcsr[7], BCSR_USB_EN);
>+
>+	/*
>+	 * Configure multiplexed gpio16 and gpio19 as alternate1 output
>+	 * source after USB reset. In this configuration gpio16 will be
>+	 * USB2HStop and gpio19 will be USB2DStop. For more details refer to
>+	 * table 34-7 of PPC460EX user manual.
>+	 */
>+	setbits32((vaddr + GPIO0_OSRH), 0x42000000);
>+	setbits32((vaddr + GPIO0_TSRH), 0x42000000);
>+	of_node_put(np);
>+err_bcsr:
>+	iounmap(bcsr);
>+	return ret;
>+}
>+machine_device_initcall(canyonlands, ppc460ex_canyonlands_fixup);

josh

  reply	other threads:[~2010-12-10 13:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-09  4:24 [PATCH v5] ppc44x:PHY fixup for USB on canyonlands board Rupjyoti Sarmah
2010-12-10 13:39 ` Josh Boyer [this message]
2010-12-13  7:17   ` Rupjyoti Sarmah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101210133905.GE1903@zod.rchland.ibm.com \
    --to=jwboyer@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=rsarmah@amcc.com \
    --cc=rsarmah@apm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).