Browse Source

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
  ...
master
Linus Torvalds 8 years ago
parent
commit
20b4fb4852
  1. 93
      arch/alpha/kernel/srm_env.c
  2. 28
      arch/arm/kernel/atags_proc.c
  3. 43
      arch/arm/kernel/swp_emulate.c
  4. 20
      arch/arm/mach-msm/last_radio_log.c
  5. 78
      arch/arm/mach-omap1/pm.c
  6. 4
      arch/blackfin/kernel/cplbinfo.c
  7. 301
      arch/cris/arch-v10/kernel/fasttimer.c
  8. 299
      arch/cris/arch-v32/kernel/fasttimer.c
  9. 35
      arch/h8300/kernel/gpio.c
  10. 502
      arch/ia64/kernel/palinfo.c
  11. 57
      arch/ia64/kernel/salinfo.c
  12. 146
      arch/ia64/sn/kernel/sn2/prominfo_proc.c
  13. 64
      arch/mips/kernel/smtc-proc.c
  14. 4
      arch/mips/lasat/picvue_proc.c
  15. 1
      arch/mips/mm/init.c
  16. 95
      arch/mips/pci/ops-pmcmsp.c
  17. 81
      arch/mips/sibyte/sb1250/bus_watcher.c
  18. 47
      arch/parisc/kernel/pdc_chassis.c
  19. 11
      arch/powerpc/kernel/lparcfg.c
  20. 21
      arch/powerpc/kernel/proc_powerpc.c
  21. 452
      arch/powerpc/kernel/rtas_flash.c
  22. 2
      arch/powerpc/kvm/book3s_64_mmu_hv.c
  23. 2
      arch/powerpc/kvm/book3s_64_vio.c
  24. 2
      arch/powerpc/kvm/book3s_hv.c
  25. 2
      arch/powerpc/platforms/cell/spufs/file.c
  26. 2
      arch/powerpc/platforms/pseries/reconfig.c
  27. 32
      arch/powerpc/platforms/pseries/scanlog.c
  28. 16
      arch/s390/kernel/compat_wrapper.S
  29. 6
      arch/s390/kernel/irq.c
  30. 1
      arch/s390/kernel/os_info.c
  31. 4
      arch/s390/kernel/syscalls.S
  32. 2
      arch/score/mm/init.c
  33. 28
      arch/sh/drivers/dma/dma-api.c
  34. 2
      arch/sh/mm/alignment.c
  35. 2
      arch/sparc/kernel/ioport.c
  36. 1
      arch/sparc/kernel/sun4d_irq.c
  37. 2
      arch/tile/kernel/hardwall.c
  38. 3
      arch/um/drivers/mconsole_kern.c
  39. 30
      arch/x86/ia32/ia32_aout.c
  40. 1
      arch/x86/mm/init_64.c
  41. 1
      arch/x86/platform/efi/efi.c
  42. 1
      arch/x86/platform/efi/efi_64.c
  43. 36
      arch/xtensa/platforms/iss/simdisk.c
  44. 2
      drivers/acpi/ac.c
  45. 2
      drivers/acpi/battery.c
  46. 2
      drivers/acpi/button.c
  47. 4
      drivers/acpi/proc.c
  48. 29
      drivers/acpi/sbs.c
  49. 29
      drivers/ata/sata_svw.c
  50. 8
      drivers/block/DAC960.c
  51. 2
      drivers/block/cciss.c
  52. 96
      drivers/block/cciss_scsi.c
  53. 2
      drivers/block/cpqarray.c
  54. 2
      drivers/block/drbd/drbd_proc.c
  55. 2
      drivers/block/loop.c
  56. 2
      drivers/block/pktcdvd.c
  57. 2
      drivers/block/ps3vram.c
  58. 34
      drivers/char/ds1620.c
  59. 83
      drivers/char/efirtc.c
  60. 48
      drivers/char/genrtc.c
  61. 8
      drivers/char/ipmi/ipmi_msghandler.c
  62. 6
      drivers/char/ipmi/ipmi_si_intf.c
  63. 1
      drivers/firmware/efi/efi-pstore.c
  64. 1
      drivers/firmware/efi/efivars.c
  65. 43
      drivers/gpu/drm/drm_proc.c
  66. 2
      drivers/gpu/drm/drm_stub.c
  67. 2
      drivers/ide/ide-cd.c
  68. 8
      drivers/ide/ide-disk_proc.c
  69. 2
      drivers/ide/ide-floppy_proc.c
  70. 22
      drivers/ide/ide-proc.c
  71. 2
      drivers/ide/ide-tape.c
  72. 58
      drivers/input/misc/hp_sdc_rtc.c
  73. 2
      drivers/isdn/gigaset/capi.c
  74. 2
      drivers/isdn/hardware/avm/b1.c
  75. 2
      drivers/isdn/hardware/avm/b1dma.c
  76. 2
      drivers/isdn/hardware/avm/c4.c
  77. 12
      drivers/isdn/hardware/eicon/divasproc.c
  78. 2
      drivers/isdn/hysdn/hycapi.c
  79. 32
      drivers/isdn/hysdn/hysdn_procconf.c
  80. 71
      drivers/isdn/hysdn/hysdn_proclog.c
  81. 76
      drivers/isdn/mISDN/timerdev.c
  82. 2
      drivers/macintosh/via-pmu.c
  83. 5
      drivers/media/dvb-core/dvb_frontend.c
  84. 5
      drivers/media/dvb-core/dvb_net.c
  85. 179
      drivers/media/pci/cx25821/cx25821-audio-upstream.c
  86. 2
      drivers/media/pci/ttpci/av7110_ir.c
  87. 4
      drivers/media/pci/zoran/zoran_procfs.c
  88. 2
      drivers/media/rc/ir-lirc-codec.c
  89. 2
      drivers/media/rc/lirc_dev.c
  90. 4
      drivers/message/fusion/mptbase.c
  91. 8
      drivers/message/fusion/mptctl.c
  92. 2
      drivers/message/fusion/mptfc.c
  93. 2
      drivers/message/fusion/mptsas.c
  94. 98
      drivers/message/fusion/mptscsih.c
  95. 2
      drivers/message/fusion/mptscsih.h
  96. 2
      drivers/message/fusion/mptspi.c
  97. 97
      drivers/message/i2o/i2o_proc.c
  98. 1
      drivers/misc/lis3lv02d/lis3lv02d.c
  99. 2
      drivers/misc/sgi-gru/gruprocfs.c
  100. 1
      drivers/mtd/mtdcore.c

