[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140507172941.66aca8fa@alan.etchedpixels.co.uk>
Date: Wed, 7 May 2014 17:29:41 +0100
From: One Thousand Gnomes <gnomes@...rguk.ukuu.org.uk>
To: Pali Rohár <pali.rohar@...il.com>
Cc: Matthew Garrett <matthew.garrett@...ula.com>,
Randy Dunlap <rdunlap@...radead.org>,
linux-kernel@...r.kernel.org, platform-driver-x86@...r.kernel.org,
linux-doc@...r.kernel.org, Sonal Santan <sonal.santan@...il.com>
Subject: Re: [PATCH 1/2] platform: x86: dell-smo8800: Dell Latitude freefall
driver (ACPI SMO8800/SMO8810)
> +static irqreturn_t smo8800_interrupt_quick(int irq, void *data)
> +{
> + struct smo8800_device *smo8800 = data;
> + atomic_inc(&smo8800->count);
> + wake_up_interruptible(&smo8800->misc_wait);
> + return IRQ_WAKE_THREAD;
> +}
> +
> +static irqreturn_t smo8800_interrupt_thread(int irq, void *data)
> +{
> + struct smo8800_device *smo8800 = data;
> + dev_info(smo8800->dev, "detected free fall\n");
printk should be fast enough not to justify a thread, in fact the
threaded IRQ overhead is going to be higher than the printk IMHO.
I'm not entirely sure a printk is the useful response here either ?
> +static ssize_t smo8800_misc_read(struct file *file, char __user *buf,
> + size_t count, loff_t *pos)
> +{
> + struct smo8800_device *smo8800 = container_of(file->private_data,
> + struct smo8800_device, miscdev);
> +
> + DECLARE_WAITQUEUE(wait, current);
> + u32 data;
> + unsigned char byte_data;
> + ssize_t retval = 1;
> +
> + if (count < 1)
> + return -EINVAL;
How can this occur ??
> +
> + add_wait_queue(&smo8800->misc_wait, &wait);
> + while (true) {
> + set_current_state(TASK_INTERRUPTIBLE);
> + data = atomic_xchg(&smo8800->count, 0);
> + if (data)
> + break;
> +
> + if (file->f_flags & O_NONBLOCK) {
> + retval = -EAGAIN;
> + goto out;
> + }
> +
> + if (signal_pending(current)) {
> + retval = -ERESTARTSYS;
> + goto out;
> + }
> +
> + schedule();
> + }
wait_event_interruptible ?
> + if (copy_to_user(buf, &byte_data, sizeof(byte_data)))
> + retval = -EFAULT;
put_user
> +static int smo8800_add(struct acpi_device *device)
> +{
> + int err;
> + struct smo8800_device *smo8800;
> +
> + if (!device)
> + return -EINVAL;
How can this occur ??
> + atomic_set(&smo8800->count, 0);
Not needed - you can't see a count until it is open
> + dev_info(&device->dev, "device /dev/freefall registered with IRQ %d\n",
> + smo8800->irq);
dev_dbg would be more appropriate. If every driver reported its
registration we'd drown in logs
> + dev_info(&device->dev, "device /dev/freefall unregistered\n");
Ditto
Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists