aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIke Panhc <ike.pan@canonical.com>2010-12-13 05:01:12 -0500
committerMatthew Garrett <mjg@redhat.com>2011-01-07 17:03:47 -0500
commitc1f73658edc8ac6f624968b47a276361ce032ca9 (patch)
treeda2bc9b2bb127152dd7a36a0029be9227a6fd33a
parent8693ae846cad00e6c2c40e116ec1fc50c145b559 (diff)
ideapad: pass ideapad_priv as argument (part 2)
Passing ideapad_priv as argument and try not to using too much global variable. This is part 2 for rfkill. Signed-off-by: Ike Panhc <ike.pan@canonical.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
-rw-r--r--drivers/platform/x86/ideapad-laptop.c71
1 files changed, 29 insertions, 42 deletions
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 37fe0d0448c9..114d95247cdf 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -31,32 +31,15 @@
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/input/sparse-keymap.h> 32#include <linux/input/sparse-keymap.h>
33 33
34#define IDEAPAD_DEV_CAMERA 0 34#define IDEAPAD_RFKILL_DEV_NUM (3)
35#define IDEAPAD_DEV_WLAN 1
36#define IDEAPAD_DEV_BLUETOOTH 2
37#define IDEAPAD_DEV_3G 3
38#define IDEAPAD_DEV_KILLSW 4
39 35
40struct ideapad_private { 36struct ideapad_private {
41 acpi_handle handle; 37 struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM];
42 struct rfkill *rfk[5];
43 struct platform_device *platform_device; 38 struct platform_device *platform_device;
44 struct input_dev *inputdev; 39 struct input_dev *inputdev;
45} *ideapad_priv;
46
47static struct {
48 char *name;
49 int cfgbit;
50 int opcode;
51 int type;
52} ideapad_rfk_data[] = {
53 { "ideapad_camera", 19, 0x1E, NUM_RFKILL_TYPES },
54 { "ideapad_wlan", 18, 0x15, RFKILL_TYPE_WLAN },
55 { "ideapad_bluetooth", 16, 0x17, RFKILL_TYPE_BLUETOOTH },
56 { "ideapad_3g", 17, 0x20, RFKILL_TYPE_WWAN },
57 { "ideapad_killsw", 0, 0, RFKILL_TYPE_WLAN }
58}; 40};
59 41
42static acpi_handle ideapad_handle;
60static bool no_bt_rfkill; 43static bool no_bt_rfkill;
61module_param(no_bt_rfkill, bool, 0444); 44module_param(no_bt_rfkill, bool, 0444);
62MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth."); 45MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth.");
@@ -176,11 +159,9 @@ static ssize_t show_ideapad_cam(struct device *dev,
176 struct device_attribute *attr, 159 struct device_attribute *attr,
177 char *buf) 160 char *buf)
178{ 161{
179 struct ideapad_private *priv = dev_get_drvdata(dev);
180 acpi_handle handle = priv->handle;
181 unsigned long result; 162 unsigned long result;
182 163
183 if (read_ec_data(handle, 0x1D, &result)) 164 if (read_ec_data(ideapad_handle, 0x1D, &result))
184 return sprintf(buf, "-1\n"); 165 return sprintf(buf, "-1\n");
185 return sprintf(buf, "%lu\n", result); 166 return sprintf(buf, "%lu\n", result);
186} 167}
@@ -189,15 +170,13 @@ static ssize_t store_ideapad_cam(struct device *dev,
189 struct device_attribute *attr, 170 struct device_attribute *attr,
190 const char *buf, size_t count) 171 const char *buf, size_t count)
191{ 172{
192 struct ideapad_private *priv = dev_get_drvdata(dev);
193 acpi_handle handle = priv->handle;
194 int ret, state; 173 int ret, state;
195 174
196 if (!count) 175 if (!count)
197 return 0; 176 return 0;
198 if (sscanf(buf, "%i", &state) != 1) 177 if (sscanf(buf, "%i", &state) != 1)
199 return -EINVAL; 178 return -EINVAL;
200 ret = write_ec_cmd(handle, 0x1E, state); 179 ret = write_ec_cmd(ideapad_handle, 0x1E, state);
201 if (ret < 0) 180 if (ret < 0)
202 return ret; 181 return ret;
203 return count; 182 return count;
@@ -208,16 +187,24 @@ static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam);
208/* 187/*
209 * Rfkill 188 * Rfkill
210 */ 189 */
190struct ideapad_rfk_data {
191 char *name;
192 int cfgbit;
193 int opcode;
194 int type;
195};
196
197const struct ideapad_rfk_data ideapad_rfk_data[] = {
198 { "ideapad_wlan", 18, 0x15, RFKILL_TYPE_WLAN },
199 { "ideapad_bluetooth", 16, 0x17, RFKILL_TYPE_BLUETOOTH },
200 { "ideapad_3g", 17, 0x20, RFKILL_TYPE_WWAN },
201};
202
211static int ideapad_rfk_set(void *data, bool blocked) 203static int ideapad_rfk_set(void *data, bool blocked)
212{ 204{
213 int device = (unsigned long)data; 205 unsigned long opcode = (unsigned long)data;
214
215 if (device == IDEAPAD_DEV_KILLSW)
216 return -EINVAL;
217 206
218 return write_ec_cmd(ideapad_priv->handle, 207 return write_ec_cmd(ideapad_handle, opcode, !blocked);
219 ideapad_rfk_data[device].opcode,
220 !blocked);
221} 208}
222 209
223static struct rfkill_ops ideapad_rfk_ops = { 210static struct rfkill_ops ideapad_rfk_ops = {
@@ -227,15 +214,14 @@ static struct rfkill_ops ideapad_rfk_ops = {
227static void ideapad_sync_rfk_state(struct acpi_device *adevice) 214static void ideapad_sync_rfk_state(struct acpi_device *adevice)
228{ 215{
229 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev); 216 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
230 acpi_handle handle = priv->handle;
231 unsigned long hw_blocked; 217 unsigned long hw_blocked;
232 int i; 218 int i;
233 219
234 if (read_ec_data(handle, 0x23, &hw_blocked)) 220 if (read_ec_data(ideapad_handle, 0x23, &hw_blocked))
235 return; 221 return;
236 hw_blocked = !hw_blocked; 222 hw_blocked = !hw_blocked;
237 223
238 for (i = IDEAPAD_DEV_WLAN; i <= IDEAPAD_DEV_KILLSW; i++) 224 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
239 if (priv->rfk[i]) 225 if (priv->rfk[i])
240 rfkill_set_hw_state(priv->rfk[i], hw_blocked); 226 rfkill_set_hw_state(priv->rfk[i], hw_blocked);
241} 227}
@@ -250,7 +236,7 @@ static int __devinit ideapad_register_rfkill(struct acpi_device *adevice,
250 if (no_bt_rfkill && 236 if (no_bt_rfkill &&
251 (ideapad_rfk_data[dev].type == RFKILL_TYPE_BLUETOOTH)) { 237 (ideapad_rfk_data[dev].type == RFKILL_TYPE_BLUETOOTH)) {
252 /* Force to enable bluetooth when no_bt_rfkill=1 */ 238 /* Force to enable bluetooth when no_bt_rfkill=1 */
253 write_ec_cmd(ideapad_priv->handle, 239 write_ec_cmd(ideapad_handle,
254 ideapad_rfk_data[dev].opcode, 1); 240 ideapad_rfk_data[dev].opcode, 1);
255 return 0; 241 return 0;
256 } 242 }
@@ -261,7 +247,7 @@ static int __devinit ideapad_register_rfkill(struct acpi_device *adevice,
261 if (!priv->rfk[dev]) 247 if (!priv->rfk[dev])
262 return -ENOMEM; 248 return -ENOMEM;
263 249
264 if (read_ec_data(ideapad_priv->handle, ideapad_rfk_data[dev].opcode-1, 250 if (read_ec_data(ideapad_handle, ideapad_rfk_data[dev].opcode-1,
265 &sw_blocked)) { 251 &sw_blocked)) {
266 rfkill_init_sw_state(priv->rfk[dev], 0); 252 rfkill_init_sw_state(priv->rfk[dev], 0);
267 } else { 253 } else {
@@ -414,9 +400,8 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
414 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 400 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
415 if (!priv) 401 if (!priv)
416 return -ENOMEM; 402 return -ENOMEM;
417 ideapad_priv = priv;
418 priv->handle = adevice->handle;
419 dev_set_drvdata(&adevice->dev, priv); 403 dev_set_drvdata(&adevice->dev, priv);
404 ideapad_handle = adevice->handle;
420 405
421 ret = ideapad_platform_init(priv); 406 ret = ideapad_platform_init(priv);
422 if (ret) 407 if (ret)
@@ -426,9 +411,11 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
426 if (ret) 411 if (ret)
427 goto input_failed; 412 goto input_failed;
428 413
429 for (i = IDEAPAD_DEV_WLAN; i < IDEAPAD_DEV_KILLSW; i++) { 414 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) {
430 if (test_bit(ideapad_rfk_data[i].cfgbit, (unsigned long *)&cfg)) 415 if (test_bit(ideapad_rfk_data[i].cfgbit, (unsigned long *)&cfg))
431 ideapad_register_rfkill(adevice, i); 416 ideapad_register_rfkill(adevice, i);
417 else
418 priv->rfk[i] = NULL;
432 } 419 }
433 ideapad_sync_rfk_state(adevice); 420 ideapad_sync_rfk_state(adevice);
434 421
@@ -446,7 +433,7 @@ static int __devexit ideapad_acpi_remove(struct acpi_device *adevice, int type)
446 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev); 433 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
447 int i; 434 int i;
448 435
449 for (i = IDEAPAD_DEV_WLAN; i < IDEAPAD_DEV_KILLSW; i++) 436 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
450 ideapad_unregister_rfkill(adevice, i); 437 ideapad_unregister_rfkill(adevice, i);
451 ideapad_input_exit(priv); 438 ideapad_input_exit(priv);
452 ideapad_platform_exit(priv); 439 ideapad_platform_exit(priv);
id='n1835' href='#n1835'>1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170

























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
%PDF-1.5
%
5702 0 obj
<</Linearized 1/L 532447/O 5704/E 127311/N 50/T 531364/H [ 542 1382]>>
endobj
         
5729 0 obj
<</DecodeParms<</Columns 5/Predictor 12>>/Filter/FlateDecode/ID[<3D1AD5A41FE76A459B54FB5D0B935C51><8BAF1BBBCD859C46BB3A787D8B3C614F>]/Index[5702 45]/Info 5701 0 R/Length 129/Prev 531365/Root 5703 0 R/Size 5747/Type/XRef/W[1 3 1]>>stream
hbbd```b``/w@$dm, +,&-A$X
"^H# lSG ɸp%\
"c*@mɼ`("d&F`iBgxs#@