Discussion:
[etherlab-dev] initialization from incompatible pointer type
Chris Grigg
2018-03-29 22:07:51 UTC
Permalink
Hello everyone,

I'm trying to install the EtherCAT Master in Ubuntu 17.04, Kernel
4.13.0-37-generic, and I am encountering this error when building:

/workspace/Etherlab_EtherCAT_Master/master/cdev.c:87:14: error:
initialization from incompatible pointer type
[-Werror=incompatible-pointer-types]



.fault = eccdev_vma_fault




^~~~~~~~~~~~~~~~

I am unsure of how to proceed or troubleshoot but would greatly appreciate
any help or advice. Thank you!

Best,

Chris
Geller, Nir
2018-04-01 10:03:16 UTC
Permalink
Hi Chris,



The following patch makes a few minor adjustments to the etherlab master code in order to adapt it to kernel 4.13


Hope this helps you out,


Nir.




diff --git a/drivers/misc/ethercat_master/devices/generic.c b/drivers/misc/ethercat_master/devices/generic.c
index 9f19a79..11ed091 100644
--- a/drivers/misc/ethercat_master/devices/generic.c
+++ b/drivers/misc/ethercat_master/devices/generic.c
@@ -206,14 +206,29 @@ int ec_gen_device_create_socket(
{
int ret;
struct sockaddr_ll sa;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0))
+ struct net *nd_net;
+#endif

