5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 static gboolean rfkill_event(GIOChannel *chan,
35 GIOCondition cond, gpointer data)
37 unsigned char buf[32];
41 if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR))
44 memset(buf, 0, sizeof(buf));
46 err = g_io_channel_read(chan, (gchar *) buf, sizeof(buf), &len);
48 if (err == G_IO_ERROR_AGAIN)
53 /* process RFKILL event */
58 static GIOChannel *channel = NULL;
60 int __connman_rfkill_init(void)
66 fd = open("/dev/rfkill", O_RDWR);
68 connman_error("Failed to open RFKILL control device");
72 channel = g_io_channel_unix_new(fd);
73 g_io_channel_set_close_on_unref(channel, TRUE);
75 g_io_add_watch(channel, G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
81 void __connman_rfkill_cleanup(void)
88 g_io_channel_shutdown(channel, TRUE, NULL);
89 g_io_channel_unref(channel);