aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@mail.ru>2007-02-07 19:12:28 -0500
committerRichard Purdie <rpurdie@rpsys.net>2007-02-20 03:38:44 -0500
commit90968e8ebc4611896ff7f2ef0c0bf8455e845cd1 (patch)
treeb2b59bb46bf1118f7283145953c494c5164534d0 /drivers
parentdfcba200679dc3f62212154b65b40b835ce69ab7 (diff)
backlight: Remove excessive (un)likelys
Remove excessive numbers of (un)likely()s in the backlight core. There are no hot paths in this code so rely on compiler to do the right thing. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/backlight/backlight.c24
-rw-r--r--drivers/video/backlight/lcd.c16
2 files changed, 20 insertions, 20 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 71056f8b621a..7a85be4d2b0a 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -37,7 +37,7 @@ static int fb_notifier_callback(struct notifier_block *self,
37 if (!bd->props->check_fb || 37 if (!bd->props->check_fb ||
38 bd->props->check_fb(evdata->info)) { 38 bd->props->check_fb(evdata->info)) {
39 bd->props->fb_blank = *(int *)evdata->data; 39 bd->props->fb_blank = *(int *)evdata->data;
40 if (likely(bd->props && bd->props->update_status)) 40 if (bd->props && bd->props->update_status)
41 bd->props->update_status(bd); 41 bd->props->update_status(bd);
42 } 42 }
43 up(&bd->sem); 43 up(&bd->sem);
@@ -73,7 +73,7 @@ static ssize_t backlight_show_power(struct class_device *cdev, char *buf)
73 struct backlight_device *bd = to_backlight_device(cdev); 73 struct backlight_device *bd = to_backlight_device(cdev);
74 74
75 down(&bd->sem); 75 down(&bd->sem);
76 if (likely(bd->props)) 76 if (bd->props)
77 rc = sprintf(buf, "%d\n", bd->props->power); 77 rc = sprintf(buf, "%d\n", bd->props->power);
78 up(&bd->sem); 78 up(&bd->sem);
79 79
@@ -94,10 +94,10 @@ static ssize_t backlight_store_power(struct class_device *cdev, const char *buf,
94 return -EINVAL; 94 return -EINVAL;
95 95
96 down(&bd->sem); 96 down(&bd->sem);
97 if (likely(bd->props)) { 97 if (bd->props) {
98 pr_debug("backlight: set power to %d\n", power); 98 pr_debug("backlight: set power to %d\n", power);
99 bd->props->power = power; 99 bd->props->power = power;
100 if (likely(bd->props->update_status)) 100 if (bd->props->update_status)
101 bd->props->update_status(bd); 101 bd->props->update_status(bd);
102 rc = count; 102 rc = count;
103 } 103 }
@@ -112,7 +112,7 @@ static ssize_t backlight_show_brightness(struct class_device *cdev, char *buf)
112 struct backlight_device *bd = to_backlight_device(cdev); 112 struct backlight_device *bd = to_backlight_device(cdev);
113 113
114 down(&bd->sem); 114 down(&bd->sem);
115 if (likely(bd->props)) 115 if (bd->props)
116 rc = sprintf(buf, "%d\n", bd->props->brightness); 116 rc = sprintf(buf, "%d\n", bd->props->brightness);
117 up(&bd->sem); 117 up(&bd->sem);
118 118
@@ -133,14 +133,14 @@ static ssize_t backlight_store_brightness(struct class_device *cdev, const char
133 return -EINVAL; 133 return -EINVAL;
134 134
135 down(&bd->sem); 135 down(&bd->sem);
136 if (likely(bd->props)) { 136 if (bd->props) {
137 if (brightness > bd->props->max_brightness) 137 if (brightness > bd->props->max_brightness)
138 rc = -EINVAL; 138 rc = -EINVAL;
139 else { 139 else {
140 pr_debug("backlight: set brightness to %d\n", 140 pr_debug("backlight: set brightness to %d\n",
141 brightness); 141 brightness);
142 bd->props->brightness = brightness; 142 bd->props->brightness = brightness;
143 if (likely(bd->props->update_status)) 143 if (bd->props->update_status)
144 bd->props->update_status(bd); 144 bd->props->update_status(bd);
145 rc = count; 145 rc = count;
146 } 146 }
@@ -156,7 +156,7 @@ static ssize_t backlight_show_max_brightness(struct class_device *cdev, char *bu
156 struct backlight_device *bd = to_backlight_device(cdev); 156 struct backlight_device *bd = to_backlight_device(cdev);
157 157
158 down(&bd->sem); 158 down(&bd->sem);
159 if (likely(bd->props)) 159 if (bd->props)
160 rc = sprintf(buf, "%d\n", bd->props->max_brightness); 160 rc = sprintf(buf, "%d\n", bd->props->max_brightness);
161 up(&bd->sem); 161 up(&bd->sem);
162 162
@@ -170,7 +170,7 @@ static ssize_t backlight_show_actual_brightness(struct class_device *cdev,
170 struct backlight_device *bd = to_backlight_device(cdev); 170 struct backlight_device *bd = to_backlight_device(cdev);
171 171
172 down(&bd->sem); 172 down(&bd->sem);
173 if (likely(bd->props && bd->props->get_brightness)) 173 if (bd->props && bd->props->get_brightness)
174 rc = sprintf(buf, "%d\n", bd->props->get_brightness(bd)); 174 rc = sprintf(buf, "%d\n", bd->props->get_brightness(bd));
175 up(&bd->sem); 175 up(&bd->sem);
176 176
@@ -227,7 +227,7 @@ struct backlight_device *backlight_device_register(const char *name,
227 pr_debug("backlight_device_alloc: name=%s\n", name); 227 pr_debug("backlight_device_alloc: name=%s\n", name);
228 228
229 new_bd = kmalloc(sizeof(struct backlight_device), GFP_KERNEL); 229 new_bd = kmalloc(sizeof(struct backlight_device), GFP_KERNEL);
230 if (unlikely(!new_bd)) 230 if (!new_bd)
231 return ERR_PTR(-ENOMEM); 231 return ERR_PTR(-ENOMEM);
232 232
233 init_MUTEX(&new_bd->sem); 233 init_MUTEX(&new_bd->sem);
@@ -239,7 +239,7 @@ struct backlight_device *backlight_device_register(const char *name,
239 class_set_devdata(&new_bd->class_dev, devdata); 239 class_set_devdata(&new_bd->class_dev, devdata);
240 240
241 rc = class_device_register(&new_bd->class_dev); 241 rc = class_device_register(&new_bd->class_dev);
242 if (unlikely(rc)) { 242 if (rc) {
243 kfree(new_bd); 243 kfree(new_bd);
244 return ERR_PTR(rc); 244 return ERR_PTR(rc);
245 } 245 }
@@ -254,7 +254,7 @@ struct backlight_device *backlight_device_register(const char *name,
254 for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) { 254 for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) {
255 rc = class_device_create_file(&new_bd->class_dev, 255 rc = class_device_create_file(&new_bd->class_dev,
256 &bl_class_device_attributes[i]); 256 &bl_class_device_attributes[i]);
257 if (unlikely(rc)) { 257 if (rc) {
258 while (--i >= 0) 258 while (--i >= 0)
259 class_device_remove_file(&new_bd->class_dev, 259 class_device_remove_file(&new_bd->class_dev,
260 &bl_class_device_attributes[i]); 260 &bl_class_device_attributes[i]);
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index f95f0e33101d..959024812abc 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -67,7 +67,7 @@ static ssize_t lcd_show_power(struct class_device *cdev, char *buf)
67 struct lcd_device *ld = to_lcd_device(cdev); 67 struct lcd_device *ld = to_lcd_device(cdev);
68 68
69 down(&ld->sem); 69 down(&ld->sem);
70 if (likely(ld->props && ld->props->get_power)) 70 if (ld->props && ld->props->get_power)
71 rc = sprintf(buf, "%d\n", ld->props->get_power(ld)); 71 rc = sprintf(buf, "%d\n", ld->props->get_power(ld));
72 else 72 else
73 rc = -ENXIO; 73 rc = -ENXIO;
@@ -90,7 +90,7 @@ static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_
90 return -EINVAL; 90 return -EINVAL;
91 91
92 down(&ld->sem); 92 down(&ld->sem);
93 if (likely(ld->props && ld->props->set_power)) { 93 if (ld->props && ld->props->set_power) {
94 pr_debug("lcd: set power to %d\n", power); 94 pr_debug("lcd: set power to %d\n", power);
95 ld->props->set_power(ld, power); 95 ld->props->set_power(ld, power);
96 rc = count; 96 rc = count;
@@ -106,7 +106,7 @@ static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf)
106 struct lcd_device *ld = to_lcd_device(cdev); 106 struct lcd_device *ld = to_lcd_device(cdev);
107 107
108 down(&ld->sem); 108 down(&ld->sem);
109 if (likely(ld->props && ld->props->get_contrast)) 109 if (ld->props && ld->props->get_contrast)
110 rc = sprintf(buf, "%d\n", ld->props->get_contrast(ld)); 110 rc = sprintf(buf, "%d\n", ld->props->get_contrast(ld));
111 up(&ld->sem); 111 up(&ld->sem);
112 112
@@ -127,7 +127,7 @@ static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, si
127 return -EINVAL; 127 return -EINVAL;
128 128
129 down(&ld->sem); 129 down(&ld->sem);
130 if (likely(ld->props && ld->props->set_contrast)) { 130 if (ld->props && ld->props->set_contrast) {
131 pr_debug("lcd: set contrast to %d\n", contrast); 131 pr_debug("lcd: set contrast to %d\n", contrast);
132 ld->props->set_contrast(ld, contrast); 132 ld->props->set_contrast(ld, contrast);
133 rc = count; 133 rc = count;
@@ -143,7 +143,7 @@ static ssize_t lcd_show_max_contrast(struct class_device *cdev, char *buf)
143 struct lcd_device *ld = to_lcd_device(cdev); 143 struct lcd_device *ld = to_lcd_device(cdev);
144 144
145 down(&ld->sem); 145 down(&ld->sem);
146 if (likely(ld->props)) 146 if (ld->props)
147 rc = sprintf(buf, "%d\n", ld->props->max_contrast); 147 rc = sprintf(buf, "%d\n", ld->props->max_contrast);
148 up(&ld->sem); 148 up(&ld->sem);
149 149
@@ -194,7 +194,7 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
194 pr_debug("lcd_device_register: name=%s\n", name); 194 pr_debug("lcd_device_register: name=%s\n", name);
195 195
196 new_ld = kmalloc(sizeof(struct lcd_device), GFP_KERNEL); 196 new_ld = kmalloc(sizeof(struct lcd_device), GFP_KERNEL);
197 if (unlikely(!new_ld)) 197 if (!new_ld)
198 return ERR_PTR(-ENOMEM); 198 return ERR_PTR(-ENOMEM);
199 199
200 init_MUTEX(&new_ld->sem); 200 init_MUTEX(&new_ld->sem);
@@ -205,7 +205,7 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
205 class_set_devdata(&new_ld->class_dev, devdata); 205 class_set_devdata(&new_ld->class_dev, devdata);
206 206
207 rc = class_device_register(&new_ld->class_dev); 207 rc = class_device_register(&new_ld->class_dev);
208 if (unlikely(rc)) { 208 if (rc) {
209 kfree(new_ld); 209 kfree(new_ld);
210 return ERR_PTR(rc); 210 return ERR_PTR(rc);
211 } 211 }
@@ -219,7 +219,7 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
219 for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++) { 219 for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++) {
220 rc = class_device_create_file(&new_ld->class_dev, 220 rc = class_device_create_file(&new_ld->class_dev,
221 &lcd_class_device_attributes[i]); 221 &lcd_class_device_attributes[i]);
222 if (unlikely(rc)) { 222 if (rc) {
223 while (--i >= 0) 223 while (--i >= 0)
224 class_device_remove_file(&new_ld->class_dev, 224 class_device_remove_file(&new_ld->class_dev,
225 &lcd_class_device_attributes[i]); 225 &lcd_class_device_attributes[i]);