Blame view

drivers/leds/leds-ams-delta.c 2.7 KB
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
1
2
3
4
5
6
7
8
9
  /*
   * 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.
   */
86383b557   Axel Lin   leds: add missing...
10
  #include <linux/module.h>
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
11
12
13
14
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <linux/platform_device.h>
  #include <linux/leds.h>
ce491cf85   Tony Lindgren   omap: headers: Mo...
15
  #include <plat/board-ams-delta.h>
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  
  /*
   * 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		= {
6c152beef   Richard Purdie   leds: Standardise...
40
  			.name		= "ams-delta::camera",
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
41
42
43
44
45
46
  			.brightness_set = ams_delta_led_set,
  		},
  		.bitmask	= AMS_DELTA_LATCH1_LED_CAMERA,
  	},
  	{
  		.cdev		= {
6c152beef   Richard Purdie   leds: Standardise...
47
  			.name		= "ams-delta::advert",
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
48
49
50
51
52
53
  			.brightness_set = ams_delta_led_set,
  		},
  		.bitmask	= AMS_DELTA_LATCH1_LED_ADVERT,
  	},
  	{
  		.cdev		= {
6c152beef   Richard Purdie   leds: Standardise...
54
  			.name		= "ams-delta::email",
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
55
56
57
58
59
60
  			.brightness_set = ams_delta_led_set,
  		},
  		.bitmask	= AMS_DELTA_LATCH1_LED_EMAIL,
  	},
  	{
  		.cdev		= {
6c152beef   Richard Purdie   leds: Standardise...
61
  			.name		= "ams-delta::handsfree",
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
62
63
64
65
66
67
  			.brightness_set = ams_delta_led_set,
  		},
  		.bitmask	= AMS_DELTA_LATCH1_LED_HANDSFREE,
  	},
  	{
  		.cdev		= {
6c152beef   Richard Purdie   leds: Standardise...
68
  			.name		= "ams-delta::voicemail",
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
69
70
71
72
73
74
  			.brightness_set = ams_delta_led_set,
  		},
  		.bitmask	= AMS_DELTA_LATCH1_LED_VOICEMAIL,
  	},
  	{
  		.cdev		= {
6c152beef   Richard Purdie   leds: Standardise...
75
  			.name		= "ams-delta::voice",
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
76
77
78
79
80
  			.brightness_set = ams_delta_led_set,
  		},
  		.bitmask	= AMS_DELTA_LATCH1_LED_VOICE,
  	},
  };
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
81
82
  static int ams_delta_led_probe(struct platform_device *pdev)
  {
fbf0baee8   Richard Purdie   leds: Simplify lo...
83
  	int i, ret;
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
84

fbf0baee8   Richard Purdie   leds: Simplify lo...
85
  	for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++) {
859cb7f2a   Richard Purdie   leds: Add suspend...
86
  		ams_delta_leds[i].cdev.flags |= LED_CORE_SUSPENDRESUME;
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
87
88
  		ret = led_classdev_register(&pdev->dev,
  				&ams_delta_leds[i].cdev);
fbf0baee8   Richard Purdie   leds: Simplify lo...
89
90
  		if (ret < 0)
  			goto fail;
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
91
  	}
fbf0baee8   Richard Purdie   leds: Simplify lo...
92
93
94
95
96
  	return 0;
  fail:
  	while (--i >= 0)
  		led_classdev_unregister(&ams_delta_leds[i].cdev);
  	return ret;	
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
97
98
99
100
101
  }
  
  static int ams_delta_led_remove(struct platform_device *pdev)
  {
  	int i;
12276efcc   Sven Wegener   leds: Fix wrong l...
102
  	for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
103
104
105
106
107
108
109
110
  		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,
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
111
112
  	.driver		= {
  		.name = "ams-delta-led",
3c4ded971   Kay Sievers   leds: fix platfor...
113
  		.owner = THIS_MODULE,
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
114
115
  	},
  };
892a8843f   Axel Lin   leds: convert led...
116
  module_platform_driver(ams_delta_led_driver);
9becde79d   Jonathan McDowell   [PATCH] leds: Ams...
117
118
119
120
  
  MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
  MODULE_DESCRIPTION("Amstrad Delta LED driver");
  MODULE_LICENSE("GPL");
3c4ded971   Kay Sievers   leds: fix platfor...
121
  MODULE_ALIAS("platform:ams-delta-led");