summaryrefslogtreecommitdiff
path: root/drivers/staging/vt6655
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 17:51:54 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 17:51:54 -0700
commit20b4fb485227404329e41ad15588afad3df23050 (patch)
treef3e099f0ab3da8a93b447203e294d2bb22f6dc05 /drivers/staging/vt6655
parentb9394d8a657cd3c064fa432aa0905c1b58b38fe9 (diff)
parentac3e3c5b1164397656df81b9e9ab4991184d3236 (diff)
downloadlinux-3.10-20b4fb485227404329e41ad15588afad3df23050.tar.gz
linux-3.10-20b4fb485227404329e41ad15588afad3df23050.tar.bz2
linux-3.10-20b4fb485227404329e41ad15588afad3df23050.zip
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull VFS updates from Al Viro, Misc cleanups all over the place, mainly wrt /proc interfaces (switch create_proc_entry to proc_create(), get rid of the deprecated create_proc_read_entry() in favor of using proc_create_data() and seq_file etc). 7kloc removed. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits) don't bother with deferred freeing of fdtables proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h proc: Make the PROC_I() and PDE() macros internal to procfs proc: Supply a function to remove a proc entry by PDE take cgroup_open() and cpuset_open() to fs/proc/base.c ppc: Clean up scanlog ppc: Clean up rtas_flash driver somewhat hostap: proc: Use remove_proc_subtree() drm: proc: Use remove_proc_subtree() drm: proc: Use minor->index to label things, not PDE->name drm: Constify drm_proc_list[] zoran: Don't print proc_dir_entry data in debug reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show() proc: Supply an accessor for getting the data from a PDE's parent airo: Use remove_proc_subtree() rtl8192u: Don't need to save device proc dir PDE rtl8187se: Use a dir under /proc/net/r8180/ proc: Add proc_mkdir_data() proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h} proc: Move PDE_NET() to fs/proc/proc_net.c ...
Diffstat (limited to 'drivers/staging/vt6655')
-rw-r--r--drivers/staging/vt6655/device_main.c74
1 files changed, 21 insertions, 53 deletions
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index be4f6c2ca3f..08b250f01da 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -60,6 +60,7 @@
*/
#undef __NO_VERSION__
+#include <linux/file.h>
#include "device.h"
#include "card.h"
#include "channel.h"
@@ -2737,83 +2738,50 @@ static int Config_FileGetParameter(unsigned char *string,
return true;
}
-int Config_FileOperation(PSDevice pDevice, bool fwrite, unsigned char *Parameter) {
- unsigned char *config_path = CONFIG_PATH;
- unsigned char *buffer = NULL;
+int Config_FileOperation(PSDevice pDevice,bool fwrite,unsigned char *Parameter)
+{
+ unsigned char *buffer = kmalloc(1024, GFP_KERNEL);
unsigned char tmpbuffer[20];
- struct file *filp = NULL;
- mm_segment_t old_fs = get_fs();
- //int oldfsuid=0,oldfsgid=0;
- int result = 0;
-
- set_fs(KERNEL_DS);
-
- /* Can't do this anymore, so we rely on correct filesystem permissions:
- //Make sure a caller can read or write power as root
- oldfsuid=current->cred->fsuid;
- oldfsgid=current->cred->fsgid;
- current->cred->fsuid = 0;
- current->cred->fsgid = 0;
- */
-
- //open file
- filp = filp_open(config_path, O_RDWR, 0);
- if (IS_ERR(filp)) {
- printk("Config_FileOperation:open file fail?\n");
- result = -1;
- goto error2;
- }
+ struct file *file;
+ int result=0;
- if (!(filp->f_op) || !(filp->f_op->read) || !(filp->f_op->write)) {
- printk("file %s cann't readable or writable?\n", config_path);
- result = -1;
- goto error1;
- }
-
- buffer = kmalloc(1024, GFP_KERNEL);
- if (buffer == NULL) {
+ if (!buffer) {
printk("allocate mem for file fail?\n");
- result = -1;
- goto error1;
+ return -1;
+ }
+ file = filp_open(CONFIG_PATH, O_RDONLY, 0);
+ if (IS_ERR(file)) {
+ kfree(buffer);
+ printk("Config_FileOperation:open file fail?\n");
+ return -1;
}
- if (filp->f_op->read(filp, buffer, 1024, &filp->f_pos) < 0) {
+ if (kernel_read(file, 0, buffer, 1024) < 0) {
printk("read file error?\n");
result = -1;
goto error1;
}
- if (Config_FileGetParameter("ZONETYPE", tmpbuffer, buffer) != true) {
+ if (Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer)!=true) {
printk("get parameter error?\n");
result = -1;
goto error1;
}
- if (memcmp(tmpbuffer, "USA", 3) == 0) {
+ if (memcmp(tmpbuffer,"USA",3)==0) {
result = ZoneType_USA;
- } else if (memcmp(tmpbuffer, "JAPAN", 5) == 0) {
+ } else if(memcmp(tmpbuffer,"JAPAN",5)==0) {
result = ZoneType_Japan;
- } else if (memcmp(tmpbuffer, "EUROPE", 5) == 0) {
+ } else if(memcmp(tmpbuffer,"EUROPE",5)==0) {
result = ZoneType_Europe;
} else {
result = -1;
- printk("Unknown Zonetype[%s]?\n", tmpbuffer);
+ printk("Unknown Zonetype[%s]?\n",tmpbuffer);
}
error1:
kfree(buffer);
-
- if (filp_close(filp, NULL))
- printk("Config_FileOperation:close file fail\n");
-
-error2:
- set_fs(old_fs);
-
- /*
- current->cred->fsuid=oldfsuid;
- current->cred->fsgid=oldfsgid;
- */
-
+ fput(file);
return result;
}