93
arch/alpha/kernel/srm_env.c

@ -51,13 +51,11 @@ MODULE_LICENSE("GPL");
typedef struct _srm_env {
char *name;
unsigned long id;
struct proc_dir_entry *proc_entry;
} srm_env_t;
static struct proc_dir_entry *base_dir;
static struct proc_dir_entry *named_dir;
static struct proc_dir_entry *numbered_dir;
static char number[256][4];
static srm_env_t srm_named_entries[] = {
{ "auto_action", ENV_AUTO_ACTION },
@ -77,21 +75,18 @@ static srm_env_t srm_named_entries[] = {
{ "tty_dev", ENV_TTY_DEV },
{ NULL, 0 },
};
static srm_env_t srm_numbered_entries[256];
static int srm_env_proc_show(struct seq_file *m, void *v)
{
unsigned long ret;
srm_env_t *entry;
unsigned long id = (unsigned long)m->private;
char *page;
entry = m->private;
page = (char *)__get_free_page(GFP_USER);
if (!page)
return -ENOMEM;
ret = callback_getenv(entry->id, page, PAGE_SIZE);
ret = callback_getenv(id, page, PAGE_SIZE);
if ((ret >> 61) == 0) {
seq_write(m, page, ret);
@ -104,14 +99,14 @@ static int srm_env_proc_show(struct seq_file *m, void *v)
static int srm_env_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, srm_env_proc_show, PDE(inode)->data);
return single_open(file, srm_env_proc_show, PDE_DATA(inode));
}
static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *pos)
{
int res;
srm_env_t *entry = PDE(file_inode(file))->data;
unsigned long id = (unsigned long)PDE_DATA(file_inode(file));
char *buf = (char *) __get_free_page(GFP_USER);
unsigned long ret1, ret2;
@ -127,7 +122,7 @@ static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
goto out;
buf[count] = '\0';
ret1 = callback_setenv(entry->id, buf, count);
ret1 = callback_setenv(id, buf, count);
if ((ret1 >> 61) == 0) {
do
ret2 = callback_save_env();
@ -149,52 +144,6 @@ static const struct file_operations srm_env_proc_fops = {
.write = srm_env_proc_write,
};
static void
srm_env_cleanup(void)
{
srm_env_t *entry;
unsigned long var_num;
if (base_dir) {
/*
* Remove named entries
*/
if (named_dir) {
entry = srm_named_entries;
while (entry->name != NULL && entry->id != 0) {
if (entry->proc_entry) {
remove_proc_entry(entry->name,
named_dir);
entry->proc_entry = NULL;
}
entry++;
}
remove_proc_entry(NAMED_DIR, base_dir);
}
/*
* Remove numbered entries
*/
if (numbered_dir) {
for (var_num = 0; var_num <= 255; var_num++) {
entry = &srm_numbered_entries[var_num];
if (entry->proc_entry) {
remove_proc_entry(entry->name,
numbered_dir);
entry->proc_entry = NULL;
entry->name = NULL;
}
}
remove_proc_entry(NUMBERED_DIR, base_dir);
}
remove_proc_entry(BASE_DIR, NULL);
}
return;
}
static int __init
srm_env_init(void)
{
@ -212,12 +161,6 @@ srm_env_init(void)
return -ENODEV;
}
/*
* Init numbers
*/
for (var_num = 0; var_num <= 255; var_num++)
sprintf(number[var_num], "%ld", var_num);
/*
* Create base directory
*/
@ -225,7 +168,7 @@ srm_env_init(void)
if (!base_dir) {
printk(KERN_ERR "Couldn't create base dir /proc/%s\n",
BASE_DIR);
goto cleanup;
return -ENOMEM;
}
/*
@ -254,9 +197,8 @@ srm_env_init(void)
*/
entry = srm_named_entries;
while (entry->name && entry->id) {
entry->proc_entry = proc_create_data(entry->name, 0644, named_dir,
&srm_env_proc_fops, entry);
if (!entry->proc_entry)
if (!proc_create_data(entry->name, 0644, named_dir,
&srm_env_proc_fops, (void *)entry->id))
goto cleanup;
entry++;
}
@ -265,15 +207,11 @@ srm_env_init(void)
* Create all numbered nodes
*/
for (var_num = 0; var_num <= 255; var_num++) {
entry = &srm_numbered_entries[var_num];
entry->name = number[var_num];
entry->proc_entry = proc_create_data(entry->name, 0644, numbered_dir,
&srm_env_proc_fops, entry);
if (!entry->proc_entry)
char name[4];
sprintf(name, "%ld", var_num);
if (!proc_create_data(name, 0644, numbered_dir,
&srm_env_proc_fops, (void *)var_num))
goto cleanup;
entry->id = var_num;
}
printk(KERN_INFO "%s: version %s loaded successfully\n", NAME,
@ -282,18 +220,15 @@ srm_env_init(void)
return 0;
cleanup:
srm_env_cleanup();
remove_proc_subtree(BASE_DIR, NULL);
return -ENOMEM;
}
static void __exit
srm_env_exit(void)
{
srm_env_cleanup();
remove_proc_subtree(BASE_DIR, NULL);
printk(KERN_INFO "%s: unloaded successfully\n", NAME);
return;
}
module_init(srm_env_init);

28
arch/arm/kernel/atags_proc.c

@ -9,24 +9,18 @@ struct buffer {
char data[];
};
static int
read_buffer(char* page, char** start, off_t off, int count,
int* eof, void* data)
static ssize_t atags_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct buffer *buffer = (struct buffer *)data;
if (off >= buffer->size) {
*eof = 1;
return 0;
}
count = min((int) (buffer->size - off), count);
memcpy(page, &buffer->data[off], count);
return count;
struct buffer *b = PDE_DATA(file_inode(file));
return simple_read_from_buffer(buf, count, ppos, b->data, b->size);
}
static const struct file_operations atags_fops = {
.read = atags_read,
.llseek = default_llseek,
};
#define BOOT_PARAMS_SIZE 1536
static char __initdata atags_copy[BOOT_PARAMS_SIZE];
@ -66,9 +60,7 @@ static int __init init_atags_procfs(void)
b->size = size;
memcpy(b->data, atags_copy, size);
tags_entry = create_proc_read_entry("atags", 0400,
NULL, read_buffer, b);
tags_entry = proc_create_data("atags", 0400, NULL, &atags_fops, b);
if (!tags_entry)
goto nomem;

43
arch/arm/kernel/swp_emulate.c

@ -21,6 +21,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/sched.h>
#include <linux/syscalls.h>
#include <linux/perf_event.h>
@ -79,27 +80,27 @@ static unsigned long abtcounter;
static pid_t previous_pid;
#ifdef CONFIG_PROC_FS
static int proc_read_status(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int proc_status_show(struct seq_file *m, void *v)
{
char *p = page;
int len;
p += sprintf(p, "Emulated SWP:\t\t%lu\n", swpcounter);
p += sprintf(p, "Emulated SWPB:\t\t%lu\n", swpbcounter);
p += sprintf(p, "Aborted SWP{B}:\t\t%lu\n", abtcounter);
seq_printf(m, "Emulated SWP:\t\t%lu\n", swpcounter);
seq_printf(m, "Emulated SWPB:\t\t%lu\n", swpbcounter);
seq_printf(m, "Aborted SWP{B}:\t\t%lu\n", abtcounter);
if (previous_pid != 0)
p += sprintf(p, "Last process:\t\t%d\n", previous_pid);
len = (p - page) - off;
if (len < 0)
len = 0;
*eof = (len <= count) ? 1 : 0;
*start = page + off;
seq_printf(m, "Last process:\t\t%d\n", previous_pid);
return 0;
}
return len;
static int proc_status_open(struct inode *inode, struct file *file)
{
return single_open(file, proc_status_show, PDE_DATA(inode));
}
static const struct file_operations proc_status_fops = {
.open = proc_status_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
#endif
/*
@ -266,14 +267,8 @@ static struct undef_hook swp_hook = {
static int __init swp_emulation_init(void)
{
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *res;
res = create_proc_entry("cpu/swp_emulation", S_IRUGO, NULL);
if (!res)
if (!proc_create("cpu/swp_emulation", S_IRUGO, NULL, &proc_status_fops))
return -ENOMEM;
res->read_proc = proc_read_status;
#endif /* CONFIG_PROC_FS */
printk(KERN_NOTICE "Registering SWP/SWPB emulation handler\n");

20
arch/arm/mach-msm/last_radio_log.c

@ -31,20 +31,8 @@ extern void *smem_item(unsigned id, unsigned *size);
static ssize_t last_radio_log_read(struct file *file, char __user *buf,
size_t len, loff_t *offset)
{
loff_t pos = *offset;
ssize_t count;
if (pos >= radio_log_size)
return 0;
count = min(len, (size_t)(radio_log_size - pos));
if (copy_to_user(buf, radio_log_base + pos, count)) {
pr_err("%s: copy to user failed\n", __func__);
return -EFAULT;
}
*offset += count;
return count;
return simple_read_from_buffer(buf, len, offset,
radio_log_base, radio_log_size);
}
static struct file_operations last_radio_log_fops = {
@ -67,7 +55,8 @@ void msm_init_last_radio_log(struct module *owner)
return;
}
entry = create_proc_entry("last_radio_log", S_IFREG | S_IRUGO, NULL);
entry = proc_create("last_radio_log", S_IRUGO, NULL,
&last_radio_log_fops);
if (!entry) {
pr_err("%s: could not create proc entry for radio log\n",
__func__);
@ -77,7 +66,6 @@ void msm_init_last_radio_log(struct module *owner)
pr_err("%s: last radio log is %d bytes long\n", __func__,
radio_log_size);
last_radio_log_fops.owner = owner;
entry->proc_fops = &last_radio_log_fops;
entry->size = radio_log_size;
}
EXPORT_SYMBOL(msm_init_last_radio_log);

78
arch/arm/mach-omap1/pm.c

@ -37,7 +37,8 @@
#include <linux/suspend.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include <linux/sysfs.h>
#include <linux/module.h>
@ -423,23 +424,12 @@ void omap1_pm_suspend(void)
omap_rev());
}
#if defined(DEBUG) && defined(CONFIG_PROC_FS)
static int g_read_completed;
#ifdef CONFIG_DEBUG_FS
/*
* Read system PM registers for debugging
*/
static int omap_pm_read_proc(
char *page_buffer,
char **my_first_byte,
off_t virtual_start,
int length,
int *eof,
void *data)
static int omap_pm_debug_show(struct seq_file *m, void *v)
{
int my_buffer_offset = 0;
char * const my_base = page_buffer;
ARM_SAVE(ARM_CKCTL);
ARM_SAVE(ARM_IDLECT1);
ARM_SAVE(ARM_IDLECT2);
@ -480,10 +470,7 @@ static int omap_pm_read_proc(
MPUI1610_SAVE(EMIFS_CONFIG);
}
if (virtual_start == 0) {
g_read_completed = 0;
my_buffer_offset += sprintf(my_base + my_buffer_offset,
seq_printf(m,
"ARM_CKCTL_REG: 0x%-8x \n"
"ARM_IDLECT1_REG: 0x%-8x \n"
"ARM_IDLECT2_REG: 0x%-8x \n"
@ -513,8 +500,8 @@ static int omap_pm_read_proc(
ULPD_SHOW(ULPD_STATUS_REQ),
ULPD_SHOW(ULPD_POWER_CTRL));
if (cpu_is_omap7xx()) {
my_buffer_offset += sprintf(my_base + my_buffer_offset,
if (cpu_is_omap7xx()) {
seq_printf(m,
"MPUI7XX_CTRL_REG 0x%-8x \n"
"MPUI7XX_DSP_STATUS_REG: 0x%-8x \n"
"MPUI7XX_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
@ -527,8 +514,8 @@ static int omap_pm_read_proc(
MPUI7XX_SHOW(MPUI_DSP_API_CONFIG),
MPUI7XX_SHOW(EMIFF_SDRAM_CONFIG),
MPUI7XX_SHOW(EMIFS_CONFIG));
} else if (cpu_is_omap15xx()) {
my_buffer_offset += sprintf(my_base + my_buffer_offset,
} else if (cpu_is_omap15xx()) {
seq_printf(m,
"MPUI1510_CTRL_REG 0x%-8x \n"
"MPUI1510_DSP_STATUS_REG: 0x%-8x \n"
"MPUI1510_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
@ -541,8 +528,8 @@ static int omap_pm_read_proc(
MPUI1510_SHOW(MPUI_DSP_API_CONFIG),
MPUI1510_SHOW(EMIFF_SDRAM_CONFIG),
MPUI1510_SHOW(EMIFS_CONFIG));
} else if (cpu_is_omap16xx()) {
my_buffer_offset += sprintf(my_base + my_buffer_offset,
} else if (cpu_is_omap16xx()) {
seq_printf(m,
"MPUI1610_CTRL_REG 0x%-8x \n"
"MPUI1610_DSP_STATUS_REG: 0x%-8x \n"
"MPUI1610_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
@ -555,28 +542,37 @@ static int omap_pm_read_proc(
MPUI1610_SHOW(MPUI_DSP_API_CONFIG),
MPUI1610_SHOW(EMIFF_SDRAM_CONFIG),
MPUI1610_SHOW(EMIFS_CONFIG));
}
g_read_completed++;
} else if (g_read_completed >= 1) {
*eof = 1;
return 0;
}
g_read_completed++;
*my_first_byte = page_buffer;
return my_buffer_offset;
return 0;
}
static int omap_pm_debug_open(struct inode *inode, struct file *file)
{
return single_open(file, omap_pm_debug_show,
&inode->i_private);
}
static void omap_pm_init_proc(void)
static const struct file_operations omap_pm_debug_fops = {
.open = omap_pm_debug_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static void omap_pm_init_debugfs(void)
{
/* XXX Appears to leak memory */
create_proc_read_entry("driver/omap_pm",
S_IWUSR | S_IRUGO, NULL,
omap_pm_read_proc, NULL);
struct dentry *d;
d = debugfs_create_dir("pm_debug", NULL);
if (!d)
return;
(void) debugfs_create_file("omap_pm", S_IWUSR | S_IRUGO,
d, NULL, &omap_pm_debug_fops);
}
#endif /* DEBUG && CONFIG_PROC_FS */
#endif /* CONFIG_DEBUG_FS */
/*
* omap_pm_prepare - Do preliminary suspend work.
@ -701,8 +697,8 @@ static int __init omap_pm_init(void)
suspend_set_ops(&omap_pm_ops);
#if defined(DEBUG) && defined(CONFIG_PROC_FS)
omap_pm_init_proc();
#ifdef CONFIG_DEBUG_FS
omap_pm_init_debugfs();
#endif
#ifdef CONFIG_OMAP_32K_TIMER

4
arch/blackfin/kernel/cplbinfo.c

@ -116,14 +116,12 @@ static const struct seq_operations cplbinfo_sops = {
static int cplbinfo_open(struct inode *inode, struct file *file)
{
struct proc_dir_entry *pde = PDE(file_inode(file));
char cplb_type;
unsigned int cpu;
unsigned int cpu = (unsigned long)PDE_DATA(file_inode(file));
int ret;
struct seq_file *m;
struct cplbinfo_data *cdata;
cpu = (unsigned int)pde->data;
cplb_type = cpu & CPLBINFO_DCPLB_FLAG ? 'D' : 'I';
cpu &= ~CPLBINFO_DCPLB_FLAG;

301
arch/cris/arch-v10/kernel/fasttimer.c

@ -25,6 +25,7 @@
#include <arch/svinto.h>
#include <asm/fasttimer.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#define DEBUG_LOG_INCLUDED
@ -489,197 +490,162 @@ void schedule_usleep(unsigned long us)
}
#ifdef CONFIG_PROC_FS
static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len
,int *eof, void *data_unused);
static struct proc_dir_entry *fasttimer_proc_entry;
#endif /* CONFIG_PROC_FS */
#ifdef CONFIG_PROC_FS
/* This value is very much based on testing */
#define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300)
static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len
,int *eof, void *data_unused)
static int proc_fasttimer_show(struct seq_file *m, void *v)
{
unsigned long flags;
int i = 0;
int num_to_show;
unsigned long flags;
int i = 0;
int num_to_show;
struct fasttime_t tv;
struct fast_timer *t, *nextt;
static char *bigbuf = NULL;
static unsigned long used;
if (!bigbuf && !(bigbuf = vmalloc(BIG_BUF_SIZE)))
{
used = 0;
if (buf)
buf[0] = '\0';
return 0;
}
if (!offset || !used)
{
do_gettimeofday_fast(&tv);
used = 0;
used += sprintf(bigbuf + used, "Fast timers added: %i\n",
fast_timers_added);
used += sprintf(bigbuf + used, "Fast timers started: %i\n",
fast_timers_started);
used += sprintf(bigbuf + used, "Fast timer interrupts: %i\n",
fast_timer_ints);
used += sprintf(bigbuf + used, "Fast timers expired: %i\n",
fast_timers_expired);
used += sprintf(bigbuf + used, "Fast timers deleted: %i\n",
fast_timers_deleted);
used += sprintf(bigbuf + used, "Fast timer running: %s\n",
fast_timer_running ? "yes" : "no");
used += sprintf(bigbuf + used, "Current time: %lu.%06lu\n",
(unsigned long)tv.tv_jiff,
(unsigned long)tv.tv_usec);
struct fast_timer *t, *nextt;
do_gettimeofday_fast(&tv);
seq_printf(m, "Fast timers added: %i\n", fast_timers_added);
seq_printf(m, "Fast timers started: %i\n", fast_timers_started);
seq_printf(m, "Fast timer interrupts: %i\n", fast_timer_ints);
seq_printf(m, "Fast timers expired: %i\n", fast_timers_expired);
seq_printf(m, "Fast timers deleted: %i\n", fast_timers_deleted);
seq_printf(m, "Fast timer running: %s\n",
fast_timer_running ? "yes" : "no");
seq_printf(m, "Current time: %lu.%06lu\n",
(unsigned long)tv.tv_jiff,
(unsigned long)tv.tv_usec);
#ifdef FAST_TIMER_SANITY_CHECKS
used += sprintf(bigbuf + used, "Sanity failed: %i\n",
sanity_failed);
seq_printf(m, "Sanity failed: %i\n", sanity_failed);
#endif
used += sprintf(bigbuf + used, "\n");
seq_putc(m, '\n');
#ifdef DEBUG_LOG_INCLUDED
{
int end_i = debug_log_cnt;
i = 0;
if (debug_log_cnt_wrapped)
{
i = debug_log_cnt;
}
while ((i != end_i || (debug_log_cnt_wrapped && !used)) &&
used+100 < BIG_BUF_SIZE)
{
used += sprintf(bigbuf + used, debug_log_string[i],
debug_log_value[i]);
i = (i+1) % DEBUG_LOG_MAX;
}
}
used += sprintf(bigbuf + used, "\n");
{
int end_i = debug_log_cnt;
i = 0;
if (debug_log_cnt_wrapped)
i = debug_log_cnt;
while (i != end_i || debug_log_cnt_wrapped) {
if (seq_printf(m, debug_log_string[i], debug_log_value[i]) < 0)
return 0;
i = (i+1) % DEBUG_LOG_MAX;
}
}
seq_putc(m, '\n');
#endif
num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started:
NUM_TIMER_STATS);
used += sprintf(bigbuf + used, "Timers started: %i\n", fast_timers_started);
for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE) ; i++)
{
int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS;
num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started:
NUM_TIMER_STATS);
seq_printf(m, "Timers started: %i\n", fast_timers_started);
for (i = 0; i < num_to_show; i++) {
int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS;
#if 1 //ndef FAST_TIMER_LOG
used += sprintf(bigbuf + used, "div: %i freq: %i delay: %i"
"\n",
timer_div_settings[cur],
timer_freq_settings[cur],
timer_delay_settings[cur]
);
seq_printf(m, "div: %i freq: %i delay: %i"
"\n",
timer_div_settings[cur],
timer_freq_settings[cur],
timer_delay_settings[cur]);
#endif
#ifdef FAST_TIMER_LOG
t = &timer_started_log[cur];
used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data
);
t = &timer_started_log[cur];
if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data) < 0)
return 0;
#endif
}
used += sprintf(bigbuf + used, "\n");
}
seq_putc(m, '\n');
#ifdef FAST_TIMER_LOG
num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added:
NUM_TIMER_STATS);
used += sprintf(bigbuf + used, "Timers added: %i\n", fast_timers_added);
for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++)
{
t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS];
used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data
);
}
used += sprintf(bigbuf + used, "\n");
num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired:
NUM_TIMER_STATS);
used += sprintf(bigbuf + used, "Timers expired: %i\n", fast_timers_expired);
for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++)
{
t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS];
used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data
);
}
used += sprintf(bigbuf + used, "\n");
num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added:
NUM_TIMER_STATS);
seq_printf(m, "Timers added: %i\n", fast_timers_added);
for (i = 0; i < num_to_show; i++) {
t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS];
if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data) < 0)
return 0;
}
seq_putc(m, '\n');
num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired:
NUM_TIMER_STATS);
seq_printf(m, "Timers expired: %i\n", fast_timers_expired);
for (i = 0; i < num_to_show; i++) {
t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS];
if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data) < 0)
return 0;
}
seq_putc(m, '\n');
#endif
used += sprintf(bigbuf + used, "Active timers:\n");
local_irq_save(flags);
t = fast_timer_list;
while (t != NULL && (used+100 < BIG_BUF_SIZE))
{
nextt = t->next;
local_irq_restore(flags);
used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
seq_puts(m, "Active timers:\n");
local_irq_save(flags);
t = fast_timer_list;
while (t) {
nextt = t->next;
local_irq_restore(flags);
if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
/* " func: 0x%08lX" */
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data
/* , t->function */
);
local_irq_save(flags);
if (t->next != nextt)
{
printk(KERN_WARNING "timer removed!\n");
}
t = nextt;
}
local_irq_restore(flags);
}
if (used - offset < len)
{
len = used - offset;
}
) < 0)
return 0;
local_irq_save(flags);
if (t->next != nextt)
printk(KERN_WARNING "timer removed!\n");
t = nextt;
}
local_irq_restore(flags);
memcpy(buf, bigbuf + offset, len);
*start = buf;
*eof = 1;
return 0;
}
return len;
static int proc_fasttimer_open(struct inode *inode, struct file *file)
{
return single_open_size(file, proc_fasttimer_show, PDE_DATA(inode), BIG_BUF_SIZE);
}
static const struct file_operations proc_fasttimer_fops = {
.open = proc_fasttimer_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
#endif /* PROC_FS */
#ifdef FAST_TIMER_TEST
@ -857,8 +823,7 @@ int fast_timer_init(void)
}
#endif
#ifdef CONFIG_PROC_FS
if ((fasttimer_proc_entry = create_proc_entry( "fasttimer", 0, 0 )))
fasttimer_proc_entry->read_proc = proc_fasttimer_read;
proc_create("fasttimer", 0, NULL, &proc_fasttimer_fops);
#endif /* PROC_FS */
if(request_irq(TIMER1_IRQ_NBR, timer1_handler, 0,
"fast timer int", NULL))

