Skip to content

Commit

Permalink
Staging: Comedi: Lindent changes to comdi driver in staging tree
Browse files Browse the repository at this point in the history
Lindent changes to comdi driver in staging tree.
This patch is followed by the checkpatch.pl error fixes.
Did not make them part of this patch as the patch size is already huge.

Signed-off-by: Mithlesh Thukral <mithlesh@linsyssoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Mithlesh Thukral authored and Greg Kroah-Hartman committed Sep 15, 2009
1 parent df67856 commit 0a85b6f
Show file tree
Hide file tree
Showing 133 changed files with 14,808 additions and 12,927 deletions.
1,002 changes: 490 additions & 512 deletions drivers/staging/comedi/comedi.h

Large diffs are not rendered by default.

115 changes: 57 additions & 58 deletions drivers/staging/comedi/comedi_compat32.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
struct comedi32_chaninfo_struct {
unsigned int subdev;
compat_uptr_t maxdata_list; /* 32-bit 'unsigned int *' */
compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */
compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */
compat_uptr_t rangelist; /* 32-bit 'unsigned int *' */
unsigned int unused[4];
};
Expand All @@ -74,36 +74,36 @@ struct comedi32_cmd_struct {
unsigned int scan_end_arg;
unsigned int stop_src;
unsigned int stop_arg;
compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */
compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */
unsigned int chanlist_len;
compat_uptr_t data; /* 32-bit 'short *' */
compat_uptr_t data; /* 32-bit 'short *' */
unsigned int data_len;
};

struct comedi32_insn_struct {
unsigned int insn;
unsigned int n;
compat_uptr_t data; /* 32-bit 'unsigned int *' */
compat_uptr_t data; /* 32-bit 'unsigned int *' */
unsigned int subdev;
unsigned int chanspec;
unsigned int unused[3];
};

struct comedi32_insnlist_struct {
unsigned int n_insns;
compat_uptr_t insns; /* 32-bit 'struct comedi_insn *' */
compat_uptr_t insns; /* 32-bit 'struct comedi_insn *' */
};

