master/ioctl.c
branchstable-1.5
changeset 2504 5ef9d5b14879
parent 2498 9cdd7669dc0b
child 2505 5ef3197e5e1f
equal deleted inserted replaced
2503:fdd4f8eb5c83 2504:5ef9d5b14879
  2728     return ret;
  2728     return ret;
  2729 }
  2729 }
  2730 
  2730 
  2731 /*****************************************************************************/
  2731 /*****************************************************************************/
  2732 
  2732 
       
  2733 /** Gets the domain's data size.
       
  2734  */
       
  2735 static ATTRIBUTES int ec_ioctl_domain_size(
       
  2736         ec_master_t *master, /**< EtherCAT master. */
       
  2737         void *arg, /**< ioctl() argument. */
       
  2738         ec_ioctl_context_t *ctx /**< Private data structure of file handle. */
       
  2739         )
       
  2740 {
       
  2741     const ec_domain_t *domain;
       
  2742 
       
  2743     if (unlikely(!ctx->requested)) {
       
  2744         return -EPERM;
       
  2745     }
       
  2746 
       
  2747     if (down_interruptible(&master->master_sem)) {
       
  2748         return -EINTR;
       
  2749     }
       
  2750 
       
  2751     list_for_each_entry(domain, &master->domains, list) {
       
  2752         if (domain->index == (unsigned long) arg) {
       
  2753             size_t size = ecrt_domain_size(domain);
       
  2754             up(&master->master_sem);
       
  2755             return size;
       
  2756         }
       
  2757     }
       
  2758 
       
  2759     up(&master->master_sem);
       
  2760     return -ENOENT;
       
  2761 }
       
  2762 
       
  2763 /*****************************************************************************/
       
  2764 
  2733 /** Gets the domain's offset in the total process data.
  2765 /** Gets the domain's offset in the total process data.
  2734  */
  2766  */
  2735 static ATTRIBUTES int ec_ioctl_domain_offset(
  2767 static ATTRIBUTES int ec_ioctl_domain_offset(
  2736         ec_master_t *master, /**< EtherCAT master. */
  2768         ec_master_t *master, /**< EtherCAT master. */
  2737         void *arg, /**< ioctl() argument. */
  2769         void *arg, /**< ioctl() argument. */
  4184                 ret = -EPERM;
  4216                 ret = -EPERM;
  4185                 break;
  4217                 break;
  4186             }
  4218             }
  4187             ret = ec_ioctl_sc_idn(master, arg, ctx);
  4219             ret = ec_ioctl_sc_idn(master, arg, ctx);
  4188             break;
  4220             break;
       
  4221         case EC_IOCTL_DOMAIN_SIZE:
       
  4222             ret = ec_ioctl_domain_size(master, arg, ctx);
       
  4223             break;
  4189         case EC_IOCTL_DOMAIN_OFFSET:
  4224         case EC_IOCTL_DOMAIN_OFFSET:
  4190             ret = ec_ioctl_domain_offset(master, arg, ctx);
  4225             ret = ec_ioctl_domain_offset(master, arg, ctx);
  4191             break;
  4226             break;
  4192         case EC_IOCTL_DOMAIN_PROCESS:
  4227         case EC_IOCTL_DOMAIN_PROCESS:
  4193             if (!ctx->writable) {
  4228             if (!ctx->writable) {