Commit 39ce7250 authored by Len Brown's avatar Len Brown

Merge intel.com:/home/lenb/bk/linux-2.6.8

into intel.com:/home/lenb/src/linux-acpi-test-2.6.8
parents c69dedac 9f53c6cc
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/threads.h> #include <linux/threads.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/seq_file.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/bitops.h> #include <asm/bitops.h>
...@@ -30,11 +31,9 @@ ...@@ -30,11 +31,9 @@
#include <asm/system.h> #include <asm/system.h>
#include <asm/reg.h> #include <asm/reg.h>
static ssize_t ppc_htab_read(struct file * file, char __user * buf, static int ppc_htab_show(struct seq_file *m, void *v);
size_t count, loff_t *ppos);
static ssize_t ppc_htab_write(struct file * file, const char __user * buffer, static ssize_t ppc_htab_write(struct file * file, const char __user * buffer,
size_t count, loff_t *ppos); size_t count, loff_t *ppos);
static long long ppc_htab_lseek(struct file * file, loff_t offset, int orig);
int proc_dol2crvec(ctl_table *table, int write, struct file *filp, int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp); void __user *buffer, size_t *lenp);
...@@ -49,10 +48,17 @@ extern unsigned long pte_errors; ...@@ -49,10 +48,17 @@ extern unsigned long pte_errors;
extern unsigned int primary_pteg_full; extern unsigned int primary_pteg_full;
extern unsigned int htab_hash_searches; extern unsigned int htab_hash_searches;
static int ppc_htab_open(struct inode *inode, struct file *file)
{
return single_open(file, ppc_htab_show, NULL);
}
struct file_operations ppc_htab_operations = { struct file_operations ppc_htab_operations = {
.llseek = ppc_htab_lseek, .open = ppc_htab_open,
.read = ppc_htab_read, .read = seq_read,
.write = ppc_htab_write, .llseek = seq_lseek,
.write = ppc_htab_write,
.release = single_release,
}; };
static char *pmc1_lookup(unsigned long mmcr0) static char *pmc1_lookup(unsigned long mmcr0)
...@@ -96,31 +102,25 @@ static char *pmc2_lookup(unsigned long mmcr0) ...@@ -96,31 +102,25 @@ static char *pmc2_lookup(unsigned long mmcr0)
* is _REALLY_ slow (see the nested for loops below) but nothing * is _REALLY_ slow (see the nested for loops below) but nothing
* in here should be really timing critical. -- Cort * in here should be really timing critical. -- Cort
*/ */
static ssize_t ppc_htab_read(struct file * file, char __user * buf, static int ppc_htab_show(struct seq_file *m, void *v)
size_t count, loff_t *ppos)
{ {
unsigned long mmcr0 = 0, pmc1 = 0, pmc2 = 0; unsigned long mmcr0 = 0, pmc1 = 0, pmc2 = 0;
int n = 0;
#if defined(CONFIG_PPC_STD_MMU) && !defined(CONFIG_PPC64BRIDGE) #if defined(CONFIG_PPC_STD_MMU) && !defined(CONFIG_PPC64BRIDGE)
unsigned int kptes = 0, uptes = 0; unsigned int kptes = 0, uptes = 0;
PTE *ptr; PTE *ptr;
#endif /* CONFIG_PPC_STD_MMU */ #endif /* CONFIG_PPC_STD_MMU */
char buffer[512];
if (count < 0)
return -EINVAL;
if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) { if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
mmcr0 = mfspr(SPRN_MMCR0); mmcr0 = mfspr(SPRN_MMCR0);
pmc1 = mfspr(SPRN_PMC1); pmc1 = mfspr(SPRN_PMC1);
pmc2 = mfspr(SPRN_PMC2); pmc2 = mfspr(SPRN_PMC2);
n += sprintf( buffer + n, seq_printf(m,
"604 Performance Monitoring\n" "604 Performance Monitoring\n"
"MMCR0\t\t: %08lx %s%s ", "MMCR0\t\t: %08lx %s%s ",
mmcr0, mmcr0,
( mmcr0>>28 & 0x2 ) ? "(user mode counted)" : "", ( mmcr0>>28 & 0x2 ) ? "(user mode counted)" : "",
( mmcr0>>28 & 0x4 ) ? "(kernel mode counted)" : ""); ( mmcr0>>28 & 0x4 ) ? "(kernel mode counted)" : "");
n += sprintf( buffer + n, seq_printf(m,
"\nPMC1\t\t: %08lx (%s)\n" "\nPMC1\t\t: %08lx (%s)\n"
"PMC2\t\t: %08lx (%s)\n", "PMC2\t\t: %08lx (%s)\n",
pmc1, pmc1_lookup(mmcr0), pmc1, pmc1_lookup(mmcr0),
...@@ -129,10 +129,9 @@ static ssize_t ppc_htab_read(struct file * file, char __user * buf, ...@@ -129,10 +129,9 @@ static ssize_t ppc_htab_read(struct file * file, char __user * buf,
#ifdef CONFIG_PPC_STD_MMU #ifdef CONFIG_PPC_STD_MMU
/* if we don't have a htab */ /* if we don't have a htab */
if ( Hash_size == 0 ) if ( Hash_size == 0 ) {
{ seq_printf(m, "No Hash Table used\n");
n += sprintf( buffer + n, "No Hash Table used\n"); return 0;
goto return_string;
} }
#ifndef CONFIG_PPC64BRIDGE #ifndef CONFIG_PPC64BRIDGE
...@@ -151,7 +150,7 @@ static ssize_t ppc_htab_read(struct file * file, char __user * buf, ...@@ -151,7 +150,7 @@ static ssize_t ppc_htab_read(struct file * file, char __user * buf,
} }
#endif #endif
n += sprintf( buffer + n, seq_printf(m,
"PTE Hash Table Information\n" "PTE Hash Table Information\n"
"Size\t\t: %luKb\n" "Size\t\t: %luKb\n"
"Buckets\t\t: %lu\n" "Buckets\t\t: %lu\n"
...@@ -173,7 +172,7 @@ static ssize_t ppc_htab_read(struct file * file, char __user * buf, ...@@ -173,7 +172,7 @@ static ssize_t ppc_htab_read(struct file * file, char __user * buf,
#endif #endif
); );
n += sprintf( buffer + n, seq_printf(m,
"Reloads\t\t: %lu\n" "Reloads\t\t: %lu\n"
"Preloads\t: %lu\n" "Preloads\t: %lu\n"
"Searches\t: %u\n" "Searches\t: %u\n"
...@@ -181,23 +180,13 @@ static ssize_t ppc_htab_read(struct file * file, char __user * buf, ...@@ -181,23 +180,13 @@ static ssize_t ppc_htab_read(struct file * file, char __user * buf,
"Evicts\t\t: %lu\n", "Evicts\t\t: %lu\n",
htab_reloads, htab_preloads, htab_hash_searches, htab_reloads, htab_preloads, htab_hash_searches,
primary_pteg_full, htab_evicts); primary_pteg_full, htab_evicts);
return_string:
#endif /* CONFIG_PPC_STD_MMU */ #endif /* CONFIG_PPC_STD_MMU */
n += sprintf( buffer + n, seq_printf(m,
"Non-error misses: %lu\n" "Non-error misses: %lu\n"
"Error misses\t: %lu\n", "Error misses\t: %lu\n",
pte_misses, pte_errors); pte_misses, pte_errors);
if (*ppos >= strlen(buffer)) return 0;
return 0;
if (n > strlen(buffer) - *ppos)
n = strlen(buffer) - *ppos;
if (n > count)
n = count;
if (copy_to_user(buf, buffer + *ppos, n))
return -EFAULT;
*ppos += n;
return n;
} }
/* /*
...@@ -210,7 +199,7 @@ static ssize_t ppc_htab_write(struct file * file, const char __user * ubuffer, ...@@ -210,7 +199,7 @@ static ssize_t ppc_htab_write(struct file * file, const char __user * ubuffer,
unsigned long tmp; unsigned long tmp;
char buffer[16]; char buffer[16];
if ( current->uid != 0 ) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
if (strncpy_from_user(buffer, ubuffer, 15)) if (strncpy_from_user(buffer, ubuffer, 15))
return -EFAULT; return -EFAULT;
...@@ -330,26 +319,6 @@ static ssize_t ppc_htab_write(struct file * file, const char __user * ubuffer, ...@@ -330,26 +319,6 @@ static ssize_t ppc_htab_write(struct file * file, const char __user * ubuffer,
#endif /* CONFIG_PPC_STD_MMU */ #endif /* CONFIG_PPC_STD_MMU */
} }
static long long
ppc_htab_lseek(struct file * file, loff_t offset, int orig)
{
long long ret = -EINVAL;
lock_kernel();
switch (orig) {
case 0:
file->f_pos = offset;
ret = file->f_pos;
break;
case 1:
file->f_pos += offset;
ret = file->f_pos;
}
unlock_kernel();
return ret;
}
int proc_dol2crvec(ctl_table *table, int write, struct file *filp, int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
void __user *buffer_arg, size_t *lenp) void __user *buffer_arg, size_t *lenp)
{ {
......
...@@ -441,7 +441,7 @@ void simple_release_fs(struct vfsmount **mount, int *count) ...@@ -441,7 +441,7 @@ void simple_release_fs(struct vfsmount **mount, int *count)
} }
ssize_t simple_read_from_buffer(void __user *to, size_t count, loff_t *ppos, ssize_t simple_read_from_buffer(void __user *to, size_t count, loff_t *ppos,
void *from, size_t available) const void *from, size_t available)
{ {
loff_t pos = *ppos; loff_t pos = *ppos;
if (pos < 0) if (pos < 0)
......
...@@ -1527,7 +1527,7 @@ extern int simple_fill_super(struct super_block *, int, struct tree_descr *); ...@@ -1527,7 +1527,7 @@ extern int simple_fill_super(struct super_block *, int, struct tree_descr *);
extern int simple_pin_fs(char *name, struct vfsmount **mount, int *count); extern int simple_pin_fs(char *name, struct vfsmount **mount, int *count);
extern void simple_release_fs(struct vfsmount **mount, int *count); extern void simple_release_fs(struct vfsmount **mount, int *count);
extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, void *, size_t); extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t);
extern int inode_change_ok(struct inode *, struct iattr *); extern int inode_change_ok(struct inode *, struct iattr *);
extern int __must_check inode_setattr(struct inode *, struct iattr *); extern int __must_check inode_setattr(struct inode *, struct iattr *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment