Contents of /trunk/hal/patches/hal-0.5.10-fixed-indentation.patch
Parent Directory | Revision Log
Revision 597 -
(show annotations)
(download)
Mon May 19 19:05:19 2008 UTC (16 years, 4 months ago) by niro
File size: 11737 byte(s)
Mon May 19 19:05:19 2008 UTC (16 years, 4 months ago) by niro
File size: 11737 byte(s)
-gentoo patches
1 | From 24cd39f605f246cbb8fff2e5b14d122bf45530e1 Mon Sep 17 00:00:00 2001 |
2 | From: Guillem Jover <guillem.jover@nokia.com> |
3 | Date: Tue, 20 Nov 2007 14:37:38 +0100 |
4 | Subject: [PATCH] fixed indentation |
5 | |
6 | Fixed indentation in hald-addon-omap-backlight. |
7 | --- |
8 | hald/linux/addons/addon-omap-backlight.c | 211 +++++++++++++++--------------- |
9 | 1 files changed, 106 insertions(+), 105 deletions(-) |
10 | |
11 | diff --git a/hald/linux/addons/addon-omap-backlight.c b/hald/linux/addons/addon-omap-backlight.c |
12 | index 97cf7a2..b05ccbb 100644 |
13 | --- a/hald/linux/addons/addon-omap-backlight.c |
14 | +++ b/hald/linux/addons/addon-omap-backlight.c |
15 | @@ -49,7 +49,7 @@ |
16 | |
17 | static GMainLoop *main_loop; |
18 | static LibHalContext *halctx = NULL; |
19 | -static char * udi; |
20 | +static char *udi; |
21 | static DBusConnection *conn; |
22 | |
23 | #define NUM_BUF_LEN 11 |
24 | @@ -58,25 +58,26 @@ static char buffer[NUM_BUF_LEN]; |
25 | |
26 | struct backlight |
27 | { |
28 | - void (*set_backlight_level)(struct backlight * bl, int i); |
29 | - int (*get_backlight_level)(struct backlight * bl); |
30 | - void (*backlight_init)(struct backlight * bl); |
31 | - int bl_min; |
32 | - int bl_max; |
33 | + void (*set_backlight_level) (struct backlight *bl, int i); |
34 | + int (*get_backlight_level) (struct backlight *bl); |
35 | + void (*backlight_init) (struct backlight *bl); |
36 | + int bl_min; |
37 | + int bl_max; |
38 | }; |
39 | |
40 | struct backlight bl_data; |
41 | |
42 | /* Reads backligh level */ |
43 | -static int read_backlight(struct backlight * bl) |
44 | +static int |
45 | +read_backlight (struct backlight * bl) |
46 | { |
47 | - int fd; |
48 | + int fd; |
49 | |
50 | - fd = open("/sys/devices/platform/omapfb/panel/backlight_level", O_RDONLY); |
51 | - if(fd <0 || read(fd, buffer, NUM_BUF_LEN) < 0) |
52 | - return -1; |
53 | + fd = open ("/sys/devices/platform/omapfb/panel/backlight_level", O_RDONLY); |
54 | + if (fd < 0 || read (fd, buffer, NUM_BUF_LEN) < 0) |
55 | + return -1; |
56 | |
57 | - return atoi(buffer); |
58 | + return atoi (buffer); |
59 | } |
60 | |
61 | /* Read maximum bl level */ |
62 | @@ -84,97 +85,98 @@ static int read_backlight(struct backlight * bl) |
63 | No we have fixed value in FDI file, but it |
64 | is better to set it in addon code. |
65 | */ |
66 | -static void backlight_init(struct backlight * bl) |
67 | +static void |
68 | +backlight_init (struct backlight * bl) |
69 | { |
70 | - int fd; |
71 | + int fd; |
72 | |
73 | - /* Reading maximum backlight level */ |
74 | - fd = open("/sys/devices/platform/omapfb/panel/backlight_max", O_RDONLY); |
75 | + /* Reading maximum backlight level */ |
76 | + fd = open ("/sys/devices/platform/omapfb/panel/backlight_max", O_RDONLY); |
77 | |
78 | - if(fd <0 || read(fd, buffer, NUM_BUF_LEN - 1) < 0) |
79 | - return; |
80 | + if (fd < 0 || read (fd, buffer, NUM_BUF_LEN - 1) < 0) |
81 | + return; |
82 | |
83 | - bl->bl_max = atoi(buffer); |
84 | - close(fd); |
85 | + bl->bl_max = atoi (buffer); |
86 | + close (fd); |
87 | } |
88 | |
89 | /* Setting backlight level */ |
90 | -static void write_backlight(struct backlight * bl, int level) |
91 | +static void |
92 | +write_backlight (struct backlight * bl, int level) |
93 | { |
94 | - int fd, l; |
95 | + int fd, l; |
96 | |
97 | - /* sanity-checking level we're required to set */ |
98 | - if(level > bl->bl_max) |
99 | - level = bl->bl_max; |
100 | + /* sanity-checking level we're required to set */ |
101 | + if (level > bl->bl_max) |
102 | + level = bl->bl_max; |
103 | |
104 | - if(level < bl->bl_min) |
105 | - level = bl->bl_min; |
106 | + if (level < bl->bl_min) |
107 | + level = bl->bl_min; |
108 | |
109 | - fd = open("/sys/devices/platform/omapfb/panel/backlight_level", O_WRONLY); |
110 | - l = snprintf(buffer, NUM_BUF_LEN - 1, "%d", level); |
111 | + fd = open ("/sys/devices/platform/omapfb/panel/backlight_level", O_WRONLY); |
112 | + l = snprintf (buffer, NUM_BUF_LEN - 1, "%d", level); |
113 | |
114 | - if(l >= (NUM_BUF_LEN - 1)) { |
115 | - close(fd); |
116 | - return; |
117 | - } |
118 | + if (l >= (NUM_BUF_LEN - 1)) { |
119 | + close (fd); |
120 | + return; |
121 | + } |
122 | |
123 | - write(fd, buffer, l); |
124 | - close(fd); |
125 | + write (fd, buffer, l); |
126 | + close (fd); |
127 | } |
128 | |
129 | static gboolean |
130 | check_priv (DBusConnection *connection, DBusMessage *message, const char *udi, const char *privilege) |
131 | #ifdef HAVE_POLKIT |
132 | { |
133 | - gboolean ret; |
134 | - char *polkit_result; |
135 | - const char *invoked_by_syscon_name; |
136 | - DBusMessage *reply; |
137 | - DBusError error; |
138 | - |
139 | - ret = FALSE; |
140 | - polkit_result = NULL; |
141 | - |
142 | - invoked_by_syscon_name = dbus_message_get_sender (message); |
143 | - |
144 | - dbus_error_init (&error); |
145 | - polkit_result = libhal_device_is_caller_privileged (halctx, |
146 | - udi, |
147 | - privilege, |
148 | - invoked_by_syscon_name, |
149 | - &error); |
150 | - if (polkit_result == NULL) { |
151 | - reply = dbus_message_new_error_printf (message, |
152 | - "org.freedesktop.Hal.Device.Error", |
153 | - "Cannot determine if caller is privileged", |
154 | - privilege, polkit_result); |
155 | - dbus_connection_send (connection, reply, NULL); |
156 | - goto out; |
157 | - } |
158 | - if (strcmp (polkit_result, "yes") != 0) { |
159 | - |
160 | - reply = dbus_message_new_error_printf (message, |
161 | - "org.freedesktop.Hal.Device.PermissionDeniedByPolicy", |
162 | - "%s %s <-- (privilege, result)", |
163 | - privilege, polkit_result); |
164 | - dbus_connection_send (connection, reply, NULL); |
165 | - goto out; |
166 | - } |
167 | - |
168 | - ret = TRUE; |
169 | + gboolean ret; |
170 | + char *polkit_result; |
171 | + const char *invoked_by_syscon_name; |
172 | + DBusMessage *reply; |
173 | + DBusError error; |
174 | + |
175 | + ret = FALSE; |
176 | + polkit_result = NULL; |
177 | + |
178 | + invoked_by_syscon_name = dbus_message_get_sender (message); |
179 | + |
180 | + dbus_error_init (&error); |
181 | + polkit_result = libhal_device_is_caller_privileged (halctx, |
182 | + udi, |
183 | + privilege, |
184 | + invoked_by_syscon_name, |
185 | + &error); |
186 | + if (polkit_result == NULL) { |
187 | + reply = dbus_message_new_error_printf (message, |
188 | + "org.freedesktop.Hal.Device.Error", |
189 | + "Cannot determine if caller is privileged", |
190 | + privilege, polkit_result); |
191 | + dbus_connection_send (connection, reply, NULL); |
192 | + goto out; |
193 | + } |
194 | + |
195 | + if (strcmp (polkit_result, "yes") != 0) { |
196 | + reply = dbus_message_new_error_printf (message, |
197 | + "org.freedesktop.Hal.Device.PermissionDeniedByPolicy", |
198 | + "%s %s <-- (privilege, result)", |
199 | + privilege, polkit_result); |
200 | + dbus_connection_send (connection, reply, NULL); |
201 | + goto out; |
202 | + } |
203 | + |
204 | + ret = TRUE; |
205 | |
206 | out: |
207 | - if (polkit_result != NULL) |
208 | - libhal_free_string (polkit_result); |
209 | - return ret; |
210 | + if (polkit_result != NULL) |
211 | + libhal_free_string (polkit_result); |
212 | + return ret; |
213 | } |
214 | #else |
215 | { |
216 | - return TRUE; |
217 | + return TRUE; |
218 | } |
219 | #endif |
220 | |
221 | - |
222 | /* DBus filter function */ |
223 | static DBusHandlerResult |
224 | filter_function (DBusConnection *connection, DBusMessage *message, void *userdata) |
225 | @@ -182,27 +184,28 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat |
226 | DBusError err; |
227 | DBusMessage *reply; |
228 | |
229 | - if (!check_priv (connection, message, dbus_message_get_path (message), "org.freedesktop.hal.power-management.lcd-panel")) { |
230 | - return DBUS_HANDLER_RESULT_HANDLED; |
231 | - } |
232 | + if (!check_priv (connection, message, dbus_message_get_path (message), |
233 | + "org.freedesktop.hal.power-management.lcd-panel")) { |
234 | + return DBUS_HANDLER_RESULT_HANDLED; |
235 | + } |
236 | |
237 | #ifdef DEBUG_OMAP_BL |
238 | - dbg ("filter_function: sender=%s destination=%s obj_path=%s interface=%s method=%s", |
239 | - dbus_message_get_sender (message), |
240 | - dbus_message_get_destination (message), |
241 | - dbus_message_get_path (message), |
242 | + dbg ("filter_function: sender=%s destination=%s obj_path=%s interface=%s method=%s", |
243 | + dbus_message_get_sender (message), |
244 | + dbus_message_get_destination (message), |
245 | + dbus_message_get_path (message), |
246 | dbus_message_get_interface (message), |
247 | dbus_message_get_member (message)); |
248 | #endif |
249 | reply = NULL; |
250 | |
251 | - if (dbus_message_is_method_call (message, |
252 | - "org.freedesktop.Hal.Device.LaptopPanel", |
253 | + if (dbus_message_is_method_call (message, |
254 | + "org.freedesktop.Hal.Device.LaptopPanel", |
255 | "SetBrightness")) { |
256 | int brightness; |
257 | |
258 | dbus_error_init (&err); |
259 | - if (dbus_message_get_args (message, |
260 | + if (dbus_message_get_args (message, |
261 | &err, |
262 | DBUS_TYPE_INT32, &brightness, |
263 | DBUS_TYPE_INVALID)) { |
264 | @@ -210,7 +213,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat |
265 | reply = dbus_message_new_error (message, |
266 | "org.freedesktop.Hal.Device.LaptopPanel.Invalid", |
267 | "Brightness has to be between 0 and 228!"); |
268 | - |
269 | } else { |
270 | int return_code; |
271 | |
272 | @@ -228,14 +230,13 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat |
273 | |
274 | dbus_connection_send (connection, reply, NULL); |
275 | } |
276 | - |
277 | - } else if (dbus_message_is_method_call (message, |
278 | - "org.freedesktop.Hal.Device.LaptopPanel", |
279 | + } else if (dbus_message_is_method_call (message, |
280 | + "org.freedesktop.Hal.Device.LaptopPanel", |
281 | "GetBrightness")) { |
282 | int brightness; |
283 | |
284 | dbus_error_init (&err); |
285 | - if (dbus_message_get_args (message, |
286 | + if (dbus_message_get_args (message, |
287 | &err, |
288 | DBUS_TYPE_INVALID)) { |
289 | |
290 | @@ -256,9 +257,8 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat |
291 | DBUS_TYPE_INVALID); |
292 | dbus_connection_send (connection, reply, NULL); |
293 | } |
294 | - |
295 | } |
296 | - |
297 | + |
298 | error: |
299 | if (reply != NULL) |
300 | dbus_message_unref (reply); |
301 | @@ -267,12 +267,13 @@ error: |
302 | } |
303 | |
304 | /* Setting-up backlight structure */ |
305 | -static void setup_cb(void) |
306 | +static void |
307 | +setup_cb (void) |
308 | { |
309 | - memset(&bl_data, 0, sizeof(struct backlight)); |
310 | - bl_data.backlight_init = backlight_init; |
311 | - bl_data.get_backlight_level = read_backlight; |
312 | - bl_data.set_backlight_level = write_backlight; |
313 | + memset (&bl_data, 0, sizeof (struct backlight)); |
314 | + bl_data.backlight_init = backlight_init; |
315 | + bl_data.get_backlight_level = read_backlight; |
316 | + bl_data.set_backlight_level = write_backlight; |
317 | } |
318 | |
319 | int |
320 | @@ -281,7 +282,7 @@ main (int argc, char *argv[]) |
321 | DBusError err; |
322 | |
323 | setup_logger (); |
324 | - setup_cb(); |
325 | + setup_cb (); |
326 | udi = getenv ("UDI"); |
327 | |
328 | HAL_DEBUG (("udi=%s", udi)); |
329 | @@ -296,16 +297,14 @@ main (int argc, char *argv[]) |
330 | return -3; |
331 | } |
332 | |
333 | - |
334 | - |
335 | conn = libhal_ctx_get_dbus_connection (halctx); |
336 | dbus_connection_setup_with_g_main (conn, NULL); |
337 | |
338 | dbus_connection_add_filter (conn, filter_function, NULL, NULL); |
339 | |
340 | - if (!libhal_device_claim_interface (halctx, |
341 | - "/org/freedesktop/Hal/devices/omapfb_bl", |
342 | - "org.freedesktop.Hal.Device.LaptopPanel", |
343 | + if (!libhal_device_claim_interface (halctx, |
344 | + "/org/freedesktop/Hal/devices/omapfb_bl", |
345 | + "org.freedesktop.Hal.Device.LaptopPanel", |
346 | " <method name=\"SetBrightness\">\n" |
347 | " <arg name=\"brightness_value\" direction=\"in\" type=\"i\"/>\n" |
348 | " <arg name=\"return_code\" direction=\"out\" type=\"i\"/>\n" |
349 | @@ -317,11 +316,13 @@ main (int argc, char *argv[]) |
350 | HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.LaptopPanel'")); |
351 | return -4; |
352 | } |
353 | + |
354 | dbus_error_init (&err); |
355 | if (!libhal_device_addon_is_ready (halctx, udi, &err)) { |
356 | return -4; |
357 | } |
358 | - bl_data.backlight_init(&bl_data); |
359 | + |
360 | + bl_data.backlight_init (&bl_data); |
361 | main_loop = g_main_loop_new (NULL, FALSE); |
362 | g_main_loop_run (main_loop); |
363 | return 0; |
364 | -- |
365 | 1.5.3.7 |
366 |