equal
deleted
inserted
replaced
108 } ec_cdev_priv_t; |
108 } ec_cdev_priv_t; |
109 |
109 |
110 /*****************************************************************************/ |
110 /*****************************************************************************/ |
111 |
111 |
112 /** Constructor. |
112 /** Constructor. |
113 * |
113 * |
114 * \return 0 in case of success, else < 0 |
114 * \return 0 in case of success, else < 0 |
115 */ |
115 */ |
116 int ec_cdev_init( |
116 int ec_cdev_init( |
117 ec_cdev_t *cdev, /**< EtherCAT master character device. */ |
117 ec_cdev_t *cdev, /**< EtherCAT master character device. */ |
118 ec_master_t *master, /**< Parent master. */ |
118 ec_master_t *master, /**< Parent master. */ |
1672 ) |
1672 ) |
1673 { |
1673 { |
1674 ec_domain_t *domain; |
1674 ec_domain_t *domain; |
1675 off_t offset; |
1675 off_t offset; |
1676 int ret; |
1676 int ret; |
1677 |
1677 |
1678 if (unlikely(!priv->requested)) |
1678 if (unlikely(!priv->requested)) |
1679 return -EPERM; |
1679 return -EPERM; |
1680 |
1680 |
1681 /* Get the sum of the domains' process data sizes. */ |
1681 /* Get the sum of the domains' process data sizes. */ |
1682 |
1682 |
1683 priv->process_data_size = 0; |
1683 priv->process_data_size = 0; |
1684 |
1684 |
1685 if (down_interruptible(&master->master_sem)) |
1685 if (down_interruptible(&master->master_sem)) |
1686 return -EINTR; |
1686 return -EINTR; |
1687 |
1687 |
1688 list_for_each_entry(domain, &master->domains, list) { |
1688 list_for_each_entry(domain, &master->domains, list) { |
1689 priv->process_data_size += ecrt_domain_size(domain); |
1689 priv->process_data_size += ecrt_domain_size(domain); |
1690 } |
1690 } |
1691 |
1691 |
1692 up(&master->master_sem); |
1692 up(&master->master_sem); |
1693 |
1693 |
1694 if (priv->process_data_size) { |
1694 if (priv->process_data_size) { |
1695 priv->process_data = vmalloc(priv->process_data_size); |
1695 priv->process_data = vmalloc(priv->process_data_size); |
1696 if (!priv->process_data) { |
1696 if (!priv->process_data) { |
1811 unsigned long arg, /**< ioctl() argument. */ |
1811 unsigned long arg, /**< ioctl() argument. */ |
1812 ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
1812 ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
1813 ) |
1813 ) |
1814 { |
1814 { |
1815 ec_master_state_t data; |
1815 ec_master_state_t data; |
1816 |
1816 |
1817 if (unlikely(!priv->requested)) |
1817 if (unlikely(!priv->requested)) |
1818 return -EPERM; |
1818 return -EPERM; |
1819 |
1819 |
1820 ecrt_master_state(master, &data); |
1820 ecrt_master_state(master, &data); |
1821 |
1821 |
1868 unsigned long arg, /**< ioctl() argument. */ |
1868 unsigned long arg, /**< ioctl() argument. */ |
1869 ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
1869 ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
1870 ) |
1870 ) |
1871 { |
1871 { |
1872 ec_ioctl_app_time_t data; |
1872 ec_ioctl_app_time_t data; |
1873 |
1873 |
1874 if (unlikely(!priv->requested)) |
1874 if (unlikely(!priv->requested)) |
1875 return -EPERM; |
1875 return -EPERM; |
1876 |
1876 |
1877 if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
1877 if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
1878 return -EFAULT; |
1878 return -EFAULT; |
2456 ) |
2456 ) |
2457 { |
2457 { |
2458 ec_ioctl_sc_state_t data; |
2458 ec_ioctl_sc_state_t data; |
2459 const ec_slave_config_t *sc; |
2459 const ec_slave_config_t *sc; |
2460 ec_slave_config_state_t state; |
2460 ec_slave_config_state_t state; |
2461 |
2461 |
2462 if (unlikely(!priv->requested)) |
2462 if (unlikely(!priv->requested)) |
2463 return -EPERM; |
2463 return -EPERM; |
2464 |
2464 |
2465 if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
2465 if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
2466 return -EFAULT; |
2466 return -EFAULT; |
2628 ) |
2628 ) |
2629 { |
2629 { |
2630 ec_ioctl_domain_state_t data; |
2630 ec_ioctl_domain_state_t data; |
2631 const ec_domain_t *domain; |
2631 const ec_domain_t *domain; |
2632 ec_domain_state_t state; |
2632 ec_domain_state_t state; |
2633 |
2633 |
2634 if (unlikely(!priv->requested)) |
2634 if (unlikely(!priv->requested)) |
2635 return -EPERM; |
2635 return -EPERM; |
2636 |
2636 |
2637 if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
2637 if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
2638 return -EFAULT; |
2638 return -EFAULT; |