mirror of
https://github.com/torvalds/linux.git
synced 2024-11-16 09:02:00 +00:00
892a8843fb
Factor out some boilerplate code for platform driver registration into module_platform_driver. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Haojian Zhuang <hzhuang1@marvell.com> [led-88pm860x.c] Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Michael Hennerich <hennerich@blackfin.uclinux.org> Cc: Mike Rapoport <mike@compulab.co.il> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
127 lines
2.7 KiB
C
127 lines
2.7 KiB
C
/*
|
|
* LEDs driver for Amstrad Delta (E3)
|
|
*
|
|
* Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/leds.h>
|
|
#include <plat/board-ams-delta.h>
|
|
|
|
/*
|
|
* Our context
|
|
*/
|
|
struct ams_delta_led {
|
|
struct led_classdev cdev;
|
|
u8 bitmask;
|
|
};
|
|
|
|
static void ams_delta_led_set(struct led_classdev *led_cdev,
|
|
enum led_brightness value)
|
|
{
|
|
struct ams_delta_led *led_dev =
|
|
container_of(led_cdev, struct ams_delta_led, cdev);
|
|
|
|
if (value)
|
|
ams_delta_latch1_write(led_dev->bitmask, led_dev->bitmask);
|
|
else
|
|
ams_delta_latch1_write(led_dev->bitmask, 0);
|
|
}
|
|
|
|
static struct ams_delta_led ams_delta_leds[] = {
|
|
{
|
|
.cdev = {
|
|
.name = "ams-delta::camera",
|
|
.brightness_set = ams_delta_led_set,
|
|
},
|
|
.bitmask = AMS_DELTA_LATCH1_LED_CAMERA,
|
|
},
|
|
{
|
|
.cdev = {
|
|
.name = "ams-delta::advert",
|
|
.brightness_set = ams_delta_led_set,
|
|
},
|
|
.bitmask = AMS_DELTA_LATCH1_LED_ADVERT,
|
|
},
|
|
{
|
|
.cdev = {
|
|
.name = "ams-delta::email",
|
|
.brightness_set = ams_delta_led_set,
|
|
},
|
|
.bitmask = AMS_DELTA_LATCH1_LED_EMAIL,
|
|
},
|
|
{
|
|
.cdev = {
|
|
.name = "ams-delta::handsfree",
|
|
.brightness_set = ams_delta_led_set,
|
|
},
|
|
.bitmask = AMS_DELTA_LATCH1_LED_HANDSFREE,
|
|
},
|
|
{
|
|
.cdev = {
|
|
.name = "ams-delta::voicemail",
|
|
.brightness_set = ams_delta_led_set,
|
|
},
|
|
.bitmask = AMS_DELTA_LATCH1_LED_VOICEMAIL,
|
|
},
|
|
{
|
|
.cdev = {
|
|
.name = "ams-delta::voice",
|
|
.brightness_set = ams_delta_led_set,
|
|
},
|
|
.bitmask = AMS_DELTA_LATCH1_LED_VOICE,
|
|
},
|
|
};
|
|
|
|
static int ams_delta_led_probe(struct platform_device *pdev)
|
|
{
|
|
int i, ret;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++) {
|
|
ams_delta_leds[i].cdev.flags |= LED_CORE_SUSPENDRESUME;
|
|
ret = led_classdev_register(&pdev->dev,
|
|
&ams_delta_leds[i].cdev);
|
|
if (ret < 0)
|
|
goto fail;
|
|
}
|
|
|
|
return 0;
|
|
fail:
|
|
while (--i >= 0)
|
|
led_classdev_unregister(&ams_delta_leds[i].cdev);
|
|
return ret;
|
|
}
|
|
|
|
static int ams_delta_led_remove(struct platform_device *pdev)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
|
|
led_classdev_unregister(&ams_delta_leds[i].cdev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver ams_delta_led_driver = {
|
|
.probe = ams_delta_led_probe,
|
|
.remove = ams_delta_led_remove,
|
|
.driver = {
|
|
.name = "ams-delta-led",
|
|
.owner = THIS_MODULE,
|
|
},
|
|
};
|
|
|
|
module_platform_driver(ams_delta_led_driver);
|
|
|
|
MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
|
|
MODULE_DESCRIPTION("Amstrad Delta LED driver");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_ALIAS("platform:ams-delta-led");
|