mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-13 22:14:20 +08:00
[S390] cio: Use add_uevent_var.
Convert ccw_uevent to use add_uevent_var and adapt snprint_alias. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
e5854a5839
commit
cfbe9bb2fb
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user