Re: [patch 02/20] chardev: GPIO for SCx200: modernize char-dev initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jesper Juhl wrote:

Thanks Jesper!
On 12/06/06, Jim Cromie <jim.cromie@xxxxxxxxx> wrote:

Update the char-dev initialization code to use modern 2.6 API, ala LDD3.

[snip]
+extern void scx200_gpio_dump(unsigned index);
+
static ssize_t scx200_gpio_write(struct file *file, const char __user * data,
                                 size_t len, loff_t * ppos)

Kernel coding style is "loff_t *ppos", not "loff_t * ppos" - I can see
why you are not making that change here as it would be unrelated, but
perhaps you could clean stuff like that up as well - either in your
first "spring clean" patch
Ironically, it was scripts/Lindent that did that * ppos damage. :-/
I figured it was intended.

or as a sepperate patch at the end (or
maybe you have done that already, I haven't read all the patches
yet)...


[snip]
+       if (major)
+ rc = register_chrdev_region(dev, num_devs, "scx200_gpio");
+       else {
+ rc = alloc_chrdev_region(&dev, 0, num_devs, "scx200_gpio");
+               major = MAJOR(dev);
+       }
+       if (rc < 0) {
+ printk(KERN_ERR NAME ": SCx200 chrdev_region failure %d\n", rc);
+               return rc;

Here you return directly ...

+       }
+ scx200_devices = kzalloc(num_devs * sizeof(struct cdev), GFP_KERNEL);
+       if (!scx200_devices) {
+               rc = -ENOMEM;
+               goto fail_malloc;

But here you use a label at the end of the function.
Make up your mind, do you want the function to be 'single exit' or
'multiple exit'?  I'd suggest trying to be consistent (and single exit
is often nice).

IIRC, I returned cuz there was no undoing to do.
But I see your point,  and will regularize (with gotos).


[snip]
+      fail_malloc:

When indenting labels they are usually indented just one space...

ack.

thanks again.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux