diff options
Diffstat (limited to 'drivers/leds/ledtrig-timer.c')
-rw-r--r-- | drivers/leds/ledtrig-timer.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c index d756bdb01c59..ed9ff02c77ea 100644 --- a/drivers/leds/ledtrig-timer.c +++ b/drivers/leds/ledtrig-timer.c | |||
@@ -52,9 +52,10 @@ static void led_timer_function(unsigned long data) | |||
52 | mod_timer(&timer_data->timer, jiffies + msecs_to_jiffies(delay)); | 52 | mod_timer(&timer_data->timer, jiffies + msecs_to_jiffies(delay)); |
53 | } | 53 | } |
54 | 54 | ||
55 | static ssize_t led_delay_on_show(struct class_device *dev, char *buf) | 55 | static ssize_t led_delay_on_show(struct device *dev, |
56 | struct device_attribute *attr, char *buf) | ||
56 | { | 57 | { |
57 | struct led_classdev *led_cdev = class_get_devdata(dev); | 58 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
58 | struct timer_trig_data *timer_data = led_cdev->trigger_data; | 59 | struct timer_trig_data *timer_data = led_cdev->trigger_data; |
59 | 60 | ||
60 | sprintf(buf, "%lu\n", timer_data->delay_on); | 61 | sprintf(buf, "%lu\n", timer_data->delay_on); |
@@ -62,10 +63,10 @@ static ssize_t led_delay_on_show(struct class_device *dev, char *buf) | |||
62 | return strlen(buf) + 1; | 63 | return strlen(buf) + 1; |
63 | } | 64 | } |
64 | 65 | ||
65 | static ssize_t led_delay_on_store(struct class_device *dev, const char *buf, | 66 | static ssize_t led_delay_on_store(struct device *dev, |
66 | size_t size) | 67 | struct device_attribute *attr, const char *buf, size_t size) |
67 | { | 68 | { |
68 | struct led_classdev *led_cdev = class_get_devdata(dev); | 69 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
69 | struct timer_trig_data *timer_data = led_cdev->trigger_data; | 70 | struct timer_trig_data *timer_data = led_cdev->trigger_data; |
70 | int ret = -EINVAL; | 71 | int ret = -EINVAL; |
71 | char *after; | 72 | char *after; |
@@ -84,9 +85,10 @@ static ssize_t led_delay_on_store(struct class_device *dev, const char *buf, | |||
84 | return ret; | 85 | return ret; |
85 | } | 86 | } |
86 | 87 | ||
87 | static ssize_t led_delay_off_show(struct class_device *dev, char *buf) | 88 | static ssize_t led_delay_off_show(struct device *dev, |
89 | struct device_attribute *attr, char *buf) | ||
88 | { | 90 | { |
89 | struct led_classdev *led_cdev = class_get_devdata(dev); | 91 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
90 | struct timer_trig_data *timer_data = led_cdev->trigger_data; | 92 | struct timer_trig_data *timer_data = led_cdev->trigger_data; |
91 | 93 | ||
92 | sprintf(buf, "%lu\n", timer_data->delay_off); | 94 | sprintf(buf, "%lu\n", timer_data->delay_off); |
@@ -94,10 +96,10 @@ static ssize_t led_delay_off_show(struct class_device *dev, char *buf) | |||
94 | return strlen(buf) + 1; | 96 | return strlen(buf) + 1; |
95 | } | 97 | } |
96 | 98 | ||
97 | static ssize_t led_delay_off_store(struct class_device *dev, const char *buf, | 99 | static ssize_t led_delay_off_store(struct device *dev, |
98 | size_t size) | 100 | struct device_attribute *attr, const char *buf, size_t size) |
99 | { | 101 | { |
100 | struct led_classdev *led_cdev = class_get_devdata(dev); | 102 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
101 | struct timer_trig_data *timer_data = led_cdev->trigger_data; | 103 | struct timer_trig_data *timer_data = led_cdev->trigger_data; |
102 | int ret = -EINVAL; | 104 | int ret = -EINVAL; |
103 | char *after; | 105 | char *after; |
@@ -116,10 +118,8 @@ static ssize_t led_delay_off_store(struct class_device *dev, const char *buf, | |||
116 | return ret; | 118 | return ret; |
117 | } | 119 | } |
118 | 120 | ||
119 | static CLASS_DEVICE_ATTR(delay_on, 0644, led_delay_on_show, | 121 | static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store); |
120 | led_delay_on_store); | 122 | static DEVICE_ATTR(delay_off, 0644, led_delay_off_show, led_delay_off_store); |
121 | static CLASS_DEVICE_ATTR(delay_off, 0644, led_delay_off_show, | ||
122 | led_delay_off_store); | ||
123 | 123 | ||
124 | static void timer_trig_activate(struct led_classdev *led_cdev) | 124 | static void timer_trig_activate(struct led_classdev *led_cdev) |
125 | { | 125 | { |
@@ -136,18 +136,17 @@ static void timer_trig_activate(struct led_classdev *led_cdev) | |||
136 | timer_data->timer.function = led_timer_function; | 136 | timer_data->timer.function = led_timer_function; |
137 | timer_data->timer.data = (unsigned long) led_cdev; | 137 | timer_data->timer.data = (unsigned long) led_cdev; |
138 | 138 | ||
139 | rc = class_device_create_file(led_cdev->class_dev, | 139 | rc = device_create_file(led_cdev->dev, &dev_attr_delay_on); |
140 | &class_device_attr_delay_on); | 140 | if (rc) |
141 | if (rc) goto err_out; | 141 | goto err_out; |
142 | rc = class_device_create_file(led_cdev->class_dev, | 142 | rc = device_create_file(led_cdev->dev, &dev_attr_delay_off); |
143 | &class_device_attr_delay_off); | 143 | if (rc) |
144 | if (rc) goto err_out_delayon; | 144 | goto err_out_delayon; |
145 | 145 | ||
146 | return; | 146 | return; |
147 | 147 | ||
148 | err_out_delayon: | 148 | err_out_delayon: |
149 | class_device_remove_file(led_cdev->class_dev, | 149 | device_remove_file(led_cdev->dev, &dev_attr_delay_on); |
150 | &class_device_attr_delay_on); | ||
151 | err_out: | 150 | err_out: |
152 | led_cdev->trigger_data = NULL; | 151 | led_cdev->trigger_data = NULL; |
153 | kfree(timer_data); | 152 | kfree(timer_data); |
@@ -158,10 +157,8 @@ static void timer_trig_deactivate(struct led_classdev *led_cdev) | |||
158 | struct timer_trig_data *timer_data = led_cdev->trigger_data; | 157 | struct timer_trig_data *timer_data = led_cdev->trigger_data; |
159 | 158 | ||
160 | if (timer_data) { | 159 | if (timer_data) { |
161 | class_device_remove_file(led_cdev->class_dev, | 160 | device_remove_file(led_cdev->dev, &dev_attr_delay_on); |
162 | &class_device_attr_delay_on); | 161 | device_remove_file(led_cdev->dev, &dev_attr_delay_off); |
163 | class_device_remove_file(led_cdev->class_dev, | ||
164 | &class_device_attr_delay_off); | ||
165 | del_timer_sync(&timer_data->timer); | 162 | del_timer_sync(&timer_data->timer); |
166 | kfree(timer_data); | 163 | kfree(timer_data); |
167 | } | 164 | } |