Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=cfbe9bb2fb5de1da58d351432a9465c22d6d3ee5
Commit:     cfbe9bb2fb5de1da58d351432a9465c22d6d3ee5
Parent:     e5854a5839fa426a7873f038080f63587de5f1f1
Author:     Cornelia Huck <[EMAIL PROTECTED]>
AuthorDate: Fri Apr 27 16:01:32 2007 +0200
Committer:  Martin Schwidefsky <[EMAIL PROTECTED]>
CommitDate: Fri Apr 27 16:01:40 2007 +0200

    [S390] cio: Use add_uevent_var.
    
    Convert ccw_uevent to use add_uevent_var and adapt snprint_alias.
    
    Signed-off-by: Cornelia Huck <[EMAIL PROTECTED]>
    Signed-off-by: Heiko Carstens <[EMAIL PROTECTED]>
    Signed-off-by: Martin Schwidefsky <[EMAIL PROTECTED]>
---
 drivers/s390/cio/device.c |   66 +++++++++++++++++---------------------------
 1 files changed, 26 insertions(+), 40 deletions(-)

diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index c3fc205..34e7d77 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -56,13 +56,12 @@ ccw_bus_match (struct device * dev, struct device_driver * 
drv)
 /* Store modalias string delimited by prefix/suffix string into buffer with
  * specified size. Return length of resulting string (excluding trailing '\0')
  * even if string doesn't fit buffer (snprintf semantics). */
-static int snprint_alias(char *buf, size_t size, const char *prefix,
+static int snprint_alias(char *buf, size_t size,
                         struct ccw_device_id *id, const char *suffix)
 {
        int len;
 
-       len = snprintf(buf, size, "%sccw:t%04Xm%02X", prefix, id->cu_type,
-                      id->cu_model);
+       len = snprintf(buf, size, "ccw:t%04Xm%02X", id->cu_type, id->cu_model);
        if (len > size)
                return len;
        buf += len;
@@ -85,53 +84,40 @@ static int ccw_uevent(struct device *dev, char **envp, int 
num_envp,
        struct ccw_device *cdev = to_ccwdev(dev);
        struct ccw_device_id *id = &(cdev->id);
        int i = 0;
-       int len;
+       int len = 0;
+       int ret;
+       char modalias_buf[30];
 
        /* CU_TYPE= */
-       len = snprintf(buffer, buffer_size, "CU_TYPE=%04X", id->cu_type) + 1;
-       if (len > buffer_size || i >= num_envp)
-               return -ENOMEM;
-       envp[i++] = buffer;
-       buffer += len;
-       buffer_size -= len;
+       ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
+                            "CU_TYPE=%04X", id->cu_type);
+       if (ret)
+               return ret;
 
        /* CU_MODEL= */
-       len = snprintf(buffer, buffer_size, "CU_MODEL=%02X", id->cu_model) + 1;
-       if (len > buffer_size || i >= num_envp)
-               return -ENOMEM;
-       envp[i++] = buffer;
-       buffer += len;
-       buffer_size -= len;
+       ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
+                            "CU_MODEL=%02X", id->cu_model);
+       if (ret)
+               return ret;
 
        /* The next two can be zero, that's ok for us */
        /* DEV_TYPE= */
-       len = snprintf(buffer, buffer_size, "DEV_TYPE=%04X", id->dev_type) + 1;
-       if (len > buffer_size || i >= num_envp)
-               return -ENOMEM;
-       envp[i++] = buffer;
-       buffer += len;
-       buffer_size -= len;
+       ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
+                            "DEV_TYPE=%04X", id->dev_type);
+       if (ret)
+               return ret;
 
        /* DEV_MODEL= */
-       len = snprintf(buffer, buffer_size, "DEV_MODEL=%02X",
-                       (unsigned char) id->dev_model) + 1;
-       if (len > buffer_size || i >= num_envp)
-               return -ENOMEM;
-       envp[i++] = buffer;
-       buffer += len;
-       buffer_size -= len;
+       ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
+                            "DEV_MODEL=%02X", id->dev_model);
+       if (ret)
+               return ret;
 
        /* MODALIAS=  */
-       len = snprint_alias(buffer, buffer_size, "MODALIAS=", id, "") + 1;
-       if (len > buffer_size || i >= num_envp)
-               return -ENOMEM;
-       envp[i++] = buffer;
-       buffer += len;
-       buffer_size -= len;
-
-       envp[i] = NULL;
-
-       return 0;
+       snprint_alias(modalias_buf, sizeof(modalias_buf), id, "");
+       ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
+                            "MODALIAS=%s", modalias_buf);
+       return ret;
 }
 
 struct bus_type ccw_bus_type;
@@ -280,7 +266,7 @@ modalias_show (struct device *dev, struct device_attribute 
*attr, char *buf)
        struct ccw_device_id *id = &(cdev->id);
        int len;
 
-       len = snprint_alias(buf, PAGE_SIZE, "", id, "\n") + 1;
+       len = snprint_alias(buf, PAGE_SIZE, id, "\n") + 1;
 
        return len > PAGE_SIZE ? PAGE_SIZE : len;
 }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to