Module: xenomai-head Branch: master Commit: d3a4ec4ad0e7d181fc003cee13124cf77e73fe9e URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=d3a4ec4ad0e7d181fc003cee13124cf77e73fe9e
Author: Alexis Berlemont <alexis.berlem...@gmail.com> Date: Sun Sep 20 16:03:20 2009 +0200 Remove useless wrappers (comedi_copy_*_user()) --- include/comedi/buffer.h | 14 ++++---- include/comedi/context.h | 10 +----- include/comedi/os_facilities.h | 20 ------------ ksrc/drivers/comedi/buffer.c | 27 ++++++++++------- ksrc/drivers/comedi/command.c | 11 ++++--- ksrc/drivers/comedi/device.c | 23 +++++++------- ksrc/drivers/comedi/instruction.c | 18 ++++++----- ksrc/drivers/comedi/subdevice.c | 61 +++++++++++++++++++----------------- 8 files changed, 85 insertions(+), 99 deletions(-) diff --git a/include/comedi/buffer.h b/include/comedi/buffer.h index 81298dd..8b3a954 100644 --- a/include/comedi/buffer.h +++ b/include/comedi/buffer.h @@ -95,9 +95,9 @@ static inline int __produce(comedi_cxt_t * cxt, if (cxt == NULL) memcpy(buf->buf + start_ptr, pin, blk_size); else - ret = comedi_copy_from_user(cxt, - buf->buf + start_ptr, - pin, blk_size); + ret = rtdm_safe_copy_from_user(cxt->user_info, + buf->buf + start_ptr, + pin, blk_size); /* Updates pointers/counts */ pin += blk_size; @@ -125,10 +125,10 @@ static inline int __consume(comedi_cxt_t * cxt, if (cxt == NULL) memcpy(pout, buf->buf + start_ptr, blk_size); else - ret = comedi_copy_to_user(cxt, - pout, - buf->buf + start_ptr, - blk_size); + ret = rtdm_safe_copy_to_user(cxt->user_info, + pout, + buf->buf + start_ptr, + blk_size); /* Updates pointers/counts */ pout += blk_size; diff --git a/include/comedi/context.h b/include/comedi/context.h index 3670d69..e9c2d08 100644 --- a/include/comedi/context.h +++ b/include/comedi/context.h @@ -35,7 +35,7 @@ struct comedi_context { setting it at the head of the structure may save useless operations */ struct comedi_device *dev; - rtdm_user_info_t *rtdm_usrinf; + rtdm_user_info_t *user_info; struct rtdm_dev_context *rtdm_cxt; }; typedef struct comedi_context comedi_cxt_t; @@ -45,16 +45,10 @@ typedef struct comedi_context comedi_cxt_t; #define comedi_init_cxt(c, u, x) \ { \ (x)->rtdm_cxt = c; \ - (x)->rtdm_usrinf = u; \ + (x)->user_info = u; \ (x)->dev = NULL; \ } -#define comedi_copy_from_user(x, d, r, s) \ - __comedi_copy_from_user(x->rtdm_usrinf, d, r, s) - -#define comedi_copy_to_user(x, d, r, s) \ - __comedi_copy_to_user(x->rtdm_usrinf, d, r, s) - #endif /* __KERNEL__ && !DOXYGEN_CPP */ #endif /* __COMEDI_CONTEXT__ */ diff --git a/include/comedi/os_facilities.h b/include/comedi/os_facilities.h index e9315b7..405c9d4 100644 --- a/include/comedi/os_facilities.h +++ b/include/comedi/os_facilities.h @@ -87,26 +87,6 @@ #define comedi_dbg(level, debug, dev, fmt, args...) \ __comedi_dbg(level, debug, "%s: " fmt, __comedi_dev_name(dev), ##args) -/* --- Allocation / MMU section --- */ - -static inline int __comedi_copy_from_user(rtdm_user_info_t * user_info, - void *pind, void *pins, int size) -{ - if (rtdm_read_user_ok(user_info, pins, size)) - return rtdm_copy_from_user(user_info, pind, pins, size); - else - return -EFAULT; -} - -static inline int __comedi_copy_to_user(rtdm_user_info_t * user_info, - void *pind, void *pins, int size) -{ - if (rtdm_rw_user_ok(user_info, pind, size)) - return rtdm_copy_to_user(user_info, pind, pins, size); - else - return -EFAULT; -} - /* --- Spinlock section --- */ typedef rtdm_lock_t comedi_lock_t; diff --git a/ksrc/drivers/comedi/buffer.c b/ksrc/drivers/comedi/buffer.c index 27696d8..d5afc67 100644 --- a/ksrc/drivers/comedi/buffer.c +++ b/ksrc/drivers/comedi/buffer.c @@ -397,8 +397,8 @@ int comedi_ioctl_mmap(comedi_cxt_t * cxt, void *arg) return -EPERM; /* Recovers the argument structure */ - if (comedi_copy_from_user(cxt, - &map_cfg, arg, sizeof(comedi_mmap_t)) != 0) + if (rtdm_safe_copy_from_user(cxt->user_info, + &map_cfg, arg, sizeof(comedi_mmap_t)) != 0) return -EFAULT; /* Checks the subdevice */ @@ -419,7 +419,7 @@ int comedi_ioctl_mmap(comedi_cxt_t * cxt, void *arg) map_cfg.size > dev->transfer.bufs[map_cfg.idx_subd]->size) return -EFAULT; - ret = rtdm_mmap_to_user(cxt->rtdm_usrinf, + ret = rtdm_mmap_to_user(cxt->user_info, dev->transfer.bufs[map_cfg.idx_subd]->buf, map_cfg.size, PROT_READ | PROT_WRITE, @@ -430,7 +430,8 @@ int comedi_ioctl_mmap(comedi_cxt_t * cxt, void *arg) if (ret < 0) return ret; - return comedi_copy_to_user(cxt, arg, &map_cfg, sizeof(comedi_mmap_t)); + return rtdm_safe_copy_to_user(cxt->user_info, + arg, &map_cfg, sizeof(comedi_mmap_t)); } /* --- IOCTL / FOPS functions --- */ @@ -452,8 +453,9 @@ int comedi_ioctl_bufcfg(comedi_cxt_t * cxt, void *arg) if (comedi_test_rt() != 0) return -EPERM; - if (comedi_copy_from_user(cxt, - &buf_cfg, arg, sizeof(comedi_bufcfg_t)) != 0) + if (rtdm_safe_copy_from_user(cxt->user_info, + &buf_cfg, + arg, sizeof(comedi_bufcfg_t)) != 0) return -EFAULT; if (buf_cfg.idx_subd >= dev->transfer.nb_subd) @@ -495,8 +497,8 @@ int comedi_ioctl_bufinfo(comedi_cxt_t * cxt, void *arg) if (!test_bit(COMEDI_DEV_ATTACHED, &dev->flags)) return -EINVAL; - if (comedi_copy_from_user(cxt, - &info, arg, sizeof(comedi_bufinfo_t)) != 0) + if (rtdm_safe_copy_from_user(cxt->user_info, + &info, arg, sizeof(comedi_bufinfo_t)) != 0) return -EFAULT; if (info.idx_subd > dev->transfer.nb_subd) @@ -570,7 +572,8 @@ int comedi_ioctl_bufinfo(comedi_cxt_t * cxt, void *arg) info.buf_size = buf->size; /* Sends the structure back to user space */ - if (comedi_copy_to_user(cxt, arg, &info, sizeof(comedi_bufinfo_t)) != 0) + if (rtdm_safe_copy_to_user(cxt->user_info, + arg, &info, sizeof(comedi_bufinfo_t)) != 0) return -EFAULT; return 0; @@ -794,7 +797,8 @@ int comedi_ioctl_poll(comedi_cxt_t * cxt, void *arg) if (!test_bit(COMEDI_DEV_ATTACHED, &dev->flags)) return -EINVAL; - if (comedi_copy_from_user(cxt, &poll, arg, sizeof(comedi_poll_t)) != 0) + if (rtdm_safe_copy_from_user(cxt->user_info, + &poll, arg, sizeof(comedi_poll_t)) != 0) return -EFAULT; /* Checks the subdevice capabilities */ @@ -864,7 +868,8 @@ int comedi_ioctl_poll(comedi_cxt_t * cxt, void *arg) poll.arg = tmp_cnt; /* Sends the structure back to user space */ - ret = comedi_copy_to_user(cxt, arg, &poll, sizeof(comedi_poll_t)); + ret = rtdm_safe_copy_to_user(cxt->user_info, + arg, &poll, sizeof(comedi_poll_t)); return ret; } diff --git a/ksrc/drivers/comedi/command.c b/ksrc/drivers/comedi/command.c index 069d748..56a4383 100644 --- a/ksrc/drivers/comedi/command.c +++ b/ksrc/drivers/comedi/command.c @@ -38,7 +38,8 @@ int comedi_fill_cmddesc(comedi_cxt_t * cxt, comedi_cmd_t * desc, void *arg) int ret = 0; unsigned int *tmpchans = NULL; - ret = comedi_copy_from_user(cxt, desc, arg, sizeof(comedi_cmd_t)); + ret = rtdm_safe_copy_from_user(cxt->user_info, + desc, arg, sizeof(comedi_cmd_t)); if (ret != 0) goto out_cmddesc; @@ -53,10 +54,10 @@ int comedi_fill_cmddesc(comedi_cxt_t * cxt, comedi_cmd_t * desc, void *arg) goto out_cmddesc; } - ret = comedi_copy_from_user(cxt, - tmpchans, - desc->chan_descs, - desc->nb_chan * sizeof(unsigned long)); + ret = rtdm_safe_copy_from_user(cxt->user_info, + tmpchans, + desc->chan_descs, + desc->nb_chan * sizeof(unsigned long)); if (ret != 0) goto out_cmddesc; diff --git a/ksrc/drivers/comedi/device.c b/ksrc/drivers/comedi/device.c index 875c6d8..30b790f 100644 --- a/ksrc/drivers/comedi/device.c +++ b/ksrc/drivers/comedi/device.c @@ -205,8 +205,8 @@ int comedi_fill_lnkdesc(comedi_cxt_t * cxt, __comedi_dbg(1, core_dbg, "comedi_fill_lnkdesc: minor=%d\n", comedi_get_minor(cxt)); - ret = comedi_copy_from_user(cxt, - link_arg, arg, sizeof(comedi_lnkdesc_t)); + ret = rtdm_safe_copy_from_user(cxt->user_info, + link_arg, arg, sizeof(comedi_lnkdesc_t)); if (ret != 0) { __comedi_err("comedi_fill_lnkdesc: " "call1(copy_from_user) failed\n"); @@ -223,10 +223,10 @@ int comedi_fill_lnkdesc(comedi_cxt_t * cxt, } tmpname[link_arg->bname_size] = 0; - ret = comedi_copy_from_user(cxt, - tmpname, - link_arg->bname, - link_arg->bname_size); + ret = rtdm_safe_copy_from_user(cxt->user_info, + tmpname, + link_arg->bname, + link_arg->bname_size); if (ret != 0) { __comedi_err("comedi_fill_lnkdesc: " "call2(copy_from_user) failed\n"); @@ -248,10 +248,10 @@ int comedi_fill_lnkdesc(comedi_cxt_t * cxt, goto out_get_lnkdesc; } - ret = comedi_copy_from_user(cxt, - tmpopts, - link_arg->opts, - link_arg->opts_size); + ret = rtdm_safe_copy_from_user(cxt->user_info, + tmpopts, + link_arg->opts, + link_arg->opts_size); if (ret != 0) { __comedi_err("comedi_fill_lnkdesc: " "call3(copy_from_user) failed\n"); @@ -478,7 +478,8 @@ int comedi_ioctl_devinfo(comedi_cxt_t * cxt, void *arg) info.idx_write_subd = dev->transfer.idx_write_subd; } - if (comedi_copy_to_user(cxt, arg, &info, sizeof(comedi_dvinfo_t)) != 0) + if (rtdm_safe_copy_to_user(cxt->user_info, + arg, &info, sizeof(comedi_dvinfo_t)) != 0) return -EINVAL; return 0; diff --git a/ksrc/drivers/comedi/instruction.c b/ksrc/drivers/comedi/instruction.c index 658d7fd..62579c8 100644 --- a/ksrc/drivers/comedi/instruction.c +++ b/ksrc/drivers/comedi/instruction.c @@ -103,7 +103,8 @@ int comedi_fill_insndsc(comedi_cxt_t * cxt, comedi_kinsn_t * dsc, void *arg) int ret = 0; void *tmp_data = NULL; - ret = comedi_copy_from_user(cxt, dsc, arg, sizeof(comedi_insn_t)); + ret = rtdm_safe_copy_from_user(cxt->user_info, + dsc, arg, sizeof(comedi_insn_t)); if (ret != 0) goto out_insndsc; @@ -120,9 +121,9 @@ int comedi_fill_insndsc(comedi_cxt_t * cxt, comedi_kinsn_t * dsc, void *arg) } if ((dsc->type & COMEDI_INSN_MASK_WRITE) != 0) { - ret = comedi_copy_from_user(cxt, - tmp_data, dsc->data, - dsc->data_size); + ret = rtdm_safe_copy_from_user(cxt->user_info, + tmp_data, dsc->data, + dsc->data_size); if (ret < 0) goto out_insndsc; } @@ -144,9 +145,9 @@ int comedi_free_insndsc(comedi_cxt_t * cxt, comedi_kinsn_t * dsc) int ret = 0; if ((dsc->type & COMEDI_INSN_MASK_READ) != 0) - ret = comedi_copy_to_user(cxt, - dsc->__udata, - dsc->data, dsc->data_size); + ret = rtdm_safe_copy_to_user(cxt->user_info, + dsc->__udata, + dsc->data, dsc->data_size); if (dsc->data != NULL) rtdm_free(dsc->data); @@ -268,7 +269,8 @@ int comedi_fill_ilstdsc(comedi_cxt_t * cxt, comedi_kilst_t * dsc, void *arg) dsc->insns = NULL; /* Recovers the structure from user space */ - ret = comedi_copy_from_user(cxt, dsc, arg, sizeof(comedi_insnlst_t)); + ret = rtdm_safe_copy_from_user(cxt->user_info, + dsc, arg, sizeof(comedi_insnlst_t)); if (ret < 0) return ret; diff --git a/ksrc/drivers/comedi/subdevice.c b/ksrc/drivers/comedi/subdevice.c index fe2352c..7613432 100644 --- a/ksrc/drivers/comedi/subdevice.c +++ b/ksrc/drivers/comedi/subdevice.c @@ -201,10 +201,10 @@ int comedi_ioctl_subdinfo(comedi_cxt_t * cxt, void *arg) dev->transfer.subds[i]->chan_desc->length : 0; } - if (comedi_copy_to_user(cxt, - arg, - subd_info, dev->transfer.nb_subd * - sizeof(comedi_sbinfo_t)) != 0) + if (rtdm_safe_copy_to_user(cxt->user_info, + arg, + subd_info, dev->transfer.nb_subd * + sizeof(comedi_sbinfo_t)) != 0) ret = -EFAULT; rtdm_free(subd_info); @@ -222,9 +222,9 @@ int comedi_ioctl_nbchaninfo(comedi_cxt_t * cxt, void *arg) if (!dev->flags & COMEDI_DEV_ATTACHED) return -EINVAL; - if (comedi_copy_from_user(cxt, - &inarg, arg, - sizeof(comedi_chinfo_arg_t)) != 0) + if (rtdm_safe_copy_from_user(cxt->user_info, + &inarg, arg, + sizeof(comedi_chinfo_arg_t)) != 0) return -EFAULT; if (inarg.idx_subd >= dev->transfer.nb_subd) @@ -236,8 +236,9 @@ int comedi_ioctl_nbchaninfo(comedi_cxt_t * cxt, void *arg) inarg.info = (void *)(unsigned long) dev->transfer.subds[inarg.idx_subd]->chan_desc->length; - if (comedi_copy_to_user(cxt, - arg, &inarg, sizeof(comedi_chinfo_arg_t)) != 0) + if (rtdm_safe_copy_to_user(cxt->user_info, + arg, + &inarg, sizeof(comedi_chinfo_arg_t)) != 0) return -EFAULT; return 0; @@ -256,9 +257,9 @@ int comedi_ioctl_chaninfo(comedi_cxt_t * cxt, void *arg) if (!test_bit(COMEDI_DEV_ATTACHED, &dev->flags)) return -EINVAL; - if (comedi_copy_from_user(cxt, - &inarg, arg, - sizeof(comedi_chinfo_arg_t)) != 0) + if (rtdm_safe_copy_from_user(cxt->user_info, + &inarg, arg, + sizeof(comedi_chinfo_arg_t)) != 0) return -EFAULT; if (inarg.idx_subd >= dev->transfer.nb_subd) @@ -292,10 +293,11 @@ int comedi_ioctl_chaninfo(comedi_cxt_t * cxt, void *arg) chan_info[i].chan_flags |= COMEDI_CHAN_GLOBAL; } - if (comedi_copy_to_user(cxt, - inarg.info, - chan_info, - chan_desc->length * sizeof(comedi_chinfo_t)) != 0) + if (rtdm_safe_copy_to_user(cxt->user_info, + inarg.info, + chan_info, + chan_desc->length * + sizeof(comedi_chinfo_t)) != 0) return -EFAULT; rtdm_free(chan_info); @@ -314,9 +316,9 @@ int comedi_ioctl_nbrnginfo(comedi_cxt_t * cxt, void *arg) if (!test_bit(COMEDI_DEV_ATTACHED, &dev->flags)) return -EINVAL; - if (comedi_copy_from_user(cxt, - &inarg, - arg, sizeof(comedi_rnginfo_arg_t)) != 0) + if (rtdm_safe_copy_from_user(cxt->user_info, + &inarg, + arg, sizeof(comedi_rnginfo_arg_t)) != 0) return -EFAULT; if (inarg.idx_subd >= dev->transfer.nb_subd) @@ -339,8 +341,9 @@ int comedi_ioctl_nbrnginfo(comedi_cxt_t * cxt, void *arg) inarg.info = (void *)0; - if (comedi_copy_to_user(cxt, - arg, &inarg, sizeof(comedi_rnginfo_arg_t)) != 0) + if (rtdm_safe_copy_to_user(cxt->user_info, + arg, + &inarg, sizeof(comedi_rnginfo_arg_t)) != 0) return -EFAULT; return 0; @@ -359,9 +362,9 @@ int comedi_ioctl_rnginfo(comedi_cxt_t * cxt, void *arg) if (!test_bit(COMEDI_DEV_ATTACHED, &dev->flags)) return -EINVAL; - if (comedi_copy_from_user(cxt, - &inarg, - arg, sizeof(comedi_rnginfo_arg_t)) != 0) + if (rtdm_safe_copy_from_user(cxt->user_info, + &inarg, + arg, sizeof(comedi_rnginfo_arg_t)) != 0) return -EFAULT; if (inarg.idx_subd >= dev->transfer.nb_subd) @@ -397,11 +400,11 @@ int comedi_ioctl_rnginfo(comedi_cxt_t * cxt, void *arg) rng_info[i].flags |= COMEDI_RNG_GLOBAL; } - if (comedi_copy_to_user(cxt, - inarg.info, - rng_info, - rng_desc->rngtabs[tmp]->length * - sizeof(comedi_rnginfo_t)) != 0) + if (rtdm_safe_copy_to_user(cxt->user_info, + inarg.info, + rng_info, + rng_desc->rngtabs[tmp]->length * + sizeof(comedi_rnginfo_t)) != 0) return -EFAULT; rtdm_free(rng_info); _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git