leds-max8997.c (bf61c8840efe60fd8f91446860b63338fb424158) | leds-max8997.c (35c164998eede9e3d49f51541fcf2e639670fe72) |
---|---|
1/* 2 * leds-max8997.c - LED class driver for MAX8997 LEDs. 3 * 4 * Copyright (C) 2011 Samsung Electronics 5 * Donggeun Kim <dg77.kim@samsung.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 215 unchanged lines hidden (view full) --- 224 225 mutex_unlock(&led->mutex); 226 227 return size; 228} 229 230static DEVICE_ATTR(mode, 0644, max8997_led_show_mode, max8997_led_store_mode); 231 | 1/* 2 * leds-max8997.c - LED class driver for MAX8997 LEDs. 3 * 4 * Copyright (C) 2011 Samsung Electronics 5 * Donggeun Kim <dg77.kim@samsung.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 215 unchanged lines hidden (view full) --- 224 225 mutex_unlock(&led->mutex); 226 227 return size; 228} 229 230static DEVICE_ATTR(mode, 0644, max8997_led_show_mode, max8997_led_store_mode); 231 |
232static struct attribute *max8997_attrs[] = { 233 &dev_attr_mode.attr, 234 NULL 235}; 236ATTRIBUTE_GROUPS(max8997); 237 |
|
232static int max8997_led_probe(struct platform_device *pdev) 233{ 234 struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); 235 struct max8997_platform_data *pdata = dev_get_platdata(iodev->dev); 236 struct max8997_led *led; 237 char name[20]; 238 int ret = 0; 239 --- 8 unchanged lines hidden (view full) --- 248 249 led->id = pdev->id; 250 snprintf(name, sizeof(name), "max8997-led%d", pdev->id); 251 252 led->cdev.name = name; 253 led->cdev.brightness_set = max8997_led_brightness_set; 254 led->cdev.flags |= LED_CORE_SUSPENDRESUME; 255 led->cdev.brightness = 0; | 238static int max8997_led_probe(struct platform_device *pdev) 239{ 240 struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); 241 struct max8997_platform_data *pdata = dev_get_platdata(iodev->dev); 242 struct max8997_led *led; 243 char name[20]; 244 int ret = 0; 245 --- 8 unchanged lines hidden (view full) --- 254 255 led->id = pdev->id; 256 snprintf(name, sizeof(name), "max8997-led%d", pdev->id); 257 258 led->cdev.name = name; 259 led->cdev.brightness_set = max8997_led_brightness_set; 260 led->cdev.flags |= LED_CORE_SUSPENDRESUME; 261 led->cdev.brightness = 0; |
262 led->cdev.groups = max8997_groups; |
|
256 led->iodev = iodev; 257 258 /* initialize mode and brightness according to platform_data */ 259 if (pdata->led_pdata) { 260 u8 mode = 0, brightness = 0; 261 262 mode = pdata->led_pdata->mode[led->id]; 263 brightness = pdata->led_pdata->brightness[led->id]; --- 12 unchanged lines hidden (view full) --- 276 mutex_init(&led->mutex); 277 278 platform_set_drvdata(pdev, led); 279 280 ret = led_classdev_register(&pdev->dev, &led->cdev); 281 if (ret < 0) 282 return ret; 283 | 263 led->iodev = iodev; 264 265 /* initialize mode and brightness according to platform_data */ 266 if (pdata->led_pdata) { 267 u8 mode = 0, brightness = 0; 268 269 mode = pdata->led_pdata->mode[led->id]; 270 brightness = pdata->led_pdata->brightness[led->id]; --- 12 unchanged lines hidden (view full) --- 283 mutex_init(&led->mutex); 284 285 platform_set_drvdata(pdev, led); 286 287 ret = led_classdev_register(&pdev->dev, &led->cdev); 288 if (ret < 0) 289 return ret; 290 |
284 ret = device_create_file(led->cdev.dev, &dev_attr_mode); 285 if (ret != 0) { 286 dev_err(&pdev->dev, 287 "failed to create file: %d\n", ret); 288 led_classdev_unregister(&led->cdev); 289 return ret; 290 } 291 | |
292 return 0; 293} 294 295static int max8997_led_remove(struct platform_device *pdev) 296{ 297 struct max8997_led *led = platform_get_drvdata(pdev); 298 | 291 return 0; 292} 293 294static int max8997_led_remove(struct platform_device *pdev) 295{ 296 struct max8997_led *led = platform_get_drvdata(pdev); 297 |
299 device_remove_file(led->cdev.dev, &dev_attr_mode); | |
300 led_classdev_unregister(&led->cdev); 301 302 return 0; 303} 304 305static struct platform_driver max8997_led_driver = { 306 .driver = { 307 .name = "max8997-led", --- 12 unchanged lines hidden --- | 298 led_classdev_unregister(&led->cdev); 299 300 return 0; 301} 302 303static struct platform_driver max8997_led_driver = { 304 .driver = { 305 .name = "max8997-led", --- 12 unchanged lines hidden --- |