299
arch/cris/arch-v32/kernel/fasttimer.c

@ -23,6 +23,7 @@
#include <hwregs/timer_defs.h>
#include <asm/fasttimer.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
/*
* timer0 is running at 100MHz and generating jiffies timer ticks
@ -463,195 +464,161 @@ void schedule_usleep(unsigned long us)
}
#ifdef CONFIG_PROC_FS
static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len
,int *eof, void *data_unused);
static struct proc_dir_entry *fasttimer_proc_entry;
#endif /* CONFIG_PROC_FS */
#ifdef CONFIG_PROC_FS
/* This value is very much based on testing */
#define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300)
static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len
,int *eof, void *data_unused)
static int proc_fasttimer_show(struct seq_file *m, void *v)
{
unsigned long flags;
int i = 0;
int num_to_show;
unsigned long flags;
int i = 0;
int num_to_show;
struct fasttime_t tv;
struct fast_timer *t, *nextt;
static char *bigbuf = NULL;
static unsigned long used;
if (!bigbuf) {
bigbuf = vmalloc(BIG_BUF_SIZE);
if (!bigbuf) {
used = 0;
if (buf)
buf[0] = '\0';
return 0;
}
}
if (!offset || !used) {
do_gettimeofday_fast(&tv);
used = 0;
used += sprintf(bigbuf + used, "Fast timers added: %i\n",
fast_timers_added);
used += sprintf(bigbuf + used, "Fast timers started: %i\n",
fast_timers_started);
used += sprintf(bigbuf + used, "Fast timer interrupts: %i\n",
fast_timer_ints);
used += sprintf(bigbuf + used, "Fast timers expired: %i\n",
fast_timers_expired);
used += sprintf(bigbuf + used, "Fast timers deleted: %i\n",
fast_timers_deleted);
used += sprintf(bigbuf + used, "Fast timer running: %s\n",
fast_timer_running ? "yes" : "no");
used += sprintf(bigbuf + used, "Current time: %lu.%06lu\n",
(unsigned long)tv.tv_jiff,
(unsigned long)tv.tv_usec);
struct fast_timer *t, *nextt;
do_gettimeofday_fast(&tv);
seq_printf(m, "Fast timers added: %i\n", fast_timers_added);
seq_printf(m, "Fast timers started: %i\n", fast_timers_started);
seq_printf(m, "Fast timer interrupts: %i\n", fast_timer_ints);
seq_printf(m, "Fast timers expired: %i\n", fast_timers_expired);
seq_printf(m, "Fast timers deleted: %i\n", fast_timers_deleted);
seq_printf(m, "Fast timer running: %s\n",
fast_timer_running ? "yes" : "no");
seq_printf(m, "Current time: %lu.%06lu\n",
(unsigned long)tv.tv_jiff,
(unsigned long)tv.tv_usec);
#ifdef FAST_TIMER_SANITY_CHECKS
used += sprintf(bigbuf + used, "Sanity failed: %i\n",
sanity_failed);
seq_printf(m, "Sanity failed: %i\n", sanity_failed);
#endif
used += sprintf(bigbuf + used, "\n");
seq_putc(m, '\n');
#ifdef DEBUG_LOG_INCLUDED
{
int end_i = debug_log_cnt;
i = 0;
if (debug_log_cnt_wrapped)
i = debug_log_cnt;
while ((i != end_i || (debug_log_cnt_wrapped && !used)) &&
used+100 < BIG_BUF_SIZE)
{
used += sprintf(bigbuf + used, debug_log_string[i],
debug_log_value[i]);
i = (i+1) % DEBUG_LOG_MAX;
}
}
used += sprintf(bigbuf + used, "\n");
{
int end_i = debug_log_cnt;
i = 0;
if (debug_log_cnt_wrapped)
i = debug_log_cnt;
while ((i != end_i || debug_log_cnt_wrapped)) {
if (seq_printf(m, debug_log_string[i], debug_log_value[i]) < 0)
return 0;
i = (i+1) % DEBUG_LOG_MAX;
}
}
seq_putc(m, '\n');
#endif
num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started:
NUM_TIMER_STATS);
used += sprintf(bigbuf + used, "Timers started: %i\n", fast_timers_started);
for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE) ; i++)
{
int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS;
num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started:
NUM_TIMER_STATS);
seq_printf(m, "Timers started: %i\n", fast_timers_started);
for (i = 0; i < num_to_show; i++) {
int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS;
#if 1 //ndef FAST_TIMER_LOG
used += sprintf(bigbuf + used, "div: %i delay: %i"
"\n",
timer_div_settings[cur],
timer_delay_settings[cur]
);
seq_printf(m, "div: %i delay: %i"
"\n",
timer_div_settings[cur],
timer_delay_settings[cur]);
#endif
#ifdef FAST_TIMER_LOG
t = &timer_started_log[cur];
used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data
);
t = &timer_started_log[cur];
if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data) < 0)
return 0;
#endif
}
used += sprintf(bigbuf + used, "\n");
}
seq_putc(m, '\n');
#ifdef FAST_TIMER_LOG
num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added:
NUM_TIMER_STATS);
used += sprintf(bigbuf + used, "Timers added: %i\n", fast_timers_added);
for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++)
{
t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS];
used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data
);
}
used += sprintf(bigbuf + used, "\n");
num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired:
NUM_TIMER_STATS);
used += sprintf(bigbuf + used, "Timers expired: %i\n", fast_timers_expired);
for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++)
{
t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS];
used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data
);
}
used += sprintf(bigbuf + used, "\n");
num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added:
NUM_TIMER_STATS);
seq_printf(m, "Timers added: %i\n", fast_timers_added);
for (i = 0; i < num_to_show; i++) {
t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS];
if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data) < 0)
return 0;
}
seq_putc(m, '\n');
num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired:
NUM_TIMER_STATS);
seq_printf(m, "Timers expired: %i\n", fast_timers_expired);
for (i = 0; i < num_to_show; i++){
t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS];
if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data) < 0)
return 0;
}
seq_putc(m, '\n');
#endif
used += sprintf(bigbuf + used, "Active timers:\n");
local_irq_save(flags);
t = fast_timer_list;
while (t != NULL && (used+100 < BIG_BUF_SIZE))
{
nextt = t->next;
local_irq_restore(flags);
used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
seq_puts(m, "Active timers:\n");
local_irq_save(flags);
t = fast_timer_list;
while (t != NULL){
nextt = t->next;
local_irq_restore(flags);
if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
"d: %6li us data: 0x%08lX"
/* " func: 0x%08lX" */
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data
"\n",
t->name,
(unsigned long)t->tv_set.tv_jiff,
(unsigned long)t->tv_set.tv_usec,
(unsigned long)t->tv_expires.tv_jiff,
(unsigned long)t->tv_expires.tv_usec,
t->delay_us,
t->data
/* , t->function */
);
local_irq_save(flags);
if (t->next != nextt)
{
printk("timer removed!\n");
}
t = nextt;
}
local_irq_restore(flags);
}
) < 0)
return 0;
local_irq_save(flags);
if (t->next != nextt)
printk("timer removed!\n");
t = nextt;
}
local_irq_restore(flags);
return 0;
}
if (used - offset < len)
{
len = used - offset;
}
static int proc_fasttimer_open(struct inode *inode, struct file *file)
{
return single_open_size(file, proc_fasttimer_show, PDE_DATA(inode), BIG_BUF_SIZE);
}
memcpy(buf, bigbuf + offset, len);
*start = buf;
*eof = 1;
static const struct file_operations proc_fasttimer_fops = {
.open = proc_fasttimer_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
return len;
}
#endif /* PROC_FS */
#ifdef FAST_TIMER_TEST
@ -816,9 +783,7 @@ int fast_timer_init(void)
printk("fast_timer_init()\n");
#ifdef CONFIG_PROC_FS
fasttimer_proc_entry = create_proc_entry("fasttimer", 0, 0);
if (fasttimer_proc_entry)
fasttimer_proc_entry->read_proc = proc_fasttimer_read;
proc_create("fasttimer", 0, NULL, &proc_fasttimer_fops);
#endif /* PROC_FS */
if (request_irq(TIMER0_INTR_VECT, timer_trig_interrupt,
IRQF_SHARED | IRQF_DISABLED,

35
arch/h8300/kernel/gpio.c

@ -11,6 +11,7 @@
#include <linux/stddef.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/fs.h>
@ -138,30 +139,34 @@ static char *port_status(int portno)
return result;
}
static int gpio_proc_read(char *buf, char **start, off_t offset,
int len, int *unused_i, void *unused_v)
static int gpio_proc_show(struct seq_file *m, void *v)
{
int c,outlen;
static const char port_name[]="123456789ABCDEFGH";
outlen = 0;
int c;
for (c = 0; c < MAX_PORT; c++) {
if (ddrs[c] == NULL)
continue ;
len = sprintf(buf,"P%c: %s\n",port_name[c],port_status(c));
buf += len;
outlen += len;
continue;
seq_printf(m, "P%c: %s\n", port_name[c], port_status(c));
}
return outlen;
return 0;
}
static __init int register_proc(void)
static int gpio_proc_open(struct inode *inode, struct file *file)
{
struct proc_dir_entry *proc_gpio;
return single_open(file, gpio_proc_show, PDE_DATA(inode));
}
proc_gpio = create_proc_entry("gpio", S_IRUGO, NULL);
if (proc_gpio)
proc_gpio->read_proc = gpio_proc_read;
return proc_gpio != NULL;
static const struct file_operations gpio_proc_fops = {
.open = gpio_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static __init int register_proc(void)
{
return proc_create("gpio", S_IRUGO, NULL, &gpio_proc_fops) != NULL;
}
__initcall(register_proc);

502
arch/ia64/kernel/palinfo.c

@ -22,6 +22,7 @@
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/efi.h>
@ -41,7 +42,7 @@ MODULE_LICENSE("GPL");
#define PALINFO_VERSION "0.5"
typedef int (*palinfo_func_t)(char*);
typedef int (*palinfo_func_t)(struct seq_file *);
typedef struct {
const char *name; /* name of the proc entry */
@ -54,7 +55,7 @@ typedef struct {
* A bunch of string array to get pretty printing
*/
static char *cache_types[] = {
static const char *cache_types[] = {
"", /* not used */
"Instruction",
"Data",
@ -122,19 +123,16 @@ static const char *mem_attrib[]={
* - a pointer to the end of the buffer
*
*/
static char *
bitvector_process(char *p, u64 vector)
static void bitvector_process(struct seq_file *m, u64 vector)
{
int i,j;
const char *units[]={ "", "K", "M", "G", "T" };
static const char *units[]={ "", "K", "M", "G", "T" };
for (i=0, j=0; i < 64; i++ , j=i/10) {
if (vector & 0x1) {
p += sprintf(p, "%d%s ", 1 << (i-j*10), units[j]);
}
if (vector & 0x1)
seq_printf(m, "%d%s ", 1 << (i-j*10), units[j]);
vector >>= 1;
}
return p;
}
/*
@ -149,8 +147,7 @@ bitvector_process(char *p, u64 vector)
* - a pointer to the end of the buffer
*
*/
static char *
bitregister_process(char *p, u64 *reg_info, int max)
static void bitregister_process(struct seq_file *m, u64 *reg_info, int max)
{
int i, begin, skip = 0;
u64 value = reg_info[0];
@ -163,9 +160,9 @@ bitregister_process(char *p, u64 *reg_info, int max)
if ((value & 0x1) == 0 && skip == 0) {
if (begin <= i - 2)
p += sprintf(p, "%d-%d ", begin, i-1);
seq_printf(m, "%d-%d ", begin, i-1);
else
p += sprintf(p, "%d ", i-1);
seq_printf(m, "%d ", i-1);
skip = 1;
begin = -1;
} else if ((value & 0x1) && skip == 1) {
@ -176,19 +173,15 @@ bitregister_process(char *p, u64 *reg_info, int max)
}
if (begin > -1) {
if (begin < 127)
p += sprintf(p, "%d-127", begin);
seq_printf(m, "%d-127", begin);
else
p += sprintf(p, "127");
seq_puts(m, "127");
}
return p;
}