public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Mark Gross <mgross@linux.intel.com>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org,
	Sebastien.Bouchard@ca.kontron.com, mark.gross@intel.com
Subject: Re: Fwd: Telecom Clock Driver for MPCBL0010 ATCA computer blade
Date: Thu, 6 Oct 2005 11:20:22 -0700	[thread overview]
Message-ID: <20051006182022.GA14414@kroah.com> (raw)
In-Reply-To: <200510060803.21470.mgross@linux.intel.com>

On Thu, Oct 06, 2005 at 08:03:21AM -0700, Mark Gross wrote:
> +#if CONFIG_DEBUG_KERNEL 
> +#define debug_printk( args... ) printk( args)
> +#else
> +#define debug_printk( args... )
> +#endif

Please just use the existing dev_dbg() and friend functions instead of
creating your own.

> +DEFINE_SPINLOCK(event_lock);

This should be static, right?

> +irqreturn_t tlclk_interrupt(int irq, void *dev_id, struct pt_regs *regs);

static?

> +DECLARE_WAIT_QUEUE_HEAD(wq);

static?

> +#ifdef TLCLK_IOCTL

Please just delete this whole section, no new ioctls for 2.6 please.

> +ssize_t
> +tlclk_read(struct file * filp, char __user * buf, size_t count, loff_t * f_pos)

Return type on the same line as the function name please.

> +{
> +	int count0 = sizeof(struct tlclk_alarms);
> +
> +	wait_event_interruptible(wq, got_event);
> +	if (copy_to_user(buf, alarm_events, sizeof(struct tlclk_alarms)))
> +		return -EFAULT;
> +
> +	memset(alarm_events, 0, sizeof(struct tlclk_alarms));
> +	got_event = 0;
> +
> +	return count0;

count0 doesn't really need to be here, does it?

What if you get passed less than that size of data?  You will be reading
in off of the end of the buffer (which is not a nice thing to do...)

> +#ifdef CONFIG_SYSFS

Not needed, just drop this #ifdef please.

> +static ssize_t show_current_ref(struct class_device *d, char * buf)
> +{
> +	unsigned long ret_val;
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&event_lock, flags);
> +		ret_val = ((inb(TLCLK_REG1) & 0x08) >> 3);
> +	spin_unlock_irqrestore(&event_lock, flags);

Odd indentation here.  You do this a lot, please fix them all.

> +static int __init tlclk_init(void)
> +{
> +	int ret;
> +#ifdef  CONFIG_SYSFS
> +	struct class_device *class;
> +#endif

Again, please drop all of the #ifdefs from this file, they are not
needed.

> +	alarm_events = kcalloc(1, sizeof(struct tlclk_alarms), GFP_KERNEL);

We have kzalloc() now.

> +
> +	if (!alarm_events)
> +		goto out1;
> +
> +/* Read telecom clock IRQ number (Set by BIOS) */

Indentation is wrong.

> +	if( 0 > (ret = misc_register(&tlclk_miscdev )) ) {

Try this instead:
	ret = misc_register(&tlclk_miscdev);
	if (ret) {

> +		printk(KERN_ERR" misc_register retruns %d \n", ret);
> +		ret =  -EBUSY;
> +		goto out3;
> +	}
> +	class = tlclk_miscdev.class;
> +	class_device_create_file(class, &class_device_attr_current_ref);

Try registering a whole attribute group instead.  It's much nicer than
the 20 lines you have to register and unregister your devices (and you
don't handle the error condition properly if something goes wrong half
way through.)

> diff -urN -X dontdiff linux-2.6.14-rc2-mm2/drivers/char/tlclk.h linux-2.6.14-rc2-mm2-tlclk/drivers/char/tlclk.h

Why not just put this stuff into the tlclk.c file itself, as it isn't
needed anywhere else?

thanks,

greg k-h

  parent reply	other threads:[~2005-10-06 18:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-06 15:03 Fwd: Telecom Clock Driver for MPCBL0010 ATCA computer blade Mark Gross
2005-10-06 16:52 ` Jesper Juhl
2005-10-06 17:28   ` Mark Gross
2005-10-07 12:21     ` Jesper Juhl
2005-10-06 17:24 ` Fwd: " Alexey Dobriyan
2005-10-06 17:31   ` Mark Gross
2005-10-06 18:20 ` Greg KH [this message]
2005-10-06 22:54   ` Mark Gross
2005-10-06 23:15     ` Greg KH
2005-10-12 22:30       ` Mark Gross
2005-10-12 22:49         ` Greg KH
2005-10-12 23:36           ` Mark Gross
2005-10-13  1:14             ` Greg KH
2005-10-13 21:36               ` Mark Gross
2005-10-13 22:08                 ` Jesper Juhl
2005-10-13 22:40                   ` Greg KH
     [not found]                     ` <9a8748490510131547s127f3167j6c9427ff3d97f878@mail.gmail.com>
     [not found]                       ` <20051014001547.GA4647@kroah.com>
2005-10-14  1:28                         ` Jesper Juhl
2005-10-06 23:45     ` Alexey Dobriyan

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=20051006182022.GA14414@kroah.com \
    --to=greg@kroah.com \
    --cc=Sebastien.Bouchard@ca.kontron.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.gross@intel.com \
    --cc=mgross@linux.intel.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