PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/arm/mach-msm/board-trout-wifi.c

https://github.com/AICP/kernel_google_msm
C | 74 lines | 50 code | 9 blank | 15 comment | 6 complexity | 999c9dbf569fee2935b6c93e59a33e25 MD5 | raw file
 1/* arch/arm/mach-msm/board-trout-wifi.c
 2 *
 3 * Copyright (C) 2008 Google, Inc.
 4 * Author: Dmitry Shmidt <dimitrysh@google.com>
 5 *
 6 * This software is licensed under the terms of the GNU General Public
 7 * License version 2, as published by the Free Software Foundation, and
 8 * may be copied, distributed, and modified under those terms.
 9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#ifdef CONFIG_WIFI_CONTROL_FUNC
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/platform_device.h>
21#include <linux/vmalloc.h>
22#include <linux/err.h>
23#include <linux/wifi_tiwlan.h>
24
25extern int trout_wifi_set_carddetect(int val);
26extern int trout_wifi_power(int on);
27extern int trout_wifi_reset(int on);
28
29#ifdef CONFIG_WIFI_MEM_PREALLOC
30typedef struct wifi_mem_prealloc_struct {
31	void *mem_ptr;
32	unsigned long size;
33} wifi_mem_prealloc_t;
34
35static wifi_mem_prealloc_t wifi_mem_array[WMPA_NUMBER_OF_SECTIONS] = {
36	{ NULL, (WMPA_SECTION_SIZE_0 + WMPA_SECTION_HEADER) },
37	{ NULL, (WMPA_SECTION_SIZE_1 + WMPA_SECTION_HEADER) },
38	{ NULL, (WMPA_SECTION_SIZE_2 + WMPA_SECTION_HEADER) }
39};
40
41static void *trout_wifi_mem_prealloc(int section, unsigned long size)
42{
43	if( (section < 0) || (section >= WMPA_NUMBER_OF_SECTIONS) )
44		return NULL;
45	if( wifi_mem_array[section].size < size )
46		return NULL;
47	return wifi_mem_array[section].mem_ptr;
48}
49
50int __init trout_init_wifi_mem( void )
51{
52	int i;
53
54	for(i=0;( i < WMPA_NUMBER_OF_SECTIONS );i++) {
55		wifi_mem_array[i].mem_ptr = vmalloc(wifi_mem_array[i].size);
56		if( wifi_mem_array[i].mem_ptr == NULL )
57			return -ENOMEM;
58	}
59	return 0;
60}
61#endif
62
63struct wifi_platform_data trout_wifi_control = {
64	.set_power		= trout_wifi_power,
65	.set_reset		= trout_wifi_reset,
66	.set_carddetect		= trout_wifi_set_carddetect,
67#ifdef CONFIG_WIFI_MEM_PREALLOC
68	.mem_prealloc		= trout_wifi_mem_prealloc,
69#else
70	.mem_prealloc		= NULL,
71#endif	
72};
73
74#endif