Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / rt3090 / rt_profile.c
CommitLineData
36c7928c
BZ
1/*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 rt_profile.c
29
30 Abstract:
31
32 Revision History:
33 Who When What
34 --------- ---------- ----------------------------------------------
35 */
36
37#include "rt_config.h"
38
39
40NDIS_STATUS RTMPReadParametersHook(
41 IN PRTMP_ADAPTER pAd)
42{
43 PSTRING src = NULL;
44 RTMP_OS_FD srcf;
45 RTMP_OS_FS_INFO osFSInfo;
46 INT retval = NDIS_STATUS_FAILURE;
47 PSTRING buffer;
48
49 buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
50 if(buffer == NULL)
51 return NDIS_STATUS_FAILURE;
52 memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
53
54 {
55
56#ifdef CONFIG_STA_SUPPORT
57 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
58 {
59 src = STA_PROFILE_PATH;
60 }
61#endif // CONFIG_STA_SUPPORT //
62#ifdef MULTIPLE_CARD_SUPPORT
63 src = (PSTRING)pAd->MC_FileName;
64#endif // MULTIPLE_CARD_SUPPORT //
65 }
66
67 if (src && *src)
68 {
69 RtmpOSFSInfoChange(&osFSInfo, TRUE);
70 srcf = RtmpOSFileOpen(src, O_RDONLY, 0);
71 if (IS_FILE_OPEN_ERR(srcf))
72 {
73 DBGPRINT(RT_DEBUG_ERROR, ("Open file \"%s\" failed!\n", src));
74 }
75 else
76 {
77 retval =RtmpOSFileRead(srcf, buffer, MAX_INI_BUFFER_SIZE);
78 if (retval > 0)
79 {
80 RTMPSetProfileParameters(pAd, buffer);
81 retval = NDIS_STATUS_SUCCESS;
82 }
83 else
84 DBGPRINT(RT_DEBUG_ERROR, ("Read file \"%s\" failed(errCode=%d)!\n", src, retval));
85
86 retval = RtmpOSFileClose(srcf);
87 if ( retval != 0)
88 {
89 retval = NDIS_STATUS_FAILURE;
90 DBGPRINT(RT_DEBUG_ERROR, ("Close file \"%s\" failed(errCode=%d)!\n", src, retval));
91 }
92 }
93
94 RtmpOSFSInfoChange(&osFSInfo, FALSE);
95 }
96
97 kfree(buffer);
98
99 return (retval);
100
101}