/* Handle translated ioctl. */
static int translated_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
unsigned long arg)
{
if (!file->f_op)
return -ENOTTY;

#ifdef HAVE_UNLOCKED_IOCTL
if (file->f_op->unlocked_ioctl) {
int rc = (int)(*file->f_op->unlocked_ioctl)(file, cmd, arg);
int rc = (int)(*file->f_op->unlocked_ioctl) (file, cmd, arg);
if (rc == -ENOIOCTLCMD)
rc = -ENOTTY;
return rc;
Expand All @@ -112,8 +112,8 @@ static int translated_ioctl(struct file *file, unsigned int cmd,
if (file->f_op->ioctl) {
int rc;
lock_kernel();
rc = (*file->f_op->ioctl)(file->f_dentry->d_inode,
file, cmd, arg);
rc = (*file->f_op->ioctl) (file->f_dentry->d_inode,
file, cmd, arg);
unlock_kernel();
return rc;
}
Expand All @@ -136,8 +136,7 @@ static int compat_chaninfo(struct file *file, unsigned long arg)

/* Copy chaninfo structure. Ignore unused members. */
if (!access_ok(VERIFY_READ, chaninfo32, sizeof(*chaninfo32))
|| !access_ok(VERIFY_WRITE, chaninfo,
sizeof(*chaninfo))) {
|| !access_ok(VERIFY_WRITE, chaninfo, sizeof(*chaninfo))) {
return -EFAULT;
}
err = 0;
Expand Down Expand Up @@ -171,8 +170,7 @@ static int compat_rangeinfo(struct file *file, unsigned long arg)

/* Copy rangeinfo structure. */
if (!access_ok(VERIFY_READ, rangeinfo32, sizeof(*rangeinfo32))
|| !access_ok(VERIFY_WRITE, rangeinfo,
sizeof(*rangeinfo))) {
|| !access_ok(VERIFY_WRITE, rangeinfo, sizeof(*rangeinfo))) {
return -EFAULT;
}
err = 0;
Expand All @@ -184,12 +182,12 @@ static int compat_rangeinfo(struct file *file, unsigned long arg)
return -EFAULT;

return translated_ioctl(file, COMEDI_RANGEINFO,
(unsigned long)rangeinfo);
(unsigned long)rangeinfo);
}

/* Copy 32-bit cmd structure to native cmd structure. */
static int get_compat_cmd(struct comedi_cmd __user *cmd,
struct comedi32_cmd_struct __user *cmd32)
static int get_compat_cmd(struct comedi_cmd __user * cmd,
struct comedi32_cmd_struct __user * cmd32)
{
int err;
union {
Expand All @@ -199,7 +197,7 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,

/* Copy cmd structure. */
if (!access_ok(VERIFY_READ, cmd32, sizeof(*cmd32))
|| !access_ok(VERIFY_WRITE, cmd, sizeof(*cmd))) {
|| !access_ok(VERIFY_WRITE, cmd, sizeof(*cmd))) {
return -EFAULT;
}
err = 0;
Expand Down Expand Up @@ -239,7 +237,8 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
}

/* Copy native cmd structure to 32-bit cmd structure. */
static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32, struct comedi_cmd __user *cmd)
static int put_compat_cmd(struct comedi32_cmd_struct __user * cmd32,
struct comedi_cmd __user * cmd)
{
int err;
unsigned int temp;
Expand All @@ -249,7 +248,7 @@ static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32, struct comed
/* (Could use ptr_to_compat() to set them, but that wasn't implemented
* until kernel version 2.6.11.) */
if (!access_ok(VERIFY_READ, cmd, sizeof(*cmd))
|| !access_ok(VERIFY_WRITE, cmd32, sizeof(*cmd32))) {
|| !access_ok(VERIFY_WRITE, cmd32, sizeof(*cmd32))) {
return -EFAULT;
}
err = 0;
Expand Down Expand Up @@ -329,8 +328,8 @@ static int compat_cmdtest(struct file *file, unsigned long arg)
}

/* Copy 32-bit insn structure to native insn structure. */
static int get_compat_insn(struct comedi_insn __user *insn,
struct comedi32_insn_struct __user *insn32)
static int get_compat_insn(struct comedi_insn __user * insn,
struct comedi32_insn_struct __user * insn32)
{
int err;
union {
Expand All @@ -341,7 +340,7 @@ static int get_compat_insn(struct comedi_insn __user *insn,
/* Copy insn structure. Ignore the unused members. */
err = 0;
if (!access_ok(VERIFY_READ, insn32, sizeof(*insn32))
|| !access_ok(VERIFY_WRITE, insn, sizeof(*insn)))
|| !access_ok(VERIFY_WRITE, insn, sizeof(*insn)))
return -EFAULT;

err |= __get_user(temp.uint, &insn32->insn);
Expand Down Expand Up @@ -385,7 +384,7 @@ static int compat_insnlist(struct file *file, unsigned long arg)

/* Allocate user memory to copy insnlist and insns into. */
s = compat_alloc_user_space(offsetof(struct combined_insnlist,
insn[n_insns]));
insn[n_insns]));

/* Set native insnlist structure. */
if (!access_ok(VERIFY_WRITE, &s->insnlist, sizeof(s->insnlist))) {
Expand All @@ -404,7 +403,7 @@ static int compat_insnlist(struct file *file, unsigned long arg)
}

return translated_ioctl(file, COMEDI_INSNLIST,
(unsigned long)&s->insnlist);
(unsigned long)&s->insnlist);
}

