]> bbs.cooldavid.org Git - net-next-2.6.git/blob - drivers/staging/rt2860/rt_profile.c
Staging: rt28x0: updates from vendor's V2.1.0.0 drivers
[net-next-2.6.git] / drivers / staging / rt2860 / rt_profile.c
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
40 NDIS_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                         src = STA_PROFILE_PATH;
57     }
58         }
59
60         if (src && *src)
61     {
62                 RtmpOSFSInfoChange(&osFSInfo, TRUE);
63                 srcf = RtmpOSFileOpen(src, O_RDONLY, 0);
64                 if (IS_FILE_OPEN_ERR(srcf))
65                 {
66                         DBGPRINT(RT_DEBUG_ERROR, ("Open file \"%s\" failed!\n", src));
67     }
68         else
69     {
70                         retval =RtmpOSFileRead(srcf, buffer, MAX_INI_BUFFER_SIZE);
71                         if (retval > 0)
72     {
73                                 RTMPSetProfileParameters(pAd, buffer);
74                                 retval = NDIS_STATUS_SUCCESS;
75     }
76                         else
77                                 DBGPRINT(RT_DEBUG_ERROR, ("Read file \"%s\" failed(errCode=%d)!\n", src, retval));
78
79                         retval = RtmpOSFileClose(srcf);
80                         if ( retval != 0)
81                 {
82                                 retval = NDIS_STATUS_FAILURE;
83                                 DBGPRINT(RT_DEBUG_ERROR, ("Close file \"%s\" failed(errCode=%d)!\n", src, retval));
84                 }
85         }
86
87                 RtmpOSFSInfoChange(&osFSInfo, FALSE);
88         }
89
90         kfree(buffer);
91
92         return (retval);
93
94 }
95