diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2007-12-02 00:12:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:05:47 -0500 |
commit | 35a84fdc89c493a6b0c1eb61296f9bd514f7b947 (patch) | |
tree | 389de964d4732ef742a31843a9663193f7824153 | |
parent | 43fd6c7ebdd50276a7d26d7dddcb109c291dde50 (diff) |
gianfar driver: eliminate compiler warnings and unnecessary macros
This patch eliminates the warning of unused return values when the driver
registers it sysfs files. Now the driver will print an error if it is
unable to register the sysfs files.
It also eliminates the macros used to wrap the DEVICE_ATTR macro and the
device_create_file function call. The macros don't reduce the number of
lines of source code in the file and the name munging makes is so that
cscope and friends don't see the references to the functions. It's better
to just call the kernel API directly.
While we're at it, the DEVICE_ATTR instances have been moved down to
be grouped with the functions they depend on.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | drivers/net/gianfar_sysfs.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c index aec9ab17a9a5..230878b94190 100644 --- a/drivers/net/gianfar_sysfs.c +++ b/drivers/net/gianfar_sysfs.c | |||
@@ -37,24 +37,6 @@ | |||
37 | 37 | ||
38 | #include "gianfar.h" | 38 | #include "gianfar.h" |
39 | 39 | ||
40 | #define GFAR_ATTR(_name) \ | ||
41 | static ssize_t gfar_show_##_name(struct device *dev, \ | ||
42 | struct device_attribute *attr, char *buf); \ | ||
43 | static ssize_t gfar_set_##_name(struct device *dev, \ | ||
44 | struct device_attribute *attr, \ | ||
45 | const char *buf, size_t count); \ | ||
46 | static DEVICE_ATTR(_name, 0644, gfar_show_##_name, gfar_set_##_name) | ||
47 | |||
48 | #define GFAR_CREATE_FILE(_dev, _name) \ | ||
49 | device_create_file(&_dev->dev, &dev_attr_##_name) | ||
50 | |||
51 | GFAR_ATTR(bd_stash); | ||
52 | GFAR_ATTR(rx_stash_size); | ||
53 | GFAR_ATTR(rx_stash_index); | ||
54 | GFAR_ATTR(fifo_threshold); | ||
55 | GFAR_ATTR(fifo_starve); | ||
56 | GFAR_ATTR(fifo_starve_off); | ||
57 | |||
58 | static ssize_t gfar_show_bd_stash(struct device *dev, | 40 | static ssize_t gfar_show_bd_stash(struct device *dev, |
59 | struct device_attribute *attr, char *buf) | 41 | struct device_attribute *attr, char *buf) |
60 | { | 42 | { |
@@ -100,6 +82,8 @@ static ssize_t gfar_set_bd_stash(struct device *dev, | |||
100 | return count; | 82 | return count; |
101 | } | 83 | } |
102 | 84 | ||
85 | DEVICE_ATTR(bd_stash, 0644, gfar_show_bd_stash, gfar_set_bd_stash); | ||
86 | |||
103 | static ssize_t gfar_show_rx_stash_size(struct device *dev, | 87 | static ssize_t gfar_show_rx_stash_size(struct device *dev, |
104 | struct device_attribute *attr, char *buf) | 88 | struct device_attribute *attr, char *buf) |
105 | { | 89 | { |
@@ -146,6 +130,9 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev, | |||
146 | return count; | 130 | return count; |
147 | } | 131 | } |
148 | 132 | ||
133 | DEVICE_ATTR(rx_stash_size, 0644, gfar_show_rx_stash_size, | ||
134 | gfar_set_rx_stash_size); | ||
135 | |||
149 | /* Stashing will only be enabled when rx_stash_size != 0 */ | 136 | /* Stashing will only be enabled when rx_stash_size != 0 */ |
150 | static ssize_t gfar_show_rx_stash_index(struct device *dev, | 137 | static ssize_t gfar_show_rx_stash_index(struct device *dev, |
151 | struct device_attribute *attr, | 138 | struct device_attribute *attr, |
@@ -184,6 +171,9 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev, | |||
184 | return count; | 171 | return count; |
185 | } | 172 | } |
186 | 173 | ||
174 | DEVICE_ATTR(rx_stash_index, 0644, gfar_show_rx_stash_index, | ||
175 | gfar_set_rx_stash_index); | ||
176 | |||
187 | static ssize_t gfar_show_fifo_threshold(struct device *dev, | 177 | static ssize_t gfar_show_fifo_threshold(struct device *dev, |
188 | struct device_attribute *attr, | 178 | struct device_attribute *attr, |
189 | char *buf) | 179 | char *buf) |
@@ -219,6 +209,9 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev, | |||
219 | return count; | 209 | return count; |
220 | } | 210 | } |
221 | 211 | ||
212 | DEVICE_ATTR(fifo_threshold, 0644, gfar_show_fifo_threshold, | ||
213 | gfar_set_fifo_threshold); | ||
214 | |||
222 | static ssize_t gfar_show_fifo_starve(struct device *dev, | 215 | static ssize_t gfar_show_fifo_starve(struct device *dev, |
223 | struct device_attribute *attr, char *buf) | 216 | struct device_attribute *attr, char *buf) |
224 | { | 217 | { |
@@ -253,6 +246,8 @@ static ssize_t gfar_set_fifo_starve(struct device *dev, | |||
253 | return count; | 246 | return count; |
254 | } | 247 | } |
255 | 248 | ||
249 | DEVICE_ATTR(fifo_starve, 0644, gfar_show_fifo_starve, gfar_set_fifo_starve); | ||
250 | |||
256 | static ssize_t gfar_show_fifo_starve_off(struct device *dev, | 251 | static ssize_t gfar_show_fifo_starve_off(struct device *dev, |
257 | struct device_attribute *attr, | 252 | struct device_attribute *attr, |
258 | char *buf) | 253 | char *buf) |
@@ -288,9 +283,13 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev, | |||
288 | return count; | 283 | return count; |
289 | } | 284 | } |
290 | 285 | ||
286 | DEVICE_ATTR(fifo_starve_off, 0644, gfar_show_fifo_starve_off, | ||
287 | gfar_set_fifo_starve_off); | ||
288 | |||
291 | void gfar_init_sysfs(struct net_device *dev) | 289 | void gfar_init_sysfs(struct net_device *dev) |
292 | { | 290 | { |
293 | struct gfar_private *priv = netdev_priv(dev); | 291 | struct gfar_private *priv = netdev_priv(dev); |
292 | int rc; | ||
294 | 293 | ||
295 | /* Initialize the default values */ | 294 | /* Initialize the default values */ |
296 | priv->rx_stash_size = DEFAULT_STASH_LENGTH; | 295 | priv->rx_stash_size = DEFAULT_STASH_LENGTH; |
@@ -301,11 +300,12 @@ void gfar_init_sysfs(struct net_device *dev) | |||
301 | priv->bd_stash_en = DEFAULT_BD_STASH; | 300 | priv->bd_stash_en = DEFAULT_BD_STASH; |
302 | 301 | ||
303 | /* Create our sysfs files */ | 302 | /* Create our sysfs files */ |
304 | GFAR_CREATE_FILE(dev, bd_stash); | 303 | rc = device_create_file(&dev->dev, &dev_attr_bd_stash); |
305 | GFAR_CREATE_FILE(dev, rx_stash_size); | 304 | rc |= device_create_file(&dev->dev, &dev_attr_rx_stash_size); |
306 | GFAR_CREATE_FILE(dev, rx_stash_index); | 305 | rc |= device_create_file(&dev->dev, &dev_attr_rx_stash_index); |
307 | GFAR_CREATE_FILE(dev, fifo_threshold); | 306 | rc |= device_create_file(&dev->dev, &dev_attr_fifo_threshold); |
308 | GFAR_CREATE_FILE(dev, fifo_starve); | 307 | rc |= device_create_file(&dev->dev, &dev_attr_fifo_starve); |
309 | GFAR_CREATE_FILE(dev, fifo_starve_off); | 308 | rc |= device_create_file(&dev->dev, &dev_attr_fifo_starve_off); |
310 | 309 | if (rc) | |
310 | dev_err(&dev->dev, "Error creating gianfar sysfs files.\n"); | ||
311 | } | 311 | } |