aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/mmc_sysfs.c
diff options
context:
space:
mode:
authorEric Rannaud <eric.rannaud@gmail.com>2007-03-31 01:23:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-04-27 13:57:29 -0400
commitbf62456eb91f3d2ef0736081583d09b0b3c8b7ea (patch)
tree851c2559ae11835e19763b7c7c54393f0ae0d5f6 /drivers/mmc/mmc_sysfs.c
parentbdc4960a0b4831a24276b65f1f7afdfc57f2f5cf (diff)
uevent: use add_uevent_var() instead of open coding it
Make use of add_uevent_var() instead of (often incorrectly) open coding it. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Eric Rannaud <eric.rannaud@gmail.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/mmc/mmc_sysfs.c')
-rw-r--r--drivers/mmc/mmc_sysfs.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/mmc_sysfs.c
index d32698b02d7f..e0e82d849d5f 100644
--- a/drivers/mmc/mmc_sysfs.c
+++ b/drivers/mmc/mmc_sysfs.c
@@ -86,31 +86,26 @@ mmc_bus_uevent(struct device *dev, char **envp, int num_envp, char *buf,
86{ 86{
87 struct mmc_card *card = dev_to_mmc_card(dev); 87 struct mmc_card *card = dev_to_mmc_card(dev);
88 char ccc[13]; 88 char ccc[13];
89 int i = 0; 89 int retval = 0, i = 0, length = 0;
90 90
91#define add_env(fmt,val) \ 91#define add_env(fmt,val) do { \
92 ({ \ 92 retval = add_uevent_var(envp, num_envp, &i, \
93 int len, ret = -ENOMEM; \ 93 buf, buf_size, &length, \
94 if (i < num_envp) { \ 94 fmt, val); \
95 envp[i++] = buf; \ 95 if (retval) \
96 len = snprintf(buf, buf_size, fmt, val) + 1; \ 96 return retval; \
97 buf_size -= len; \ 97} while (0);
98 buf += len; \
99 if (buf_size >= 0) \
100 ret = 0; \
101 } \
102 ret; \
103 })
104 98
105 for (i = 0; i < 12; i++) 99 for (i = 0; i < 12; i++)
106 ccc[i] = card->csd.cmdclass & (1 << i) ? '1' : '0'; 100 ccc[i] = card->csd.cmdclass & (1 << i) ? '1' : '0';
107 ccc[12] = '\0'; 101 ccc[12] = '\0';
108 102
109 i = 0;
110 add_env("MMC_CCC=%s", ccc); 103 add_env("MMC_CCC=%s", ccc);
111 add_env("MMC_MANFID=%06x", card->cid.manfid); 104 add_env("MMC_MANFID=%06x", card->cid.manfid);
112 add_env("MMC_NAME=%s", mmc_card_name(card)); 105 add_env("MMC_NAME=%s", mmc_card_name(card));
113 add_env("MMC_OEMID=%04x", card->cid.oemid); 106 add_env("MMC_OEMID=%04x", card->cid.oemid);
107#undef add_env
108 envp[i] = NULL;
114 109
115 return 0; 110 return 0;
116} 111}