~ubuntu-branches/ubuntu/trusty/linux-ti-omap/trusty

« back to all changes in this revision

Viewing changes to ubuntu/omnibook/wireless.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bader, Amit Kucheria
  • Date: 2010-03-23 18:05:12 UTC
  • Revision ID: james.westby@ubuntu.com-20100323180512-iavj906ocnphdubp
Tags: 2.6.33-500.3
[ Amit Kucheria ]

* [Config] Fix the debug package name to end in -dbgsym
* SAUCE: Add the ubuntu/ drivers to omap
* SAUCE: Re-export the symbols for aufs
* [Config] Enable AUFS and COMPCACHE

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * wireless.c Wifi feature
 
3
 * 
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License as published by the
 
6
 * Free Software Foundation; either version 2, or (at your option) any
 
7
 * later version.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful, but
 
10
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
12
 * General Public License for more details.
 
13
 *
 
14
 * Written by Mathieu Bérard <mathieu.berard@crans.org>, 2006
 
15
 *
 
16
 */
 
17
 
 
18
#include "omnibook.h"
 
19
#include "hardware.h"
 
20
 
 
21
static int omnibook_wifi_read(char *buffer, struct omnibook_operation *io_op)
 
22
{
 
23
        int len = 0;
 
24
        int retval;
 
25
        unsigned int state;
 
26
 
 
27
        if ((retval = backend_aerial_get(io_op, &state)))
 
28
                return retval;
 
29
 
 
30
        len +=
 
31
            sprintf(buffer + len, "Wifi adapter is %s", (state & WIFI_EX) ? "present" : "absent");
 
32
        if (state & WIFI_EX)
 
33
                len +=
 
34
                    sprintf(buffer + len, " and %s", (state & WIFI_STA) ? "enabled" : "disabled");
 
35
        len += sprintf(buffer + len, ".\n");
 
36
        len +=
 
37
            sprintf(buffer + len, "Wifi Kill switch is %s.\n", (state & KILLSWITCH) ? "on" : "off");
 
38
 
 
39
        return len;
 
40
 
 
41
}
 
42
 
 
43
static int omnibook_wifi_write(char *buffer, struct omnibook_operation *io_op)
 
44
{
 
45
        int retval = 0;
 
46
        unsigned int state;
 
47
 
 
48
        if(mutex_lock_interruptible(&io_op->backend->mutex))
 
49
                return -ERESTARTSYS;    
 
50
 
 
51
        if ((retval = __backend_aerial_get(io_op, &state)))
 
52
                goto out;
 
53
 
 
54
        if (*buffer == '0')
 
55
                state &= ~WIFI_STA;
 
56
        else if (*buffer == '1')
 
57
                state |= WIFI_STA;
 
58
        else {
 
59
                retval = -EINVAL;
 
60
                goto out;
 
61
        }
 
62
 
 
63
        if ((retval = __backend_aerial_set(io_op, state)))
 
64
                return retval;
 
65
 
 
66
        out:            
 
67
        mutex_unlock(&io_op->backend->mutex);
 
68
        return retval;
 
69
}
 
70
 
 
71
static struct omnibook_feature wifi_driver;
 
72
 
 
73
static int __init omnibook_wifi_init(struct omnibook_operation *io_op)
 
74
{
 
75
        int retval = 0;
 
76
        unsigned int state;
 
77
 
 
78
/*
 
79
 *  Refuse enabling/disabling a non-existent device
 
80
 */
 
81
 
 
82
        if ((retval = backend_aerial_get(io_op, &state)))
 
83
                return retval;
 
84
 
 
85
        if (!(state & WIFI_EX))
 
86
                wifi_driver.write = NULL;
 
87
 
 
88
        return retval;
 
89
}
 
90
 
 
91
static struct omnibook_tbl wireless_table[] __initdata = {
 
92
        {TSM70 | TSX205, {ACPI,}},      /* stubs to select backend */
 
93
        {TSM40, {SMI,}},                /* stubs to select backend */
 
94
        {0,}
 
95
};
 
96
 
 
97
static struct omnibook_feature __declared_feature wifi_driver = {
 
98
        .name = "wifi",
 
99
        .enabled = 1,
 
100
        .read = omnibook_wifi_read,
 
101
        .write = omnibook_wifi_write,
 
102
        .init = omnibook_wifi_init,
 
103
        .ectypes = TSM70 | TSM40 | TSX205,
 
104
        .tbl = wireless_table,
 
105
};
 
106
 
 
107
module_param_named(wifi, wifi_driver.enabled, int, S_IRUGO);
 
108
MODULE_PARM_DESC(wifi, "Use 0 to disable, 1 to enable Wifi adapter control");