Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: Use DEVICE_ATTR_{RW, RO, WO} macros

Instead of open coding DEVICE_ATTR() defines, use the
DEVICE_ATTR_RW(), DEVICE_ATTR_WO(), and DEVICE_ATTR_RO()
macros.

This required a few functions to be renamed, but the functionality
itself is unchanged.

Reviewed-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>

authored by

Dwaipayan Ray and committed by
Pavel Machek
5ccfa39d 5c8fe583

+53 -53
+12 -12
drivers/leds/leds-blinkm.c
··· 192 192 return 0; 193 193 } 194 194 195 - static ssize_t show_red(struct device *dev, struct device_attribute *attr, 195 + static ssize_t red_show(struct device *dev, struct device_attribute *attr, 196 196 char *buf) 197 197 { 198 198 return show_color_common(dev, buf, RED); 199 199 } 200 200 201 - static ssize_t store_red(struct device *dev, struct device_attribute *attr, 201 + static ssize_t red_store(struct device *dev, struct device_attribute *attr, 202 202 const char *buf, size_t count) 203 203 { 204 204 int ret; ··· 209 209 return count; 210 210 } 211 211 212 - static DEVICE_ATTR(red, S_IRUGO | S_IWUSR, show_red, store_red); 212 + static DEVICE_ATTR_RW(red); 213 213 214 - static ssize_t show_green(struct device *dev, struct device_attribute *attr, 214 + static ssize_t green_show(struct device *dev, struct device_attribute *attr, 215 215 char *buf) 216 216 { 217 217 return show_color_common(dev, buf, GREEN); 218 218 } 219 219 220 - static ssize_t store_green(struct device *dev, struct device_attribute *attr, 220 + static ssize_t green_store(struct device *dev, struct device_attribute *attr, 221 221 const char *buf, size_t count) 222 222 { 223 223 ··· 229 229 return count; 230 230 } 231 231 232 - static DEVICE_ATTR(green, S_IRUGO | S_IWUSR, show_green, store_green); 232 + static DEVICE_ATTR_RW(green); 233 233 234 - static ssize_t show_blue(struct device *dev, struct device_attribute *attr, 234 + static ssize_t blue_show(struct device *dev, struct device_attribute *attr, 235 235 char *buf) 236 236 { 237 237 return show_color_common(dev, buf, BLUE); 238 238 } 239 239 240 - static ssize_t store_blue(struct device *dev, struct device_attribute *attr, 240 + static ssize_t blue_store(struct device *dev, struct device_attribute *attr, 241 241 const char *buf, size_t count) 242 242 { 243 243 int ret; ··· 248 248 return count; 249 249 } 250 250 251 - static DEVICE_ATTR(blue, S_IRUGO | S_IWUSR, show_blue, store_blue); 251 + static DEVICE_ATTR_RW(blue); 252 252 253 - static ssize_t show_test(struct device *dev, struct device_attribute *attr, 253 + static ssize_t test_show(struct device *dev, struct device_attribute *attr, 254 254 char *buf) 255 255 { 256 256 return scnprintf(buf, PAGE_SIZE, 257 257 "#Write into test to start test sequence!#\n"); 258 258 } 259 259 260 - static ssize_t store_test(struct device *dev, struct device_attribute *attr, 260 + static ssize_t test_store(struct device *dev, struct device_attribute *attr, 261 261 const char *buf, size_t count) 262 262 { 263 263 ··· 273 273 return count; 274 274 } 275 275 276 - static DEVICE_ATTR(test, S_IRUGO | S_IWUSR, show_test, store_test); 276 + static DEVICE_ATTR_RW(test); 277 277 278 278 /* TODO: HSB, fade, timeadj, script ... */ 279 279
+5 -5
drivers/leds/leds-lm3530.c
··· 346 346 } 347 347 } 348 348 349 - static ssize_t lm3530_mode_get(struct device *dev, 350 - struct device_attribute *attr, char *buf) 349 + static ssize_t mode_show(struct device *dev, 350 + struct device_attribute *attr, char *buf) 351 351 { 352 352 struct led_classdev *led_cdev = dev_get_drvdata(dev); 353 353 struct lm3530_data *drvdata; ··· 365 365 return len; 366 366 } 367 367 368 - static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute 369 - *attr, const char *buf, size_t size) 368 + static ssize_t mode_store(struct device *dev, struct device_attribute 369 + *attr, const char *buf, size_t size) 370 370 { 371 371 struct led_classdev *led_cdev = dev_get_drvdata(dev); 372 372 struct lm3530_data *drvdata; ··· 397 397 398 398 return sizeof(drvdata->mode); 399 399 } 400 - static DEVICE_ATTR(mode, 0644, lm3530_mode_get, lm3530_mode_set); 400 + static DEVICE_ATTR_RW(mode); 401 401 402 402 static struct attribute *lm3530_attrs[] = { 403 403 &dev_attr_mode.attr,
+4 -4
drivers/leds/leds-lm355x.c
··· 349 349 } 350 350 351 351 /* indicator pattern only for lm3556*/ 352 - static ssize_t lm3556_indicator_pattern_store(struct device *dev, 353 - struct device_attribute *attr, 354 - const char *buf, size_t size) 352 + static ssize_t pattern_store(struct device *dev, 353 + struct device_attribute *attr, 354 + const char *buf, size_t size) 355 355 { 356 356 ssize_t ret; 357 357 struct led_classdev *led_cdev = dev_get_drvdata(dev); ··· 381 381 return ret; 382 382 } 383 383 384 - static DEVICE_ATTR(pattern, S_IWUSR, NULL, lm3556_indicator_pattern_store); 384 + static DEVICE_ATTR_WO(pattern); 385 385 386 386 static struct attribute *lm355x_indicator_attrs[] = { 387 387 &dev_attr_pattern.attr,
+8 -8
drivers/leds/leds-lm3642.c
··· 165 165 /* torch */ 166 166 167 167 /* torch pin config for lm3642 */ 168 - static ssize_t lm3642_torch_pin_store(struct device *dev, 169 - struct device_attribute *attr, 170 - const char *buf, size_t size) 168 + static ssize_t torch_pin_store(struct device *dev, 169 + struct device_attribute *attr, 170 + const char *buf, size_t size) 171 171 { 172 172 ssize_t ret; 173 173 struct led_classdev *led_cdev = dev_get_drvdata(dev); ··· 193 193 return size; 194 194 } 195 195 196 - static DEVICE_ATTR(torch_pin, S_IWUSR, NULL, lm3642_torch_pin_store); 196 + static DEVICE_ATTR_WO(torch_pin); 197 197 198 198 static int lm3642_torch_brightness_set(struct led_classdev *cdev, 199 199 enum led_brightness brightness) ··· 212 212 /* flash */ 213 213 214 214 /* strobe pin config for lm3642*/ 215 - static ssize_t lm3642_strobe_pin_store(struct device *dev, 216 - struct device_attribute *attr, 217 - const char *buf, size_t size) 215 + static ssize_t strobe_pin_store(struct device *dev, 216 + struct device_attribute *attr, 217 + const char *buf, size_t size) 218 218 { 219 219 ssize_t ret; 220 220 struct led_classdev *led_cdev = dev_get_drvdata(dev); ··· 240 240 return size; 241 241 } 242 242 243 - static DEVICE_ATTR(strobe_pin, S_IWUSR, NULL, lm3642_strobe_pin_store); 243 + static DEVICE_ATTR_WO(strobe_pin); 244 244 245 245 static int lm3642_strobe_brightness_set(struct led_classdev *cdev, 246 246 enum led_brightness brightness)
+6 -6
drivers/leds/leds-max8997.c
··· 160 160 } 161 161 } 162 162 163 - static ssize_t max8997_led_show_mode(struct device *dev, 164 - struct device_attribute *attr, char *buf) 163 + static ssize_t mode_show(struct device *dev, 164 + struct device_attribute *attr, char *buf) 165 165 { 166 166 struct led_classdev *led_cdev = dev_get_drvdata(dev); 167 167 struct max8997_led *led = ··· 193 193 return ret; 194 194 } 195 195 196 - static ssize_t max8997_led_store_mode(struct device *dev, 197 - struct device_attribute *attr, 198 - const char *buf, size_t size) 196 + static ssize_t mode_store(struct device *dev, 197 + struct device_attribute *attr, 198 + const char *buf, size_t size) 199 199 { 200 200 struct led_classdev *led_cdev = dev_get_drvdata(dev); 201 201 struct max8997_led *led = ··· 222 222 return size; 223 223 } 224 224 225 - static DEVICE_ATTR(mode, 0644, max8997_led_show_mode, max8997_led_store_mode); 225 + static DEVICE_ATTR_RW(mode); 226 226 227 227 static struct attribute *max8997_attrs[] = { 228 228 &dev_attr_mode.attr,
+6 -6
drivers/leds/leds-netxbig.c
··· 204 204 spin_unlock_irqrestore(&led_dat->lock, flags); 205 205 } 206 206 207 - static ssize_t netxbig_led_sata_store(struct device *dev, 208 - struct device_attribute *attr, 209 - const char *buff, size_t count) 207 + static ssize_t sata_store(struct device *dev, 208 + struct device_attribute *attr, 209 + const char *buff, size_t count) 210 210 { 211 211 struct led_classdev *led_cdev = dev_get_drvdata(dev); 212 212 struct netxbig_led_data *led_dat = ··· 255 255 return ret; 256 256 } 257 257 258 - static ssize_t netxbig_led_sata_show(struct device *dev, 259 - struct device_attribute *attr, char *buf) 258 + static ssize_t sata_show(struct device *dev, 259 + struct device_attribute *attr, char *buf) 260 260 { 261 261 struct led_classdev *led_cdev = dev_get_drvdata(dev); 262 262 struct netxbig_led_data *led_dat = ··· 265 265 return sprintf(buf, "%d\n", led_dat->sata); 266 266 } 267 267 268 - static DEVICE_ATTR(sata, 0644, netxbig_led_sata_show, netxbig_led_sata_store); 268 + static DEVICE_ATTR_RW(sata); 269 269 270 270 static struct attribute *netxbig_led_attrs[] = { 271 271 &dev_attr_sata.attr,
+6 -6
drivers/leds/leds-ss4200.c
··· 441 441 nasgpio_led_set_brightness(&amber->led_cdev, LED_FULL); 442 442 } 443 443 444 - static ssize_t nas_led_blink_show(struct device *dev, 445 - struct device_attribute *attr, char *buf) 444 + static ssize_t blink_show(struct device *dev, 445 + struct device_attribute *attr, char *buf) 446 446 { 447 447 struct led_classdev *led = dev_get_drvdata(dev); 448 448 int blinking = 0; ··· 451 451 return sprintf(buf, "%u\n", blinking); 452 452 } 453 453 454 - static ssize_t nas_led_blink_store(struct device *dev, 455 - struct device_attribute *attr, 456 - const char *buf, size_t size) 454 + static ssize_t blink_store(struct device *dev, 455 + struct device_attribute *attr, 456 + const char *buf, size_t size) 457 457 { 458 458 int ret; 459 459 struct led_classdev *led = dev_get_drvdata(dev); ··· 468 468 return size; 469 469 } 470 470 471 - static DEVICE_ATTR(blink, 0644, nas_led_blink_show, nas_led_blink_store); 471 + static DEVICE_ATTR_RW(blink); 472 472 473 473 static struct attribute *nasgpio_led_attrs[] = { 474 474 &dev_attr_blink.attr,
+6 -6
drivers/leds/leds-wm831x-status.c
··· 155 155 "soft", 156 156 }; 157 157 158 - static ssize_t wm831x_status_src_show(struct device *dev, 159 - struct device_attribute *attr, char *buf) 158 + static ssize_t src_show(struct device *dev, 159 + struct device_attribute *attr, char *buf) 160 160 { 161 161 struct led_classdev *led_cdev = dev_get_drvdata(dev); 162 162 struct wm831x_status *led = to_wm831x_status(led_cdev); ··· 178 178 return ret; 179 179 } 180 180 181 - static ssize_t wm831x_status_src_store(struct device *dev, 182 - struct device_attribute *attr, 183 - const char *buf, size_t size) 181 + static ssize_t src_store(struct device *dev, 182 + struct device_attribute *attr, 183 + const char *buf, size_t size) 184 184 { 185 185 struct led_classdev *led_cdev = dev_get_drvdata(dev); 186 186 struct wm831x_status *led = to_wm831x_status(led_cdev); ··· 197 197 return size; 198 198 } 199 199 200 - static DEVICE_ATTR(src, 0644, wm831x_status_src_show, wm831x_status_src_store); 200 + static DEVICE_ATTR_RW(src); 201 201 202 202 static struct attribute *wm831x_status_attrs[] = { 203 203 &dev_attr_src.attr,