Re: drivers: Push down BKL into various drivers

From: Geert Uytterhoeven
Date: Sat Jun 05 2010 - 16:39:46 EST


On Mon, May 24, 2010 at 18:00, Linux Kernel Mailing List
<linux-kernel@xxxxxxxxxxxxxxx> wrote:
> diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
> index ad730e1..e00a1cc 100644
> --- a/drivers/input/misc/hp_sdc_rtc.c
> +++ b/drivers/input/misc/hp_sdc_rtc.c
> @@ -43,6 +43,7 @@
> Â#include <linux/proc_fs.h>
> Â#include <linux/poll.h>
> Â#include <linux/rtc.h>
> +#include <linux/smp_lock.h>
> Â#include <linux/semaphore.h>
>
> ÂMODULE_AUTHOR("Brian S. Julin <bri@xxxxxxxxx>");
> @@ -64,8 +65,8 @@ static DECLARE_WAIT_QUEUE_HEAD(hp_sdc_rtc_wait);
> Âstatic ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â size_t count, loff_t *ppos);
>
> -static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned int cmd, unsigned long arg);
> +static long hp_sdc_rtc_unlocked_ioctl(struct file *file,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned int cmd, unsigned long arg);
>
> Âstatic unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait);
>
> @@ -512,7 +513,7 @@ static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off,
> Â Â Â Â return len;
> Â}
>
> -static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
> +static int hp_sdc_rtc_ioctl(struct file *file,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Âunsigned int cmd, unsigned long arg)
> Â{
> Â#if 1
> @@ -659,14 +660,27 @@ static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
> Â#endif
> Â}
>
> +static long hp_sdc_rtc_unlocked_ioctl(struct file *file,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned int cmd, unsigned long arg)
> +{
> + Â Â Â int ret;
> +
> + Â Â Â lock_kernel();
> + Â Â Â ret = hp_sdc_rtc_ioctl(file, cmd, arg);
> + Â Â Â unlock_kernel();
> +
> + Â Â Â return ret;
> +}
> +
> +
> Âstatic const struct file_operations hp_sdc_rtc_fops = {
> - Â Â Â Â.owner = Â Â Â THIS_MODULE,
> - Â Â Â Â.llseek = Â Â Âno_llseek,
> - Â Â Â Â.read = Â Â Â Â Â Â Â Âhp_sdc_rtc_read,
> - Â Â Â Â.poll = Â Â Â Â Â Â Â Âhp_sdc_rtc_poll,
> - Â Â Â Â.ioctl = Â Â Â hp_sdc_rtc_ioctl,
> - Â Â Â Â.open = Â Â Â Â Â Â Â Âhp_sdc_rtc_open,
> - Â Â Â Â.fasync = Â Â Âhp_sdc_rtc_fasync,
> + Â Â Â Â.owner = Â Â Â Â Â Â Â THIS_MODULE,
> + Â Â Â Â.llseek = Â Â Â Â Â Â Âno_llseek,
> + Â Â Â Â.read = Â Â Â Â Â Â Â Â Â Â Â Âhp_sdc_rtc_read,
> + Â Â Â Â.poll = Â Â Â Â Â Â Â Â Â Â Â Âhp_sdc_rtc_poll,
> + Â Â Â Â.unlocked_ioctl = Â Â Âhp_sdc_rtc_ioctl,
> + Â Â Â Â.open = Â Â Â Â Â Â Â Â Â Â Â Âhp_sdc_rtc_open,
> + Â Â Â Â.fasync = Â Â Â Â Â Â Âhp_sdc_rtc_fasync,
> Â};
>
> Âstatic struct miscdevice hp_sdc_rtc_dev = {

Something went wrong with this one:

| drivers/input/misc/hp_sdc_rtc.c:681: warning: initialization from
incompatible pointer type
| drivers/input/misc/hp_sdc_rtc.c:665: warning:
âhp_sdc_rtc_unlocked_ioctlâ defined but not used

(detected while debugging my script to find compiler warning regressions)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/