From b05315ade7bfe7d7ec52433d769aa0cda5148bb5 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sat, 17 Jul 2004 22:55:05 +0000 Subject: [PATCH] list 10 insn limit on insn lists --- comedi/comedi_fops.c | 8 ++------ include/linux/sched.h | 7 +++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index 84139125..79fec01a 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -552,7 +552,6 @@ static int parse_insn(comedi_device *dev,comedi_insn *insn,lsampl_t *data,void * */ /* arbitrary limits */ #define MAX_SAMPLES 256 -#define MAX_INSNS 10 static int do_insnlist_ioctl(comedi_device *dev,void *arg,void *file) { comedi_insnlist insnlist; @@ -564,11 +563,6 @@ static int do_insnlist_ioctl(comedi_device *dev,void *arg,void *file) if(copy_from_user(&insnlist,arg,sizeof(comedi_insnlist))) return -EFAULT; - if(insnlist.n_insns>=MAX_INSNS){ - DPRINTK("insnlist too long\n"); - return -EINVAL; - } - data=kmalloc(sizeof(lsampl_t)*MAX_SAMPLES,GFP_KERNEL); if(!data){ DPRINTK("kmalloc failed\n"); @@ -618,6 +612,8 @@ static int do_insnlist_ioctl(comedi_device *dev,void *arg,void *file) goto error; } } + if(need_resched()) + schedule(); } error: diff --git a/include/linux/sched.h b/include/linux/sched.h index 753d54f7..5e040ddc 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -11,6 +11,13 @@ #define signal_pending(x) (((x)->signal) & (~(x)->blocked)) #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20) /* not sure exactly when need_resched() was added */ +static inline int need_resched(void) +{ + return current->need_resched; +} +#endif + #include_next #endif -- 2.26.2