dev->rx_buf = kmalloc(EC_GEN_RX_BUF_SIZE, GFP_KERNEL);
if (!dev->rx_buf) {
return -ENOMEM;
}

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0))
ret = sock_create_kern(PF_PACKET, SOCK_RAW,
htons(ETH_P_ETHERCAT), &(dev->socket));
+#else
+ nd_net = dev_net(dev->netdev);
+
+ if (!nd_net) {
+ printk(KERN_ERR PFX "Failed to obtain net namespace\n");
+ return -EINVAL;
+ }
+
+ ret = sock_create_kern(nd_net, PF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT),
+ &dev->socket);
+#endif
if (ret) {
printk(KERN_ERR PFX "Failed to create socket (ret = %i).\n", ret);
return ret;
diff --git a/drivers/misc/ethercat_master/master/cdev.c b/drivers/misc/ethercat_master/master/cdev.c
index 3361872..14e2e86 100644
--- a/drivers/misc/ethercat_master/master/cdev.c
+++ b/drivers/misc/ethercat_master/master/cdev.c
@@ -64,7 +64,7 @@ static int eccdev_mmap(struct file *, struct vm_area_struct *);
#define PAGE_FAULT_VERSION KERNEL_VERSION(2, 6, 23)

#if LINUX_VERSION_CODE >= PAGE_FAULT_VERSION
-static int eccdev_vma_fault(struct vm_area_struct *, struct vm_fault *);
+static int eccdev_vma_fault(struct vm_fault *);
#else
static struct page *eccdev_vma_nopage(
struct vm_area_struct *, unsigned long, int *);
@@ -276,12 +276,11 @@ int eccdev_mmap(
* \return Zero on success, otherwise a negative error code.
*/
static int eccdev_vma_fault(
- struct vm_area_struct *vma, /**< Virtual memory area. */
struct vm_fault *vmf /**< Fault data. */
)
{
unsigned long offset = vmf->pgoff << PAGE_SHIFT;
- ec_cdev_priv_t *priv = (ec_cdev_priv_t *) vma->vm_private_data;
+ ec_cdev_priv_t *priv = (ec_cdev_priv_t *) vmf->vma->vm_private_data;
struct page *page;

if (offset >= priv->ctx.process_data_size) {
@@ -297,7 +296,7 @@ static int eccdev_vma_fault(
vmf->page = page;

EC_MASTER_DBG(priv->cdev->master, 1, "Vma fault, virtual_address = %p,"
- " offset = %lu, page = %p\n", vmf->virtual_address, offset, page);
+ " offset = %lu, page = %p\n", (void*)vmf->address, offset, page);

return 0;
}
diff --git a/drivers/misc/ethercat_master/master/master.c b/drivers/misc/ethercat_master/master/master.c
index 3a65030..d589d5d 100644
--- a/drivers/misc/ethercat_master/master/master.c
+++ b/drivers/misc/ethercat_master/master/master.c
@@ -44,6 +44,8 @@
#include <linux/device.h>
#include <linux/version.h>
#include <linux/hrtimer.h>
+#include <linux/sched/signal.h>
+#include <uapi/linux/sched/types.h>
#include "globals.h"
#include "slave.h"
#include "slave_config.h"


________________________________
From: etherlab-dev <etherlab-dev-***@etherlab.org> on behalf of Chris Grigg <***@gmail.com>
Sent: Friday, March 30, 2018 1:07:51 AM
To: etherlab-***@etherlab.org
Subject: [etherlab-dev] initialization from incompatible pointer type

Hello everyone,

I'm trying to install the EtherCAT Master in Ubuntu 17.04, Kernel 4.13.0-37-generic, and I am encountering this error when building:

/workspace/Etherlab_EtherCAT_Master/master/cdev.c:87:14: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.fault = eccdev_vma_fault
^~~~~~~~~~~~~~~~

I am unsure of how to proceed or troubleshoot but would greatly appreciate any help or advice. Thank you!

Best,

Chris
Chris Grigg
2018-04-09 14:26:08 UTC
Permalink
Thank you, this is great. I will give it a try soon.


On April 1, 2018 at 6:03:19 AM, Geller, Nir (***@servotronix.com)
wrote:

Hi Chris,



The following patch makes a few minor adjustments to the etherlab master
code in order to adapt it to kernel 4.13


Hope this helps you out,


Nir.




diff --git a/drivers/misc/ethercat_master/devices/generic.c
b/drivers/misc/ethercat_master/devices/generic.c
index 9f19a79..11ed091 100644
--- a/drivers/misc/ethercat_master/devices/generic.c
+++ b/drivers/misc/ethercat_master/devices/generic.c
@@ -206,14 +206,29 @@ int ec_gen_device_create_socket(
{
int ret;
struct sockaddr_ll sa;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0))
+ struct net *nd_net;
+#endif

dev->rx_buf = kmalloc(EC_GEN_RX_BUF_SIZE, GFP_KERNEL);
if (!dev->rx_buf) {
return -ENOMEM;
}

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0))
ret = sock_create_kern(PF_PACKET, SOCK_RAW,
htons(ETH_P_ETHERCAT), &(dev->socket));
+#else
+ nd_net = dev_net(dev->netdev);
+
+ if (!nd_net) {
+ printk(KERN_ERR PFX "Failed to obtain net namespace\n");
+ return -EINVAL;
+ }
+
+ ret = sock_create_kern(nd_net, PF_PACKET, SOCK_RAW,
htons(ETH_P_ETHERCAT),
+ &dev->socket);
+#endif
if (ret) {
printk(KERN_ERR PFX "Failed to create socket (ret = %i).\n", ret);
return ret;
diff --git a/drivers/misc/ethercat_master/master/cdev.c
b/drivers/misc/ethercat_master/master/cdev.c
index 3361872..14e2e86 100644
--- a/drivers/misc/ethercat_master/master/cdev.c
+++ b/drivers/misc/ethercat_master/master/cdev.c
@@ -64,7 +64,7 @@ static int eccdev_mmap(struct file *, struct
vm_area_struct *);
#define PAGE_FAULT_VERSION KERNEL_VERSION(2, 6, 23)

#if LINUX_VERSION_CODE >= PAGE_FAULT_VERSION
-static int eccdev_vma_fault(struct vm_area_struct *, struct vm_fault *);
+static int eccdev_vma_fault(struct vm_fault *);
#else
static struct page *eccdev_vma_nopage(
struct vm_area_struct *, unsigned long, int *);
@@ -276,12 +276,11 @@ int eccdev_mmap(
* \return Zero on success, otherwise a negative error code.
*/
static int eccdev_vma_fault(
- struct vm_area_struct *vma, /**< Virtual memory area. */
struct vm_fault *vmf /**< Fault data. */
)
{
unsigned long offset = vmf->pgoff << PAGE_SHIFT;
- ec_cdev_priv_t *priv = (ec_cdev_priv_t *) vma->vm_private_data;
+ ec_cdev_priv_t *priv = (ec_cdev_priv_t *) vmf->vma->vm_private_data;
struct page *page;

if (offset >= priv->ctx.process_data_size) {
@@ -297,7 +296,7 @@ static int eccdev_vma_fault(
vmf->page = page;

EC_MASTER_DBG(priv->cdev->master, 1, "Vma fault, virtual_address = %p,"
- " offset = %lu, page = %p\n", vmf->virtual_address, offset,
page);
+ " offset = %lu, page = %p\n", (void*)vmf->address, offset,
page);

return 0;
}
diff --git a/drivers/misc/ethercat_master/master/master.c
b/drivers/misc/ethercat_master/master/master.c
index 3a65030..d589d5d 100644
--- a/drivers/misc/ethercat_master/master/master.c
+++ b/drivers/misc/ethercat_master/master/master.c
@@ -44,6 +44,8 @@
#include <linux/device.h>
#include <linux/version.h>
#include <linux/hrtimer.h>
+#include <linux/sched/signal.h>
+#include <uapi/linux/sched/types.h>
#include "globals.h"
#include "slave.h"
#include "slave_config.h"

------------------------------
*From:* etherlab-dev <etherlab-dev-***@etherlab.org> on behalf of Chris
Grigg <***@gmail.com>
*Sent:* Friday, March 30, 2018 1:07:51 AM
*To:* etherlab-***@etherlab.org
*Subject:* [etherlab-dev] initialization from incompatible pointer type

Hello everyone,

I'm trying to install the EtherCAT Master in Ubuntu 17.04, Kernel
4.13.0-37-generic, and I am encountering this error when building:

/workspace/Etherlab_EtherCAT_Master/master/cdev.c:87:14: error:
initialization from incompatible pointer type
[-Werror=incompatible-pointer-types]



.fault = eccdev_vma_fault




^~~~~~~~~~~~~~~~

I am unsure of how to proceed or troubleshoot but would greatly appreciate
any help or advice. Thank you!

Best,

Chris

Continue reading on narkive:
Loading...