/* Handle 32-bit COMEDI_INSN ioctl. */
Expand All @@ -427,7 +426,7 @@ static int compat_insn(struct file *file, unsigned long arg)
/* Process untranslated ioctl. */
/* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */
static inline int raw_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
unsigned long arg)
{
int rc;

Expand Down Expand Up @@ -477,8 +476,7 @@ static inline int raw_ioctl(struct file *file, unsigned int cmd,

/* compat_ioctl file operation. */
/* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */
long comedi_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
long comedi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
return raw_ioctl(file, cmd, arg);
}
Expand All @@ -497,7 +495,7 @@ long comedi_compat_ioctl(struct file *file, unsigned int cmd,

/* Handler for all 32-bit ioctl codes registered by this driver. */
static int mapped_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
struct file *file)
struct file *file)
{
int rc;

Expand All @@ -515,27 +513,27 @@ static int mapped_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,

struct ioctl32_map {
unsigned int cmd;
int (*handler)(unsigned int, unsigned int, unsigned long,
int (*handler) (unsigned int, unsigned int, unsigned long,
struct file *);
int registered;
};

static struct ioctl32_map comedi_ioctl32_map[] = {
{ COMEDI_DEVCONFIG, mapped_ioctl, 0 },
{ COMEDI_DEVINFO, mapped_ioctl, 0 },
{ COMEDI_SUBDINFO, mapped_ioctl, 0 },
{ COMEDI_BUFCONFIG, mapped_ioctl, 0 },
{ COMEDI_BUFINFO, mapped_ioctl, 0 },
{ COMEDI_LOCK, mapped_ioctl, 0 },
{ COMEDI_UNLOCK, mapped_ioctl, 0 },
{ COMEDI_CANCEL, mapped_ioctl, 0 },
{ COMEDI_POLL, mapped_ioctl, 0 },
{ COMEDI32_CHANINFO, mapped_ioctl, 0 },
{ COMEDI32_RANGEINFO, mapped_ioctl, 0 },
{ COMEDI32_CMD, mapped_ioctl, 0 },
{ COMEDI32_CMDTEST, mapped_ioctl, 0 },
{ COMEDI32_INSNLIST, mapped_ioctl, 0 },
{ COMEDI32_INSN, mapped_ioctl, 0 },
{COMEDI_DEVCONFIG, mapped_ioctl, 0},
{COMEDI_DEVINFO, mapped_ioctl, 0},
{COMEDI_SUBDINFO, mapped_ioctl, 0},
{COMEDI_BUFCONFIG, mapped_ioctl, 0},
{COMEDI_BUFINFO, mapped_ioctl, 0},
{COMEDI_LOCK, mapped_ioctl, 0},
{COMEDI_UNLOCK, mapped_ioctl, 0},
{COMEDI_CANCEL, mapped_ioctl, 0},
{COMEDI_POLL, mapped_ioctl, 0},
{COMEDI32_CHANINFO, mapped_ioctl, 0},
{COMEDI32_RANGEINFO, mapped_ioctl, 0},
{COMEDI32_CMD, mapped_ioctl, 0},
{COMEDI32_CMDTEST, mapped_ioctl, 0},
{COMEDI32_INSNLIST, mapped_ioctl, 0},
{COMEDI32_INSN, mapped_ioctl, 0},
};

#define NUM_IOCTL32_MAPS ARRAY_SIZE(comedi_ioctl32_map)
Expand All @@ -547,13 +545,13 @@ void comedi_register_ioctl32(void)

for (n = 0; n < NUM_IOCTL32_MAPS; n++) {
rc = register_ioctl32_conversion(comedi_ioctl32_map[n].cmd,
comedi_ioctl32_map[n].handler);
comedi_ioctl32_map[n].handler);
if (rc) {
printk(KERN_WARNING
"comedi: failed to register 32-bit "
"compatible ioctl handler for 0x%X - "
"expect bad things to happen!\n",
comedi_ioctl32_map[n].cmd);
"comedi: failed to register 32-bit "
"compatible ioctl handler for 0x%X - "
"expect bad things to happen!\n",
comedi_ioctl32_map[n].cmd);
}
comedi_ioctl32_map[n].registered = !rc;
}
Expand All @@ -566,22 +564,23 @@ void comedi_unregister_ioctl32(void)

for (n = 0; n < NUM_IOCTL32_MAPS; n++) {
if (comedi_ioctl32_map[n].registered) {
rc = unregister_ioctl32_conversion(
comedi_ioctl32_map[n].cmd,
comedi_ioctl32_map[n].handler);
rc = unregister_ioctl32_conversion(comedi_ioctl32_map
[n].cmd,
comedi_ioctl32_map
[n].handler);
if (rc) {
printk(KERN_ERR
"comedi: failed to unregister 32-bit "
"compatible ioctl handler for 0x%X - "
"expect kernel Oops!\n",
comedi_ioctl32_map[n].cmd);
"comedi: failed to unregister 32-bit "
"compatible ioctl handler for 0x%X - "
"expect kernel Oops!\n",
comedi_ioctl32_map[n].cmd);
} else {
comedi_ioctl32_map[n].registered = 0;
}
}
}
}

#endif /* HAVE_COMPAT_IOCTL */
#endif /* HAVE_COMPAT_IOCTL */

#endif /* CONFIG_COMPAT */
#endif /* CONFIG_COMPAT */
4 changes: 2 additions & 2 deletions drivers/staging/comedi/comedi_compat32.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
#define _COMEDI_COMPAT32_H

#include <linux/compat.h>
#include <linux/fs.h> /* For HAVE_COMPAT_IOCTL and HAVE_UNLOCKED_IOCTL */
#include <linux/fs.h> /* For HAVE_COMPAT_IOCTL and HAVE_UNLOCKED_IOCTL */

#ifdef CONFIG_COMPAT

#ifdef HAVE_COMPAT_IOCTL

extern long comedi_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg);
unsigned long arg);
#define comedi_register_ioctl32() do {} while (0)
#define comedi_unregister_ioctl32() do {} while (0)

Expand Down
Loading

0 comments on commit 0a85b6f

Please sign in to comment.