Update to new sinfo resource variants API
authorReto Buerki <reet@codelabs.ch>
Thu, 22 Mar 2018 10:38:39 +0000 (11:38 +0100)
committerReto Buerki <reet@codelabs.ch>
Tue, 3 Apr 2018 15:02:50 +0000 (17:02 +0200)
internal.h
net.c
reader.c
writer.c

index 3858b61..088059c 100644 (file)
@@ -165,7 +165,7 @@ void debug_remove_device(struct dev_info *dev_info);
  * @brief Initializes the network device reader part
  */
 int initialize_reader(struct dev_info *dev_info,
-                     const struct muen_channel_info * const region);
+                     const struct muen_resource_type *const region);
 
 /**
  * @brief Shuts down the network device reader part
@@ -192,8 +192,8 @@ void writer_down(struct dev_info *dev_info);
  * @brief Initializes the network device writer part
  */
 int initialize_writer(struct dev_info *dev_info,
-                     const struct muen_channel_info * const region,
-                     const struct muen_channel_info * const pmtu_region);
+                     const struct muen_resource_type *const region,
+                     const struct muen_resource_type *const pmtu_region);
 
 /**
  * @brief Shuts down the network device writer part
diff --git a/net.c b/net.c
index e1654f3..cecc985 100644 (file)
--- a/net.c
+++ b/net.c
@@ -299,7 +299,6 @@ static int add_device(const char *device_name,
        struct net_device *dev;
        struct dev_info *dev_info;
        size_t bus_info_len = 2; /* place for separator and finishing \0 */
-       struct muen_channel_info reader_channel, writer_channel, pmtu_channel;
 
        if (input)
                bus_info_len += strlen(input);
@@ -354,12 +353,15 @@ static int add_device(const char *device_name,
 
        /* first check all the names */
        if (input && strlen(input) > 0) {
-               if (!muen_get_channel_info(input, &reader_channel)) {
+               const struct muen_resource_type *const
+                       reader_channel = muen_get_resource(input,
+                                                          MUEN_RES_MEMORY);
+               if (!reader_channel) {
                        netdev_err(dev_info->dev,
                                   "Input channel '%s' not found\n", input);
                        goto err_free_businfo;
                }
-               ret = initialize_reader(dev_info, &reader_channel);
+               ret = initialize_reader(dev_info, reader_channel);
                if (ret < 0) {
                        netdev_err(dev_info->dev,
                                   "Unable to init reader (status: %d)\n", ret);
@@ -368,23 +370,29 @@ static int add_device(const char *device_name,
        }
 
        if (output && strlen(output) > 0) {
-               if (!muen_get_channel_info(output, &writer_channel)) {
+               const struct muen_resource_type *const
+                       writer_channel = muen_get_resource(output,
+                                                          MUEN_RES_MEMORY);
+               if (!writer_channel) {
                        netdev_err(dev_info->dev,
                                   "Output channel '%s' not found\n", output);
                        goto err_cleanup_reader;
                }
 
                if (pmtu && strlen(pmtu) > 0) {
-                       if (!muen_get_channel_info(pmtu, &pmtu_channel)) {
+                       const struct muen_resource_type *const
+                               pmtu_channel = muen_get_resource(
+                                               pmtu, MUEN_RES_MEMORY);
+                       if (!pmtu_channel) {
                                netdev_err(dev_info->dev,
                                           "PMTU channel '%s' not found\n",
                                           pmtu);
                                goto err_cleanup_reader;
                        }
-                       ret = initialize_writer(dev_info, &writer_channel,
-                                               &pmtu_channel);
+                       ret = initialize_writer(dev_info, writer_channel,
+                                               pmtu_channel);
                } else
-                       ret = initialize_writer(dev_info, &writer_channel,
+                       ret = initialize_writer(dev_info, writer_channel,
                                                NULL);
 
                if (ret < 0) {
index 7e6af2a..d06512a 100644 (file)
--- a/reader.c
+++ b/reader.c
@@ -237,17 +237,23 @@ schedule:
  * @return -EFAULT if ioremap fails
  */
 int initialize_reader(struct dev_info *dev_info,
-                     const struct muen_channel_info * const channel)
+                     const struct muen_resource_type *const channel)
 {
-       if (channel->writable) {
+       if (!(channel->data.mem.flags & MEM_CHANNEL_FLAG)) {
+               netdev_err(dev_info->dev, "Memory '%s' not a channel\n",
+                          channel->name.data);
+               return -EPERM;
+       }
+       if (channel->data.mem.flags & MEM_WRITABLE_FLAG) {
                netdev_err(dev_info->dev, "Reader channel '%s' writable\n",
-                          channel->name);
+                          channel->name.data);
                return -EPERM;
        }
 
        dev_info->reader_element_size = 0;
 
-       dev_info->channel_in = ioremap_cache(channel->address, channel->size);
+       dev_info->channel_in = ioremap_cache(channel->data.mem.address,
+                                            channel->data.mem.size);
        if (dev_info->channel_in == NULL) {
                netdev_err(dev_info->dev, "Unable to map reader channel\n");
                return -EFAULT;
index 137c2a9..df607f6 100644 (file)
--- a/writer.c
+++ b/writer.c
@@ -109,33 +109,40 @@ void cleanup_writer(struct dev_info *dev_info)
  * @return errors returned by #common_check_region
  */
 int initialize_writer(struct dev_info *dev_info,
-                     const struct muen_channel_info * const channel,
-                     const struct muen_channel_info * const pmtu_channel)
+                     const struct muen_resource_type *const channel,
+                     const struct muen_resource_type *const pmtu_channel)
 {
        /* some sanity checks */
-       if (!channel->writable) {
+       if (!(channel->data.mem.flags & MEM_CHANNEL_FLAG)) {
+               netdev_err(dev_info->dev, "Memory '%s' not a channel\n",
+                          channel->name.data);
+               return -EPERM;
+       }
+       if (!channel->data.mem.flags & MEM_WRITABLE_FLAG) {
                netdev_err(dev_info->dev, "Writer channel '%s' not writable\n",
-                          channel->name);
+                          channel->name.data);
                return -EPERM;
        }
 
-       dev_info->writer_region_size = channel->size;
+       dev_info->writer_region_size = channel->data.mem.size;
 
        /* writer_element_size is determined when the interface is set up */
        dev_info->writer_element_size = 0;
 
        /* now remember the start of the region and initialize it */
-       dev_info->channel_out = ioremap_cache(channel->address, channel->size);
+       dev_info->channel_out = ioremap_cache(channel->data.mem.address,
+                                             channel->data.mem.size);
        if (dev_info->channel_out == NULL) {
                netdev_err(dev_info->dev, "Unable to map writer channel\n");
                return -EFAULT;
        }
 
        if (pmtu_channel != NULL) {
-               dev_info->pmtu_elements = pmtu_channel->size / sizeof(u32);
+               dev_info->pmtu_elements = pmtu_channel->data.mem.size
+                       / sizeof(u32);
 
-               dev_info->pmtu = ioremap_cache(pmtu_channel->address,
-                                              pmtu_channel->size);
+               dev_info->pmtu = ioremap_cache(pmtu_channel->data.mem.address,
+                                              pmtu_channel->data.mem.size);
                if (dev_info->channel_out == NULL) {
                        netdev_err(dev_info->dev,
                                   "Unable to map writer PMTU channel\n");