From: Sonny Rao <sonnyrao@us.ibm.com>
To: Nathan Lynch <ntl@pobox.com>
Cc: sonnyrao@linux.vnet.ibm.com, paulus@samba.org, linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] Power5,Power6 BSR driver
Date: Tue, 17 Jun 2008 17:44:43 -0500 [thread overview]
Message-ID: <20080617224443.GD7552@localhost.localdomain> (raw)
In-Reply-To: <20080617223952.GA9594@localdomain>
On Tue, Jun 17, 2008 at 05:39:52PM -0500, Nathan Lynch wrote:
> Hi, mainly a couple of coding style things, but one minor bug (I
> think).
>
> jschopp@austin.ibm.com wrote:
> > From: Sonny Rao <sonnyrao@linux.vnet.ibm.com>
> >
> > +static int bsr_mmap(struct file *filp, struct vm_area_struct *vma)
> > +{
> > + unsigned long size = vma->vm_end - vma->vm_start;
> > + struct bsr_dev *dev = filp->private_data;
> > +
> > + if (size > dev->bsr_len || (size & (PAGE_SIZE-1)))
> > + return -EINVAL;
> > +
> > + vma->vm_flags |= (VM_IO | VM_DONTEXPAND);
> > + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> > +
> > + if (io_remap_pfn_range(vma, vma->vm_start, dev->bsr_addr >> PAGE_SHIFT,
> > + size, vma->vm_page_prot))
> > + return -EAGAIN;
>
> Indentation is wrong.
Yeah I noticed that too.
> > +static void bsr_cleanup_devs(void)
> > +{
> > + int i;
> > + for (i=0 ; i < num_bsr_devs; i++) {
>
> i = 0
>
> > + struct bsr_dev *cur = bsr_devs + i;
> > + if (cur->bsr_device) {
> > + cdev_del(&cur->bsr_cdev);
> > + device_del(cur->bsr_device);
> > + }
> > + }
> > +
> > + kfree(bsr_devs);
> > +}
> > +
> > +static int bsr_create_devs(struct device_node *bn)
> > +{
> > + int reg_len, bsr_stride_len, bsr_bytes_len;
> > + const u64 *reg;
> > + const u32 *bsr_stride;
> > + const u32 *bsr_bytes;
> > + unsigned i;
> > +
> > + reg = of_get_property(bn, "reg", ®_len);
> > + bsr_stride = of_get_property(bn, "ibm,lock-stride", &bsr_stride_len);
> > + bsr_bytes = of_get_property(bn, "ibm,#lock-bytes", &bsr_bytes_len);
> > +
> > + if (!reg || !bsr_stride || !bsr_bytes ||
> > + (bsr_stride_len != bsr_bytes_len) ||
> > + (bsr_stride_len/4 != reg_len/16)) {
>
> bsr_stride_len / 4 != reg_len / 16
>
>
> > + printk(KERN_ERR "bsr of-node has missing/incorrect property\n");
> > + return -ENODEV;
> > + }
>
> ...
>
> > +static int __init bsr_init(void)
> > +{
> > + struct device_node *np;
> > + dev_t bsr_dev = MKDEV(bsr_major, 0);
> > + int ret = -ENODEV;
> > + int result;
> > +
> > + np = of_find_compatible_node(NULL, "ibm,bsr", "ibm,bsr");
> > + if (!np)
> > + goto out_err;
> > +
> > + bsr_class = class_create(THIS_MODULE, "bsr");
> > + if (IS_ERR(bsr_class)) {
> > + printk(KERN_ERR "class_create() failed for bsr_class\n");
> > + goto out_err;
>
> At this point I think you can leak a reference to np.
Yeah, you're right.
>
> > + }
> > + bsr_class->dev_attrs = bsr_dev_attrs;
> > +
> > + result = alloc_chrdev_region(&bsr_dev, 0, BSR_MAX_DEVS, "bsr");
> > + bsr_major = MAJOR(bsr_dev);
> > + if (result < 0) {
> > + printk(KERN_ERR "alloc_chrdev_region() failed for bsr\n");
> > + goto out_err_1;
> > + }
> > +
> > + if ((ret = bsr_create_devs(np)) < 0)
> > + goto out_err_2;
> > +
> > + of_node_put(np);
> > +
> > + return 0;
> > +
> > + out_err_2:
> > + unregister_chrdev_region(bsr_dev, BSR_MAX_DEVS);
> > +
> > + out_err_1:
> > + class_destroy(bsr_class);
> > + of_node_put(np);
> > +
> > + out_err:
> > +
> > + return ret;
> > +}
Ok Will fix and send out again
--
Sonny Rao, LTC Ozlabs
next prev parent reply other threads:[~2008-06-18 7:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-16 18:53 [PATCH] Power5,Power6 BSR driver jschopp
2008-06-17 22:39 ` Nathan Lynch
2008-06-17 22:44 ` Sonny Rao [this message]
2008-06-18 6:51 ` Sonny Rao
2008-07-07 4:59 ` Benjamin Herrenschmidt
2008-07-07 21:17 ` Sonny Rao
2008-07-07 22:26 ` Benjamin Herrenschmidt
2008-07-08 2:58 ` [PATCHv3] " Sonny Rao
2008-07-08 4:52 ` Stephen Rothwell
2008-07-08 5:45 ` [PATCHv4] " Sonny Rao
2008-06-18 6:53 ` [PATCH] " Sonny Rao
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=20080617224443.GD7552@localhost.localdomain \
--to=sonnyrao@us.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=ntl@pobox.com \
--cc=paulus@samba.org \
--cc=sonnyrao@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.