aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 20:51:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 20:51:54 -0400
commit20b4fb485227404329e41ad15588afad3df23050 (patch)
treef3e099f0ab3da8a93b447203e294d2bb22f6dc05 /drivers
parentb9394d8a657cd3c064fa432aa0905c1b58b38fe9 (diff)
parentac3e3c5b1164397656df81b9e9ab4991184d3236 (diff)
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')
-rw-r--r--drivers/acpi/ac.c2
-rw-r--r--drivers/acpi/battery.c2
-rw-r--r--drivers/acpi/button.c2
-rw-r--r--drivers/acpi/proc.c4
-rw-r--r--drivers/acpi/sbs.c29
-rw-r--r--drivers/ata/sata_svw.c29
-rw-r--r--drivers/block/DAC960.c8
-rw-r--r--drivers/block/cciss.c2
-rw-r--r--drivers/block/cciss_scsi.c96
-rw-r--r--drivers/block/cpqarray.c2
-rw-r--r--drivers/block/drbd/drbd_proc.c2
-rw-r--r--drivers/block/loop.c2
-rw-r--r--drivers/block/pktcdvd.c2
-rw-r--r--drivers/block/ps3vram.c2
-rw-r--r--drivers/char/ds1620.c34
-rw-r--r--drivers/char/efirtc.c83
-rw-r--r--drivers/char/genrtc.c48
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c8
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c6
-rw-r--r--drivers/firmware/efi/efi-pstore.c1
-rw-r--r--drivers/firmware/efi/efivars.c1
-rw-r--r--drivers/gpu/drm/drm_proc.c43
-rw-r--r--drivers/gpu/drm/drm_stub.c2
-rw-r--r--drivers/ide/ide-cd.c2
-rw-r--r--drivers/ide/ide-disk_proc.c8
-rw-r--r--drivers/ide/ide-floppy_proc.c2
-rw-r--r--drivers/ide/ide-proc.c22
-rw-r--r--drivers/ide/ide-tape.c2
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c58
-rw-r--r--drivers/isdn/gigaset/capi.c2
-rw-r--r--drivers/isdn/hardware/avm/b1.c2
-rw-r--r--drivers/isdn/hardware/avm/b1dma.c2
-rw-r--r--drivers/isdn/hardware/avm/c4.c2
-rw-r--r--drivers/isdn/hardware/eicon/divasproc.c12
-rw-r--r--drivers/isdn/hysdn/hycapi.c2
-rw-r--r--drivers/isdn/hysdn/hysdn_procconf.c32
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c71
-rw-r--r--drivers/isdn/mISDN/timerdev.c76
-rw-r--r--drivers/macintosh/via-pmu.c2
-rw-r--r--drivers/media/dvb-core/dvb_frontend.c5
-rw-r--r--drivers/media/dvb-core/dvb_net.c5
-rw-r--r--drivers/media/pci/cx25821/cx25821-audio-upstream.c179
-rw-r--r--drivers/media/pci/ttpci/av7110_ir.c2
-rw-r--r--drivers/media/pci/zoran/zoran_procfs.c4
-rw-r--r--drivers/media/rc/ir-lirc-codec.c2
-rw-r--r--drivers/media/rc/lirc_dev.c2
-rw-r--r--drivers/message/fusion/mptbase.c4
-rw-r--r--drivers/message/fusion/mptctl.c8
-rw-r--r--drivers/message/fusion/mptfc.c2
-rw-r--r--drivers/message/fusion/mptsas.c2
-rw-r--r--drivers/message/fusion/mptscsih.c98
-rw-r--r--drivers/message/fusion/mptscsih.h2
-rw-r--r--drivers/message/fusion/mptspi.c2
-rw-r--r--drivers/message/i2o/i2o_proc.c97
-rw-r--r--drivers/misc/lis3lv02d/lis3lv02d.c1
-rw-r--r--drivers/misc/sgi-gru/gruprocfs.c2
-rw-r--r--drivers/mtd/mtdcore.c1
-rw-r--r--drivers/net/bonding/bond_procfs.c4
-rw-r--r--drivers/net/irda/vlsi_ir.c4
-rw-r--r--drivers/net/wireless/airo.c116
-rw-r--r--drivers/net/wireless/ath/wil6210/debugfs.c4
-rw-r--r--drivers/net/wireless/atmel.c69
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c375
-rw-r--r--drivers/net/wireless/hostap/hostap_download.c68
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c38
-rw-r--r--drivers/net/wireless/hostap/hostap_proc.c609
-rw-r--r--drivers/net/wireless/hostap/hostap_wlan.h3
-rw-r--r--drivers/net/wireless/ray_cs.c2
-rw-r--r--drivers/nubus/nubus.c55
-rw-r--r--drivers/nubus/proc.c80
-rw-r--r--drivers/of/base.c11
-rw-r--r--drivers/parisc/led.c4
-rw-r--r--drivers/pci/proc.c34
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c4
-rw-r--r--drivers/platform/x86/toshiba_acpi.c18
-rw-r--r--drivers/pnp/isapnp/proc.c6
-rw-r--r--drivers/pnp/pnpbios/proc.c4
-rw-r--r--drivers/pps/clients/pps_parport.c1
-rw-r--r--drivers/rtc/rtc-proc.c2
-rw-r--r--drivers/s390/cio/qdio_debug.c2
-rw-r--r--drivers/scsi/BusLogic.c83
-rw-r--r--drivers/scsi/BusLogic.h1
-rw-r--r--drivers/scsi/NCR5380.c61
-rw-r--r--drivers/scsi/NCR5380.h6
-rw-r--r--drivers/scsi/a2091.c3
-rw-r--r--drivers/scsi/a3000.c3
-rw-r--r--drivers/scsi/advansys.c1164
-rw-r--r--drivers/scsi/aha152x.c61
-rw-r--r--drivers/scsi/aha1740.c29
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c9
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.h12
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_proc.c163
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c9
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h12
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_proc.c153
-rw-r--r--drivers/scsi/aic7xxx_old.c2
-rw-r--r--drivers/scsi/aic7xxx_old/aic7xxx_proc.c221
-rw-r--r--drivers/scsi/arm/acornscsi.c58
-rw-r--r--drivers/scsi/arm/arxescsi.c40
-rw-r--r--drivers/scsi/arm/cumana_1.c1
-rw-r--r--drivers/scsi/arm/cumana_2.c43
-rw-r--r--drivers/scsi/arm/eesox.c42
-rw-r--r--drivers/scsi/arm/fas216.c31
-rw-r--r--drivers/scsi/arm/fas216.h6
-rw-r--r--drivers/scsi/arm/oak.c6
-rw-r--r--drivers/scsi/arm/powertec.c29
-rw-r--r--drivers/scsi/atari_NCR5380.c145
-rw-r--r--drivers/scsi/atari_scsi.c2
-rw-r--r--drivers/scsi/atari_scsi.h2
-rw-r--r--drivers/scsi/atp870u.c40
-rw-r--r--drivers/scsi/dc395x.c20
-rw-r--r--drivers/scsi/dpt_i2o.c102
-rw-r--r--drivers/scsi/dtc.c3
-rw-r--r--drivers/scsi/dtc.h3
-rw-r--r--drivers/scsi/eata_pio.c56
-rw-r--r--drivers/scsi/g_NCR5380.c51
-rw-r--r--drivers/scsi/gdth.c3
-rw-r--r--drivers/scsi/gdth.h3
-rw-r--r--drivers/scsi/gdth_proc.c211
-rw-r--r--drivers/scsi/gdth_proc.h5
-rw-r--r--drivers/scsi/gvp11.c3
-rw-r--r--drivers/scsi/imm.c40
-rw-r--r--drivers/scsi/in2000.c178
-rw-r--r--drivers/scsi/ips.c238
-rw-r--r--drivers/scsi/ips.h9
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c33
-rw-r--r--drivers/scsi/mac_scsi.c3
-rw-r--r--drivers/scsi/mac_scsi.h3
-rw-r--r--drivers/scsi/megaraid.c1040
-rw-r--r--drivers/scsi/megaraid.h17
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_ctl.c14
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_ctl.c14
-rw-r--r--drivers/scsi/mvme147.c3
-rw-r--r--drivers/scsi/nsp32.c39
-rw-r--r--drivers/scsi/pas16.c3
-rw-r--r--drivers/scsi/pas16.h3
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c36
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h9
-rw-r--r--drivers/scsi/pmcraid.c14
-rw-r--r--drivers/scsi/ppa.c36
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c2
-rw-r--r--drivers/scsi/scsi_debug.c53
-rw-r--r--drivers/scsi/scsi_proc.c74
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c115
-rw-r--r--drivers/scsi/t128.c3
-rw-r--r--drivers/scsi/t128.h3
-rw-r--r--drivers/scsi/wd33c93.c194
-rw-r--r--drivers/scsi/wd33c93.h3
-rw-r--r--drivers/scsi/wd7000.c31
-rw-r--r--drivers/staging/comedi/proc.c55
-rw-r--r--drivers/staging/csr/csr_wifi_hip_udi.c353
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifi_udi.h17
-rw-r--r--drivers/staging/csr/drv.c4
-rw-r--r--drivers/staging/csr/io.c151
-rw-r--r--drivers/staging/cxt1e1/Makefile3
-rw-r--r--drivers/staging/cxt1e1/sbeproc.c460
-rw-r--r--drivers/staging/cxt1e1/sbeproc.h14
-rw-r--r--drivers/staging/dgrp/dgrp_common.c31
-rw-r--r--drivers/staging/dgrp/dgrp_common.h65
-rw-r--r--drivers/staging/dgrp/dgrp_dpa_ops.c29
-rw-r--r--drivers/staging/dgrp/dgrp_mon_ops.c26
-rw-r--r--drivers/staging/dgrp/dgrp_net_ops.c30
-rw-r--r--drivers/staging/dgrp/dgrp_ports_ops.c18
-rw-r--r--drivers/staging/dgrp/dgrp_specproc.c399
-rw-r--r--drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c130
-rw-r--r--drivers/staging/ft1000/ft1000-usb/ft1000_debug.c2
-rw-r--r--drivers/staging/ft1000/ft1000-usb/ft1000_proc.c129
-rw-r--r--drivers/staging/keucr/scsiglue.c45
-rw-r--r--drivers/staging/rtl8187se/r8180.h1
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c146
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/Makefile1
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_core.c5
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_core.h6
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_debug.c1029
-rw-r--r--drivers/staging/rtl8192e/rtllib_crypt_ccmp.c21
-rw-r--r--drivers/staging/rtl8192e/rtllib_crypt_tkip.c44
-rw-r--r--drivers/staging/rtl8192e/rtllib_crypt_wep.c6
-rw-r--r--drivers/staging/rtl8192e/rtllib_module.c54
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_module.c53
-rw-r--r--drivers/staging/rtl8192u/ieee80211/proc.c8
-rw-r--r--drivers/staging/rtl8192u/r8192U.h1
-rw-r--r--drivers/staging/rtl8192u/r8192U_core.c211
-rw-r--r--drivers/staging/rts5139/rts51x_scsi.c30
-rw-r--r--drivers/staging/rts5139/rts51x_scsi.h2
-rw-r--r--drivers/staging/silicom/Makefile3
-rw-r--r--drivers/staging/silicom/bp_proc.c1327
-rw-r--r--drivers/staging/silicom/bpctl_mod.c (renamed from drivers/staging/silicom/bp_mod.c)1925
-rw-r--r--drivers/staging/vt6655/device_main.c74
-rw-r--r--drivers/staging/vt6656/main_usb.c63
-rw-r--r--drivers/staging/wlags49_h2/wl_main.c331
-rw-r--r--drivers/target/loopback/tcm_loop.c9
-rw-r--r--drivers/tty/serial/serial_core.c2
-rw-r--r--drivers/usb/gadget/at91_udc.c2
-rw-r--r--drivers/usb/gadget/f_fs.c2
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c124
-rw-r--r--drivers/usb/gadget/goku_udc.c89
-rw-r--r--drivers/usb/gadget/inode.c2
-rw-r--r--drivers/usb/gadget/lpc32xx_udc.c2
-rw-r--r--drivers/usb/gadget/rndis.c4
-rw-r--r--drivers/usb/host/isp1362-hcd.c7
-rw-r--r--drivers/usb/host/sl811-hcd.c2
-rw-r--r--drivers/usb/misc/yurex.c2
-rw-r--r--drivers/usb/storage/scsiglue.c42
-rw-r--r--drivers/video/bfin_adv7393fb.c43
-rw-r--r--drivers/video/pxa3xx-gcu.c36
-rw-r--r--drivers/zorro/proc.c6
206 files changed, 4530 insertions, 10891 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 6d5bf649196d..00d2efd674df 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -194,7 +194,7 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
194 194
195static int acpi_ac_open_fs(struct inode *inode, struct file *file) 195static int acpi_ac_open_fs(struct inode *inode, struct file *file)
196{ 196{
197 return single_open(file, acpi_ac_seq_show, PDE(inode)->data); 197 return single_open(file, acpi_ac_seq_show, PDE_DATA(inode));
198} 198}
199 199
200static int acpi_ac_add_fs(struct acpi_device *device) 200static int acpi_ac_add_fs(struct acpi_device *device)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 0cc384b72943..e7100459ac4a 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -929,7 +929,7 @@ static int acpi_battery_read_##_name(struct seq_file *seq, void *offset) \
929} \ 929} \
930static int acpi_battery_##_name##_open_fs(struct inode *inode, struct file *file) \ 930static int acpi_battery_##_name##_open_fs(struct inode *inode, struct file *file) \
931{ \ 931{ \
932 return single_open(file, acpi_battery_read_##_name, PDE(inode)->data); \ 932 return single_open(file, acpi_battery_read_##_name, PDE_DATA(inode)); \
933} 933}
934 934
935DECLARE_FILE_FUNCTIONS(info); 935DECLARE_FILE_FUNCTIONS(info);
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 92a659aa6396..d2e617b5b3f6 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -129,7 +129,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
129 129
130static int acpi_button_state_open_fs(struct inode *inode, struct file *file) 130static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
131{ 131{
132 return single_open(file, acpi_button_state_seq_show, PDE(inode)->data); 132 return single_open(file, acpi_button_state_seq_show, PDE_DATA(inode));
133} 133}
134 134
135static const struct file_operations acpi_button_state_fops = { 135static const struct file_operations acpi_button_state_fops = {
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 52ce76725c20..aa1227a7e3f2 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -120,7 +120,7 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
120 120
121static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file) 121static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file)
122{ 122{
123 return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data); 123 return single_open(file, acpi_system_alarm_seq_show, PDE_DATA(inode));
124} 124}
125 125
126static int get_date_field(char **p, u32 * value) 126static int get_date_field(char **p, u32 * value)
@@ -397,7 +397,7 @@ static int
397acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file) 397acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
398{ 398{
399 return single_open(file, acpi_system_wakeup_device_seq_show, 399 return single_open(file, acpi_system_wakeup_device_seq_show,
400 PDE(inode)->data); 400 PDE_DATA(inode));
401} 401}
402 402
403static const struct file_operations acpi_system_wakeup_device_fops = { 403static const struct file_operations acpi_system_wakeup_device_fops = {
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index e523245643ac..b6241eeb1132 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -521,19 +521,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
521 return 0; 521 return 0;
522} 522}
523 523
524static void
525acpi_sbs_remove_fs(struct proc_dir_entry **dir,
526 struct proc_dir_entry *parent_dir)
527{
528 if (*dir) {
529 remove_proc_entry(ACPI_SBS_FILE_INFO, *dir);
530 remove_proc_entry(ACPI_SBS_FILE_STATE, *dir);
531 remove_proc_entry(ACPI_SBS_FILE_ALARM, *dir);
532 remove_proc_entry((*dir)->name, parent_dir);
533 *dir = NULL;
534 }
535}
536
537/* Smart Battery Interface */ 524/* Smart Battery Interface */
538static struct proc_dir_entry *acpi_battery_dir = NULL; 525static struct proc_dir_entry *acpi_battery_dir = NULL;
539 526
@@ -584,7 +571,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
584 571
585static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) 572static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
586{ 573{
587 return single_open(file, acpi_battery_read_info, PDE(inode)->data); 574 return single_open(file, acpi_battery_read_info, PDE_DATA(inode));
588} 575}
589 576
590static int acpi_battery_read_state(struct seq_file *seq, void *offset) 577static int acpi_battery_read_state(struct seq_file *seq, void *offset)
@@ -623,7 +610,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
623 610
624static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) 611static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
625{ 612{
626 return single_open(file, acpi_battery_read_state, PDE(inode)->data); 613 return single_open(file, acpi_battery_read_state, PDE_DATA(inode));
627} 614}
628 615
629static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) 616static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
@@ -688,7 +675,7 @@ acpi_battery_write_alarm(struct file *file, const char __user * buffer,
688 675
689static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) 676static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
690{ 677{
691 return single_open(file, acpi_battery_read_alarm, PDE(inode)->data); 678 return single_open(file, acpi_battery_read_alarm, PDE_DATA(inode));
692} 679}
693 680
694static const struct file_operations acpi_battery_info_fops = { 681static const struct file_operations acpi_battery_info_fops = {
@@ -736,7 +723,7 @@ static int acpi_ac_read_state(struct seq_file *seq, void *offset)
736 723
737static int acpi_ac_state_open_fs(struct inode *inode, struct file *file) 724static int acpi_ac_state_open_fs(struct inode *inode, struct file *file)
738{ 725{
739 return single_open(file, acpi_ac_read_state, PDE(inode)->data); 726 return single_open(file, acpi_ac_read_state, PDE_DATA(inode));
740} 727}
741 728
742static const struct file_operations acpi_ac_state_fops = { 729static const struct file_operations acpi_ac_state_fops = {
@@ -836,8 +823,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
836 power_supply_unregister(&battery->bat); 823 power_supply_unregister(&battery->bat);
837 } 824 }
838#ifdef CONFIG_ACPI_PROCFS_POWER 825#ifdef CONFIG_ACPI_PROCFS_POWER
839 if (battery->proc_entry) 826 proc_remove(battery->proc_entry);
840 acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir); 827 battery->proc_entry = NULL;
841#endif 828#endif
842} 829}
843 830
@@ -873,8 +860,8 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
873 if (sbs->charger.dev) 860 if (sbs->charger.dev)
874 power_supply_unregister(&sbs->charger); 861 power_supply_unregister(&sbs->charger);
875#ifdef CONFIG_ACPI_PROCFS_POWER 862#ifdef CONFIG_ACPI_PROCFS_POWER
876 if (sbs->charger_entry) 863 proc_remove(sbs->charger_entry);
877 acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); 864 sbs->charger_entry = NULL;
878#endif 865#endif
879} 866}
880 867
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index 08608de87e4e..dc4f70179e7d 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -322,23 +322,11 @@ static u8 k2_stat_check_status(struct ata_port *ap)
322} 322}
323 323
324#ifdef CONFIG_PPC_OF 324#ifdef CONFIG_PPC_OF
325/* 325static int k2_sata_show_info(struct seq_file *m, struct Scsi_Host *shost)
326 * k2_sata_proc_info
327 * inout : decides on the direction of the dataflow and the meaning of the
328 * variables
329 * buffer: If inout==FALSE data is being written to it else read from it
330 * *start: If inout==FALSE start of the valid data in the buffer
331 * offset: If inout==FALSE offset from the beginning of the imaginary file
332 * from which we start writing into the buffer
333 * length: If inout==FALSE max number of bytes to be written into the buffer
334 * else number of bytes in the buffer
335 */
336static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start,
337 off_t offset, int count, int inout)
338{ 326{
339 struct ata_port *ap; 327 struct ata_port *ap;
340 struct device_node *np; 328 struct device_node *np;
341 int len, index; 329 int index;
342 330
343 /* Find the ata_port */ 331 /* Find the ata_port */
344 ap = ata_shost_to_port(shost); 332 ap = ata_shost_to_port(shost);
@@ -356,15 +344,12 @@ static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start,
356 const u32 *reg = of_get_property(np, "reg", NULL); 344 const u32 *reg = of_get_property(np, "reg", NULL);
357 if (!reg) 345 if (!reg)
358 continue; 346 continue;
359 if (index == *reg) 347 if (index == *reg) {
348 seq_printf(m, "devspec: %s\n", np->full_name);
360 break; 349 break;
350 }
361 } 351 }
362 if (np == NULL) 352 return 0;
363 return 0;
364
365 len = sprintf(page, "devspec: %s\n", np->full_name);
366
367 return len;
368} 353}
369#endif /* CONFIG_PPC_OF */ 354#endif /* CONFIG_PPC_OF */
370 355
@@ -372,7 +357,7 @@ static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start,
372static struct scsi_host_template k2_sata_sht = { 357static struct scsi_host_template k2_sata_sht = {
373 ATA_BMDMA_SHT(DRV_NAME), 358 ATA_BMDMA_SHT(DRV_NAME),
374#ifdef CONFIG_PPC_OF 359#ifdef CONFIG_PPC_OF
375 .proc_info = k2_sata_proc_info, 360 .show_info = k2_sata_show_info,
376#endif 361#endif
377}; 362};
378 363
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 5b5ee79ff236..eb3950113e42 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -6473,7 +6473,7 @@ static int dac960_initial_status_proc_show(struct seq_file *m, void *v)
6473 6473
6474static int dac960_initial_status_proc_open(struct inode *inode, struct file *file) 6474static int dac960_initial_status_proc_open(struct inode *inode, struct file *file)
6475{ 6475{
6476 return single_open(file, dac960_initial_status_proc_show, PDE(inode)->data); 6476 return single_open(file, dac960_initial_status_proc_show, PDE_DATA(inode));
6477} 6477}
6478 6478
6479static const struct file_operations dac960_initial_status_proc_fops = { 6479static const struct file_operations dac960_initial_status_proc_fops = {
@@ -6519,7 +6519,7 @@ static int dac960_current_status_proc_show(struct seq_file *m, void *v)
6519 6519
6520static int dac960_current_status_proc_open(struct inode *inode, struct file *file) 6520static int dac960_current_status_proc_open(struct inode *inode, struct file *file)
6521{ 6521{
6522 return single_open(file, dac960_current_status_proc_show, PDE(inode)->data); 6522 return single_open(file, dac960_current_status_proc_show, PDE_DATA(inode));
6523} 6523}
6524 6524
6525static const struct file_operations dac960_current_status_proc_fops = { 6525static const struct file_operations dac960_current_status_proc_fops = {
@@ -6540,14 +6540,14 @@ static int dac960_user_command_proc_show(struct seq_file *m, void *v)
6540 6540
6541static int dac960_user_command_proc_open(struct inode *inode, struct file *file) 6541static int dac960_user_command_proc_open(struct inode *inode, struct file *file)
6542{ 6542{
6543 return single_open(file, dac960_user_command_proc_show, PDE(inode)->data); 6543 return single_open(file, dac960_user_command_proc_show, PDE_DATA(inode));
6544} 6544}
6545 6545
6546static ssize_t dac960_user_command_proc_write(struct file *file, 6546static ssize_t dac960_user_command_proc_write(struct file *file,
6547 const char __user *Buffer, 6547 const char __user *Buffer,
6548 size_t Count, loff_t *pos) 6548 size_t Count, loff_t *pos)
6549{ 6549{
6550 DAC960_Controller_T *Controller = (DAC960_Controller_T *) PDE(file_inode(file))->data; 6550 DAC960_Controller_T *Controller = PDE_DATA(file_inode(file));
6551 unsigned char CommandBuffer[80]; 6551 unsigned char CommandBuffer[80];
6552 int Length; 6552 int Length;
6553 if (Count > sizeof(CommandBuffer)-1) return -EINVAL; 6553 if (Count > sizeof(CommandBuffer)-1) return -EINVAL;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 1c1b8e544aa2..e18c99140c0a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -493,7 +493,7 @@ static int cciss_seq_open(struct inode *inode, struct file *file)
493 struct seq_file *seq = file->private_data; 493 struct seq_file *seq = file->private_data;
494 494
495 if (!ret) 495 if (!ret)
496 seq->private = PDE(inode)->data; 496 seq->private = PDE_DATA(inode);
497 497
498 return ret; 498 return ret;
499} 499}
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index da3311129a0c..ecd845cd28d8 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -54,13 +54,11 @@ static CommandList_struct *cmd_special_alloc(ctlr_info_t *h);
54static void cmd_free(ctlr_info_t *h, CommandList_struct *c); 54static void cmd_free(ctlr_info_t *h, CommandList_struct *c);
55static void cmd_special_free(ctlr_info_t *h, CommandList_struct *c); 55static void cmd_special_free(ctlr_info_t *h, CommandList_struct *c);
56 56
57static int cciss_scsi_proc_info( 57static int cciss_scsi_write_info(struct Scsi_Host *sh,
58 struct Scsi_Host *sh,
59 char *buffer, /* data buffer */ 58 char *buffer, /* data buffer */
60 char **start, /* where data in buffer starts */ 59 int length); /* length of data in buffer */
61 off_t offset, /* offset from start of imaginary file */ 60static int cciss_scsi_show_info(struct seq_file *m,
62 int length, /* length of data in buffer */ 61 struct Scsi_Host *sh);
63 int func); /* 0 == read, 1 == write */
64 62
65static int cciss_scsi_queue_command (struct Scsi_Host *h, 63static int cciss_scsi_queue_command (struct Scsi_Host *h,
66 struct scsi_cmnd *cmd); 64 struct scsi_cmnd *cmd);
@@ -82,7 +80,8 @@ static struct scsi_host_template cciss_driver_template = {
82 .module = THIS_MODULE, 80 .module = THIS_MODULE,
83 .name = "cciss", 81 .name = "cciss",
84 .proc_name = "cciss", 82 .proc_name = "cciss",
85 .proc_info = cciss_scsi_proc_info, 83 .write_info = cciss_scsi_write_info,
84 .show_info = cciss_scsi_show_info,
86 .queuecommand = cciss_scsi_queue_command, 85 .queuecommand = cciss_scsi_queue_command,
87 .this_id = 7, 86 .this_id = 7,
88 .cmd_per_lun = 1, 87 .cmd_per_lun = 1,
@@ -1302,59 +1301,54 @@ cciss_scsi_user_command(ctlr_info_t *h, int hostno, char *buffer, int length)
1302 return length; 1301 return length;
1303} 1302}
1304 1303
1305
1306static int 1304static int
1307cciss_scsi_proc_info(struct Scsi_Host *sh, 1305cciss_scsi_write_info(struct Scsi_Host *sh,
1308 char *buffer, /* data buffer */ 1306 char *buffer, /* data buffer */
1309 char **start, /* where data in buffer starts */ 1307 int length) /* length of data in buffer */
1310 off_t offset, /* offset from start of imaginary file */
1311 int length, /* length of data in buffer */
1312 int func) /* 0 == read, 1 == write */
1313{ 1308{
1309 ctlr_info_t *h = (ctlr_info_t *) sh->hostdata[0];
1310 if (h == NULL) /* This really shouldn't ever happen. */
1311 return -EINVAL;
1314 1312
1315 int buflen, datalen; 1313 return cciss_scsi_user_command(h, sh->host_no,
1316 ctlr_info_t *h; 1314 buffer, length);
1315}
1316
1317static int
1318cciss_scsi_show_info(struct seq_file *m, struct Scsi_Host *sh)
1319{
1320
1321 ctlr_info_t *h = (ctlr_info_t *) sh->hostdata[0];
1317 int i; 1322 int i;
1318 1323
1319 h = (ctlr_info_t *) sh->hostdata[0];
1320 if (h == NULL) /* This really shouldn't ever happen. */ 1324 if (h == NULL) /* This really shouldn't ever happen. */
1321 return -EINVAL; 1325 return -EINVAL;
1322 1326
1323 if (func == 0) { /* User is reading from /proc/scsi/ciss*?/?* */ 1327 seq_printf(m, "cciss%d: SCSI host: %d\n",
1324 buflen = sprintf(buffer, "cciss%d: SCSI host: %d\n", 1328 h->ctlr, sh->host_no);
1325 h->ctlr, sh->host_no); 1329
1326 1330 /* this information is needed by apps to know which cciss
1327 /* this information is needed by apps to know which cciss 1331 device corresponds to which scsi host number without
1328 device corresponds to which scsi host number without 1332 having to open a scsi target device node. The device
1329 having to open a scsi target device node. The device 1333 information is not a duplicate of /proc/scsi/scsi because
1330 information is not a duplicate of /proc/scsi/scsi because 1334 the two may be out of sync due to scsi hotplug, rather
1331 the two may be out of sync due to scsi hotplug, rather 1335 this info is for an app to be able to use to know how to
1332 this info is for an app to be able to use to know how to 1336 get them back in sync. */
1333 get them back in sync. */ 1337
1334 1338 for (i = 0; i < ccissscsi[h->ctlr].ndevices; i++) {
1335 for (i = 0; i < ccissscsi[h->ctlr].ndevices; i++) { 1339 struct cciss_scsi_dev_t *sd =
1336 struct cciss_scsi_dev_t *sd = 1340 &ccissscsi[h->ctlr].dev[i];
1337 &ccissscsi[h->ctlr].dev[i]; 1341 seq_printf(m, "c%db%dt%dl%d %02d "
1338 buflen += sprintf(&buffer[buflen], "c%db%dt%dl%d %02d " 1342 "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
1339 "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", 1343 sh->host_no, sd->bus, sd->target, sd->lun,
1340 sh->host_no, sd->bus, sd->target, sd->lun, 1344 sd->devtype,
1341 sd->devtype, 1345 sd->scsi3addr[0], sd->scsi3addr[1],
1342 sd->scsi3addr[0], sd->scsi3addr[1], 1346 sd->scsi3addr[2], sd->scsi3addr[3],
1343 sd->scsi3addr[2], sd->scsi3addr[3], 1347 sd->scsi3addr[4], sd->scsi3addr[5],
1344 sd->scsi3addr[4], sd->scsi3addr[5], 1348 sd->scsi3addr[6], sd->scsi3addr[7]);
1345 sd->scsi3addr[6], sd->scsi3addr[7]); 1349 }
1346 } 1350 return 0;
1347 datalen = buflen - offset; 1351}
1348 if (datalen < 0) { /* they're reading past EOF. */
1349 datalen = 0;
1350 *start = buffer+buflen;
1351 } else
1352 *start = buffer + offset;
1353 return(datalen);
1354 } else /* User is writing to /proc/scsi/cciss*?/?* ... */
1355 return cciss_scsi_user_command(h, sh->host_no,
1356 buffer, length);
1357}
1358 1352
1359/* cciss_scatter_gather takes a struct scsi_cmnd, (cmd), and does the pci 1353/* cciss_scatter_gather takes a struct scsi_cmnd, (cmd), and does the pci
1360 dma mapping and fills in the scatter gather entries of the 1354 dma mapping and fills in the scatter gather entries of the
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 3f087133a25a..3b9e8ebcb96b 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -296,7 +296,7 @@ static int ida_proc_show(struct seq_file *m, void *v)
296 296
297static int ida_proc_open(struct inode *inode, struct file *file) 297static int ida_proc_open(struct inode *inode, struct file *file)
298{ 298{
299 return single_open(file, ida_proc_show, PDE(inode)->data); 299 return single_open(file, ida_proc_show, PDE_DATA(inode));
300} 300}
301 301
302static const struct file_operations ida_proc_fops = { 302static const struct file_operations ida_proc_fops = {
diff --git a/drivers/block/drbd/drbd_proc.c b/drivers/block/drbd/drbd_proc.c
index 56672a61eb94..928adb815b09 100644
--- a/drivers/block/drbd/drbd_proc.c
+++ b/drivers/block/drbd/drbd_proc.c
@@ -314,7 +314,7 @@ static int drbd_seq_show(struct seq_file *seq, void *v)
314static int drbd_proc_open(struct inode *inode, struct file *file) 314static int drbd_proc_open(struct inode *inode, struct file *file)
315{ 315{
316 if (try_module_get(THIS_MODULE)) 316 if (try_module_get(THIS_MODULE))
317 return single_open(file, drbd_seq_show, PDE(inode)->data); 317 return single_open(file, drbd_seq_show, PDE_DATA(inode));
318 return -ENODEV; 318 return -ENODEV;
319} 319}
320 320
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index dfe758382eaf..b2955b3f2cbc 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -230,9 +230,11 @@ static int __do_lo_send_write(struct file *file,
230 ssize_t bw; 230 ssize_t bw;
231 mm_segment_t old_fs = get_fs(); 231 mm_segment_t old_fs = get_fs();
232 232
233 file_start_write(file);
233 set_fs(get_ds()); 234 set_fs(get_ds());
234 bw = file->f_op->write(file, buf, len, &pos); 235 bw = file->f_op->write(file, buf, len, &pos);
235 set_fs(old_fs); 236 set_fs(old_fs);
237 file_end_write(file);
236 if (likely(bw == len)) 238 if (likely(bw == len))
237 return 0; 239 return 0;
238 printk(KERN_ERR "loop: Write error at byte offset %llu, length %i.\n", 240 printk(KERN_ERR "loop: Write error at byte offset %llu, length %i.\n",
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 2e7de7a59bfc..e0588c6dd86f 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2648,7 +2648,7 @@ static int pkt_seq_show(struct seq_file *m, void *p)
2648 2648
2649static int pkt_seq_open(struct inode *inode, struct file *file) 2649static int pkt_seq_open(struct inode *inode, struct file *file)
2650{ 2650{
2651 return single_open(file, pkt_seq_show, PDE(inode)->data); 2651 return single_open(file, pkt_seq_show, PDE_DATA(inode));
2652} 2652}
2653 2653
2654static const struct file_operations pkt_proc_fops = { 2654static const struct file_operations pkt_proc_fops = {
diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
index 75e112d66006..06a2e53e5f37 100644
--- a/drivers/block/ps3vram.c
+++ b/drivers/block/ps3vram.c
@@ -525,7 +525,7 @@ static int ps3vram_proc_show(struct seq_file *m, void *v)
525 525
526static int ps3vram_proc_open(struct inode *inode, struct file *file) 526static int ps3vram_proc_open(struct inode *inode, struct file *file)
527{ 527{
528 return single_open(file, ps3vram_proc_show, PDE(inode)->data); 528 return single_open(file, ps3vram_proc_show, PDE_DATA(inode));
529} 529}
530 530
531static const struct file_operations ps3vram_proc_fops = { 531static const struct file_operations ps3vram_proc_fops = {
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c
index 24ffd8cec51e..544b4ce617f8 100644
--- a/drivers/char/ds1620.c
+++ b/drivers/char/ds1620.c
@@ -6,6 +6,7 @@
6#include <linux/miscdevice.h> 6#include <linux/miscdevice.h>
7#include <linux/delay.h> 7#include <linux/delay.h>
8#include <linux/proc_fs.h> 8#include <linux/proc_fs.h>
9#include <linux/seq_file.h>
9#include <linux/capability.h> 10#include <linux/capability.h>
10#include <linux/init.h> 11#include <linux/init.h>
11#include <linux/mutex.h> 12#include <linux/mutex.h>
@@ -329,9 +330,7 @@ ds1620_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
329} 330}
330 331
331#ifdef THERM_USE_PROC 332#ifdef THERM_USE_PROC
332static int 333static int ds1620_proc_therm_show(struct seq_file *m, void *v)
333proc_therm_ds1620_read(char *buf, char **start, off_t offset,
334 int len, int *eof, void *unused)
335{ 334{
336 struct therm th; 335 struct therm th;
337 int temp; 336 int temp;
@@ -339,17 +338,25 @@ proc_therm_ds1620_read(char *buf, char **start, off_t offset,
339 ds1620_read_state(&th); 338 ds1620_read_state(&th);
340 temp = cvt_9_to_int(ds1620_in(THERM_READ_TEMP, 9)); 339 temp = cvt_9_to_int(ds1620_in(THERM_READ_TEMP, 9));
341 340
342 len = sprintf(buf, "Thermostat: HI %i.%i, LOW %i.%i; " 341 seq_printf(m, "Thermostat: HI %i.%i, LOW %i.%i; temperature: %i.%i C, fan %s\n",
343 "temperature: %i.%i C, fan %s\n", 342 th.hi >> 1, th.hi & 1 ? 5 : 0,
344 th.hi >> 1, th.hi & 1 ? 5 : 0, 343 th.lo >> 1, th.lo & 1 ? 5 : 0,
345 th.lo >> 1, th.lo & 1 ? 5 : 0, 344 temp >> 1, temp & 1 ? 5 : 0,
346 temp >> 1, temp & 1 ? 5 : 0, 345 fan_state[netwinder_get_fan()]);
347 fan_state[netwinder_get_fan()]); 346 return 0;
347}
348 348
349 return len; 349static int ds1620_proc_therm_open(struct inode *inode, struct file *file)
350{
351 return single_open(file, ds1620_proc_therm_show, NULL);
350} 352}
351 353
352static struct proc_dir_entry *proc_therm_ds1620; 354static const struct file_operations ds1620_proc_therm_fops = {
355 .open = ds1620_proc_therm_open,
356 .read = seq_read,
357 .llseek = seq_lseek,
358 .release = seq_release,
359};
353#endif 360#endif
354 361
355static const struct file_operations ds1620_fops = { 362static const struct file_operations ds1620_fops = {
@@ -397,10 +404,7 @@ static int __init ds1620_init(void)
397 return ret; 404 return ret;
398 405
399#ifdef THERM_USE_PROC 406#ifdef THERM_USE_PROC
400 proc_therm_ds1620 = create_proc_entry("therm", 0, NULL); 407 if (!proc_create("therm", 0, NULL, &ds1620_proc_therm_fops))
401 if (proc_therm_ds1620)
402 proc_therm_ds1620->read_proc = proc_therm_ds1620_read;
403 else
404 printk(KERN_ERR "therm: unable to register /proc/therm\n"); 408 printk(KERN_ERR "therm: unable to register /proc/therm\n");
405#endif 409#endif
406 410
diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c
index a082d00b0f11..ea54a6e3f5ad 100644
--- a/drivers/char/efirtc.c
+++ b/drivers/char/efirtc.c
@@ -34,6 +34,7 @@
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/rtc.h> 35#include <linux/rtc.h>
36#include <linux/proc_fs.h> 36#include <linux/proc_fs.h>
37#include <linux/seq_file.h>
37#include <linux/efi.h> 38#include <linux/efi.h>
38#include <linux/uaccess.h> 39#include <linux/uaccess.h>
39 40
@@ -296,12 +297,10 @@ static struct miscdevice efi_rtc_dev= {
296/* 297/*
297 * We export RAW EFI information to /proc/driver/efirtc 298 * We export RAW EFI information to /proc/driver/efirtc
298 */ 299 */
299static int 300static int efi_rtc_proc_show(struct seq_file *m, void *v)
300efi_rtc_get_status(char *buf)
301{ 301{
302 efi_time_t eft, alm; 302 efi_time_t eft, alm;
303 efi_time_cap_t cap; 303 efi_time_cap_t cap;
304 char *p = buf;
305 efi_bool_t enabled, pending; 304 efi_bool_t enabled, pending;
306 unsigned long flags; 305 unsigned long flags;
307 306
@@ -316,64 +315,63 @@ efi_rtc_get_status(char *buf)
316 315
317 spin_unlock_irqrestore(&efi_rtc_lock,flags); 316 spin_unlock_irqrestore(&efi_rtc_lock,flags);
318 317
319 p += sprintf(p, 318 seq_printf(m,
320 "Time : %u:%u:%u.%09u\n" 319 "Time : %u:%u:%u.%09u\n"
321 "Date : %u-%u-%u\n" 320 "Date : %u-%u-%u\n"
322 "Daylight : %u\n", 321 "Daylight : %u\n",
323 eft.hour, eft.minute, eft.second, eft.nanosecond, 322 eft.hour, eft.minute, eft.second, eft.nanosecond,
324 eft.year, eft.month, eft.day, 323 eft.year, eft.month, eft.day,
325 eft.daylight); 324 eft.daylight);
326 325
327 if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) 326 if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
328 p += sprintf(p, "Timezone : unspecified\n"); 327 seq_puts(m, "Timezone : unspecified\n");
329 else 328 else
330 /* XXX fixme: convert to string? */ 329 /* XXX fixme: convert to string? */
331 p += sprintf(p, "Timezone : %u\n", eft.timezone); 330 seq_printf(m, "Timezone : %u\n", eft.timezone);
332 331
333 332
334 p += sprintf(p, 333 seq_printf(m,
335 "Alarm Time : %u:%u:%u.%09u\n" 334 "Alarm Time : %u:%u:%u.%09u\n"
336 "Alarm Date : %u-%u-%u\n" 335 "Alarm Date : %u-%u-%u\n"
337 "Alarm Daylight : %u\n" 336 "Alarm Daylight : %u\n"
338 "Enabled : %s\n" 337 "Enabled : %s\n"
339 "Pending : %s\n", 338 "Pending : %s\n",
340 alm.hour, alm.minute, alm.second, alm.nanosecond, 339 alm.hour, alm.minute, alm.second, alm.nanosecond,
341 alm.year, alm.month, alm.day, 340 alm.year, alm.month, alm.day,
342 alm.daylight, 341 alm.daylight,
343 enabled == 1 ? "yes" : "no", 342 enabled == 1 ? "yes" : "no",
344 pending == 1 ? "yes" : "no"); 343 pending == 1 ? "yes" : "no");
345 344
346 if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) 345 if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
347 p += sprintf(p, "Timezone : unspecified\n"); 346 seq_puts(m, "Timezone : unspecified\n");
348 else 347 else
349 /* XXX fixme: convert to string? */ 348 /* XXX fixme: convert to string? */
350 p += sprintf(p, "Timezone : %u\n", alm.timezone); 349 seq_printf(m, "Timezone : %u\n", alm.timezone);
351 350
352 /* 351 /*
353 * now prints the capabilities 352 * now prints the capabilities
354 */ 353 */
355 p += sprintf(p, 354 seq_printf(m,
356 "Resolution : %u\n" 355 "Resolution : %u\n"
357 "Accuracy : %u\n" 356 "Accuracy : %u\n"
358 "SetstoZero : %u\n", 357 "SetstoZero : %u\n",
359 cap.resolution, cap.accuracy, cap.sets_to_zero); 358 cap.resolution, cap.accuracy, cap.sets_to_zero);
360 359
361 return p - buf; 360 return 0;
362} 361}
363 362
364static int 363static int efi_rtc_proc_open(struct inode *inode, struct file *file)
365efi_rtc_read_proc(char *page, char **start, off_t off,
366 int count, int *eof, void *data)
367{ 364{
368 int len = efi_rtc_get_status(page); 365 return single_open(file, efi_rtc_proc_show, NULL);
369 if (len <= off+count) *eof = 1;
370 *start = page + off;
371 len -= off;
372 if (len>count) len = count;
373 if (len<0) len = 0;
374 return len;
375} 366}
376 367
368static const struct file_operations efi_rtc_proc_fops = {
369 .open = efi_rtc_proc_open,
370 .read = seq_read,
371 .llseek = seq_lseek,
372 .release = seq_release,
373};
374
377static int __init 375static int __init
378efi_rtc_init(void) 376efi_rtc_init(void)
379{ 377{
@@ -389,8 +387,7 @@ efi_rtc_init(void)
389 return ret; 387 return ret;
390 } 388 }
391 389
392 dir = create_proc_read_entry ("driver/efirtc", 0, NULL, 390 dir = proc_create("driver/efirtc", 0, NULL, &efi_rtc_proc_fops);
393 efi_rtc_read_proc, NULL);
394 if (dir == NULL) { 391 if (dir == NULL) {
395 printk(KERN_ERR "efirtc: can't create /proc/driver/efirtc.\n"); 392 printk(KERN_ERR "efirtc: can't create /proc/driver/efirtc.\n");
396 misc_deregister(&efi_rtc_dev); 393 misc_deregister(&efi_rtc_dev);
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index 21cb980f1157..bc9b84d56ee4 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -52,6 +52,7 @@
52#include <linux/init.h> 52#include <linux/init.h>
53#include <linux/poll.h> 53#include <linux/poll.h>
54#include <linux/proc_fs.h> 54#include <linux/proc_fs.h>
55#include <linux/seq_file.h>
55#include <linux/mutex.h> 56#include <linux/mutex.h>
56#include <linux/workqueue.h> 57#include <linux/workqueue.h>
57 58
@@ -386,18 +387,15 @@ static int gen_rtc_release(struct inode *inode, struct file *file)
386 * Info exported via "/proc/driver/rtc". 387 * Info exported via "/proc/driver/rtc".
387 */ 388 */
388 389
389static int gen_rtc_proc_output(char *buf) 390static int gen_rtc_proc_show(struct seq_file *m, void *v)
390{ 391{
391 char *p;
392 struct rtc_time tm; 392 struct rtc_time tm;
393 unsigned int flags; 393 unsigned int flags;
394 struct rtc_pll_info pll; 394 struct rtc_pll_info pll;
395 395
396 p = buf;
397
398 flags = get_rtc_time(&tm); 396 flags = get_rtc_time(&tm);
399 397
400 p += sprintf(p, 398 seq_printf(m,
401 "rtc_time\t: %02d:%02d:%02d\n" 399 "rtc_time\t: %02d:%02d:%02d\n"
402 "rtc_date\t: %04d-%02d-%02d\n" 400 "rtc_date\t: %04d-%02d-%02d\n"
403 "rtc_epoch\t: %04u\n", 401 "rtc_epoch\t: %04u\n",
@@ -406,23 +404,23 @@ static int gen_rtc_proc_output(char *buf)
406 404
407 tm.tm_hour = tm.tm_min = tm.tm_sec = 0; 405 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
408 406
409 p += sprintf(p, "alarm\t\t: "); 407 seq_puts(m, "alarm\t\t: ");
410 if (tm.tm_hour <= 24) 408 if (tm.tm_hour <= 24)
411 p += sprintf(p, "%02d:", tm.tm_hour); 409 seq_printf(m, "%02d:", tm.tm_hour);
412 else 410 else
413 p += sprintf(p, "**:"); 411 seq_puts(m, "**:");
414 412
415 if (tm.tm_min <= 59) 413 if (tm.tm_min <= 59)
416 p += sprintf(p, "%02d:", tm.tm_min); 414 seq_printf(m, "%02d:", tm.tm_min);
417 else 415 else
418 p += sprintf(p, "**:"); 416 seq_puts(m, "**:");
419 417
420 if (tm.tm_sec <= 59) 418 if (tm.tm_sec <= 59)
421 p += sprintf(p, "%02d\n", tm.tm_sec); 419 seq_printf(m, "%02d\n", tm.tm_sec);
422 else 420 else
423 p += sprintf(p, "**\n"); 421 seq_puts(m, "**\n");
424 422
425 p += sprintf(p, 423 seq_printf(m,
426 "DST_enable\t: %s\n" 424 "DST_enable\t: %s\n"
427 "BCD\t\t: %s\n" 425 "BCD\t\t: %s\n"
428 "24hr\t\t: %s\n" 426 "24hr\t\t: %s\n"
@@ -442,7 +440,7 @@ static int gen_rtc_proc_output(char *buf)
442 0L /* freq */, 440 0L /* freq */,
443 (flags & RTC_BATT_BAD) ? "bad" : "okay"); 441 (flags & RTC_BATT_BAD) ? "bad" : "okay");
444 if (!get_rtc_pll(&pll)) 442 if (!get_rtc_pll(&pll))
445 p += sprintf(p, 443 seq_printf(m,
446 "PLL adjustment\t: %d\n" 444 "PLL adjustment\t: %d\n"
447 "PLL max +ve adjustment\t: %d\n" 445 "PLL max +ve adjustment\t: %d\n"
448 "PLL max -ve adjustment\t: %d\n" 446 "PLL max -ve adjustment\t: %d\n"
@@ -455,26 +453,26 @@ static int gen_rtc_proc_output(char *buf)
455 pll.pll_posmult, 453 pll.pll_posmult,
456 pll.pll_negmult, 454 pll.pll_negmult,
457 pll.pll_clock); 455 pll.pll_clock);
458 return p - buf; 456 return 0;
459} 457}
460 458
461static int gen_rtc_read_proc(char *page, char **start, off_t off, 459static int gen_rtc_proc_open(struct inode *inode, struct file *file)
462 int count, int *eof, void *data)
463{ 460{
464 int len = gen_rtc_proc_output (page); 461 return single_open(file, gen_rtc_proc_show, NULL);
465 if (len <= off+count) *eof = 1;
466 *start = page + off;
467 len -= off;
468 if (len>count) len = count;
469 if (len<0) len = 0;
470 return len;
471} 462}
472 463
464static const struct file_operations gen_rtc_proc_fops = {
465 .open = gen_rtc_proc_open,
466 .read = seq_read,
467 .llseek = seq_lseek,
468 .release = seq_release,
469};
470
473static int __init gen_rtc_proc_init(void) 471static int __init gen_rtc_proc_init(void)
474{ 472{
475 struct proc_dir_entry *r; 473 struct proc_dir_entry *r;
476 474
477 r = create_proc_read_entry("driver/rtc", 0, NULL, gen_rtc_read_proc, NULL); 475 r = proc_create("driver/rtc", 0, NULL, &gen_rtc_proc_fops);
478 if (!r) 476 if (!r)
479 return -ENOMEM; 477 return -ENOMEM;
480 return 0; 478 return 0;
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 053201b062a4..4d439d2fcfd6 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -1917,7 +1917,7 @@ static int smi_ipmb_proc_show(struct seq_file *m, void *v)
1917 1917
1918static int smi_ipmb_proc_open(struct inode *inode, struct file *file) 1918static int smi_ipmb_proc_open(struct inode *inode, struct file *file)
1919{ 1919{
1920 return single_open(file, smi_ipmb_proc_show, PDE(inode)->data); 1920 return single_open(file, smi_ipmb_proc_show, PDE_DATA(inode));
1921} 1921}
1922 1922
1923static const struct file_operations smi_ipmb_proc_ops = { 1923static const struct file_operations smi_ipmb_proc_ops = {
@@ -1938,7 +1938,7 @@ static int smi_version_proc_show(struct seq_file *m, void *v)
1938 1938
1939static int smi_version_proc_open(struct inode *inode, struct file *file) 1939static int smi_version_proc_open(struct inode *inode, struct file *file)
1940{ 1940{
1941 return single_open(file, smi_version_proc_show, PDE(inode)->data); 1941 return single_open(file, smi_version_proc_show, PDE_DATA(inode));
1942} 1942}
1943 1943
1944static const struct file_operations smi_version_proc_ops = { 1944static const struct file_operations smi_version_proc_ops = {
@@ -2013,7 +2013,7 @@ static int smi_stats_proc_show(struct seq_file *m, void *v)
2013 2013
2014static int smi_stats_proc_open(struct inode *inode, struct file *file) 2014static int smi_stats_proc_open(struct inode *inode, struct file *file)
2015{ 2015{
2016 return single_open(file, smi_stats_proc_show, PDE(inode)->data); 2016 return single_open(file, smi_stats_proc_show, PDE_DATA(inode));
2017} 2017}
2018 2018
2019static const struct file_operations smi_stats_proc_ops = { 2019static const struct file_operations smi_stats_proc_ops = {
@@ -4541,7 +4541,7 @@ static void __exit cleanup_ipmi(void)
4541 del_timer_sync(&ipmi_timer); 4541 del_timer_sync(&ipmi_timer);
4542 4542
4543#ifdef CONFIG_PROC_FS 4543#ifdef CONFIG_PROC_FS
4544 remove_proc_entry(proc_ipmi_root->name, NULL); 4544 proc_remove(proc_ipmi_root);
4545#endif /* CONFIG_PROC_FS */ 4545#endif /* CONFIG_PROC_FS */
4546 4546
4547 driver_unregister(&ipmidriver.driver); 4547 driver_unregister(&ipmidriver.driver);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 0ac9b45a585e..313538abe63c 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2839,7 +2839,7 @@ static int smi_type_proc_show(struct seq_file *m, void *v)
2839 2839
2840static int smi_type_proc_open(struct inode *inode, struct file *file) 2840static int smi_type_proc_open(struct inode *inode, struct file *file)
2841{ 2841{
2842 return single_open(file, smi_type_proc_show, PDE(inode)->data); 2842 return single_open(file, smi_type_proc_show, PDE_DATA(inode));
2843} 2843}
2844 2844
2845static const struct file_operations smi_type_proc_ops = { 2845static const struct file_operations smi_type_proc_ops = {
@@ -2882,7 +2882,7 @@ static int smi_si_stats_proc_show(struct seq_file *m, void *v)
2882 2882
2883static int smi_si_stats_proc_open(struct inode *inode, struct file *file) 2883static int smi_si_stats_proc_open(struct inode *inode, struct file *file)
2884{ 2884{
2885 return single_open(file, smi_si_stats_proc_show, PDE(inode)->data); 2885 return single_open(file, smi_si_stats_proc_show, PDE_DATA(inode));
2886} 2886}
2887 2887
2888static const struct file_operations smi_si_stats_proc_ops = { 2888static const struct file_operations smi_si_stats_proc_ops = {
@@ -2910,7 +2910,7 @@ static int smi_params_proc_show(struct seq_file *m, void *v)
2910 2910
2911static int smi_params_proc_open(struct inode *inode, struct file *file) 2911static int smi_params_proc_open(struct inode *inode, struct file *file)
2912{ 2912{
2913 return single_open(file, smi_params_proc_show, PDE(inode)->data); 2913 return single_open(file, smi_params_proc_show, PDE_DATA(inode));
2914} 2914}
2915 2915
2916static const struct file_operations smi_params_proc_ops = { 2916static const struct file_operations smi_params_proc_ops = {
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index 67615d6d038d..202d2c85ba2e 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -1,6 +1,7 @@
1#include <linux/efi.h> 1#include <linux/efi.h>
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/pstore.h> 3#include <linux/pstore.h>
4#include <linux/slab.h>
4#include <linux/ucs2_string.h> 5#include <linux/ucs2_string.h>
5 6
6#define DUMP_NAME_LEN 52 7#define DUMP_NAME_LEN 52
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
index 5e94897244cf..b623c599e572 100644
--- a/drivers/firmware/efi/efivars.c
+++ b/drivers/firmware/efi/efivars.c
@@ -67,6 +67,7 @@
67 67
68#include <linux/efi.h> 68#include <linux/efi.h>
69#include <linux/module.h> 69#include <linux/module.h>
70#include <linux/slab.h>
70#include <linux/ucs2_string.h> 71#include <linux/ucs2_string.h>
71 72
72#define EFIVARS_VERSION "0.08" 73#define EFIVARS_VERSION "0.08"
diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c
index ff5456b7df72..d7f2324b4fb1 100644
--- a/drivers/gpu/drm/drm_proc.c
+++ b/drivers/gpu/drm/drm_proc.c
@@ -49,7 +49,7 @@
49/** 49/**
50 * Proc file list. 50 * Proc file list.
51 */ 51 */
52static struct drm_info_list drm_proc_list[] = { 52static const struct drm_info_list drm_proc_list[] = {
53 {"name", drm_name_info, 0}, 53 {"name", drm_name_info, 0},
54 {"vm", drm_vm_info, 0}, 54 {"vm", drm_vm_info, 0},
55 {"clients", drm_clients_info, 0}, 55 {"clients", drm_clients_info, 0},
@@ -63,7 +63,7 @@ static struct drm_info_list drm_proc_list[] = {
63 63
64static int drm_proc_open(struct inode *inode, struct file *file) 64static int drm_proc_open(struct inode *inode, struct file *file)
65{ 65{
66 struct drm_info_node* node = PDE(inode)->data; 66 struct drm_info_node* node = PDE_DATA(inode);
67 67
68 return single_open(file, node->info_ent->show, node); 68 return single_open(file, node->info_ent->show, node);
69} 69}
@@ -89,13 +89,13 @@ static const struct file_operations drm_proc_fops = {
89 * Create a given set of proc files represented by an array of 89 * Create a given set of proc files represented by an array of
90 * gdm_proc_lists in the given root directory. 90 * gdm_proc_lists in the given root directory.
91 */ 91 */
92static int drm_proc_create_files(struct drm_info_list *files, int count, 92static int drm_proc_create_files(const struct drm_info_list *files, int count,
93 struct proc_dir_entry *root, struct drm_minor *minor) 93 struct proc_dir_entry *root, struct drm_minor *minor)
94{ 94{
95 struct drm_device *dev = minor->dev; 95 struct drm_device *dev = minor->dev;
96 struct proc_dir_entry *ent; 96 struct proc_dir_entry *ent;
97 struct drm_info_node *tmp; 97 struct drm_info_node *tmp;
98 int i, ret; 98 int i;
99 99
100 for (i = 0; i < count; i++) { 100 for (i = 0; i < count; i++) {
101 u32 features = files[i].driver_features; 101 u32 features = files[i].driver_features;
@@ -105,10 +105,9 @@ static int drm_proc_create_files(struct drm_info_list *files, int count,
105 continue; 105 continue;
106 106
107 tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL); 107 tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
108 if (tmp == NULL) { 108 if (!tmp)
109 ret = -1; 109 return -1;
110 goto fail; 110
111 }
112 tmp->minor = minor; 111 tmp->minor = minor;
113 tmp->info_ent = &files[i]; 112 tmp->info_ent = &files[i];
114 list_add(&tmp->list, &minor->proc_nodes.list); 113 list_add(&tmp->list, &minor->proc_nodes.list);
@@ -116,28 +115,20 @@ static int drm_proc_create_files(struct drm_info_list *files, int count,
116 ent = proc_create_data(files[i].name, S_IRUGO, root, 115 ent = proc_create_data(files[i].name, S_IRUGO, root,
117 &drm_proc_fops, tmp); 116 &drm_proc_fops, tmp);
118 if (!ent) { 117 if (!ent) {
119 DRM_ERROR("Cannot create /proc/dri/%s/%s\n", 118 DRM_ERROR("Cannot create /proc/dri/%u/%s\n",
120 root->name, files[i].name); 119 minor->index, files[i].name);
121 list_del(&tmp->list); 120 list_del(&tmp->list);
122 kfree(tmp); 121 kfree(tmp);
123 ret = -1; 122 return -1;
124 goto fail;
125 } 123 }
126
127 } 124 }
128 return 0; 125 return 0;
129
130fail:
131 for (i = 0; i < count; i++)
132 remove_proc_entry(drm_proc_list[i].name, minor->proc_root);
133 return ret;
134} 126}
135 127
136/** 128/**
137 * Initialize the DRI proc filesystem for a device 129 * Initialize the DRI proc filesystem for a device
138 * 130 *
139 * \param dev DRM device 131 * \param dev DRM device
140 * \param minor device minor number
141 * \param root DRI proc dir entry. 132 * \param root DRI proc dir entry.
142 * \param dev_root resulting DRI device proc dir entry. 133 * \param dev_root resulting DRI device proc dir entry.
143 * \return root entry pointer on success, or NULL on failure. 134 * \return root entry pointer on success, or NULL on failure.
@@ -146,14 +137,13 @@ fail:
146 * "/proc/dri/%minor%/", and each entry in proc_list as 137 * "/proc/dri/%minor%/", and each entry in proc_list as
147 * "/proc/dri/%minor%/%name%". 138 * "/proc/dri/%minor%/%name%".
148 */ 139 */
149int drm_proc_init(struct drm_minor *minor, int minor_id, 140int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root)
150 struct proc_dir_entry *root)
151{ 141{
152 char name[64]; 142 char name[12];
153 int ret; 143 int ret;
154 144
155 INIT_LIST_HEAD(&minor->proc_nodes.list); 145 INIT_LIST_HEAD(&minor->proc_nodes.list);
156 sprintf(name, "%d", minor_id); 146 sprintf(name, "%u", minor->index);
157 minor->proc_root = proc_mkdir(name, root); 147 minor->proc_root = proc_mkdir(name, root);
158 if (!minor->proc_root) { 148 if (!minor->proc_root) {
159 DRM_ERROR("Cannot create /proc/dri/%s\n", name); 149 DRM_ERROR("Cannot create /proc/dri/%s\n", name);
@@ -163,7 +153,7 @@ int drm_proc_init(struct drm_minor *minor, int minor_id,
163 ret = drm_proc_create_files(drm_proc_list, DRM_PROC_ENTRIES, 153 ret = drm_proc_create_files(drm_proc_list, DRM_PROC_ENTRIES,
164 minor->proc_root, minor); 154 minor->proc_root, minor);
165 if (ret) { 155 if (ret) {
166 remove_proc_entry(name, root); 156 remove_proc_subtree(name, root);
167 minor->proc_root = NULL; 157 minor->proc_root = NULL;
168 DRM_ERROR("Failed to create core drm proc files\n"); 158 DRM_ERROR("Failed to create core drm proc files\n");
169 return ret; 159 return ret;
@@ -172,7 +162,7 @@ int drm_proc_init(struct drm_minor *minor, int minor_id,
172 return 0; 162 return 0;
173} 163}
174 164
175static int drm_proc_remove_files(struct drm_info_list *files, int count, 165static int drm_proc_remove_files(const struct drm_info_list *files, int count,
176 struct drm_minor *minor) 166 struct drm_minor *minor)
177{ 167{
178 struct list_head *pos, *q; 168 struct list_head *pos, *q;
@@ -213,8 +203,7 @@ int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root)
213 drm_proc_remove_files(drm_proc_list, DRM_PROC_ENTRIES, minor); 203 drm_proc_remove_files(drm_proc_list, DRM_PROC_ENTRIES, minor);
214 204
215 sprintf(name, "%d", minor->index); 205 sprintf(name, "%d", minor->index);
216 remove_proc_entry(name, root); 206 remove_proc_subtree(name, root);
217
218 return 0; 207 return 0;
219} 208}
220 209
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 7d30802a018f..16f3ec579b3b 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -352,7 +352,7 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
352 idr_replace(&drm_minors_idr, new_minor, minor_id); 352 idr_replace(&drm_minors_idr, new_minor, minor_id);
353 353
354 if (type == DRM_MINOR_LEGACY) { 354 if (type == DRM_MINOR_LEGACY) {
355 ret = drm_proc_init(new_minor, minor_id, drm_proc_root); 355 ret = drm_proc_init(new_minor, drm_proc_root);
356 if (ret) { 356 if (ret) {
357 DRM_ERROR("DRM: Failed to initialize /proc/dri.\n"); 357 DRM_ERROR("DRM: Failed to initialize /proc/dri.\n");
358 goto err_mem; 358 goto err_mem;
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 8126824daccb..b23113926388 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1408,7 +1408,7 @@ static int idecd_capacity_proc_show(struct seq_file *m, void *v)
1408 1408
1409static int idecd_capacity_proc_open(struct inode *inode, struct file *file) 1409static int idecd_capacity_proc_open(struct inode *inode, struct file *file)
1410{ 1410{
1411 return single_open(file, idecd_capacity_proc_show, PDE(inode)->data); 1411 return single_open(file, idecd_capacity_proc_show, PDE_DATA(inode));
1412} 1412}
1413 1413
1414static const struct file_operations idecd_capacity_proc_fops = { 1414static const struct file_operations idecd_capacity_proc_fops = {
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c
index 8b570a17bcd9..0d1fae6cba6d 100644
--- a/drivers/ide/ide-disk_proc.c
+++ b/drivers/ide/ide-disk_proc.c
@@ -53,7 +53,7 @@ static int idedisk_cache_proc_show(struct seq_file *m, void *v)
53 53
54static int idedisk_cache_proc_open(struct inode *inode, struct file *file) 54static int idedisk_cache_proc_open(struct inode *inode, struct file *file)
55{ 55{
56 return single_open(file, idedisk_cache_proc_show, PDE(inode)->data); 56 return single_open(file, idedisk_cache_proc_show, PDE_DATA(inode));
57} 57}
58 58
59static const struct file_operations idedisk_cache_proc_fops = { 59static const struct file_operations idedisk_cache_proc_fops = {
@@ -74,7 +74,7 @@ static int idedisk_capacity_proc_show(struct seq_file *m, void *v)
74 74
75static int idedisk_capacity_proc_open(struct inode *inode, struct file *file) 75static int idedisk_capacity_proc_open(struct inode *inode, struct file *file)
76{ 76{
77 return single_open(file, idedisk_capacity_proc_show, PDE(inode)->data); 77 return single_open(file, idedisk_capacity_proc_show, PDE_DATA(inode));
78} 78}
79 79
80static const struct file_operations idedisk_capacity_proc_fops = { 80static const struct file_operations idedisk_capacity_proc_fops = {
@@ -115,7 +115,7 @@ static int idedisk_sv_proc_show(struct seq_file *m, void *v)
115 115
116static int idedisk_sv_proc_open(struct inode *inode, struct file *file) 116static int idedisk_sv_proc_open(struct inode *inode, struct file *file)
117{ 117{
118 return single_open(file, idedisk_sv_proc_show, PDE(inode)->data); 118 return single_open(file, idedisk_sv_proc_show, PDE_DATA(inode));
119} 119}
120 120
121static const struct file_operations idedisk_sv_proc_fops = { 121static const struct file_operations idedisk_sv_proc_fops = {
@@ -133,7 +133,7 @@ static int idedisk_st_proc_show(struct seq_file *m, void *v)
133 133
134static int idedisk_st_proc_open(struct inode *inode, struct file *file) 134static int idedisk_st_proc_open(struct inode *inode, struct file *file)
135{ 135{
136 return single_open(file, idedisk_st_proc_show, PDE(inode)->data); 136 return single_open(file, idedisk_st_proc_show, PDE_DATA(inode));
137} 137}
138 138
139static const struct file_operations idedisk_st_proc_fops = { 139static const struct file_operations idedisk_st_proc_fops = {
diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c
index 1600720f3e86..e7a25ea757df 100644
--- a/drivers/ide/ide-floppy_proc.c
+++ b/drivers/ide/ide-floppy_proc.c
@@ -15,7 +15,7 @@ static int idefloppy_capacity_proc_show(struct seq_file *m, void *v)
15 15
16static int idefloppy_capacity_proc_open(struct inode *inode, struct file *file) 16static int idefloppy_capacity_proc_open(struct inode *inode, struct file *file)
17{ 17{
18 return single_open(file, idefloppy_capacity_proc_show, PDE(inode)->data); 18 return single_open(file, idefloppy_capacity_proc_show, PDE_DATA(inode));
19} 19}
20 20
21static const struct file_operations idefloppy_capacity_proc_fops = { 21static const struct file_operations idefloppy_capacity_proc_fops = {
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 2abcc4790f12..97c070077774 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -58,7 +58,7 @@ static int ide_imodel_proc_show(struct seq_file *m, void *v)
58 58
59static int ide_imodel_proc_open(struct inode *inode, struct file *file) 59static int ide_imodel_proc_open(struct inode *inode, struct file *file)
60{ 60{
61 return single_open(file, ide_imodel_proc_show, PDE(inode)->data); 61 return single_open(file, ide_imodel_proc_show, PDE_DATA(inode));
62} 62}
63 63
64static const struct file_operations ide_imodel_proc_fops = { 64static const struct file_operations ide_imodel_proc_fops = {
@@ -82,7 +82,7 @@ static int ide_mate_proc_show(struct seq_file *m, void *v)
82 82
83static int ide_mate_proc_open(struct inode *inode, struct file *file) 83static int ide_mate_proc_open(struct inode *inode, struct file *file)
84{ 84{
85 return single_open(file, ide_mate_proc_show, PDE(inode)->data); 85 return single_open(file, ide_mate_proc_show, PDE_DATA(inode));
86} 86}
87 87
88static const struct file_operations ide_mate_proc_fops = { 88static const struct file_operations ide_mate_proc_fops = {
@@ -103,7 +103,7 @@ static int ide_channel_proc_show(struct seq_file *m, void *v)
103 103
104static int ide_channel_proc_open(struct inode *inode, struct file *file) 104static int ide_channel_proc_open(struct inode *inode, struct file *file)
105{ 105{
106 return single_open(file, ide_channel_proc_show, PDE(inode)->data); 106 return single_open(file, ide_channel_proc_show, PDE_DATA(inode));
107} 107}
108 108
109static const struct file_operations ide_channel_proc_fops = { 109static const struct file_operations ide_channel_proc_fops = {
@@ -143,7 +143,7 @@ static int ide_identify_proc_show(struct seq_file *m, void *v)
143 143
144static int ide_identify_proc_open(struct inode *inode, struct file *file) 144static int ide_identify_proc_open(struct inode *inode, struct file *file)
145{ 145{
146 return single_open(file, ide_identify_proc_show, PDE(inode)->data); 146 return single_open(file, ide_identify_proc_show, PDE_DATA(inode));
147} 147}
148 148
149static const struct file_operations ide_identify_proc_fops = { 149static const struct file_operations ide_identify_proc_fops = {
@@ -325,7 +325,7 @@ static int ide_settings_proc_show(struct seq_file *m, void *v)
325 325
326static int ide_settings_proc_open(struct inode *inode, struct file *file) 326static int ide_settings_proc_open(struct inode *inode, struct file *file)
327{ 327{
328 return single_open(file, ide_settings_proc_show, PDE(inode)->data); 328 return single_open(file, ide_settings_proc_show, PDE_DATA(inode));
329} 329}
330 330
331#define MAX_LEN 30 331#define MAX_LEN 30
@@ -333,7 +333,7 @@ static int ide_settings_proc_open(struct inode *inode, struct file *file)
333static ssize_t ide_settings_proc_write(struct file *file, const char __user *buffer, 333static ssize_t ide_settings_proc_write(struct file *file, const char __user *buffer,
334 size_t count, loff_t *pos) 334 size_t count, loff_t *pos)
335{ 335{
336 ide_drive_t *drive = (ide_drive_t *) PDE(file_inode(file))->data; 336 ide_drive_t *drive = PDE_DATA(file_inode(file));
337 char name[MAX_LEN + 1]; 337 char name[MAX_LEN + 1];
338 int for_real = 0, mul_factor, div_factor; 338 int for_real = 0, mul_factor, div_factor;
339 unsigned long n; 339 unsigned long n;
@@ -474,7 +474,7 @@ static int ide_geometry_proc_show(struct seq_file *m, void *v)
474 474
475static int ide_geometry_proc_open(struct inode *inode, struct file *file) 475static int ide_geometry_proc_open(struct inode *inode, struct file *file)
476{ 476{
477 return single_open(file, ide_geometry_proc_show, PDE(inode)->data); 477 return single_open(file, ide_geometry_proc_show, PDE_DATA(inode));
478} 478}
479 479
480const struct file_operations ide_geometry_proc_fops = { 480const struct file_operations ide_geometry_proc_fops = {
@@ -497,7 +497,7 @@ static int ide_dmodel_proc_show(struct seq_file *seq, void *v)
497 497
498static int ide_dmodel_proc_open(struct inode *inode, struct file *file) 498static int ide_dmodel_proc_open(struct inode *inode, struct file *file)
499{ 499{
500 return single_open(file, ide_dmodel_proc_show, PDE(inode)->data); 500 return single_open(file, ide_dmodel_proc_show, PDE_DATA(inode));
501} 501}
502 502
503static const struct file_operations ide_dmodel_proc_fops = { 503static const struct file_operations ide_dmodel_proc_fops = {
@@ -525,7 +525,7 @@ static int ide_driver_proc_show(struct seq_file *m, void *v)
525 525
526static int ide_driver_proc_open(struct inode *inode, struct file *file) 526static int ide_driver_proc_open(struct inode *inode, struct file *file)
527{ 527{
528 return single_open(file, ide_driver_proc_show, PDE(inode)->data); 528 return single_open(file, ide_driver_proc_show, PDE_DATA(inode));
529} 529}
530 530
531static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) 531static int ide_replace_subdriver(ide_drive_t *drive, const char *driver)
@@ -558,7 +558,7 @@ static int ide_replace_subdriver(ide_drive_t *drive, const char *driver)
558static ssize_t ide_driver_proc_write(struct file *file, const char __user *buffer, 558static ssize_t ide_driver_proc_write(struct file *file, const char __user *buffer,
559 size_t count, loff_t *pos) 559 size_t count, loff_t *pos)
560{ 560{
561 ide_drive_t *drive = (ide_drive_t *) PDE(file_inode(file))->data; 561 ide_drive_t *drive = PDE_DATA(file_inode(file));
562 char name[32]; 562 char name[32];
563 563
564 if (!capable(CAP_SYS_ADMIN)) 564 if (!capable(CAP_SYS_ADMIN))
@@ -601,7 +601,7 @@ static int ide_media_proc_show(struct seq_file *m, void *v)
601 601
602static int ide_media_proc_open(struct inode *inode, struct file *file) 602static int ide_media_proc_open(struct inode *inode, struct file *file)
603{ 603{
604 return single_open(file, ide_media_proc_show, PDE(inode)->data); 604 return single_open(file, ide_media_proc_show, PDE_DATA(inode));
605} 605}
606 606
607static const struct file_operations ide_media_proc_fops = { 607static const struct file_operations ide_media_proc_fops = {
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index ce8237d36159..89f859591bbb 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1847,7 +1847,7 @@ static int idetape_name_proc_show(struct seq_file *m, void *v)
1847 1847
1848static int idetape_name_proc_open(struct inode *inode, struct file *file) 1848static int idetape_name_proc_open(struct inode *inode, struct file *file)
1849{ 1849{
1850 return single_open(file, idetape_name_proc_show, PDE(inode)->data); 1850 return single_open(file, idetape_name_proc_show, PDE_DATA(inode));
1851} 1851}
1852 1852
1853static const struct file_operations idetape_name_proc_fops = { 1853static const struct file_operations idetape_name_proc_fops = {
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index 2e3334b8f82d..770479df8657 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -41,6 +41,7 @@
41#include <linux/time.h> 41#include <linux/time.h>
42#include <linux/miscdevice.h> 42#include <linux/miscdevice.h>
43#include <linux/proc_fs.h> 43#include <linux/proc_fs.h>
44#include <linux/seq_file.h>
44#include <linux/poll.h> 45#include <linux/poll.h>
45#include <linux/rtc.h> 46#include <linux/rtc.h>
46#include <linux/mutex.h> 47#include <linux/mutex.h>
@@ -74,9 +75,6 @@ static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait);
74static int hp_sdc_rtc_open(struct inode *inode, struct file *file); 75static int hp_sdc_rtc_open(struct inode *inode, struct file *file);
75static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on); 76static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on);
76 77
77static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off,
78 int count, int *eof, void *data);
79
80static void hp_sdc_rtc_isr (int irq, void *dev_id, 78static void hp_sdc_rtc_isr (int irq, void *dev_id,
81 uint8_t status, uint8_t data) 79 uint8_t status, uint8_t data)
82{ 80{
@@ -427,22 +425,19 @@ static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on)
427 return fasync_helper (fd, filp, on, &hp_sdc_rtc_async_queue); 425 return fasync_helper (fd, filp, on, &hp_sdc_rtc_async_queue);
428} 426}
429 427
430static int hp_sdc_rtc_proc_output (char *buf) 428static int hp_sdc_rtc_proc_show(struct seq_file *m, void *v)
431{ 429{
432#define YN(bit) ("no") 430#define YN(bit) ("no")
433#define NY(bit) ("yes") 431#define NY(bit) ("yes")
434 char *p;
435 struct rtc_time tm; 432 struct rtc_time tm;
436 struct timeval tv; 433 struct timeval tv;
437 434
438 memset(&tm, 0, sizeof(struct rtc_time)); 435 memset(&tm, 0, sizeof(struct rtc_time));
439 436
440 p = buf;
441
442 if (hp_sdc_rtc_read_bbrtc(&tm)) { 437 if (hp_sdc_rtc_read_bbrtc(&tm)) {
443 p += sprintf(p, "BBRTC\t\t: READ FAILED!\n"); 438 seq_puts(m, "BBRTC\t\t: READ FAILED!\n");
444 } else { 439 } else {
445 p += sprintf(p, 440 seq_printf(m,
446 "rtc_time\t: %02d:%02d:%02d\n" 441 "rtc_time\t: %02d:%02d:%02d\n"
447 "rtc_date\t: %04d-%02d-%02d\n" 442 "rtc_date\t: %04d-%02d-%02d\n"
448 "rtc_epoch\t: %04lu\n", 443 "rtc_epoch\t: %04lu\n",
@@ -452,41 +447,41 @@ static int hp_sdc_rtc_proc_output (char *buf)
452 } 447 }
453 448
454 if (hp_sdc_rtc_read_rt(&tv)) { 449 if (hp_sdc_rtc_read_rt(&tv)) {
455 p += sprintf(p, "i8042 rtc\t: READ FAILED!\n"); 450 seq_puts(m, "i8042 rtc\t: READ FAILED!\n");
456 } else { 451 } else {
457 p += sprintf(p, "i8042 rtc\t: %ld.%02d seconds\n", 452 seq_printf(m, "i8042 rtc\t: %ld.%02d seconds\n",
458 tv.tv_sec, (int)tv.tv_usec/1000); 453 tv.tv_sec, (int)tv.tv_usec/1000);
459 } 454 }
460 455
461 if (hp_sdc_rtc_read_fhs(&tv)) { 456 if (hp_sdc_rtc_read_fhs(&tv)) {
462 p += sprintf(p, "handshake\t: READ FAILED!\n"); 457 seq_puts(m, "handshake\t: READ FAILED!\n");
463 } else { 458 } else {
464 p += sprintf(p, "handshake\t: %ld.%02d seconds\n", 459 seq_printf(m, "handshake\t: %ld.%02d seconds\n",
465 tv.tv_sec, (int)tv.tv_usec/1000); 460 tv.tv_sec, (int)tv.tv_usec/1000);
466 } 461 }
467 462
468 if (hp_sdc_rtc_read_mt(&tv)) { 463 if (hp_sdc_rtc_read_mt(&tv)) {
469 p += sprintf(p, "alarm\t\t: READ FAILED!\n"); 464 seq_puts(m, "alarm\t\t: READ FAILED!\n");
470 } else { 465 } else {
471 p += sprintf(p, "alarm\t\t: %ld.%02d seconds\n", 466 seq_printf(m, "alarm\t\t: %ld.%02d seconds\n",
472 tv.tv_sec, (int)tv.tv_usec/1000); 467 tv.tv_sec, (int)tv.tv_usec/1000);
473 } 468 }
474 469
475 if (hp_sdc_rtc_read_dt(&tv)) { 470 if (hp_sdc_rtc_read_dt(&tv)) {
476 p += sprintf(p, "delay\t\t: READ FAILED!\n"); 471 seq_puts(m, "delay\t\t: READ FAILED!\n");
477 } else { 472 } else {
478 p += sprintf(p, "delay\t\t: %ld.%02d seconds\n", 473 seq_printf(m, "delay\t\t: %ld.%02d seconds\n",
479 tv.tv_sec, (int)tv.tv_usec/1000); 474 tv.tv_sec, (int)tv.tv_usec/1000);
480 } 475 }
481 476
482 if (hp_sdc_rtc_read_ct(&tv)) { 477 if (hp_sdc_rtc_read_ct(&tv)) {
483 p += sprintf(p, "periodic\t: READ FAILED!\n"); 478 seq_puts(m, "periodic\t: READ FAILED!\n");
484 } else { 479 } else {
485 p += sprintf(p, "periodic\t: %ld.%02d seconds\n", 480 seq_printf(m, "periodic\t: %ld.%02d seconds\n",
486 tv.tv_sec, (int)tv.tv_usec/1000); 481 tv.tv_sec, (int)tv.tv_usec/1000);
487 } 482 }
488 483
489 p += sprintf(p, 484 seq_printf(m,
490 "DST_enable\t: %s\n" 485 "DST_enable\t: %s\n"
491 "BCD\t\t: %s\n" 486 "BCD\t\t: %s\n"
492 "24hr\t\t: %s\n" 487 "24hr\t\t: %s\n"
@@ -506,23 +501,23 @@ static int hp_sdc_rtc_proc_output (char *buf)
506 1UL, 501 1UL,
507 1 ? "okay" : "dead"); 502 1 ? "okay" : "dead");
508 503
509 return p - buf; 504 return 0;
510#undef YN 505#undef YN
511#undef NY 506#undef NY
512} 507}
513 508
514static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off, 509static int hp_sdc_rtc_proc_open(struct inode *inode, struct file *file)
515 int count, int *eof, void *data)
516{ 510{
517 int len = hp_sdc_rtc_proc_output (page); 511 return single_open(file, hp_sdc_rtc_proc_show, NULL);
518 if (len <= off+count) *eof = 1;
519 *start = page + off;
520 len -= off;
521 if (len>count) len = count;
522 if (len<0) len = 0;
523 return len;
524} 512}
525 513
514static const struct file_operations hp_sdc_rtc_proc_fops = {
515 .open = hp_sdc_rtc_proc_open,
516 .read = seq_read,
517 .llseek = seq_lseek,
518 .release = seq_release,
519};
520
526static int hp_sdc_rtc_ioctl(struct file *file, 521static int hp_sdc_rtc_ioctl(struct file *file,
527 unsigned int cmd, unsigned long arg) 522 unsigned int cmd, unsigned long arg)
528{ 523{
@@ -715,8 +710,7 @@ static int __init hp_sdc_rtc_init(void)
715 if (misc_register(&hp_sdc_rtc_dev) != 0) 710 if (misc_register(&hp_sdc_rtc_dev) != 0)
716 printk(KERN_INFO "Could not register misc. dev for i8042 rtc\n"); 711 printk(KERN_INFO "Could not register misc. dev for i8042 rtc\n");
717 712
718 create_proc_read_entry ("driver/rtc", 0, NULL, 713 proc_create("driver/rtc", 0, NULL, &hp_sdc_rtc_proc_fops);
719 hp_sdc_rtc_read_proc, NULL);
720 714
721 printk(KERN_INFO "HP i8042 SDC + MSM-58321 RTC support loaded " 715 printk(KERN_INFO "HP i8042 SDC + MSM-58321 RTC support loaded "
722 "(RTC v " RTC_VERSION ")\n"); 716 "(RTC v " RTC_VERSION ")\n");
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index 03a0a01a4054..3286903a95d2 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -2334,7 +2334,7 @@ static int gigaset_proc_show(struct seq_file *m, void *v)
2334 2334
2335static int gigaset_proc_open(struct inode *inode, struct file *file) 2335static int gigaset_proc_open(struct inode *inode, struct file *file)
2336{ 2336{
2337 return single_open(file, gigaset_proc_show, PDE(inode)->data); 2337 return single_open(file, gigaset_proc_show, PDE_DATA(inode));
2338} 2338}
2339 2339
2340static const struct file_operations gigaset_proc_fops = { 2340static const struct file_operations gigaset_proc_fops = {
diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
index 821f7ac33b37..4d9b195547c5 100644
--- a/drivers/isdn/hardware/avm/b1.c
+++ b/drivers/isdn/hardware/avm/b1.c
@@ -702,7 +702,7 @@ static int b1ctl_proc_show(struct seq_file *m, void *v)
702 702
703static int b1ctl_proc_open(struct inode *inode, struct file *file) 703static int b1ctl_proc_open(struct inode *inode, struct file *file)
704{ 704{
705 return single_open(file, b1ctl_proc_show, PDE(inode)->data); 705 return single_open(file, b1ctl_proc_show, PDE_DATA(inode));
706} 706}
707 707
708const struct file_operations b1ctl_proc_fops = { 708const struct file_operations b1ctl_proc_fops = {
diff --git a/drivers/isdn/hardware/avm/b1dma.c b/drivers/isdn/hardware/avm/b1dma.c
index 0896aa86fc08..19b113faeb7b 100644
--- a/drivers/isdn/hardware/avm/b1dma.c
+++ b/drivers/isdn/hardware/avm/b1dma.c
@@ -944,7 +944,7 @@ static int b1dmactl_proc_show(struct seq_file *m, void *v)
944 944
945static int b1dmactl_proc_open(struct inode *inode, struct file *file) 945static int b1dmactl_proc_open(struct inode *inode, struct file *file)
946{ 946{
947 return single_open(file, b1dmactl_proc_show, PDE(inode)->data); 947 return single_open(file, b1dmactl_proc_show, PDE_DATA(inode));
948} 948}
949 949
950const struct file_operations b1dmactl_proc_fops = { 950const struct file_operations b1dmactl_proc_fops = {
diff --git a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c
index 1d7fc44e3eef..5d00d72fe482 100644
--- a/drivers/isdn/hardware/avm/c4.c
+++ b/drivers/isdn/hardware/avm/c4.c
@@ -1129,7 +1129,7 @@ static int c4_proc_show(struct seq_file *m, void *v)
1129 1129
1130static int c4_proc_open(struct inode *inode, struct file *file) 1130static int c4_proc_open(struct inode *inode, struct file *file)
1131{ 1131{
1132 return single_open(file, c4_proc_show, PDE(inode)->data); 1132 return single_open(file, c4_proc_show, PDE_DATA(inode));
1133} 1133}
1134 1134
1135static const struct file_operations c4_proc_fops = { 1135static const struct file_operations c4_proc_fops = {
diff --git a/drivers/isdn/hardware/eicon/divasproc.c b/drivers/isdn/hardware/eicon/divasproc.c
index 3a4165c61196..56ce98a4e248 100644
--- a/drivers/isdn/hardware/eicon/divasproc.c
+++ b/drivers/isdn/hardware/eicon/divasproc.c
@@ -145,7 +145,7 @@ void remove_divas_proc(void)
145static ssize_t grp_opt_proc_write(struct file *file, const char __user *buffer, 145static ssize_t grp_opt_proc_write(struct file *file, const char __user *buffer,
146 size_t count, loff_t *pos) 146 size_t count, loff_t *pos)
147{ 147{
148 diva_os_xdi_adapter_t *a = PDE(file_inode(file))->data; 148 diva_os_xdi_adapter_t *a = PDE_DATA(file_inode(file));
149 PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; 149 PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1];
150 150
151 if ((count == 1) || (count == 2)) { 151 if ((count == 1) || (count == 2)) {
@@ -172,7 +172,7 @@ static ssize_t grp_opt_proc_write(struct file *file, const char __user *buffer,
172static ssize_t d_l1_down_proc_write(struct file *file, const char __user *buffer, 172static ssize_t d_l1_down_proc_write(struct file *file, const char __user *buffer,
173 size_t count, loff_t *pos) 173 size_t count, loff_t *pos)
174{ 174{
175 diva_os_xdi_adapter_t *a = PDE(file_inode(file))->data; 175 diva_os_xdi_adapter_t *a = PDE_DATA(file_inode(file));
176 PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; 176 PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1];
177 177
178 if ((count == 1) || (count == 2)) { 178 if ((count == 1) || (count == 2)) {
@@ -210,7 +210,7 @@ static int d_l1_down_proc_show(struct seq_file *m, void *v)
210 210
211static int d_l1_down_proc_open(struct inode *inode, struct file *file) 211static int d_l1_down_proc_open(struct inode *inode, struct file *file)
212{ 212{
213 return single_open(file, d_l1_down_proc_show, PDE(inode)->data); 213 return single_open(file, d_l1_down_proc_show, PDE_DATA(inode));
214} 214}
215 215
216static const struct file_operations d_l1_down_proc_fops = { 216static const struct file_operations d_l1_down_proc_fops = {
@@ -236,7 +236,7 @@ static int grp_opt_proc_show(struct seq_file *m, void *v)
236 236
237static int grp_opt_proc_open(struct inode *inode, struct file *file) 237static int grp_opt_proc_open(struct inode *inode, struct file *file)
238{ 238{
239 return single_open(file, grp_opt_proc_show, PDE(inode)->data); 239 return single_open(file, grp_opt_proc_show, PDE_DATA(inode));
240} 240}
241 241
242static const struct file_operations grp_opt_proc_fops = { 242static const struct file_operations grp_opt_proc_fops = {
@@ -251,7 +251,7 @@ static const struct file_operations grp_opt_proc_fops = {
251static ssize_t info_proc_write(struct file *file, const char __user *buffer, 251static ssize_t info_proc_write(struct file *file, const char __user *buffer,
252 size_t count, loff_t *pos) 252 size_t count, loff_t *pos)
253{ 253{
254 diva_os_xdi_adapter_t *a = PDE(file_inode(file))->data; 254 diva_os_xdi_adapter_t *a = PDE_DATA(file_inode(file));
255 PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; 255 PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1];
256 char c[4]; 256 char c[4];
257 257
@@ -335,7 +335,7 @@ static int info_proc_show(struct seq_file *m, void *v)
335 335
336static int info_proc_open(struct inode *inode, struct file *file) 336static int info_proc_open(struct inode *inode, struct file *file)
337{ 337{
338 return single_open(file, info_proc_show, PDE(inode)->data); 338 return single_open(file, info_proc_show, PDE_DATA(inode));
339} 339}
340 340
341static const struct file_operations info_proc_fops = { 341static const struct file_operations info_proc_fops = {
diff --git a/drivers/isdn/hysdn/hycapi.c b/drivers/isdn/hysdn/hycapi.c
index 931f916c9c23..00aad10507d8 100644
--- a/drivers/isdn/hysdn/hycapi.c
+++ b/drivers/isdn/hysdn/hycapi.c
@@ -469,7 +469,7 @@ static int hycapi_proc_show(struct seq_file *m, void *v)
469 469
470static int hycapi_proc_open(struct inode *inode, struct file *file) 470static int hycapi_proc_open(struct inode *inode, struct file *file)
471{ 471{
472 return single_open(file, hycapi_proc_show, PDE(inode)->data); 472 return single_open(file, hycapi_proc_show, PDE_DATA(inode));
473} 473}
474 474
475static const struct file_operations hycapi_proc_fops = { 475static const struct file_operations hycapi_proc_fops = {
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
index 8023d2510fba..73079213ec94 100644
--- a/drivers/isdn/hysdn/hysdn_procconf.c
+++ b/drivers/isdn/hysdn/hysdn_procconf.c
@@ -229,23 +229,12 @@ static int
229hysdn_conf_open(struct inode *ino, struct file *filep) 229hysdn_conf_open(struct inode *ino, struct file *filep)
230{ 230{
231 hysdn_card *card; 231 hysdn_card *card;
232 struct proc_dir_entry *pd;
233 struct conf_writedata *cnf; 232 struct conf_writedata *cnf;
234 char *cp, *tmp; 233 char *cp, *tmp;
235 234
236 /* now search the addressed card */ 235 /* now search the addressed card */
237 mutex_lock(&hysdn_conf_mutex); 236 mutex_lock(&hysdn_conf_mutex);
238 card = card_root; 237 card = PDE_DATA(ino);
239 while (card) {
240 pd = card->procconf;
241 if (pd == PDE(ino))
242 break;
243 card = card->next; /* search next entry */
244 }
245 if (!card) {
246 mutex_unlock(&hysdn_conf_mutex);
247 return (-ENODEV); /* device is unknown/invalid */
248 }
249 if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) 238 if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
250 hysdn_addlog(card, "config open for uid=%d gid=%d mode=0x%x", 239 hysdn_addlog(card, "config open for uid=%d gid=%d mode=0x%x",
251 filep->f_cred->fsuid, filep->f_cred->fsgid, 240 filep->f_cred->fsuid, filep->f_cred->fsgid,
@@ -317,21 +306,9 @@ hysdn_conf_close(struct inode *ino, struct file *filep)
317 hysdn_card *card; 306 hysdn_card *card;
318 struct conf_writedata *cnf; 307 struct conf_writedata *cnf;
319 int retval = 0; 308 int retval = 0;
320 struct proc_dir_entry *pd;
321 309
322 mutex_lock(&hysdn_conf_mutex); 310 mutex_lock(&hysdn_conf_mutex);
323 /* search the addressed card */ 311 card = PDE_DATA(ino);
324 card = card_root;
325 while (card) {
326 pd = card->procconf;
327 if (pd == PDE(ino))
328 break;
329 card = card->next; /* search next entry */
330 }
331 if (!card) {
332 mutex_unlock(&hysdn_conf_mutex);
333 return (-ENODEV); /* device is unknown/invalid */
334 }
335 if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) 312 if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
336 hysdn_addlog(card, "config close for uid=%d gid=%d mode=0x%x", 313 hysdn_addlog(card, "config close for uid=%d gid=%d mode=0x%x",
337 filep->f_cred->fsuid, filep->f_cred->fsgid, 314 filep->f_cred->fsuid, filep->f_cred->fsgid,
@@ -394,10 +371,11 @@ hysdn_procconf_init(void)
394 while (card) { 371 while (card) {
395 372
396 sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid); 373 sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid);
397 if ((card->procconf = (void *) proc_create(conf_name, 374 if ((card->procconf = (void *) proc_create_data(conf_name,
398 S_IFREG | S_IRUGO | S_IWUSR, 375 S_IFREG | S_IRUGO | S_IWUSR,
399 hysdn_proc_entry, 376 hysdn_proc_entry,
400 &conf_fops)) != NULL) { 377 &conf_fops,
378 card)) != NULL) {
401 hysdn_proclog_init(card); /* init the log file entry */ 379 hysdn_proclog_init(card); /* init the log file entry */
402 } 380 }
403 card = card->next; /* next entry */ 381 card = card->next; /* next entry */
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index 9a3ce93665c5..b61e8d5e84ad 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -173,27 +173,14 @@ hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t *off)
173{ 173{
174 struct log_data *inf; 174 struct log_data *inf;
175 int len; 175 int len;
176 struct proc_dir_entry *pde = PDE(file_inode(file)); 176 hysdn_card *card = PDE_DATA(file_inode(file));
177 struct procdata *pd = NULL;
178 hysdn_card *card;
179 177
180 if (!*((struct log_data **) file->private_data)) { 178 if (!*((struct log_data **) file->private_data)) {
179 struct procdata *pd = card->proclog;
181 if (file->f_flags & O_NONBLOCK) 180 if (file->f_flags & O_NONBLOCK)
182 return (-EAGAIN); 181 return (-EAGAIN);
183 182
184 /* sorry, but we need to search the card */ 183 interruptible_sleep_on(&(pd->rd_queue));
185 card = card_root;
186 while (card) {
187 pd = card->proclog;
188 if (pd->log == pde)
189 break;
190 card = card->next; /* search next entry */
191 }
192 if (card)
193 interruptible_sleep_on(&(pd->rd_queue));
194 else
195 return (-EAGAIN);
196
197 } 184 }
198 if (!(inf = *((struct log_data **) file->private_data))) 185 if (!(inf = *((struct log_data **) file->private_data)))
199 return (0); 186 return (0);
@@ -215,27 +202,15 @@ hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t *off)
215static int 202static int
216hysdn_log_open(struct inode *ino, struct file *filep) 203hysdn_log_open(struct inode *ino, struct file *filep)
217{ 204{
218 hysdn_card *card; 205 hysdn_card *card = PDE_DATA(ino);
219 struct procdata *pd = NULL;
220 unsigned long flags;
221 206
222 mutex_lock(&hysdn_log_mutex); 207 mutex_lock(&hysdn_log_mutex);
223 card = card_root;
224 while (card) {
225 pd = card->proclog;
226 if (pd->log == PDE(ino))
227 break;
228 card = card->next; /* search next entry */
229 }
230 if (!card) {
231 mutex_unlock(&hysdn_log_mutex);
232 return (-ENODEV); /* device is unknown/invalid */
233 }
234 filep->private_data = card; /* remember our own card */
235
236 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { 208 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
237 /* write only access -> write log level only */ 209 /* write only access -> write log level only */
210 filep->private_data = card; /* remember our own card */
238 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { 211 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
212 struct procdata *pd = card->proclog;
213 unsigned long flags;
239 214
240 /* read access -> log/debug read */ 215 /* read access -> log/debug read */
241 spin_lock_irqsave(&card->hysdn_lock, flags); 216 spin_lock_irqsave(&card->hysdn_lock, flags);
@@ -275,21 +250,13 @@ hysdn_log_close(struct inode *ino, struct file *filep)
275 } else { 250 } else {
276 /* read access -> log/debug read, mark one further file as closed */ 251 /* read access -> log/debug read, mark one further file as closed */
277 252
278 pd = NULL;
279 inf = *((struct log_data **) filep->private_data); /* get first log entry */ 253 inf = *((struct log_data **) filep->private_data); /* get first log entry */
280 if (inf) 254 if (inf)
281 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */ 255 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */
282 else { 256 else {
283 /* no info available -> search card */ 257 /* no info available -> search card */
284 card = card_root; 258 card = PDE_DATA(file_inode(filep));
285 while (card) { 259 pd = card->proclog; /* pointer to procfs log */
286 pd = card->proclog;
287 if (pd->log == PDE(ino))
288 break;
289 card = card->next; /* search next entry */
290 }
291 if (card)
292 pd = card->proclog; /* pointer to procfs log */
293 } 260 }
294 if (pd) 261 if (pd)
295 pd->if_used--; /* decrement interface usage count by one */ 262 pd->if_used--; /* decrement interface usage count by one */
@@ -319,24 +286,12 @@ static unsigned int
319hysdn_log_poll(struct file *file, poll_table *wait) 286hysdn_log_poll(struct file *file, poll_table *wait)
320{ 287{
321 unsigned int mask = 0; 288 unsigned int mask = 0;
322 struct proc_dir_entry *pde = PDE(file_inode(file)); 289 hysdn_card *card = PDE_DATA(file_inode(file));
323 hysdn_card *card; 290 struct procdata *pd = card->proclog;
324 struct procdata *pd = NULL;
325 291
326 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) 292 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE)
327 return (mask); /* no polling for write supported */ 293 return (mask); /* no polling for write supported */
328 294
329 /* we need to search the card */
330 card = card_root;
331 while (card) {
332 pd = card->proclog;
333 if (pd->log == pde)
334 break;
335 card = card->next; /* search next entry */
336 }
337 if (!card)
338 return (mask); /* card not found */
339
340 poll_wait(file, &(pd->rd_queue), wait); 295 poll_wait(file, &(pd->rd_queue), wait);
341 296
342 if (*((struct log_data **) file->private_data)) 297 if (*((struct log_data **) file->private_data))
@@ -373,9 +328,9 @@ hysdn_proclog_init(hysdn_card *card)
373 328
374 if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) { 329 if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
375 sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid); 330 sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid);
376 pd->log = proc_create(pd->log_name, 331 pd->log = proc_create_data(pd->log_name,
377 S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry, 332 S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry,
378 &log_fops); 333 &log_fops, card);
379 334
380 init_waitqueue_head(&(pd->rd_queue)); 335 init_waitqueue_head(&(pd->rd_queue));
381 336
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index 1094667d8f31..9438d7ec3308 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -64,7 +64,6 @@ mISDN_open(struct inode *ino, struct file *filep)
64 dev->work = 0; 64 dev->work = 0;
65 init_waitqueue_head(&dev->wait); 65 init_waitqueue_head(&dev->wait);
66 filep->private_data = dev; 66 filep->private_data = dev;
67 __module_get(THIS_MODULE);
68 return nonseekable_open(ino, filep); 67 return nonseekable_open(ino, filep);
69} 68}
70 69
@@ -72,19 +71,28 @@ static int
72mISDN_close(struct inode *ino, struct file *filep) 71mISDN_close(struct inode *ino, struct file *filep)
73{ 72{
74 struct mISDNtimerdev *dev = filep->private_data; 73 struct mISDNtimerdev *dev = filep->private_data;
74 struct list_head *list = &dev->pending;
75 struct mISDNtimer *timer, *next; 75 struct mISDNtimer *timer, *next;
76 76
77 if (*debug & DEBUG_TIMER) 77 if (*debug & DEBUG_TIMER)
78 printk(KERN_DEBUG "%s(%p,%p)\n", __func__, ino, filep); 78 printk(KERN_DEBUG "%s(%p,%p)\n", __func__, ino, filep);
79 list_for_each_entry_safe(timer, next, &dev->pending, list) { 79
80 del_timer(&timer->tl); 80 spin_lock_irq(&dev->lock);
81 while (!list_empty(list)) {
82 timer = list_first_entry(list, struct mISDNtimer, list);
83 spin_unlock_irq(&dev->lock);
84 del_timer_sync(&timer->tl);
85 spin_lock_irq(&dev->lock);
86 /* it might have been moved to ->expired */
87 list_del(&timer->list);
81 kfree(timer); 88 kfree(timer);
82 } 89 }
90 spin_unlock_irq(&dev->lock);
91
83 list_for_each_entry_safe(timer, next, &dev->expired, list) { 92 list_for_each_entry_safe(timer, next, &dev->expired, list) {
84 kfree(timer); 93 kfree(timer);
85 } 94 }
86 kfree(dev); 95 kfree(dev);
87 module_put(THIS_MODULE);
88 return 0; 96 return 0;
89} 97}
90 98
@@ -92,36 +100,41 @@ static ssize_t
92mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off) 100mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off)
93{ 101{
94 struct mISDNtimerdev *dev = filep->private_data; 102 struct mISDNtimerdev *dev = filep->private_data;
103 struct list_head *list = &dev->expired;
95 struct mISDNtimer *timer; 104 struct mISDNtimer *timer;
96 u_long flags;
97 int ret = 0; 105 int ret = 0;
98 106
99 if (*debug & DEBUG_TIMER) 107 if (*debug & DEBUG_TIMER)
100 printk(KERN_DEBUG "%s(%p, %p, %d, %p)\n", __func__, 108 printk(KERN_DEBUG "%s(%p, %p, %d, %p)\n", __func__,
101 filep, buf, (int)count, off); 109 filep, buf, (int)count, off);
102 110
103 if (list_empty(&dev->expired) && (dev->work == 0)) { 111 if (count < sizeof(int))
112 return -ENOSPC;
113
114 spin_lock_irq(&dev->lock);
115 while (list_empty(list) && (dev->work == 0)) {
116 spin_unlock_irq(&dev->lock);
104 if (filep->f_flags & O_NONBLOCK) 117 if (filep->f_flags & O_NONBLOCK)
105 return -EAGAIN; 118 return -EAGAIN;
106 wait_event_interruptible(dev->wait, (dev->work || 119 wait_event_interruptible(dev->wait, (dev->work ||
107 !list_empty(&dev->expired))); 120 !list_empty(list)));
108 if (signal_pending(current)) 121 if (signal_pending(current))
109 return -ERESTARTSYS; 122 return -ERESTARTSYS;
123 spin_lock_irq(&dev->lock);
110 } 124 }
111 if (count < sizeof(int))
112 return -ENOSPC;
113 if (dev->work) 125 if (dev->work)
114 dev->work = 0; 126 dev->work = 0;
115 if (!list_empty(&dev->expired)) { 127 if (!list_empty(list)) {
116 spin_lock_irqsave(&dev->lock, flags); 128 timer = list_first_entry(list, struct mISDNtimer, list);
117 timer = (struct mISDNtimer *)dev->expired.next;
118 list_del(&timer->list); 129 list_del(&timer->list);
119 spin_unlock_irqrestore(&dev->lock, flags); 130 spin_unlock_irq(&dev->lock);
120 if (put_user(timer->id, (int __user *)buf)) 131 if (put_user(timer->id, (int __user *)buf))
121 ret = -EFAULT; 132 ret = -EFAULT;
122 else 133 else
123 ret = sizeof(int); 134 ret = sizeof(int);
124 kfree(timer); 135 kfree(timer);
136 } else {
137 spin_unlock_irq(&dev->lock);
125 } 138 }
126 return ret; 139 return ret;
127} 140}
@@ -153,7 +166,8 @@ dev_expire_timer(unsigned long data)
153 u_long flags; 166 u_long flags;
154 167
155 spin_lock_irqsave(&timer->dev->lock, flags); 168 spin_lock_irqsave(&timer->dev->lock, flags);
156 list_move_tail(&timer->list, &timer->dev->expired); 169 if (timer->id >= 0)
170 list_move_tail(&timer->list, &timer->dev->expired);
157 spin_unlock_irqrestore(&timer->dev->lock, flags); 171 spin_unlock_irqrestore(&timer->dev->lock, flags);
158 wake_up_interruptible(&timer->dev->wait); 172 wake_up_interruptible(&timer->dev->wait);
159} 173}
@@ -162,7 +176,6 @@ static int
162misdn_add_timer(struct mISDNtimerdev *dev, int timeout) 176misdn_add_timer(struct mISDNtimerdev *dev, int timeout)
163{ 177{
164 int id; 178 int id;
165 u_long flags;
166 struct mISDNtimer *timer; 179 struct mISDNtimer *timer;
167 180
168 if (!timeout) { 181 if (!timeout) {
@@ -173,19 +186,16 @@ misdn_add_timer(struct mISDNtimerdev *dev, int timeout)
173 timer = kzalloc(sizeof(struct mISDNtimer), GFP_KERNEL); 186 timer = kzalloc(sizeof(struct mISDNtimer), GFP_KERNEL);
174 if (!timer) 187 if (!timer)
175 return -ENOMEM; 188 return -ENOMEM;
176 spin_lock_irqsave(&dev->lock, flags); 189 timer->dev = dev;
177 timer->id = dev->next_id++; 190 setup_timer(&timer->tl, dev_expire_timer, (long)timer);
191 spin_lock_irq(&dev->lock);
192 id = timer->id = dev->next_id++;
178 if (dev->next_id < 0) 193 if (dev->next_id < 0)
179 dev->next_id = 1; 194 dev->next_id = 1;
180 list_add_tail(&timer->list, &dev->pending); 195 list_add_tail(&timer->list, &dev->pending);
181 spin_unlock_irqrestore(&dev->lock, flags);
182 timer->dev = dev;
183 timer->tl.data = (long)timer;
184 timer->tl.function = dev_expire_timer;
185 init_timer(&timer->tl);
186 timer->tl.expires = jiffies + ((HZ * (u_long)timeout) / 1000); 196 timer->tl.expires = jiffies + ((HZ * (u_long)timeout) / 1000);
187 add_timer(&timer->tl); 197 add_timer(&timer->tl);
188 id = timer->id; 198 spin_unlock_irq(&dev->lock);
189 } 199 }
190 return id; 200 return id;
191} 201}
@@ -193,26 +203,21 @@ misdn_add_timer(struct mISDNtimerdev *dev, int timeout)
193static int 203static int
194misdn_del_timer(struct mISDNtimerdev *dev, int id) 204misdn_del_timer(struct mISDNtimerdev *dev, int id)
195{ 205{
196 u_long flags;
197 struct mISDNtimer *timer; 206 struct mISDNtimer *timer;
198 int ret = 0;
199 207
200 spin_lock_irqsave(&dev->lock, flags); 208 spin_lock_irq(&dev->lock);
201 list_for_each_entry(timer, &dev->pending, list) { 209 list_for_each_entry(timer, &dev->pending, list) {
202 if (timer->id == id) { 210 if (timer->id == id) {
203 list_del_init(&timer->list); 211 list_del_init(&timer->list);
204 /* RED-PEN AK: race -- timer can be still running on 212 timer->id = -1;
205 * other CPU. Needs reference count I think 213 spin_unlock_irq(&dev->lock);
206 */ 214 del_timer_sync(&timer->tl);
207 del_timer(&timer->tl);
208 ret = timer->id;
209 kfree(timer); 215 kfree(timer);
210 goto unlock; 216 return id;
211 } 217 }
212 } 218 }
213unlock: 219 spin_unlock_irq(&dev->lock);
214 spin_unlock_irqrestore(&dev->lock, flags); 220 return 0;
215 return ret;
216} 221}
217 222
218static long 223static long
@@ -262,6 +267,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
262} 267}
263 268
264static const struct file_operations mISDN_fops = { 269static const struct file_operations mISDN_fops = {
270 .owner = THIS_MODULE,
265 .read = mISDN_read, 271 .read = mISDN_read,
266 .poll = mISDN_poll, 272 .poll = mISDN_poll,
267 .unlocked_ioctl = mISDN_ioctl, 273 .unlocked_ioctl = mISDN_ioctl,
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 22b8ce4191cc..c31fbab6aa82 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -869,7 +869,7 @@ static int pmu_battery_proc_show(struct seq_file *m, void *v)
869 869
870static int pmu_battery_proc_open(struct inode *inode, struct file *file) 870static int pmu_battery_proc_open(struct inode *inode, struct file *file)
871{ 871{
872 return single_open(file, pmu_battery_proc_show, PDE(inode)->data); 872 return single_open(file, pmu_battery_proc_show, PDE_DATA(inode));
873} 873}
874 874
875static const struct file_operations pmu_battery_proc_fops = { 875static const struct file_operations pmu_battery_proc_fops = {
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 57601c0704c1..1f925e856974 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -2527,11 +2527,8 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
2527 2527
2528 if (dvbdev->users == -1) { 2528 if (dvbdev->users == -1) {
2529 wake_up(&fepriv->wait_queue); 2529 wake_up(&fepriv->wait_queue);
2530 if (fepriv->exit != DVB_FE_NO_EXIT) { 2530 if (fepriv->exit != DVB_FE_NO_EXIT)
2531 fops_put(file->f_op);
2532 file->f_op = NULL;
2533 wake_up(&dvbdev->wait_queue); 2531 wake_up(&dvbdev->wait_queue);
2534 }
2535 if (fe->ops.ts_bus_ctrl) 2532 if (fe->ops.ts_bus_ctrl)
2536 fe->ops.ts_bus_ctrl(fe, 0); 2533 fe->ops.ts_bus_ctrl(fe, 0);
2537 } 2534 }
diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index c3cc3b52662b..f91c80c0e9ec 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -1479,11 +1479,8 @@ static int dvb_net_close(struct inode *inode, struct file *file)
1479 1479
1480 dvb_generic_release(inode, file); 1480 dvb_generic_release(inode, file);
1481 1481
1482 if(dvbdev->users == 1 && dvbnet->exit == 1) { 1482 if(dvbdev->users == 1 && dvbnet->exit == 1)
1483 fops_put(file->f_op);
1484 file->f_op = NULL;
1485 wake_up(&dvbdev->wait_queue); 1483 wake_up(&dvbdev->wait_queue);
1486 }
1487 return 0; 1484 return 0;
1488} 1485}
1489 1486
diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
index b9be535e32b8..68dbc2dbc982 100644
--- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c
+++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
@@ -259,79 +259,46 @@ void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev)
259static int cx25821_get_audio_data(struct cx25821_dev *dev, 259static int cx25821_get_audio_data(struct cx25821_dev *dev,
260 const struct sram_channel *sram_ch) 260 const struct sram_channel *sram_ch)
261{ 261{
262 struct file *myfile; 262 struct file *file;
263 int frame_index_temp = dev->_audioframe_index; 263 int frame_index_temp = dev->_audioframe_index;
264 int i = 0; 264 int i = 0;
265 int line_size = AUDIO_LINE_SIZE;
266 int frame_size = AUDIO_DATA_BUF_SZ; 265 int frame_size = AUDIO_DATA_BUF_SZ;
267 int frame_offset = frame_size * frame_index_temp; 266 int frame_offset = frame_size * frame_index_temp;
268 ssize_t vfs_read_retval = 0; 267 char mybuf[AUDIO_LINE_SIZE];
269 char mybuf[line_size];
270 loff_t file_offset = dev->_audioframe_count * frame_size; 268 loff_t file_offset = dev->_audioframe_count * frame_size;
271 loff_t pos; 269 char *p = NULL;
272 mm_segment_t old_fs;
273 270
274 if (dev->_audiofile_status == END_OF_FILE) 271 if (dev->_audiofile_status == END_OF_FILE)
275 return 0; 272 return 0;
276 273
277 myfile = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0); 274 file = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0);
275 if (IS_ERR(file)) {
276 pr_err("%s(): ERROR opening file(%s) with errno = %ld!\n",
277 __func__, dev->_audiofilename, -PTR_ERR(file));
278 return PTR_ERR(file);
279 }
278 280
279 if (IS_ERR(myfile)) { 281 if (dev->_audiodata_buf_virt_addr)
280 const int open_errno = -PTR_ERR(myfile); 282 p = (char *)dev->_audiodata_buf_virt_addr + frame_offset;
281 pr_err("%s(): ERROR opening file(%s) with errno = %d!\n",
282 __func__, dev->_audiofilename, open_errno);
283 return PTR_ERR(myfile);
284 } else {
285 if (!(myfile->f_op)) {
286 pr_err("%s(): File has no file operations registered!\n",
287 __func__);
288 filp_close(myfile, NULL);
289 return -EIO;
290 }
291 283
292 if (!myfile->f_op->read) { 284 for (i = 0; i < dev->_audio_lines_count; i++) {
293 pr_err("%s(): File has no READ operations registered!\n", 285 int n = kernel_read(file, file_offset, mybuf, AUDIO_LINE_SIZE);
286 if (n < AUDIO_LINE_SIZE) {
287 pr_info("Done: exit %s() since no more bytes to read from Audio file\n",
294 __func__); 288 __func__);
295 filp_close(myfile, NULL); 289 dev->_audiofile_status = END_OF_FILE;
296 return -EIO; 290 fput(file);
291 return 0;
297 } 292 }
298 293 dev->_audiofile_status = IN_PROGRESS;
299 pos = myfile->f_pos; 294 if (p) {
300 old_fs = get_fs(); 295 memcpy(p, mybuf, n);
301 set_fs(KERNEL_DS); 296 p += n;
302
303 for (i = 0; i < dev->_audio_lines_count; i++) {
304 pos = file_offset;
305
306 vfs_read_retval = vfs_read(myfile, mybuf, line_size,
307 &pos);
308
309 if (vfs_read_retval > 0 && vfs_read_retval == line_size
310 && dev->_audiodata_buf_virt_addr != NULL) {
311 memcpy((void *)(dev->_audiodata_buf_virt_addr +
312 frame_offset / 4), mybuf,
313 vfs_read_retval);
314 }
315
316 file_offset += vfs_read_retval;
317 frame_offset += vfs_read_retval;
318
319 if (vfs_read_retval < line_size) {
320 pr_info("Done: exit %s() since no more bytes to read from Audio file\n",
321 __func__);
322 break;
323 }
324 } 297 }
325 298 file_offset += n;
326 if (i > 0)
327 dev->_audioframe_count++;
328
329 dev->_audiofile_status = (vfs_read_retval == line_size) ?
330 IN_PROGRESS : END_OF_FILE;
331
332 set_fs(old_fs);
333 filp_close(myfile, NULL);
334 } 299 }
300 dev->_audioframe_count++;
301 fput(file);
335 302
336 return 0; 303 return 0;
337} 304}
@@ -354,81 +321,41 @@ static void cx25821_audioups_handler(struct work_struct *work)
354static int cx25821_openfile_audio(struct cx25821_dev *dev, 321static int cx25821_openfile_audio(struct cx25821_dev *dev,
355 const struct sram_channel *sram_ch) 322 const struct sram_channel *sram_ch)
356{ 323{
357 struct file *myfile; 324 char *p = (void *)dev->_audiodata_buf_virt_addr;
358 int i = 0, j = 0; 325 struct file *file;
359 int line_size = AUDIO_LINE_SIZE; 326 loff_t offset;
360 ssize_t vfs_read_retval = 0; 327 int i, j;
361 char mybuf[line_size]; 328
362 loff_t pos; 329 file = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0);
363 loff_t offset = (unsigned long)0; 330 if (IS_ERR(file)) {
364 mm_segment_t old_fs; 331 pr_err("%s(): ERROR opening file(%s) with errno = %ld!\n",
365 332 __func__, dev->_audiofilename, PTR_ERR(file));
366 myfile = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0); 333 return PTR_ERR(file);
367 334 }
368 if (IS_ERR(myfile)) {
369 const int open_errno = -PTR_ERR(myfile);
370 pr_err("%s(): ERROR opening file(%s) with errno = %d!\n",
371 __func__, dev->_audiofilename, open_errno);
372 return PTR_ERR(myfile);
373 } else {
374 if (!(myfile->f_op)) {
375 pr_err("%s(): File has no file operations registered!\n",
376 __func__);
377 filp_close(myfile, NULL);
378 return -EIO;
379 }
380
381 if (!myfile->f_op->read) {
382 pr_err("%s(): File has no READ operations registered!\n",
383 __func__);
384 filp_close(myfile, NULL);
385 return -EIO;
386 }
387
388 pos = myfile->f_pos;
389 old_fs = get_fs();
390 set_fs(KERNEL_DS);
391
392 for (j = 0; j < NUM_AUDIO_FRAMES; j++) {
393 for (i = 0; i < dev->_audio_lines_count; i++) {
394 pos = offset;
395
396 vfs_read_retval = vfs_read(myfile, mybuf,
397 line_size, &pos);
398
399 if (vfs_read_retval > 0 &&
400 vfs_read_retval == line_size &&
401 dev->_audiodata_buf_virt_addr != NULL) {
402 memcpy((void *)(dev->
403 _audiodata_buf_virt_addr
404 + offset / 4), mybuf,
405 vfs_read_retval);
406 }
407 335
408 offset += vfs_read_retval; 336 for (j = 0, offset = 0; j < NUM_AUDIO_FRAMES; j++) {
337 for (i = 0; i < dev->_audio_lines_count; i++) {
338 char buf[AUDIO_LINE_SIZE];
339 int n = kernel_read(file, offset, buf,
340 AUDIO_LINE_SIZE);
409 341
410 if (vfs_read_retval < line_size) { 342 if (n < AUDIO_LINE_SIZE) {
411 pr_info("Done: exit %s() since no more bytes to read from Audio file\n", 343 pr_info("Done: exit %s() since no more bytes to read from Audio file\n",
412 __func__); 344 __func__);
413 break; 345 dev->_audiofile_status = END_OF_FILE;
414 } 346 fput(file);
347 return 0;
415 } 348 }
416 349
417 if (i > 0) 350 if (p)
418 dev->_audioframe_count++; 351 memcpy(p + offset, buf, n);
419 352
420 if (vfs_read_retval < line_size) 353 offset += n;
421 break;
422 } 354 }
423 355 dev->_audioframe_count++;
424 dev->_audiofile_status = (vfs_read_retval == line_size) ?
425 IN_PROGRESS : END_OF_FILE;
426
427 set_fs(old_fs);
428 myfile->f_pos = 0;
429 filp_close(myfile, NULL);
430 } 356 }
431 357 dev->_audiofile_status = IN_PROGRESS;
358 fput(file);
432 return 0; 359 return 0;
433} 360}
434 361
diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c
index eb822862a646..0e763a784e2b 100644
--- a/drivers/media/pci/ttpci/av7110_ir.c
+++ b/drivers/media/pci/ttpci/av7110_ir.c
@@ -375,7 +375,7 @@ int av7110_ir_init(struct av7110 *av7110)
375 if (av_cnt == 1) { 375 if (av_cnt == 1) {
376 e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops); 376 e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops);
377 if (e) 377 if (e)
378 e->size = 4 + 256 * sizeof(u16); 378 proc_set_size(e, 4 + 256 * sizeof(u16));
379 } 379 }
380 380
381 tasklet_init(&av7110->ir.ir_tasklet, av7110_emit_key, (unsigned long) &av7110->ir); 381 tasklet_init(&av7110->ir.ir_tasklet, av7110_emit_key, (unsigned long) &av7110->ir);
diff --git a/drivers/media/pci/zoran/zoran_procfs.c b/drivers/media/pci/zoran/zoran_procfs.c
index 1512b5d40533..f7ceee0cdefd 100644
--- a/drivers/media/pci/zoran/zoran_procfs.c
+++ b/drivers/media/pci/zoran/zoran_procfs.c
@@ -130,14 +130,14 @@ static int zoran_show(struct seq_file *p, void *v)
130 130
131static int zoran_open(struct inode *inode, struct file *file) 131static int zoran_open(struct inode *inode, struct file *file)
132{ 132{
133 struct zoran *data = PDE(inode)->data; 133 struct zoran *data = PDE_DATA(inode);
134 return single_open(file, zoran_show, data); 134 return single_open(file, zoran_show, data);
135} 135}
136 136
137static ssize_t zoran_write(struct file *file, const char __user *buffer, 137static ssize_t zoran_write(struct file *file, const char __user *buffer,
138 size_t count, loff_t *ppos) 138 size_t count, loff_t *ppos)
139{ 139{
140 struct zoran *zr = PDE(file_inode(file))->data; 140 struct zoran *zr = PDE_DATA(file_inode(file));
141 char *string, *sp; 141 char *string, *sp;
142 char *line, *ldelim, *varname, *svar, *tdelim; 142 char *line, *ldelim, *varname, *svar, *tdelim;
143 143
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index ff4d93d1907f..e4561264e124 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -307,7 +307,7 @@ static void ir_lirc_close(void *data)
307 return; 307 return;
308} 308}
309 309
310static struct file_operations lirc_fops = { 310static const struct file_operations lirc_fops = {
311 .owner = THIS_MODULE, 311 .owner = THIS_MODULE,
312 .write = ir_lirc_transmit_ir, 312 .write = ir_lirc_transmit_ir,
313 .unlocked_ioctl = ir_lirc_ioctl, 313 .unlocked_ioctl = ir_lirc_ioctl,
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index 5247d94fea29..8dc057b273f2 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -152,7 +152,7 @@ static int lirc_thread(void *irctl)
152} 152}
153 153
154 154
155static struct file_operations lirc_dev_fops = { 155static const struct file_operations lirc_dev_fops = {
156 .owner = THIS_MODULE, 156 .owner = THIS_MODULE,
157 .read = lirc_dev_fop_read, 157 .read = lirc_dev_fop_read,
158 .write = lirc_dev_fop_write, 158 .write = lirc_dev_fop_write,
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index fb69baa06ca8..767ff4d839f4 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -6656,7 +6656,7 @@ static int mpt_summary_proc_show(struct seq_file *m, void *v)
6656 6656
6657static int mpt_summary_proc_open(struct inode *inode, struct file *file) 6657static int mpt_summary_proc_open(struct inode *inode, struct file *file)
6658{ 6658{
6659 return single_open(file, mpt_summary_proc_show, PDE(inode)->data); 6659 return single_open(file, mpt_summary_proc_show, PDE_DATA(inode));
6660} 6660}
6661 6661
6662static const struct file_operations mpt_summary_proc_fops = { 6662static const struct file_operations mpt_summary_proc_fops = {
@@ -6805,7 +6805,7 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
6805 6805
6806static int mpt_iocinfo_proc_open(struct inode *inode, struct file *file) 6806static int mpt_iocinfo_proc_open(struct inode *inode, struct file *file)
6807{ 6807{
6808 return single_open(file, mpt_iocinfo_proc_show, PDE(inode)->data); 6808 return single_open(file, mpt_iocinfo_proc_show, PDE_DATA(inode));
6809} 6809}
6810 6810
6811static const struct file_operations mpt_iocinfo_proc_fops = { 6811static const struct file_operations mpt_iocinfo_proc_fops = {
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index b383b6961e59..dcc8385adeb3 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -597,13 +597,6 @@ mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
597} 597}
598 598
599static int 599static int
600mptctl_release(struct inode *inode, struct file *filep)
601{
602 fasync_helper(-1, filep, 0, &async_queue);
603 return 0;
604}
605
606static int
607mptctl_fasync(int fd, struct file *filep, int mode) 600mptctl_fasync(int fd, struct file *filep, int mode)
608{ 601{
609 MPT_ADAPTER *ioc; 602 MPT_ADAPTER *ioc;
@@ -2822,7 +2815,6 @@ static const struct file_operations mptctl_fops = {
2822 .llseek = no_llseek, 2815 .llseek = no_llseek,
2823 .fasync = mptctl_fasync, 2816 .fasync = mptctl_fasync,
2824 .unlocked_ioctl = mptctl_ioctl, 2817 .unlocked_ioctl = mptctl_ioctl,
2825 .release = mptctl_release,
2826#ifdef CONFIG_COMPAT 2818#ifdef CONFIG_COMPAT
2827 .compat_ioctl = compat_mpctl_ioctl, 2819 .compat_ioctl = compat_mpctl_ioctl,
2828#endif 2820#endif
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index c13cd9bc590b..fd75108c355e 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -109,7 +109,7 @@ static int mptfc_host_reset(struct scsi_cmnd *SCpnt);
109static struct scsi_host_template mptfc_driver_template = { 109static struct scsi_host_template mptfc_driver_template = {
110 .module = THIS_MODULE, 110 .module = THIS_MODULE,
111 .proc_name = "mptfc", 111 .proc_name = "mptfc",
112 .proc_info = mptscsih_proc_info, 112 .show_info = mptscsih_show_info,
113 .name = "MPT FC Host", 113 .name = "MPT FC Host",
114 .info = mptscsih_info, 114 .info = mptscsih_info,
115 .queuecommand = mptfc_qcmd, 115 .queuecommand = mptfc_qcmd,
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index fa43c391c8ed..ffee6f781e30 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1977,7 +1977,7 @@ done:
1977static struct scsi_host_template mptsas_driver_template = { 1977static struct scsi_host_template mptsas_driver_template = {
1978 .module = THIS_MODULE, 1978 .module = THIS_MODULE,
1979 .proc_name = "mptsas", 1979 .proc_name = "mptsas",
1980 .proc_info = mptscsih_proc_info, 1980 .show_info = mptscsih_show_info,
1981 .name = "MPT SAS Host", 1981 .name = "MPT SAS Host",
1982 .info = mptscsih_info, 1982 .info = mptscsih_info,
1983 .queuecommand = mptsas_qcmd, 1983 .queuecommand = mptsas_qcmd,
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 164afa71bba7..727819cc7034 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1284,101 +1284,17 @@ mptscsih_info(struct Scsi_Host *SChost)
1284 return h->info_kbuf; 1284 return h->info_kbuf;
1285} 1285}
1286 1286
1287struct info_str { 1287int mptscsih_show_info(struct seq_file *m, struct Scsi_Host *host)
1288 char *buffer;
1289 int length;
1290 int offset;
1291 int pos;
1292};
1293
1294static void
1295mptscsih_copy_mem_info(struct info_str *info, char *data, int len)
1296{
1297 if (info->pos + len > info->length)
1298 len = info->length - info->pos;
1299
1300 if (info->pos + len < info->offset) {
1301 info->pos += len;
1302 return;
1303 }
1304
1305 if (info->pos < info->offset) {
1306 data += (info->offset - info->pos);
1307 len -= (info->offset - info->pos);
1308 }
1309
1310 if (len > 0) {
1311 memcpy(info->buffer + info->pos, data, len);
1312 info->pos += len;
1313 }
1314}
1315
1316static int
1317mptscsih_copy_info(struct info_str *info, char *fmt, ...)
1318{
1319 va_list args;
1320 char buf[81];
1321 int len;
1322
1323 va_start(args, fmt);
1324 len = vsprintf(buf, fmt, args);
1325 va_end(args);
1326
1327 mptscsih_copy_mem_info(info, buf, len);
1328 return len;
1329}
1330
1331static int
1332mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len)
1333{
1334 struct info_str info;
1335
1336 info.buffer = pbuf;
1337 info.length = len;
1338 info.offset = offset;
1339 info.pos = 0;
1340
1341 mptscsih_copy_info(&info, "%s: %s, ", ioc->name, ioc->prod_name);
1342 mptscsih_copy_info(&info, "%s%08xh, ", MPT_FW_REV_MAGIC_ID_STRING, ioc->facts.FWVersion.Word);
1343 mptscsih_copy_info(&info, "Ports=%d, ", ioc->facts.NumberOfPorts);
1344 mptscsih_copy_info(&info, "MaxQ=%d\n", ioc->req_depth);
1345
1346 return ((info.pos > info.offset) ? info.pos - info.offset : 0);
1347}
1348
1349/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1350/**
1351 * mptscsih_proc_info - Return information about MPT adapter
1352 * @host: scsi host struct
1353 * @buffer: if write, user data; if read, buffer for user
1354 * @start: returns the buffer address
1355 * @offset: if write, 0; if read, the current offset into the buffer from
1356 * the previous read.
1357 * @length: if write, return length;
1358 * @func: write = 1; read = 0
1359 *
1360 * (linux scsi_host_template.info routine)
1361 */
1362int
1363mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
1364 int length, int func)
1365{ 1288{
1366 MPT_SCSI_HOST *hd = shost_priv(host); 1289 MPT_SCSI_HOST *hd = shost_priv(host);
1367 MPT_ADAPTER *ioc = hd->ioc; 1290 MPT_ADAPTER *ioc = hd->ioc;
1368 int size = 0;
1369 1291
1370 if (func) { 1292 seq_printf(m, "%s: %s, ", ioc->name, ioc->prod_name);
1371 /* 1293 seq_printf(m, "%s%08xh, ", MPT_FW_REV_MAGIC_ID_STRING, ioc->facts.FWVersion.Word);
1372 * write is not supported 1294 seq_printf(m, "Ports=%d, ", ioc->facts.NumberOfPorts);
1373 */ 1295 seq_printf(m, "MaxQ=%d\n", ioc->req_depth);
1374 } else {
1375 if (start)
1376 *start = buffer;
1377
1378 size = mptscsih_host_info(ioc, buffer, offset, length);
1379 }
1380 1296
1381 return size; 1297 return 0;
1382} 1298}
1383 1299
1384/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1300/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -3348,7 +3264,7 @@ EXPORT_SYMBOL(mptscsih_shutdown);
3348EXPORT_SYMBOL(mptscsih_suspend); 3264EXPORT_SYMBOL(mptscsih_suspend);
3349EXPORT_SYMBOL(mptscsih_resume); 3265EXPORT_SYMBOL(mptscsih_resume);
3350#endif 3266#endif
3351EXPORT_SYMBOL(mptscsih_proc_info); 3267EXPORT_SYMBOL(mptscsih_show_info);
3352EXPORT_SYMBOL(mptscsih_info); 3268EXPORT_SYMBOL(mptscsih_info);
3353EXPORT_SYMBOL(mptscsih_qcmd); 3269EXPORT_SYMBOL(mptscsih_qcmd);
3354EXPORT_SYMBOL(mptscsih_slave_destroy); 3270EXPORT_SYMBOL(mptscsih_slave_destroy);
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 43e75ff39921..83f503162f7a 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -111,7 +111,7 @@ extern void mptscsih_shutdown(struct pci_dev *);
111extern int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); 111extern int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state);
112extern int mptscsih_resume(struct pci_dev *pdev); 112extern int mptscsih_resume(struct pci_dev *pdev);
113#endif 113#endif
114extern int mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func); 114extern int mptscsih_show_info(struct seq_file *, struct Scsi_Host *);
115extern const char * mptscsih_info(struct Scsi_Host *SChost); 115extern const char * mptscsih_info(struct Scsi_Host *SChost);
116extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)); 116extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *));
117extern int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, 117extern int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel,
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index c3aabde2dc4f..5653e505f91f 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -831,7 +831,7 @@ static void mptspi_slave_destroy(struct scsi_device *sdev)
831static struct scsi_host_template mptspi_driver_template = { 831static struct scsi_host_template mptspi_driver_template = {
832 .module = THIS_MODULE, 832 .module = THIS_MODULE,
833 .proc_name = "mptspi", 833 .proc_name = "mptspi",
834 .proc_info = mptscsih_proc_info, 834 .show_info = mptscsih_show_info,
835 .name = "MPT SPI Host", 835 .name = "MPT SPI Host",
836 .info = mptscsih_info, 836 .info = mptscsih_info,
837 .queuecommand = mptspi_qcmd, 837 .queuecommand = mptspi_qcmd,
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
index 8001aa6bfb48..b7d87cd227a9 100644
--- a/drivers/message/i2o/i2o_proc.c
+++ b/drivers/message/i2o/i2o_proc.c
@@ -1599,98 +1599,98 @@ static int i2o_seq_show_sensors(struct seq_file *seq, void *v)
1599 1599
1600static int i2o_seq_open_hrt(struct inode *inode, struct file *file) 1600static int i2o_seq_open_hrt(struct inode *inode, struct file *file)
1601{ 1601{
1602 return single_open(file, i2o_seq_show_hrt, PDE(inode)->data); 1602 return single_open(file, i2o_seq_show_hrt, PDE_DATA(inode));
1603}; 1603};
1604 1604
1605static int i2o_seq_open_lct(struct inode *inode, struct file *file) 1605static int i2o_seq_open_lct(struct inode *inode, struct file *file)
1606{ 1606{
1607 return single_open(file, i2o_seq_show_lct, PDE(inode)->data); 1607 return single_open(file, i2o_seq_show_lct, PDE_DATA(inode));
1608}; 1608};
1609 1609
1610static int i2o_seq_open_status(struct inode *inode, struct file *file) 1610static int i2o_seq_open_status(struct inode *inode, struct file *file)
1611{ 1611{
1612 return single_open(file, i2o_seq_show_status, PDE(inode)->data); 1612 return single_open(file, i2o_seq_show_status, PDE_DATA(inode));
1613}; 1613};
1614 1614
1615static int i2o_seq_open_hw(struct inode *inode, struct file *file) 1615static int i2o_seq_open_hw(struct inode *inode, struct file *file)
1616{ 1616{
1617 return single_open(file, i2o_seq_show_hw, PDE(inode)->data); 1617 return single_open(file, i2o_seq_show_hw, PDE_DATA(inode));
1618}; 1618};
1619 1619
1620static int i2o_seq_open_ddm_table(struct inode *inode, struct file *file) 1620static int i2o_seq_open_ddm_table(struct inode *inode, struct file *file)
1621{ 1621{
1622 return single_open(file, i2o_seq_show_ddm_table, PDE(inode)->data); 1622 return single_open(file, i2o_seq_show_ddm_table, PDE_DATA(inode));
1623}; 1623};
1624 1624
1625static int i2o_seq_open_driver_store(struct inode *inode, struct file *file) 1625static int i2o_seq_open_driver_store(struct inode *inode, struct file *file)
1626{ 1626{
1627 return single_open(file, i2o_seq_show_driver_store, PDE(inode)->data); 1627 return single_open(file, i2o_seq_show_driver_store, PDE_DATA(inode));
1628}; 1628};
1629 1629
1630static int i2o_seq_open_drivers_stored(struct inode *inode, struct file *file) 1630static int i2o_seq_open_drivers_stored(struct inode *inode, struct file *file)
1631{ 1631{
1632 return single_open(file, i2o_seq_show_drivers_stored, PDE(inode)->data); 1632 return single_open(file, i2o_seq_show_drivers_stored, PDE_DATA(inode));
1633}; 1633};
1634 1634
1635static int i2o_seq_open_groups(struct inode *inode, struct file *file) 1635static int i2o_seq_open_groups(struct inode *inode, struct file *file)
1636{ 1636{
1637 return single_open(file, i2o_seq_show_groups, PDE(inode)->data); 1637 return single_open(file, i2o_seq_show_groups, PDE_DATA(inode));
1638}; 1638};
1639 1639
1640static int i2o_seq_open_phys_device(struct inode *inode, struct file *file) 1640static int i2o_seq_open_phys_device(struct inode *inode, struct file *file)
1641{ 1641{
1642 return single_open(file, i2o_seq_show_phys_device, PDE(inode)->data); 1642 return single_open(file, i2o_seq_show_phys_device, PDE_DATA(inode));
1643}; 1643};
1644 1644
1645static int i2o_seq_open_claimed(struct inode *inode, struct file *file) 1645static int i2o_seq_open_claimed(struct inode *inode, struct file *file)
1646{ 1646{
1647 return single_open(file, i2o_seq_show_claimed, PDE(inode)->data); 1647 return single_open(file, i2o_seq_show_claimed, PDE_DATA(inode));
1648}; 1648};
1649 1649
1650static int i2o_seq_open_users(struct inode *inode, struct file *file) 1650static int i2o_seq_open_users(struct inode *inode, struct file *file)
1651{ 1651{
1652 return single_open(file, i2o_seq_show_users, PDE(inode)->data); 1652 return single_open(file, i2o_seq_show_users, PDE_DATA(inode));
1653}; 1653};
1654 1654
1655static int i2o_seq_open_priv_msgs(struct inode *inode, struct file *file) 1655static int i2o_seq_open_priv_msgs(struct inode *inode, struct file *file)
1656{ 1656{
1657 return single_open(file, i2o_seq_show_priv_msgs, PDE(inode)->data); 1657 return single_open(file, i2o_seq_show_priv_msgs, PDE_DATA(inode));
1658}; 1658};
1659 1659
1660static int i2o_seq_open_authorized_users(struct inode *inode, struct file *file) 1660static int i2o_seq_open_authorized_users(struct inode *inode, struct file *file)
1661{ 1661{
1662 return single_open(file, i2o_seq_show_authorized_users, 1662 return single_open(file, i2o_seq_show_authorized_users,
1663 PDE(inode)->data); 1663 PDE_DATA(inode));
1664}; 1664};
1665 1665
1666static int i2o_seq_open_dev_identity(struct inode *inode, struct file *file) 1666static int i2o_seq_open_dev_identity(struct inode *inode, struct file *file)
1667{ 1667{
1668 return single_open(file, i2o_seq_show_dev_identity, PDE(inode)->data); 1668 return single_open(file, i2o_seq_show_dev_identity, PDE_DATA(inode));
1669}; 1669};
1670 1670
1671static int i2o_seq_open_ddm_identity(struct inode *inode, struct file *file) 1671static int i2o_seq_open_ddm_identity(struct inode *inode, struct file *file)
1672{ 1672{
1673 return single_open(file, i2o_seq_show_ddm_identity, PDE(inode)->data); 1673 return single_open(file, i2o_seq_show_ddm_identity, PDE_DATA(inode));
1674}; 1674};
1675 1675
1676static int i2o_seq_open_uinfo(struct inode *inode, struct file *file) 1676static int i2o_seq_open_uinfo(struct inode *inode, struct file *file)
1677{ 1677{
1678 return single_open(file, i2o_seq_show_uinfo, PDE(inode)->data); 1678 return single_open(file, i2o_seq_show_uinfo, PDE_DATA(inode));
1679}; 1679};
1680 1680
1681static int i2o_seq_open_sgl_limits(struct inode *inode, struct file *file) 1681static int i2o_seq_open_sgl_limits(struct inode *inode, struct file *file)
1682{ 1682{
1683 return single_open(file, i2o_seq_show_sgl_limits, PDE(inode)->data); 1683 return single_open(file, i2o_seq_show_sgl_limits, PDE_DATA(inode));
1684}; 1684};
1685 1685
1686static int i2o_seq_open_sensors(struct inode *inode, struct file *file) 1686static int i2o_seq_open_sensors(struct inode *inode, struct file *file)
1687{ 1687{
1688 return single_open(file, i2o_seq_show_sensors, PDE(inode)->data); 1688 return single_open(file, i2o_seq_show_sensors, PDE_DATA(inode));
1689}; 1689};
1690 1690
1691static int i2o_seq_open_dev_name(struct inode *inode, struct file *file) 1691static int i2o_seq_open_dev_name(struct inode *inode, struct file *file)
1692{ 1692{
1693 return single_open(file, i2o_seq_show_dev_name, PDE(inode)->data); 1693 return single_open(file, i2o_seq_show_dev_name, PDE_DATA(inode));
1694}; 1694};
1695 1695
1696static const struct file_operations i2o_seq_fops_lct = { 1696static const struct file_operations i2o_seq_fops_lct = {
@@ -1895,25 +1895,6 @@ static int i2o_proc_create_entries(struct proc_dir_entry *dir,
1895} 1895}
1896 1896
1897/** 1897/**
1898 * i2o_proc_subdir_remove - Remove child entries from a proc entry
1899 * @dir: proc dir entry from which the childs should be removed
1900 *
1901 * Iterate over each i2o proc entry under dir and remove it. If the child
1902 * also has entries, remove them too.
1903 */
1904static void i2o_proc_subdir_remove(struct proc_dir_entry *dir)
1905{
1906 struct proc_dir_entry *pe, *tmp;
1907 pe = dir->subdir;
1908 while (pe) {
1909 tmp = pe->next;
1910 i2o_proc_subdir_remove(pe);
1911 remove_proc_entry(pe->name, dir);
1912 pe = tmp;
1913 }
1914};
1915
1916/**
1917 * i2o_proc_device_add - Add an I2O device to the proc dir 1898 * i2o_proc_device_add - Add an I2O device to the proc dir
1918 * @dir: proc dir entry to which the device should be added 1899 * @dir: proc dir entry to which the device should be added
1919 * @dev: I2O device which should be added 1900 * @dev: I2O device which should be added
@@ -1932,14 +1913,12 @@ static void i2o_proc_device_add(struct proc_dir_entry *dir,
1932 1913
1933 osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff); 1914 osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff);
1934 1915
1935 devdir = proc_mkdir(buff, dir); 1916 devdir = proc_mkdir_data(buff, 0, dir, dev);
1936 if (!devdir) { 1917 if (!devdir) {
1937 osm_warn("Could not allocate procdir!\n"); 1918 osm_warn("Could not allocate procdir!\n");
1938 return; 1919 return;
1939 } 1920 }
1940 1921
1941 devdir->data = dev;
1942
1943 i2o_proc_create_entries(devdir, generic_dev_entries, dev); 1922 i2o_proc_create_entries(devdir, generic_dev_entries, dev);
1944 1923
1945 /* Inform core that we want updates about this device's status */ 1924 /* Inform core that we want updates about this device's status */
@@ -1973,12 +1952,10 @@ static int i2o_proc_iop_add(struct proc_dir_entry *dir,
1973 1952
1974 osm_debug("adding IOP /proc/i2o/%s\n", c->name); 1953 osm_debug("adding IOP /proc/i2o/%s\n", c->name);
1975 1954
1976 iopdir = proc_mkdir(c->name, dir); 1955 iopdir = proc_mkdir_data(c->name, 0, dir, c);
1977 if (!iopdir) 1956 if (!iopdir)
1978 return -1; 1957 return -1;
1979 1958
1980 iopdir->data = c;
1981
1982 i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c); 1959 i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c);
1983 1960
1984 list_for_each_entry(dev, &c->devices, list) 1961 list_for_each_entry(dev, &c->devices, list)
@@ -1988,31 +1965,6 @@ static int i2o_proc_iop_add(struct proc_dir_entry *dir,
1988} 1965}
1989 1966
1990/** 1967/**
1991 * i2o_proc_iop_remove - Removes an I2O controller from the i2o proc tree
1992 * @dir: parent proc dir entry
1993 * @c: I2O controller which should be removed
1994 *
1995 * Iterate over each i2o proc entry and search controller c. If it is found
1996 * remove it from the tree.
1997 */
1998static void i2o_proc_iop_remove(struct proc_dir_entry *dir,
1999 struct i2o_controller *c)
2000{
2001 struct proc_dir_entry *pe, *tmp;
2002
2003 pe = dir->subdir;
2004 while (pe) {
2005 tmp = pe->next;
2006 if (pe->data == c) {
2007 i2o_proc_subdir_remove(pe);
2008 remove_proc_entry(pe->name, dir);
2009 }
2010 osm_debug("removing IOP /proc/i2o/%s\n", c->name);
2011 pe = tmp;
2012 }
2013}
2014
2015/**
2016 * i2o_proc_fs_create - Create the i2o proc fs. 1968 * i2o_proc_fs_create - Create the i2o proc fs.
2017 * 1969 *
2018 * Iterate over each I2O controller and create the entries for it. 1970 * Iterate over each I2O controller and create the entries for it.
@@ -2042,12 +1994,7 @@ static int __init i2o_proc_fs_create(void)
2042 */ 1994 */
2043static int __exit i2o_proc_fs_destroy(void) 1995static int __exit i2o_proc_fs_destroy(void)
2044{ 1996{
2045 struct i2o_controller *c; 1997 remove_proc_subtree("i2o", NULL);
2046
2047 list_for_each_entry(c, &i2o_controllers, list)
2048 i2o_proc_iop_remove(i2o_proc_dir_root, c);
2049
2050 remove_proc_entry("i2o", NULL);
2051 1998
2052 return 0; 1999 return 0;
2053}; 2000};
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
index 4a87e5c0a320..4cd4a3d2a76a 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
@@ -593,7 +593,6 @@ static int lis3lv02d_misc_release(struct inode *inode, struct file *file)
593 struct lis3lv02d *lis3 = container_of(file->private_data, 593 struct lis3lv02d *lis3 = container_of(file->private_data,
594 struct lis3lv02d, miscdev); 594 struct lis3lv02d, miscdev);
595 595
596 fasync_helper(-1, file, 0, &lis3->async_queue);
597 clear_bit(0, &lis3->misc_opened); /* release the device */ 596 clear_bit(0, &lis3->misc_opened); /* release the device */
598 if (lis3->pm_dev) 597 if (lis3->pm_dev)
599 pm_runtime_put(lis3->pm_dev); 598 pm_runtime_put(lis3->pm_dev);
diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
index 950dbe9ecb36..797d7962cc88 100644
--- a/drivers/misc/sgi-gru/gruprocfs.c
+++ b/drivers/misc/sgi-gru/gruprocfs.c
@@ -355,7 +355,7 @@ static void delete_proc_files(void)
355 for (p = proc_files; p->name; p++) 355 for (p = proc_files; p->name; p++)
356 if (p->entry) 356 if (p->entry)
357 remove_proc_entry(p->name, proc_gru); 357 remove_proc_entry(p->name, proc_gru);
358 remove_proc_entry("gru", proc_gru->parent); 358 proc_remove(proc_gru);
359 } 359 }
360} 360}
361 361
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 61d5f56473e1..322ca65b0cc5 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -36,6 +36,7 @@
36#include <linux/idr.h> 36#include <linux/idr.h>
37#include <linux/backing-dev.h> 37#include <linux/backing-dev.h>
38#include <linux/gfp.h> 38#include <linux/gfp.h>
39#include <linux/slab.h>
39 40
40#include <linux/mtd/mtd.h> 41#include <linux/mtd/mtd.h>
41#include <linux/mtd/partitions.h> 42#include <linux/mtd/partitions.h>
diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c
index 3cea38d37344..94d06f1307b8 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -218,15 +218,13 @@ static const struct seq_operations bond_info_seq_ops = {
218static int bond_info_open(struct inode *inode, struct file *file) 218static int bond_info_open(struct inode *inode, struct file *file)
219{ 219{
220 struct seq_file *seq; 220 struct seq_file *seq;
221 struct proc_dir_entry *proc;
222 int res; 221 int res;
223 222
224 res = seq_open(file, &bond_info_seq_ops); 223 res = seq_open(file, &bond_info_seq_ops);
225 if (!res) { 224 if (!res) {
226 /* recover the pointer buried in proc_dir_entry data */ 225 /* recover the pointer buried in proc_dir_entry data */
227 seq = file->private_data; 226 seq = file->private_data;
228 proc = PDE(inode); 227 seq->private = PDE_DATA(inode);
229 seq->private = proc->data;
230 } 228 }
231 229
232 return res; 230 return res;
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index 2f99f8881dfc..5f4758492e4c 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -383,7 +383,7 @@ static int vlsi_seq_show(struct seq_file *seq, void *v)
383 383
384static int vlsi_seq_open(struct inode *inode, struct file *file) 384static int vlsi_seq_open(struct inode *inode, struct file *file)
385{ 385{
386 return single_open(file, vlsi_seq_show, PDE(inode)->data); 386 return single_open(file, vlsi_seq_show, PDE_DATA(inode));
387} 387}
388 388
389static const struct file_operations vlsi_proc_fops = { 389static const struct file_operations vlsi_proc_fops = {
@@ -1678,7 +1678,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1678 IRDA_WARNING("%s: failed to create proc entry\n", 1678 IRDA_WARNING("%s: failed to create proc entry\n",
1679 __func__); 1679 __func__);
1680 } else { 1680 } else {
1681 ent->size = 0; 1681 proc_set_size(ent, 0);
1682 } 1682 }
1683 idev->proc_entry = ent; 1683 idev->proc_entry = ent;
1684 } 1684 }
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 53295418f576..6125adb520a3 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -4506,108 +4506,75 @@ static int setup_proc_entry( struct net_device *dev,
4506 apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm, 4506 apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm,
4507 airo_entry); 4507 airo_entry);
4508 if (!apriv->proc_entry) 4508 if (!apriv->proc_entry)
4509 goto fail; 4509 return -ENOMEM;
4510 apriv->proc_entry->uid = proc_kuid; 4510 proc_set_user(apriv->proc_entry, proc_kuid, proc_kgid);
4511 apriv->proc_entry->gid = proc_kgid;
4512 4511
4513 /* Setup the StatsDelta */ 4512 /* Setup the StatsDelta */
4514 entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm, 4513 entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm,
4515 apriv->proc_entry, &proc_statsdelta_ops, dev); 4514 apriv->proc_entry, &proc_statsdelta_ops, dev);
4516 if (!entry) 4515 if (!entry)
4517 goto fail_stats_delta; 4516 goto fail;
4518 entry->uid = proc_kuid; 4517 proc_set_user(entry, proc_kuid, proc_kgid);
4519 entry->gid = proc_kgid;
4520 4518
4521 /* Setup the Stats */ 4519 /* Setup the Stats */
4522 entry = proc_create_data("Stats", S_IRUGO & proc_perm, 4520 entry = proc_create_data("Stats", S_IRUGO & proc_perm,
4523 apriv->proc_entry, &proc_stats_ops, dev); 4521 apriv->proc_entry, &proc_stats_ops, dev);
4524 if (!entry) 4522 if (!entry)
4525 goto fail_stats; 4523 goto fail;
4526 entry->uid = proc_kuid; 4524 proc_set_user(entry, proc_kuid, proc_kgid);
4527 entry->gid = proc_kgid;
4528 4525
4529 /* Setup the Status */ 4526 /* Setup the Status */
4530 entry = proc_create_data("Status", S_IRUGO & proc_perm, 4527 entry = proc_create_data("Status", S_IRUGO & proc_perm,
4531 apriv->proc_entry, &proc_status_ops, dev); 4528 apriv->proc_entry, &proc_status_ops, dev);
4532 if (!entry) 4529 if (!entry)
4533 goto fail_status; 4530 goto fail;
4534 entry->uid = proc_kuid; 4531 proc_set_user(entry, proc_kuid, proc_kgid);
4535 entry->gid = proc_kgid;
4536 4532
4537 /* Setup the Config */ 4533 /* Setup the Config */
4538 entry = proc_create_data("Config", proc_perm, 4534 entry = proc_create_data("Config", proc_perm,
4539 apriv->proc_entry, &proc_config_ops, dev); 4535 apriv->proc_entry, &proc_config_ops, dev);
4540 if (!entry) 4536 if (!entry)
4541 goto fail_config; 4537 goto fail;
4542 entry->uid = proc_kuid; 4538 proc_set_user(entry, proc_kuid, proc_kgid);
4543 entry->gid = proc_kgid;
4544 4539
4545 /* Setup the SSID */ 4540 /* Setup the SSID */
4546 entry = proc_create_data("SSID", proc_perm, 4541 entry = proc_create_data("SSID", proc_perm,
4547 apriv->proc_entry, &proc_SSID_ops, dev); 4542 apriv->proc_entry, &proc_SSID_ops, dev);
4548 if (!entry) 4543 if (!entry)
4549 goto fail_ssid; 4544 goto fail;
4550 entry->uid = proc_kuid; 4545 proc_set_user(entry, proc_kuid, proc_kgid);
4551 entry->gid = proc_kgid;
4552 4546
4553 /* Setup the APList */ 4547 /* Setup the APList */
4554 entry = proc_create_data("APList", proc_perm, 4548 entry = proc_create_data("APList", proc_perm,
4555 apriv->proc_entry, &proc_APList_ops, dev); 4549 apriv->proc_entry, &proc_APList_ops, dev);
4556 if (!entry) 4550 if (!entry)
4557 goto fail_aplist; 4551 goto fail;
4558 entry->uid = proc_kuid; 4552 proc_set_user(entry, proc_kuid, proc_kgid);
4559 entry->gid = proc_kgid;
4560 4553
4561 /* Setup the BSSList */ 4554 /* Setup the BSSList */
4562 entry = proc_create_data("BSSList", proc_perm, 4555 entry = proc_create_data("BSSList", proc_perm,
4563 apriv->proc_entry, &proc_BSSList_ops, dev); 4556 apriv->proc_entry, &proc_BSSList_ops, dev);
4564 if (!entry) 4557 if (!entry)
4565 goto fail_bsslist; 4558 goto fail;
4566 entry->uid = proc_kuid; 4559 proc_set_user(entry, proc_kuid, proc_kgid);
4567 entry->gid = proc_kgid;
4568 4560
4569 /* Setup the WepKey */ 4561 /* Setup the WepKey */
4570 entry = proc_create_data("WepKey", proc_perm, 4562 entry = proc_create_data("WepKey", proc_perm,
4571 apriv->proc_entry, &proc_wepkey_ops, dev); 4563 apriv->proc_entry, &proc_wepkey_ops, dev);
4572 if (!entry) 4564 if (!entry)
4573 goto fail_wepkey; 4565 goto fail;
4574 entry->uid = proc_kuid; 4566 proc_set_user(entry, proc_kuid, proc_kgid);
4575 entry->gid = proc_kgid;
4576
4577 return 0; 4567 return 0;
4578 4568
4579fail_wepkey:
4580 remove_proc_entry("BSSList", apriv->proc_entry);
4581fail_bsslist:
4582 remove_proc_entry("APList", apriv->proc_entry);
4583fail_aplist:
4584 remove_proc_entry("SSID", apriv->proc_entry);
4585fail_ssid:
4586 remove_proc_entry("Config", apriv->proc_entry);
4587fail_config:
4588 remove_proc_entry("Status", apriv->proc_entry);
4589fail_status:
4590 remove_proc_entry("Stats", apriv->proc_entry);
4591fail_stats:
4592 remove_proc_entry("StatsDelta", apriv->proc_entry);
4593fail_stats_delta:
4594 remove_proc_entry(apriv->proc_name, airo_entry);
4595fail: 4569fail:
4570 remove_proc_subtree(apriv->proc_name, airo_entry);
4596 return -ENOMEM; 4571 return -ENOMEM;
4597} 4572}
4598 4573
4599static int takedown_proc_entry( struct net_device *dev, 4574static int takedown_proc_entry( struct net_device *dev,
4600 struct airo_info *apriv ) { 4575 struct airo_info *apriv )
4601 if ( !apriv->proc_entry->namelen ) return 0; 4576{
4602 remove_proc_entry("Stats",apriv->proc_entry); 4577 remove_proc_subtree(apriv->proc_name, airo_entry);
4603 remove_proc_entry("StatsDelta",apriv->proc_entry);
4604 remove_proc_entry("Status",apriv->proc_entry);
4605 remove_proc_entry("Config",apriv->proc_entry);
4606 remove_proc_entry("SSID",apriv->proc_entry);
4607 remove_proc_entry("APList",apriv->proc_entry);
4608 remove_proc_entry("BSSList",apriv->proc_entry);
4609 remove_proc_entry("WepKey",apriv->proc_entry);
4610 remove_proc_entry(apriv->proc_name,airo_entry);
4611 return 0; 4578 return 0;
4612} 4579}
4613 4580
@@ -4663,8 +4630,7 @@ static ssize_t proc_write( struct file *file,
4663static int proc_status_open(struct inode *inode, struct file *file) 4630static int proc_status_open(struct inode *inode, struct file *file)
4664{ 4631{
4665 struct proc_data *data; 4632 struct proc_data *data;
4666 struct proc_dir_entry *dp = PDE(inode); 4633 struct net_device *dev = PDE_DATA(inode);
4667 struct net_device *dev = dp->data;
4668 struct airo_info *apriv = dev->ml_priv; 4634 struct airo_info *apriv = dev->ml_priv;
4669 CapabilityRid cap_rid; 4635 CapabilityRid cap_rid;
4670 StatusRid status_rid; 4636 StatusRid status_rid;
@@ -4746,8 +4712,7 @@ static int proc_stats_rid_open( struct inode *inode,
4746 u16 rid ) 4712 u16 rid )
4747{ 4713{
4748 struct proc_data *data; 4714 struct proc_data *data;
4749 struct proc_dir_entry *dp = PDE(inode); 4715 struct net_device *dev = PDE_DATA(inode);
4750 struct net_device *dev = dp->data;
4751 struct airo_info *apriv = dev->ml_priv; 4716 struct airo_info *apriv = dev->ml_priv;
4752 StatsRid stats; 4717 StatsRid stats;
4753 int i, j; 4718 int i, j;
@@ -4809,8 +4774,7 @@ static inline int sniffing_mode(struct airo_info *ai)
4809static void proc_config_on_close(struct inode *inode, struct file *file) 4774static void proc_config_on_close(struct inode *inode, struct file *file)
4810{ 4775{
4811 struct proc_data *data = file->private_data; 4776 struct proc_data *data = file->private_data;
4812 struct proc_dir_entry *dp = PDE(inode); 4777 struct net_device *dev = PDE_DATA(inode);
4813 struct net_device *dev = dp->data;
4814 struct airo_info *ai = dev->ml_priv; 4778 struct airo_info *ai = dev->ml_priv;
4815 char *line; 4779 char *line;
4816 4780
@@ -5021,8 +4985,7 @@ static const char *get_rmode(__le16 mode)
5021static int proc_config_open(struct inode *inode, struct file *file) 4985static int proc_config_open(struct inode *inode, struct file *file)
5022{ 4986{
5023 struct proc_data *data; 4987 struct proc_data *data;
5024 struct proc_dir_entry *dp = PDE(inode); 4988 struct net_device *dev = PDE_DATA(inode);
5025 struct net_device *dev = dp->data;
5026 struct airo_info *ai = dev->ml_priv; 4989 struct airo_info *ai = dev->ml_priv;
5027 int i; 4990 int i;
5028 __le16 mode; 4991 __le16 mode;
@@ -5112,8 +5075,7 @@ static int proc_config_open(struct inode *inode, struct file *file)
5112static void proc_SSID_on_close(struct inode *inode, struct file *file) 5075static void proc_SSID_on_close(struct inode *inode, struct file *file)
5113{ 5076{
5114 struct proc_data *data = file->private_data; 5077 struct proc_data *data = file->private_data;
5115 struct proc_dir_entry *dp = PDE(inode); 5078 struct net_device *dev = PDE_DATA(inode);
5116 struct net_device *dev = dp->data;
5117 struct airo_info *ai = dev->ml_priv; 5079 struct airo_info *ai = dev->ml_priv;
5118 SsidRid SSID_rid; 5080 SsidRid SSID_rid;
5119 int i; 5081 int i;
@@ -5148,8 +5110,7 @@ static void proc_SSID_on_close(struct inode *inode, struct file *file)
5148 5110
5149static void proc_APList_on_close( struct inode *inode, struct file *file ) { 5111static void proc_APList_on_close( struct inode *inode, struct file *file ) {
5150 struct proc_data *data = file->private_data; 5112 struct proc_data *data = file->private_data;
5151 struct proc_dir_entry *dp = PDE(inode); 5113 struct net_device *dev = PDE_DATA(inode);
5152 struct net_device *dev = dp->data;
5153 struct airo_info *ai = dev->ml_priv; 5114 struct airo_info *ai = dev->ml_priv;
5154 APListRid APList_rid; 5115 APListRid APList_rid;
5155 int i; 5116 int i;
@@ -5283,8 +5244,7 @@ static int set_wep_tx_idx(struct airo_info *ai, u16 index, int perm, int lock)
5283 5244
5284static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { 5245static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
5285 struct proc_data *data; 5246 struct proc_data *data;
5286 struct proc_dir_entry *dp = PDE(inode); 5247 struct net_device *dev = PDE_DATA(inode);
5287 struct net_device *dev = dp->data;
5288 struct airo_info *ai = dev->ml_priv; 5248 struct airo_info *ai = dev->ml_priv;
5289 int i, rc; 5249 int i, rc;
5290 char key[16]; 5250 char key[16];
@@ -5335,8 +5295,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
5335static int proc_wepkey_open( struct inode *inode, struct file *file ) 5295static int proc_wepkey_open( struct inode *inode, struct file *file )
5336{ 5296{
5337 struct proc_data *data; 5297 struct proc_data *data;
5338 struct proc_dir_entry *dp = PDE(inode); 5298 struct net_device *dev = PDE_DATA(inode);
5339 struct net_device *dev = dp->data;
5340 struct airo_info *ai = dev->ml_priv; 5299 struct airo_info *ai = dev->ml_priv;
5341 char *ptr; 5300 char *ptr;
5342 WepKeyRid wkr; 5301 WepKeyRid wkr;
@@ -5384,8 +5343,7 @@ static int proc_wepkey_open( struct inode *inode, struct file *file )
5384static int proc_SSID_open(struct inode *inode, struct file *file) 5343static int proc_SSID_open(struct inode *inode, struct file *file)
5385{ 5344{
5386 struct proc_data *data; 5345 struct proc_data *data;
5387 struct proc_dir_entry *dp = PDE(inode); 5346 struct net_device *dev = PDE_DATA(inode);
5388 struct net_device *dev = dp->data;
5389 struct airo_info *ai = dev->ml_priv; 5347 struct airo_info *ai = dev->ml_priv;
5390 int i; 5348 int i;
5391 char *ptr; 5349 char *ptr;
@@ -5428,8 +5386,7 @@ static int proc_SSID_open(struct inode *inode, struct file *file)
5428 5386
5429static int proc_APList_open( struct inode *inode, struct file *file ) { 5387static int proc_APList_open( struct inode *inode, struct file *file ) {
5430 struct proc_data *data; 5388 struct proc_data *data;
5431 struct proc_dir_entry *dp = PDE(inode); 5389 struct net_device *dev = PDE_DATA(inode);
5432 struct net_device *dev = dp->data;
5433 struct airo_info *ai = dev->ml_priv; 5390 struct airo_info *ai = dev->ml_priv;
5434 int i; 5391 int i;
5435 char *ptr; 5392 char *ptr;
@@ -5468,8 +5425,7 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
5468 5425
5469static int proc_BSSList_open( struct inode *inode, struct file *file ) { 5426static int proc_BSSList_open( struct inode *inode, struct file *file ) {
5470 struct proc_data *data; 5427 struct proc_data *data;
5471 struct proc_dir_entry *dp = PDE(inode); 5428 struct net_device *dev = PDE_DATA(inode);
5472 struct net_device *dev = dp->data;
5473 struct airo_info *ai = dev->ml_priv; 5429 struct airo_info *ai = dev->ml_priv;
5474 char *ptr; 5430 char *ptr;
5475 BSSListRid BSSList_rid; 5431 BSSListRid BSSList_rid;
@@ -5706,10 +5662,8 @@ static int __init airo_init_module( void )
5706 5662
5707 airo_entry = proc_mkdir_mode("driver/aironet", airo_perm, NULL); 5663 airo_entry = proc_mkdir_mode("driver/aironet", airo_perm, NULL);
5708 5664
5709 if (airo_entry) { 5665 if (airo_entry)
5710 airo_entry->uid = proc_kuid; 5666 proc_set_user(airo_entry, proc_kuid, proc_kgid);
5711 airo_entry->gid = proc_kgid;
5712 }
5713 5667
5714 for (i = 0; i < 4 && io[i] && irq[i]; i++) { 5668 for (i = 0; i < 4 && io[i] && irq[i]; i++) {
5715 airo_print_info("", "Trying to configure ISA adapter at irq=%d " 5669 airo_print_info("", "Trying to configure ISA adapter at irq=%d "
diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
index 4be07f5e22b9..727b1f53e6ad 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -216,7 +216,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get,
216 wil_debugfs_iomem_x32_set, "0x%08llx\n"); 216 wil_debugfs_iomem_x32_set, "0x%08llx\n");
217 217
218static struct dentry *wil_debugfs_create_iomem_x32(const char *name, 218static struct dentry *wil_debugfs_create_iomem_x32(const char *name,
219 mode_t mode, 219 umode_t mode,
220 struct dentry *parent, 220 struct dentry *parent,
221 void __iomem *value) 221 void __iomem *value)
222{ 222{
@@ -359,7 +359,7 @@ static const struct file_operations fops_ioblob = {
359 359
360static 360static
361struct dentry *wil_debugfs_create_ioblob(const char *name, 361struct dentry *wil_debugfs_create_ioblob(const char *name,
362 mode_t mode, 362 umode_t mode,
363 struct dentry *parent, 363 struct dentry *parent,
364 struct debugfs_blob_wrapper *blob) 364 struct debugfs_blob_wrapper *blob)
365{ 365{
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 4374079dfc2a..23a3498f14d4 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -63,6 +63,7 @@
63#include <net/iw_handler.h> 63#include <net/iw_handler.h>
64#include <linux/crc32.h> 64#include <linux/crc32.h>
65#include <linux/proc_fs.h> 65#include <linux/proc_fs.h>
66#include <linux/seq_file.h>
66#include <linux/device.h> 67#include <linux/device.h>
67#include <linux/moduleparam.h> 68#include <linux/moduleparam.h>
68#include <linux/firmware.h> 69#include <linux/firmware.h>
@@ -1409,30 +1410,28 @@ static int atmel_validate_channel(struct atmel_private *priv, int channel)
1409 return 0; 1410 return 0;
1410} 1411}
1411 1412
1412static int atmel_proc_output (char *buf, struct atmel_private *priv) 1413static int atmel_proc_show(struct seq_file *m, void *v)
1413{ 1414{
1415 struct atmel_private *priv = m->private;
1414 int i; 1416 int i;
1415 char *p = buf;
1416 char *s, *r, *c; 1417 char *s, *r, *c;
1417 1418
1418 p += sprintf(p, "Driver version:\t\t%d.%d\n", 1419 seq_printf(m, "Driver version:\t\t%d.%d\n", DRIVER_MAJOR, DRIVER_MINOR);
1419 DRIVER_MAJOR, DRIVER_MINOR);
1420 1420
1421 if (priv->station_state != STATION_STATE_DOWN) { 1421 if (priv->station_state != STATION_STATE_DOWN) {
1422 p += sprintf(p, "Firmware version:\t%d.%d build %d\n" 1422 seq_printf(m,
1423 "Firmware location:\t", 1423 "Firmware version:\t%d.%d build %d\n"
1424 priv->host_info.major_version, 1424 "Firmware location:\t",
1425 priv->host_info.minor_version, 1425 priv->host_info.major_version,
1426 priv->host_info.build_version); 1426 priv->host_info.minor_version,
1427 priv->host_info.build_version);
1427 1428
1428 if (priv->card_type != CARD_TYPE_EEPROM) 1429 if (priv->card_type != CARD_TYPE_EEPROM)
1429 p += sprintf(p, "on card\n"); 1430 seq_puts(m, "on card\n");
1430 else if (priv->firmware) 1431 else if (priv->firmware)
1431 p += sprintf(p, "%s loaded by host\n", 1432 seq_printf(m, "%s loaded by host\n", priv->firmware_id);
1432 priv->firmware_id);
1433 else 1433 else
1434 p += sprintf(p, "%s loaded by hotplug\n", 1434 seq_printf(m, "%s loaded by hotplug\n", priv->firmware_id);
1435 priv->firmware_id);
1436 1435
1437 switch (priv->card_type) { 1436 switch (priv->card_type) {
1438 case CARD_TYPE_PARALLEL_FLASH: 1437 case CARD_TYPE_PARALLEL_FLASH:
@@ -1453,12 +1452,12 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv)
1453 if (priv->reg_domain == channel_table[i].reg_domain) 1452 if (priv->reg_domain == channel_table[i].reg_domain)
1454 r = channel_table[i].name; 1453 r = channel_table[i].name;
1455 1454
1456 p += sprintf(p, "MAC memory type:\t%s\n", c); 1455 seq_printf(m, "MAC memory type:\t%s\n", c);
1457 p += sprintf(p, "Regulatory domain:\t%s\n", r); 1456 seq_printf(m, "Regulatory domain:\t%s\n", r);
1458 p += sprintf(p, "Host CRC checking:\t%s\n", 1457 seq_printf(m, "Host CRC checking:\t%s\n",
1459 priv->do_rx_crc ? "On" : "Off"); 1458 priv->do_rx_crc ? "On" : "Off");
1460 p += sprintf(p, "WPA-capable firmware:\t%s\n", 1459 seq_printf(m, "WPA-capable firmware:\t%s\n",
1461 priv->use_wpa ? "Yes" : "No"); 1460 priv->use_wpa ? "Yes" : "No");
1462 } 1461 }
1463 1462
1464 switch (priv->station_state) { 1463 switch (priv->station_state) {
@@ -1490,26 +1489,22 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv)
1490 s = "<unknown>"; 1489 s = "<unknown>";
1491 } 1490 }
1492 1491
1493 p += sprintf(p, "Current state:\t\t%s\n", s); 1492 seq_printf(m, "Current state:\t\t%s\n", s);
1494 return p - buf; 1493 return 0;
1495} 1494}
1496 1495
1497static int atmel_read_proc(char *page, char **start, off_t off, 1496static int atmel_proc_open(struct inode *inode, struct file *file)
1498 int count, int *eof, void *data)
1499{ 1497{
1500 struct atmel_private *priv = data; 1498 return single_open(file, atmel_proc_show, PDE_DATA(inode));
1501 int len = atmel_proc_output (page, priv);
1502 if (len <= off+count)
1503 *eof = 1;
1504 *start = page + off;
1505 len -= off;
1506 if (len > count)
1507 len = count;
1508 if (len < 0)
1509 len = 0;
1510 return len;
1511} 1499}
1512 1500
1501static const struct file_operations atmel_proc_fops = {
1502 .open = atmel_proc_open,
1503 .read = seq_read,
1504 .llseek = seq_lseek,
1505 .release = seq_release,
1506};
1507
1513static const struct net_device_ops atmel_netdev_ops = { 1508static const struct net_device_ops atmel_netdev_ops = {
1514 .ndo_open = atmel_open, 1509 .ndo_open = atmel_open,
1515 .ndo_stop = atmel_close, 1510 .ndo_stop = atmel_close,
@@ -1525,7 +1520,6 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
1525 struct device *sys_dev, 1520 struct device *sys_dev,
1526 int (*card_present)(void *), void *card) 1521 int (*card_present)(void *), void *card)
1527{ 1522{
1528 struct proc_dir_entry *ent;
1529 struct net_device *dev; 1523 struct net_device *dev;
1530 struct atmel_private *priv; 1524 struct atmel_private *priv;
1531 int rc; 1525 int rc;
@@ -1630,8 +1624,7 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
1630 1624
1631 netif_carrier_off(dev); 1625 netif_carrier_off(dev);
1632 1626
1633 ent = create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv); 1627 if (!proc_create_data("driver/atmel", 0, NULL, &atmel_proc_fops, priv));
1634 if (!ent)
1635 printk(KERN_WARNING "atmel: unable to create /proc entry.\n"); 1628 printk(KERN_WARNING "atmel: unable to create /proc entry.\n");
1636 1629
1637 printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %pM\n", 1630 printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %pM\n",
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index dd9a18f8dbca..19c45e363aa7 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/seq_file.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
21#include <linux/random.h> 22#include <linux/random.h>
22#include <linux/if_arp.h> 23#include <linux/if_arp.h>
@@ -64,28 +65,32 @@ static void prism2_send_mgmt(struct net_device *dev,
64 65
65 66
66#ifndef PRISM2_NO_PROCFS_DEBUG 67#ifndef PRISM2_NO_PROCFS_DEBUG
67static int ap_debug_proc_read(char *page, char **start, off_t off, 68static int ap_debug_proc_show(struct seq_file *m, void *v)
68 int count, int *eof, void *data) 69{
69{ 70 struct ap_data *ap = m->private;
70 char *p = page; 71
71 struct ap_data *ap = (struct ap_data *) data; 72 seq_printf(m, "BridgedUnicastFrames=%u\n", ap->bridged_unicast);
72 73 seq_printf(m, "BridgedMulticastFrames=%u\n", ap->bridged_multicast);
73 if (off != 0) { 74 seq_printf(m, "max_inactivity=%u\n", ap->max_inactivity / HZ);
74 *eof = 1; 75 seq_printf(m, "bridge_packets=%u\n", ap->bridge_packets);
75 return 0; 76 seq_printf(m, "nullfunc_ack=%u\n", ap->nullfunc_ack);
76 } 77 seq_printf(m, "autom_ap_wds=%u\n", ap->autom_ap_wds);
77 78 seq_printf(m, "auth_algs=%u\n", ap->local->auth_algs);
78 p += sprintf(p, "BridgedUnicastFrames=%u\n", ap->bridged_unicast); 79 seq_printf(m, "tx_drop_nonassoc=%u\n", ap->tx_drop_nonassoc);
79 p += sprintf(p, "BridgedMulticastFrames=%u\n", ap->bridged_multicast); 80 return 0;
80 p += sprintf(p, "max_inactivity=%u\n", ap->max_inactivity / HZ); 81}
81 p += sprintf(p, "bridge_packets=%u\n", ap->bridge_packets);
82 p += sprintf(p, "nullfunc_ack=%u\n", ap->nullfunc_ack);
83 p += sprintf(p, "autom_ap_wds=%u\n", ap->autom_ap_wds);
84 p += sprintf(p, "auth_algs=%u\n", ap->local->auth_algs);
85 p += sprintf(p, "tx_drop_nonassoc=%u\n", ap->tx_drop_nonassoc);
86 82
87 return (p - page); 83static int ap_debug_proc_open(struct inode *inode, struct file *file)
84{
85 return single_open(file, ap_debug_proc_show, PDE_DATA(inode));
88} 86}
87
88static const struct file_operations ap_debug_proc_fops = {
89 .open = ap_debug_proc_open,
90 .read = seq_read,
91 .llseek = seq_lseek,
92 .release = seq_release,
93};
89#endif /* PRISM2_NO_PROCFS_DEBUG */ 94#endif /* PRISM2_NO_PROCFS_DEBUG */
90 95
91 96
@@ -325,50 +330,81 @@ void hostap_deauth_all_stas(struct net_device *dev, struct ap_data *ap,
325} 330}
326 331
327 332
328static int ap_control_proc_read(char *page, char **start, off_t off, 333static int ap_control_proc_show(struct seq_file *m, void *v)
329 int count, int *eof, void *data)
330{ 334{
331 char *p = page; 335 struct ap_data *ap = m->private;
332 struct ap_data *ap = (struct ap_data *) data;
333 char *policy_txt; 336 char *policy_txt;
334 struct mac_entry *entry; 337 struct mac_entry *entry;
335 338
336 if (off != 0) { 339 if (v == SEQ_START_TOKEN) {
337 *eof = 1; 340 switch (ap->mac_restrictions.policy) {
341 case MAC_POLICY_OPEN:
342 policy_txt = "open";
343 break;
344 case MAC_POLICY_ALLOW:
345 policy_txt = "allow";
346 break;
347 case MAC_POLICY_DENY:
348 policy_txt = "deny";
349 break;
350 default:
351 policy_txt = "unknown";
352 break;
353 }
354 seq_printf(m, "MAC policy: %s\n", policy_txt);
355 seq_printf(m, "MAC entries: %u\n", ap->mac_restrictions.entries);
356 seq_puts(m, "MAC list:\n");
338 return 0; 357 return 0;
339 } 358 }
340 359
341 switch (ap->mac_restrictions.policy) { 360 entry = v;
342 case MAC_POLICY_OPEN: 361 seq_printf(m, "%pM\n", entry->addr);
343 policy_txt = "open"; 362 return 0;
344 break; 363}
345 case MAC_POLICY_ALLOW: 364
346 policy_txt = "allow"; 365static void *ap_control_proc_start(struct seq_file *m, loff_t *_pos)
347 break; 366{
348 case MAC_POLICY_DENY: 367 struct ap_data *ap = m->private;
349 policy_txt = "deny";
350 break;
351 default:
352 policy_txt = "unknown";
353 break;
354 }
355 p += sprintf(p, "MAC policy: %s\n", policy_txt);
356 p += sprintf(p, "MAC entries: %u\n", ap->mac_restrictions.entries);
357 p += sprintf(p, "MAC list:\n");
358 spin_lock_bh(&ap->mac_restrictions.lock); 368 spin_lock_bh(&ap->mac_restrictions.lock);
359 list_for_each_entry(entry, &ap->mac_restrictions.mac_list, list) { 369 return seq_list_start_head(&ap->mac_restrictions.mac_list, *_pos);
360 if (p - page > PAGE_SIZE - 80) { 370}
361 p += sprintf(p, "All entries did not fit one page.\n");
362 break;
363 }
364 371
365 p += sprintf(p, "%pM\n", entry->addr); 372static void *ap_control_proc_next(struct seq_file *m, void *v, loff_t *_pos)
366 } 373{
374 struct ap_data *ap = m->private;
375 return seq_list_next(v, &ap->mac_restrictions.mac_list, _pos);
376}
377
378static void ap_control_proc_stop(struct seq_file *m, void *v)
379{
380 struct ap_data *ap = m->private;
367 spin_unlock_bh(&ap->mac_restrictions.lock); 381 spin_unlock_bh(&ap->mac_restrictions.lock);
382}
368 383
369 return (p - page); 384static const struct seq_operations ap_control_proc_seqops = {
385 .start = ap_control_proc_start,
386 .next = ap_control_proc_next,
387 .stop = ap_control_proc_stop,
388 .show = ap_control_proc_show,
389};
390
391static int ap_control_proc_open(struct inode *inode, struct file *file)
392{
393 int ret = seq_open(file, &ap_control_proc_seqops);
394 if (ret == 0) {
395 struct seq_file *m = file->private_data;
396 m->private = PDE_DATA(inode);
397 }
398 return ret;
370} 399}
371 400
401static const struct file_operations ap_control_proc_fops = {
402 .open = ap_control_proc_open,
403 .read = seq_read,
404 .llseek = seq_lseek,
405 .release = seq_release,
406};
407
372 408
373int ap_control_add_mac(struct mac_restrictions *mac_restrictions, u8 *mac) 409int ap_control_add_mac(struct mac_restrictions *mac_restrictions, u8 *mac)
374{ 410{
@@ -510,61 +546,84 @@ void ap_control_kickall(struct ap_data *ap)
510 546
511#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 547#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
512 548
513#define PROC_LIMIT (PAGE_SIZE - 80) 549static int prism2_ap_proc_show(struct seq_file *m, void *v)
514
515static int prism2_ap_proc_read(char *page, char **start, off_t off,
516 int count, int *eof, void *data)
517{ 550{
518 char *p = page; 551 struct sta_info *sta = v;
519 struct ap_data *ap = (struct ap_data *) data;
520 struct sta_info *sta;
521 int i; 552 int i;
522 553
523 if (off > PROC_LIMIT) { 554 if (v == SEQ_START_TOKEN) {
524 *eof = 1; 555 seq_printf(m, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n");
525 return 0; 556 return 0;
526 } 557 }
527 558
528 p += sprintf(p, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n"); 559 if (!sta->ap)
529 spin_lock_bh(&ap->sta_table_lock); 560 return 0;
530 list_for_each_entry(sta, &ap->sta_list, list) {
531 if (!sta->ap)
532 continue;
533 561
534 p += sprintf(p, "%pM %d %d %d %d '", 562 seq_printf(m, "%pM %d %d %d %d '",
535 sta->addr, 563 sta->addr,
536 sta->u.ap.channel, sta->last_rx_signal, 564 sta->u.ap.channel, sta->last_rx_signal,
537 sta->last_rx_silence, sta->last_rx_rate); 565 sta->last_rx_silence, sta->last_rx_rate);
538 for (i = 0; i < sta->u.ap.ssid_len; i++)
539 p += sprintf(p, ((sta->u.ap.ssid[i] >= 32 &&
540 sta->u.ap.ssid[i] < 127) ?
541 "%c" : "<%02x>"),
542 sta->u.ap.ssid[i]);
543 p += sprintf(p, "'");
544 if (sta->capability & WLAN_CAPABILITY_ESS)
545 p += sprintf(p, " [ESS]");
546 if (sta->capability & WLAN_CAPABILITY_IBSS)
547 p += sprintf(p, " [IBSS]");
548 if (sta->capability & WLAN_CAPABILITY_PRIVACY)
549 p += sprintf(p, " [WEP]");
550 p += sprintf(p, "\n");
551
552 if ((p - page) > PROC_LIMIT) {
553 printk(KERN_DEBUG "hostap: ap proc did not fit\n");
554 break;
555 }
556 }
557 spin_unlock_bh(&ap->sta_table_lock);
558 566
559 if ((p - page) <= off) { 567 for (i = 0; i < sta->u.ap.ssid_len; i++) {
560 *eof = 1; 568 if (sta->u.ap.ssid[i] >= 32 && sta->u.ap.ssid[i] < 127)
561 return 0; 569 seq_putc(m, sta->u.ap.ssid[i]);
570 else
571 seq_printf(m, "<%02x>", sta->u.ap.ssid[i]);
562 } 572 }
563 573
564 *start = page + off; 574 seq_putc(m, '\'');
575 if (sta->capability & WLAN_CAPABILITY_ESS)
576 seq_puts(m, " [ESS]");
577 if (sta->capability & WLAN_CAPABILITY_IBSS)
578 seq_puts(m, " [IBSS]");
579 if (sta->capability & WLAN_CAPABILITY_PRIVACY)
580 seq_puts(m, " [WEP]");
581 seq_putc(m, '\n');
582 return 0;
583}
584
585static void *prism2_ap_proc_start(struct seq_file *m, loff_t *_pos)
586{
587 struct ap_data *ap = m->private;
588 spin_lock_bh(&ap->sta_table_lock);
589 return seq_list_start_head(&ap->sta_list, *_pos);
590}
565 591
566 return (p - page - off); 592static void *prism2_ap_proc_next(struct seq_file *m, void *v, loff_t *_pos)
593{
594 struct ap_data *ap = m->private;
595 return seq_list_next(v, &ap->sta_list, _pos);
567} 596}
597
598static void prism2_ap_proc_stop(struct seq_file *m, void *v)
599{
600 struct ap_data *ap = m->private;
601 spin_unlock_bh(&ap->sta_table_lock);
602}
603
604static const struct seq_operations prism2_ap_proc_seqops = {
605 .start = prism2_ap_proc_start,
606 .next = prism2_ap_proc_next,
607 .stop = prism2_ap_proc_stop,
608 .show = prism2_ap_proc_show,
609};
610
611static int prism2_ap_proc_open(struct inode *inode, struct file *file)
612{
613 int ret = seq_open(file, &prism2_ap_proc_seqops);
614 if (ret == 0) {
615 struct seq_file *m = file->private_data;
616 m->private = PDE_DATA(inode);
617 }
618 return ret;
619}
620
621static const struct file_operations prism2_ap_proc_fops = {
622 .open = prism2_ap_proc_open,
623 .read = seq_read,
624 .llseek = seq_lseek,
625 .release = seq_release,
626};
568#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 627#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
569 628
570 629
@@ -836,15 +895,12 @@ void hostap_init_ap_proc(local_info_t *local)
836 return; 895 return;
837 896
838#ifndef PRISM2_NO_PROCFS_DEBUG 897#ifndef PRISM2_NO_PROCFS_DEBUG
839 create_proc_read_entry("ap_debug", 0, ap->proc, 898 proc_create_data("ap_debug", 0, ap->proc, &ap_debug_proc_fops, ap);
840 ap_debug_proc_read, ap);
841#endif /* PRISM2_NO_PROCFS_DEBUG */ 899#endif /* PRISM2_NO_PROCFS_DEBUG */
842 900
843#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 901#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
844 create_proc_read_entry("ap_control", 0, ap->proc, 902 proc_create_data("ap_control", 0, ap->proc, &ap_control_proc_fops, ap);
845 ap_control_proc_read, ap); 903 proc_create_data("ap", 0, ap->proc, &prism2_ap_proc_fops, ap);
846 create_proc_read_entry("ap", 0, ap->proc,
847 prism2_ap_proc_read, ap);
848#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 904#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
849 905
850} 906}
@@ -982,79 +1038,86 @@ static void prism2_send_mgmt(struct net_device *dev,
982#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 1038#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
983 1039
984 1040
985static int prism2_sta_proc_read(char *page, char **start, off_t off, 1041static int prism2_sta_proc_show(struct seq_file *m, void *v)
986 int count, int *eof, void *data)
987{ 1042{
988 char *p = page; 1043 struct sta_info *sta = m->private;
989 struct sta_info *sta = (struct sta_info *) data;
990 int i; 1044 int i;
991 1045
992 /* FIX: possible race condition.. the STA data could have just expired, 1046 /* FIX: possible race condition.. the STA data could have just expired,
993 * but proc entry was still here so that the read could have started; 1047 * but proc entry was still here so that the read could have started;
994 * some locking should be done here.. */ 1048 * some locking should be done here.. */
995 1049
996 if (off != 0) { 1050 seq_printf(m,
997 *eof = 1; 1051 "%s=%pM\nusers=%d\naid=%d\n"
998 return 0; 1052 "flags=0x%04x%s%s%s%s%s%s%s\n"
999 } 1053 "capability=0x%02x\nlisten_interval=%d\nsupported_rates=",
1000 1054 sta->ap ? "AP" : "STA",
1001 p += sprintf(p, "%s=%pM\nusers=%d\naid=%d\n" 1055 sta->addr, atomic_read(&sta->users), sta->aid,
1002 "flags=0x%04x%s%s%s%s%s%s%s\n" 1056 sta->flags,
1003 "capability=0x%02x\nlisten_interval=%d\nsupported_rates=", 1057 sta->flags & WLAN_STA_AUTH ? " AUTH" : "",
1004 sta->ap ? "AP" : "STA", 1058 sta->flags & WLAN_STA_ASSOC ? " ASSOC" : "",
1005 sta->addr, atomic_read(&sta->users), sta->aid, 1059 sta->flags & WLAN_STA_PS ? " PS" : "",
1006 sta->flags, 1060 sta->flags & WLAN_STA_TIM ? " TIM" : "",
1007 sta->flags & WLAN_STA_AUTH ? " AUTH" : "", 1061 sta->flags & WLAN_STA_PERM ? " PERM" : "",
1008 sta->flags & WLAN_STA_ASSOC ? " ASSOC" : "", 1062 sta->flags & WLAN_STA_AUTHORIZED ? " AUTHORIZED" : "",
1009 sta->flags & WLAN_STA_PS ? " PS" : "", 1063 sta->flags & WLAN_STA_PENDING_POLL ? " POLL" : "",
1010 sta->flags & WLAN_STA_TIM ? " TIM" : "", 1064 sta->capability, sta->listen_interval);
1011 sta->flags & WLAN_STA_PERM ? " PERM" : "",
1012 sta->flags & WLAN_STA_AUTHORIZED ? " AUTHORIZED" : "",
1013 sta->flags & WLAN_STA_PENDING_POLL ? " POLL" : "",
1014 sta->capability, sta->listen_interval);
1015 /* supported_rates: 500 kbit/s units with msb ignored */ 1065 /* supported_rates: 500 kbit/s units with msb ignored */
1016 for (i = 0; i < sizeof(sta->supported_rates); i++) 1066 for (i = 0; i < sizeof(sta->supported_rates); i++)
1017 if (sta->supported_rates[i] != 0) 1067 if (sta->supported_rates[i] != 0)
1018 p += sprintf(p, "%d%sMbps ", 1068 seq_printf(m, "%d%sMbps ",
1019 (sta->supported_rates[i] & 0x7f) / 2, 1069 (sta->supported_rates[i] & 0x7f) / 2,
1020 sta->supported_rates[i] & 1 ? ".5" : ""); 1070 sta->supported_rates[i] & 1 ? ".5" : "");
1021 p += sprintf(p, "\njiffies=%lu\nlast_auth=%lu\nlast_assoc=%lu\n" 1071 seq_printf(m,
1022 "last_rx=%lu\nlast_tx=%lu\nrx_packets=%lu\n" 1072 "\njiffies=%lu\nlast_auth=%lu\nlast_assoc=%lu\n"
1023 "tx_packets=%lu\n" 1073 "last_rx=%lu\nlast_tx=%lu\nrx_packets=%lu\n"
1024 "rx_bytes=%lu\ntx_bytes=%lu\nbuffer_count=%d\n" 1074 "tx_packets=%lu\n"
1025 "last_rx: silence=%d dBm signal=%d dBm rate=%d%s Mbps\n" 1075 "rx_bytes=%lu\ntx_bytes=%lu\nbuffer_count=%d\n"
1026 "tx_rate=%d\ntx[1M]=%d\ntx[2M]=%d\ntx[5.5M]=%d\n" 1076 "last_rx: silence=%d dBm signal=%d dBm rate=%d%s Mbps\n"
1027 "tx[11M]=%d\n" 1077 "tx_rate=%d\ntx[1M]=%d\ntx[2M]=%d\ntx[5.5M]=%d\n"
1028 "rx[1M]=%d\nrx[2M]=%d\nrx[5.5M]=%d\nrx[11M]=%d\n", 1078 "tx[11M]=%d\n"
1029 jiffies, sta->last_auth, sta->last_assoc, sta->last_rx, 1079 "rx[1M]=%d\nrx[2M]=%d\nrx[5.5M]=%d\nrx[11M]=%d\n",
1030 sta->last_tx, 1080 jiffies, sta->last_auth, sta->last_assoc, sta->last_rx,
1031 sta->rx_packets, sta->tx_packets, sta->rx_bytes, 1081 sta->last_tx,
1032 sta->tx_bytes, skb_queue_len(&sta->tx_buf), 1082 sta->rx_packets, sta->tx_packets, sta->rx_bytes,
1033 sta->last_rx_silence, 1083 sta->tx_bytes, skb_queue_len(&sta->tx_buf),
1034 sta->last_rx_signal, sta->last_rx_rate / 10, 1084 sta->last_rx_silence,
1035 sta->last_rx_rate % 10 ? ".5" : "", 1085 sta->last_rx_signal, sta->last_rx_rate / 10,
1036 sta->tx_rate, sta->tx_count[0], sta->tx_count[1], 1086 sta->last_rx_rate % 10 ? ".5" : "",
1037 sta->tx_count[2], sta->tx_count[3], sta->rx_count[0], 1087 sta->tx_rate, sta->tx_count[0], sta->tx_count[1],
1038 sta->rx_count[1], sta->rx_count[2], sta->rx_count[3]); 1088 sta->tx_count[2], sta->tx_count[3], sta->rx_count[0],
1089 sta->rx_count[1], sta->rx_count[2], sta->rx_count[3]);
1039 if (sta->crypt && sta->crypt->ops && sta->crypt->ops->print_stats) 1090 if (sta->crypt && sta->crypt->ops && sta->crypt->ops->print_stats)
1040 p = sta->crypt->ops->print_stats(p, sta->crypt->priv); 1091 sta->crypt->ops->print_stats(m, sta->crypt->priv);
1041#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 1092#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1042 if (sta->ap) { 1093 if (sta->ap) {
1043 if (sta->u.ap.channel >= 0) 1094 if (sta->u.ap.channel >= 0)
1044 p += sprintf(p, "channel=%d\n", sta->u.ap.channel); 1095 seq_printf(m, "channel=%d\n", sta->u.ap.channel);
1045 p += sprintf(p, "ssid="); 1096 seq_puts(m, "ssid=");
1046 for (i = 0; i < sta->u.ap.ssid_len; i++) 1097 for (i = 0; i < sta->u.ap.ssid_len; i++) {
1047 p += sprintf(p, ((sta->u.ap.ssid[i] >= 32 && 1098 if (sta->u.ap.ssid[i] >= 32 && sta->u.ap.ssid[i] < 127)
1048 sta->u.ap.ssid[i] < 127) ? 1099 seq_putc(m, sta->u.ap.ssid[i]);
1049 "%c" : "<%02x>"), 1100 else
1050 sta->u.ap.ssid[i]); 1101 seq_printf(m, "<%02x>", sta->u.ap.ssid[i]);
1051 p += sprintf(p, "\n"); 1102 }
1103 seq_putc(m, '\n');
1052 } 1104 }
1053#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 1105#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
1054 1106
1055 return (p - page); 1107 return 0;
1108}
1109
1110static int prism2_sta_proc_open(struct inode *inode, struct file *file)
1111{
1112 return single_open(file, prism2_sta_proc_show, PDE_DATA(inode));
1056} 1113}
1057 1114
1115static const struct file_operations prism2_sta_proc_fops = {
1116 .open = prism2_sta_proc_open,
1117 .read = seq_read,
1118 .llseek = seq_lseek,
1119 .release = seq_release,
1120};
1058 1121
1059static void handle_add_proc_queue(struct work_struct *work) 1122static void handle_add_proc_queue(struct work_struct *work)
1060{ 1123{
@@ -1076,9 +1139,9 @@ static void handle_add_proc_queue(struct work_struct *work)
1076 1139
1077 if (sta) { 1140 if (sta) {
1078 sprintf(name, "%pM", sta->addr); 1141 sprintf(name, "%pM", sta->addr);
1079 sta->proc = create_proc_read_entry( 1142 sta->proc = proc_create_data(
1080 name, 0, ap->proc, 1143 name, 0, ap->proc,
1081 prism2_sta_proc_read, sta); 1144 &prism2_sta_proc_fops, sta);
1082 1145
1083 atomic_dec(&sta->users); 1146 atomic_dec(&sta->users);
1084 } 1147 }
diff --git a/drivers/net/wireless/hostap/hostap_download.c b/drivers/net/wireless/hostap/hostap_download.c
index e73bf739fd9b..705fe668b969 100644
--- a/drivers/net/wireless/hostap/hostap_download.c
+++ b/drivers/net/wireless/hostap/hostap_download.c
@@ -174,20 +174,70 @@ static int prism2_pda_ok(u8 *buf)
174} 174}
175 175
176 176
177static int prism2_download_aux_dump(struct net_device *dev, 177#define prism2_download_aux_dump_npages 65536
178 unsigned int addr, int len, u8 *buf)
179{
180 int res;
181 178
182 prism2_enable_aux_port(dev, 1); 179struct prism2_download_aux_dump {
183 res = hfa384x_from_aux(dev, addr, len, buf); 180 local_info_t *local;
184 prism2_enable_aux_port(dev, 0); 181 u16 page[0x80];
185 if (res) 182};
186 return -1; 183
184static int prism2_download_aux_dump_proc_show(struct seq_file *m, void *v)
185{
186 struct prism2_download_aux_dump *ctx = m->private;
187 187
188 hfa384x_from_aux(ctx->local->dev, (unsigned long)v - 1, 0x80, ctx->page);
189 seq_write(m, ctx->page, 0x80);
188 return 0; 190 return 0;
189} 191}
190 192
193static void *prism2_download_aux_dump_proc_start(struct seq_file *m, loff_t *_pos)
194{
195 struct prism2_download_aux_dump *ctx = m->private;
196 prism2_enable_aux_port(ctx->local->dev, 1);
197 if (*_pos >= prism2_download_aux_dump_npages)
198 return NULL;
199 return (void *)((unsigned long)*_pos + 1);
200}
201
202static void *prism2_download_aux_dump_proc_next(struct seq_file *m, void *v, loff_t *_pos)
203{
204 ++*_pos;
205 if (*_pos >= prism2_download_aux_dump_npages)
206 return NULL;
207 return (void *)((unsigned long)*_pos + 1);
208}
209
210static void prism2_download_aux_dump_proc_stop(struct seq_file *m, void *v)
211{
212 struct prism2_download_aux_dump *ctx = m->private;
213 prism2_enable_aux_port(ctx->local->dev, 0);
214}
215
216static const struct seq_operations prism2_download_aux_dump_proc_seqops = {
217 .start = prism2_download_aux_dump_proc_start,
218 .next = prism2_download_aux_dump_proc_next,
219 .stop = prism2_download_aux_dump_proc_stop,
220 .show = prism2_download_aux_dump_proc_show,
221};
222
223static int prism2_download_aux_dump_proc_open(struct inode *inode, struct file *file)
224{
225 int ret = seq_open_private(file, &prism2_download_aux_dump_proc_seqops,
226 sizeof(struct prism2_download_aux_dump));
227 if (ret == 0) {
228 struct seq_file *m = file->private_data;
229 m->private = PDE_DATA(inode);
230 }
231 return ret;
232}
233
234static const struct file_operations prism2_download_aux_dump_proc_fops = {
235 .open = prism2_download_aux_dump_proc_open,
236 .read = seq_read,
237 .llseek = seq_lseek,
238 .release = seq_release_private,
239};
240
191 241
192static u8 * prism2_read_pda(struct net_device *dev) 242static u8 * prism2_read_pda(struct net_device *dev)
193{ 243{
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index 8e7000fd4414..507ab99eef4e 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -38,6 +38,7 @@
38#include <linux/netdevice.h> 38#include <linux/netdevice.h>
39#include <linux/etherdevice.h> 39#include <linux/etherdevice.h>
40#include <linux/proc_fs.h> 40#include <linux/proc_fs.h>
41#include <linux/seq_file.h>
41#include <linux/if_arp.h> 42#include <linux/if_arp.h>
42#include <linux/delay.h> 43#include <linux/delay.h>
43#include <linux/random.h> 44#include <linux/random.h>
@@ -129,8 +130,7 @@ static void prism2_check_sta_fw_version(local_info_t *local);
129 130
130#ifdef PRISM2_DOWNLOAD_SUPPORT 131#ifdef PRISM2_DOWNLOAD_SUPPORT
131/* hostap_download.c */ 132/* hostap_download.c */
132static int prism2_download_aux_dump(struct net_device *dev, 133static const struct file_operations prism2_download_aux_dump_proc_fops;
133 unsigned int addr, int len, u8 *buf);
134static u8 * prism2_read_pda(struct net_device *dev); 134static u8 * prism2_read_pda(struct net_device *dev);
135static int prism2_download(local_info_t *local, 135static int prism2_download(local_info_t *local,
136 struct prism2_download_param *param); 136 struct prism2_download_param *param);
@@ -2894,19 +2894,12 @@ static void hostap_tick_timer(unsigned long data)
2894 2894
2895 2895
2896#ifndef PRISM2_NO_PROCFS_DEBUG 2896#ifndef PRISM2_NO_PROCFS_DEBUG
2897static int prism2_registers_proc_read(char *page, char **start, off_t off, 2897static int prism2_registers_proc_show(struct seq_file *m, void *v)
2898 int count, int *eof, void *data)
2899{ 2898{
2900 char *p = page; 2899 local_info_t *local = m->private;
2901 local_info_t *local = (local_info_t *) data;
2902
2903 if (off != 0) {
2904 *eof = 1;
2905 return 0;
2906 }
2907 2900
2908#define SHOW_REG(n) \ 2901#define SHOW_REG(n) \
2909p += sprintf(p, #n "=%04x\n", hfa384x_read_reg(local->dev, HFA384X_##n##_OFF)) 2902 seq_printf(m, #n "=%04x\n", hfa384x_read_reg(local->dev, HFA384X_##n##_OFF))
2910 2903
2911 SHOW_REG(CMD); 2904 SHOW_REG(CMD);
2912 SHOW_REG(PARAM0); 2905 SHOW_REG(PARAM0);
@@ -2952,8 +2945,21 @@ p += sprintf(p, #n "=%04x\n", hfa384x_read_reg(local->dev, HFA384X_##n##_OFF))
2952 SHOW_REG(PCI_M1_CTL); 2945 SHOW_REG(PCI_M1_CTL);
2953#endif /* PRISM2_PCI */ 2946#endif /* PRISM2_PCI */
2954 2947
2955 return (p - page); 2948 return 0;
2956} 2949}
2950
2951static int prism2_registers_proc_open(struct inode *inode, struct file *file)
2952{
2953 return single_open(file, prism2_registers_proc_show, PDE_DATA(inode));
2954}
2955
2956static const struct file_operations prism2_registers_proc_fops = {
2957 .open = prism2_registers_proc_open,
2958 .read = seq_read,
2959 .llseek = seq_lseek,
2960 .release = seq_release,
2961};
2962
2957#endif /* PRISM2_NO_PROCFS_DEBUG */ 2963#endif /* PRISM2_NO_PROCFS_DEBUG */
2958 2964
2959 2965
@@ -3128,7 +3134,7 @@ prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx,
3128 local->func->reset_port = prism2_reset_port; 3134 local->func->reset_port = prism2_reset_port;
3129 local->func->schedule_reset = prism2_schedule_reset; 3135 local->func->schedule_reset = prism2_schedule_reset;
3130#ifdef PRISM2_DOWNLOAD_SUPPORT 3136#ifdef PRISM2_DOWNLOAD_SUPPORT
3131 local->func->read_aux = prism2_download_aux_dump; 3137 local->func->read_aux_fops = &prism2_download_aux_dump_proc_fops;
3132 local->func->download = prism2_download; 3138 local->func->download = prism2_download;
3133#endif /* PRISM2_DOWNLOAD_SUPPORT */ 3139#endif /* PRISM2_DOWNLOAD_SUPPORT */
3134 local->func->tx = prism2_tx_80211; 3140 local->func->tx = prism2_tx_80211;
@@ -3274,8 +3280,8 @@ static int hostap_hw_ready(struct net_device *dev)
3274 } 3280 }
3275 hostap_init_proc(local); 3281 hostap_init_proc(local);
3276#ifndef PRISM2_NO_PROCFS_DEBUG 3282#ifndef PRISM2_NO_PROCFS_DEBUG
3277 create_proc_read_entry("registers", 0, local->proc, 3283 proc_create_data("registers", 0, local->proc,
3278 prism2_registers_proc_read, local); 3284 &prism2_registers_proc_fops, local);
3279#endif /* PRISM2_NO_PROCFS_DEBUG */ 3285#endif /* PRISM2_NO_PROCFS_DEBUG */
3280 hostap_init_ap_proc(local); 3286 hostap_init_ap_proc(local);
3281 return 0; 3287 return 0;
diff --git a/drivers/net/wireless/hostap/hostap_proc.c b/drivers/net/wireless/hostap/hostap_proc.c
index dc447c1b5abe..7491dab2c105 100644
--- a/drivers/net/wireless/hostap/hostap_proc.c
+++ b/drivers/net/wireless/hostap/hostap_proc.c
@@ -12,259 +12,297 @@
12 12
13 13
14#ifndef PRISM2_NO_PROCFS_DEBUG 14#ifndef PRISM2_NO_PROCFS_DEBUG
15static int prism2_debug_proc_read(char *page, char **start, off_t off, 15static int prism2_debug_proc_show(struct seq_file *m, void *v)
16 int count, int *eof, void *data)
17{ 16{
18 char *p = page; 17 local_info_t *local = m->private;
19 local_info_t *local = (local_info_t *) data;
20 int i; 18 int i;
21 19
22 if (off != 0) { 20 seq_printf(m, "next_txfid=%d next_alloc=%d\n",
23 *eof = 1; 21 local->next_txfid, local->next_alloc);
24 return 0;
25 }
26
27 p += sprintf(p, "next_txfid=%d next_alloc=%d\n",
28 local->next_txfid, local->next_alloc);
29 for (i = 0; i < PRISM2_TXFID_COUNT; i++) 22 for (i = 0; i < PRISM2_TXFID_COUNT; i++)
30 p += sprintf(p, "FID: tx=%04X intransmit=%04X\n", 23 seq_printf(m, "FID: tx=%04X intransmit=%04X\n",
31 local->txfid[i], local->intransmitfid[i]); 24 local->txfid[i], local->intransmitfid[i]);
32 p += sprintf(p, "FW TX rate control: %d\n", local->fw_tx_rate_control); 25 seq_printf(m, "FW TX rate control: %d\n", local->fw_tx_rate_control);
33 p += sprintf(p, "beacon_int=%d\n", local->beacon_int); 26 seq_printf(m, "beacon_int=%d\n", local->beacon_int);
34 p += sprintf(p, "dtim_period=%d\n", local->dtim_period); 27 seq_printf(m, "dtim_period=%d\n", local->dtim_period);
35 p += sprintf(p, "wds_max_connections=%d\n", 28 seq_printf(m, "wds_max_connections=%d\n", local->wds_max_connections);
36 local->wds_max_connections); 29 seq_printf(m, "dev_enabled=%d\n", local->dev_enabled);
37 p += sprintf(p, "dev_enabled=%d\n", local->dev_enabled); 30 seq_printf(m, "sw_tick_stuck=%d\n", local->sw_tick_stuck);
38 p += sprintf(p, "sw_tick_stuck=%d\n", local->sw_tick_stuck);
39 for (i = 0; i < WEP_KEYS; i++) { 31 for (i = 0; i < WEP_KEYS; i++) {
40 if (local->crypt_info.crypt[i] && 32 if (local->crypt_info.crypt[i] &&
41 local->crypt_info.crypt[i]->ops) { 33 local->crypt_info.crypt[i]->ops) {
42 p += sprintf(p, "crypt[%d]=%s\n", i, 34 seq_printf(m, "crypt[%d]=%s\n", i,
43 local->crypt_info.crypt[i]->ops->name); 35 local->crypt_info.crypt[i]->ops->name);
44 } 36 }
45 } 37 }
46 p += sprintf(p, "pri_only=%d\n", local->pri_only); 38 seq_printf(m, "pri_only=%d\n", local->pri_only);
47 p += sprintf(p, "pci=%d\n", local->func->hw_type == HOSTAP_HW_PCI); 39 seq_printf(m, "pci=%d\n", local->func->hw_type == HOSTAP_HW_PCI);
48 p += sprintf(p, "sram_type=%d\n", local->sram_type); 40 seq_printf(m, "sram_type=%d\n", local->sram_type);
49 p += sprintf(p, "no_pri=%d\n", local->no_pri); 41 seq_printf(m, "no_pri=%d\n", local->no_pri);
50 42
51 return (p - page); 43 return 0;
52} 44}
45
46static int prism2_debug_proc_open(struct inode *inode, struct file *file)
47{
48 return single_open(file, prism2_debug_proc_show, PDE_DATA(inode));
49}
50
51static const struct file_operations prism2_debug_proc_fops = {
52 .open = prism2_debug_proc_open,
53 .read = seq_read,
54 .llseek = seq_lseek,
55 .release = seq_release,
56};
53#endif /* PRISM2_NO_PROCFS_DEBUG */ 57#endif /* PRISM2_NO_PROCFS_DEBUG */
54 58
55 59
56static int prism2_stats_proc_read(char *page, char **start, off_t off, 60static int prism2_stats_proc_show(struct seq_file *m, void *v)
57 int count, int *eof, void *data)
58{ 61{
59 char *p = page; 62 local_info_t *local = m->private;
60 local_info_t *local = (local_info_t *) data;
61 struct comm_tallies_sums *sums = &local->comm_tallies; 63 struct comm_tallies_sums *sums = &local->comm_tallies;
62 64
63 if (off != 0) { 65 seq_printf(m, "TxUnicastFrames=%u\n", sums->tx_unicast_frames);
64 *eof = 1; 66 seq_printf(m, "TxMulticastframes=%u\n", sums->tx_multicast_frames);
65 return 0; 67 seq_printf(m, "TxFragments=%u\n", sums->tx_fragments);
66 } 68 seq_printf(m, "TxUnicastOctets=%u\n", sums->tx_unicast_octets);
67 69 seq_printf(m, "TxMulticastOctets=%u\n", sums->tx_multicast_octets);
68 p += sprintf(p, "TxUnicastFrames=%u\n", sums->tx_unicast_frames); 70 seq_printf(m, "TxDeferredTransmissions=%u\n",
69 p += sprintf(p, "TxMulticastframes=%u\n", sums->tx_multicast_frames); 71 sums->tx_deferred_transmissions);
70 p += sprintf(p, "TxFragments=%u\n", sums->tx_fragments); 72 seq_printf(m, "TxSingleRetryFrames=%u\n", sums->tx_single_retry_frames);
71 p += sprintf(p, "TxUnicastOctets=%u\n", sums->tx_unicast_octets); 73 seq_printf(m, "TxMultipleRetryFrames=%u\n",
72 p += sprintf(p, "TxMulticastOctets=%u\n", sums->tx_multicast_octets); 74 sums->tx_multiple_retry_frames);
73 p += sprintf(p, "TxDeferredTransmissions=%u\n", 75 seq_printf(m, "TxRetryLimitExceeded=%u\n",
74 sums->tx_deferred_transmissions); 76 sums->tx_retry_limit_exceeded);
75 p += sprintf(p, "TxSingleRetryFrames=%u\n", 77 seq_printf(m, "TxDiscards=%u\n", sums->tx_discards);
76 sums->tx_single_retry_frames); 78 seq_printf(m, "RxUnicastFrames=%u\n", sums->rx_unicast_frames);
77 p += sprintf(p, "TxMultipleRetryFrames=%u\n", 79 seq_printf(m, "RxMulticastFrames=%u\n", sums->rx_multicast_frames);
78 sums->tx_multiple_retry_frames); 80 seq_printf(m, "RxFragments=%u\n", sums->rx_fragments);
79 p += sprintf(p, "TxRetryLimitExceeded=%u\n", 81 seq_printf(m, "RxUnicastOctets=%u\n", sums->rx_unicast_octets);
80 sums->tx_retry_limit_exceeded); 82 seq_printf(m, "RxMulticastOctets=%u\n", sums->rx_multicast_octets);
81 p += sprintf(p, "TxDiscards=%u\n", sums->tx_discards); 83 seq_printf(m, "RxFCSErrors=%u\n", sums->rx_fcs_errors);
82 p += sprintf(p, "RxUnicastFrames=%u\n", sums->rx_unicast_frames); 84 seq_printf(m, "RxDiscardsNoBuffer=%u\n", sums->rx_discards_no_buffer);
83 p += sprintf(p, "RxMulticastFrames=%u\n", sums->rx_multicast_frames); 85 seq_printf(m, "TxDiscardsWrongSA=%u\n", sums->tx_discards_wrong_sa);
84 p += sprintf(p, "RxFragments=%u\n", sums->rx_fragments); 86 seq_printf(m, "RxDiscardsWEPUndecryptable=%u\n",
85 p += sprintf(p, "RxUnicastOctets=%u\n", sums->rx_unicast_octets); 87 sums->rx_discards_wep_undecryptable);
86 p += sprintf(p, "RxMulticastOctets=%u\n", sums->rx_multicast_octets); 88 seq_printf(m, "RxMessageInMsgFragments=%u\n",
87 p += sprintf(p, "RxFCSErrors=%u\n", sums->rx_fcs_errors); 89 sums->rx_message_in_msg_fragments);
88 p += sprintf(p, "RxDiscardsNoBuffer=%u\n", 90 seq_printf(m, "RxMessageInBadMsgFragments=%u\n",
89 sums->rx_discards_no_buffer); 91 sums->rx_message_in_bad_msg_fragments);
90 p += sprintf(p, "TxDiscardsWrongSA=%u\n", sums->tx_discards_wrong_sa);
91 p += sprintf(p, "RxDiscardsWEPUndecryptable=%u\n",
92 sums->rx_discards_wep_undecryptable);
93 p += sprintf(p, "RxMessageInMsgFragments=%u\n",
94 sums->rx_message_in_msg_fragments);
95 p += sprintf(p, "RxMessageInBadMsgFragments=%u\n",
96 sums->rx_message_in_bad_msg_fragments);
97 /* FIX: this may grow too long for one page(?) */ 92 /* FIX: this may grow too long for one page(?) */
98 93
99 return (p - page); 94 return 0;
95}
96
97static int prism2_stats_proc_open(struct inode *inode, struct file *file)
98{
99 return single_open(file, prism2_stats_proc_show, PDE_DATA(inode));
100} 100}
101 101
102static const struct file_operations prism2_stats_proc_fops = {
103 .open = prism2_stats_proc_open,
104 .read = seq_read,
105 .llseek = seq_lseek,
106 .release = seq_release,
107};
102 108
103static int prism2_wds_proc_read(char *page, char **start, off_t off, 109
104 int count, int *eof, void *data) 110static int prism2_wds_proc_show(struct seq_file *m, void *v)
105{ 111{
106 char *p = page; 112 struct list_head *ptr = v;
107 local_info_t *local = (local_info_t *) data;
108 struct list_head *ptr;
109 struct hostap_interface *iface; 113 struct hostap_interface *iface;
110 114
111 if (off > PROC_LIMIT) { 115 iface = list_entry(ptr, struct hostap_interface, list);
112 *eof = 1; 116 if (iface->type == HOSTAP_INTERFACE_WDS)
113 return 0; 117 seq_printf(m, "%s\t%pM\n",
114 } 118 iface->dev->name, iface->u.wds.remote_addr);
119 return 0;
120}
115 121
122static void *prism2_wds_proc_start(struct seq_file *m, loff_t *_pos)
123{
124 local_info_t *local = m->private;
116 read_lock_bh(&local->iface_lock); 125 read_lock_bh(&local->iface_lock);
117 list_for_each(ptr, &local->hostap_interfaces) { 126 return seq_list_start(&local->hostap_interfaces, *_pos);
118 iface = list_entry(ptr, struct hostap_interface, list); 127}
119 if (iface->type != HOSTAP_INTERFACE_WDS)
120 continue;
121 p += sprintf(p, "%s\t%pM\n",
122 iface->dev->name,
123 iface->u.wds.remote_addr);
124 if ((p - page) > PROC_LIMIT) {
125 printk(KERN_DEBUG "%s: wds proc did not fit\n",
126 local->dev->name);
127 break;
128 }
129 }
130 read_unlock_bh(&local->iface_lock);
131 128
132 if ((p - page) <= off) { 129static void *prism2_wds_proc_next(struct seq_file *m, void *v, loff_t *_pos)
133 *eof = 1; 130{
134 return 0; 131 local_info_t *local = m->private;
135 } 132 return seq_list_next(v, &local->hostap_interfaces, _pos);
133}
136 134
137 *start = page + off; 135static void prism2_wds_proc_stop(struct seq_file *m, void *v)
136{
137 local_info_t *local = m->private;
138 read_unlock_bh(&local->iface_lock);
139}
138 140
139 return (p - page - off); 141static const struct seq_operations prism2_wds_proc_seqops = {
142 .start = prism2_wds_proc_start,
143 .next = prism2_wds_proc_next,
144 .stop = prism2_wds_proc_stop,
145 .show = prism2_wds_proc_show,
146};
147
148static int prism2_wds_proc_open(struct inode *inode, struct file *file)
149{
150 int ret = seq_open(file, &prism2_wds_proc_seqops);
151 if (ret == 0) {
152 struct seq_file *m = file->private_data;
153 m->private = PDE_DATA(inode);
154 }
155 return ret;
140} 156}
141 157
158static const struct file_operations prism2_wds_proc_fops = {
159 .open = prism2_wds_proc_open,
160 .read = seq_read,
161 .llseek = seq_lseek,
162 .release = seq_release,
163};
142 164
143static int prism2_bss_list_proc_read(char *page, char **start, off_t off, 165
144 int count, int *eof, void *data) 166static int prism2_bss_list_proc_show(struct seq_file *m, void *v)
145{ 167{
146 char *p = page; 168 local_info_t *local = m->private;
147 local_info_t *local = (local_info_t *) data; 169 struct list_head *ptr = v;
148 struct list_head *ptr;
149 struct hostap_bss_info *bss; 170 struct hostap_bss_info *bss;
150 int i; 171 int i;
151 172
152 if (off > PROC_LIMIT) { 173 if (ptr == &local->bss_list) {
153 *eof = 1; 174 seq_printf(m, "#BSSID\tlast_update\tcount\tcapab_info\tSSID(txt)\t"
175 "SSID(hex)\tWPA IE\n");
154 return 0; 176 return 0;
155 } 177 }
156 178
157 p += sprintf(p, "#BSSID\tlast_update\tcount\tcapab_info\tSSID(txt)\t" 179 bss = list_entry(ptr, struct hostap_bss_info, list);
158 "SSID(hex)\tWPA IE\n"); 180 seq_printf(m, "%pM\t%lu\t%u\t0x%x\t",
181 bss->bssid, bss->last_update,
182 bss->count, bss->capab_info);
183
184 for (i = 0; i < bss->ssid_len; i++)
185 seq_putc(m,bss->ssid[i] >= 32 && bss->ssid[i] < 127 ?
186 bss->ssid[i] : '_');
187
188 seq_putc(m, '\t');
189 for (i = 0; i < bss->ssid_len; i++)
190 seq_printf(m, "%02x", bss->ssid[i]);
191 seq_putc(m, '\t');
192 for (i = 0; i < bss->wpa_ie_len; i++)
193 seq_printf(m, "%02x", bss->wpa_ie[i]);
194 seq_putc(m, '\n');
195 return 0;
196}
197
198static void *prism2_bss_list_proc_start(struct seq_file *m, loff_t *_pos)
199{
200 local_info_t *local = m->private;
159 spin_lock_bh(&local->lock); 201 spin_lock_bh(&local->lock);
160 list_for_each(ptr, &local->bss_list) { 202 return seq_list_start_head(&local->bss_list, *_pos);
161 bss = list_entry(ptr, struct hostap_bss_info, list); 203}
162 p += sprintf(p, "%pM\t%lu\t%u\t0x%x\t",
163 bss->bssid, bss->last_update,
164 bss->count, bss->capab_info);
165 for (i = 0; i < bss->ssid_len; i++) {
166 p += sprintf(p, "%c",
167 bss->ssid[i] >= 32 && bss->ssid[i] < 127 ?
168 bss->ssid[i] : '_');
169 }
170 p += sprintf(p, "\t");
171 for (i = 0; i < bss->ssid_len; i++) {
172 p += sprintf(p, "%02x", bss->ssid[i]);
173 }
174 p += sprintf(p, "\t");
175 for (i = 0; i < bss->wpa_ie_len; i++) {
176 p += sprintf(p, "%02x", bss->wpa_ie[i]);
177 }
178 p += sprintf(p, "\n");
179 if ((p - page) > PROC_LIMIT) {
180 printk(KERN_DEBUG "%s: BSS proc did not fit\n",
181 local->dev->name);
182 break;
183 }
184 }
185 spin_unlock_bh(&local->lock);
186 204
187 if ((p - page) <= off) { 205static void *prism2_bss_list_proc_next(struct seq_file *m, void *v, loff_t *_pos)
188 *eof = 1; 206{
189 return 0; 207 local_info_t *local = m->private;
190 } 208 return seq_list_next(v, &local->bss_list, _pos);
209}
191 210
192 *start = page + off; 211static void prism2_bss_list_proc_stop(struct seq_file *m, void *v)
212{
213 local_info_t *local = m->private;
214 spin_unlock_bh(&local->lock);
215}
216
217static const struct seq_operations prism2_bss_list_proc_seqops = {
218 .start = prism2_bss_list_proc_start,
219 .next = prism2_bss_list_proc_next,
220 .stop = prism2_bss_list_proc_stop,
221 .show = prism2_bss_list_proc_show,
222};
193 223
194 return (p - page - off); 224static int prism2_bss_list_proc_open(struct inode *inode, struct file *file)
225{
226 int ret = seq_open(file, &prism2_bss_list_proc_seqops);
227 if (ret == 0) {
228 struct seq_file *m = file->private_data;
229 m->private = PDE_DATA(inode);
230 }
231 return ret;
195} 232}
196 233
234static const struct file_operations prism2_bss_list_proc_fops = {
235 .open = prism2_bss_list_proc_open,
236 .read = seq_read,
237 .llseek = seq_lseek,
238 .release = seq_release,
239};
197 240
198static int prism2_crypt_proc_read(char *page, char **start, off_t off, 241
199 int count, int *eof, void *data) 242static int prism2_crypt_proc_show(struct seq_file *m, void *v)
200{ 243{
201 char *p = page; 244 local_info_t *local = m->private;
202 local_info_t *local = (local_info_t *) data;
203 int i; 245 int i;
204 246
205 if (off > PROC_LIMIT) { 247 seq_printf(m, "tx_keyidx=%d\n", local->crypt_info.tx_keyidx);
206 *eof = 1;
207 return 0;
208 }
209
210 p += sprintf(p, "tx_keyidx=%d\n", local->crypt_info.tx_keyidx);
211 for (i = 0; i < WEP_KEYS; i++) { 248 for (i = 0; i < WEP_KEYS; i++) {
212 if (local->crypt_info.crypt[i] && 249 if (local->crypt_info.crypt[i] &&
213 local->crypt_info.crypt[i]->ops && 250 local->crypt_info.crypt[i]->ops &&
214 local->crypt_info.crypt[i]->ops->print_stats) { 251 local->crypt_info.crypt[i]->ops->print_stats) {
215 p = local->crypt_info.crypt[i]->ops->print_stats( 252 local->crypt_info.crypt[i]->ops->print_stats(
216 p, local->crypt_info.crypt[i]->priv); 253 m, local->crypt_info.crypt[i]->priv);
217 } 254 }
218 } 255 }
256 return 0;
257}
219 258
220 if ((p - page) <= off) { 259static int prism2_crypt_proc_open(struct inode *inode, struct file *file)
221 *eof = 1; 260{
222 return 0; 261 return single_open(file, prism2_crypt_proc_show, PDE_DATA(inode));
223 }
224
225 *start = page + off;
226
227 return (p - page - off);
228} 262}
229 263
264static const struct file_operations prism2_crypt_proc_fops = {
265 .open = prism2_crypt_proc_open,
266 .read = seq_read,
267 .llseek = seq_lseek,
268 .release = seq_release,
269};
230 270
231static int prism2_pda_proc_read(char *page, char **start, off_t off, 271
232 int count, int *eof, void *data) 272static ssize_t prism2_pda_proc_read(struct file *file, char __user *buf,
273 size_t count, loff_t *_pos)
233{ 274{
234 local_info_t *local = (local_info_t *) data; 275 local_info_t *local = PDE_DATA(file_inode(file));
276 size_t off;
235 277
236 if (local->pda == NULL || off >= PRISM2_PDA_SIZE) { 278 if (local->pda == NULL || *_pos >= PRISM2_PDA_SIZE)
237 *eof = 1;
238 return 0; 279 return 0;
239 }
240 280
241 if (off + count > PRISM2_PDA_SIZE) 281 off = *_pos;
282 if (count > PRISM2_PDA_SIZE - off)
242 count = PRISM2_PDA_SIZE - off; 283 count = PRISM2_PDA_SIZE - off;
243 284 if (copy_to_user(buf, local->pda + off, count) != 0)
244 memcpy(page, local->pda + off, count); 285 return -EFAULT;
286 *_pos += count;
245 return count; 287 return count;
246} 288}
247 289
290static const struct file_operations prism2_pda_proc_fops = {
291 .read = prism2_pda_proc_read,
292 .llseek = generic_file_llseek,
293};
248 294
249static int prism2_aux_dump_proc_read(char *page, char **start, off_t off,
250 int count, int *eof, void *data)
251{
252 local_info_t *local = (local_info_t *) data;
253
254 if (local->func->read_aux == NULL) {
255 *eof = 1;
256 return 0;
257 }
258 295
259 if (local->func->read_aux(local->dev, off, count, page)) { 296static ssize_t prism2_aux_dump_proc_no_read(struct file *file, char __user *buf,
260 *eof = 1; 297 size_t bufsize, loff_t *_pos)
261 return 0; 298{
262 } 299 return 0;
263 *start = page;
264
265 return count;
266} 300}
267 301
302static const struct file_operations prism2_aux_dump_proc_fops = {
303 .read = prism2_aux_dump_proc_no_read,
304};
305
268 306
269#ifdef PRISM2_IO_DEBUG 307#ifdef PRISM2_IO_DEBUG
270static int prism2_io_debug_proc_read(char *page, char **start, off_t off, 308static int prism2_io_debug_proc_read(char *page, char **start, off_t off,
@@ -306,82 +344,108 @@ static int prism2_io_debug_proc_read(char *page, char **start, off_t off,
306 344
307 345
308#ifndef PRISM2_NO_STATION_MODES 346#ifndef PRISM2_NO_STATION_MODES
309static int prism2_scan_results_proc_read(char *page, char **start, off_t off, 347static int prism2_scan_results_proc_show(struct seq_file *m, void *v)
310 int count, int *eof, void *data)
311{ 348{
312 char *p = page; 349 local_info_t *local = m->private;
313 local_info_t *local = (local_info_t *) data; 350 unsigned long entry;
314 int entry, i, len, total = 0; 351 int i, len;
315 struct hfa384x_hostscan_result *scanres; 352 struct hfa384x_hostscan_result *scanres;
316 u8 *pos; 353 u8 *p;
317 354
318 p += sprintf(p, "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates " 355 if (v == SEQ_START_TOKEN) {
319 "SSID\n"); 356 seq_printf(m,
357 "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates SSID\n");
358 return 0;
359 }
320 360
361 entry = (unsigned long)v - 2;
362 scanres = &local->last_scan_results[entry];
363
364 seq_printf(m, "%d %d %d %d 0x%02x %d %pM %d ",
365 le16_to_cpu(scanres->chid),
366 (s16) le16_to_cpu(scanres->anl),
367 (s16) le16_to_cpu(scanres->sl),
368 le16_to_cpu(scanres->beacon_interval),
369 le16_to_cpu(scanres->capability),
370 le16_to_cpu(scanres->rate),
371 scanres->bssid,
372 le16_to_cpu(scanres->atim));
373
374 p = scanres->sup_rates;
375 for (i = 0; i < sizeof(scanres->sup_rates); i++) {
376 if (p[i] == 0)
377 break;
378 seq_printf(m, "<%02x>", p[i]);
379 }
380 seq_putc(m, ' ');
381
382 p = scanres->ssid;
383 len = le16_to_cpu(scanres->ssid_len);
384 if (len > 32)
385 len = 32;
386 for (i = 0; i < len; i++) {
387 unsigned char c = p[i];
388 if (c >= 32 && c < 127)
389 seq_putc(m, c);
390 else
391 seq_printf(m, "<%02x>", c);
392 }
393 seq_putc(m, '\n');
394 return 0;
395}
396
397static void *prism2_scan_results_proc_start(struct seq_file *m, loff_t *_pos)
398{
399 local_info_t *local = m->private;
321 spin_lock_bh(&local->lock); 400 spin_lock_bh(&local->lock);
322 for (entry = 0; entry < local->last_scan_results_count; entry++) {
323 scanres = &local->last_scan_results[entry];
324 401
325 if (total + (p - page) <= off) { 402 /* We have a header (pos 0) + N results to show (pos 1...N) */
326 total += p - page; 403 if (*_pos > local->last_scan_results_count)
327 p = page; 404 return NULL;
328 } 405 return (void *)(unsigned long)(*_pos + 1); /* 0 would be EOF */
329 if (total + (p - page) > off + count) 406}
330 break;
331 if ((p - page) > (PAGE_SIZE - 200))
332 break;
333 407
334 p += sprintf(p, "%d %d %d %d 0x%02x %d %pM %d ", 408static void *prism2_scan_results_proc_next(struct seq_file *m, void *v, loff_t *_pos)
335 le16_to_cpu(scanres->chid), 409{
336 (s16) le16_to_cpu(scanres->anl), 410 local_info_t *local = m->private;
337 (s16) le16_to_cpu(scanres->sl), 411
338 le16_to_cpu(scanres->beacon_interval), 412 ++*_pos;
339 le16_to_cpu(scanres->capability), 413 if (*_pos > local->last_scan_results_count)
340 le16_to_cpu(scanres->rate), 414 return NULL;
341 scanres->bssid, 415 return (void *)(unsigned long)(*_pos + 1); /* 0 would be EOF */
342 le16_to_cpu(scanres->atim)); 416}
343 417
344 pos = scanres->sup_rates; 418static void prism2_scan_results_proc_stop(struct seq_file *m, void *v)
345 for (i = 0; i < sizeof(scanres->sup_rates); i++) { 419{
346 if (pos[i] == 0) 420 local_info_t *local = m->private;
347 break;
348 p += sprintf(p, "<%02x>", pos[i]);
349 }
350 p += sprintf(p, " ");
351
352 pos = scanres->ssid;
353 len = le16_to_cpu(scanres->ssid_len);
354 if (len > 32)
355 len = 32;
356 for (i = 0; i < len; i++) {
357 unsigned char c = pos[i];
358 if (c >= 32 && c < 127)
359 p += sprintf(p, "%c", c);
360 else
361 p += sprintf(p, "<%02x>", c);
362 }
363 p += sprintf(p, "\n");
364 }
365 spin_unlock_bh(&local->lock); 421 spin_unlock_bh(&local->lock);
422}
366 423
367 total += (p - page); 424static const struct seq_operations prism2_scan_results_proc_seqops = {
368 if (total >= off + count) 425 .start = prism2_scan_results_proc_start,
369 *eof = 1; 426 .next = prism2_scan_results_proc_next,
427 .stop = prism2_scan_results_proc_stop,
428 .show = prism2_scan_results_proc_show,
429};
370 430
371 if (total < off) { 431static int prism2_scan_results_proc_open(struct inode *inode, struct file *file)
372 *eof = 1; 432{
373 return 0; 433 int ret = seq_open(file, &prism2_scan_results_proc_seqops);
434 if (ret == 0) {
435 struct seq_file *m = file->private_data;
436 m->private = PDE_DATA(inode);
374 } 437 }
438 return ret;
439}
440
441static const struct file_operations prism2_scan_results_proc_fops = {
442 .open = prism2_scan_results_proc_open,
443 .read = seq_read,
444 .llseek = seq_lseek,
445 .release = seq_release,
446};
375 447
376 len = total - off;
377 if (len > (p - page))
378 len = p - page;
379 *start = p - len;
380 if (len > count)
381 len = count;
382 448
383 return len;
384}
385#endif /* PRISM2_NO_STATION_MODES */ 449#endif /* PRISM2_NO_STATION_MODES */
386 450
387 451
@@ -403,53 +467,36 @@ void hostap_init_proc(local_info_t *local)
403 } 467 }
404 468
405#ifndef PRISM2_NO_PROCFS_DEBUG 469#ifndef PRISM2_NO_PROCFS_DEBUG
406 create_proc_read_entry("debug", 0, local->proc, 470 proc_create_data("debug", 0, local->proc,
407 prism2_debug_proc_read, local); 471 &prism2_debug_proc_fops, local);
408#endif /* PRISM2_NO_PROCFS_DEBUG */ 472#endif /* PRISM2_NO_PROCFS_DEBUG */
409 create_proc_read_entry("stats", 0, local->proc, 473 proc_create_data("stats", 0, local->proc,
410 prism2_stats_proc_read, local); 474 &prism2_stats_proc_fops, local);
411 create_proc_read_entry("wds", 0, local->proc, 475 proc_create_data("wds", 0, local->proc,
412 prism2_wds_proc_read, local); 476 &prism2_wds_proc_fops, local);
413 create_proc_read_entry("pda", 0, local->proc, 477 proc_create_data("pda", 0, local->proc,
414 prism2_pda_proc_read, local); 478 &prism2_pda_proc_fops, local);
415 create_proc_read_entry("aux_dump", 0, local->proc, 479 proc_create_data("aux_dump", 0, local->proc,
416 prism2_aux_dump_proc_read, local); 480 local->func->read_aux_fops ?: &prism2_aux_dump_proc_fops,
417 create_proc_read_entry("bss_list", 0, local->proc, 481 local);
418 prism2_bss_list_proc_read, local); 482 proc_create_data("bss_list", 0, local->proc,
419 create_proc_read_entry("crypt", 0, local->proc, 483 &prism2_bss_list_proc_fops, local);
420 prism2_crypt_proc_read, local); 484 proc_create_data("crypt", 0, local->proc,
485 &prism2_crypt_proc_fops, local);
421#ifdef PRISM2_IO_DEBUG 486#ifdef PRISM2_IO_DEBUG
422 create_proc_read_entry("io_debug", 0, local->proc, 487 proc_create_data("io_debug", 0, local->proc,
423 prism2_io_debug_proc_read, local); 488 &prism2_io_debug_proc_fops, local);
424#endif /* PRISM2_IO_DEBUG */ 489#endif /* PRISM2_IO_DEBUG */
425#ifndef PRISM2_NO_STATION_MODES 490#ifndef PRISM2_NO_STATION_MODES
426 create_proc_read_entry("scan_results", 0, local->proc, 491 proc_create_data("scan_results", 0, local->proc,
427 prism2_scan_results_proc_read, local); 492 &prism2_scan_results_proc_fops, local);
428#endif /* PRISM2_NO_STATION_MODES */ 493#endif /* PRISM2_NO_STATION_MODES */
429} 494}
430 495
431 496
432void hostap_remove_proc(local_info_t *local) 497void hostap_remove_proc(local_info_t *local)
433{ 498{
434 if (local->proc != NULL) { 499 remove_proc_subtree(local->ddev->name, hostap_proc);
435#ifndef PRISM2_NO_STATION_MODES
436 remove_proc_entry("scan_results", local->proc);
437#endif /* PRISM2_NO_STATION_MODES */
438#ifdef PRISM2_IO_DEBUG
439 remove_proc_entry("io_debug", local->proc);
440#endif /* PRISM2_IO_DEBUG */
441 remove_proc_entry("pda", local->proc);
442 remove_proc_entry("aux_dump", local->proc);
443 remove_proc_entry("wds", local->proc);
444 remove_proc_entry("stats", local->proc);
445 remove_proc_entry("bss_list", local->proc);
446 remove_proc_entry("crypt", local->proc);
447#ifndef PRISM2_NO_PROCFS_DEBUG
448 remove_proc_entry("debug", local->proc);
449#endif /* PRISM2_NO_PROCFS_DEBUG */
450 if (hostap_proc != NULL)
451 remove_proc_entry(local->proc->name, hostap_proc);
452 }
453} 500}
454 501
455 502
diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h
index 7bb0b4b3f2cb..57904015380f 100644
--- a/drivers/net/wireless/hostap/hostap_wlan.h
+++ b/drivers/net/wireless/hostap/hostap_wlan.h
@@ -596,8 +596,7 @@ struct prism2_helper_functions {
596 struct prism2_download_param *param); 596 struct prism2_download_param *param);
597 int (*tx)(struct sk_buff *skb, struct net_device *dev); 597 int (*tx)(struct sk_buff *skb, struct net_device *dev);
598 int (*set_tim)(struct net_device *dev, int aid, int set); 598 int (*set_tim)(struct net_device *dev, int aid, int set);
599 int (*read_aux)(struct net_device *dev, unsigned addr, int len, 599 const struct file_operations *read_aux_fops;
600 u8 *buf);
601 600
602 int need_tx_headroom; /* number of bytes of headroom needed before 601 int need_tx_headroom; /* number of bytes of headroom needed before
603 * IEEE 802.11 header */ 602 * IEEE 802.11 header */
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index ebada812b3a5..9b557a1bb7f8 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -2778,7 +2778,7 @@ static ssize_t int_proc_write(struct file *file, const char __user *buffer,
2778 nr = nr * 10 + c; 2778 nr = nr * 10 + c;
2779 p++; 2779 p++;
2780 } while (--len); 2780 } while (--len);
2781 *(int *)PDE(file_inode(file))->data = nr; 2781 *(int *)PDE_DATA(file_inode(file)) = nr;
2782 return count; 2782 return count;
2783} 2783}
2784 2784
diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index 44d01afafe9c..43926cd25ae8 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -19,7 +19,6 @@
19#include <asm/setup.h> 19#include <asm/setup.h>
20#include <asm/page.h> 20#include <asm/page.h>
21#include <asm/hwtest.h> 21#include <asm/hwtest.h>
22#include <linux/proc_fs.h>
23#include <asm/mac_via.h> 22#include <asm/mac_via.h>
24#include <asm/mac_oss.h> 23#include <asm/mac_oss.h>
25 24
@@ -954,56 +953,6 @@ void __init nubus_probe_slot(int slot)
954 } 953 }
955} 954}
956 955
957#if defined(CONFIG_PROC_FS)
958
959/* /proc/nubus stuff */
960
961static int sprint_nubus_board(struct nubus_board* board, char* ptr, int len)
962{
963 if(len < 100)
964 return -1;
965
966 sprintf(ptr, "Slot %X: %s\n",
967 board->slot, board->name);
968
969 return strlen(ptr);
970}
971
972static int nubus_read_proc(char *page, char **start, off_t off,
973 int count, int *eof, void *data)
974{
975 int nprinted, len, begin = 0;
976 int size = PAGE_SIZE;
977 struct nubus_board* board;
978
979 len = sprintf(page, "Nubus devices found:\n");
980 /* Walk the list of NuBus boards */
981 for (board = nubus_boards; board != NULL; board = board->next)
982 {
983 nprinted = sprint_nubus_board(board, page + len, size - len);
984 if (nprinted < 0)
985 break;
986 len += nprinted;
987 if (len+begin < off) {
988 begin += len;
989 len = 0;
990 }
991 if (len+begin >= off+count)
992 break;
993 }
994 if (len+begin < off)
995 *eof = 1;
996 off -= begin;
997 *start = page + off;
998 len -= off;
999 if (len>count)
1000 len = count;
1001 if (len<0)
1002 len = 0;
1003 return len;
1004}
1005#endif
1006
1007void __init nubus_scan_bus(void) 956void __init nubus_scan_bus(void)
1008{ 957{
1009 int slot; 958 int slot;
@@ -1041,11 +990,7 @@ static int __init nubus_init(void)
1041 nubus_devices = NULL; 990 nubus_devices = NULL;
1042 nubus_boards = NULL; 991 nubus_boards = NULL;
1043 nubus_scan_bus(); 992 nubus_scan_bus();
1044
1045#ifdef CONFIG_PROC_FS
1046 create_proc_read_entry("nubus", 0, NULL, nubus_read_proc, NULL);
1047 nubus_proc_init(); 993 nubus_proc_init();
1048#endif
1049 return 0; 994 return 0;
1050} 995}
1051 996
diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c
index 208dd12825bc..b8286ed65919 100644
--- a/drivers/nubus/proc.c
+++ b/drivers/nubus/proc.c
@@ -52,7 +52,6 @@ static int nubus_devices_proc_open(struct inode *inode, struct file *file)
52} 52}
53 53
54static const struct file_operations nubus_devices_proc_fops = { 54static const struct file_operations nubus_devices_proc_fops = {
55 .owner = THIS_MODULE,
56 .open = nubus_devices_proc_open, 55 .open = nubus_devices_proc_open,
57 .read = seq_read, 56 .read = seq_read,
58 .llseek = seq_lseek, 57 .llseek = seq_lseek,
@@ -61,6 +60,10 @@ static const struct file_operations nubus_devices_proc_fops = {
61 60
62static struct proc_dir_entry *proc_bus_nubus_dir; 61static struct proc_dir_entry *proc_bus_nubus_dir;
63 62
63static const struct file_operations nubus_proc_subdir_fops = {
64#warning Need to set some I/O handlers here
65};
66
64static void nubus_proc_subdir(struct nubus_dev* dev, 67static void nubus_proc_subdir(struct nubus_dev* dev,
65 struct proc_dir_entry* parent, 68 struct proc_dir_entry* parent,
66 struct nubus_dir* dir) 69 struct nubus_dir* dir)
@@ -73,9 +76,10 @@ static void nubus_proc_subdir(struct nubus_dev* dev,
73 struct proc_dir_entry* e; 76 struct proc_dir_entry* e;
74 77
75 sprintf(name, "%x", ent.type); 78 sprintf(name, "%x", ent.type);
76 e = create_proc_entry(name, S_IFREG | S_IRUGO | 79 e = proc_create(name, S_IFREG | S_IRUGO | S_IWUSR, parent,
77 S_IWUSR, parent); 80 &nubus_proc_subdir_fops);
78 if (!e) return; 81 if (!e)
82 return;
79 } 83 }
80} 84}
81 85
@@ -158,6 +162,73 @@ int nubus_proc_detach_device(struct nubus_dev *dev)
158} 162}
159EXPORT_SYMBOL(nubus_proc_detach_device); 163EXPORT_SYMBOL(nubus_proc_detach_device);
160 164
165/*
166 * /proc/nubus stuff
167 */
168static int nubus_proc_show(struct seq_file *m, void *v)
169{
170 const struct nubus_board *board = v;
171
172 /* Display header on line 1 */
173 if (v == SEQ_START_TOKEN)
174 seq_puts(m, "Nubus devices found:\n");
175 else
176 seq_printf(m, "Slot %X: %s\n", board->slot, board->name);
177 return 0;
178}
179
180static void *nubus_proc_start(struct seq_file *m, loff_t *_pos)
181{
182 struct nubus_board *board;
183 unsigned pos;
184
185 if (*_pos > LONG_MAX)
186 return NULL;
187 pos = *_pos;
188 if (pos == 0)
189 return SEQ_START_TOKEN;
190 for (board = nubus_boards; board; board = board->next)
191 if (--pos == 0)
192 break;
193 return board;
194}
195
196static void *nubus_proc_next(struct seq_file *p, void *v, loff_t *_pos)
197{
198 /* Walk the list of NuBus boards */
199 struct nubus_board *board = v;
200
201 ++*_pos;
202 if (v == SEQ_START_TOKEN)
203 board = nubus_boards;
204 else if (board)
205 board = board->next;
206 return board;
207}
208
209static void nubus_proc_stop(struct seq_file *p, void *v)
210{
211}
212
213static const struct seq_operations nubus_proc_seqops = {
214 .start = nubus_proc_start,
215 .next = nubus_proc_next,
216 .stop = nubus_proc_stop,
217 .show = nubus_proc_show,
218};
219
220static int nubus_proc_open(struct inode *inode, struct file *file)
221{
222 return seq_open(file, &nubus_proc_seqops);
223}
224
225static const struct file_operations nubus_proc_fops = {
226 .open = nubus_proc_open,
227 .read = seq_read,
228 .llseek = seq_lseek,
229 .release = seq_release,
230};
231
161void __init proc_bus_nubus_add_devices(void) 232void __init proc_bus_nubus_add_devices(void)
162{ 233{
163 struct nubus_dev *dev; 234 struct nubus_dev *dev;
@@ -168,6 +239,7 @@ void __init proc_bus_nubus_add_devices(void)
168 239
169void __init nubus_proc_init(void) 240void __init nubus_proc_init(void)
170{ 241{
242 proc_create("nubus", 0, NULL, &nubus_proc_fops);
171 if (!MACH_IS_MAC) 243 if (!MACH_IS_MAC)
172 return; 244 return;
173 proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL); 245 proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL);
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 1733081eb873..0a2bdd106b23 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1453,16 +1453,7 @@ int of_attach_node(struct device_node *np)
1453#ifdef CONFIG_PROC_DEVICETREE 1453#ifdef CONFIG_PROC_DEVICETREE
1454static void of_remove_proc_dt_entry(struct device_node *dn) 1454static void of_remove_proc_dt_entry(struct device_node *dn)
1455{ 1455{
1456 struct device_node *parent = dn->parent; 1456 proc_remove(dn->pde);
1457 struct property *prop = dn->properties;
1458
1459 while (prop) {
1460 remove_proc_entry(prop->name, dn->pde);
1461 prop = prop->next;
1462 }
1463
1464 if (dn->pde)
1465 remove_proc_entry(dn->pde->name, parent->pde);
1466} 1457}
1467#else 1458#else
1468static void of_remove_proc_dt_entry(struct device_node *dn) 1459static void of_remove_proc_dt_entry(struct device_node *dn)
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index d4d800c54d86..b48243131993 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -172,14 +172,14 @@ static int led_proc_show(struct seq_file *m, void *v)
172 172
173static int led_proc_open(struct inode *inode, struct file *file) 173static int led_proc_open(struct inode *inode, struct file *file)
174{ 174{
175 return single_open(file, led_proc_show, PDE(inode)->data); 175 return single_open(file, led_proc_show, PDE_DATA(inode));
176} 176}
177 177
178 178
179static ssize_t led_proc_write(struct file *file, const char *buf, 179static ssize_t led_proc_write(struct file *file, const char *buf,
180 size_t count, loff_t *pos) 180 size_t count, loff_t *pos)
181{ 181{
182 void *data = PDE(file_inode(file))->data; 182 void *data = PDE_DATA(file_inode(file));
183 char *cur, lbuf[32]; 183 char *cur, lbuf[32];
184 int d; 184 int d;
185 185
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 0b009470e6db..08126087ec31 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -46,9 +46,7 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
46static ssize_t 46static ssize_t
47proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 47proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
48{ 48{
49 const struct inode *ino = file_inode(file); 49 struct pci_dev *dev = PDE_DATA(file_inode(file));
50 const struct proc_dir_entry *dp = PDE(ino);
51 struct pci_dev *dev = dp->data;
52 unsigned int pos = *ppos; 50 unsigned int pos = *ppos;
53 unsigned int cnt, size; 51 unsigned int cnt, size;
54 52
@@ -59,7 +57,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
59 */ 57 */
60 58
61 if (capable(CAP_SYS_ADMIN)) 59 if (capable(CAP_SYS_ADMIN))
62 size = dp->size; 60 size = dev->cfg_size;
63 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) 61 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
64 size = 128; 62 size = 128;
65 else 63 else
@@ -133,10 +131,9 @@ static ssize_t
133proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos) 131proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos)
134{ 132{
135 struct inode *ino = file_inode(file); 133 struct inode *ino = file_inode(file);
136 const struct proc_dir_entry *dp = PDE(ino); 134 struct pci_dev *dev = PDE_DATA(ino);
137 struct pci_dev *dev = dp->data;
138 int pos = *ppos; 135 int pos = *ppos;
139 int size = dp->size; 136 int size = dev->cfg_size;
140 int cnt; 137 int cnt;
141 138
142 if (pos >= size) 139 if (pos >= size)
@@ -200,7 +197,7 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof
200 pci_config_pm_runtime_put(dev); 197 pci_config_pm_runtime_put(dev);
201 198
202 *ppos = pos; 199 *ppos = pos;
203 i_size_write(ino, dp->size); 200 i_size_write(ino, dev->cfg_size);
204 return nbytes; 201 return nbytes;
205} 202}
206 203
@@ -212,8 +209,7 @@ struct pci_filp_private {
212static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd, 209static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
213 unsigned long arg) 210 unsigned long arg)
214{ 211{
215 const struct proc_dir_entry *dp = PDE(file_inode(file)); 212 struct pci_dev *dev = PDE_DATA(file_inode(file));
216 struct pci_dev *dev = dp->data;
217#ifdef HAVE_PCI_MMAP 213#ifdef HAVE_PCI_MMAP
218 struct pci_filp_private *fpriv = file->private_data; 214 struct pci_filp_private *fpriv = file->private_data;
219#endif /* HAVE_PCI_MMAP */ 215#endif /* HAVE_PCI_MMAP */
@@ -253,9 +249,7 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
253#ifdef HAVE_PCI_MMAP 249#ifdef HAVE_PCI_MMAP
254static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma) 250static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)
255{ 251{
256 struct inode *inode = file_inode(file); 252 struct pci_dev *dev = PDE_DATA(file_inode(file));
257 const struct proc_dir_entry *dp = PDE(inode);
258 struct pci_dev *dev = dp->data;
259 struct pci_filp_private *fpriv = file->private_data; 253 struct pci_filp_private *fpriv = file->private_data;
260 int i, ret; 254 int i, ret;
261 255
@@ -425,7 +419,7 @@ int pci_proc_attach_device(struct pci_dev *dev)
425 &proc_bus_pci_operations, dev); 419 &proc_bus_pci_operations, dev);
426 if (!e) 420 if (!e)
427 return -ENOMEM; 421 return -ENOMEM;
428 e->size = dev->cfg_size; 422 proc_set_size(e, dev->cfg_size);
429 dev->procent = e; 423 dev->procent = e;
430 424
431 return 0; 425 return 0;
@@ -433,20 +427,14 @@ int pci_proc_attach_device(struct pci_dev *dev)
433 427
434int pci_proc_detach_device(struct pci_dev *dev) 428int pci_proc_detach_device(struct pci_dev *dev)
435{ 429{
436 struct proc_dir_entry *e; 430 proc_remove(dev->procent);
437 431 dev->procent = NULL;
438 if ((e = dev->procent)) {
439 remove_proc_entry(e->name, dev->bus->procdir);
440 dev->procent = NULL;
441 }
442 return 0; 432 return 0;
443} 433}
444 434
445int pci_proc_detach_bus(struct pci_bus* bus) 435int pci_proc_detach_bus(struct pci_bus* bus)
446{ 436{
447 struct proc_dir_entry *de = bus->procdir; 437 proc_remove(bus->procdir);
448 if (de)
449 remove_proc_entry(de->name, proc_bus_pci_dir);
450 return 0; 438 return 0;
451} 439}
452 440
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index edec135b1685..54d31c0a9840 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -844,14 +844,14 @@ static int dispatch_proc_show(struct seq_file *m, void *v)
844 844
845static int dispatch_proc_open(struct inode *inode, struct file *file) 845static int dispatch_proc_open(struct inode *inode, struct file *file)
846{ 846{
847 return single_open(file, dispatch_proc_show, PDE(inode)->data); 847 return single_open(file, dispatch_proc_show, PDE_DATA(inode));
848} 848}
849 849
850static ssize_t dispatch_proc_write(struct file *file, 850static ssize_t dispatch_proc_write(struct file *file,
851 const char __user *userbuf, 851 const char __user *userbuf,
852 size_t count, loff_t *pos) 852 size_t count, loff_t *pos)
853{ 853{
854 struct ibm_struct *ibm = PDE(file_inode(file))->data; 854 struct ibm_struct *ibm = PDE_DATA(file_inode(file));
855 char *kernbuf; 855 char *kernbuf;
856 int ret; 856 int ret;
857 857
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 242abac62d8b..eb3467ea6d86 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -553,7 +553,7 @@ static int lcd_proc_show(struct seq_file *m, void *v)
553 553
554static int lcd_proc_open(struct inode *inode, struct file *file) 554static int lcd_proc_open(struct inode *inode, struct file *file)
555{ 555{
556 return single_open(file, lcd_proc_show, PDE(inode)->data); 556 return single_open(file, lcd_proc_show, PDE_DATA(inode));
557} 557}
558 558
559static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value) 559static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value)
@@ -583,7 +583,7 @@ static int set_lcd_status(struct backlight_device *bd)
583static ssize_t lcd_proc_write(struct file *file, const char __user *buf, 583static ssize_t lcd_proc_write(struct file *file, const char __user *buf,
584 size_t count, loff_t *pos) 584 size_t count, loff_t *pos)
585{ 585{
586 struct toshiba_acpi_dev *dev = PDE(file_inode(file))->data; 586 struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file));
587 char cmd[42]; 587 char cmd[42];
588 size_t len; 588 size_t len;
589 int value; 589 int value;
@@ -644,13 +644,13 @@ static int video_proc_show(struct seq_file *m, void *v)
644 644
645static int video_proc_open(struct inode *inode, struct file *file) 645static int video_proc_open(struct inode *inode, struct file *file)
646{ 646{
647 return single_open(file, video_proc_show, PDE(inode)->data); 647 return single_open(file, video_proc_show, PDE_DATA(inode));
648} 648}
649 649
650static ssize_t video_proc_write(struct file *file, const char __user *buf, 650static ssize_t video_proc_write(struct file *file, const char __user *buf,
651 size_t count, loff_t *pos) 651 size_t count, loff_t *pos)
652{ 652{
653 struct toshiba_acpi_dev *dev = PDE(file_inode(file))->data; 653 struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file));
654 char *cmd, *buffer; 654 char *cmd, *buffer;
655 int ret; 655 int ret;
656 int value; 656 int value;
@@ -744,13 +744,13 @@ static int fan_proc_show(struct seq_file *m, void *v)
744 744
745static int fan_proc_open(struct inode *inode, struct file *file) 745static int fan_proc_open(struct inode *inode, struct file *file)
746{ 746{
747 return single_open(file, fan_proc_show, PDE(inode)->data); 747 return single_open(file, fan_proc_show, PDE_DATA(inode));
748} 748}
749 749
750static ssize_t fan_proc_write(struct file *file, const char __user *buf, 750static ssize_t fan_proc_write(struct file *file, const char __user *buf,
751 size_t count, loff_t *pos) 751 size_t count, loff_t *pos)
752{ 752{
753 struct toshiba_acpi_dev *dev = PDE(file_inode(file))->data; 753 struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file));
754 char cmd[42]; 754 char cmd[42];
755 size_t len; 755 size_t len;
756 int value; 756 int value;
@@ -816,13 +816,13 @@ static int keys_proc_show(struct seq_file *m, void *v)
816 816
817static int keys_proc_open(struct inode *inode, struct file *file) 817static int keys_proc_open(struct inode *inode, struct file *file)
818{ 818{
819 return single_open(file, keys_proc_show, PDE(inode)->data); 819 return single_open(file, keys_proc_show, PDE_DATA(inode));
820} 820}
821 821
822static ssize_t keys_proc_write(struct file *file, const char __user *buf, 822static ssize_t keys_proc_write(struct file *file, const char __user *buf,
823 size_t count, loff_t *pos) 823 size_t count, loff_t *pos)
824{ 824{
825 struct toshiba_acpi_dev *dev = PDE(file_inode(file))->data; 825 struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file));
826 char cmd[42]; 826 char cmd[42];
827 size_t len; 827 size_t len;
828 int value; 828 int value;
@@ -859,7 +859,7 @@ static int version_proc_show(struct seq_file *m, void *v)
859 859
860static int version_proc_open(struct inode *inode, struct file *file) 860static int version_proc_open(struct inode *inode, struct file *file)
861{ 861{
862 return single_open(file, version_proc_show, PDE(inode)->data); 862 return single_open(file, version_proc_show, PDE_DATA(inode));
863} 863}
864 864
865static const struct file_operations version_proc_fops = { 865static const struct file_operations version_proc_fops = {
diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c
index 65f735ac6b3b..2365ef37ae24 100644
--- a/drivers/pnp/isapnp/proc.c
+++ b/drivers/pnp/isapnp/proc.c
@@ -55,9 +55,7 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
55static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf, 55static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf,
56 size_t nbytes, loff_t * ppos) 56 size_t nbytes, loff_t * ppos)
57{ 57{
58 struct inode *ino = file_inode(file); 58 struct pnp_dev *dev = PDE_DATA(file_inode(file));
59 struct proc_dir_entry *dp = PDE(ino);
60 struct pnp_dev *dev = dp->data;
61 int pos = *ppos; 59 int pos = *ppos;
62 int cnt, size = 256; 60 int cnt, size = 256;
63 61
@@ -107,7 +105,7 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev)
107 &isapnp_proc_bus_file_operations, dev); 105 &isapnp_proc_bus_file_operations, dev);
108 if (!e) 106 if (!e)
109 return -ENOMEM; 107 return -ENOMEM;
110 e->size = 256; 108 proc_set_size(e, 256);
111 return 0; 109 return 0;
112} 110}
113 111
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
index 1c03ee822e50..c212db0fc65d 100644
--- a/drivers/pnp/pnpbios/proc.c
+++ b/drivers/pnp/pnpbios/proc.c
@@ -237,13 +237,13 @@ static int pnpbios_proc_show(struct seq_file *m, void *v)
237 237
238static int pnpbios_proc_open(struct inode *inode, struct file *file) 238static int pnpbios_proc_open(struct inode *inode, struct file *file)
239{ 239{
240 return single_open(file, pnpbios_proc_show, PDE(inode)->data); 240 return single_open(file, pnpbios_proc_show, PDE_DATA(inode));
241} 241}
242 242
243static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf, 243static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf,
244 size_t count, loff_t *pos) 244 size_t count, loff_t *pos)
245{ 245{
246 void *data = PDE(file_inode(file))->data; 246 void *data = PDE_DATA(file_inode(file));
247 struct pnp_bios_node *node; 247 struct pnp_bios_node *node;
248 int boot = (long)data >> 8; 248 int boot = (long)data >> 8;
249 u8 nodenum = (long)data; 249 u8 nodenum = (long)data;
diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c
index e1b4705ae3ec..38a8bbe74810 100644
--- a/drivers/pps/clients/pps_parport.c
+++ b/drivers/pps/clients/pps_parport.c
@@ -32,6 +32,7 @@
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/irqnr.h> 33#include <linux/irqnr.h>
34#include <linux/time.h> 34#include <linux/time.h>
35#include <linux/slab.h>
35#include <linux/parport.h> 36#include <linux/parport.h>
36#include <linux/pps_kernel.h> 37#include <linux/pps_kernel.h>
37 38
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index e96236ac2e78..ffa69e1c9245 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -110,7 +110,7 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
110static int rtc_proc_open(struct inode *inode, struct file *file) 110static int rtc_proc_open(struct inode *inode, struct file *file)
111{ 111{
112 int ret; 112 int ret;
113 struct rtc_device *rtc = PDE(inode)->data; 113 struct rtc_device *rtc = PDE_DATA(inode);
114 114
115 if (!try_module_get(THIS_MODULE)) 115 if (!try_module_get(THIS_MODULE))
116 return -ENODEV; 116 return -ENODEV;
diff --git a/drivers/s390/cio/qdio_debug.c b/drivers/s390/cio/qdio_debug.c
index ccaae9d63d27..4221b02085ad 100644
--- a/drivers/s390/cio/qdio_debug.c
+++ b/drivers/s390/cio/qdio_debug.c
@@ -224,7 +224,7 @@ static int qperf_seq_open(struct inode *inode, struct file *filp)
224 file_inode(filp)->i_private); 224 file_inode(filp)->i_private);
225} 225}
226 226
227static struct file_operations debugfs_perf_fops = { 227static const struct file_operations debugfs_perf_fops = {
228 .owner = THIS_MODULE, 228 .owner = THIS_MODULE,
229 .open = qperf_seq_open, 229 .open = qperf_seq_open,
230 .read = seq_read, 230 .read = seq_read,
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index d7ca247efa35..344d87599cd2 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -3201,26 +3201,30 @@ static int BusLogic_BIOSDiskParameters(struct scsi_device *sdev, struct block_de
3201 BugLogic_ProcDirectoryInfo implements /proc/scsi/BusLogic/<N>. 3201 BugLogic_ProcDirectoryInfo implements /proc/scsi/BusLogic/<N>.
3202*/ 3202*/
3203 3203
3204static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *shost, char *ProcBuffer, char **StartPointer, off_t Offset, int BytesAvailable, int WriteFlag) 3204static int BusLogic_write_info(struct Scsi_Host *shost, char *ProcBuffer, int BytesAvailable)
3205{ 3205{
3206 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata; 3206 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata;
3207 struct BusLogic_TargetStatistics *TargetStatistics; 3207 struct BusLogic_TargetStatistics *TargetStatistics;
3208 int TargetID, Length;
3209 char *Buffer;
3210 3208
3211 TargetStatistics = HostAdapter->TargetStatistics; 3209 TargetStatistics = HostAdapter->TargetStatistics;
3212 if (WriteFlag) { 3210 HostAdapter->ExternalHostAdapterResets = 0;
3213 HostAdapter->ExternalHostAdapterResets = 0; 3211 HostAdapter->HostAdapterInternalErrors = 0;
3214 HostAdapter->HostAdapterInternalErrors = 0; 3212 memset(TargetStatistics, 0, BusLogic_MaxTargetDevices * sizeof(struct BusLogic_TargetStatistics));
3215 memset(TargetStatistics, 0, BusLogic_MaxTargetDevices * sizeof(struct BusLogic_TargetStatistics)); 3213 return 0;
3216 return 0; 3214}
3217 } 3215
3218 Buffer = HostAdapter->MessageBuffer; 3216static int BusLogic_show_info(struct seq_file *m, struct Scsi_Host *shost)
3219 Length = HostAdapter->MessageBufferLength; 3217{
3220 Length += sprintf(&Buffer[Length], "\n\ 3218 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata;
3219 struct BusLogic_TargetStatistics *TargetStatistics;
3220 int TargetID;
3221
3222 TargetStatistics = HostAdapter->TargetStatistics;
3223 seq_write(m, HostAdapter->MessageBuffer, HostAdapter->MessageBufferLength);
3224 seq_printf(m, "\n\
3221Current Driver Queue Depth: %d\n\ 3225Current Driver Queue Depth: %d\n\
3222Currently Allocated CCBs: %d\n", HostAdapter->DriverQueueDepth, HostAdapter->AllocatedCCBs); 3226Currently Allocated CCBs: %d\n", HostAdapter->DriverQueueDepth, HostAdapter->AllocatedCCBs);
3223 Length += sprintf(&Buffer[Length], "\n\n\ 3227 seq_printf(m, "\n\n\
3224 DATA TRANSFER STATISTICS\n\ 3228 DATA TRANSFER STATISTICS\n\
3225\n\ 3229\n\
3226Target Tagged Queuing Queue Depth Active Attempted Completed\n\ 3230Target Tagged Queuing Queue Depth Active Attempted Completed\n\
@@ -3229,66 +3233,62 @@ Target Tagged Queuing Queue Depth Active Attempted Completed\n\
3229 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID]; 3233 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3230 if (!TargetFlags->TargetExists) 3234 if (!TargetFlags->TargetExists)
3231 continue; 3235 continue;
3232 Length += sprintf(&Buffer[Length], " %2d %s", TargetID, (TargetFlags->TaggedQueuingSupported ? (TargetFlags->TaggedQueuingActive ? " Active" : (HostAdapter->TaggedQueuingPermitted & (1 << TargetID) 3236 seq_printf(m, " %2d %s", TargetID, (TargetFlags->TaggedQueuingSupported ? (TargetFlags->TaggedQueuingActive ? " Active" : (HostAdapter->TaggedQueuingPermitted & (1 << TargetID)
3233 ? " Permitted" : " Disabled")) 3237 ? " Permitted" : " Disabled"))
3234 : "Not Supported")); 3238 : "Not Supported"));
3235 Length += sprintf(&Buffer[Length], 3239 seq_printf(m,
3236 " %3d %3u %9u %9u\n", HostAdapter->QueueDepth[TargetID], HostAdapter->ActiveCommands[TargetID], TargetStatistics[TargetID].CommandsAttempted, TargetStatistics[TargetID].CommandsCompleted); 3240 " %3d %3u %9u %9u\n", HostAdapter->QueueDepth[TargetID], HostAdapter->ActiveCommands[TargetID], TargetStatistics[TargetID].CommandsAttempted, TargetStatistics[TargetID].CommandsCompleted);
3237 } 3241 }
3238 Length += sprintf(&Buffer[Length], "\n\ 3242 seq_printf(m, "\n\
3239Target Read Commands Write Commands Total Bytes Read Total Bytes Written\n\ 3243Target Read Commands Write Commands Total Bytes Read Total Bytes Written\n\
3240====== ============= ============== =================== ===================\n"); 3244====== ============= ============== =================== ===================\n");
3241 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) { 3245 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3242 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID]; 3246 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3243 if (!TargetFlags->TargetExists) 3247 if (!TargetFlags->TargetExists)
3244 continue; 3248 continue;
3245 Length += sprintf(&Buffer[Length], " %2d %9u %9u", TargetID, TargetStatistics[TargetID].ReadCommands, TargetStatistics[TargetID].WriteCommands); 3249 seq_printf(m, " %2d %9u %9u", TargetID, TargetStatistics[TargetID].ReadCommands, TargetStatistics[TargetID].WriteCommands);
3246 if (TargetStatistics[TargetID].TotalBytesRead.Billions > 0) 3250 if (TargetStatistics[TargetID].TotalBytesRead.Billions > 0)
3247 Length += sprintf(&Buffer[Length], " %9u%09u", TargetStatistics[TargetID].TotalBytesRead.Billions, TargetStatistics[TargetID].TotalBytesRead.Units); 3251 seq_printf(m, " %9u%09u", TargetStatistics[TargetID].TotalBytesRead.Billions, TargetStatistics[TargetID].TotalBytesRead.Units);
3248 else 3252 else
3249 Length += sprintf(&Buffer[Length], " %9u", TargetStatistics[TargetID].TotalBytesRead.Units); 3253 seq_printf(m, " %9u", TargetStatistics[TargetID].TotalBytesRead.Units);
3250 if (TargetStatistics[TargetID].TotalBytesWritten.Billions > 0) 3254 if (TargetStatistics[TargetID].TotalBytesWritten.Billions > 0)
3251 Length += sprintf(&Buffer[Length], " %9u%09u\n", TargetStatistics[TargetID].TotalBytesWritten.Billions, TargetStatistics[TargetID].TotalBytesWritten.Units); 3255 seq_printf(m, " %9u%09u\n", TargetStatistics[TargetID].TotalBytesWritten.Billions, TargetStatistics[TargetID].TotalBytesWritten.Units);
3252 else 3256 else
3253 Length += sprintf(&Buffer[Length], " %9u\n", TargetStatistics[TargetID].TotalBytesWritten.Units); 3257 seq_printf(m, " %9u\n", TargetStatistics[TargetID].TotalBytesWritten.Units);
3254 } 3258 }
3255 Length += sprintf(&Buffer[Length], "\n\ 3259 seq_printf(m, "\n\
3256Target Command 0-1KB 1-2KB 2-4KB 4-8KB 8-16KB\n\ 3260Target Command 0-1KB 1-2KB 2-4KB 4-8KB 8-16KB\n\
3257====== ======= ========= ========= ========= ========= =========\n"); 3261====== ======= ========= ========= ========= ========= =========\n");
3258 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) { 3262 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3259 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID]; 3263 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3260 if (!TargetFlags->TargetExists) 3264 if (!TargetFlags->TargetExists)
3261 continue; 3265 continue;
3262 Length += 3266 seq_printf(m,
3263 sprintf(&Buffer[Length],
3264 " %2d Read %9u %9u %9u %9u %9u\n", TargetID, 3267 " %2d Read %9u %9u %9u %9u %9u\n", TargetID,
3265 TargetStatistics[TargetID].ReadCommandSizeBuckets[0], 3268 TargetStatistics[TargetID].ReadCommandSizeBuckets[0],
3266 TargetStatistics[TargetID].ReadCommandSizeBuckets[1], TargetStatistics[TargetID].ReadCommandSizeBuckets[2], TargetStatistics[TargetID].ReadCommandSizeBuckets[3], TargetStatistics[TargetID].ReadCommandSizeBuckets[4]); 3269 TargetStatistics[TargetID].ReadCommandSizeBuckets[1], TargetStatistics[TargetID].ReadCommandSizeBuckets[2], TargetStatistics[TargetID].ReadCommandSizeBuckets[3], TargetStatistics[TargetID].ReadCommandSizeBuckets[4]);
3267 Length += 3270 seq_printf(m,
3268 sprintf(&Buffer[Length],
3269 " %2d Write %9u %9u %9u %9u %9u\n", TargetID, 3271 " %2d Write %9u %9u %9u %9u %9u\n", TargetID,
3270 TargetStatistics[TargetID].WriteCommandSizeBuckets[0], 3272 TargetStatistics[TargetID].WriteCommandSizeBuckets[0],
3271 TargetStatistics[TargetID].WriteCommandSizeBuckets[1], TargetStatistics[TargetID].WriteCommandSizeBuckets[2], TargetStatistics[TargetID].WriteCommandSizeBuckets[3], TargetStatistics[TargetID].WriteCommandSizeBuckets[4]); 3273 TargetStatistics[TargetID].WriteCommandSizeBuckets[1], TargetStatistics[TargetID].WriteCommandSizeBuckets[2], TargetStatistics[TargetID].WriteCommandSizeBuckets[3], TargetStatistics[TargetID].WriteCommandSizeBuckets[4]);
3272 } 3274 }
3273 Length += sprintf(&Buffer[Length], "\n\ 3275 seq_printf(m, "\n\
3274Target Command 16-32KB 32-64KB 64-128KB 128-256KB 256KB+\n\ 3276Target Command 16-32KB 32-64KB 64-128KB 128-256KB 256KB+\n\
3275====== ======= ========= ========= ========= ========= =========\n"); 3277====== ======= ========= ========= ========= ========= =========\n");
3276 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) { 3278 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3277 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID]; 3279 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3278 if (!TargetFlags->TargetExists) 3280 if (!TargetFlags->TargetExists)
3279 continue; 3281 continue;
3280 Length += 3282 seq_printf(m,
3281 sprintf(&Buffer[Length],
3282 " %2d Read %9u %9u %9u %9u %9u\n", TargetID, 3283 " %2d Read %9u %9u %9u %9u %9u\n", TargetID,
3283 TargetStatistics[TargetID].ReadCommandSizeBuckets[5], 3284 TargetStatistics[TargetID].ReadCommandSizeBuckets[5],
3284 TargetStatistics[TargetID].ReadCommandSizeBuckets[6], TargetStatistics[TargetID].ReadCommandSizeBuckets[7], TargetStatistics[TargetID].ReadCommandSizeBuckets[8], TargetStatistics[TargetID].ReadCommandSizeBuckets[9]); 3285 TargetStatistics[TargetID].ReadCommandSizeBuckets[6], TargetStatistics[TargetID].ReadCommandSizeBuckets[7], TargetStatistics[TargetID].ReadCommandSizeBuckets[8], TargetStatistics[TargetID].ReadCommandSizeBuckets[9]);
3285 Length += 3286 seq_printf(m,
3286 sprintf(&Buffer[Length],
3287 " %2d Write %9u %9u %9u %9u %9u\n", TargetID, 3287 " %2d Write %9u %9u %9u %9u %9u\n", TargetID,
3288 TargetStatistics[TargetID].WriteCommandSizeBuckets[5], 3288 TargetStatistics[TargetID].WriteCommandSizeBuckets[5],
3289 TargetStatistics[TargetID].WriteCommandSizeBuckets[6], TargetStatistics[TargetID].WriteCommandSizeBuckets[7], TargetStatistics[TargetID].WriteCommandSizeBuckets[8], TargetStatistics[TargetID].WriteCommandSizeBuckets[9]); 3289 TargetStatistics[TargetID].WriteCommandSizeBuckets[6], TargetStatistics[TargetID].WriteCommandSizeBuckets[7], TargetStatistics[TargetID].WriteCommandSizeBuckets[8], TargetStatistics[TargetID].WriteCommandSizeBuckets[9]);
3290 } 3290 }
3291 Length += sprintf(&Buffer[Length], "\n\n\ 3291 seq_printf(m, "\n\n\
3292 ERROR RECOVERY STATISTICS\n\ 3292 ERROR RECOVERY STATISTICS\n\
3293\n\ 3293\n\
3294 Command Aborts Bus Device Resets Host Adapter Resets\n\ 3294 Command Aborts Bus Device Resets Host Adapter Resets\n\
@@ -3299,20 +3299,12 @@ Target Requested Completed Requested Completed Requested Completed\n\
3299 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID]; 3299 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3300 if (!TargetFlags->TargetExists) 3300 if (!TargetFlags->TargetExists)
3301 continue; 3301 continue;
3302 Length += sprintf(&Buffer[Length], "\ 3302 seq_printf(m, "\
3303 %2d %5d %5d %5d %5d %5d %5d %5d %5d %5d\n", TargetID, TargetStatistics[TargetID].CommandAbortsRequested, TargetStatistics[TargetID].CommandAbortsAttempted, TargetStatistics[TargetID].CommandAbortsCompleted, TargetStatistics[TargetID].BusDeviceResetsRequested, TargetStatistics[TargetID].BusDeviceResetsAttempted, TargetStatistics[TargetID].BusDeviceResetsCompleted, TargetStatistics[TargetID].HostAdapterResetsRequested, TargetStatistics[TargetID].HostAdapterResetsAttempted, TargetStatistics[TargetID].HostAdapterResetsCompleted); 3303 %2d %5d %5d %5d %5d %5d %5d %5d %5d %5d\n", TargetID, TargetStatistics[TargetID].CommandAbortsRequested, TargetStatistics[TargetID].CommandAbortsAttempted, TargetStatistics[TargetID].CommandAbortsCompleted, TargetStatistics[TargetID].BusDeviceResetsRequested, TargetStatistics[TargetID].BusDeviceResetsAttempted, TargetStatistics[TargetID].BusDeviceResetsCompleted, TargetStatistics[TargetID].HostAdapterResetsRequested, TargetStatistics[TargetID].HostAdapterResetsAttempted, TargetStatistics[TargetID].HostAdapterResetsCompleted);
3304 } 3304 }
3305 Length += sprintf(&Buffer[Length], "\nExternal Host Adapter Resets: %d\n", HostAdapter->ExternalHostAdapterResets); 3305 seq_printf(m, "\nExternal Host Adapter Resets: %d\n", HostAdapter->ExternalHostAdapterResets);
3306 Length += sprintf(&Buffer[Length], "Host Adapter Internal Errors: %d\n", HostAdapter->HostAdapterInternalErrors); 3306 seq_printf(m, "Host Adapter Internal Errors: %d\n", HostAdapter->HostAdapterInternalErrors);
3307 if (Length >= BusLogic_MessageBufferSize) 3307 return 0;
3308 BusLogic_Error("Message Buffer length %d exceeds size %d\n", HostAdapter, Length, BusLogic_MessageBufferSize);
3309 if ((Length -= Offset) <= 0)
3310 return 0;
3311 if (Length >= BytesAvailable)
3312 Length = BytesAvailable;
3313 memcpy(ProcBuffer, HostAdapter->MessageBuffer + Offset, Length);
3314 *StartPointer = ProcBuffer;
3315 return Length;
3316} 3308}
3317 3309
3318 3310
@@ -3566,7 +3558,8 @@ static int __init BusLogic_ParseDriverOptions(char *OptionsString)
3566static struct scsi_host_template Bus_Logic_template = { 3558static struct scsi_host_template Bus_Logic_template = {
3567 .module = THIS_MODULE, 3559 .module = THIS_MODULE,
3568 .proc_name = "BusLogic", 3560 .proc_name = "BusLogic",
3569 .proc_info = BusLogic_ProcDirectoryInfo, 3561 .write_info = BusLogic_write_info,
3562 .show_info = BusLogic_show_info,
3570 .name = "BusLogic", 3563 .name = "BusLogic",
3571 .info = BusLogic_DriverInfo, 3564 .info = BusLogic_DriverInfo,
3572 .queuecommand = BusLogic_QueueCommand, 3565 .queuecommand = BusLogic_QueueCommand,
diff --git a/drivers/scsi/BusLogic.h b/drivers/scsi/BusLogic.h
index 649fcb31f26d..6c6c13c3be1b 100644
--- a/drivers/scsi/BusLogic.h
+++ b/drivers/scsi/BusLogic.h
@@ -1321,7 +1321,6 @@ static inline void BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T Co
1321static const char *BusLogic_DriverInfo(struct Scsi_Host *); 1321static const char *BusLogic_DriverInfo(struct Scsi_Host *);
1322static int BusLogic_QueueCommand(struct Scsi_Host *h, struct scsi_cmnd *); 1322static int BusLogic_QueueCommand(struct Scsi_Host *h, struct scsi_cmnd *);
1323static int BusLogic_BIOSDiskParameters(struct scsi_device *, struct block_device *, sector_t, int *); 1323static int BusLogic_BIOSDiskParameters(struct scsi_device *, struct block_device *, sector_t, int *);
1324static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *, char *, char **, off_t, int, int);
1325static int BusLogic_SlaveConfigure(struct scsi_device *); 1324static int BusLogic_SlaveConfigure(struct scsi_device *);
1326static void BusLogic_QueueCompletedCCB(struct BusLogic_CCB *); 1325static void BusLogic_QueueCompletedCCB(struct BusLogic_CCB *);
1327static irqreturn_t BusLogic_InterruptHandler(int, void *); 1326static irqreturn_t BusLogic_InterruptHandler(int, void *);
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 450353e04dde..1e9d6ad9302b 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -695,33 +695,35 @@ static void NCR5380_print_status(struct Scsi_Host *instance)
695 * Return the number of bytes read from or written 695 * Return the number of bytes read from or written
696 */ 696 */
697 697
698static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance,
699 char *buffer, int length)
700{
701#ifdef DTC_PUBLIC_RELEASE
702 dtc_wmaxi = dtc_maxi = 0;
703#endif
704#ifdef PAS16_PUBLIC_RELEASE
705 pas_wmaxi = pas_maxi = 0;
706#endif
707 return (-ENOSYS); /* Currently this is a no-op */
708}
709
698#undef SPRINTF 710#undef SPRINTF
699#define SPRINTF(args...) do { if(pos < buffer + length-80) pos += sprintf(pos, ## args); } while(0) 711#define SPRINTF(args...) seq_printf(m, ## args)
700static 712static
701char *lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, char *pos, char *buffer, int length); 713void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m);
702static 714static
703char *lprint_command(unsigned char *cmd, char *pos, char *buffer, int len); 715void lprint_command(unsigned char *cmd, struct seq_file *m);
704static 716static
705char *lprint_opcode(int opcode, char *pos, char *buffer, int length); 717void lprint_opcode(int opcode, struct seq_file *m);
706 718
707static int __maybe_unused NCR5380_proc_info(struct Scsi_Host *instance, 719static int __maybe_unused NCR5380_show_info(struct seq_file *m,
708 char *buffer, char **start, off_t offset, int length, int inout) 720 struct Scsi_Host *instance)
709{ 721{
710 char *pos = buffer;
711 struct NCR5380_hostdata *hostdata; 722 struct NCR5380_hostdata *hostdata;
712 Scsi_Cmnd *ptr; 723 Scsi_Cmnd *ptr;
713 724
714 hostdata = (struct NCR5380_hostdata *) instance->hostdata; 725 hostdata = (struct NCR5380_hostdata *) instance->hostdata;
715 726
716 if (inout) { /* Has data been written to the file ? */
717#ifdef DTC_PUBLIC_RELEASE
718 dtc_wmaxi = dtc_maxi = 0;
719#endif
720#ifdef PAS16_PUBLIC_RELEASE
721 pas_wmaxi = pas_maxi = 0;
722#endif
723 return (-ENOSYS); /* Currently this is a no-op */
724 }
725 SPRINTF("NCR5380 core release=%d. ", NCR5380_PUBLIC_RELEASE); 727 SPRINTF("NCR5380 core release=%d. ", NCR5380_PUBLIC_RELEASE);
726 if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400) 728 if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400)
727 SPRINTF("ncr53c400 release=%d. ", NCR53C400_PUBLIC_RELEASE); 729 SPRINTF("ncr53c400 release=%d. ", NCR53C400_PUBLIC_RELEASE);
@@ -755,46 +757,37 @@ static int __maybe_unused NCR5380_proc_info(struct Scsi_Host *instance,
755 if (!hostdata->connected) 757 if (!hostdata->connected)
756 SPRINTF("scsi%d: no currently connected command\n", instance->host_no); 758 SPRINTF("scsi%d: no currently connected command\n", instance->host_no);
757 else 759 else
758 pos = lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, pos, buffer, length); 760 lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m);
759 SPRINTF("scsi%d: issue_queue\n", instance->host_no); 761 SPRINTF("scsi%d: issue_queue\n", instance->host_no);
760 for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) 762 for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
761 pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length); 763 lprint_Scsi_Cmnd(ptr, m);
762 764
763 SPRINTF("scsi%d: disconnected_queue\n", instance->host_no); 765 SPRINTF("scsi%d: disconnected_queue\n", instance->host_no);
764 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) 766 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
765 pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length); 767 lprint_Scsi_Cmnd(ptr, m);
766 spin_unlock_irq(instance->host_lock); 768 spin_unlock_irq(instance->host_lock);
767 769 return 0;
768 *start = buffer;
769 if (pos - buffer < offset)
770 return 0;
771 else if (pos - buffer - offset < length)
772 return pos - buffer - offset;
773 return length;
774} 770}
775 771
776static char *lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, char *pos, char *buffer, int length) 772static void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m)
777{ 773{
778 SPRINTF("scsi%d : destination target %d, lun %d\n", cmd->device->host->host_no, cmd->device->id, cmd->device->lun); 774 SPRINTF("scsi%d : destination target %d, lun %d\n", cmd->device->host->host_no, cmd->device->id, cmd->device->lun);
779 SPRINTF(" command = "); 775 SPRINTF(" command = ");
780 pos = lprint_command(cmd->cmnd, pos, buffer, length); 776 lprint_command(cmd->cmnd, m);
781 return (pos);
782} 777}
783 778
784static char *lprint_command(unsigned char *command, char *pos, char *buffer, int length) 779static void lprint_command(unsigned char *command, struct seq_file *m)
785{ 780{
786 int i, s; 781 int i, s;
787 pos = lprint_opcode(command[0], pos, buffer, length); 782 lprint_opcode(command[0], m);
788 for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) 783 for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
789 SPRINTF("%02x ", command[i]); 784 SPRINTF("%02x ", command[i]);
790 SPRINTF("\n"); 785 SPRINTF("\n");
791 return (pos);
792} 786}
793 787
794static char *lprint_opcode(int opcode, char *pos, char *buffer, int length) 788static void lprint_opcode(int opcode, struct seq_file *m)
795{ 789{
796 SPRINTF("%2d (0x%02x)", opcode, opcode); 790 SPRINTF("%2d (0x%02x)", opcode, opcode);
797 return (pos);
798} 791}
799 792
800 793
diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h
index fd40a32b1f6f..14964d0a0e9d 100644
--- a/drivers/scsi/NCR5380.h
+++ b/drivers/scsi/NCR5380.h
@@ -314,8 +314,10 @@ static void NCR5380_print(struct Scsi_Host *instance);
314static int NCR5380_abort(Scsi_Cmnd * cmd); 314static int NCR5380_abort(Scsi_Cmnd * cmd);
315static int NCR5380_bus_reset(Scsi_Cmnd * cmd); 315static int NCR5380_bus_reset(Scsi_Cmnd * cmd);
316static int NCR5380_queue_command(struct Scsi_Host *, struct scsi_cmnd *); 316static int NCR5380_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
317static int __maybe_unused NCR5380_proc_info(struct Scsi_Host *instance, 317static int __maybe_unused NCR5380_show_info(struct seq_file *,
318 char *buffer, char **start, off_t offset, int length, int inout); 318 struct Scsi_Host *);
319static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance,
320 char *buffer, int length);
319 321
320static void NCR5380_reselect(struct Scsi_Host *instance); 322static void NCR5380_reselect(struct Scsi_Host *instance);
321static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag); 323static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag);
diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c
index 3e09aa21c1ca..30fa38a0ad39 100644
--- a/drivers/scsi/a2091.c
+++ b/drivers/scsi/a2091.c
@@ -166,7 +166,8 @@ static int a2091_bus_reset(struct scsi_cmnd *cmd)
166static struct scsi_host_template a2091_scsi_template = { 166static struct scsi_host_template a2091_scsi_template = {
167 .module = THIS_MODULE, 167 .module = THIS_MODULE,
168 .name = "Commodore A2091/A590 SCSI", 168 .name = "Commodore A2091/A590 SCSI",
169 .proc_info = wd33c93_proc_info, 169 .show_info = wd33c93_show_info,
170 .write_info = wd33c93_write_info,
170 .proc_name = "A2901", 171 .proc_name = "A2901",
171 .queuecommand = wd33c93_queuecommand, 172 .queuecommand = wd33c93_queuecommand,
172 .eh_abort_handler = wd33c93_abort, 173 .eh_abort_handler = wd33c93_abort,
diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c
index e29fe0e708f8..c487916a9d45 100644
--- a/drivers/scsi/a3000.c
+++ b/drivers/scsi/a3000.c
@@ -181,7 +181,8 @@ static int a3000_bus_reset(struct scsi_cmnd *cmd)
181static struct scsi_host_template amiga_a3000_scsi_template = { 181static struct scsi_host_template amiga_a3000_scsi_template = {
182 .module = THIS_MODULE, 182 .module = THIS_MODULE,
183 .name = "Amiga 3000 built-in SCSI", 183 .name = "Amiga 3000 built-in SCSI",
184 .proc_info = wd33c93_proc_info, 184 .show_info = wd33c93_show_info,
185 .write_info = wd33c93_write_info,
185 .proc_name = "A3000", 186 .proc_name = "A3000",
186 .queuecommand = wd33c93_queuecommand, 187 .queuecommand = wd33c93_queuecommand,
187 .eh_abort_handler = wd33c93_abort, 188 .eh_abort_handler = wd33c93_abort,
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index dcfaee66a8b9..c67e401954c5 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2178,22 +2178,6 @@ do { \
2178 2178
2179#define ASC_INFO_SIZE 128 /* advansys_info() line size */ 2179#define ASC_INFO_SIZE 128 /* advansys_info() line size */
2180 2180
2181#ifdef CONFIG_PROC_FS
2182/* /proc/scsi/advansys/[0...] related definitions */
2183#define ASC_PRTBUF_SIZE 2048
2184#define ASC_PRTLINE_SIZE 160
2185
2186#define ASC_PRT_NEXT() \
2187 if (cp) { \
2188 totlen += len; \
2189 leftlen -= len; \
2190 if (leftlen == 0) { \
2191 return totlen; \
2192 } \
2193 cp += len; \
2194 }
2195#endif /* CONFIG_PROC_FS */
2196
2197/* Asc Library return codes */ 2181/* Asc Library return codes */
2198#define ASC_TRUE 1 2182#define ASC_TRUE 1
2199#define ASC_FALSE 0 2183#define ASC_FALSE 0
@@ -2384,7 +2368,6 @@ struct asc_board {
2384 } eep_config; 2368 } eep_config;
2385 ulong last_reset; /* Saved last reset time */ 2369 ulong last_reset; /* Saved last reset time */
2386 /* /proc/scsi/advansys/[0...] */ 2370 /* /proc/scsi/advansys/[0...] */
2387 char *prtbuf; /* /proc print buffer */
2388#ifdef ADVANSYS_STATS 2371#ifdef ADVANSYS_STATS
2389 struct asc_stats asc_stats; /* Board statistics */ 2372 struct asc_stats asc_stats; /* Board statistics */
2390#endif /* ADVANSYS_STATS */ 2373#endif /* ADVANSYS_STATS */
@@ -2875,64 +2858,21 @@ static const char *advansys_info(struct Scsi_Host *shost)
2875} 2858}
2876 2859
2877#ifdef CONFIG_PROC_FS 2860#ifdef CONFIG_PROC_FS
2878/*
2879 * asc_prt_line()
2880 *
2881 * If 'cp' is NULL print to the console, otherwise print to a buffer.
2882 *
2883 * Return 0 if printing to the console, otherwise return the number of
2884 * bytes written to the buffer.
2885 *
2886 * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
2887 * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
2888 */
2889static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
2890{
2891 va_list args;
2892 int ret;
2893 char s[ASC_PRTLINE_SIZE];
2894
2895 va_start(args, fmt);
2896 ret = vsprintf(s, fmt, args);
2897 BUG_ON(ret >= ASC_PRTLINE_SIZE);
2898 if (buf == NULL) {
2899 (void)printk(s);
2900 ret = 0;
2901 } else {
2902 ret = min(buflen, ret);
2903 memcpy(buf, s, ret);
2904 }
2905 va_end(args);
2906 return ret;
2907}
2908 2861
2909/* 2862/*
2910 * asc_prt_board_devices() 2863 * asc_prt_board_devices()
2911 * 2864 *
2912 * Print driver information for devices attached to the board. 2865 * Print driver information for devices attached to the board.
2913 *
2914 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
2915 * cf. asc_prt_line().
2916 *
2917 * Return the number of characters copied into 'cp'. No more than
2918 * 'cplen' characters will be copied to 'cp'.
2919 */ 2866 */
2920static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen) 2867static void asc_prt_board_devices(struct seq_file *m, struct Scsi_Host *shost)
2921{ 2868{
2922 struct asc_board *boardp = shost_priv(shost); 2869 struct asc_board *boardp = shost_priv(shost);
2923 int leftlen;
2924 int totlen;
2925 int len;
2926 int chip_scsi_id; 2870 int chip_scsi_id;
2927 int i; 2871 int i;
2928 2872
2929 leftlen = cplen; 2873 seq_printf(m,
2930 totlen = len = 0; 2874 "\nDevice Information for AdvanSys SCSI Host %d:\n",
2931 2875 shost->host_no);
2932 len = asc_prt_line(cp, leftlen,
2933 "\nDevice Information for AdvanSys SCSI Host %d:\n",
2934 shost->host_no);
2935 ASC_PRT_NEXT();
2936 2876
2937 if (ASC_NARROW_BOARD(boardp)) { 2877 if (ASC_NARROW_BOARD(boardp)) {
2938 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; 2878 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
@@ -2940,60 +2880,42 @@ static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
2940 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id; 2880 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
2941 } 2881 }
2942 2882
2943 len = asc_prt_line(cp, leftlen, "Target IDs Detected:"); 2883 seq_printf(m, "Target IDs Detected:");
2944 ASC_PRT_NEXT();
2945 for (i = 0; i <= ADV_MAX_TID; i++) { 2884 for (i = 0; i <= ADV_MAX_TID; i++) {
2946 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) { 2885 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i))
2947 len = asc_prt_line(cp, leftlen, " %X,", i); 2886 seq_printf(m, " %X,", i);
2948 ASC_PRT_NEXT();
2949 }
2950 } 2887 }
2951 len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id); 2888 seq_printf(m, " (%X=Host Adapter)\n", chip_scsi_id);
2952 ASC_PRT_NEXT();
2953
2954 return totlen;
2955} 2889}
2956 2890
2957/* 2891/*
2958 * Display Wide Board BIOS Information. 2892 * Display Wide Board BIOS Information.
2959 */ 2893 */
2960static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen) 2894static void asc_prt_adv_bios(struct seq_file *m, struct Scsi_Host *shost)
2961{ 2895{
2962 struct asc_board *boardp = shost_priv(shost); 2896 struct asc_board *boardp = shost_priv(shost);
2963 int leftlen;
2964 int totlen;
2965 int len;
2966 ushort major, minor, letter; 2897 ushort major, minor, letter;
2967 2898
2968 leftlen = cplen; 2899 seq_printf(m, "\nROM BIOS Version: ");
2969 totlen = len = 0;
2970
2971 len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
2972 ASC_PRT_NEXT();
2973 2900
2974 /* 2901 /*
2975 * If the BIOS saved a valid signature, then fill in 2902 * If the BIOS saved a valid signature, then fill in
2976 * the BIOS code segment base address. 2903 * the BIOS code segment base address.
2977 */ 2904 */
2978 if (boardp->bios_signature != 0x55AA) { 2905 if (boardp->bios_signature != 0x55AA) {
2979 len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n"); 2906 seq_printf(m, "Disabled or Pre-3.1\n");
2980 ASC_PRT_NEXT(); 2907 seq_printf(m,
2981 len = asc_prt_line(cp, leftlen, 2908 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
2982 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n"); 2909 seq_printf(m,
2983 ASC_PRT_NEXT(); 2910 "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
2984 len = asc_prt_line(cp, leftlen,
2985 "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
2986 ASC_PRT_NEXT();
2987 } else { 2911 } else {
2988 major = (boardp->bios_version >> 12) & 0xF; 2912 major = (boardp->bios_version >> 12) & 0xF;
2989 minor = (boardp->bios_version >> 8) & 0xF; 2913 minor = (boardp->bios_version >> 8) & 0xF;
2990 letter = (boardp->bios_version & 0xFF); 2914 letter = (boardp->bios_version & 0xFF);
2991 2915
2992 len = asc_prt_line(cp, leftlen, "%d.%d%c\n", 2916 seq_printf(m, "%d.%d%c\n",
2993 major, minor, 2917 major, minor,
2994 letter >= 26 ? '?' : letter + 'A'); 2918 letter >= 26 ? '?' : letter + 'A');
2995 ASC_PRT_NEXT();
2996
2997 /* 2919 /*
2998 * Current available ROM BIOS release is 3.1I for UW 2920 * Current available ROM BIOS release is 3.1I for UW
2999 * and 3.2I for U2W. This code doesn't differentiate 2921 * and 3.2I for U2W. This code doesn't differentiate
@@ -3001,16 +2923,12 @@ static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
3001 */ 2923 */
3002 if (major < 3 || (major <= 3 && minor < 1) || 2924 if (major < 3 || (major <= 3 && minor < 1) ||
3003 (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) { 2925 (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
3004 len = asc_prt_line(cp, leftlen, 2926 seq_printf(m,
3005 "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n"); 2927 "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
3006 ASC_PRT_NEXT(); 2928 seq_printf(m,
3007 len = asc_prt_line(cp, leftlen, 2929 "ftp://ftp.connectcom.net/pub\n");
3008 "ftp://ftp.connectcom.net/pub\n");
3009 ASC_PRT_NEXT();
3010 } 2930 }
3011 } 2931 }
3012
3013 return totlen;
3014} 2932}
3015 2933
3016/* 2934/*
@@ -3115,20 +3033,11 @@ static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
3115 * asc_prt_asc_board_eeprom() 3033 * asc_prt_asc_board_eeprom()
3116 * 3034 *
3117 * Print board EEPROM configuration. 3035 * Print board EEPROM configuration.
3118 *
3119 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3120 * cf. asc_prt_line().
3121 *
3122 * Return the number of characters copied into 'cp'. No more than
3123 * 'cplen' characters will be copied to 'cp'.
3124 */ 3036 */
3125static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen) 3037static void asc_prt_asc_board_eeprom(struct seq_file *m, struct Scsi_Host *shost)
3126{ 3038{
3127 struct asc_board *boardp = shost_priv(shost); 3039 struct asc_board *boardp = shost_priv(shost);
3128 ASC_DVC_VAR *asc_dvc_varp; 3040 ASC_DVC_VAR *asc_dvc_varp;
3129 int leftlen;
3130 int totlen;
3131 int len;
3132 ASCEEP_CONFIG *ep; 3041 ASCEEP_CONFIG *ep;
3133 int i; 3042 int i;
3134#ifdef CONFIG_ISA 3043#ifdef CONFIG_ISA
@@ -3139,129 +3048,75 @@ static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3139 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var; 3048 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
3140 ep = &boardp->eep_config.asc_eep; 3049 ep = &boardp->eep_config.asc_eep;
3141 3050
3142 leftlen = cplen; 3051 seq_printf(m,
3143 totlen = len = 0; 3052 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3144 3053 shost->host_no);
3145 len = asc_prt_line(cp, leftlen,
3146 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3147 shost->host_no);
3148 ASC_PRT_NEXT();
3149 3054
3150 if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr) 3055 if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
3151 == ASC_TRUE) { 3056 == ASC_TRUE)
3152 len = 3057 seq_printf(m, " Serial Number: %s\n", serialstr);
3153 asc_prt_line(cp, leftlen, " Serial Number: %s\n", 3058 else if (ep->adapter_info[5] == 0xBB)
3154 serialstr); 3059 seq_printf(m,
3155 ASC_PRT_NEXT(); 3060 " Default Settings Used for EEPROM-less Adapter.\n");
3156 } else { 3061 else
3157 if (ep->adapter_info[5] == 0xBB) { 3062 seq_printf(m,
3158 len = asc_prt_line(cp, leftlen, 3063 " Serial Number Signature Not Present.\n");
3159 " Default Settings Used for EEPROM-less Adapter.\n"); 3064
3160 ASC_PRT_NEXT(); 3065 seq_printf(m,
3161 } else { 3066 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3162 len = asc_prt_line(cp, leftlen, 3067 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
3163 " Serial Number Signature Not Present.\n"); 3068 ep->max_tag_qng);
3164 ASC_PRT_NEXT(); 3069
3165 } 3070 seq_printf(m,
3166 } 3071 " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
3167 3072
3168 len = asc_prt_line(cp, leftlen, 3073 seq_printf(m, " Target ID: ");
3169 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", 3074 for (i = 0; i <= ASC_MAX_TID; i++)
3170 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng, 3075 seq_printf(m, " %d", i);
3171 ep->max_tag_qng); 3076 seq_printf(m, "\n");
3172 ASC_PRT_NEXT(); 3077
3173 3078 seq_printf(m, " Disconnects: ");
3174 len = asc_prt_line(cp, leftlen, 3079 for (i = 0; i <= ASC_MAX_TID; i++)
3175 " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam); 3080 seq_printf(m, " %c",
3176 ASC_PRT_NEXT(); 3081 (ep->disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3177 3082 seq_printf(m, "\n");
3178 len = asc_prt_line(cp, leftlen, " Target ID: "); 3083
3179 ASC_PRT_NEXT(); 3084 seq_printf(m, " Command Queuing: ");
3180 for (i = 0; i <= ASC_MAX_TID; i++) { 3085 for (i = 0; i <= ASC_MAX_TID; i++)
3181 len = asc_prt_line(cp, leftlen, " %d", i); 3086 seq_printf(m, " %c",
3182 ASC_PRT_NEXT(); 3087 (ep->use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3183 } 3088 seq_printf(m, "\n");
3184 len = asc_prt_line(cp, leftlen, "\n"); 3089
3185 ASC_PRT_NEXT(); 3090 seq_printf(m, " Start Motor: ");
3186 3091 for (i = 0; i <= ASC_MAX_TID; i++)
3187 len = asc_prt_line(cp, leftlen, " Disconnects: "); 3092 seq_printf(m, " %c",
3188 ASC_PRT_NEXT(); 3093 (ep->start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3189 for (i = 0; i <= ASC_MAX_TID; i++) { 3094 seq_printf(m, "\n");
3190 len = asc_prt_line(cp, leftlen, " %c", 3095
3191 (ep-> 3096 seq_printf(m, " Synchronous Transfer:");
3192 disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 3097 for (i = 0; i <= ASC_MAX_TID; i++)
3193 'N'); 3098 seq_printf(m, " %c",
3194 ASC_PRT_NEXT(); 3099 (ep->init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3195 } 3100 seq_printf(m, "\n");
3196 len = asc_prt_line(cp, leftlen, "\n");
3197 ASC_PRT_NEXT();
3198
3199 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
3200 ASC_PRT_NEXT();
3201 for (i = 0; i <= ASC_MAX_TID; i++) {
3202 len = asc_prt_line(cp, leftlen, " %c",
3203 (ep->
3204 use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3205 'N');
3206 ASC_PRT_NEXT();
3207 }
3208 len = asc_prt_line(cp, leftlen, "\n");
3209 ASC_PRT_NEXT();
3210
3211 len = asc_prt_line(cp, leftlen, " Start Motor: ");
3212 ASC_PRT_NEXT();
3213 for (i = 0; i <= ASC_MAX_TID; i++) {
3214 len = asc_prt_line(cp, leftlen, " %c",
3215 (ep->
3216 start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3217 'N');
3218 ASC_PRT_NEXT();
3219 }
3220 len = asc_prt_line(cp, leftlen, "\n");
3221 ASC_PRT_NEXT();
3222
3223 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3224 ASC_PRT_NEXT();
3225 for (i = 0; i <= ASC_MAX_TID; i++) {
3226 len = asc_prt_line(cp, leftlen, " %c",
3227 (ep->
3228 init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3229 'N');
3230 ASC_PRT_NEXT();
3231 }
3232 len = asc_prt_line(cp, leftlen, "\n");
3233 ASC_PRT_NEXT();
3234 3101
3235#ifdef CONFIG_ISA 3102#ifdef CONFIG_ISA
3236 if (asc_dvc_varp->bus_type & ASC_IS_ISA) { 3103 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
3237 len = asc_prt_line(cp, leftlen, 3104 seq_printf(m,
3238 " Host ISA DMA speed: %d MB/S\n", 3105 " Host ISA DMA speed: %d MB/S\n",
3239 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]); 3106 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
3240 ASC_PRT_NEXT();
3241 } 3107 }
3242#endif /* CONFIG_ISA */ 3108#endif /* CONFIG_ISA */
3243
3244 return totlen;
3245} 3109}
3246 3110
3247/* 3111/*
3248 * asc_prt_adv_board_eeprom() 3112 * asc_prt_adv_board_eeprom()
3249 * 3113 *
3250 * Print board EEPROM configuration. 3114 * Print board EEPROM configuration.
3251 *
3252 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3253 * cf. asc_prt_line().
3254 *
3255 * Return the number of characters copied into 'cp'. No more than
3256 * 'cplen' characters will be copied to 'cp'.
3257 */ 3115 */
3258static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen) 3116static void asc_prt_adv_board_eeprom(struct seq_file *m, struct Scsi_Host *shost)
3259{ 3117{
3260 struct asc_board *boardp = shost_priv(shost); 3118 struct asc_board *boardp = shost_priv(shost);
3261 ADV_DVC_VAR *adv_dvc_varp; 3119 ADV_DVC_VAR *adv_dvc_varp;
3262 int leftlen;
3263 int totlen;
3264 int len;
3265 int i; 3120 int i;
3266 char *termstr; 3121 char *termstr;
3267 uchar serialstr[13]; 3122 uchar serialstr[13];
@@ -3281,13 +3136,9 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3281 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep; 3136 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
3282 } 3137 }
3283 3138
3284 leftlen = cplen; 3139 seq_printf(m,
3285 totlen = len = 0; 3140 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3286 3141 shost->host_no);
3287 len = asc_prt_line(cp, leftlen,
3288 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3289 shost->host_no);
3290 ASC_PRT_NEXT();
3291 3142
3292 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3143 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3293 wordp = &ep_3550->serial_number_word1; 3144 wordp = &ep_3550->serial_number_word1;
@@ -3297,38 +3148,28 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3297 wordp = &ep_38C1600->serial_number_word1; 3148 wordp = &ep_38C1600->serial_number_word1;
3298 } 3149 }
3299 3150
3300 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) { 3151 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE)
3301 len = 3152 seq_printf(m, " Serial Number: %s\n", serialstr);
3302 asc_prt_line(cp, leftlen, " Serial Number: %s\n", 3153 else
3303 serialstr); 3154 seq_printf(m, " Serial Number Signature Not Present.\n");
3304 ASC_PRT_NEXT();
3305 } else {
3306 len = asc_prt_line(cp, leftlen,
3307 " Serial Number Signature Not Present.\n");
3308 ASC_PRT_NEXT();
3309 }
3310 3155
3311 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3156 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
3312 len = asc_prt_line(cp, leftlen, 3157 seq_printf(m,
3313 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", 3158 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3314 ep_3550->adapter_scsi_id, 3159 ep_3550->adapter_scsi_id,
3315 ep_3550->max_host_qng, ep_3550->max_dvc_qng); 3160 ep_3550->max_host_qng, ep_3550->max_dvc_qng);
3316 ASC_PRT_NEXT(); 3161 else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
3317 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { 3162 seq_printf(m,
3318 len = asc_prt_line(cp, leftlen, 3163 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3319 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", 3164 ep_38C0800->adapter_scsi_id,
3320 ep_38C0800->adapter_scsi_id, 3165 ep_38C0800->max_host_qng,
3321 ep_38C0800->max_host_qng, 3166 ep_38C0800->max_dvc_qng);
3322 ep_38C0800->max_dvc_qng); 3167 else
3323 ASC_PRT_NEXT(); 3168 seq_printf(m,
3324 } else { 3169 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3325 len = asc_prt_line(cp, leftlen, 3170 ep_38C1600->adapter_scsi_id,
3326 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", 3171 ep_38C1600->max_host_qng,
3327 ep_38C1600->adapter_scsi_id, 3172 ep_38C1600->max_dvc_qng);
3328 ep_38C1600->max_host_qng,
3329 ep_38C1600->max_dvc_qng);
3330 ASC_PRT_NEXT();
3331 }
3332 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3173 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3333 word = ep_3550->termination; 3174 word = ep_3550->termination;
3334 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { 3175 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
@@ -3352,34 +3193,26 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3352 break; 3193 break;
3353 } 3194 }
3354 3195
3355 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3196 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
3356 len = asc_prt_line(cp, leftlen, 3197 seq_printf(m,
3357 " termination: %u (%s), bios_ctrl: 0x%x\n", 3198 " termination: %u (%s), bios_ctrl: 0x%x\n",
3358 ep_3550->termination, termstr, 3199 ep_3550->termination, termstr,
3359 ep_3550->bios_ctrl); 3200 ep_3550->bios_ctrl);
3360 ASC_PRT_NEXT(); 3201 else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
3361 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { 3202 seq_printf(m,
3362 len = asc_prt_line(cp, leftlen, 3203 " termination: %u (%s), bios_ctrl: 0x%x\n",
3363 " termination: %u (%s), bios_ctrl: 0x%x\n", 3204 ep_38C0800->termination_lvd, termstr,
3364 ep_38C0800->termination_lvd, termstr, 3205 ep_38C0800->bios_ctrl);
3365 ep_38C0800->bios_ctrl); 3206 else
3366 ASC_PRT_NEXT(); 3207 seq_printf(m,
3367 } else { 3208 " termination: %u (%s), bios_ctrl: 0x%x\n",
3368 len = asc_prt_line(cp, leftlen, 3209 ep_38C1600->termination_lvd, termstr,
3369 " termination: %u (%s), bios_ctrl: 0x%x\n", 3210 ep_38C1600->bios_ctrl);
3370 ep_38C1600->termination_lvd, termstr,
3371 ep_38C1600->bios_ctrl);
3372 ASC_PRT_NEXT();
3373 }
3374 3211
3375 len = asc_prt_line(cp, leftlen, " Target ID: "); 3212 seq_printf(m, " Target ID: ");
3376 ASC_PRT_NEXT(); 3213 for (i = 0; i <= ADV_MAX_TID; i++)
3377 for (i = 0; i <= ADV_MAX_TID; i++) { 3214 seq_printf(m, " %X", i);
3378 len = asc_prt_line(cp, leftlen, " %X", i); 3215 seq_printf(m, "\n");
3379 ASC_PRT_NEXT();
3380 }
3381 len = asc_prt_line(cp, leftlen, "\n");
3382 ASC_PRT_NEXT();
3383 3216
3384 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3217 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3385 word = ep_3550->disc_enable; 3218 word = ep_3550->disc_enable;
@@ -3388,15 +3221,11 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3388 } else { 3221 } else {
3389 word = ep_38C1600->disc_enable; 3222 word = ep_38C1600->disc_enable;
3390 } 3223 }
3391 len = asc_prt_line(cp, leftlen, " Disconnects: "); 3224 seq_printf(m, " Disconnects: ");
3392 ASC_PRT_NEXT(); 3225 for (i = 0; i <= ADV_MAX_TID; i++)
3393 for (i = 0; i <= ADV_MAX_TID; i++) { 3226 seq_printf(m, " %c",
3394 len = asc_prt_line(cp, leftlen, " %c", 3227 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3395 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 3228 seq_printf(m, "\n");
3396 ASC_PRT_NEXT();
3397 }
3398 len = asc_prt_line(cp, leftlen, "\n");
3399 ASC_PRT_NEXT();
3400 3229
3401 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3230 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3402 word = ep_3550->tagqng_able; 3231 word = ep_3550->tagqng_able;
@@ -3405,15 +3234,11 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3405 } else { 3234 } else {
3406 word = ep_38C1600->tagqng_able; 3235 word = ep_38C1600->tagqng_able;
3407 } 3236 }
3408 len = asc_prt_line(cp, leftlen, " Command Queuing: "); 3237 seq_printf(m, " Command Queuing: ");
3409 ASC_PRT_NEXT(); 3238 for (i = 0; i <= ADV_MAX_TID; i++)
3410 for (i = 0; i <= ADV_MAX_TID; i++) { 3239 seq_printf(m, " %c",
3411 len = asc_prt_line(cp, leftlen, " %c", 3240 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3412 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 3241 seq_printf(m, "\n");
3413 ASC_PRT_NEXT();
3414 }
3415 len = asc_prt_line(cp, leftlen, "\n");
3416 ASC_PRT_NEXT();
3417 3242
3418 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3243 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3419 word = ep_3550->start_motor; 3244 word = ep_3550->start_motor;
@@ -3422,42 +3247,28 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3422 } else { 3247 } else {
3423 word = ep_38C1600->start_motor; 3248 word = ep_38C1600->start_motor;
3424 } 3249 }
3425 len = asc_prt_line(cp, leftlen, " Start Motor: "); 3250 seq_printf(m, " Start Motor: ");
3426 ASC_PRT_NEXT(); 3251 for (i = 0; i <= ADV_MAX_TID; i++)
3427 for (i = 0; i <= ADV_MAX_TID; i++) { 3252 seq_printf(m, " %c",
3428 len = asc_prt_line(cp, leftlen, " %c", 3253 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3429 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 3254 seq_printf(m, "\n");
3430 ASC_PRT_NEXT();
3431 }
3432 len = asc_prt_line(cp, leftlen, "\n");
3433 ASC_PRT_NEXT();
3434 3255
3435 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3256 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3436 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:"); 3257 seq_printf(m, " Synchronous Transfer:");
3437 ASC_PRT_NEXT(); 3258 for (i = 0; i <= ADV_MAX_TID; i++)
3438 for (i = 0; i <= ADV_MAX_TID; i++) { 3259 seq_printf(m, " %c",
3439 len = asc_prt_line(cp, leftlen, " %c", 3260 (ep_3550->sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
3440 (ep_3550-> 3261 'Y' : 'N');
3441 sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 3262 seq_printf(m, "\n");
3442 'Y' : 'N');
3443 ASC_PRT_NEXT();
3444 }
3445 len = asc_prt_line(cp, leftlen, "\n");
3446 ASC_PRT_NEXT();
3447 } 3263 }
3448 3264
3449 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3265 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3450 len = asc_prt_line(cp, leftlen, " Ultra Transfer: "); 3266 seq_printf(m, " Ultra Transfer: ");
3451 ASC_PRT_NEXT(); 3267 for (i = 0; i <= ADV_MAX_TID; i++)
3452 for (i = 0; i <= ADV_MAX_TID; i++) { 3268 seq_printf(m, " %c",
3453 len = asc_prt_line(cp, leftlen, " %c", 3269 (ep_3550->ultra_able & ADV_TID_TO_TIDMASK(i))
3454 (ep_3550-> 3270 ? 'Y' : 'N');
3455 ultra_able & ADV_TID_TO_TIDMASK(i)) 3271 seq_printf(m, "\n");
3456 ? 'Y' : 'N');
3457 ASC_PRT_NEXT();
3458 }
3459 len = asc_prt_line(cp, leftlen, "\n");
3460 ASC_PRT_NEXT();
3461 } 3272 }
3462 3273
3463 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3274 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
@@ -3467,21 +3278,16 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3467 } else { 3278 } else {
3468 word = ep_38C1600->wdtr_able; 3279 word = ep_38C1600->wdtr_able;
3469 } 3280 }
3470 len = asc_prt_line(cp, leftlen, " Wide Transfer: "); 3281 seq_printf(m, " Wide Transfer: ");
3471 ASC_PRT_NEXT(); 3282 for (i = 0; i <= ADV_MAX_TID; i++)
3472 for (i = 0; i <= ADV_MAX_TID; i++) { 3283 seq_printf(m, " %c",
3473 len = asc_prt_line(cp, leftlen, " %c", 3284 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3474 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 3285 seq_printf(m, "\n");
3475 ASC_PRT_NEXT();
3476 }
3477 len = asc_prt_line(cp, leftlen, "\n");
3478 ASC_PRT_NEXT();
3479 3286
3480 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 || 3287 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
3481 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) { 3288 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
3482 len = asc_prt_line(cp, leftlen, 3289 seq_printf(m,
3483 " Synchronous Transfer Speed (Mhz):\n "); 3290 " Synchronous Transfer Speed (Mhz):\n ");
3484 ASC_PRT_NEXT();
3485 for (i = 0; i <= ADV_MAX_TID; i++) { 3291 for (i = 0; i <= ADV_MAX_TID; i++) {
3486 char *speed_str; 3292 char *speed_str;
3487 3293
@@ -3517,99 +3323,64 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3517 speed_str = "Unk"; 3323 speed_str = "Unk";
3518 break; 3324 break;
3519 } 3325 }
3520 len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str); 3326 seq_printf(m, "%X:%s ", i, speed_str);
3521 ASC_PRT_NEXT(); 3327 if (i == 7)
3522 if (i == 7) { 3328 seq_printf(m, "\n ");
3523 len = asc_prt_line(cp, leftlen, "\n ");
3524 ASC_PRT_NEXT();
3525 }
3526 sdtr_speed >>= 4; 3329 sdtr_speed >>= 4;
3527 } 3330 }
3528 len = asc_prt_line(cp, leftlen, "\n"); 3331 seq_printf(m, "\n");
3529 ASC_PRT_NEXT();
3530 } 3332 }
3531
3532 return totlen;
3533} 3333}
3534 3334
3535/* 3335/*
3536 * asc_prt_driver_conf() 3336 * asc_prt_driver_conf()
3537 *
3538 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3539 * cf. asc_prt_line().
3540 *
3541 * Return the number of characters copied into 'cp'. No more than
3542 * 'cplen' characters will be copied to 'cp'.
3543 */ 3337 */
3544static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen) 3338static void asc_prt_driver_conf(struct seq_file *m, struct Scsi_Host *shost)
3545{ 3339{
3546 struct asc_board *boardp = shost_priv(shost); 3340 struct asc_board *boardp = shost_priv(shost);
3547 int leftlen;
3548 int totlen;
3549 int len;
3550 int chip_scsi_id; 3341 int chip_scsi_id;
3551 3342
3552 leftlen = cplen; 3343 seq_printf(m,
3553 totlen = len = 0; 3344 "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
3345 shost->host_no);
3554 3346
3555 len = asc_prt_line(cp, leftlen, 3347 seq_printf(m,
3556 "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n", 3348 " host_busy %u, last_reset %lu, max_id %u, max_lun %u, max_channel %u\n",
3557 shost->host_no); 3349 shost->host_busy, shost->last_reset, shost->max_id,
3558 ASC_PRT_NEXT(); 3350 shost->max_lun, shost->max_channel);
3559 3351
3560 len = asc_prt_line(cp, leftlen, 3352 seq_printf(m,
3561 " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n", 3353 " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
3562 shost->host_busy, shost->last_reset, shost->max_id, 3354 shost->unique_id, shost->can_queue, shost->this_id,
3563 shost->max_lun, shost->max_channel); 3355 shost->sg_tablesize, shost->cmd_per_lun);
3564 ASC_PRT_NEXT();
3565 3356
3566 len = asc_prt_line(cp, leftlen, 3357 seq_printf(m,
3567 " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n", 3358 " unchecked_isa_dma %d, use_clustering %d\n",
3568 shost->unique_id, shost->can_queue, shost->this_id, 3359 shost->unchecked_isa_dma, shost->use_clustering);
3569 shost->sg_tablesize, shost->cmd_per_lun);
3570 ASC_PRT_NEXT();
3571 3360
3572 len = asc_prt_line(cp, leftlen, 3361 seq_printf(m,
3573 " unchecked_isa_dma %d, use_clustering %d\n", 3362 " flags 0x%x, last_reset 0x%lx, jiffies 0x%lx, asc_n_io_port 0x%x\n",
3574 shost->unchecked_isa_dma, shost->use_clustering); 3363 boardp->flags, boardp->last_reset, jiffies,
3575 ASC_PRT_NEXT(); 3364 boardp->asc_n_io_port);
3576 3365
3577 len = asc_prt_line(cp, leftlen, 3366 seq_printf(m, " io_port 0x%lx\n", shost->io_port);
3578 " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
3579 boardp->flags, boardp->last_reset, jiffies,
3580 boardp->asc_n_io_port);
3581 ASC_PRT_NEXT();
3582
3583 len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
3584 ASC_PRT_NEXT();
3585 3367
3586 if (ASC_NARROW_BOARD(boardp)) { 3368 if (ASC_NARROW_BOARD(boardp)) {
3587 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; 3369 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
3588 } else { 3370 } else {
3589 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id; 3371 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
3590 } 3372 }
3591
3592 return totlen;
3593} 3373}
3594 3374
3595/* 3375/*
3596 * asc_prt_asc_board_info() 3376 * asc_prt_asc_board_info()
3597 * 3377 *
3598 * Print dynamic board configuration information. 3378 * Print dynamic board configuration information.
3599 *
3600 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3601 * cf. asc_prt_line().
3602 *
3603 * Return the number of characters copied into 'cp'. No more than
3604 * 'cplen' characters will be copied to 'cp'.
3605 */ 3379 */
3606static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen) 3380static void asc_prt_asc_board_info(struct seq_file *m, struct Scsi_Host *shost)
3607{ 3381{
3608 struct asc_board *boardp = shost_priv(shost); 3382 struct asc_board *boardp = shost_priv(shost);
3609 int chip_scsi_id; 3383 int chip_scsi_id;
3610 int leftlen;
3611 int totlen;
3612 int len;
3613 ASC_DVC_VAR *v; 3384 ASC_DVC_VAR *v;
3614 ASC_DVC_CFG *c; 3385 ASC_DVC_CFG *c;
3615 int i; 3386 int i;
@@ -3619,105 +3390,79 @@ static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3619 c = &boardp->dvc_cfg.asc_dvc_cfg; 3390 c = &boardp->dvc_cfg.asc_dvc_cfg;
3620 chip_scsi_id = c->chip_scsi_id; 3391 chip_scsi_id = c->chip_scsi_id;
3621 3392
3622 leftlen = cplen; 3393 seq_printf(m,
3623 totlen = len = 0; 3394 "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3395 shost->host_no);
3624 3396
3625 len = asc_prt_line(cp, leftlen, 3397 seq_printf(m, " chip_version %u, mcode_date 0x%x, "
3626 "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n", 3398 "mcode_version 0x%x, err_code %u\n",
3627 shost->host_no); 3399 c->chip_version, c->mcode_date, c->mcode_version,
3628 ASC_PRT_NEXT(); 3400 v->err_code);
3629
3630 len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
3631 "mcode_version 0x%x, err_code %u\n",
3632 c->chip_version, c->mcode_date, c->mcode_version,
3633 v->err_code);
3634 ASC_PRT_NEXT();
3635 3401
3636 /* Current number of commands waiting for the host. */ 3402 /* Current number of commands waiting for the host. */
3637 len = asc_prt_line(cp, leftlen, 3403 seq_printf(m,
3638 " Total Command Pending: %d\n", v->cur_total_qng); 3404 " Total Command Pending: %d\n", v->cur_total_qng);
3639 ASC_PRT_NEXT();
3640 3405
3641 len = asc_prt_line(cp, leftlen, " Command Queuing:"); 3406 seq_printf(m, " Command Queuing:");
3642 ASC_PRT_NEXT();
3643 for (i = 0; i <= ASC_MAX_TID; i++) { 3407 for (i = 0; i <= ASC_MAX_TID; i++) {
3644 if ((chip_scsi_id == i) || 3408 if ((chip_scsi_id == i) ||
3645 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3409 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3646 continue; 3410 continue;
3647 } 3411 }
3648 len = asc_prt_line(cp, leftlen, " %X:%c", 3412 seq_printf(m, " %X:%c",
3649 i, 3413 i,
3650 (v-> 3414 (v->use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3651 use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
3652 'Y' : 'N');
3653 ASC_PRT_NEXT();
3654 } 3415 }
3655 len = asc_prt_line(cp, leftlen, "\n"); 3416 seq_printf(m, "\n");
3656 ASC_PRT_NEXT();
3657 3417
3658 /* Current number of commands waiting for a device. */ 3418 /* Current number of commands waiting for a device. */
3659 len = asc_prt_line(cp, leftlen, " Command Queue Pending:"); 3419 seq_printf(m, " Command Queue Pending:");
3660 ASC_PRT_NEXT();
3661 for (i = 0; i <= ASC_MAX_TID; i++) { 3420 for (i = 0; i <= ASC_MAX_TID; i++) {
3662 if ((chip_scsi_id == i) || 3421 if ((chip_scsi_id == i) ||
3663 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3422 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3664 continue; 3423 continue;
3665 } 3424 }
3666 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]); 3425 seq_printf(m, " %X:%u", i, v->cur_dvc_qng[i]);
3667 ASC_PRT_NEXT();
3668 } 3426 }
3669 len = asc_prt_line(cp, leftlen, "\n"); 3427 seq_printf(m, "\n");
3670 ASC_PRT_NEXT();
3671 3428
3672 /* Current limit on number of commands that can be sent to a device. */ 3429 /* Current limit on number of commands that can be sent to a device. */
3673 len = asc_prt_line(cp, leftlen, " Command Queue Limit:"); 3430 seq_printf(m, " Command Queue Limit:");
3674 ASC_PRT_NEXT();
3675 for (i = 0; i <= ASC_MAX_TID; i++) { 3431 for (i = 0; i <= ASC_MAX_TID; i++) {
3676 if ((chip_scsi_id == i) || 3432 if ((chip_scsi_id == i) ||
3677 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3433 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3678 continue; 3434 continue;
3679 } 3435 }
3680 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]); 3436 seq_printf(m, " %X:%u", i, v->max_dvc_qng[i]);
3681 ASC_PRT_NEXT();
3682 } 3437 }
3683 len = asc_prt_line(cp, leftlen, "\n"); 3438 seq_printf(m, "\n");
3684 ASC_PRT_NEXT();
3685 3439
3686 /* Indicate whether the device has returned queue full status. */ 3440 /* Indicate whether the device has returned queue full status. */
3687 len = asc_prt_line(cp, leftlen, " Command Queue Full:"); 3441 seq_printf(m, " Command Queue Full:");
3688 ASC_PRT_NEXT();
3689 for (i = 0; i <= ASC_MAX_TID; i++) { 3442 for (i = 0; i <= ASC_MAX_TID; i++) {
3690 if ((chip_scsi_id == i) || 3443 if ((chip_scsi_id == i) ||
3691 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3444 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3692 continue; 3445 continue;
3693 } 3446 }
3694 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) { 3447 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i))
3695 len = asc_prt_line(cp, leftlen, " %X:Y-%d", 3448 seq_printf(m, " %X:Y-%d",
3696 i, boardp->queue_full_cnt[i]); 3449 i, boardp->queue_full_cnt[i]);
3697 } else { 3450 else
3698 len = asc_prt_line(cp, leftlen, " %X:N", i); 3451 seq_printf(m, " %X:N", i);
3699 }
3700 ASC_PRT_NEXT();
3701 } 3452 }
3702 len = asc_prt_line(cp, leftlen, "\n"); 3453 seq_printf(m, "\n");
3703 ASC_PRT_NEXT();
3704 3454
3705 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:"); 3455 seq_printf(m, " Synchronous Transfer:");
3706 ASC_PRT_NEXT();
3707 for (i = 0; i <= ASC_MAX_TID; i++) { 3456 for (i = 0; i <= ASC_MAX_TID; i++) {
3708 if ((chip_scsi_id == i) || 3457 if ((chip_scsi_id == i) ||
3709 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3458 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3710 continue; 3459 continue;
3711 } 3460 }
3712 len = asc_prt_line(cp, leftlen, " %X:%c", 3461 seq_printf(m, " %X:%c",
3713 i, 3462 i,
3714 (v-> 3463 (v->sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3715 sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3716 'N');
3717 ASC_PRT_NEXT();
3718 } 3464 }
3719 len = asc_prt_line(cp, leftlen, "\n"); 3465 seq_printf(m, "\n");
3720 ASC_PRT_NEXT();
3721 3466
3722 for (i = 0; i <= ASC_MAX_TID; i++) { 3467 for (i = 0; i <= ASC_MAX_TID; i++) {
3723 uchar syn_period_ix; 3468 uchar syn_period_ix;
@@ -3728,69 +3473,48 @@ static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3728 continue; 3473 continue;
3729 } 3474 }
3730 3475
3731 len = asc_prt_line(cp, leftlen, " %X:", i); 3476 seq_printf(m, " %X:", i);
3732 ASC_PRT_NEXT();
3733 3477
3734 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) { 3478 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
3735 len = asc_prt_line(cp, leftlen, " Asynchronous"); 3479 seq_printf(m, " Asynchronous");
3736 ASC_PRT_NEXT();
3737 } else { 3480 } else {
3738 syn_period_ix = 3481 syn_period_ix =
3739 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index - 3482 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
3740 1); 3483 1);
3741 3484
3742 len = asc_prt_line(cp, leftlen, 3485 seq_printf(m,
3743 " Transfer Period Factor: %d (%d.%d Mhz),", 3486 " Transfer Period Factor: %d (%d.%d Mhz),",
3744 v->sdtr_period_tbl[syn_period_ix], 3487 v->sdtr_period_tbl[syn_period_ix],
3745 250 / 3488 250 / v->sdtr_period_tbl[syn_period_ix],
3746 v->sdtr_period_tbl[syn_period_ix], 3489 ASC_TENTHS(250,
3747 ASC_TENTHS(250, 3490 v->sdtr_period_tbl[syn_period_ix]));
3748 v->
3749 sdtr_period_tbl
3750 [syn_period_ix]));
3751 ASC_PRT_NEXT();
3752 3491
3753 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d", 3492 seq_printf(m, " REQ/ACK Offset: %d",
3754 boardp-> 3493 boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET);
3755 sdtr_data[i] & ASC_SYN_MAX_OFFSET);
3756 ASC_PRT_NEXT();
3757 } 3494 }
3758 3495
3759 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { 3496 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3760 len = asc_prt_line(cp, leftlen, "*\n"); 3497 seq_printf(m, "*\n");
3761 renegotiate = 1; 3498 renegotiate = 1;
3762 } else { 3499 } else {
3763 len = asc_prt_line(cp, leftlen, "\n"); 3500 seq_printf(m, "\n");
3764 } 3501 }
3765 ASC_PRT_NEXT();
3766 } 3502 }
3767 3503
3768 if (renegotiate) { 3504 if (renegotiate) {
3769 len = asc_prt_line(cp, leftlen, 3505 seq_printf(m,
3770 " * = Re-negotiation pending before next command.\n"); 3506 " * = Re-negotiation pending before next command.\n");
3771 ASC_PRT_NEXT();
3772 } 3507 }
3773
3774 return totlen;
3775} 3508}
3776 3509
3777/* 3510/*
3778 * asc_prt_adv_board_info() 3511 * asc_prt_adv_board_info()
3779 * 3512 *
3780 * Print dynamic board configuration information. 3513 * Print dynamic board configuration information.
3781 *
3782 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3783 * cf. asc_prt_line().
3784 *
3785 * Return the number of characters copied into 'cp'. No more than
3786 * 'cplen' characters will be copied to 'cp'.
3787 */ 3514 */
3788static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen) 3515static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost)
3789{ 3516{
3790 struct asc_board *boardp = shost_priv(shost); 3517 struct asc_board *boardp = shost_priv(shost);
3791 int leftlen;
3792 int totlen;
3793 int len;
3794 int i; 3518 int i;
3795 ADV_DVC_VAR *v; 3519 ADV_DVC_VAR *v;
3796 ADV_DVC_CFG *c; 3520 ADV_DVC_CFG *c;
@@ -3809,47 +3533,35 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3809 iop_base = v->iop_base; 3533 iop_base = v->iop_base;
3810 chip_scsi_id = v->chip_scsi_id; 3534 chip_scsi_id = v->chip_scsi_id;
3811 3535
3812 leftlen = cplen; 3536 seq_printf(m,
3813 totlen = len = 0; 3537 "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3814 3538 shost->host_no);
3815 len = asc_prt_line(cp, leftlen,
3816 "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3817 shost->host_no);
3818 ASC_PRT_NEXT();
3819 3539
3820 len = asc_prt_line(cp, leftlen, 3540 seq_printf(m,
3821 " iop_base 0x%lx, cable_detect: %X, err_code %u\n", 3541 " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
3822 v->iop_base, 3542 (unsigned long)v->iop_base,
3823 AdvReadWordRegister(iop_base, 3543 AdvReadWordRegister(iop_base,IOPW_SCSI_CFG1) & CABLE_DETECT,
3824 IOPW_SCSI_CFG1) & CABLE_DETECT, 3544 v->err_code);
3825 v->err_code);
3826 ASC_PRT_NEXT();
3827 3545
3828 len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, " 3546 seq_printf(m, " chip_version %u, mcode_date 0x%x, "
3829 "mcode_version 0x%x\n", c->chip_version, 3547 "mcode_version 0x%x\n", c->chip_version,
3830 c->mcode_date, c->mcode_version); 3548 c->mcode_date, c->mcode_version);
3831 ASC_PRT_NEXT();
3832 3549
3833 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able); 3550 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
3834 len = asc_prt_line(cp, leftlen, " Queuing Enabled:"); 3551 seq_printf(m, " Queuing Enabled:");
3835 ASC_PRT_NEXT();
3836 for (i = 0; i <= ADV_MAX_TID; i++) { 3552 for (i = 0; i <= ADV_MAX_TID; i++) {
3837 if ((chip_scsi_id == i) || 3553 if ((chip_scsi_id == i) ||
3838 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3554 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3839 continue; 3555 continue;
3840 } 3556 }
3841 3557
3842 len = asc_prt_line(cp, leftlen, " %X:%c", 3558 seq_printf(m, " %X:%c",
3843 i, 3559 i,
3844 (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 3560 (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3845 'N');
3846 ASC_PRT_NEXT();
3847 } 3561 }
3848 len = asc_prt_line(cp, leftlen, "\n"); 3562 seq_printf(m, "\n");
3849 ASC_PRT_NEXT();
3850 3563
3851 len = asc_prt_line(cp, leftlen, " Queue Limit:"); 3564 seq_printf(m, " Queue Limit:");
3852 ASC_PRT_NEXT();
3853 for (i = 0; i <= ADV_MAX_TID; i++) { 3565 for (i = 0; i <= ADV_MAX_TID; i++) {
3854 if ((chip_scsi_id == i) || 3566 if ((chip_scsi_id == i) ||
3855 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3567 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
@@ -3859,14 +3571,11 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3859 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i, 3571 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
3860 lrambyte); 3572 lrambyte);
3861 3573
3862 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte); 3574 seq_printf(m, " %X:%d", i, lrambyte);
3863 ASC_PRT_NEXT();
3864 } 3575 }
3865 len = asc_prt_line(cp, leftlen, "\n"); 3576 seq_printf(m, "\n");
3866 ASC_PRT_NEXT();
3867 3577
3868 len = asc_prt_line(cp, leftlen, " Command Pending:"); 3578 seq_printf(m, " Command Pending:");
3869 ASC_PRT_NEXT();
3870 for (i = 0; i <= ADV_MAX_TID; i++) { 3579 for (i = 0; i <= ADV_MAX_TID; i++) {
3871 if ((chip_scsi_id == i) || 3580 if ((chip_scsi_id == i) ||
3872 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3581 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
@@ -3876,33 +3585,26 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3876 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i, 3585 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
3877 lrambyte); 3586 lrambyte);
3878 3587
3879 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte); 3588 seq_printf(m, " %X:%d", i, lrambyte);
3880 ASC_PRT_NEXT();
3881 } 3589 }
3882 len = asc_prt_line(cp, leftlen, "\n"); 3590 seq_printf(m, "\n");
3883 ASC_PRT_NEXT();
3884 3591
3885 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able); 3592 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
3886 len = asc_prt_line(cp, leftlen, " Wide Enabled:"); 3593 seq_printf(m, " Wide Enabled:");
3887 ASC_PRT_NEXT();
3888 for (i = 0; i <= ADV_MAX_TID; i++) { 3594 for (i = 0; i <= ADV_MAX_TID; i++) {
3889 if ((chip_scsi_id == i) || 3595 if ((chip_scsi_id == i) ||
3890 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3596 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3891 continue; 3597 continue;
3892 } 3598 }
3893 3599
3894 len = asc_prt_line(cp, leftlen, " %X:%c", 3600 seq_printf(m, " %X:%c",
3895 i, 3601 i,
3896 (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 3602 (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3897 'N');
3898 ASC_PRT_NEXT();
3899 } 3603 }
3900 len = asc_prt_line(cp, leftlen, "\n"); 3604 seq_printf(m, "\n");
3901 ASC_PRT_NEXT();
3902 3605
3903 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done); 3606 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
3904 len = asc_prt_line(cp, leftlen, " Transfer Bit Width:"); 3607 seq_printf(m, " Transfer Bit Width:");
3905 ASC_PRT_NEXT();
3906 for (i = 0; i <= ADV_MAX_TID; i++) { 3608 for (i = 0; i <= ADV_MAX_TID; i++) {
3907 if ((chip_scsi_id == i) || 3609 if ((chip_scsi_id == i) ||
3908 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3610 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
@@ -3913,37 +3615,30 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3913 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i), 3615 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
3914 lramword); 3616 lramword);
3915 3617
3916 len = asc_prt_line(cp, leftlen, " %X:%d", 3618 seq_printf(m, " %X:%d",
3917 i, (lramword & 0x8000) ? 16 : 8); 3619 i, (lramword & 0x8000) ? 16 : 8);
3918 ASC_PRT_NEXT();
3919 3620
3920 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) && 3621 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
3921 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { 3622 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3922 len = asc_prt_line(cp, leftlen, "*"); 3623 seq_printf(m, "*");
3923 ASC_PRT_NEXT();
3924 renegotiate = 1; 3624 renegotiate = 1;
3925 } 3625 }
3926 } 3626 }
3927 len = asc_prt_line(cp, leftlen, "\n"); 3627 seq_printf(m, "\n");
3928 ASC_PRT_NEXT();
3929 3628
3930 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able); 3629 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
3931 len = asc_prt_line(cp, leftlen, " Synchronous Enabled:"); 3630 seq_printf(m, " Synchronous Enabled:");
3932 ASC_PRT_NEXT();
3933 for (i = 0; i <= ADV_MAX_TID; i++) { 3631 for (i = 0; i <= ADV_MAX_TID; i++) {
3934 if ((chip_scsi_id == i) || 3632 if ((chip_scsi_id == i) ||
3935 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3633 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3936 continue; 3634 continue;
3937 } 3635 }
3938 3636
3939 len = asc_prt_line(cp, leftlen, " %X:%c", 3637 seq_printf(m, " %X:%c",
3940 i, 3638 i,
3941 (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 3639 (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3942 'N');
3943 ASC_PRT_NEXT();
3944 } 3640 }
3945 len = asc_prt_line(cp, leftlen, "\n"); 3641 seq_printf(m, "\n");
3946 ASC_PRT_NEXT();
3947 3642
3948 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done); 3643 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
3949 for (i = 0; i <= ADV_MAX_TID; i++) { 3644 for (i = 0; i <= ADV_MAX_TID; i++) {
@@ -3959,358 +3654,170 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3959 continue; 3654 continue;
3960 } 3655 }
3961 3656
3962 len = asc_prt_line(cp, leftlen, " %X:", i); 3657 seq_printf(m, " %X:", i);
3963 ASC_PRT_NEXT();
3964 3658
3965 if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */ 3659 if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
3966 len = asc_prt_line(cp, leftlen, " Asynchronous"); 3660 seq_printf(m, " Asynchronous");
3967 ASC_PRT_NEXT();
3968 } else { 3661 } else {
3969 len = 3662 seq_printf(m, " Transfer Period Factor: ");
3970 asc_prt_line(cp, leftlen,
3971 " Transfer Period Factor: ");
3972 ASC_PRT_NEXT();
3973 3663
3974 if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */ 3664 if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
3975 len = 3665 seq_printf(m, "9 (80.0 Mhz),");
3976 asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
3977 ASC_PRT_NEXT();
3978 } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */ 3666 } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
3979 len = 3667 seq_printf(m, "10 (40.0 Mhz),");
3980 asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
3981 ASC_PRT_NEXT();
3982 } else { /* 20 Mhz or below. */ 3668 } else { /* 20 Mhz or below. */
3983 3669
3984 period = (((lramword >> 8) * 25) + 50) / 4; 3670 period = (((lramword >> 8) * 25) + 50) / 4;
3985 3671
3986 if (period == 0) { /* Should never happen. */ 3672 if (period == 0) { /* Should never happen. */
3987 len = 3673 seq_printf(m, "%d (? Mhz), ", period);
3988 asc_prt_line(cp, leftlen,
3989 "%d (? Mhz), ");
3990 ASC_PRT_NEXT();
3991 } else { 3674 } else {
3992 len = asc_prt_line(cp, leftlen, 3675 seq_printf(m,
3993 "%d (%d.%d Mhz),", 3676 "%d (%d.%d Mhz),",
3994 period, 250 / period, 3677 period, 250 / period,
3995 ASC_TENTHS(250, 3678 ASC_TENTHS(250, period));
3996 period));
3997 ASC_PRT_NEXT();
3998 } 3679 }
3999 } 3680 }
4000 3681
4001 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d", 3682 seq_printf(m, " REQ/ACK Offset: %d",
4002 lramword & 0x1F); 3683 lramword & 0x1F);
4003 ASC_PRT_NEXT();
4004 } 3684 }
4005 3685
4006 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { 3686 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
4007 len = asc_prt_line(cp, leftlen, "*\n"); 3687 seq_printf(m, "*\n");
4008 renegotiate = 1; 3688 renegotiate = 1;
4009 } else { 3689 } else {
4010 len = asc_prt_line(cp, leftlen, "\n"); 3690 seq_printf(m, "\n");
4011 } 3691 }
4012 ASC_PRT_NEXT();
4013 } 3692 }
4014 3693
4015 if (renegotiate) { 3694 if (renegotiate) {
4016 len = asc_prt_line(cp, leftlen, 3695 seq_printf(m,
4017 " * = Re-negotiation pending before next command.\n"); 3696 " * = Re-negotiation pending before next command.\n");
4018 ASC_PRT_NEXT();
4019 } 3697 }
4020
4021 return totlen;
4022}
4023
4024/*
4025 * asc_proc_copy()
4026 *
4027 * Copy proc information to a read buffer taking into account the current
4028 * read offset in the file and the remaining space in the read buffer.
4029 */
4030static int
4031asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
4032 char *cp, int cplen)
4033{
4034 int cnt = 0;
4035
4036 ASC_DBG(2, "offset %d, advoffset %d, cplen %d\n",
4037 (unsigned)offset, (unsigned)advoffset, cplen);
4038 if (offset <= advoffset) {
4039 /* Read offset below current offset, copy everything. */
4040 cnt = min(cplen, leftlen);
4041 ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
4042 (ulong)curbuf, (ulong)cp, cnt);
4043 memcpy(curbuf, cp, cnt);
4044 } else if (offset < advoffset + cplen) {
4045 /* Read offset within current range, partial copy. */
4046 cnt = (advoffset + cplen) - offset;
4047 cp = (cp + cplen) - cnt;
4048 cnt = min(cnt, leftlen);
4049 ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
4050 (ulong)curbuf, (ulong)cp, cnt);
4051 memcpy(curbuf, cp, cnt);
4052 }
4053 return cnt;
4054} 3698}
4055 3699
4056#ifdef ADVANSYS_STATS 3700#ifdef ADVANSYS_STATS
4057/* 3701/*
4058 * asc_prt_board_stats() 3702 * asc_prt_board_stats()
4059 *
4060 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
4061 * cf. asc_prt_line().
4062 *
4063 * Return the number of characters copied into 'cp'. No more than
4064 * 'cplen' characters will be copied to 'cp'.
4065 */ 3703 */
4066static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen) 3704static void asc_prt_board_stats(struct seq_file *m, struct Scsi_Host *shost)
4067{ 3705{
4068 struct asc_board *boardp = shost_priv(shost); 3706 struct asc_board *boardp = shost_priv(shost);
4069 struct asc_stats *s = &boardp->asc_stats; 3707 struct asc_stats *s = &boardp->asc_stats;
4070 3708
4071 int leftlen = cplen; 3709 seq_printf(m,
4072 int len, totlen = 0; 3710 "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
3711 shost->host_no);
4073 3712
4074 len = asc_prt_line(cp, leftlen, 3713 seq_printf(m,
4075 "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n", 3714 " queuecommand %u, reset %u, biosparam %u, interrupt %u\n",
4076 shost->host_no); 3715 s->queuecommand, s->reset, s->biosparam,
4077 ASC_PRT_NEXT(); 3716 s->interrupt);
4078 3717
4079 len = asc_prt_line(cp, leftlen, 3718 seq_printf(m,
4080 " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n", 3719 " callback %u, done %u, build_error %u, build_noreq %u, build_nosg %u\n",
4081 s->queuecommand, s->reset, s->biosparam, 3720 s->callback, s->done, s->build_error,
4082 s->interrupt); 3721 s->adv_build_noreq, s->adv_build_nosg);
4083 ASC_PRT_NEXT();
4084 3722
4085 len = asc_prt_line(cp, leftlen, 3723 seq_printf(m,
4086 " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n", 3724 " exe_noerror %u, exe_busy %u, exe_error %u, exe_unknown %u\n",
4087 s->callback, s->done, s->build_error, 3725 s->exe_noerror, s->exe_busy, s->exe_error,
4088 s->adv_build_noreq, s->adv_build_nosg); 3726 s->exe_unknown);
4089 ASC_PRT_NEXT();
4090
4091 len = asc_prt_line(cp, leftlen,
4092 " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
4093 s->exe_noerror, s->exe_busy, s->exe_error,
4094 s->exe_unknown);
4095 ASC_PRT_NEXT();
4096 3727
4097 /* 3728 /*
4098 * Display data transfer statistics. 3729 * Display data transfer statistics.
4099 */ 3730 */
4100 if (s->xfer_cnt > 0) { 3731 if (s->xfer_cnt > 0) {
4101 len = asc_prt_line(cp, leftlen, " xfer_cnt %lu, xfer_elem %lu, ", 3732 seq_printf(m, " xfer_cnt %u, xfer_elem %u, ",
4102 s->xfer_cnt, s->xfer_elem); 3733 s->xfer_cnt, s->xfer_elem);
4103 ASC_PRT_NEXT();
4104 3734
4105 len = asc_prt_line(cp, leftlen, "xfer_bytes %lu.%01lu kb\n", 3735 seq_printf(m, "xfer_bytes %u.%01u kb\n",
4106 s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2)); 3736 s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2));
4107 ASC_PRT_NEXT();
4108 3737
4109 /* Scatter gather transfer statistics */ 3738 /* Scatter gather transfer statistics */
4110 len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ", 3739 seq_printf(m, " avg_num_elem %u.%01u, ",
4111 s->xfer_elem / s->xfer_cnt, 3740 s->xfer_elem / s->xfer_cnt,
4112 ASC_TENTHS(s->xfer_elem, s->xfer_cnt)); 3741 ASC_TENTHS(s->xfer_elem, s->xfer_cnt));
4113 ASC_PRT_NEXT();
4114 3742
4115 len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ", 3743 seq_printf(m, "avg_elem_size %u.%01u kb, ",
4116 (s->xfer_sect / 2) / s->xfer_elem, 3744 (s->xfer_sect / 2) / s->xfer_elem,
4117 ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem)); 3745 ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem));
4118 ASC_PRT_NEXT();
4119 3746
4120 len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n", 3747 seq_printf(m, "avg_xfer_size %u.%01u kb\n",
4121 (s->xfer_sect / 2) / s->xfer_cnt, 3748 (s->xfer_sect / 2) / s->xfer_cnt,
4122 ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt)); 3749 ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt));
4123 ASC_PRT_NEXT();
4124 } 3750 }
4125
4126 return totlen;
4127} 3751}
4128#endif /* ADVANSYS_STATS */ 3752#endif /* ADVANSYS_STATS */
4129 3753
4130/* 3754/*
4131 * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...} 3755 * advansys_show_info() - /proc/scsi/advansys/{0,1,2,3,...}
4132 * 3756 *
4133 * *buffer: I/O buffer 3757 * m: seq_file to print into
4134 * **start: if inout == FALSE pointer into buffer where user read should start 3758 * shost: Scsi_Host
4135 * offset: current offset into a /proc/scsi/advansys/[0...] file
4136 * length: length of buffer
4137 * hostno: Scsi_Host host_no
4138 * inout: TRUE - user is writing; FALSE - user is reading
4139 * 3759 *
4140 * Return the number of bytes read from or written to a 3760 * Return the number of bytes read from or written to a
4141 * /proc/scsi/advansys/[0...] file. 3761 * /proc/scsi/advansys/[0...] file.
4142 *
4143 * Note: This function uses the per board buffer 'prtbuf' which is
4144 * allocated when the board is initialized in advansys_detect(). The
4145 * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
4146 * used to write to the buffer. The way asc_proc_copy() is written
4147 * if 'prtbuf' is too small it will not be overwritten. Instead the
4148 * user just won't get all the available statistics.
4149 */ 3762 */
4150static int 3763static int
4151advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start, 3764advansys_show_info(struct seq_file *m, struct Scsi_Host *shost)
4152 off_t offset, int length, int inout)
4153{ 3765{
4154 struct asc_board *boardp = shost_priv(shost); 3766 struct asc_board *boardp = shost_priv(shost);
4155 char *cp;
4156 int cplen;
4157 int cnt;
4158 int totcnt;
4159 int leftlen;
4160 char *curbuf;
4161 off_t advoffset;
4162 3767
4163 ASC_DBG(1, "begin\n"); 3768 ASC_DBG(1, "begin\n");
4164 3769
4165 /* 3770 /*
4166 * User write not supported.
4167 */
4168 if (inout == TRUE)
4169 return -ENOSYS;
4170
4171 /*
4172 * User read of /proc/scsi/advansys/[0...] file. 3771 * User read of /proc/scsi/advansys/[0...] file.
4173 */ 3772 */
4174 3773
4175 /* Copy read data starting at the beginning of the buffer. */
4176 *start = buffer;
4177 curbuf = buffer;
4178 advoffset = 0;
4179 totcnt = 0;
4180 leftlen = length;
4181
4182 /* 3774 /*
4183 * Get board configuration information. 3775 * Get board configuration information.
4184 * 3776 *
4185 * advansys_info() returns the board string from its own static buffer. 3777 * advansys_info() returns the board string from its own static buffer.
4186 */ 3778 */
4187 cp = (char *)advansys_info(shost);
4188 strcat(cp, "\n");
4189 cplen = strlen(cp);
4190 /* Copy board information. */ 3779 /* Copy board information. */
4191 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); 3780 seq_printf(m, "%s\n", (char *)advansys_info(shost));
4192 totcnt += cnt;
4193 leftlen -= cnt;
4194 if (leftlen == 0) {
4195 ASC_DBG(1, "totcnt %d\n", totcnt);
4196 return totcnt;
4197 }
4198 advoffset += cplen;
4199 curbuf += cnt;
4200
4201 /* 3781 /*
4202 * Display Wide Board BIOS Information. 3782 * Display Wide Board BIOS Information.
4203 */ 3783 */
4204 if (!ASC_NARROW_BOARD(boardp)) { 3784 if (!ASC_NARROW_BOARD(boardp))
4205 cp = boardp->prtbuf; 3785 asc_prt_adv_bios(m, shost);
4206 cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
4207 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4208 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
4209 cplen);
4210 totcnt += cnt;
4211 leftlen -= cnt;
4212 if (leftlen == 0) {
4213 ASC_DBG(1, "totcnt %d\n", totcnt);
4214 return totcnt;
4215 }
4216 advoffset += cplen;
4217 curbuf += cnt;
4218 }
4219 3786
4220 /* 3787 /*
4221 * Display driver information for each device attached to the board. 3788 * Display driver information for each device attached to the board.
4222 */ 3789 */
4223 cp = boardp->prtbuf; 3790 asc_prt_board_devices(m, shost);
4224 cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
4225 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4226 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4227 totcnt += cnt;
4228 leftlen -= cnt;
4229 if (leftlen == 0) {
4230 ASC_DBG(1, "totcnt %d\n", totcnt);
4231 return totcnt;
4232 }
4233 advoffset += cplen;
4234 curbuf += cnt;
4235 3791
4236 /* 3792 /*
4237 * Display EEPROM configuration for the board. 3793 * Display EEPROM configuration for the board.
4238 */ 3794 */
4239 cp = boardp->prtbuf; 3795 if (ASC_NARROW_BOARD(boardp))
4240 if (ASC_NARROW_BOARD(boardp)) { 3796 asc_prt_asc_board_eeprom(m, shost);
4241 cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE); 3797 else
4242 } else { 3798 asc_prt_adv_board_eeprom(m, shost);
4243 cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
4244 }
4245 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4246 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4247 totcnt += cnt;
4248 leftlen -= cnt;
4249 if (leftlen == 0) {
4250 ASC_DBG(1, "totcnt %d\n", totcnt);
4251 return totcnt;
4252 }
4253 advoffset += cplen;
4254 curbuf += cnt;
4255 3799
4256 /* 3800 /*
4257 * Display driver configuration and information for the board. 3801 * Display driver configuration and information for the board.
4258 */ 3802 */
4259 cp = boardp->prtbuf; 3803 asc_prt_driver_conf(m, shost);
4260 cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
4261 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4262 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4263 totcnt += cnt;
4264 leftlen -= cnt;
4265 if (leftlen == 0) {
4266 ASC_DBG(1, "totcnt %d\n", totcnt);
4267 return totcnt;
4268 }
4269 advoffset += cplen;
4270 curbuf += cnt;
4271 3804
4272#ifdef ADVANSYS_STATS 3805#ifdef ADVANSYS_STATS
4273 /* 3806 /*
4274 * Display driver statistics for the board. 3807 * Display driver statistics for the board.
4275 */ 3808 */
4276 cp = boardp->prtbuf; 3809 asc_prt_board_stats(m, shost);
4277 cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
4278 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4279 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4280 totcnt += cnt;
4281 leftlen -= cnt;
4282 if (leftlen == 0) {
4283 ASC_DBG(1, "totcnt %d\n", totcnt);
4284 return totcnt;
4285 }
4286 advoffset += cplen;
4287 curbuf += cnt;
4288#endif /* ADVANSYS_STATS */ 3810#endif /* ADVANSYS_STATS */
4289 3811
4290 /* 3812 /*
4291 * Display Asc Library dynamic configuration information 3813 * Display Asc Library dynamic configuration information
4292 * for the board. 3814 * for the board.
4293 */ 3815 */
4294 cp = boardp->prtbuf; 3816 if (ASC_NARROW_BOARD(boardp))
4295 if (ASC_NARROW_BOARD(boardp)) { 3817 asc_prt_asc_board_info(m, shost);
4296 cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE); 3818 else
4297 } else { 3819 asc_prt_adv_board_info(m, shost);
4298 cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE); 3820 return 0;
4299 }
4300 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4301 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4302 totcnt += cnt;
4303 leftlen -= cnt;
4304 if (leftlen == 0) {
4305 ASC_DBG(1, "totcnt %d\n", totcnt);
4306 return totcnt;
4307 }
4308 advoffset += cplen;
4309 curbuf += cnt;
4310
4311 ASC_DBG(1, "totcnt %d\n", totcnt);
4312
4313 return totcnt;
4314} 3821}
4315#endif /* CONFIG_PROC_FS */ 3822#endif /* CONFIG_PROC_FS */
4316 3823
@@ -11743,7 +11250,7 @@ static int AdvInitGetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
11743static struct scsi_host_template advansys_template = { 11250static struct scsi_host_template advansys_template = {
11744 .proc_name = DRV_NAME, 11251 .proc_name = DRV_NAME,
11745#ifdef CONFIG_PROC_FS 11252#ifdef CONFIG_PROC_FS
11746 .proc_info = advansys_proc_info, 11253 .show_info = advansys_show_info,
11747#endif 11254#endif
11748 .name = DRV_NAME, 11255 .name = DRV_NAME,
11749 .info = advansys_info, 11256 .info = advansys_info,
@@ -11939,20 +11446,6 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
11939#endif /* CONFIG_PCI */ 11446#endif /* CONFIG_PCI */
11940 } 11447 }
11941 11448
11942#ifdef CONFIG_PROC_FS
11943 /*
11944 * Allocate buffer for printing information from
11945 * /proc/scsi/advansys/[0...].
11946 */
11947 boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
11948 if (!boardp->prtbuf) {
11949 shost_printk(KERN_ERR, shost, "kmalloc(%d) returned NULL\n",
11950 ASC_PRTBUF_SIZE);
11951 ret = -ENOMEM;
11952 goto err_unmap;
11953 }
11954#endif /* CONFIG_PROC_FS */
11955
11956 if (ASC_NARROW_BOARD(boardp)) { 11449 if (ASC_NARROW_BOARD(boardp)) {
11957 /* 11450 /*
11958 * Set the board bus type and PCI IRQ before 11451 * Set the board bus type and PCI IRQ before
@@ -12010,7 +11503,7 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
12010 } 11503 }
12011 11504
12012 if (ret) 11505 if (ret)
12013 goto err_free_proc; 11506 goto err_unmap;
12014 11507
12015 /* 11508 /*
12016 * Save the EEPROM configuration so that it can be displayed 11509 * Save the EEPROM configuration so that it can be displayed
@@ -12055,7 +11548,7 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
12055 ASC_DBG(2, "AscInitSetConfig()\n"); 11548 ASC_DBG(2, "AscInitSetConfig()\n");
12056 ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0; 11549 ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0;
12057 if (ret) 11550 if (ret)
12058 goto err_free_proc; 11551 goto err_unmap;
12059 } else { 11552 } else {
12060 ADVEEP_3550_CONFIG *ep_3550; 11553 ADVEEP_3550_CONFIG *ep_3550;
12061 ADVEEP_38C0800_CONFIG *ep_38C0800; 11554 ADVEEP_38C0800_CONFIG *ep_38C0800;
@@ -12290,7 +11783,7 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
12290 shost_printk(KERN_ERR, shost, "request_dma() " 11783 shost_printk(KERN_ERR, shost, "request_dma() "
12291 "%d failed %d\n", 11784 "%d failed %d\n",
12292 shost->dma_channel, ret); 11785 shost->dma_channel, ret);
12293 goto err_free_proc; 11786 goto err_unmap;
12294 } 11787 }
12295 AscEnableIsaDma(shost->dma_channel); 11788 AscEnableIsaDma(shost->dma_channel);
12296 } 11789 }
@@ -12371,8 +11864,6 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
12371 if (shost->dma_channel != NO_ISA_DMA) 11864 if (shost->dma_channel != NO_ISA_DMA)
12372 free_dma(shost->dma_channel); 11865 free_dma(shost->dma_channel);
12373#endif 11866#endif
12374 err_free_proc:
12375 kfree(boardp->prtbuf);
12376 err_unmap: 11867 err_unmap:
12377 if (boardp->ioremap_addr) 11868 if (boardp->ioremap_addr)
12378 iounmap(boardp->ioremap_addr); 11869 iounmap(boardp->ioremap_addr);
@@ -12406,7 +11897,6 @@ static int advansys_release(struct Scsi_Host *shost)
12406 iounmap(board->ioremap_addr); 11897 iounmap(board->ioremap_addr);
12407 advansys_wide_free_mem(board); 11898 advansys_wide_free_mem(board);
12408 } 11899 }
12409 kfree(board->prtbuf);
12410 scsi_host_put(shost); 11900 scsi_host_put(shost);
12411 ASC_DBG(1, "end\n"); 11901 ASC_DBG(1, "end\n");
12412 return 0; 11902 return 0;
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index a284be17699f..3f7b6fee0a74 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -2977,11 +2977,10 @@ static void show_queues(struct Scsi_Host *shpnt)
2977} 2977}
2978 2978
2979#undef SPRINTF 2979#undef SPRINTF
2980#define SPRINTF(args...) pos += sprintf(pos, ## args) 2980#define SPRINTF(args...) seq_printf(m, ##args)
2981 2981
2982static int get_command(char *pos, Scsi_Cmnd * ptr) 2982static void get_command(struct seq_file *m, Scsi_Cmnd * ptr)
2983{ 2983{
2984 char *start = pos;
2985 int i; 2984 int i;
2986 2985
2987 SPRINTF("%p: target=%d; lun=%d; cmnd=( ", 2986 SPRINTF("%p: target=%d; lun=%d; cmnd=( ",
@@ -3011,13 +3010,10 @@ static int get_command(char *pos, Scsi_Cmnd * ptr)
3011 if (ptr->SCp.phase & syncneg) 3010 if (ptr->SCp.phase & syncneg)
3012 SPRINTF("syncneg|"); 3011 SPRINTF("syncneg|");
3013 SPRINTF("; next=0x%p\n", SCNEXT(ptr)); 3012 SPRINTF("; next=0x%p\n", SCNEXT(ptr));
3014
3015 return (pos - start);
3016} 3013}
3017 3014
3018static int get_ports(struct Scsi_Host *shpnt, char *pos) 3015static void get_ports(struct seq_file *m, struct Scsi_Host *shpnt)
3019{ 3016{
3020 char *start = pos;
3021 int s; 3017 int s;
3022 3018
3023 SPRINTF("\n%s: %s(%s) ", CURRENT_SC ? "on bus" : "waiting", states[STATE].name, states[PREVSTATE].name); 3019 SPRINTF("\n%s: %s(%s) ", CURRENT_SC ? "on bus" : "waiting", states[STATE].name, states[PREVSTATE].name);
@@ -3273,11 +3269,9 @@ static int get_ports(struct Scsi_Host *shpnt, char *pos)
3273 if (s & ENREQINIT) 3269 if (s & ENREQINIT)
3274 SPRINTF("ENREQINIT "); 3270 SPRINTF("ENREQINIT ");
3275 SPRINTF(")\n"); 3271 SPRINTF(")\n");
3276
3277 return (pos - start);
3278} 3272}
3279 3273
3280static int aha152x_set_info(char *buffer, int length, struct Scsi_Host *shpnt) 3274static int aha152x_set_info(struct Scsi_Host *shpnt, char *buffer, int length)
3281{ 3275{
3282 if(!shpnt || !buffer || length<8 || strncmp("aha152x ", buffer, 8)!=0) 3276 if(!shpnt || !buffer || length<8 || strncmp("aha152x ", buffer, 8)!=0)
3283 return -EINVAL; 3277 return -EINVAL;
@@ -3320,26 +3314,11 @@ static int aha152x_set_info(char *buffer, int length, struct Scsi_Host *shpnt)
3320 return length; 3314 return length;
3321} 3315}
3322 3316
3323#undef SPRINTF 3317static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt)
3324#define SPRINTF(args...) \
3325 do { if(pos < buffer + length) pos += sprintf(pos, ## args); } while(0)
3326
3327static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start,
3328 off_t offset, int length, int inout)
3329{ 3318{
3330 int i; 3319 int i;
3331 char *pos = buffer;
3332 Scsi_Cmnd *ptr; 3320 Scsi_Cmnd *ptr;
3333 unsigned long flags; 3321 unsigned long flags;
3334 int thislength;
3335
3336 DPRINTK(debug_procinfo,
3337 KERN_DEBUG "aha152x_proc_info: buffer=%p offset=%ld length=%d hostno=%d inout=%d\n",
3338 buffer, offset, length, shpnt->host_no, inout);
3339
3340
3341 if (inout)
3342 return aha152x_set_info(buffer, length, shpnt);
3343 3322
3344 SPRINTF(AHA152X_REVID "\n"); 3323 SPRINTF(AHA152X_REVID "\n");
3345 3324
@@ -3392,25 +3371,25 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start
3392 if (ISSUE_SC) { 3371 if (ISSUE_SC) {
3393 SPRINTF("not yet issued commands:\n"); 3372 SPRINTF("not yet issued commands:\n");
3394 for (ptr = ISSUE_SC; ptr; ptr = SCNEXT(ptr)) 3373 for (ptr = ISSUE_SC; ptr; ptr = SCNEXT(ptr))
3395 pos += get_command(pos, ptr); 3374 get_command(m, ptr);
3396 } else 3375 } else
3397 SPRINTF("no not yet issued commands\n"); 3376 SPRINTF("no not yet issued commands\n");
3398 DO_UNLOCK(flags); 3377 DO_UNLOCK(flags);
3399 3378
3400 if (CURRENT_SC) { 3379 if (CURRENT_SC) {
3401 SPRINTF("current command:\n"); 3380 SPRINTF("current command:\n");
3402 pos += get_command(pos, CURRENT_SC); 3381 get_command(m, CURRENT_SC);
3403 } else 3382 } else
3404 SPRINTF("no current command\n"); 3383 SPRINTF("no current command\n");
3405 3384
3406 if (DISCONNECTED_SC) { 3385 if (DISCONNECTED_SC) {
3407 SPRINTF("disconnected commands:\n"); 3386 SPRINTF("disconnected commands:\n");
3408 for (ptr = DISCONNECTED_SC; ptr; ptr = SCNEXT(ptr)) 3387 for (ptr = DISCONNECTED_SC; ptr; ptr = SCNEXT(ptr))
3409 pos += get_command(pos, ptr); 3388 get_command(m, ptr);
3410 } else 3389 } else
3411 SPRINTF("no disconnected commands\n"); 3390 SPRINTF("no disconnected commands\n");
3412 3391
3413 pos += get_ports(shpnt, pos); 3392 get_ports(m, shpnt);
3414 3393
3415#if defined(AHA152X_STAT) 3394#if defined(AHA152X_STAT)
3416 SPRINTF("statistics:\n" 3395 SPRINTF("statistics:\n"
@@ -3440,24 +3419,7 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start
3440 HOSTDATA(shpnt)->time[i]); 3419 HOSTDATA(shpnt)->time[i]);
3441 } 3420 }
3442#endif 3421#endif
3443 3422 return 0;
3444 DPRINTK(debug_procinfo, KERN_DEBUG "aha152x_proc_info: pos=%p\n", pos);
3445
3446 thislength = pos - (buffer + offset);
3447 DPRINTK(debug_procinfo, KERN_DEBUG "aha152x_proc_info: length=%d thislength=%d\n", length, thislength);
3448
3449 if(thislength<0) {
3450 DPRINTK(debug_procinfo, KERN_DEBUG "aha152x_proc_info: output too short\n");
3451 *start = NULL;
3452 return 0;
3453 }
3454
3455 thislength = thislength<length ? thislength : length;
3456
3457 DPRINTK(debug_procinfo, KERN_DEBUG "aha152x_proc_info: return %d\n", thislength);
3458
3459 *start = buffer + offset;
3460 return thislength < length ? thislength : length;
3461} 3423}
3462 3424
3463static int aha152x_adjust_queue(struct scsi_device *device) 3425static int aha152x_adjust_queue(struct scsi_device *device)
@@ -3470,7 +3432,8 @@ static struct scsi_host_template aha152x_driver_template = {
3470 .module = THIS_MODULE, 3432 .module = THIS_MODULE,
3471 .name = AHA152X_REVID, 3433 .name = AHA152X_REVID,
3472 .proc_name = "aha152x", 3434 .proc_name = "aha152x",
3473 .proc_info = aha152x_proc_info, 3435 .show_info = aha152x_show_info,
3436 .write_info = aha152x_set_info,
3474 .queuecommand = aha152x_queue, 3437 .queuecommand = aha152x_queue,
3475 .eh_abort_handler = aha152x_abort, 3438 .eh_abort_handler = aha152x_abort,
3476 .eh_device_reset_handler = aha152x_device_reset, 3439 .eh_device_reset_handler = aha152x_device_reset,
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index df775e6ba579..5f3101797c93 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -106,33 +106,14 @@ static inline dma_addr_t ecb_cpu_to_dma (struct Scsi_Host *host, void *cpu)
106 return hdata->ecb_dma_addr + offset; 106 return hdata->ecb_dma_addr + offset;
107} 107}
108 108
109static int aha1740_proc_info(struct Scsi_Host *shpnt, char *buffer, 109static int aha1740_show_info(struct seq_file *m, struct Scsi_Host *shpnt)
110 char **start, off_t offset,
111 int length, int inout)
112{ 110{
113 int len; 111 struct aha1740_hostdata *host = HOSTDATA(shpnt);
114 struct aha1740_hostdata *host; 112 seq_printf(m, "aha174x at IO:%lx, IRQ %d, SLOT %d.\n"
115
116 if (inout)
117 return-ENOSYS;
118
119 host = HOSTDATA(shpnt);
120
121 len = sprintf(buffer, "aha174x at IO:%lx, IRQ %d, SLOT %d.\n"
122 "Extended translation %sabled.\n", 113 "Extended translation %sabled.\n",
123 shpnt->io_port, shpnt->irq, host->edev->slot, 114 shpnt->io_port, shpnt->irq, host->edev->slot,
124 host->translation ? "en" : "dis"); 115 host->translation ? "en" : "dis");
125 116 return 0;
126 if (offset > len) {
127 *start = buffer;
128 return 0;
129 }
130
131 *start = buffer + offset;
132 len -= offset;
133 if (len > length)
134 len = length;
135 return len;
136} 117}
137 118
138static int aha1740_makecode(unchar *sense, unchar *status) 119static int aha1740_makecode(unchar *sense, unchar *status)
@@ -556,7 +537,7 @@ static int aha1740_eh_abort_handler (Scsi_Cmnd *dummy)
556static struct scsi_host_template aha1740_template = { 537static struct scsi_host_template aha1740_template = {
557 .module = THIS_MODULE, 538 .module = THIS_MODULE,
558 .proc_name = "aha1740", 539 .proc_name = "aha1740",
559 .proc_info = aha1740_proc_info, 540 .show_info = aha1740_show_info,
560 .name = "Adaptec 174x (EISA)", 541 .name = "Adaptec 174x (EISA)",
561 .queuecommand = aha1740_queuecommand, 542 .queuecommand = aha1740_queuecommand,
562 .bios_param = aha1740_biosparam, 543 .bios_param = aha1740_biosparam,
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 9328121804bb..69d5c43a65e5 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -906,7 +906,8 @@ struct scsi_host_template aic79xx_driver_template = {
906 .module = THIS_MODULE, 906 .module = THIS_MODULE,
907 .name = "aic79xx", 907 .name = "aic79xx",
908 .proc_name = "aic79xx", 908 .proc_name = "aic79xx",
909 .proc_info = ahd_linux_proc_info, 909 .show_info = ahd_linux_show_info,
910 .write_info = ahd_proc_write_seeprom,
910 .info = ahd_linux_info, 911 .info = ahd_linux_info,
911 .queuecommand = ahd_linux_queue, 912 .queuecommand = ahd_linux_queue,
912 .eh_abort_handler = ahd_linux_abort, 913 .eh_abort_handler = ahd_linux_abort,
@@ -1702,19 +1703,13 @@ ahd_send_async(struct ahd_softc *ahd, char channel,
1702 switch (code) { 1703 switch (code) {
1703 case AC_TRANSFER_NEG: 1704 case AC_TRANSFER_NEG:
1704 { 1705 {
1705 char buf[80];
1706 struct scsi_target *starget; 1706 struct scsi_target *starget;
1707 struct info_str info;
1708 struct ahd_initiator_tinfo *tinfo; 1707 struct ahd_initiator_tinfo *tinfo;
1709 struct ahd_tmode_tstate *tstate; 1708 struct ahd_tmode_tstate *tstate;
1710 unsigned int target_ppr_options; 1709 unsigned int target_ppr_options;
1711 1710
1712 BUG_ON(target == CAM_TARGET_WILDCARD); 1711 BUG_ON(target == CAM_TARGET_WILDCARD);
1713 1712
1714 info.buffer = buf;
1715 info.length = sizeof(buf);
1716 info.offset = 0;
1717 info.pos = 0;
1718 tinfo = ahd_fetch_transinfo(ahd, channel, ahd->our_id, 1713 tinfo = ahd_fetch_transinfo(ahd, channel, ahd->our_id,
1719 target, &tstate); 1714 target, &tstate);
1720 1715
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index 28e43498cdff..c58fa33c6592 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -379,14 +379,6 @@ void ahd_insb(struct ahd_softc * ahd, long port,
379int ahd_linux_register_host(struct ahd_softc *, 379int ahd_linux_register_host(struct ahd_softc *,
380 struct scsi_host_template *); 380 struct scsi_host_template *);
381 381
382/*************************** Pretty Printing **********************************/
383struct info_str {
384 char *buffer;
385 int length;
386 off_t offset;
387 int pos;
388};
389
390/******************************** Locking *************************************/ 382/******************************** Locking *************************************/
391static inline void 383static inline void
392ahd_lockinit(struct ahd_softc *ahd) 384ahd_lockinit(struct ahd_softc *ahd)
@@ -513,8 +505,8 @@ ahd_flush_device_writes(struct ahd_softc *ahd)
513} 505}
514 506
515/**************************** Proc FS Support *********************************/ 507/**************************** Proc FS Support *********************************/
516int ahd_linux_proc_info(struct Scsi_Host *, char *, char **, 508int ahd_proc_write_seeprom(struct Scsi_Host *, char *, int);
517 off_t, int, int); 509int ahd_linux_show_info(struct seq_file *,struct Scsi_Host *);
518 510
519/*********************** Transaction Access Wrappers **************************/ 511/*********************** Transaction Access Wrappers **************************/
520static inline void ahd_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t); 512static inline void ahd_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t);
diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c
index 59c85d5a153a..e9778b4f7e32 100644
--- a/drivers/scsi/aic7xxx/aic79xx_proc.c
+++ b/drivers/scsi/aic7xxx/aic79xx_proc.c
@@ -42,16 +42,12 @@
42#include "aic79xx_osm.h" 42#include "aic79xx_osm.h"
43#include "aic79xx_inline.h" 43#include "aic79xx_inline.h"
44 44
45static void copy_mem_info(struct info_str *info, char *data, int len);
46static int copy_info(struct info_str *info, char *fmt, ...);
47static void ahd_dump_target_state(struct ahd_softc *ahd, 45static void ahd_dump_target_state(struct ahd_softc *ahd,
48 struct info_str *info, 46 struct seq_file *m,
49 u_int our_id, char channel, 47 u_int our_id, char channel,
50 u_int target_id); 48 u_int target_id);
51static void ahd_dump_device_state(struct info_str *info, 49static void ahd_dump_device_state(struct seq_file *m,
52 struct scsi_device *sdev); 50 struct scsi_device *sdev);
53static int ahd_proc_write_seeprom(struct ahd_softc *ahd,
54 char *buffer, int length);
55 51
56/* 52/*
57 * Table of syncrates that don't follow the "divisible by 4" 53 * Table of syncrates that don't follow the "divisible by 4"
@@ -93,58 +89,15 @@ ahd_calc_syncsrate(u_int period_factor)
93 return (10000000 / (period_factor * 4 * 10)); 89 return (10000000 / (period_factor * 4 * 10));
94} 90}
95 91
96
97static void
98copy_mem_info(struct info_str *info, char *data, int len)
99{
100 if (info->pos + len > info->offset + info->length)
101 len = info->offset + info->length - info->pos;
102
103 if (info->pos + len < info->offset) {
104 info->pos += len;
105 return;
106 }
107
108 if (info->pos < info->offset) {
109 off_t partial;
110
111 partial = info->offset - info->pos;
112 data += partial;
113 info->pos += partial;
114 len -= partial;
115 }
116
117 if (len > 0) {
118 memcpy(info->buffer, data, len);
119 info->pos += len;
120 info->buffer += len;
121 }
122}
123
124static int
125copy_info(struct info_str *info, char *fmt, ...)
126{
127 va_list args;
128 char buf[256];
129 int len;
130
131 va_start(args, fmt);
132 len = vsprintf(buf, fmt, args);
133 va_end(args);
134
135 copy_mem_info(info, buf, len);
136 return (len);
137}
138
139static void 92static void
140ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo) 93ahd_format_transinfo(struct seq_file *m, struct ahd_transinfo *tinfo)
141{ 94{
142 u_int speed; 95 u_int speed;
143 u_int freq; 96 u_int freq;
144 u_int mb; 97 u_int mb;
145 98
146 if (tinfo->period == AHD_PERIOD_UNKNOWN) { 99 if (tinfo->period == AHD_PERIOD_UNKNOWN) {
147 copy_info(info, "Renegotiation Pending\n"); 100 seq_printf(m, "Renegotiation Pending\n");
148 return; 101 return;
149 } 102 }
150 speed = 3300; 103 speed = 3300;
@@ -156,34 +109,34 @@ ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo)
156 speed *= (0x01 << tinfo->width); 109 speed *= (0x01 << tinfo->width);
157 mb = speed / 1000; 110 mb = speed / 1000;
158 if (mb > 0) 111 if (mb > 0)
159 copy_info(info, "%d.%03dMB/s transfers", mb, speed % 1000); 112 seq_printf(m, "%d.%03dMB/s transfers", mb, speed % 1000);
160 else 113 else
161 copy_info(info, "%dKB/s transfers", speed); 114 seq_printf(m, "%dKB/s transfers", speed);
162 115
163 if (freq != 0) { 116 if (freq != 0) {
164 int printed_options; 117 int printed_options;
165 118
166 printed_options = 0; 119 printed_options = 0;
167 copy_info(info, " (%d.%03dMHz", freq / 1000, freq % 1000); 120 seq_printf(m, " (%d.%03dMHz", freq / 1000, freq % 1000);
168 if ((tinfo->ppr_options & MSG_EXT_PPR_RD_STRM) != 0) { 121 if ((tinfo->ppr_options & MSG_EXT_PPR_RD_STRM) != 0) {
169 copy_info(info, " RDSTRM"); 122 seq_printf(m, " RDSTRM");
170 printed_options++; 123 printed_options++;
171 } 124 }
172 if ((tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0) { 125 if ((tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
173 copy_info(info, "%s", printed_options ? "|DT" : " DT"); 126 seq_printf(m, "%s", printed_options ? "|DT" : " DT");
174 printed_options++; 127 printed_options++;
175 } 128 }
176 if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) != 0) { 129 if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
177 copy_info(info, "%s", printed_options ? "|IU" : " IU"); 130 seq_printf(m, "%s", printed_options ? "|IU" : " IU");
178 printed_options++; 131 printed_options++;
179 } 132 }
180 if ((tinfo->ppr_options & MSG_EXT_PPR_RTI) != 0) { 133 if ((tinfo->ppr_options & MSG_EXT_PPR_RTI) != 0) {
181 copy_info(info, "%s", 134 seq_printf(m, "%s",
182 printed_options ? "|RTI" : " RTI"); 135 printed_options ? "|RTI" : " RTI");
183 printed_options++; 136 printed_options++;
184 } 137 }
185 if ((tinfo->ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) { 138 if ((tinfo->ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
186 copy_info(info, "%s", 139 seq_printf(m, "%s",
187 printed_options ? "|QAS" : " QAS"); 140 printed_options ? "|QAS" : " QAS");
188 printed_options++; 141 printed_options++;
189 } 142 }
@@ -191,19 +144,19 @@ ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo)
191 144
192 if (tinfo->width > 0) { 145 if (tinfo->width > 0) {
193 if (freq != 0) { 146 if (freq != 0) {
194 copy_info(info, ", "); 147 seq_printf(m, ", ");
195 } else { 148 } else {
196 copy_info(info, " ("); 149 seq_printf(m, " (");
197 } 150 }
198 copy_info(info, "%dbit)", 8 * (0x01 << tinfo->width)); 151 seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width));
199 } else if (freq != 0) { 152 } else if (freq != 0) {
200 copy_info(info, ")"); 153 seq_printf(m, ")");
201 } 154 }
202 copy_info(info, "\n"); 155 seq_printf(m, "\n");
203} 156}
204 157
205static void 158static void
206ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info, 159ahd_dump_target_state(struct ahd_softc *ahd, struct seq_file *m,
207 u_int our_id, char channel, u_int target_id) 160 u_int our_id, char channel, u_int target_id)
208{ 161{
209 struct scsi_target *starget; 162 struct scsi_target *starget;
@@ -213,17 +166,17 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info,
213 166
214 tinfo = ahd_fetch_transinfo(ahd, channel, our_id, 167 tinfo = ahd_fetch_transinfo(ahd, channel, our_id,
215 target_id, &tstate); 168 target_id, &tstate);
216 copy_info(info, "Target %d Negotiation Settings\n", target_id); 169 seq_printf(m, "Target %d Negotiation Settings\n", target_id);
217 copy_info(info, "\tUser: "); 170 seq_printf(m, "\tUser: ");
218 ahd_format_transinfo(info, &tinfo->user); 171 ahd_format_transinfo(m, &tinfo->user);
219 starget = ahd->platform_data->starget[target_id]; 172 starget = ahd->platform_data->starget[target_id];
220 if (starget == NULL) 173 if (starget == NULL)
221 return; 174 return;
222 175
223 copy_info(info, "\tGoal: "); 176 seq_printf(m, "\tGoal: ");
224 ahd_format_transinfo(info, &tinfo->goal); 177 ahd_format_transinfo(m, &tinfo->goal);
225 copy_info(info, "\tCurr: "); 178 seq_printf(m, "\tCurr: ");
226 ahd_format_transinfo(info, &tinfo->curr); 179 ahd_format_transinfo(m, &tinfo->curr);
227 180
228 for (lun = 0; lun < AHD_NUM_LUNS; lun++) { 181 for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
229 struct scsi_device *dev; 182 struct scsi_device *dev;
@@ -233,29 +186,30 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info,
233 if (dev == NULL) 186 if (dev == NULL)
234 continue; 187 continue;
235 188
236 ahd_dump_device_state(info, dev); 189 ahd_dump_device_state(m, dev);
237 } 190 }
238} 191}
239 192
240static void 193static void
241ahd_dump_device_state(struct info_str *info, struct scsi_device *sdev) 194ahd_dump_device_state(struct seq_file *m, struct scsi_device *sdev)
242{ 195{
243 struct ahd_linux_device *dev = scsi_transport_device_data(sdev); 196 struct ahd_linux_device *dev = scsi_transport_device_data(sdev);
244 197
245 copy_info(info, "\tChannel %c Target %d Lun %d Settings\n", 198 seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n",
246 sdev->sdev_target->channel + 'A', 199 sdev->sdev_target->channel + 'A',
247 sdev->sdev_target->id, sdev->lun); 200 sdev->sdev_target->id, sdev->lun);
248 201
249 copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued); 202 seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued);
250 copy_info(info, "\t\tCommands Active %d\n", dev->active); 203 seq_printf(m, "\t\tCommands Active %d\n", dev->active);
251 copy_info(info, "\t\tCommand Openings %d\n", dev->openings); 204 seq_printf(m, "\t\tCommand Openings %d\n", dev->openings);
252 copy_info(info, "\t\tMax Tagged Openings %d\n", dev->maxtags); 205 seq_printf(m, "\t\tMax Tagged Openings %d\n", dev->maxtags);
253 copy_info(info, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen); 206 seq_printf(m, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen);
254} 207}
255 208
256static int 209int
257ahd_proc_write_seeprom(struct ahd_softc *ahd, char *buffer, int length) 210ahd_proc_write_seeprom(struct Scsi_Host *shost, char *buffer, int length)
258{ 211{
212 struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
259 ahd_mode_state saved_modes; 213 ahd_mode_state saved_modes;
260 int have_seeprom; 214 int have_seeprom;
261 u_long s; 215 u_long s;
@@ -319,64 +273,45 @@ done:
319 * Return information to handle /proc support for the driver. 273 * Return information to handle /proc support for the driver.
320 */ 274 */
321int 275int
322ahd_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, 276ahd_linux_show_info(struct seq_file *m, struct Scsi_Host *shost)
323 off_t offset, int length, int inout)
324{ 277{
325 struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata; 278 struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
326 struct info_str info;
327 char ahd_info[256]; 279 char ahd_info[256];
328 u_int max_targ; 280 u_int max_targ;
329 u_int i; 281 u_int i;
330 int retval;
331 282
332 /* Has data been written to the file? */ 283 seq_printf(m, "Adaptec AIC79xx driver version: %s\n",
333 if (inout == TRUE) {
334 retval = ahd_proc_write_seeprom(ahd, buffer, length);
335 goto done;
336 }
337
338 if (start)
339 *start = buffer;
340
341 info.buffer = buffer;
342 info.length = length;
343 info.offset = offset;
344 info.pos = 0;
345
346 copy_info(&info, "Adaptec AIC79xx driver version: %s\n",
347 AIC79XX_DRIVER_VERSION); 284 AIC79XX_DRIVER_VERSION);
348 copy_info(&info, "%s\n", ahd->description); 285 seq_printf(m, "%s\n", ahd->description);
349 ahd_controller_info(ahd, ahd_info); 286 ahd_controller_info(ahd, ahd_info);
350 copy_info(&info, "%s\n", ahd_info); 287 seq_printf(m, "%s\n", ahd_info);
351 copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n", 288 seq_printf(m, "Allocated SCBs: %d, SG List Length: %d\n\n",
352 ahd->scb_data.numscbs, AHD_NSEG); 289 ahd->scb_data.numscbs, AHD_NSEG);
353 290
354 max_targ = 16; 291 max_targ = 16;
355 292
356 if (ahd->seep_config == NULL) 293 if (ahd->seep_config == NULL)
357 copy_info(&info, "No Serial EEPROM\n"); 294 seq_printf(m, "No Serial EEPROM\n");
358 else { 295 else {
359 copy_info(&info, "Serial EEPROM:\n"); 296 seq_printf(m, "Serial EEPROM:\n");
360 for (i = 0; i < sizeof(*ahd->seep_config)/2; i++) { 297 for (i = 0; i < sizeof(*ahd->seep_config)/2; i++) {
361 if (((i % 8) == 0) && (i != 0)) { 298 if (((i % 8) == 0) && (i != 0)) {
362 copy_info(&info, "\n"); 299 seq_printf(m, "\n");
363 } 300 }
364 copy_info(&info, "0x%.4x ", 301 seq_printf(m, "0x%.4x ",
365 ((uint16_t*)ahd->seep_config)[i]); 302 ((uint16_t*)ahd->seep_config)[i]);
366 } 303 }
367 copy_info(&info, "\n"); 304 seq_printf(m, "\n");
368 } 305 }
369 copy_info(&info, "\n"); 306 seq_printf(m, "\n");
370 307
371 if ((ahd->features & AHD_WIDE) == 0) 308 if ((ahd->features & AHD_WIDE) == 0)
372 max_targ = 8; 309 max_targ = 8;
373 310
374 for (i = 0; i < max_targ; i++) { 311 for (i = 0; i < max_targ; i++) {
375 312
376 ahd_dump_target_state(ahd, &info, ahd->our_id, 'A', 313 ahd_dump_target_state(ahd, m, ahd->our_id, 'A',
377 /*target_id*/i); 314 /*target_id*/i);
378 } 315 }
379 retval = info.pos > info.offset ? info.pos - info.offset : 0; 316 return 0;
380done:
381 return (retval);
382} 317}
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 5a477cdc780d..c0c62583b542 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -803,7 +803,8 @@ struct scsi_host_template aic7xxx_driver_template = {
803 .module = THIS_MODULE, 803 .module = THIS_MODULE,
804 .name = "aic7xxx", 804 .name = "aic7xxx",
805 .proc_name = "aic7xxx", 805 .proc_name = "aic7xxx",
806 .proc_info = ahc_linux_proc_info, 806 .show_info = ahc_linux_show_info,
807 .write_info = ahc_proc_write_seeprom,
807 .info = ahc_linux_info, 808 .info = ahc_linux_info,
808 .queuecommand = ahc_linux_queue, 809 .queuecommand = ahc_linux_queue,
809 .eh_abort_handler = ahc_linux_abort, 810 .eh_abort_handler = ahc_linux_abort,
@@ -1631,10 +1632,8 @@ ahc_send_async(struct ahc_softc *ahc, char channel,
1631 switch (code) { 1632 switch (code) {
1632 case AC_TRANSFER_NEG: 1633 case AC_TRANSFER_NEG:
1633 { 1634 {
1634 char buf[80];
1635 struct scsi_target *starget; 1635 struct scsi_target *starget;
1636 struct ahc_linux_target *targ; 1636 struct ahc_linux_target *targ;
1637 struct info_str info;
1638 struct ahc_initiator_tinfo *tinfo; 1637 struct ahc_initiator_tinfo *tinfo;
1639 struct ahc_tmode_tstate *tstate; 1638 struct ahc_tmode_tstate *tstate;
1640 int target_offset; 1639 int target_offset;
@@ -1642,10 +1641,6 @@ ahc_send_async(struct ahc_softc *ahc, char channel,
1642 1641
1643 BUG_ON(target == CAM_TARGET_WILDCARD); 1642 BUG_ON(target == CAM_TARGET_WILDCARD);
1644 1643
1645 info.buffer = buf;
1646 info.length = sizeof(buf);
1647 info.offset = 0;
1648 info.pos = 0;
1649 tinfo = ahc_fetch_transinfo(ahc, channel, 1644 tinfo = ahc_fetch_transinfo(ahc, channel,
1650 channel == 'A' ? ahc->our_id 1645 channel == 'A' ? ahc->our_id
1651 : ahc->our_id_b, 1646 : ahc->our_id_b,
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index bca0fb83f553..bc4cca92ff04 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -383,14 +383,6 @@ void ahc_insb(struct ahc_softc * ahc, long port,
383int ahc_linux_register_host(struct ahc_softc *, 383int ahc_linux_register_host(struct ahc_softc *,
384 struct scsi_host_template *); 384 struct scsi_host_template *);
385 385
386/*************************** Pretty Printing **********************************/
387struct info_str {
388 char *buffer;
389 int length;
390 off_t offset;
391 int pos;
392};
393
394/******************************** Locking *************************************/ 386/******************************** Locking *************************************/
395/* Lock protecting internal data structures */ 387/* Lock protecting internal data structures */
396 388
@@ -523,8 +515,8 @@ ahc_flush_device_writes(struct ahc_softc *ahc)
523} 515}
524 516
525/**************************** Proc FS Support *********************************/ 517/**************************** Proc FS Support *********************************/
526int ahc_linux_proc_info(struct Scsi_Host *, char *, char **, 518int ahc_proc_write_seeprom(struct Scsi_Host *, char *, int);
527 off_t, int, int); 519int ahc_linux_show_info(struct seq_file *, struct Scsi_Host *);
528 520
529/*************************** Domain Validation ********************************/ 521/*************************** Domain Validation ********************************/
530/*********************** Transaction Access Wrappers *************************/ 522/*********************** Transaction Access Wrappers *************************/
diff --git a/drivers/scsi/aic7xxx/aic7xxx_proc.c b/drivers/scsi/aic7xxx/aic7xxx_proc.c
index f2525f8ed1c7..383a3d11652d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_proc.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_proc.c
@@ -43,16 +43,12 @@
43#include "aic7xxx_inline.h" 43#include "aic7xxx_inline.h"
44#include "aic7xxx_93cx6.h" 44#include "aic7xxx_93cx6.h"
45 45
46static void copy_mem_info(struct info_str *info, char *data, int len);
47static int copy_info(struct info_str *info, char *fmt, ...);
48static void ahc_dump_target_state(struct ahc_softc *ahc, 46static void ahc_dump_target_state(struct ahc_softc *ahc,
49 struct info_str *info, 47 struct seq_file *m,
50 u_int our_id, char channel, 48 u_int our_id, char channel,
51 u_int target_id, u_int target_offset); 49 u_int target_id, u_int target_offset);
52static void ahc_dump_device_state(struct info_str *info, 50static void ahc_dump_device_state(struct seq_file *m,
53 struct scsi_device *dev); 51 struct scsi_device *dev);
54static int ahc_proc_write_seeprom(struct ahc_softc *ahc,
55 char *buffer, int length);
56 52
57/* 53/*
58 * Table of syncrates that don't follow the "divisible by 4" 54 * Table of syncrates that don't follow the "divisible by 4"
@@ -94,51 +90,8 @@ ahc_calc_syncsrate(u_int period_factor)
94 return (10000000 / (period_factor * 4 * 10)); 90 return (10000000 / (period_factor * 4 * 10));
95} 91}
96 92
97
98static void
99copy_mem_info(struct info_str *info, char *data, int len)
100{
101 if (info->pos + len > info->offset + info->length)
102 len = info->offset + info->length - info->pos;
103
104 if (info->pos + len < info->offset) {
105 info->pos += len;
106 return;
107 }
108
109 if (info->pos < info->offset) {
110 off_t partial;
111
112 partial = info->offset - info->pos;
113 data += partial;
114 info->pos += partial;
115 len -= partial;
116 }
117
118 if (len > 0) {
119 memcpy(info->buffer, data, len);
120 info->pos += len;
121 info->buffer += len;
122 }
123}
124
125static int
126copy_info(struct info_str *info, char *fmt, ...)
127{
128 va_list args;
129 char buf[256];
130 int len;
131
132 va_start(args, fmt);
133 len = vsprintf(buf, fmt, args);
134 va_end(args);
135
136 copy_mem_info(info, buf, len);
137 return (len);
138}
139
140static void 93static void
141ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo) 94ahc_format_transinfo(struct seq_file *m, struct ahc_transinfo *tinfo)
142{ 95{
143 u_int speed; 96 u_int speed;
144 u_int freq; 97 u_int freq;
@@ -153,12 +106,12 @@ ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo)
153 speed *= (0x01 << tinfo->width); 106 speed *= (0x01 << tinfo->width);
154 mb = speed / 1000; 107 mb = speed / 1000;
155 if (mb > 0) 108 if (mb > 0)
156 copy_info(info, "%d.%03dMB/s transfers", mb, speed % 1000); 109 seq_printf(m, "%d.%03dMB/s transfers", mb, speed % 1000);
157 else 110 else
158 copy_info(info, "%dKB/s transfers", speed); 111 seq_printf(m, "%dKB/s transfers", speed);
159 112
160 if (freq != 0) { 113 if (freq != 0) {
161 copy_info(info, " (%d.%03dMHz%s, offset %d", 114 seq_printf(m, " (%d.%03dMHz%s, offset %d",
162 freq / 1000, freq % 1000, 115 freq / 1000, freq % 1000,
163 (tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0 116 (tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0
164 ? " DT" : "", tinfo->offset); 117 ? " DT" : "", tinfo->offset);
@@ -166,19 +119,19 @@ ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo)
166 119
167 if (tinfo->width > 0) { 120 if (tinfo->width > 0) {
168 if (freq != 0) { 121 if (freq != 0) {
169 copy_info(info, ", "); 122 seq_printf(m, ", ");
170 } else { 123 } else {
171 copy_info(info, " ("); 124 seq_printf(m, " (");
172 } 125 }
173 copy_info(info, "%dbit)", 8 * (0x01 << tinfo->width)); 126 seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width));
174 } else if (freq != 0) { 127 } else if (freq != 0) {
175 copy_info(info, ")"); 128 seq_printf(m, ")");
176 } 129 }
177 copy_info(info, "\n"); 130 seq_printf(m, "\n");
178} 131}
179 132
180static void 133static void
181ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info, 134ahc_dump_target_state(struct ahc_softc *ahc, struct seq_file *m,
182 u_int our_id, char channel, u_int target_id, 135 u_int our_id, char channel, u_int target_id,
183 u_int target_offset) 136 u_int target_offset)
184{ 137{
@@ -190,18 +143,18 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
190 tinfo = ahc_fetch_transinfo(ahc, channel, our_id, 143 tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
191 target_id, &tstate); 144 target_id, &tstate);
192 if ((ahc->features & AHC_TWIN) != 0) 145 if ((ahc->features & AHC_TWIN) != 0)
193 copy_info(info, "Channel %c ", channel); 146 seq_printf(m, "Channel %c ", channel);
194 copy_info(info, "Target %d Negotiation Settings\n", target_id); 147 seq_printf(m, "Target %d Negotiation Settings\n", target_id);
195 copy_info(info, "\tUser: "); 148 seq_printf(m, "\tUser: ");
196 ahc_format_transinfo(info, &tinfo->user); 149 ahc_format_transinfo(m, &tinfo->user);
197 starget = ahc->platform_data->starget[target_offset]; 150 starget = ahc->platform_data->starget[target_offset];
198 if (!starget) 151 if (!starget)
199 return; 152 return;
200 153
201 copy_info(info, "\tGoal: "); 154 seq_printf(m, "\tGoal: ");
202 ahc_format_transinfo(info, &tinfo->goal); 155 ahc_format_transinfo(m, &tinfo->goal);
203 copy_info(info, "\tCurr: "); 156 seq_printf(m, "\tCurr: ");
204 ahc_format_transinfo(info, &tinfo->curr); 157 ahc_format_transinfo(m, &tinfo->curr);
205 158
206 for (lun = 0; lun < AHC_NUM_LUNS; lun++) { 159 for (lun = 0; lun < AHC_NUM_LUNS; lun++) {
207 struct scsi_device *sdev; 160 struct scsi_device *sdev;
@@ -211,29 +164,30 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
211 if (sdev == NULL) 164 if (sdev == NULL)
212 continue; 165 continue;
213 166
214 ahc_dump_device_state(info, sdev); 167 ahc_dump_device_state(m, sdev);
215 } 168 }
216} 169}
217 170
218static void 171static void
219ahc_dump_device_state(struct info_str *info, struct scsi_device *sdev) 172ahc_dump_device_state(struct seq_file *m, struct scsi_device *sdev)
220{ 173{
221 struct ahc_linux_device *dev = scsi_transport_device_data(sdev); 174 struct ahc_linux_device *dev = scsi_transport_device_data(sdev);
222 175
223 copy_info(info, "\tChannel %c Target %d Lun %d Settings\n", 176 seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n",
224 sdev->sdev_target->channel + 'A', 177 sdev->sdev_target->channel + 'A',
225 sdev->sdev_target->id, sdev->lun); 178 sdev->sdev_target->id, sdev->lun);
226 179
227 copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued); 180 seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued);
228 copy_info(info, "\t\tCommands Active %d\n", dev->active); 181 seq_printf(m, "\t\tCommands Active %d\n", dev->active);
229 copy_info(info, "\t\tCommand Openings %d\n", dev->openings); 182 seq_printf(m, "\t\tCommand Openings %d\n", dev->openings);
230 copy_info(info, "\t\tMax Tagged Openings %d\n", dev->maxtags); 183 seq_printf(m, "\t\tMax Tagged Openings %d\n", dev->maxtags);
231 copy_info(info, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen); 184 seq_printf(m, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen);
232} 185}
233 186
234static int 187int
235ahc_proc_write_seeprom(struct ahc_softc *ahc, char *buffer, int length) 188ahc_proc_write_seeprom(struct Scsi_Host *shost, char *buffer, int length)
236{ 189{
190 struct ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata;
237 struct seeprom_descriptor sd; 191 struct seeprom_descriptor sd;
238 int have_seeprom; 192 int have_seeprom;
239 u_long s; 193 u_long s;
@@ -332,53 +286,36 @@ done:
332 * Return information to handle /proc support for the driver. 286 * Return information to handle /proc support for the driver.
333 */ 287 */
334int 288int
335ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, 289ahc_linux_show_info(struct seq_file *m, struct Scsi_Host *shost)
336 off_t offset, int length, int inout)
337{ 290{
338 struct ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata; 291 struct ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata;
339 struct info_str info;
340 char ahc_info[256]; 292 char ahc_info[256];
341 u_int max_targ; 293 u_int max_targ;
342 u_int i; 294 u_int i;
343 int retval;
344 295
345 /* Has data been written to the file? */ 296 seq_printf(m, "Adaptec AIC7xxx driver version: %s\n",
346 if (inout == TRUE) {
347 retval = ahc_proc_write_seeprom(ahc, buffer, length);
348 goto done;
349 }
350
351 if (start)
352 *start = buffer;
353
354 info.buffer = buffer;
355 info.length = length;
356 info.offset = offset;
357 info.pos = 0;
358
359 copy_info(&info, "Adaptec AIC7xxx driver version: %s\n",
360 AIC7XXX_DRIVER_VERSION); 297 AIC7XXX_DRIVER_VERSION);
361 copy_info(&info, "%s\n", ahc->description); 298 seq_printf(m, "%s\n", ahc->description);
362 ahc_controller_info(ahc, ahc_info); 299 ahc_controller_info(ahc, ahc_info);
363 copy_info(&info, "%s\n", ahc_info); 300 seq_printf(m, "%s\n", ahc_info);
364 copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n", 301 seq_printf(m, "Allocated SCBs: %d, SG List Length: %d\n\n",
365 ahc->scb_data->numscbs, AHC_NSEG); 302 ahc->scb_data->numscbs, AHC_NSEG);
366 303
367 304
368 if (ahc->seep_config == NULL) 305 if (ahc->seep_config == NULL)
369 copy_info(&info, "No Serial EEPROM\n"); 306 seq_printf(m, "No Serial EEPROM\n");
370 else { 307 else {
371 copy_info(&info, "Serial EEPROM:\n"); 308 seq_printf(m, "Serial EEPROM:\n");
372 for (i = 0; i < sizeof(*ahc->seep_config)/2; i++) { 309 for (i = 0; i < sizeof(*ahc->seep_config)/2; i++) {
373 if (((i % 8) == 0) && (i != 0)) { 310 if (((i % 8) == 0) && (i != 0)) {
374 copy_info(&info, "\n"); 311 seq_printf(m, "\n");
375 } 312 }
376 copy_info(&info, "0x%.4x ", 313 seq_printf(m, "0x%.4x ",
377 ((uint16_t*)ahc->seep_config)[i]); 314 ((uint16_t*)ahc->seep_config)[i]);
378 } 315 }
379 copy_info(&info, "\n"); 316 seq_printf(m, "\n");
380 } 317 }
381 copy_info(&info, "\n"); 318 seq_printf(m, "\n");
382 319
383 max_targ = 16; 320 max_targ = 16;
384 if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0) 321 if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0)
@@ -398,10 +335,8 @@ ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
398 target_id = i % 8; 335 target_id = i % 8;
399 } 336 }
400 337
401 ahc_dump_target_state(ahc, &info, our_id, 338 ahc_dump_target_state(ahc, m, our_id,
402 channel, target_id, i); 339 channel, target_id, i);
403 } 340 }
404 retval = info.pos > info.offset ? info.pos - info.offset : 0; 341 return 0;
405done:
406 return (retval);
407} 342}
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index 5b212f0df898..33ec9c643400 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -11108,7 +11108,7 @@ MODULE_VERSION(AIC7XXX_H_VERSION);
11108 11108
11109 11109
11110static struct scsi_host_template driver_template = { 11110static struct scsi_host_template driver_template = {
11111 .proc_info = aic7xxx_proc_info, 11111 .show_info = aic7xxx_show_info,
11112 .detect = aic7xxx_detect, 11112 .detect = aic7xxx_detect,
11113 .release = aic7xxx_release, 11113 .release = aic7xxx_release,
11114 .info = aic7xxx_info, 11114 .info = aic7xxx_info,
diff --git a/drivers/scsi/aic7xxx_old/aic7xxx_proc.c b/drivers/scsi/aic7xxx_old/aic7xxx_proc.c
index b07e4f04fd00..976f45ccf2cf 100644
--- a/drivers/scsi/aic7xxx_old/aic7xxx_proc.c
+++ b/drivers/scsi/aic7xxx_old/aic7xxx_proc.c
@@ -30,62 +30,23 @@
30 *-M*************************************************************************/ 30 *-M*************************************************************************/
31 31
32 32
33#define BLS (&aic7xxx_buffer[size])
34#define HDRB \ 33#define HDRB \
35" 0 - 4K 4 - 16K 16 - 64K 64 - 256K 256K - 1M 1M+" 34" 0 - 4K 4 - 16K 16 - 64K 64 - 256K 256K - 1M 1M+"
36 35
37#ifdef PROC_DEBUG
38extern int vsprintf(char *, const char *, va_list);
39
40static void
41proc_debug(const char *fmt, ...)
42{
43 va_list ap;
44 char buf[256];
45
46 va_start(ap, fmt);
47 vsprintf(buf, fmt, ap);
48 printk(buf);
49 va_end(ap);
50}
51#else /* PROC_DEBUG */
52# define proc_debug(fmt, args...)
53#endif /* PROC_DEBUG */
54
55static int aic7xxx_buffer_size = 0;
56static char *aic7xxx_buffer = NULL;
57
58 36
59/*+F************************************************************************* 37/*+F*************************************************************************
60 * Function: 38 * Function:
61 * aic7xxx_set_info 39 * aic7xxx_show_info
62 *
63 * Description:
64 * Set parameters for the driver from the /proc filesystem.
65 *-F*************************************************************************/
66static int
67aic7xxx_set_info(char *buffer, int length, struct Scsi_Host *HBAptr)
68{
69 proc_debug("aic7xxx_set_info(): %s\n", buffer);
70 return (-ENOSYS); /* Currently this is a no-op */
71}
72
73
74/*+F*************************************************************************
75 * Function:
76 * aic7xxx_proc_info
77 * 40 *
78 * Description: 41 * Description:
79 * Return information to handle /proc support for the driver. 42 * Return information to handle /proc support for the driver.
80 *-F*************************************************************************/ 43 *-F*************************************************************************/
81int 44int
82aic7xxx_proc_info ( struct Scsi_Host *HBAptr, char *buffer, char **start, off_t offset, int length, 45aic7xxx_show_info(struct seq_file *m, struct Scsi_Host *HBAptr)
83 int inout)
84{ 46{
85 struct aic7xxx_host *p; 47 struct aic7xxx_host *p;
86 struct aic_dev_data *aic_dev; 48 struct aic_dev_data *aic_dev;
87 struct scsi_device *sdptr; 49 struct scsi_device *sdptr;
88 int size = 0;
89 unsigned char i; 50 unsigned char i;
90 unsigned char tindex; 51 unsigned char tindex;
91 52
@@ -94,66 +55,21 @@ aic7xxx_proc_info ( struct Scsi_Host *HBAptr, char *buffer, char **start, off_t
94 55
95 if (!p) 56 if (!p)
96 { 57 {
97 size += sprintf(buffer, "Can't find adapter for host number %d\n", HBAptr->host_no); 58 seq_printf(m, "Can't find adapter for host number %d\n", HBAptr->host_no);
98 if (size > length) 59 return 0;
99 {
100 return (size);
101 }
102 else
103 {
104 return (length);
105 }
106 }
107
108 if (inout == TRUE) /* Has data been written to the file? */
109 {
110 return (aic7xxx_set_info(buffer, length, HBAptr));
111 } 60 }
112 61
113 p = (struct aic7xxx_host *) HBAptr->hostdata; 62 p = (struct aic7xxx_host *) HBAptr->hostdata;
114 63
115 /* 64 seq_printf(m, "Adaptec AIC7xxx driver version: ");
116 * It takes roughly 1K of space to hold all relevant card info, not 65 seq_printf(m, "%s/", AIC7XXX_C_VERSION);
117 * counting any proc stats, so we start out with a 1.5k buffer size and 66 seq_printf(m, "%s", AIC7XXX_H_VERSION);
118 * if proc_stats is defined, then we sweep the stats structure to see 67 seq_printf(m, "\n");
119 * how many drives we will be printing out for and add 384 bytes per 68 seq_printf(m, "Adapter Configuration:\n");
120 * device with active stats. 69 seq_printf(m, " SCSI Adapter: %s\n",
121 *
122 * Hmmmm...that 1.5k seems to keep growing as items get added so they
123 * can be easily viewed for debugging purposes. So, we bumped that
124 * 1.5k to 4k so we can quit having to bump it all the time.
125 */
126
127 size = 4096;
128 list_for_each_entry(aic_dev, &p->aic_devs, list)
129 size += 512;
130 if (aic7xxx_buffer_size != size)
131 {
132 if (aic7xxx_buffer != NULL)
133 {
134 kfree(aic7xxx_buffer);
135 aic7xxx_buffer_size = 0;
136 }
137 aic7xxx_buffer = kmalloc(size, GFP_KERNEL);
138 }
139 if (aic7xxx_buffer == NULL)
140 {
141 size = sprintf(buffer, "AIC7xxx - kmalloc error at line %d\n",
142 __LINE__);
143 return size;
144 }
145 aic7xxx_buffer_size = size;
146
147 size = 0;
148 size += sprintf(BLS, "Adaptec AIC7xxx driver version: ");
149 size += sprintf(BLS, "%s/", AIC7XXX_C_VERSION);
150 size += sprintf(BLS, "%s", AIC7XXX_H_VERSION);
151 size += sprintf(BLS, "\n");
152 size += sprintf(BLS, "Adapter Configuration:\n");
153 size += sprintf(BLS, " SCSI Adapter: %s\n",
154 board_names[p->board_name_index]); 70 board_names[p->board_name_index]);
155 if (p->flags & AHC_TWIN) 71 if (p->flags & AHC_TWIN)
156 size += sprintf(BLS, " Twin Channel Controller "); 72 seq_printf(m, " Twin Channel Controller ");
157 else 73 else
158 { 74 {
159 char *channel = ""; 75 char *channel = "";
@@ -184,86 +100,86 @@ aic7xxx_proc_info ( struct Scsi_Host *HBAptr, char *buffer, char **start, off_t
184 ultra = "Ultra-2 LVD/SE "; 100 ultra = "Ultra-2 LVD/SE ";
185 else if (p->features & AHC_ULTRA) 101 else if (p->features & AHC_ULTRA)
186 ultra = "Ultra "; 102 ultra = "Ultra ";
187 size += sprintf(BLS, " %s%sController%s ", 103 seq_printf(m, " %s%sController%s ",
188 ultra, wide, channel); 104 ultra, wide, channel);
189 } 105 }
190 switch(p->chip & ~AHC_CHIPID_MASK) 106 switch(p->chip & ~AHC_CHIPID_MASK)
191 { 107 {
192 case AHC_VL: 108 case AHC_VL:
193 size += sprintf(BLS, "at VLB slot %d\n", p->pci_device_fn); 109 seq_printf(m, "at VLB slot %d\n", p->pci_device_fn);
194 break; 110 break;
195 case AHC_EISA: 111 case AHC_EISA:
196 size += sprintf(BLS, "at EISA slot %d\n", p->pci_device_fn); 112 seq_printf(m, "at EISA slot %d\n", p->pci_device_fn);
197 break; 113 break;
198 default: 114 default:
199 size += sprintf(BLS, "at PCI %d/%d/%d\n", p->pci_bus, 115 seq_printf(m, "at PCI %d/%d/%d\n", p->pci_bus,
200 PCI_SLOT(p->pci_device_fn), PCI_FUNC(p->pci_device_fn)); 116 PCI_SLOT(p->pci_device_fn), PCI_FUNC(p->pci_device_fn));
201 break; 117 break;
202 } 118 }
203 if( !(p->maddr) ) 119 if( !(p->maddr) )
204 { 120 {
205 size += sprintf(BLS, " Programmed I/O Base: %lx\n", p->base); 121 seq_printf(m, " Programmed I/O Base: %lx\n", p->base);
206 } 122 }
207 else 123 else
208 { 124 {
209 size += sprintf(BLS, " PCI MMAPed I/O Base: 0x%lx\n", p->mbase); 125 seq_printf(m, " PCI MMAPed I/O Base: 0x%lx\n", p->mbase);
210 } 126 }
211 if( (p->chip & (AHC_VL | AHC_EISA)) ) 127 if( (p->chip & (AHC_VL | AHC_EISA)) )
212 { 128 {
213 size += sprintf(BLS, " BIOS Memory Address: 0x%08x\n", p->bios_address); 129 seq_printf(m, " BIOS Memory Address: 0x%08x\n", p->bios_address);
214 } 130 }
215 size += sprintf(BLS, " Adapter SEEPROM Config: %s\n", 131 seq_printf(m, " Adapter SEEPROM Config: %s\n",
216 (p->flags & AHC_SEEPROM_FOUND) ? "SEEPROM found and used." : 132 (p->flags & AHC_SEEPROM_FOUND) ? "SEEPROM found and used." :
217 ((p->flags & AHC_USEDEFAULTS) ? "SEEPROM not found, using defaults." : 133 ((p->flags & AHC_USEDEFAULTS) ? "SEEPROM not found, using defaults." :
218 "SEEPROM not found, using leftover BIOS values.") ); 134 "SEEPROM not found, using leftover BIOS values.") );
219 size += sprintf(BLS, " Adaptec SCSI BIOS: %s\n", 135 seq_printf(m, " Adaptec SCSI BIOS: %s\n",
220 (p->flags & AHC_BIOS_ENABLED) ? "Enabled" : "Disabled"); 136 (p->flags & AHC_BIOS_ENABLED) ? "Enabled" : "Disabled");
221 size += sprintf(BLS, " IRQ: %d\n", HBAptr->irq); 137 seq_printf(m, " IRQ: %d\n", HBAptr->irq);
222 size += sprintf(BLS, " SCBs: Active %d, Max Active %d,\n", 138 seq_printf(m, " SCBs: Active %d, Max Active %d,\n",
223 p->activescbs, p->max_activescbs); 139 p->activescbs, p->max_activescbs);
224 size += sprintf(BLS, " Allocated %d, HW %d, " 140 seq_printf(m, " Allocated %d, HW %d, "
225 "Page %d\n", p->scb_data->numscbs, p->scb_data->maxhscbs, 141 "Page %d\n", p->scb_data->numscbs, p->scb_data->maxhscbs,
226 p->scb_data->maxscbs); 142 p->scb_data->maxscbs);
227 if (p->flags & AHC_EXTERNAL_SRAM) 143 if (p->flags & AHC_EXTERNAL_SRAM)
228 size += sprintf(BLS, " Using External SCB SRAM\n"); 144 seq_printf(m, " Using External SCB SRAM\n");
229 size += sprintf(BLS, " Interrupts: %ld", p->isr_count); 145 seq_printf(m, " Interrupts: %ld", p->isr_count);
230 if (p->chip & AHC_EISA) 146 if (p->chip & AHC_EISA)
231 { 147 {
232 size += sprintf(BLS, " %s\n", 148 seq_printf(m, " %s\n",
233 (p->pause & IRQMS) ? "(Level Sensitive)" : "(Edge Triggered)"); 149 (p->pause & IRQMS) ? "(Level Sensitive)" : "(Edge Triggered)");
234 } 150 }
235 else 151 else
236 { 152 {
237 size += sprintf(BLS, "\n"); 153 seq_printf(m, "\n");
238 } 154 }
239 size += sprintf(BLS, " BIOS Control Word: 0x%04x\n", 155 seq_printf(m, " BIOS Control Word: 0x%04x\n",
240 p->bios_control); 156 p->bios_control);
241 size += sprintf(BLS, " Adapter Control Word: 0x%04x\n", 157 seq_printf(m, " Adapter Control Word: 0x%04x\n",
242 p->adapter_control); 158 p->adapter_control);
243 size += sprintf(BLS, " Extended Translation: %sabled\n", 159 seq_printf(m, " Extended Translation: %sabled\n",
244 (p->flags & AHC_EXTEND_TRANS_A) ? "En" : "Dis"); 160 (p->flags & AHC_EXTEND_TRANS_A) ? "En" : "Dis");
245 size += sprintf(BLS, "Disconnect Enable Flags: 0x%04x\n", p->discenable); 161 seq_printf(m, "Disconnect Enable Flags: 0x%04x\n", p->discenable);
246 if (p->features & (AHC_ULTRA | AHC_ULTRA2)) 162 if (p->features & (AHC_ULTRA | AHC_ULTRA2))
247 { 163 {
248 size += sprintf(BLS, " Ultra Enable Flags: 0x%04x\n", p->ultraenb); 164 seq_printf(m, " Ultra Enable Flags: 0x%04x\n", p->ultraenb);
249 } 165 }
250 size += sprintf(BLS, "Default Tag Queue Depth: %d\n", aic7xxx_default_queue_depth); 166 seq_printf(m, "Default Tag Queue Depth: %d\n", aic7xxx_default_queue_depth);
251 size += sprintf(BLS, " Tagged Queue By Device array for aic7xxx host " 167 seq_printf(m, " Tagged Queue By Device array for aic7xxx host "
252 "instance %d:\n", p->instance); 168 "instance %d:\n", p->instance);
253 size += sprintf(BLS, " {"); 169 seq_printf(m, " {");
254 for(i=0; i < (MAX_TARGETS - 1); i++) 170 for(i=0; i < (MAX_TARGETS - 1); i++)
255 size += sprintf(BLS, "%d,",aic7xxx_tag_info[p->instance].tag_commands[i]); 171 seq_printf(m, "%d,",aic7xxx_tag_info[p->instance].tag_commands[i]);
256 size += sprintf(BLS, "%d}\n",aic7xxx_tag_info[p->instance].tag_commands[i]); 172 seq_printf(m, "%d}\n",aic7xxx_tag_info[p->instance].tag_commands[i]);
257 173
258 size += sprintf(BLS, "\n"); 174 seq_printf(m, "\n");
259 size += sprintf(BLS, "Statistics:\n\n"); 175 seq_printf(m, "Statistics:\n\n");
260 list_for_each_entry(aic_dev, &p->aic_devs, list) 176 list_for_each_entry(aic_dev, &p->aic_devs, list)
261 { 177 {
262 sdptr = aic_dev->SDptr; 178 sdptr = aic_dev->SDptr;
263 tindex = sdptr->channel << 3 | sdptr->id; 179 tindex = sdptr->channel << 3 | sdptr->id;
264 size += sprintf(BLS, "(scsi%d:%d:%d:%d)\n", 180 seq_printf(m, "(scsi%d:%d:%d:%d)\n",
265 p->host_no, sdptr->channel, sdptr->id, sdptr->lun); 181 p->host_no, sdptr->channel, sdptr->id, sdptr->lun);
266 size += sprintf(BLS, " Device using %s/%s", 182 seq_printf(m, " Device using %s/%s",
267 (aic_dev->cur.width == MSG_EXT_WDTR_BUS_16_BIT) ? 183 (aic_dev->cur.width == MSG_EXT_WDTR_BUS_16_BIT) ?
268 "Wide" : "Narrow", 184 "Wide" : "Narrow",
269 (aic_dev->cur.offset != 0) ? 185 (aic_dev->cur.offset != 0) ?
@@ -279,78 +195,59 @@ aic7xxx_proc_info ( struct Scsi_Host *HBAptr, char *buffer, char **start, off_t
279 sync_rate = aic7xxx_find_syncrate(p, &period, 0, &options); 195 sync_rate = aic7xxx_find_syncrate(p, &period, 0, &options);
280 if (sync_rate != NULL) 196 if (sync_rate != NULL)
281 { 197 {
282 size += sprintf(BLS, "%s MByte/sec, offset %d\n", 198 seq_printf(m, "%s MByte/sec, offset %d\n",
283 sync_rate->rate[rate], 199 sync_rate->rate[rate],
284 aic_dev->cur.offset ); 200 aic_dev->cur.offset );
285 } 201 }
286 else 202 else
287 { 203 {
288 size += sprintf(BLS, "3.3 MByte/sec, offset %d\n", 204 seq_printf(m, "3.3 MByte/sec, offset %d\n",
289 aic_dev->cur.offset ); 205 aic_dev->cur.offset );
290 } 206 }
291 } 207 }
292 size += sprintf(BLS, " Transinfo settings: "); 208 seq_printf(m, " Transinfo settings: ");
293 size += sprintf(BLS, "current(%d/%d/%d/%d), ", 209 seq_printf(m, "current(%d/%d/%d/%d), ",
294 aic_dev->cur.period, 210 aic_dev->cur.period,
295 aic_dev->cur.offset, 211 aic_dev->cur.offset,
296 aic_dev->cur.width, 212 aic_dev->cur.width,
297 aic_dev->cur.options); 213 aic_dev->cur.options);
298 size += sprintf(BLS, "goal(%d/%d/%d/%d), ", 214 seq_printf(m, "goal(%d/%d/%d/%d), ",
299 aic_dev->goal.period, 215 aic_dev->goal.period,
300 aic_dev->goal.offset, 216 aic_dev->goal.offset,
301 aic_dev->goal.width, 217 aic_dev->goal.width,
302 aic_dev->goal.options); 218 aic_dev->goal.options);
303 size += sprintf(BLS, "user(%d/%d/%d/%d)\n", 219 seq_printf(m, "user(%d/%d/%d/%d)\n",
304 p->user[tindex].period, 220 p->user[tindex].period,
305 p->user[tindex].offset, 221 p->user[tindex].offset,
306 p->user[tindex].width, 222 p->user[tindex].width,
307 p->user[tindex].options); 223 p->user[tindex].options);
308 if(sdptr->simple_tags) 224 if(sdptr->simple_tags)
309 { 225 {
310 size += sprintf(BLS, " Tagged Command Queueing Enabled, Ordered Tags %s, Depth %d/%d\n", sdptr->ordered_tags ? "Enabled" : "Disabled", sdptr->queue_depth, aic_dev->max_q_depth); 226 seq_printf(m, " Tagged Command Queueing Enabled, Ordered Tags %s, Depth %d/%d\n", sdptr->ordered_tags ? "Enabled" : "Disabled", sdptr->queue_depth, aic_dev->max_q_depth);
311 } 227 }
312 if(aic_dev->barrier_total) 228 if(aic_dev->barrier_total)
313 size += sprintf(BLS, " Total transfers %ld:\n (%ld/%ld/%ld/%ld reads/writes/REQ_BARRIER/Ordered Tags)\n", 229 seq_printf(m, " Total transfers %ld:\n (%ld/%ld/%ld/%ld reads/writes/REQ_BARRIER/Ordered Tags)\n",
314 aic_dev->r_total+aic_dev->w_total, aic_dev->r_total, aic_dev->w_total, 230 aic_dev->r_total+aic_dev->w_total, aic_dev->r_total, aic_dev->w_total,
315 aic_dev->barrier_total, aic_dev->ordered_total); 231 aic_dev->barrier_total, aic_dev->ordered_total);
316 else 232 else
317 size += sprintf(BLS, " Total transfers %ld:\n (%ld/%ld reads/writes)\n", 233 seq_printf(m, " Total transfers %ld:\n (%ld/%ld reads/writes)\n",
318 aic_dev->r_total+aic_dev->w_total, aic_dev->r_total, aic_dev->w_total); 234 aic_dev->r_total+aic_dev->w_total, aic_dev->r_total, aic_dev->w_total);
319 size += sprintf(BLS, "%s\n", HDRB); 235 seq_printf(m, "%s\n", HDRB);
320 size += sprintf(BLS, " Reads:"); 236 seq_printf(m, " Reads:");
321 for (i = 0; i < ARRAY_SIZE(aic_dev->r_bins); i++) 237 for (i = 0; i < ARRAY_SIZE(aic_dev->r_bins); i++)
322 { 238 {
323 size += sprintf(BLS, " %10ld", aic_dev->r_bins[i]); 239 seq_printf(m, " %10ld", aic_dev->r_bins[i]);
324 } 240 }
325 size += sprintf(BLS, "\n"); 241 seq_printf(m, "\n");
326 size += sprintf(BLS, " Writes:"); 242 seq_printf(m, " Writes:");
327 for (i = 0; i < ARRAY_SIZE(aic_dev->w_bins); i++) 243 for (i = 0; i < ARRAY_SIZE(aic_dev->w_bins); i++)
328 { 244 {
329 size += sprintf(BLS, " %10ld", aic_dev->w_bins[i]); 245 seq_printf(m, " %10ld", aic_dev->w_bins[i]);
330 } 246 }
331 size += sprintf(BLS, "\n"); 247 seq_printf(m, "\n");
332 size += sprintf(BLS, "\n\n"); 248 seq_printf(m, "\n\n");
333 }
334 if (size >= aic7xxx_buffer_size)
335 {
336 printk(KERN_WARNING "aic7xxx: Overflow in aic7xxx_proc.c\n");
337 }
338
339 if (offset > size - 1)
340 {
341 kfree(aic7xxx_buffer);
342 aic7xxx_buffer = NULL;
343 aic7xxx_buffer_size = length = 0;
344 *start = NULL;
345 } 249 }
346 else 250 return 0;
347 {
348 *start = buffer;
349 length = min_t(int, length, size - offset);
350 memcpy(buffer, &aic7xxx_buffer[offset], length);
351 }
352
353 return (length);
354} 251}
355 252
356/* 253/*
diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
index 3e1172adb37b..09ba1869d366 100644
--- a/drivers/scsi/arm/acornscsi.c
+++ b/drivers/scsi/arm/acornscsi.c
@@ -2836,20 +2836,15 @@ char *acornscsi_info(struct Scsi_Host *host)
2836 return string; 2836 return string;
2837} 2837}
2838 2838
2839int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start, off_t offset, 2839static int acornscsi_show_info(struct seq_file *m, struct Scsi_Host *instance)
2840 int length, int inout)
2841{ 2840{
2842 int pos, begin = 0, devidx; 2841 int devidx;
2843 struct scsi_device *scd; 2842 struct scsi_device *scd;
2844 AS_Host *host; 2843 AS_Host *host;
2845 char *p = buffer;
2846
2847 if (inout == 1)
2848 return -EINVAL;
2849 2844
2850 host = (AS_Host *)instance->hostdata; 2845 host = (AS_Host *)instance->hostdata;
2851 2846
2852 p += sprintf(p, "AcornSCSI driver v%d.%d.%d" 2847 seq_printf(m, "AcornSCSI driver v%d.%d.%d"
2853#ifdef CONFIG_SCSI_ACORNSCSI_SYNC 2848#ifdef CONFIG_SCSI_ACORNSCSI_SYNC
2854 " SYNC" 2849 " SYNC"
2855#endif 2850#endif
@@ -2864,14 +2859,14 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start,
2864#endif 2859#endif
2865 "\n\n", VER_MAJOR, VER_MINOR, VER_PATCH); 2860 "\n\n", VER_MAJOR, VER_MINOR, VER_PATCH);
2866 2861
2867 p += sprintf(p, "SBIC: WD33C93A Address: %p IRQ : %d\n", 2862 seq_printf(m, "SBIC: WD33C93A Address: %p IRQ : %d\n",
2868 host->base + SBIC_REGIDX, host->scsi.irq); 2863 host->base + SBIC_REGIDX, host->scsi.irq);
2869#ifdef USE_DMAC 2864#ifdef USE_DMAC
2870 p += sprintf(p, "DMAC: uPC71071 Address: %p IRQ : %d\n\n", 2865 seq_printf(m, "DMAC: uPC71071 Address: %p IRQ : %d\n\n",
2871 host->base + DMAC_OFFSET, host->scsi.irq); 2866 host->base + DMAC_OFFSET, host->scsi.irq);
2872#endif 2867#endif
2873 2868
2874 p += sprintf(p, "Statistics:\n" 2869 seq_printf(m, "Statistics:\n"
2875 "Queued commands: %-10u Issued commands: %-10u\n" 2870 "Queued commands: %-10u Issued commands: %-10u\n"
2876 "Done commands : %-10u Reads : %-10u\n" 2871 "Done commands : %-10u Reads : %-10u\n"
2877 "Writes : %-10u Others : %-10u\n" 2872 "Writes : %-10u Others : %-10u\n"
@@ -2886,7 +2881,7 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start,
2886 for (devidx = 0; devidx < 9; devidx ++) { 2881 for (devidx = 0; devidx < 9; devidx ++) {
2887 unsigned int statptr, prev; 2882 unsigned int statptr, prev;
2888 2883
2889 p += sprintf(p, "\n%c:", devidx == 8 ? 'H' : ('0' + devidx)); 2884 seq_printf(m, "\n%c:", devidx == 8 ? 'H' : ('0' + devidx));
2890 statptr = host->status_ptr[devidx] - 10; 2885 statptr = host->status_ptr[devidx] - 10;
2891 2886
2892 if ((signed int)statptr < 0) 2887 if ((signed int)statptr < 0)
@@ -2896,7 +2891,7 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start,
2896 2891
2897 for (; statptr != host->status_ptr[devidx]; statptr = (statptr + 1) & (STATUS_BUFFER_SIZE - 1)) { 2892 for (; statptr != host->status_ptr[devidx]; statptr = (statptr + 1) & (STATUS_BUFFER_SIZE - 1)) {
2898 if (host->status[devidx][statptr].when) { 2893 if (host->status[devidx][statptr].when) {
2899 p += sprintf(p, "%c%02X:%02X+%2ld", 2894 seq_printf(m, "%c%02X:%02X+%2ld",
2900 host->status[devidx][statptr].irq ? '-' : ' ', 2895 host->status[devidx][statptr].irq ? '-' : ' ',
2901 host->status[devidx][statptr].ph, 2896 host->status[devidx][statptr].ph,
2902 host->status[devidx][statptr].ssr, 2897 host->status[devidx][statptr].ssr,
@@ -2907,51 +2902,32 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start,
2907 } 2902 }
2908 } 2903 }
2909 2904
2910 p += sprintf(p, "\nAttached devices:\n"); 2905 seq_printf(m, "\nAttached devices:\n");
2911 2906
2912 shost_for_each_device(scd, instance) { 2907 shost_for_each_device(scd, instance) {
2913 p += sprintf(p, "Device/Lun TaggedQ Sync\n"); 2908 seq_printf(m, "Device/Lun TaggedQ Sync\n");
2914 p += sprintf(p, " %d/%d ", scd->id, scd->lun); 2909 seq_printf(m, " %d/%d ", scd->id, scd->lun);
2915 if (scd->tagged_supported) 2910 if (scd->tagged_supported)
2916 p += sprintf(p, "%3sabled(%3d) ", 2911 seq_printf(m, "%3sabled(%3d) ",
2917 scd->simple_tags ? "en" : "dis", 2912 scd->simple_tags ? "en" : "dis",
2918 scd->current_tag); 2913 scd->current_tag);
2919 else 2914 else
2920 p += sprintf(p, "unsupported "); 2915 seq_printf(m, "unsupported ");
2921 2916
2922 if (host->device[scd->id].sync_xfer & 15) 2917 if (host->device[scd->id].sync_xfer & 15)
2923 p += sprintf(p, "offset %d, %d ns\n", 2918 seq_printf(m, "offset %d, %d ns\n",
2924 host->device[scd->id].sync_xfer & 15, 2919 host->device[scd->id].sync_xfer & 15,
2925 acornscsi_getperiod(host->device[scd->id].sync_xfer)); 2920 acornscsi_getperiod(host->device[scd->id].sync_xfer));
2926 else 2921 else
2927 p += sprintf(p, "async\n"); 2922 seq_printf(m, "async\n");
2928 2923
2929 pos = p - buffer;
2930 if (pos + begin < offset) {
2931 begin += pos;
2932 p = buffer;
2933 }
2934 pos = p - buffer;
2935 if (pos + begin > offset + length) {
2936 scsi_device_put(scd);
2937 break;
2938 }
2939 } 2924 }
2940 2925 return 0;
2941 pos = p - buffer;
2942
2943 *start = buffer + (offset - begin);
2944 pos -= offset - begin;
2945
2946 if (pos > length)
2947 pos = length;
2948
2949 return pos;
2950} 2926}
2951 2927
2952static struct scsi_host_template acornscsi_template = { 2928static struct scsi_host_template acornscsi_template = {
2953 .module = THIS_MODULE, 2929 .module = THIS_MODULE,
2954 .proc_info = acornscsi_proc_info, 2930 .show_info = acornscsi_show_info,
2955 .name = "AcornSCSI", 2931 .name = "AcornSCSI",
2956 .info = acornscsi_info, 2932 .info = acornscsi_info,
2957 .queuecommand = acornscsi_queuecmd, 2933 .queuecommand = acornscsi_queuecmd,
diff --git a/drivers/scsi/arm/arxescsi.c b/drivers/scsi/arm/arxescsi.c
index 9274510294ac..32d23212de48 100644
--- a/drivers/scsi/arm/arxescsi.c
+++ b/drivers/scsi/arm/arxescsi.c
@@ -220,47 +220,21 @@ static const char *arxescsi_info(struct Scsi_Host *host)
220 return string; 220 return string;
221} 221}
222 222
223/*
224 * Function: int arxescsi_proc_info(char *buffer, char **start, off_t offset,
225 * int length, int host_no, int inout)
226 * Purpose : Return information about the driver to a user process accessing
227 * the /proc filesystem.
228 * Params : buffer - a buffer to write information to
229 * start - a pointer into this buffer set by this routine to the start
230 * of the required information.
231 * offset - offset into information that we have read up to.
232 * length - length of buffer
233 * host_no - host number to return information for
234 * inout - 0 for reading, 1 for writing.
235 * Returns : length of data written to buffer.
236 */
237static int 223static int
238arxescsi_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, 224arxescsi_show_info(struct seq_file *m, struct Scsi_Host *host)
239 int inout)
240{ 225{
241 struct arxescsi_info *info; 226 struct arxescsi_info *info;
242 char *p = buffer;
243 int pos;
244
245 info = (struct arxescsi_info *)host->hostdata; 227 info = (struct arxescsi_info *)host->hostdata;
246 if (inout == 1)
247 return -EINVAL;
248
249 p += sprintf(p, "ARXE 16-bit SCSI driver v%s\n", VERSION);
250 p += fas216_print_host(&info->info, p);
251 p += fas216_print_stats(&info->info, p);
252 p += fas216_print_devices(&info->info, p);
253
254 *start = buffer + offset;
255 pos = p - buffer - offset;
256 if (pos > length)
257 pos = length;
258 228
259 return pos; 229 seq_printf(m, "ARXE 16-bit SCSI driver v%s\n", VERSION);
230 fas216_print_host(&info->info, m);
231 fas216_print_stats(&info->info, m);
232 fas216_print_devices(&info->info, m);
233 return 0;
260} 234}
261 235
262static struct scsi_host_template arxescsi_template = { 236static struct scsi_host_template arxescsi_template = {
263 .proc_info = arxescsi_proc_info, 237 .show_info = arxescsi_show_info,
264 .name = "ARXE SCSI card", 238 .name = "ARXE SCSI card",
265 .info = arxescsi_info, 239 .info = arxescsi_info,
266 .queuecommand = fas216_noqueue_command, 240 .queuecommand = fas216_noqueue_command,
diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c
index c93938b246d5..b679778376c5 100644
--- a/drivers/scsi/arm/cumana_1.c
+++ b/drivers/scsi/arm/cumana_1.c
@@ -30,7 +30,6 @@
30#define NCR5380_write(reg, value) cumanascsi_write(_instance, reg, value) 30#define NCR5380_write(reg, value) cumanascsi_write(_instance, reg, value)
31#define NCR5380_intr cumanascsi_intr 31#define NCR5380_intr cumanascsi_intr
32#define NCR5380_queue_command cumanascsi_queue_command 32#define NCR5380_queue_command cumanascsi_queue_command
33#define NCR5380_proc_info cumanascsi_proc_info
34 33
35#define NCR5380_implementation_fields \ 34#define NCR5380_implementation_fields \
36 unsigned ctrl; \ 35 unsigned ctrl; \
diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c
index e3bae93c3c22..58915f29055b 100644
--- a/drivers/scsi/arm/cumana_2.c
+++ b/drivers/scsi/arm/cumana_2.c
@@ -337,50 +337,25 @@ cumanascsi_2_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
337 return ret; 337 return ret;
338} 338}
339 339
340/* Prototype: int cumanascsi_2_proc_info(char *buffer, char **start, off_t offset, 340static int cumanascsi_2_show_info(struct seq_file *m, struct Scsi_Host *host)
341 * int length, int host_no, int inout)
342 * Purpose : Return information about the driver to a user process accessing
343 * the /proc filesystem.
344 * Params : buffer - a buffer to write information to
345 * start - a pointer into this buffer set by this routine to the start
346 * of the required information.
347 * offset - offset into information that we have read up to.
348 * length - length of buffer
349 * host_no - host number to return information for
350 * inout - 0 for reading, 1 for writing.
351 * Returns : length of data written to buffer.
352 */
353int cumanascsi_2_proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t offset,
354 int length, int inout)
355{ 341{
356 struct cumanascsi2_info *info; 342 struct cumanascsi2_info *info;
357 char *p = buffer;
358 int pos;
359
360 if (inout == 1)
361 return cumanascsi_2_set_proc_info(host, buffer, length);
362
363 info = (struct cumanascsi2_info *)host->hostdata; 343 info = (struct cumanascsi2_info *)host->hostdata;
364 344
365 p += sprintf(p, "Cumana SCSI II driver v%s\n", VERSION); 345 seq_printf(m, "Cumana SCSI II driver v%s\n", VERSION);
366 p += fas216_print_host(&info->info, p); 346 fas216_print_host(&info->info, m);
367 p += sprintf(p, "Term : o%s\n", 347 seq_printf(m, "Term : o%s\n",
368 info->terms ? "n" : "ff"); 348 info->terms ? "n" : "ff");
369 349
370 p += fas216_print_stats(&info->info, p); 350 fas216_print_stats(&info->info, m);
371 p += fas216_print_devices(&info->info, p); 351 fas216_print_devices(&info->info, m);
372 352 return 0;
373 *start = buffer + offset;
374 pos = p - buffer - offset;
375 if (pos > length)
376 pos = length;
377
378 return pos;
379} 353}
380 354
381static struct scsi_host_template cumanascsi2_template = { 355static struct scsi_host_template cumanascsi2_template = {
382 .module = THIS_MODULE, 356 .module = THIS_MODULE,
383 .proc_info = cumanascsi_2_proc_info, 357 .show_info = cumanascsi_2_show_info,
358 .write_info = cumanascsi_2_set_proc_info,
384 .name = "Cumana SCSI II", 359 .name = "Cumana SCSI II",
385 .info = cumanascsi_2_info, 360 .info = cumanascsi_2_info,
386 .queuecommand = fas216_queue_command, 361 .queuecommand = fas216_queue_command,
diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c
index 8e36908415ec..5bf3c0d134b4 100644
--- a/drivers/scsi/arm/eesox.c
+++ b/drivers/scsi/arm/eesox.c
@@ -422,45 +422,20 @@ eesoxscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
422 return ret; 422 return ret;
423} 423}
424 424
425/* Prototype: int eesoxscsi_proc_info(char *buffer, char **start, off_t offset, 425static int eesoxscsi_show_info(struct seq_file *m, struct Scsi_Host *host)
426 * int length, int host_no, int inout)
427 * Purpose : Return information about the driver to a user process accessing
428 * the /proc filesystem.
429 * Params : buffer - a buffer to write information to
430 * start - a pointer into this buffer set by this routine to the start
431 * of the required information.
432 * offset - offset into information that we have read up to.
433 * length - length of buffer
434 * host_no - host number to return information for
435 * inout - 0 for reading, 1 for writing.
436 * Returns : length of data written to buffer.
437 */
438int eesoxscsi_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
439 int length, int inout)
440{ 426{
441 struct eesoxscsi_info *info; 427 struct eesoxscsi_info *info;
442 char *p = buffer;
443 int pos;
444
445 if (inout == 1)
446 return eesoxscsi_set_proc_info(host, buffer, length);
447 428
448 info = (struct eesoxscsi_info *)host->hostdata; 429 info = (struct eesoxscsi_info *)host->hostdata;
449 430
450 p += sprintf(p, "EESOX SCSI driver v%s\n", VERSION); 431 seq_printf(m, "EESOX SCSI driver v%s\n", VERSION);
451 p += fas216_print_host(&info->info, p); 432 fas216_print_host(&info->info, m);
452 p += sprintf(p, "Term : o%s\n", 433 seq_printf(m, "Term : o%s\n",
453 info->control & EESOX_TERM_ENABLE ? "n" : "ff"); 434 info->control & EESOX_TERM_ENABLE ? "n" : "ff");
454 435
455 p += fas216_print_stats(&info->info, p); 436 fas216_print_stats(&info->info, m);
456 p += fas216_print_devices(&info->info, p); 437 fas216_print_devices(&info->info, m);
457 438 return 0;
458 *start = buffer + offset;
459 pos = p - buffer - offset;
460 if (pos > length)
461 pos = length;
462
463 return pos;
464} 439}
465 440
466static ssize_t eesoxscsi_show_term(struct device *dev, struct device_attribute *attr, char *buf) 441static ssize_t eesoxscsi_show_term(struct device *dev, struct device_attribute *attr, char *buf)
@@ -498,7 +473,8 @@ static DEVICE_ATTR(bus_term, S_IRUGO | S_IWUSR,
498 473
499static struct scsi_host_template eesox_template = { 474static struct scsi_host_template eesox_template = {
500 .module = THIS_MODULE, 475 .module = THIS_MODULE,
501 .proc_info = eesoxscsi_proc_info, 476 .show_info = eesoxscsi_show_info,
477 .write_info = eesoxscsi_set_proc_info,
502 .name = "EESOX SCSI", 478 .name = "EESOX SCSI",
503 .info = eesoxscsi_info, 479 .info = eesoxscsi_info,
504 .queuecommand = fas216_queue_command, 480 .queuecommand = fas216_queue_command,
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index 737554c37d9e..b46a6f6c0eb3 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -2958,9 +2958,9 @@ void fas216_release(struct Scsi_Host *host)
2958 queue_free(&info->queues.issue); 2958 queue_free(&info->queues.issue);
2959} 2959}
2960 2960
2961int fas216_print_host(FAS216_Info *info, char *buffer) 2961void fas216_print_host(FAS216_Info *info, struct seq_file *m)
2962{ 2962{
2963 return sprintf(buffer, 2963 seq_printf(m,
2964 "\n" 2964 "\n"
2965 "Chip : %s\n" 2965 "Chip : %s\n"
2966 " Address: 0x%p\n" 2966 " Address: 0x%p\n"
@@ -2970,11 +2970,9 @@ int fas216_print_host(FAS216_Info *info, char *buffer)
2970 info->scsi.irq, info->scsi.dma); 2970 info->scsi.irq, info->scsi.dma);
2971} 2971}
2972 2972
2973int fas216_print_stats(FAS216_Info *info, char *buffer) 2973void fas216_print_stats(FAS216_Info *info, struct seq_file *m)
2974{ 2974{
2975 char *p = buffer; 2975 seq_printf(m, "\n"
2976
2977 p += sprintf(p, "\n"
2978 "Command Statistics:\n" 2976 "Command Statistics:\n"
2979 " Queued : %u\n" 2977 " Queued : %u\n"
2980 " Issued : %u\n" 2978 " Issued : %u\n"
@@ -2991,38 +2989,33 @@ int fas216_print_stats(FAS216_Info *info, char *buffer)
2991 info->stats.writes, info->stats.miscs, 2989 info->stats.writes, info->stats.miscs,
2992 info->stats.disconnects, info->stats.aborts, 2990 info->stats.disconnects, info->stats.aborts,
2993 info->stats.bus_resets, info->stats.host_resets); 2991 info->stats.bus_resets, info->stats.host_resets);
2994
2995 return p - buffer;
2996} 2992}
2997 2993
2998int fas216_print_devices(FAS216_Info *info, char *buffer) 2994void fas216_print_devices(FAS216_Info *info, struct seq_file *m)
2999{ 2995{
3000 struct fas216_device *dev; 2996 struct fas216_device *dev;
3001 struct scsi_device *scd; 2997 struct scsi_device *scd;
3002 char *p = buffer;
3003 2998
3004 p += sprintf(p, "Device/Lun TaggedQ Parity Sync\n"); 2999 seq_printf(m, "Device/Lun TaggedQ Parity Sync\n");
3005 3000
3006 shost_for_each_device(scd, info->host) { 3001 shost_for_each_device(scd, info->host) {
3007 dev = &info->device[scd->id]; 3002 dev = &info->device[scd->id];
3008 p += sprintf(p, " %d/%d ", scd->id, scd->lun); 3003 seq_printf(m, " %d/%d ", scd->id, scd->lun);
3009 if (scd->tagged_supported) 3004 if (scd->tagged_supported)
3010 p += sprintf(p, "%3sabled(%3d) ", 3005 seq_printf(m, "%3sabled(%3d) ",
3011 scd->simple_tags ? "en" : "dis", 3006 scd->simple_tags ? "en" : "dis",
3012 scd->current_tag); 3007 scd->current_tag);
3013 else 3008 else
3014 p += sprintf(p, "unsupported "); 3009 seq_printf(m, "unsupported ");
3015 3010
3016 p += sprintf(p, "%3sabled ", dev->parity_enabled ? "en" : "dis"); 3011 seq_printf(m, "%3sabled ", dev->parity_enabled ? "en" : "dis");
3017 3012
3018 if (dev->sof) 3013 if (dev->sof)
3019 p += sprintf(p, "offset %d, %d ns\n", 3014 seq_printf(m, "offset %d, %d ns\n",
3020 dev->sof, dev->period * 4); 3015 dev->sof, dev->period * 4);
3021 else 3016 else
3022 p += sprintf(p, "async\n"); 3017 seq_printf(m, "async\n");
3023 } 3018 }
3024
3025 return p - buffer;
3026} 3019}
3027 3020
3028EXPORT_SYMBOL(fas216_init); 3021EXPORT_SYMBOL(fas216_init);
diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h
index df2e1b3ddfe2..c57c16ef8193 100644
--- a/drivers/scsi/arm/fas216.h
+++ b/drivers/scsi/arm/fas216.h
@@ -358,9 +358,9 @@ extern void fas216_remove (struct Scsi_Host *instance);
358 */ 358 */
359extern void fas216_release (struct Scsi_Host *instance); 359extern void fas216_release (struct Scsi_Host *instance);
360 360
361extern int fas216_print_host(FAS216_Info *info, char *buffer); 361extern void fas216_print_host(FAS216_Info *info, struct seq_file *m);
362extern int fas216_print_stats(FAS216_Info *info, char *buffer); 362extern void fas216_print_stats(FAS216_Info *info, struct seq_file *m);
363extern int fas216_print_devices(FAS216_Info *info, char *buffer); 363extern void fas216_print_devices(FAS216_Info *info, struct seq_file *m);
364 364
365/* Function: int fas216_eh_abort(struct scsi_cmnd *SCpnt) 365/* Function: int fas216_eh_abort(struct scsi_cmnd *SCpnt)
366 * Purpose : abort this command 366 * Purpose : abort this command
diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c
index 48facdc18002..4266eef8aca1 100644
--- a/drivers/scsi/arm/oak.c
+++ b/drivers/scsi/arm/oak.c
@@ -31,7 +31,8 @@
31#define NCR5380_write(reg, value) writeb(value, _base + ((reg) << 2)) 31#define NCR5380_write(reg, value) writeb(value, _base + ((reg) << 2))
32#define NCR5380_intr oakscsi_intr 32#define NCR5380_intr oakscsi_intr
33#define NCR5380_queue_command oakscsi_queue_command 33#define NCR5380_queue_command oakscsi_queue_command
34#define NCR5380_proc_info oakscsi_proc_info 34#define NCR5380_show_info oakscsi_show_info
35#define NCR5380_write_info oakscsi_write_info
35 36
36#define NCR5380_implementation_fields \ 37#define NCR5380_implementation_fields \
37 void __iomem *base 38 void __iomem *base
@@ -115,7 +116,8 @@ printk("reading %p len %d\n", addr, len);
115 116
116static struct scsi_host_template oakscsi_template = { 117static struct scsi_host_template oakscsi_template = {
117 .module = THIS_MODULE, 118 .module = THIS_MODULE,
118 .proc_info = oakscsi_proc_info, 119 .show_info = oakscsi_show_info,
120 .write_info = oakscsi_write_info,
119 .name = "Oak 16-bit SCSI", 121 .name = "Oak 16-bit SCSI",
120 .info = oakscsi_info, 122 .info = oakscsi_info,
121 .queuecommand = oakscsi_queue_command, 123 .queuecommand = oakscsi_queue_command,
diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c
index 246600b93555..abc9593615e9 100644
--- a/drivers/scsi/arm/powertec.c
+++ b/drivers/scsi/arm/powertec.c
@@ -237,32 +237,20 @@ powertecscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
237 * inout - 0 for reading, 1 for writing. 237 * inout - 0 for reading, 1 for writing.
238 * Returns : length of data written to buffer. 238 * Returns : length of data written to buffer.
239 */ 239 */
240int powertecscsi_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, 240static int powertecscsi_show_info(struct seq_file *m, struct Scsi_Host *host)
241 int length, int inout)
242{ 241{
243 struct powertec_info *info; 242 struct powertec_info *info;
244 char *p = buffer;
245 int pos;
246
247 if (inout == 1)
248 return powertecscsi_set_proc_info(host, buffer, length);
249 243
250 info = (struct powertec_info *)host->hostdata; 244 info = (struct powertec_info *)host->hostdata;
251 245
252 p += sprintf(p, "PowerTec SCSI driver v%s\n", VERSION); 246 seq_printf(m, "PowerTec SCSI driver v%s\n", VERSION);
253 p += fas216_print_host(&info->info, p); 247 fas216_print_host(&info->info, m);
254 p += sprintf(p, "Term : o%s\n", 248 seq_printf(m, "Term : o%s\n",
255 info->term_ctl ? "n" : "ff"); 249 info->term_ctl ? "n" : "ff");
256 250
257 p += fas216_print_stats(&info->info, p); 251 fas216_print_stats(&info->info, m);
258 p += fas216_print_devices(&info->info, p); 252 fas216_print_devices(&info->info, m);
259 253 return 0;
260 *start = buffer + offset;
261 pos = p - buffer - offset;
262 if (pos > length)
263 pos = length;
264
265 return pos;
266} 254}
267 255
268static ssize_t powertecscsi_show_term(struct device *dev, struct device_attribute *attr, char *buf) 256static ssize_t powertecscsi_show_term(struct device *dev, struct device_attribute *attr, char *buf)
@@ -291,7 +279,8 @@ static DEVICE_ATTR(bus_term, S_IRUGO | S_IWUSR,
291 279
292static struct scsi_host_template powertecscsi_template = { 280static struct scsi_host_template powertecscsi_template = {
293 .module = THIS_MODULE, 281 .module = THIS_MODULE,
294 .proc_info = powertecscsi_proc_info, 282 .show_info = powertecscsi_show_info,
283 .write_info = powertecscsi_set_proc_info,
295 .name = "PowerTec SCSI", 284 .name = "PowerTec SCSI",
296 .info = powertecscsi_info, 285 .info = powertecscsi_info,
297 .queuecommand = fas216_queue_command, 286 .queuecommand = fas216_queue_command,
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 2db79b469d9e..0f3cdbc80ba6 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -719,119 +719,94 @@ static void __init NCR5380_print_options(struct Scsi_Host *instance)
719 * Inputs : instance, pointer to this instance. 719 * Inputs : instance, pointer to this instance.
720 */ 720 */
721 721
722static void NCR5380_print_status(struct Scsi_Host *instance) 722static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd)
723{ 723{
724 char *pr_bfr; 724 int i, s;
725 char *start; 725 unsigned char *command;
726 int len; 726 printk("scsi%d: destination target %d, lun %d\n",
727 727 H_NO(cmd), cmd->device->id, cmd->device->lun);
728 NCR_PRINT(NDEBUG_ANY); 728 printk(KERN_CONT " command = ");
729 NCR_PRINT_PHASE(NDEBUG_ANY); 729 command = cmd->cmnd;
730 730 printk(KERN_CONT "%2d (0x%02x)", command[0], command[0]);
731 pr_bfr = (char *)__get_free_page(GFP_ATOMIC); 731 for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
732 if (!pr_bfr) { 732 printk(KERN_CONT " %02x", command[i]);
733 printk("NCR5380_print_status: no memory for print buffer\n"); 733 printk("\n");
734 return;
735 }
736 len = NCR5380_proc_info(instance, pr_bfr, &start, 0, PAGE_SIZE, 0);
737 pr_bfr[len] = 0;
738 printk("\n%s\n", pr_bfr);
739 free_page((unsigned long)pr_bfr);
740} 734}
741 735
742 736static void NCR5380_print_status(struct Scsi_Host *instance)
743/******************************************/
744/*
745 * /proc/scsi/[dtc pas16 t128 generic]/[0-ASC_NUM_BOARD_SUPPORTED]
746 *
747 * *buffer: I/O buffer
748 * **start: if inout == FALSE pointer into buffer where user read should start
749 * offset: current offset
750 * length: length of buffer
751 * hostno: Scsi_Host host_no
752 * inout: TRUE - user is writing; FALSE - user is reading
753 *
754 * Return the number of bytes read from or written
755*/
756
757#undef SPRINTF
758#define SPRINTF(fmt,args...) \
759 do { \
760 if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \
761 pos += sprintf(pos, fmt , ## args); \
762 } while(0)
763static char *lprint_Scsi_Cmnd(Scsi_Cmnd *cmd, char *pos, char *buffer, int length);
764
765static int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer,
766 char **start, off_t offset, int length, int inout)
767{ 737{
768 char *pos = buffer;
769 struct NCR5380_hostdata *hostdata; 738 struct NCR5380_hostdata *hostdata;
770 Scsi_Cmnd *ptr; 739 Scsi_Cmnd *ptr;
771 unsigned long flags; 740 unsigned long flags;
772 off_t begin = 0; 741
773#define check_offset() \ 742 NCR_PRINT(NDEBUG_ANY);
774 do { \ 743 NCR_PRINT_PHASE(NDEBUG_ANY);
775 if (pos - buffer < offset - begin) { \
776 begin += pos - buffer; \
777 pos = buffer; \
778 } \
779 } while (0)
780 744
781 hostdata = (struct NCR5380_hostdata *)instance->hostdata; 745 hostdata = (struct NCR5380_hostdata *)instance->hostdata;
782 746
783 if (inout) /* Has data been written to the file ? */ 747 printk("\nNCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
784 return -ENOSYS; /* Currently this is a no-op */
785 SPRINTF("NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
786 check_offset();
787 local_irq_save(flags); 748 local_irq_save(flags);
788 SPRINTF("NCR5380: coroutine is%s running.\n", 749 printk("NCR5380: coroutine is%s running.\n",
789 main_running ? "" : "n't"); 750 main_running ? "" : "n't");
790 check_offset();
791 if (!hostdata->connected) 751 if (!hostdata->connected)
792 SPRINTF("scsi%d: no currently connected command\n", HOSTNO); 752 printk("scsi%d: no currently connected command\n", HOSTNO);
793 else 753 else
794 pos = lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, 754 lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected);
795 pos, buffer, length); 755 printk("scsi%d: issue_queue\n", HOSTNO);
796 SPRINTF("scsi%d: issue_queue\n", HOSTNO); 756 for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr))
797 check_offset(); 757 lprint_Scsi_Cmnd(ptr);
798 for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) {
799 pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length);
800 check_offset();
801 }
802 758
803 SPRINTF("scsi%d: disconnected_queue\n", HOSTNO); 759 printk("scsi%d: disconnected_queue\n", HOSTNO);
804 check_offset();
805 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; 760 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
806 ptr = NEXT(ptr)) { 761 ptr = NEXT(ptr))
807 pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length); 762 lprint_Scsi_Cmnd(ptr);
808 check_offset();
809 }
810 763
811 local_irq_restore(flags); 764 local_irq_restore(flags);
812 *start = buffer + (offset - begin); 765 printk("\n");
813 if (pos - buffer < offset - begin)
814 return 0;
815 else if (pos - buffer - (offset - begin) < length)
816 return pos - buffer - (offset - begin);
817 return length;
818} 766}
819 767
820static char *lprint_Scsi_Cmnd(Scsi_Cmnd *cmd, char *pos, char *buffer, int length) 768static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m)
821{ 769{
822 int i, s; 770 int i, s;
823 unsigned char *command; 771 unsigned char *command;
824 SPRINTF("scsi%d: destination target %d, lun %d\n", 772 seq_printf(m, "scsi%d: destination target %d, lun %d\n",
825 H_NO(cmd), cmd->device->id, cmd->device->lun); 773 H_NO(cmd), cmd->device->id, cmd->device->lun);
826 SPRINTF(" command = "); 774 seq_printf(m, " command = ");
827 command = cmd->cmnd; 775 command = cmd->cmnd;
828 SPRINTF("%2d (0x%02x)", command[0], command[0]); 776 seq_printf(m, "%2d (0x%02x)", command[0], command[0]);
829 for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) 777 for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
830 SPRINTF(" %02x", command[i]); 778 seq_printf(m, " %02x", command[i]);
831 SPRINTF("\n"); 779 seq_printf(m, "\n");
832 return pos;
833} 780}
834 781
782static int NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance)
783{
784 struct NCR5380_hostdata *hostdata;
785 Scsi_Cmnd *ptr;
786 unsigned long flags;
787
788 hostdata = (struct NCR5380_hostdata *)instance->hostdata;
789
790 seq_printf(m, "NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
791 local_irq_save(flags);
792 seq_printf(m, "NCR5380: coroutine is%s running.\n",
793 main_running ? "" : "n't");
794 if (!hostdata->connected)
795 seq_printf(m, "scsi%d: no currently connected command\n", HOSTNO);
796 else
797 show_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m);
798 seq_printf(m, "scsi%d: issue_queue\n", HOSTNO);
799 for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr))
800 show_Scsi_Cmnd(ptr, m);
801
802 seq_printf(m, "scsi%d: disconnected_queue\n", HOSTNO);
803 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
804 ptr = NEXT(ptr))
805 show_Scsi_Cmnd(ptr, m);
806
807 local_irq_restore(flags);
808 return 0;
809}
835 810
836/* 811/*
837 * Function : void NCR5380_init (struct Scsi_Host *instance) 812 * Function : void NCR5380_init (struct Scsi_Host *instance)
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index df740cbbaef4..a3e6c8a3ff0f 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -1100,7 +1100,7 @@ static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value)
1100#include "atari_NCR5380.c" 1100#include "atari_NCR5380.c"
1101 1101
1102static struct scsi_host_template driver_template = { 1102static struct scsi_host_template driver_template = {
1103 .proc_info = atari_scsi_proc_info, 1103 .show_info = atari_scsi_show_info,
1104 .name = "Atari native SCSI", 1104 .name = "Atari native SCSI",
1105 .detect = atari_scsi_detect, 1105 .detect = atari_scsi_detect,
1106 .release = atari_scsi_release, 1106 .release = atari_scsi_release,
diff --git a/drivers/scsi/atari_scsi.h b/drivers/scsi/atari_scsi.h
index bd52df78b209..11c624bb122d 100644
--- a/drivers/scsi/atari_scsi.h
+++ b/drivers/scsi/atari_scsi.h
@@ -47,7 +47,7 @@
47#define NCR5380_intr atari_scsi_intr 47#define NCR5380_intr atari_scsi_intr
48#define NCR5380_queue_command atari_scsi_queue_command 48#define NCR5380_queue_command atari_scsi_queue_command
49#define NCR5380_abort atari_scsi_abort 49#define NCR5380_abort atari_scsi_abort
50#define NCR5380_proc_info atari_scsi_proc_info 50#define NCR5380_show_info atari_scsi_show_info
51#define NCR5380_dma_read_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 0) 51#define NCR5380_dma_read_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 0)
52#define NCR5380_dma_write_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 1) 52#define NCR5380_dma_write_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 1)
53#define NCR5380_dma_residual(inst) atari_scsi_dma_residual( inst ) 53#define NCR5380_dma_residual(inst) atari_scsi_dma_residual( inst )
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index cfc73041f102..15a629d8ed08 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -3099,38 +3099,14 @@ static const char *atp870u_info(struct Scsi_Host *notused)
3099 return buffer; 3099 return buffer;
3100} 3100}
3101 3101
3102#define BLS buffer + len + size 3102static int atp870u_show_info(struct seq_file *m, struct Scsi_Host *HBAptr)
3103static int atp870u_proc_info(struct Scsi_Host *HBAptr, char *buffer,
3104 char **start, off_t offset, int length, int inout)
3105{ 3103{
3106 static u8 buff[512]; 3104 seq_printf(m, "ACARD AEC-671X Driver Version: 2.6+ac\n");
3107 int size = 0; 3105 seq_printf(m, "\n");
3108 int len = 0; 3106 seq_printf(m, "Adapter Configuration:\n");
3109 off_t begin = 0; 3107 seq_printf(m, " Base IO: %#.4lx\n", HBAptr->io_port);
3110 off_t pos = 0; 3108 seq_printf(m, " IRQ: %d\n", HBAptr->irq);
3111 3109 return 0;
3112 if (inout)
3113 return -EINVAL;
3114 if (offset == 0)
3115 memset(buff, 0, sizeof(buff));
3116 size += sprintf(BLS, "ACARD AEC-671X Driver Version: 2.6+ac\n");
3117 len += size;
3118 pos = begin + len;
3119 size = 0;
3120
3121 size += sprintf(BLS, "\n");
3122 size += sprintf(BLS, "Adapter Configuration:\n");
3123 size += sprintf(BLS, " Base IO: %#.4lx\n", HBAptr->io_port);
3124 size += sprintf(BLS, " IRQ: %d\n", HBAptr->irq);
3125 len += size;
3126 pos = begin + len;
3127
3128 *start = buffer + (offset - begin); /* Start of wanted data */
3129 len -= (offset - begin); /* Start slop */
3130 if (len > length) {
3131 len = length; /* Ending slop */
3132 }
3133 return (len);
3134} 3110}
3135 3111
3136 3112
@@ -3177,7 +3153,7 @@ static struct scsi_host_template atp870u_template = {
3177 .module = THIS_MODULE, 3153 .module = THIS_MODULE,
3178 .name = "atp870u" /* name */, 3154 .name = "atp870u" /* name */,
3179 .proc_name = "atp870u", 3155 .proc_name = "atp870u",
3180 .proc_info = atp870u_proc_info, 3156 .show_info = atp870u_show_info,
3181 .info = atp870u_info /* info */, 3157 .info = atp870u_info /* info */,
3182 .queuecommand = atp870u_queuecommand /* queuecommand */, 3158 .queuecommand = atp870u_queuecommand /* queuecommand */,
3183 .eh_abort_handler = atp870u_abort /* abort */, 3159 .eh_abort_handler = atp870u_abort /* abort */,
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index fed486bfd3f4..694e13c45dfd 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -4616,26 +4616,21 @@ static void adapter_uninit(struct AdapterCtlBlk *acb)
4616 4616
4617 4617
4618#undef SPRINTF 4618#undef SPRINTF
4619#define SPRINTF(args...) pos += sprintf(pos, args) 4619#define SPRINTF(args...) seq_printf(m,##args)
4620 4620
4621#undef YESNO 4621#undef YESNO
4622#define YESNO(YN) \ 4622#define YESNO(YN) \
4623 if (YN) SPRINTF(" Yes ");\ 4623 if (YN) SPRINTF(" Yes ");\
4624 else SPRINTF(" No ") 4624 else SPRINTF(" No ")
4625 4625
4626static int dc395x_proc_info(struct Scsi_Host *host, char *buffer, 4626static int dc395x_show_info(struct seq_file *m, struct Scsi_Host *host)
4627 char **start, off_t offset, int length, int inout)
4628{ 4627{
4629 struct AdapterCtlBlk *acb = (struct AdapterCtlBlk *)host->hostdata; 4628 struct AdapterCtlBlk *acb = (struct AdapterCtlBlk *)host->hostdata;
4630 int spd, spd1; 4629 int spd, spd1;
4631 char *pos = buffer;
4632 struct DeviceCtlBlk *dcb; 4630 struct DeviceCtlBlk *dcb;
4633 unsigned long flags; 4631 unsigned long flags;
4634 int dev; 4632 int dev;
4635 4633
4636 if (inout) /* Has data been written to the file ? */
4637 return -EPERM;
4638
4639 SPRINTF(DC395X_BANNER " PCI SCSI Host Adapter\n"); 4634 SPRINTF(DC395X_BANNER " PCI SCSI Host Adapter\n");
4640 SPRINTF(" Driver Version " DC395X_VERSION "\n"); 4635 SPRINTF(" Driver Version " DC395X_VERSION "\n");
4641 4636
@@ -4735,22 +4730,15 @@ static int dc395x_proc_info(struct Scsi_Host *host, char *buffer,
4735 SPRINTF("END\n"); 4730 SPRINTF("END\n");
4736 } 4731 }
4737 4732
4738 *start = buffer + offset;
4739 DC395x_UNLOCK_IO(acb->scsi_host, flags); 4733 DC395x_UNLOCK_IO(acb->scsi_host, flags);
4740 4734 return 0;
4741 if (pos - buffer < offset)
4742 return 0;
4743 else if (pos - buffer - offset < length)
4744 return pos - buffer - offset;
4745 else
4746 return length;
4747} 4735}
4748 4736
4749 4737
4750static struct scsi_host_template dc395x_driver_template = { 4738static struct scsi_host_template dc395x_driver_template = {
4751 .module = THIS_MODULE, 4739 .module = THIS_MODULE,
4752 .proc_name = DC395X_NAME, 4740 .proc_name = DC395X_NAME,
4753 .proc_info = dc395x_proc_info, 4741 .show_info = dc395x_show_info,
4754 .name = DC395X_BANNER " " DC395X_VERSION, 4742 .name = DC395X_BANNER " " DC395X_VERSION,
4755 .queuecommand = dc395x_queue_command, 4743 .queuecommand = dc395x_queue_command,
4756 .bios_param = dc395x_bios_param, 4744 .bios_param = dc395x_bios_param,
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index b6e2700ec1c6..19e1b422260a 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -553,36 +553,14 @@ static const char *adpt_info(struct Scsi_Host *host)
553 return (char *) (pHba->detail); 553 return (char *) (pHba->detail);
554} 554}
555 555
556static int adpt_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, 556static int adpt_show_info(struct seq_file *m, struct Scsi_Host *host)
557 int length, int inout)
558{ 557{
559 struct adpt_device* d; 558 struct adpt_device* d;
560 int id; 559 int id;
561 int chan; 560 int chan;
562 int len = 0;
563 int begin = 0;
564 int pos = 0;
565 adpt_hba* pHba; 561 adpt_hba* pHba;
566 int unit; 562 int unit;
567 563
568 *start = buffer;
569 if (inout == TRUE) {
570 /*
571 * The user has done a write and wants us to take the
572 * data in the buffer and do something with it.
573 * proc_scsiwrite calls us with inout = 1
574 *
575 * Read data from buffer (writing to us) - NOT SUPPORTED
576 */
577 return -EINVAL;
578 }
579
580 /*
581 * inout = 0 means the user has done a read and wants information
582 * returned, so we write information about the cards into the buffer
583 * proc_scsiread() calls us with inout = 0
584 */
585
586 // Find HBA (host bus adapter) we are looking for 564 // Find HBA (host bus adapter) we are looking for
587 mutex_lock(&adpt_configuration_lock); 565 mutex_lock(&adpt_configuration_lock);
588 for (pHba = hba_chain; pHba; pHba = pHba->next) { 566 for (pHba = hba_chain; pHba; pHba = pHba->next) {
@@ -596,86 +574,30 @@ static int adpt_proc_info(struct Scsi_Host *host, char *buffer, char **start, of
596 } 574 }
597 host = pHba->host; 575 host = pHba->host;
598 576
599 len = sprintf(buffer , "Adaptec I2O RAID Driver Version: %s\n\n", DPT_I2O_VERSION); 577 seq_printf(m, "Adaptec I2O RAID Driver Version: %s\n\n", DPT_I2O_VERSION);
600 len += sprintf(buffer+len, "%s\n", pHba->detail); 578 seq_printf(m, "%s\n", pHba->detail);
601 len += sprintf(buffer+len, "SCSI Host=scsi%d Control Node=/dev/%s irq=%d\n", 579 seq_printf(m, "SCSI Host=scsi%d Control Node=/dev/%s irq=%d\n",
602 pHba->host->host_no, pHba->name, host->irq); 580 pHba->host->host_no, pHba->name, host->irq);
603 len += sprintf(buffer+len, "\tpost fifo size = %d\n\treply fifo size = %d\n\tsg table size = %d\n\n", 581 seq_printf(m, "\tpost fifo size = %d\n\treply fifo size = %d\n\tsg table size = %d\n\n",
604 host->can_queue, (int) pHba->reply_fifo_size , host->sg_tablesize); 582 host->can_queue, (int) pHba->reply_fifo_size , host->sg_tablesize);
605 583
606 pos = begin + len; 584 seq_printf(m, "Devices:\n");
607
608 /* CHECKPOINT */
609 if(pos > offset + length) {
610 goto stop_output;
611 }
612 if(pos <= offset) {
613 /*
614 * If we haven't even written to where we last left
615 * off (the last time we were called), reset the
616 * beginning pointer.
617 */
618 len = 0;
619 begin = pos;
620 }
621 len += sprintf(buffer+len, "Devices:\n");
622 for(chan = 0; chan < MAX_CHANNEL; chan++) { 585 for(chan = 0; chan < MAX_CHANNEL; chan++) {
623 for(id = 0; id < MAX_ID; id++) { 586 for(id = 0; id < MAX_ID; id++) {
624 d = pHba->channel[chan].device[id]; 587 d = pHba->channel[chan].device[id];
625 while(d){ 588 while(d) {
626 len += sprintf(buffer+len,"\t%-24.24s", d->pScsi_dev->vendor); 589 seq_printf(m,"\t%-24.24s", d->pScsi_dev->vendor);
627 len += sprintf(buffer+len," Rev: %-8.8s\n", d->pScsi_dev->rev); 590 seq_printf(m," Rev: %-8.8s\n", d->pScsi_dev->rev);
628 pos = begin + len;
629
630
631 /* CHECKPOINT */
632 if(pos > offset + length) {
633 goto stop_output;
634 }
635 if(pos <= offset) {
636 len = 0;
637 begin = pos;
638 }
639 591
640 unit = d->pI2o_dev->lct_data.tid; 592 unit = d->pI2o_dev->lct_data.tid;
641 len += sprintf(buffer+len, "\tTID=%d, (Channel=%d, Target=%d, Lun=%d) (%s)\n\n", 593 seq_printf(m, "\tTID=%d, (Channel=%d, Target=%d, Lun=%d) (%s)\n\n",
642 unit, (int)d->scsi_channel, (int)d->scsi_id, (int)d->scsi_lun, 594 unit, (int)d->scsi_channel, (int)d->scsi_id, (int)d->scsi_lun,
643 scsi_device_online(d->pScsi_dev)? "online":"offline"); 595 scsi_device_online(d->pScsi_dev)? "online":"offline");
644 pos = begin + len;
645
646 /* CHECKPOINT */
647 if(pos > offset + length) {
648 goto stop_output;
649 }
650 if(pos <= offset) {
651 len = 0;
652 begin = pos;
653 }
654
655 d = d->next_lun; 596 d = d->next_lun;
656 } 597 }
657 } 598 }
658 } 599 }
659 600 return 0;
660 /*
661 * begin is where we last checked our position with regards to offset
662 * begin is always less than offset. len is relative to begin. It
663 * is the number of bytes written past begin
664 *
665 */
666stop_output:
667 /* stop the output and calculate the correct length */
668 *(buffer + len) = '\0';
669
670 *start = buffer + (offset - begin); /* Start of wanted data */
671 len -= (offset - begin);
672 if(len > length) {
673 len = length;
674 } else if(len < 0){
675 len = 0;
676 **start = '\0';
677 }
678 return len;
679} 601}
680 602
681/* 603/*
@@ -3639,7 +3561,7 @@ static struct scsi_host_template driver_template = {
3639 .module = THIS_MODULE, 3561 .module = THIS_MODULE,
3640 .name = "dpt_i2o", 3562 .name = "dpt_i2o",
3641 .proc_name = "dpt_i2o", 3563 .proc_name = "dpt_i2o",
3642 .proc_info = adpt_proc_info, 3564 .show_info = adpt_show_info,
3643 .info = adpt_info, 3565 .info = adpt_info,
3644 .queuecommand = adpt_queue, 3566 .queuecommand = adpt_queue,
3645 .eh_abort_handler = adpt_abort, 3567 .eh_abort_handler = adpt_abort,
diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c
index 4b11bb04f5c4..d01f01604140 100644
--- a/drivers/scsi/dtc.c
+++ b/drivers/scsi/dtc.c
@@ -216,7 +216,8 @@ static int __init dtc_detect(struct scsi_host_template * tpnt)
216 int sig, count; 216 int sig, count;
217 217
218 tpnt->proc_name = "dtc3x80"; 218 tpnt->proc_name = "dtc3x80";
219 tpnt->proc_info = &dtc_proc_info; 219 tpnt->show_info = dtc_show_info;
220 tpnt->write_info = dtc_write_info;
220 221
221 for (count = 0; current_override < NO_OVERRIDES; ++current_override) { 222 for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
222 addr = 0; 223 addr = 0;
diff --git a/drivers/scsi/dtc.h b/drivers/scsi/dtc.h
index cdc621204b66..92d7cfc3f4fc 100644
--- a/drivers/scsi/dtc.h
+++ b/drivers/scsi/dtc.h
@@ -88,7 +88,8 @@ static int dtc_bus_reset(Scsi_Cmnd *);
88#define NCR5380_queue_command dtc_queue_command 88#define NCR5380_queue_command dtc_queue_command
89#define NCR5380_abort dtc_abort 89#define NCR5380_abort dtc_abort
90#define NCR5380_bus_reset dtc_bus_reset 90#define NCR5380_bus_reset dtc_bus_reset
91#define NCR5380_proc_info dtc_proc_info 91#define NCR5380_show_info dtc_show_info
92#define NCR5380_write_info dtc_write_info
92 93
93/* 15 12 11 10 94/* 15 12 11 10
94 1001 1100 0000 0000 */ 95 1001 1100 0000 0000 */
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index d5f8362335d3..356def44ce58 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -92,58 +92,22 @@ static unsigned long queue_counter;
92 92
93static struct scsi_host_template driver_template; 93static struct scsi_host_template driver_template;
94 94
95/* 95static int eata_pio_show_info(struct seq_file *m, struct Scsi_Host *shost)
96 * eata_proc_info
97 * inout : decides on the direction of the dataflow and the meaning of the
98 * variables
99 * buffer: If inout==FALSE data is being written to it else read from it
100 * *start: If inout==FALSE start of the valid data in the buffer
101 * offset: If inout==FALSE offset from the beginning of the imaginary file
102 * from which we start writing into the buffer
103 * length: If inout==FALSE max number of bytes to be written into the buffer
104 * else number of bytes in the buffer
105 */
106static int eata_pio_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset,
107 int length, int rw)
108{ 96{
109 int len = 0; 97 seq_printf(m, "EATA (Extended Attachment) PIO driver version: "
110 off_t begin = 0, pos = 0;
111
112 if (rw)
113 return -ENOSYS;
114
115 len += sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version: "
116 "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB); 98 "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB);
117 len += sprintf(buffer + len, "queued commands: %10ld\n" 99 seq_printf(m, "queued commands: %10ld\n"
118 "processed interrupts:%10ld\n", queue_counter, int_counter); 100 "processed interrupts:%10ld\n", queue_counter, int_counter);
119 len += sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n", 101 seq_printf(m, "\nscsi%-2d: HBA %.10s\n",
120 shost->host_no, SD(shost)->name); 102 shost->host_no, SD(shost)->name);
121 len += sprintf(buffer + len, "Firmware revision: v%s\n", 103 seq_printf(m, "Firmware revision: v%s\n",
122 SD(shost)->revision); 104 SD(shost)->revision);
123 len += sprintf(buffer + len, "IO: PIO\n"); 105 seq_printf(m, "IO: PIO\n");
124 len += sprintf(buffer + len, "Base IO : %#.4x\n", (u32) shost->base); 106 seq_printf(m, "Base IO : %#.4x\n", (u32) shost->base);
125 len += sprintf(buffer + len, "Host Bus: %s\n", 107 seq_printf(m, "Host Bus: %s\n",
126 (SD(shost)->bustype == 'P')?"PCI ": 108 (SD(shost)->bustype == 'P')?"PCI ":
127 (SD(shost)->bustype == 'E')?"EISA":"ISA "); 109 (SD(shost)->bustype == 'E')?"EISA":"ISA ");
128 110 return 0;
129 pos = begin + len;
130
131 if (pos < offset) {
132 len = 0;
133 begin = pos;
134 }
135 if (pos > offset + length)
136 goto stop_output;
137
138stop_output:
139 DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len));
140 *start = buffer + (offset - begin); /* Start of wanted data */
141 len -= (offset - begin); /* Start slop */
142 if (len > length)
143 len = length; /* Ending slop */
144 DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len));
145
146 return len;
147} 111}
148 112
149static int eata_pio_release(struct Scsi_Host *sh) 113static int eata_pio_release(struct Scsi_Host *sh)
@@ -985,7 +949,7 @@ static int eata_pio_detect(struct scsi_host_template *tpnt)
985static struct scsi_host_template driver_template = { 949static struct scsi_host_template driver_template = {
986 .proc_name = "eata_pio", 950 .proc_name = "eata_pio",
987 .name = "EATA (Extended Attachment) PIO driver", 951 .name = "EATA (Extended Attachment) PIO driver",
988 .proc_info = eata_pio_proc_info, 952 .show_info = eata_pio_show_info,
989 .detect = eata_pio_detect, 953 .detect = eata_pio_detect,
990 .release = eata_pio_release, 954 .release = eata_pio_release,
991 .queuecommand = eata_pio_queue, 955 .queuecommand = eata_pio_queue,
diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index 5041f925c191..5cec6c60ca22 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -745,42 +745,36 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src,
745 745
746#include "NCR5380.c" 746#include "NCR5380.c"
747 747
748#define PRINTP(x) len += sprintf(buffer+len, x) 748#define PRINTP(x) seq_printf(m, x)
749#define ANDP , 749#define ANDP ,
750 750
751static int sprint_opcode(char *buffer, int len, int opcode) 751static void sprint_opcode(struct seq_file *m, int opcode)
752{ 752{
753 int start = len;
754 PRINTP("0x%02x " ANDP opcode); 753 PRINTP("0x%02x " ANDP opcode);
755 return len - start;
756} 754}
757 755
758static int sprint_command(char *buffer, int len, unsigned char *command) 756static void sprint_command(struct seq_file *m, unsigned char *command)
759{ 757{
760 int i, s, start = len; 758 int i, s;
761 len += sprint_opcode(buffer, len, command[0]); 759 sprint_opcode(m, command[0]);
762 for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) 760 for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
763 PRINTP("%02x " ANDP command[i]); 761 PRINTP("%02x " ANDP command[i]);
764 PRINTP("\n"); 762 PRINTP("\n");
765 return len - start;
766} 763}
767 764
768/** 765/**
769 * sprintf_Scsi_Cmnd - print a scsi command 766 * sprintf_Scsi_Cmnd - print a scsi command
770 * @buffer: buffr to print into 767 * @m: seq_fil to print into
771 * @len: buffer length
772 * @cmd: SCSI command block 768 * @cmd: SCSI command block
773 * 769 *
774 * Print out the target and command data in hex 770 * Print out the target and command data in hex
775 */ 771 */
776 772
777static int sprint_Scsi_Cmnd(char *buffer, int len, Scsi_Cmnd * cmd) 773static void sprint_Scsi_Cmnd(struct seq_file *m, Scsi_Cmnd * cmd)
778{ 774{
779 int start = len;
780 PRINTP("host number %d destination target %d, lun %d\n" ANDP cmd->device->host->host_no ANDP cmd->device->id ANDP cmd->device->lun); 775 PRINTP("host number %d destination target %d, lun %d\n" ANDP cmd->device->host->host_no ANDP cmd->device->id ANDP cmd->device->lun);
781 PRINTP(" command = "); 776 PRINTP(" command = ");
782 len += sprint_command(buffer, len, cmd->cmnd); 777 sprint_command(m, cmd->cmnd);
783 return len - start;
784} 778}
785 779
786/** 780/**
@@ -800,9 +794,8 @@ static int sprint_Scsi_Cmnd(char *buffer, int len, Scsi_Cmnd * cmd)
800 * Locks: global cli/lock for queue walk 794 * Locks: global cli/lock for queue walk
801 */ 795 */
802 796
803static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, char **start, off_t offset, int length, int inout) 797static int generic_NCR5380_show_info(struct seq_file *m, struct Scsi_Host *scsi_ptr)
804{ 798{
805 int len = 0;
806 NCR5380_local_declare(); 799 NCR5380_local_declare();
807 unsigned long flags; 800 unsigned long flags;
808 unsigned char status; 801 unsigned char status;
@@ -853,16 +846,16 @@ static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, c
853 PRINTP(" T:%d %s " ANDP dev->id ANDP scsi_device_type(dev->type)); 846 PRINTP(" T:%d %s " ANDP dev->id ANDP scsi_device_type(dev->type));
854 for (i = 0; i < 8; i++) 847 for (i = 0; i < 8; i++)
855 if (dev->vendor[i] >= 0x20) 848 if (dev->vendor[i] >= 0x20)
856 *(buffer + (len++)) = dev->vendor[i]; 849 seq_putc(m, dev->vendor[i]);
857 *(buffer + (len++)) = ' '; 850 seq_putc(m, ' ');
858 for (i = 0; i < 16; i++) 851 for (i = 0; i < 16; i++)
859 if (dev->model[i] >= 0x20) 852 if (dev->model[i] >= 0x20)
860 *(buffer + (len++)) = dev->model[i]; 853 seq_putc(m, dev->model[i]);
861 *(buffer + (len++)) = ' '; 854 seq_putc(m, ' ');
862 for (i = 0; i < 4; i++) 855 for (i = 0; i < 4; i++)
863 if (dev->rev[i] >= 0x20) 856 if (dev->rev[i] >= 0x20)
864 *(buffer + (len++)) = dev->rev[i]; 857 seq_putc(m, dev->rev[i]);
865 *(buffer + (len++)) = ' '; 858 seq_putc(m, ' ');
866 859
867 PRINTP("\n%10ld kb read in %5ld secs" ANDP br / 1024 ANDP tr); 860 PRINTP("\n%10ld kb read in %5ld secs" ANDP br / 1024 ANDP tr);
868 if (tr) 861 if (tr)
@@ -886,32 +879,28 @@ static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, c
886 if (!hostdata->connected) { 879 if (!hostdata->connected) {
887 PRINTP("No currently connected command\n"); 880 PRINTP("No currently connected command\n");
888 } else { 881 } else {
889 len += sprint_Scsi_Cmnd(buffer, len, (Scsi_Cmnd *) hostdata->connected); 882 sprint_Scsi_Cmnd(m, (Scsi_Cmnd *) hostdata->connected);
890 } 883 }
891 884
892 PRINTP("issue_queue\n"); 885 PRINTP("issue_queue\n");
893 886
894 for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) 887 for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
895 len += sprint_Scsi_Cmnd(buffer, len, ptr); 888 sprint_Scsi_Cmnd(m, ptr);
896 889
897 PRINTP("disconnected_queue\n"); 890 PRINTP("disconnected_queue\n");
898 891
899 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) 892 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
900 len += sprint_Scsi_Cmnd(buffer, len, ptr); 893 sprint_Scsi_Cmnd(m, ptr);
901 894
902 *start = buffer + offset;
903 len -= offset;
904 if (len > length)
905 len = length;
906 spin_unlock_irqrestore(scsi_ptr->host_lock, flags); 895 spin_unlock_irqrestore(scsi_ptr->host_lock, flags);
907 return len; 896 return 0;
908} 897}
909 898
910#undef PRINTP 899#undef PRINTP
911#undef ANDP 900#undef ANDP
912 901
913static struct scsi_host_template driver_template = { 902static struct scsi_host_template driver_template = {
914 .proc_info = generic_NCR5380_proc_info, 903 .show_info = generic_NCR5380_show_info,
915 .name = "Generic NCR5380/NCR53C400 Scsi Driver", 904 .name = "Generic NCR5380/NCR53C400 Scsi Driver",
916 .detect = generic_NCR5380_detect, 905 .detect = generic_NCR5380_detect,
917 .release = generic_NCR5380_release_resources, 906 .release = generic_NCR5380_release_resources,
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 59bceac51a4c..6d55b4e7e792 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -4676,7 +4676,8 @@ static struct scsi_host_template gdth_template = {
4676 .eh_bus_reset_handler = gdth_eh_bus_reset, 4676 .eh_bus_reset_handler = gdth_eh_bus_reset,
4677 .slave_configure = gdth_slave_configure, 4677 .slave_configure = gdth_slave_configure,
4678 .bios_param = gdth_bios_param, 4678 .bios_param = gdth_bios_param,
4679 .proc_info = gdth_proc_info, 4679 .show_info = gdth_show_info,
4680 .write_info = gdth_set_info,
4680 .eh_timed_out = gdth_timed_out, 4681 .eh_timed_out = gdth_timed_out,
4681 .proc_name = "gdth", 4682 .proc_name = "gdth",
4682 .can_queue = GDTH_MAXCMDS, 4683 .can_queue = GDTH_MAXCMDS,
diff --git a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h
index fbf6f0f4b0dd..3fd8b83ffbf9 100644
--- a/drivers/scsi/gdth.h
+++ b/drivers/scsi/gdth.h
@@ -1007,6 +1007,7 @@ typedef struct {
1007 1007
1008/* function prototyping */ 1008/* function prototyping */
1009 1009
1010int gdth_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int); 1010int gdth_show_info(struct seq_file *, struct Scsi_Host *);
1011int gdth_set_info(struct Scsi_Host *, char *, int);
1011 1012
1012#endif 1013#endif
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index 652754319a4b..9fb632684863 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -5,23 +5,9 @@
5#include <linux/completion.h> 5#include <linux/completion.h>
6#include <linux/slab.h> 6#include <linux/slab.h>
7 7
8int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length, 8int gdth_set_info(struct Scsi_Host *host, char *buffer, int length)
9 int inout)
10{ 9{
11 gdth_ha_str *ha = shost_priv(host); 10 gdth_ha_str *ha = shost_priv(host);
12
13 TRACE2(("gdth_proc_info() length %d offs %d inout %d\n",
14 length,(int)offset,inout));
15
16 if (inout)
17 return(gdth_set_info(buffer,length,host,ha));
18 else
19 return(gdth_get_info(buffer,start,offset,length,host,ha));
20}
21
22static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
23 gdth_ha_str *ha)
24{
25 int ret_val = -EINVAL; 11 int ret_val = -EINVAL;
26 12
27 TRACE2(("gdth_set_info() ha %d\n",ha->hanum,)); 13 TRACE2(("gdth_set_info() ha %d\n",ha->hanum,));
@@ -149,12 +135,10 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
149 return(-EINVAL); 135 return(-EINVAL);
150} 136}
151 137
152static int gdth_get_info(char *buffer,char **start,off_t offset,int length, 138int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
153 struct Scsi_Host *host, gdth_ha_str *ha)
154{ 139{
155 int size = 0,len = 0; 140 gdth_ha_str *ha = shost_priv(host);
156 int hlen; 141 int hlen;
157 off_t begin = 0,pos = 0;
158 int id, i, j, k, sec, flag; 142 int id, i, j, k, sec, flag;
159 int no_mdrv = 0, drv_no, is_mirr; 143 int no_mdrv = 0, drv_no, is_mirr;
160 u32 cnt; 144 u32 cnt;
@@ -189,8 +173,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
189 /* request is i.e. "cat /proc/scsi/gdth/0" */ 173 /* request is i.e. "cat /proc/scsi/gdth/0" */
190 /* format: %-15s\t%-10s\t%-15s\t%s */ 174 /* format: %-15s\t%-10s\t%-15s\t%s */
191 /* driver parameters */ 175 /* driver parameters */
192 size = sprintf(buffer+len,"Driver Parameters:\n"); 176 seq_printf(m, "Driver Parameters:\n");
193 len += size; pos = begin + len;
194 if (reserve_list[0] == 0xff) 177 if (reserve_list[0] == 0xff)
195 strcpy(hrec, "--"); 178 strcpy(hrec, "--");
196 else { 179 else {
@@ -201,69 +184,50 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
201 hlen += snprintf(hrec + hlen , 161 - hlen, ",%d", reserve_list[i]); 184 hlen += snprintf(hrec + hlen , 161 - hlen, ",%d", reserve_list[i]);
202 } 185 }
203 } 186 }
204 size = sprintf(buffer+len, 187 seq_printf(m,
205 " reserve_mode: \t%d \treserve_list: \t%s\n", 188 " reserve_mode: \t%d \treserve_list: \t%s\n",
206 reserve_mode, hrec); 189 reserve_mode, hrec);
207 len += size; pos = begin + len; 190 seq_printf(m,
208 size = sprintf(buffer+len,
209 " max_ids: \t%-3d \thdr_channel: \t%d\n", 191 " max_ids: \t%-3d \thdr_channel: \t%d\n",
210 max_ids, hdr_channel); 192 max_ids, hdr_channel);
211 len += size; pos = begin + len;
212 193
213 /* controller information */ 194 /* controller information */
214 size = sprintf(buffer+len,"\nDisk Array Controller Information:\n"); 195 seq_printf(m,"\nDisk Array Controller Information:\n");
215 len += size; pos = begin + len; 196 seq_printf(m,
216 strcpy(hrec, ha->binfo.type_string);
217 size = sprintf(buffer+len,
218 " Number: \t%d \tName: \t%s\n", 197 " Number: \t%d \tName: \t%s\n",
219 ha->hanum, hrec); 198 ha->hanum, ha->binfo.type_string);
220 len += size; pos = begin + len;
221 199
200 seq_printf(m,
201 " Driver Ver.: \t%-10s\tFirmware Ver.: \t",
202 GDTH_VERSION_STR);
222 if (ha->more_proc) 203 if (ha->more_proc)
223 sprintf(hrec, "%d.%02d.%02d-%c%03X", 204 seq_printf(m, "%d.%02d.%02d-%c%03X\n",
224 (u8)(ha->binfo.upd_fw_ver>>24), 205 (u8)(ha->binfo.upd_fw_ver>>24),
225 (u8)(ha->binfo.upd_fw_ver>>16), 206 (u8)(ha->binfo.upd_fw_ver>>16),
226 (u8)(ha->binfo.upd_fw_ver), 207 (u8)(ha->binfo.upd_fw_ver),
227 ha->bfeat.raid ? 'R':'N', 208 ha->bfeat.raid ? 'R':'N',
228 ha->binfo.upd_revision); 209 ha->binfo.upd_revision);
229 else 210 else
230 sprintf(hrec, "%d.%02d", (u8)(ha->cpar.version>>8), 211 seq_printf(m, "%d.%02d\n", (u8)(ha->cpar.version>>8),
231 (u8)(ha->cpar.version)); 212 (u8)(ha->cpar.version));
232
233 size = sprintf(buffer+len,
234 " Driver Ver.: \t%-10s\tFirmware Ver.: \t%s\n",
235 GDTH_VERSION_STR, hrec);
236 len += size; pos = begin + len;
237 213
238 if (ha->more_proc) { 214 if (ha->more_proc)
239 /* more information: 1. about controller */ 215 /* more information: 1. about controller */
240 size = sprintf(buffer+len, 216 seq_printf(m,
241 " Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n", 217 " Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n",
242 ha->binfo.ser_no, ha->binfo.memsize / 1024); 218 ha->binfo.ser_no, ha->binfo.memsize / 1024);
243 len += size; pos = begin + len;
244 }
245 219
246#ifdef GDTH_DMA_STATISTICS 220#ifdef GDTH_DMA_STATISTICS
247 /* controller statistics */ 221 /* controller statistics */
248 size = sprintf(buffer+len,"\nController Statistics:\n"); 222 seq_printf(m,"\nController Statistics:\n");
249 len += size; pos = begin + len; 223 seq_printf(m,
250 size = sprintf(buffer+len,
251 " 32-bit DMA buffer:\t%lu\t64-bit DMA buffer:\t%lu\n", 224 " 32-bit DMA buffer:\t%lu\t64-bit DMA buffer:\t%lu\n",
252 ha->dma32_cnt, ha->dma64_cnt); 225 ha->dma32_cnt, ha->dma64_cnt);
253 len += size; pos = begin + len;
254#endif 226#endif
255 227
256 if (pos < offset) {
257 len = 0;
258 begin = pos;
259 }
260 if (pos > offset + length)
261 goto stop_output;
262
263 if (ha->more_proc) { 228 if (ha->more_proc) {
264 /* more information: 2. about physical devices */ 229 /* more information: 2. about physical devices */
265 size = sprintf(buffer+len,"\nPhysical Devices:"); 230 seq_printf(m, "\nPhysical Devices:");
266 len += size; pos = begin + len;
267 flag = FALSE; 231 flag = FALSE;
268 232
269 buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); 233 buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
@@ -309,21 +273,19 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
309 strncpy(hrec+8,pdi->product,16); 273 strncpy(hrec+8,pdi->product,16);
310 strncpy(hrec+24,pdi->revision,4); 274 strncpy(hrec+24,pdi->revision,4);
311 hrec[28] = 0; 275 hrec[28] = 0;
312 size = sprintf(buffer+len, 276 seq_printf(m,
313 "\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n", 277 "\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n",
314 'A'+i,pdi->target_id,pdi->lun,hrec); 278 'A'+i,pdi->target_id,pdi->lun,hrec);
315 len += size; pos = begin + len;
316 flag = TRUE; 279 flag = TRUE;
317 pdi->no_ldrive &= 0xffff; 280 pdi->no_ldrive &= 0xffff;
318 if (pdi->no_ldrive == 0xffff) 281 if (pdi->no_ldrive == 0xffff)
319 strcpy(hrec,"--"); 282 strcpy(hrec,"--");
320 else 283 else
321 sprintf(hrec,"%d",pdi->no_ldrive); 284 sprintf(hrec,"%d",pdi->no_ldrive);
322 size = sprintf(buffer+len, 285 seq_printf(m,
323 " Capacity [MB]:\t%-6d \tTo Log. Drive: \t%s\n", 286 " Capacity [MB]:\t%-6d \tTo Log. Drive: \t%s\n",
324 pdi->blkcnt/(1024*1024/pdi->blksize), 287 pdi->blkcnt/(1024*1024/pdi->blksize),
325 hrec); 288 hrec);
326 len += size; pos = begin + len;
327 } else { 289 } else {
328 pdi->devtype = 0xff; 290 pdi->devtype = 0xff;
329 } 291 }
@@ -333,11 +295,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
333 for (k = 0; k < pds->count; ++k) { 295 for (k = 0; k < pds->count; ++k) {
334 if (pds->list[k].tid == pdi->target_id && 296 if (pds->list[k].tid == pdi->target_id &&
335 pds->list[k].lun == pdi->lun) { 297 pds->list[k].lun == pdi->lun) {
336 size = sprintf(buffer+len, 298 seq_printf(m,
337 " Retries: \t%-6d \tReassigns: \t%d\n", 299 " Retries: \t%-6d \tReassigns: \t%d\n",
338 pds->list[k].retries, 300 pds->list[k].retries,
339 pds->list[k].reassigns); 301 pds->list[k].reassigns);
340 len += size; pos = begin + len;
341 break; 302 break;
342 } 303 }
343 } 304 }
@@ -355,32 +316,20 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
355 pdef->sddc_type = 0x08; 316 pdef->sddc_type = 0x08;
356 317
357 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { 318 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
358 size = sprintf(buffer+len, 319 seq_printf(m,
359 " Grown Defects:\t%d\n", 320 " Grown Defects:\t%d\n",
360 pdef->sddc_cnt); 321 pdef->sddc_cnt);
361 len += size; pos = begin + len;
362 } 322 }
363 } 323 }
364 if (pos < offset) {
365 len = 0;
366 begin = pos;
367 }
368 if (pos > offset + length) {
369 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
370 goto stop_output;
371 }
372 } 324 }
373 } 325 }
374 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); 326 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
375 327
376 if (!flag) { 328 if (!flag)
377 size = sprintf(buffer+len, "\n --\n"); 329 seq_printf(m, "\n --\n");
378 len += size; pos = begin + len;
379 }
380 330
381 /* 3. about logical drives */ 331 /* 3. about logical drives */
382 size = sprintf(buffer+len,"\nLogical Drives:"); 332 seq_printf(m,"\nLogical Drives:");
383 len += size; pos = begin + len;
384 flag = FALSE; 333 flag = FALSE;
385 334
386 buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); 335 buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
@@ -418,10 +367,9 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
418 } 367 }
419 368
420 if (drv_no == i) { 369 if (drv_no == i) {
421 size = sprintf(buffer+len, 370 seq_printf(m,
422 "\n Number: \t%-2d \tStatus: \t%s\n", 371 "\n Number: \t%-2d \tStatus: \t%s\n",
423 drv_no, hrec); 372 drv_no, hrec);
424 len += size; pos = begin + len;
425 flag = TRUE; 373 flag = TRUE;
426 no_mdrv = pcdi->cd_ldcnt; 374 no_mdrv = pcdi->cd_ldcnt;
427 if (no_mdrv > 1 || pcdi->ld_slave != -1) { 375 if (no_mdrv > 1 || pcdi->ld_slave != -1) {
@@ -436,61 +384,37 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
436 } else { 384 } else {
437 strcpy(hrec, "???"); 385 strcpy(hrec, "???");
438 } 386 }
439 size = sprintf(buffer+len, 387 seq_printf(m,
440 " Capacity [MB]:\t%-6d \tType: \t%s\n", 388 " Capacity [MB]:\t%-6d \tType: \t%s\n",
441 pcdi->ld_blkcnt/(1024*1024/pcdi->ld_blksize), 389 pcdi->ld_blkcnt/(1024*1024/pcdi->ld_blksize),
442 hrec); 390 hrec);
443 len += size; pos = begin + len;
444 } else { 391 } else {
445 size = sprintf(buffer+len, 392 seq_printf(m,
446 " Slave Number: \t%-2d \tStatus: \t%s\n", 393 " Slave Number: \t%-2d \tStatus: \t%s\n",
447 drv_no & 0x7fff, hrec); 394 drv_no & 0x7fff, hrec);
448 len += size; pos = begin + len;
449 } 395 }
450 drv_no = pcdi->ld_slave; 396 drv_no = pcdi->ld_slave;
451 if (pos < offset) {
452 len = 0;
453 begin = pos;
454 }
455 if (pos > offset + length) {
456 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
457 goto stop_output;
458 }
459 } while (drv_no != -1); 397 } while (drv_no != -1);
460 398
461 if (is_mirr) { 399 if (is_mirr)
462 size = sprintf(buffer+len, 400 seq_printf(m,
463 " Missing Drv.: \t%-2d \tInvalid Drv.: \t%d\n", 401 " Missing Drv.: \t%-2d \tInvalid Drv.: \t%d\n",
464 no_mdrv - j - k, k); 402 no_mdrv - j - k, k);
465 len += size; pos = begin + len; 403
466 }
467
468 if (!ha->hdr[i].is_arraydrv) 404 if (!ha->hdr[i].is_arraydrv)
469 strcpy(hrec, "--"); 405 strcpy(hrec, "--");
470 else 406 else
471 sprintf(hrec, "%d", ha->hdr[i].master_no); 407 sprintf(hrec, "%d", ha->hdr[i].master_no);
472 size = sprintf(buffer+len, 408 seq_printf(m,
473 " To Array Drv.:\t%s\n", hrec); 409 " To Array Drv.:\t%s\n", hrec);
474 len += size; pos = begin + len;
475 if (pos < offset) {
476 len = 0;
477 begin = pos;
478 }
479 if (pos > offset + length) {
480 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
481 goto stop_output;
482 }
483 } 410 }
484 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); 411 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
485 412
486 if (!flag) { 413 if (!flag)
487 size = sprintf(buffer+len, "\n --\n"); 414 seq_printf(m, "\n --\n");
488 len += size; pos = begin + len;
489 }
490 415
491 /* 4. about array drives */ 416 /* 4. about array drives */
492 size = sprintf(buffer+len,"\nArray Drives:"); 417 seq_printf(m,"\nArray Drives:");
493 len += size; pos = begin + len;
494 flag = FALSE; 418 flag = FALSE;
495 419
496 buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); 420 buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
@@ -525,10 +449,9 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
525 strcat(hrec, "/expand"); 449 strcat(hrec, "/expand");
526 else if (pai->ai_ext_state & 0x1) 450 else if (pai->ai_ext_state & 0x1)
527 strcat(hrec, "/patch"); 451 strcat(hrec, "/patch");
528 size = sprintf(buffer+len, 452 seq_printf(m,
529 "\n Number: \t%-2d \tStatus: \t%s\n", 453 "\n Number: \t%-2d \tStatus: \t%s\n",
530 i,hrec); 454 i,hrec);
531 len += size; pos = begin + len;
532 flag = TRUE; 455 flag = TRUE;
533 456
534 if (pai->ai_type == 0) 457 if (pai->ai_type == 0)
@@ -539,31 +462,19 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
539 strcpy(hrec, "RAID-5"); 462 strcpy(hrec, "RAID-5");
540 else 463 else
541 strcpy(hrec, "RAID-10"); 464 strcpy(hrec, "RAID-10");
542 size = sprintf(buffer+len, 465 seq_printf(m,
543 " Capacity [MB]:\t%-6d \tType: \t%s\n", 466 " Capacity [MB]:\t%-6d \tType: \t%s\n",
544 pai->ai_size/(1024*1024/pai->ai_secsize), 467 pai->ai_size/(1024*1024/pai->ai_secsize),
545 hrec); 468 hrec);
546 len += size; pos = begin + len;
547 if (pos < offset) {
548 len = 0;
549 begin = pos;
550 }
551 if (pos > offset + length) {
552 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
553 goto stop_output;
554 }
555 } 469 }
556 } 470 }
557 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); 471 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
558 472
559 if (!flag) { 473 if (!flag)
560 size = sprintf(buffer+len, "\n --\n"); 474 seq_printf(m, "\n --\n");
561 len += size; pos = begin + len;
562 }
563 475
564 /* 5. about host drives */ 476 /* 5. about host drives */
565 size = sprintf(buffer+len,"\nHost Drives:"); 477 seq_printf(m,"\nHost Drives:");
566 len += size; pos = begin + len;
567 flag = FALSE; 478 flag = FALSE;
568 479
569 buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr); 480 buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr);
@@ -605,33 +516,22 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
605 if (!(ha->hdr[i].present)) 516 if (!(ha->hdr[i].present))
606 continue; 517 continue;
607 518
608 size = sprintf(buffer+len, 519 seq_printf(m,
609 "\n Number: \t%-2d \tArr/Log. Drive:\t%d\n", 520 "\n Number: \t%-2d \tArr/Log. Drive:\t%d\n",
610 i, ha->hdr[i].ldr_no); 521 i, ha->hdr[i].ldr_no);
611 len += size; pos = begin + len;
612 flag = TRUE; 522 flag = TRUE;
613 523
614 size = sprintf(buffer+len, 524 seq_printf(m,
615 " Capacity [MB]:\t%-6d \tStart Sector: \t%d\n", 525 " Capacity [MB]:\t%-6d \tStart Sector: \t%d\n",
616 (u32)(ha->hdr[i].size/2048), ha->hdr[i].start_sec); 526 (u32)(ha->hdr[i].size/2048), ha->hdr[i].start_sec);
617 len += size; pos = begin + len;
618 if (pos < offset) {
619 len = 0;
620 begin = pos;
621 }
622 if (pos > offset + length)
623 goto stop_output;
624 } 527 }
625 528
626 if (!flag) { 529 if (!flag)
627 size = sprintf(buffer+len, "\n --\n"); 530 seq_printf(m, "\n --\n");
628 len += size; pos = begin + len;
629 }
630 } 531 }
631 532
632 /* controller events */ 533 /* controller events */
633 size = sprintf(buffer+len,"\nController Events:\n"); 534 seq_printf(m,"\nController Events:\n");
634 len += size; pos = begin + len;
635 535
636 for (id = -1;;) { 536 for (id = -1;;) {
637 id = gdth_read_event(ha, id, estr); 537 id = gdth_read_event(ha, id, estr);
@@ -643,29 +543,14 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
643 do_gettimeofday(&tv); 543 do_gettimeofday(&tv);
644 sec = (int)(tv.tv_sec - estr->first_stamp); 544 sec = (int)(tv.tv_sec - estr->first_stamp);
645 if (sec < 0) sec = 0; 545 if (sec < 0) sec = 0;
646 size = sprintf(buffer+len," date- %02d:%02d:%02d\t%s\n", 546 seq_printf(m," date- %02d:%02d:%02d\t%s\n",
647 sec/3600, sec%3600/60, sec%60, hrec); 547 sec/3600, sec%3600/60, sec%60, hrec);
648 len += size; pos = begin + len;
649 if (pos < offset) {
650 len = 0;
651 begin = pos;
652 }
653 if (pos > offset + length)
654 goto stop_output;
655 } 548 }
656 if (id == -1) 549 if (id == -1)
657 break; 550 break;
658 } 551 }
659
660stop_output: 552stop_output:
661 *start = buffer +(offset-begin); 553 rc = 0;
662 len -= (offset-begin);
663 if (len > length)
664 len = length;
665 TRACE2(("get_info() len %d pos %d begin %d offset %d length %d size %d\n",
666 len,(int)pos,(int)begin,(int)offset,length,size));
667 rc = len;
668
669free_fail: 554free_fail:
670 kfree(gdtcmd); 555 kfree(gdtcmd);
671 kfree(estr); 556 kfree(estr);
diff --git a/drivers/scsi/gdth_proc.h b/drivers/scsi/gdth_proc.h
index dab15f59f2cc..aaa618198972 100644
--- a/drivers/scsi/gdth_proc.h
+++ b/drivers/scsi/gdth_proc.h
@@ -8,11 +8,6 @@
8int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd, 8int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd,
9 int timeout, u32 *info); 9 int timeout, u32 *info);
10 10
11static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
12 gdth_ha_str *ha);
13static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
14 struct Scsi_Host *host, gdth_ha_str *ha);
15
16static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, 11static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
17 int length, gdth_ha_str *ha); 12 int length, gdth_ha_str *ha);
18 13
diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c
index dbe4cc6b9f8b..2203ac281103 100644
--- a/drivers/scsi/gvp11.c
+++ b/drivers/scsi/gvp11.c
@@ -191,7 +191,8 @@ static int gvp11_bus_reset(struct scsi_cmnd *cmd)
191static struct scsi_host_template gvp11_scsi_template = { 191static struct scsi_host_template gvp11_scsi_template = {
192 .module = THIS_MODULE, 192 .module = THIS_MODULE,
193 .name = "GVP Series II SCSI", 193 .name = "GVP Series II SCSI",
194 .proc_info = wd33c93_proc_info, 194 .show_info = wd33c93_show_info,
195 .write_info = wd33c93_write_info,
195 .proc_name = "GVP11", 196 .proc_name = "GVP11",
196 .queuecommand = wd33c93_queuecommand, 197 .queuecommand = wd33c93_queuecommand,
197 .eh_abort_handler = wd33c93_abort, 198 .eh_abort_handler = wd33c93_abort,
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 26cd9d1d7571..89a8266560d0 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -121,45 +121,26 @@ static inline void imm_pb_release(imm_struct *dev)
121 * testing... 121 * testing...
122 * Also gives a method to use a script to obtain optimum timings (TODO) 122 * Also gives a method to use a script to obtain optimum timings (TODO)
123 */ 123 */
124static inline int imm_proc_write(imm_struct *dev, char *buffer, int length) 124static int imm_write_info(struct Scsi_Host *host, char *buffer, int length)
125{ 125{
126 unsigned long x; 126 imm_struct *dev = imm_dev(host);
127 127
128 if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) { 128 if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) {
129 x = simple_strtoul(buffer + 5, NULL, 0); 129 dev->mode = simple_strtoul(buffer + 5, NULL, 0);
130 dev->mode = x;
131 return length; 130 return length;
132 } 131 }
133 printk("imm /proc: invalid variable\n"); 132 printk("imm /proc: invalid variable\n");
134 return (-EINVAL); 133 return -EINVAL;
135} 134}
136 135
137static int imm_proc_info(struct Scsi_Host *host, char *buffer, char **start, 136static int imm_show_info(struct seq_file *m, struct Scsi_Host *host)
138 off_t offset, int length, int inout)
139{ 137{
140 imm_struct *dev = imm_dev(host); 138 imm_struct *dev = imm_dev(host);
141 int len = 0;
142
143 if (inout)
144 return imm_proc_write(dev, buffer, length);
145
146 len += sprintf(buffer + len, "Version : %s\n", IMM_VERSION);
147 len +=
148 sprintf(buffer + len, "Parport : %s\n",
149 dev->dev->port->name);
150 len +=
151 sprintf(buffer + len, "Mode : %s\n",
152 IMM_MODE_STRING[dev->mode]);
153 139
154 /* Request for beyond end of buffer */ 140 seq_printf(m, "Version : %s\n", IMM_VERSION);
155 if (offset > len) 141 seq_printf(m, "Parport : %s\n", dev->dev->port->name);
156 return 0; 142 seq_printf(m, "Mode : %s\n", IMM_MODE_STRING[dev->mode]);
157 143 return 0;
158 *start = buffer + offset;
159 len -= offset;
160 if (len > length)
161 len = length;
162 return len;
163} 144}
164 145
165#if IMM_DEBUG > 0 146#if IMM_DEBUG > 0
@@ -1118,7 +1099,8 @@ static int imm_adjust_queue(struct scsi_device *device)
1118static struct scsi_host_template imm_template = { 1099static struct scsi_host_template imm_template = {
1119 .module = THIS_MODULE, 1100 .module = THIS_MODULE,
1120 .proc_name = "imm", 1101 .proc_name = "imm",
1121 .proc_info = imm_proc_info, 1102 .show_info = imm_show_info,
1103 .write_info = imm_write_info,
1122 .name = "Iomega VPI2 (imm) interface", 1104 .name = "Iomega VPI2 (imm) interface",
1123 .queuecommand = imm_queuecommand, 1105 .queuecommand = imm_queuecommand,
1124 .eh_abort_handler = imm_abort, 1106 .eh_abort_handler = imm_abort,
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
index deb5b6d8398e..bf028218ac36 100644
--- a/drivers/scsi/in2000.c
+++ b/drivers/scsi/in2000.c
@@ -2166,152 +2166,117 @@ static int in2000_biosparam(struct scsi_device *sdev, struct block_device *bdev,
2166} 2166}
2167 2167
2168 2168
2169static int in2000_proc_info(struct Scsi_Host *instance, char *buf, char **start, off_t off, int len, int in) 2169static int in2000_write_info(struct Scsi_Host *instance, char *buf, int len)
2170{ 2170{
2171 2171
2172#ifdef PROC_INTERFACE 2172#ifdef PROC_INTERFACE
2173 2173
2174 char *bp; 2174 char *bp;
2175 char tbuf[128];
2176 unsigned long flags;
2177 struct IN2000_hostdata *hd; 2175 struct IN2000_hostdata *hd;
2178 Scsi_Cmnd *cmd;
2179 int x, i; 2176 int x, i;
2180 static int stop = 0;
2181 2177
2182 hd = (struct IN2000_hostdata *) instance->hostdata; 2178 hd = (struct IN2000_hostdata *) instance->hostdata;
2183 2179
2184/* If 'in' is TRUE we need to _read_ the proc file. We accept the following 2180 buf[len] = '\0';
2185 * keywords (same format as command-line, but only ONE per read): 2181 bp = buf;
2186 * debug 2182 if (!strncmp(bp, "debug:", 6)) {
2187 * disconnect 2183 bp += 6;
2188 * period 2184 hd->args = simple_strtoul(bp, NULL, 0) & DB_MASK;
2189 * resync 2185 } else if (!strncmp(bp, "disconnect:", 11)) {
2190 * proc 2186 bp += 11;
2191 */ 2187 x = simple_strtoul(bp, NULL, 0);
2192 2188 if (x < DIS_NEVER || x > DIS_ALWAYS)
2193 if (in) { 2189 x = DIS_ADAPTIVE;
2194 buf[len] = '\0'; 2190 hd->disconnect = x;
2195 bp = buf; 2191 } else if (!strncmp(bp, "period:", 7)) {
2196 if (!strncmp(bp, "debug:", 6)) { 2192 bp += 7;
2197 bp += 6; 2193 x = simple_strtoul(bp, NULL, 0);
2198 hd->args = simple_strtoul(bp, NULL, 0) & DB_MASK; 2194 hd->default_sx_per = sx_table[round_period((unsigned int) x)].period_ns;
2199 } else if (!strncmp(bp, "disconnect:", 11)) { 2195 } else if (!strncmp(bp, "resync:", 7)) {
2200 bp += 11; 2196 bp += 7;
2201 x = simple_strtoul(bp, NULL, 0); 2197 x = simple_strtoul(bp, NULL, 0);
2202 if (x < DIS_NEVER || x > DIS_ALWAYS) 2198 for (i = 0; i < 7; i++)
2203 x = DIS_ADAPTIVE; 2199 if (x & (1 << i))
2204 hd->disconnect = x; 2200 hd->sync_stat[i] = SS_UNSET;
2205 } else if (!strncmp(bp, "period:", 7)) { 2201 } else if (!strncmp(bp, "proc:", 5)) {
2206 bp += 7; 2202 bp += 5;
2207 x = simple_strtoul(bp, NULL, 0); 2203 hd->proc = simple_strtoul(bp, NULL, 0);
2208 hd->default_sx_per = sx_table[round_period((unsigned int) x)].period_ns; 2204 } else if (!strncmp(bp, "level2:", 7)) {
2209 } else if (!strncmp(bp, "resync:", 7)) { 2205 bp += 7;
2210 bp += 7; 2206 hd->level2 = simple_strtoul(bp, NULL, 0);
2211 x = simple_strtoul(bp, NULL, 0);
2212 for (i = 0; i < 7; i++)
2213 if (x & (1 << i))
2214 hd->sync_stat[i] = SS_UNSET;
2215 } else if (!strncmp(bp, "proc:", 5)) {
2216 bp += 5;
2217 hd->proc = simple_strtoul(bp, NULL, 0);
2218 } else if (!strncmp(bp, "level2:", 7)) {
2219 bp += 7;
2220 hd->level2 = simple_strtoul(bp, NULL, 0);
2221 }
2222 return len;
2223 } 2207 }
2208#endif
2209 return len;
2210}
2211
2212static int in2000_show_info(struct seq_file *m, struct Scsi_Host *instance)
2213{
2214
2215#ifdef PROC_INTERFACE
2216 unsigned long flags;
2217 struct IN2000_hostdata *hd;
2218 Scsi_Cmnd *cmd;
2219 int x;
2220
2221 hd = (struct IN2000_hostdata *) instance->hostdata;
2224 2222
2225 spin_lock_irqsave(instance->host_lock, flags); 2223 spin_lock_irqsave(instance->host_lock, flags);
2226 bp = buf; 2224 if (hd->proc & PR_VERSION)
2227 *bp = '\0'; 2225 seq_printf(m, "\nVersion %s - %s.", IN2000_VERSION, IN2000_DATE);
2228 if (hd->proc & PR_VERSION) { 2226
2229 sprintf(tbuf, "\nVersion %s - %s.", IN2000_VERSION, IN2000_DATE);
2230 strcat(bp, tbuf);
2231 }
2232 if (hd->proc & PR_INFO) { 2227 if (hd->proc & PR_INFO) {
2233 sprintf(tbuf, "\ndip_switch=%02x: irq=%d io=%02x floppy=%s sync/DOS5=%s", (hd->dip_switch & 0x7f), instance->irq, hd->io_base, (hd->dip_switch & 0x40) ? "Yes" : "No", (hd->dip_switch & 0x20) ? "Yes" : "No"); 2228 seq_printf(m, "\ndip_switch=%02x: irq=%d io=%02x floppy=%s sync/DOS5=%s", (hd->dip_switch & 0x7f), instance->irq, hd->io_base, (hd->dip_switch & 0x40) ? "Yes" : "No", (hd->dip_switch & 0x20) ? "Yes" : "No");
2234 strcat(bp, tbuf); 2229 seq_printf(m, "\nsync_xfer[] = ");
2235 strcat(bp, "\nsync_xfer[] = "); 2230 for (x = 0; x < 7; x++)
2236 for (x = 0; x < 7; x++) { 2231 seq_printf(m, "\t%02x", hd->sync_xfer[x]);
2237 sprintf(tbuf, "\t%02x", hd->sync_xfer[x]); 2232 seq_printf(m, "\nsync_stat[] = ");
2238 strcat(bp, tbuf); 2233 for (x = 0; x < 7; x++)
2239 } 2234 seq_printf(m, "\t%02x", hd->sync_stat[x]);
2240 strcat(bp, "\nsync_stat[] = ");
2241 for (x = 0; x < 7; x++) {
2242 sprintf(tbuf, "\t%02x", hd->sync_stat[x]);
2243 strcat(bp, tbuf);
2244 }
2245 } 2235 }
2246#ifdef PROC_STATISTICS 2236#ifdef PROC_STATISTICS
2247 if (hd->proc & PR_STATISTICS) { 2237 if (hd->proc & PR_STATISTICS) {
2248 strcat(bp, "\ncommands issued: "); 2238 seq_printf(m, "\ncommands issued: ");
2249 for (x = 0; x < 7; x++) { 2239 for (x = 0; x < 7; x++)
2250 sprintf(tbuf, "\t%ld", hd->cmd_cnt[x]); 2240 seq_printf(m, "\t%ld", hd->cmd_cnt[x]);
2251 strcat(bp, tbuf); 2241 seq_printf(m, "\ndisconnects allowed:");
2252 } 2242 for (x = 0; x < 7; x++)
2253 strcat(bp, "\ndisconnects allowed:"); 2243 seq_printf(m, "\t%ld", hd->disc_allowed_cnt[x]);
2254 for (x = 0; x < 7; x++) { 2244 seq_printf(m, "\ndisconnects done: ");
2255 sprintf(tbuf, "\t%ld", hd->disc_allowed_cnt[x]); 2245 for (x = 0; x < 7; x++)
2256 strcat(bp, tbuf); 2246 seq_printf(m, "\t%ld", hd->disc_done_cnt[x]);
2257 } 2247 seq_printf(m, "\ninterrupts: \t%ld", hd->int_cnt);
2258 strcat(bp, "\ndisconnects done: ");
2259 for (x = 0; x < 7; x++) {
2260 sprintf(tbuf, "\t%ld", hd->disc_done_cnt[x]);
2261 strcat(bp, tbuf);
2262 }
2263 sprintf(tbuf, "\ninterrupts: \t%ld", hd->int_cnt);
2264 strcat(bp, tbuf);
2265 } 2248 }
2266#endif 2249#endif
2267 if (hd->proc & PR_CONNECTED) { 2250 if (hd->proc & PR_CONNECTED) {
2268 strcat(bp, "\nconnected: "); 2251 seq_printf(m, "\nconnected: ");
2269 if (hd->connected) { 2252 if (hd->connected) {
2270 cmd = (Scsi_Cmnd *) hd->connected; 2253 cmd = (Scsi_Cmnd *) hd->connected;
2271 sprintf(tbuf, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); 2254 seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2272 strcat(bp, tbuf);
2273 } 2255 }
2274 } 2256 }
2275 if (hd->proc & PR_INPUTQ) { 2257 if (hd->proc & PR_INPUTQ) {
2276 strcat(bp, "\ninput_Q: "); 2258 seq_printf(m, "\ninput_Q: ");
2277 cmd = (Scsi_Cmnd *) hd->input_Q; 2259 cmd = (Scsi_Cmnd *) hd->input_Q;
2278 while (cmd) { 2260 while (cmd) {
2279 sprintf(tbuf, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); 2261 seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2280 strcat(bp, tbuf);
2281 cmd = (Scsi_Cmnd *) cmd->host_scribble; 2262 cmd = (Scsi_Cmnd *) cmd->host_scribble;
2282 } 2263 }
2283 } 2264 }
2284 if (hd->proc & PR_DISCQ) { 2265 if (hd->proc & PR_DISCQ) {
2285 strcat(bp, "\ndisconnected_Q:"); 2266 seq_printf(m, "\ndisconnected_Q:");
2286 cmd = (Scsi_Cmnd *) hd->disconnected_Q; 2267 cmd = (Scsi_Cmnd *) hd->disconnected_Q;
2287 while (cmd) { 2268 while (cmd) {
2288 sprintf(tbuf, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); 2269 seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2289 strcat(bp, tbuf);
2290 cmd = (Scsi_Cmnd *) cmd->host_scribble; 2270 cmd = (Scsi_Cmnd *) cmd->host_scribble;
2291 } 2271 }
2292 } 2272 }
2293 if (hd->proc & PR_TEST) { 2273 if (hd->proc & PR_TEST) {
2294 ; /* insert your own custom function here */ 2274 ; /* insert your own custom function here */
2295 } 2275 }
2296 strcat(bp, "\n"); 2276 seq_printf(m, "\n");
2297 spin_unlock_irqrestore(instance->host_lock, flags); 2277 spin_unlock_irqrestore(instance->host_lock, flags);
2298 *start = buf;
2299 if (stop) {
2300 stop = 0;
2301 return 0; /* return 0 to signal end-of-file */
2302 }
2303 if (off > 0x40000) /* ALWAYS stop after 256k bytes have been read */
2304 stop = 1;
2305 if (hd->proc & PR_STOP) /* stop every other time */
2306 stop = 1;
2307 return strlen(bp);
2308
2309#else /* PROC_INTERFACE */
2310
2311 return 0;
2312
2313#endif /* PROC_INTERFACE */ 2278#endif /* PROC_INTERFACE */
2314 2279 return 0;
2315} 2280}
2316 2281
2317MODULE_LICENSE("GPL"); 2282MODULE_LICENSE("GPL");
@@ -2319,7 +2284,8 @@ MODULE_LICENSE("GPL");
2319 2284
2320static struct scsi_host_template driver_template = { 2285static struct scsi_host_template driver_template = {
2321 .proc_name = "in2000", 2286 .proc_name = "in2000",
2322 .proc_info = in2000_proc_info, 2287 .write_info = in2000_write_info,
2288 .show_info = in2000_show_info,
2323 .name = "Always IN2000", 2289 .name = "Always IN2000",
2324 .detect = in2000_detect, 2290 .detect = in2000_detect,
2325 .release = in2000_release, 2291 .release = in2000_release,
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 9aa86a315a08..8d5ea8a1e5a6 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -326,10 +326,9 @@ static void ips_scmd_buf_write(struct scsi_cmnd * scmd, void *data,
326static void ips_scmd_buf_read(struct scsi_cmnd * scmd, void *data, 326static void ips_scmd_buf_read(struct scsi_cmnd * scmd, void *data,
327 unsigned int count); 327 unsigned int count);
328 328
329static int ips_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int); 329static int ips_write_info(struct Scsi_Host *, char *, int);
330static int ips_host_info(ips_ha_t *, char *, off_t, int); 330static int ips_show_info(struct seq_file *, struct Scsi_Host *);
331static void copy_mem_info(IPS_INFOSTR *, char *, int); 331static int ips_host_info(ips_ha_t *, struct seq_file *);
332static int copy_info(IPS_INFOSTR *, char *, ...);
333static int ips_abort_init(ips_ha_t * ha, int index); 332static int ips_abort_init(ips_ha_t * ha, int index);
334static int ips_init_phase2(int index); 333static int ips_init_phase2(int index);
335 334
@@ -367,7 +366,8 @@ static struct scsi_host_template ips_driver_template = {
367 .eh_abort_handler = ips_eh_abort, 366 .eh_abort_handler = ips_eh_abort,
368 .eh_host_reset_handler = ips_eh_reset, 367 .eh_host_reset_handler = ips_eh_reset,
369 .proc_name = "ips", 368 .proc_name = "ips",
370 .proc_info = ips_proc_info, 369 .show_info = ips_show_info,
370 .write_info = ips_write_info,
371 .slave_configure = ips_slave_configure, 371 .slave_configure = ips_slave_configure,
372 .bios_param = ips_biosparam, 372 .bios_param = ips_biosparam,
373 .this_id = -1, 373 .this_id = -1,
@@ -1433,25 +1433,12 @@ ips_info(struct Scsi_Host *SH)
1433 return (bp); 1433 return (bp);
1434} 1434}
1435 1435
1436/****************************************************************************/
1437/* */
1438/* Routine Name: ips_proc_info */
1439/* */
1440/* Routine Description: */
1441/* */
1442/* The passthru interface for the driver */
1443/* */
1444/****************************************************************************/
1445static int 1436static int
1446ips_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, 1437ips_write_info(struct Scsi_Host *host, char *buffer, int length)
1447 int length, int func)
1448{ 1438{
1449 int i; 1439 int i;
1450 int ret;
1451 ips_ha_t *ha = NULL; 1440 ips_ha_t *ha = NULL;
1452 1441
1453 METHOD_TRACE("ips_proc_info", 1);
1454
1455 /* Find our host structure */ 1442 /* Find our host structure */
1456 for (i = 0; i < ips_next_controller; i++) { 1443 for (i = 0; i < ips_next_controller; i++) {
1457 if (ips_sh[i]) { 1444 if (ips_sh[i]) {
@@ -1465,18 +1452,29 @@ ips_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
1465 if (!ha) 1452 if (!ha)
1466 return (-EINVAL); 1453 return (-EINVAL);
1467 1454
1468 if (func) { 1455 return 0;
1469 /* write */ 1456}
1470 return (0);
1471 } else {
1472 /* read */
1473 if (start)
1474 *start = buffer;
1475 1457
1476 ret = ips_host_info(ha, buffer, offset, length); 1458static int
1459ips_show_info(struct seq_file *m, struct Scsi_Host *host)
1460{
1461 int i;
1462 ips_ha_t *ha = NULL;
1477 1463
1478 return (ret); 1464 /* Find our host structure */
1465 for (i = 0; i < ips_next_controller; i++) {
1466 if (ips_sh[i]) {
1467 if (ips_sh[i] == host) {
1468 ha = (ips_ha_t *) ips_sh[i]->hostdata;
1469 break;
1470 }
1471 }
1479 } 1472 }
1473
1474 if (!ha)
1475 return (-EINVAL);
1476
1477 return ips_host_info(ha, m);
1480} 1478}
1481 1479
1482/*--------------------------------------------------------------------------*/ 1480/*--------------------------------------------------------------------------*/
@@ -2035,183 +2033,113 @@ ips_cleanup_passthru(ips_ha_t * ha, ips_scb_t * scb)
2035/* */ 2033/* */
2036/****************************************************************************/ 2034/****************************************************************************/
2037static int 2035static int
2038ips_host_info(ips_ha_t * ha, char *ptr, off_t offset, int len) 2036ips_host_info(ips_ha_t *ha, struct seq_file *m)
2039{ 2037{
2040 IPS_INFOSTR info;
2041
2042 METHOD_TRACE("ips_host_info", 1); 2038 METHOD_TRACE("ips_host_info", 1);
2043 2039
2044 info.buffer = ptr; 2040 seq_printf(m, "\nIBM ServeRAID General Information:\n\n");
2045 info.length = len;
2046 info.offset = offset;
2047 info.pos = 0;
2048 info.localpos = 0;
2049
2050 copy_info(&info, "\nIBM ServeRAID General Information:\n\n");
2051 2041
2052 if ((le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) && 2042 if ((le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) &&
2053 (le16_to_cpu(ha->nvram->adapter_type) != 0)) 2043 (le16_to_cpu(ha->nvram->adapter_type) != 0))
2054 copy_info(&info, "\tController Type : %s\n", 2044 seq_printf(m, "\tController Type : %s\n",
2055 ips_adapter_name[ha->ad_type - 1]); 2045 ips_adapter_name[ha->ad_type - 1]);
2056 else 2046 else
2057 copy_info(&info, 2047 seq_printf(m,
2058 "\tController Type : Unknown\n"); 2048 "\tController Type : Unknown\n");
2059 2049
2060 if (ha->io_addr) 2050 if (ha->io_addr)
2061 copy_info(&info, 2051 seq_printf(m,
2062 "\tIO region : 0x%lx (%d bytes)\n", 2052 "\tIO region : 0x%x (%d bytes)\n",
2063 ha->io_addr, ha->io_len); 2053 ha->io_addr, ha->io_len);
2064 2054
2065 if (ha->mem_addr) { 2055 if (ha->mem_addr) {
2066 copy_info(&info, 2056 seq_printf(m,
2067 "\tMemory region : 0x%lx (%d bytes)\n", 2057 "\tMemory region : 0x%x (%d bytes)\n",
2068 ha->mem_addr, ha->mem_len); 2058 ha->mem_addr, ha->mem_len);
2069 copy_info(&info, 2059 seq_printf(m,
2070 "\tShared memory address : 0x%lx\n", 2060 "\tShared memory address : 0x%lx\n",
2071 ha->mem_ptr); 2061 (unsigned long)ha->mem_ptr);
2072 } 2062 }
2073 2063
2074 copy_info(&info, "\tIRQ number : %d\n", ha->pcidev->irq); 2064 seq_printf(m, "\tIRQ number : %d\n", ha->pcidev->irq);
2075 2065
2076 /* For the Next 3 lines Check for Binary 0 at the end and don't include it if it's there. */ 2066 /* For the Next 3 lines Check for Binary 0 at the end and don't include it if it's there. */
2077 /* That keeps everything happy for "text" operations on the proc file. */ 2067 /* That keeps everything happy for "text" operations on the proc file. */
2078 2068
2079 if (le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) { 2069 if (le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) {
2080 if (ha->nvram->bios_low[3] == 0) { 2070 if (ha->nvram->bios_low[3] == 0) {
2081 copy_info(&info, 2071 seq_printf(m,
2082 "\tBIOS Version : %c%c%c%c%c%c%c\n", 2072 "\tBIOS Version : %c%c%c%c%c%c%c\n",
2083 ha->nvram->bios_high[0], ha->nvram->bios_high[1], 2073 ha->nvram->bios_high[0], ha->nvram->bios_high[1],
2084 ha->nvram->bios_high[2], ha->nvram->bios_high[3], 2074 ha->nvram->bios_high[2], ha->nvram->bios_high[3],
2085 ha->nvram->bios_low[0], ha->nvram->bios_low[1], 2075 ha->nvram->bios_low[0], ha->nvram->bios_low[1],
2086 ha->nvram->bios_low[2]); 2076 ha->nvram->bios_low[2]);
2087 2077
2088 } else { 2078 } else {
2089 copy_info(&info, 2079 seq_printf(m,
2090 "\tBIOS Version : %c%c%c%c%c%c%c%c\n", 2080 "\tBIOS Version : %c%c%c%c%c%c%c%c\n",
2091 ha->nvram->bios_high[0], ha->nvram->bios_high[1], 2081 ha->nvram->bios_high[0], ha->nvram->bios_high[1],
2092 ha->nvram->bios_high[2], ha->nvram->bios_high[3], 2082 ha->nvram->bios_high[2], ha->nvram->bios_high[3],
2093 ha->nvram->bios_low[0], ha->nvram->bios_low[1], 2083 ha->nvram->bios_low[0], ha->nvram->bios_low[1],
2094 ha->nvram->bios_low[2], ha->nvram->bios_low[3]); 2084 ha->nvram->bios_low[2], ha->nvram->bios_low[3]);
2095 } 2085 }
2096 2086
2097 } 2087 }
2098 2088
2099 if (ha->enq->CodeBlkVersion[7] == 0) { 2089 if (ha->enq->CodeBlkVersion[7] == 0) {
2100 copy_info(&info, 2090 seq_printf(m,
2101 "\tFirmware Version : %c%c%c%c%c%c%c\n", 2091 "\tFirmware Version : %c%c%c%c%c%c%c\n",
2102 ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1], 2092 ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1],
2103 ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3], 2093 ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3],
2104 ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5], 2094 ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5],
2105 ha->enq->CodeBlkVersion[6]); 2095 ha->enq->CodeBlkVersion[6]);
2106 } else { 2096 } else {
2107 copy_info(&info, 2097 seq_printf(m,
2108 "\tFirmware Version : %c%c%c%c%c%c%c%c\n", 2098 "\tFirmware Version : %c%c%c%c%c%c%c%c\n",
2109 ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1], 2099 ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1],
2110 ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3], 2100 ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3],
2111 ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5], 2101 ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5],
2112 ha->enq->CodeBlkVersion[6], ha->enq->CodeBlkVersion[7]); 2102 ha->enq->CodeBlkVersion[6], ha->enq->CodeBlkVersion[7]);
2113 } 2103 }
2114 2104
2115 if (ha->enq->BootBlkVersion[7] == 0) { 2105 if (ha->enq->BootBlkVersion[7] == 0) {
2116 copy_info(&info, 2106 seq_printf(m,
2117 "\tBoot Block Version : %c%c%c%c%c%c%c\n", 2107 "\tBoot Block Version : %c%c%c%c%c%c%c\n",
2118 ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1], 2108 ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1],
2119 ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3], 2109 ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3],
2120 ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5], 2110 ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5],
2121 ha->enq->BootBlkVersion[6]); 2111 ha->enq->BootBlkVersion[6]);
2122 } else { 2112 } else {
2123 copy_info(&info, 2113 seq_printf(m,
2124 "\tBoot Block Version : %c%c%c%c%c%c%c%c\n", 2114 "\tBoot Block Version : %c%c%c%c%c%c%c%c\n",
2125 ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1], 2115 ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1],
2126 ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3], 2116 ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3],
2127 ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5], 2117 ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5],
2128 ha->enq->BootBlkVersion[6], ha->enq->BootBlkVersion[7]); 2118 ha->enq->BootBlkVersion[6], ha->enq->BootBlkVersion[7]);
2129 } 2119 }
2130 2120
2131 copy_info(&info, "\tDriver Version : %s%s\n", 2121 seq_printf(m, "\tDriver Version : %s%s\n",
2132 IPS_VERSION_HIGH, IPS_VERSION_LOW); 2122 IPS_VERSION_HIGH, IPS_VERSION_LOW);
2133 2123
2134 copy_info(&info, "\tDriver Build : %d\n", 2124 seq_printf(m, "\tDriver Build : %d\n",
2135 IPS_BUILD_IDENT); 2125 IPS_BUILD_IDENT);
2136 2126
2137 copy_info(&info, "\tMax Physical Devices : %d\n", 2127 seq_printf(m, "\tMax Physical Devices : %d\n",
2138 ha->enq->ucMaxPhysicalDevices); 2128 ha->enq->ucMaxPhysicalDevices);
2139 copy_info(&info, "\tMax Active Commands : %d\n", 2129 seq_printf(m, "\tMax Active Commands : %d\n",
2140 ha->max_cmds); 2130 ha->max_cmds);
2141 copy_info(&info, "\tCurrent Queued Commands : %d\n", 2131 seq_printf(m, "\tCurrent Queued Commands : %d\n",
2142 ha->scb_waitlist.count); 2132 ha->scb_waitlist.count);
2143 copy_info(&info, "\tCurrent Active Commands : %d\n", 2133 seq_printf(m, "\tCurrent Active Commands : %d\n",
2144 ha->scb_activelist.count - ha->num_ioctl); 2134 ha->scb_activelist.count - ha->num_ioctl);
2145 copy_info(&info, "\tCurrent Queued PT Commands : %d\n", 2135 seq_printf(m, "\tCurrent Queued PT Commands : %d\n",
2146 ha->copp_waitlist.count); 2136 ha->copp_waitlist.count);
2147 copy_info(&info, "\tCurrent Active PT Commands : %d\n", 2137 seq_printf(m, "\tCurrent Active PT Commands : %d\n",
2148 ha->num_ioctl); 2138 ha->num_ioctl);
2149 2139
2150 copy_info(&info, "\n"); 2140 seq_printf(m, "\n");
2151
2152 return (info.localpos);
2153}
2154
2155/****************************************************************************/
2156/* */
2157/* Routine Name: copy_mem_info */
2158/* */
2159/* Routine Description: */
2160/* */
2161/* Copy data into an IPS_INFOSTR structure */
2162/* */
2163/****************************************************************************/
2164static void
2165copy_mem_info(IPS_INFOSTR * info, char *data, int len)
2166{
2167 METHOD_TRACE("copy_mem_info", 1);
2168
2169 if (info->pos + len < info->offset) {
2170 info->pos += len;
2171 return;
2172 }
2173
2174 if (info->pos < info->offset) {
2175 data += (info->offset - info->pos);
2176 len -= (info->offset - info->pos);
2177 info->pos += (info->offset - info->pos);
2178 }
2179
2180 if (info->localpos + len > info->length)
2181 len = info->length - info->localpos;
2182 2141
2183 if (len > 0) { 2142 return 0;
2184 memcpy(info->buffer + info->localpos, data, len);
2185 info->pos += len;
2186 info->localpos += len;
2187 }
2188}
2189
2190/****************************************************************************/
2191/* */
2192/* Routine Name: copy_info */
2193/* */
2194/* Routine Description: */
2195/* */
2196/* printf style wrapper for an info structure */
2197/* */
2198/****************************************************************************/
2199static int
2200copy_info(IPS_INFOSTR * info, char *fmt, ...)
2201{
2202 va_list args;
2203 char buf[128];
2204 int len;
2205
2206 METHOD_TRACE("copy_info", 1);
2207
2208 va_start(args, fmt);
2209 len = vsprintf(buf, fmt, args);
2210 va_end(args);
2211
2212 copy_mem_info(info, buf, len);
2213
2214 return (len);
2215} 2143}
2216 2144
2217/****************************************************************************/ 2145/****************************************************************************/
diff --git a/drivers/scsi/ips.h b/drivers/scsi/ips.h
index f2df0593332b..45b9566b928e 100644
--- a/drivers/scsi/ips.h
+++ b/drivers/scsi/ips.h
@@ -416,7 +416,6 @@
416 /* 416 /*
417 * Scsi_Host Template 417 * Scsi_Host Template
418 */ 418 */
419 static int ips_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int);
420 static int ips_biosparam(struct scsi_device *sdev, struct block_device *bdev, 419 static int ips_biosparam(struct scsi_device *sdev, struct block_device *bdev,
421 sector_t capacity, int geom[]); 420 sector_t capacity, int geom[]);
422 static int ips_slave_configure(struct scsi_device *SDptr); 421 static int ips_slave_configure(struct scsi_device *SDptr);
@@ -959,14 +958,6 @@ typedef union {
959 IPS_ENH_SG_LIST *enh_list; 958 IPS_ENH_SG_LIST *enh_list;
960} IPS_SG_LIST; 959} IPS_SG_LIST;
961 960
962typedef struct _IPS_INFOSTR {
963 char *buffer;
964 int length;
965 int offset;
966 int pos;
967 int localpos;
968} IPS_INFOSTR;
969
970typedef struct { 961typedef struct {
971 char *option_name; 962 char *option_name;
972 int *option_flag; 963 int *option_flag;
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 5da297290262..90b8b0515e23 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -10394,36 +10394,6 @@ lpfc_io_resume(struct pci_dev *pdev)
10394 return; 10394 return;
10395} 10395}
10396 10396
10397/**
10398 * lpfc_mgmt_open - method called when 'lpfcmgmt' is opened from userspace
10399 * @inode: pointer to the inode representing the lpfcmgmt device
10400 * @filep: pointer to the file representing the open lpfcmgmt device
10401 *
10402 * This routine puts a reference count on the lpfc module whenever the
10403 * character device is opened
10404 **/
10405static int
10406lpfc_mgmt_open(struct inode *inode, struct file *filep)
10407{
10408 try_module_get(THIS_MODULE);
10409 return 0;
10410}
10411
10412/**
10413 * lpfc_mgmt_release - method called when 'lpfcmgmt' is closed in userspace
10414 * @inode: pointer to the inode representing the lpfcmgmt device
10415 * @filep: pointer to the file representing the open lpfcmgmt device
10416 *
10417 * This routine removes a reference count from the lpfc module when the
10418 * character device is closed
10419 **/
10420static int
10421lpfc_mgmt_release(struct inode *inode, struct file *filep)
10422{
10423 module_put(THIS_MODULE);
10424 return 0;
10425}
10426
10427static struct pci_device_id lpfc_id_table[] = { 10397static struct pci_device_id lpfc_id_table[] = {
10428 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_VIPER, 10398 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_VIPER,
10429 PCI_ANY_ID, PCI_ANY_ID, }, 10399 PCI_ANY_ID, PCI_ANY_ID, },
@@ -10541,8 +10511,7 @@ static struct pci_driver lpfc_driver = {
10541}; 10511};
10542 10512
10543static const struct file_operations lpfc_mgmt_fop = { 10513static const struct file_operations lpfc_mgmt_fop = {
10544 .open = lpfc_mgmt_open, 10514 .owner = THIS_MODULE,
10545 .release = lpfc_mgmt_release,
10546}; 10515};
10547 10516
10548static struct miscdevice lpfc_mgmt_dev = { 10517static struct miscdevice lpfc_mgmt_dev = {
diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c
index 24828b54773a..858075723c87 100644
--- a/drivers/scsi/mac_scsi.c
+++ b/drivers/scsi/mac_scsi.c
@@ -561,7 +561,8 @@ static int macscsi_pwrite (struct Scsi_Host *instance,
561 561
562static struct scsi_host_template driver_template = { 562static struct scsi_host_template driver_template = {
563 .proc_name = "Mac5380", 563 .proc_name = "Mac5380",
564 .proc_info = macscsi_proc_info, 564 .show_info = macscsi_show_info,
565 .write_info = macscsi_write_info,
565 .name = "Macintosh NCR5380 SCSI", 566 .name = "Macintosh NCR5380 SCSI",
566 .detect = macscsi_detect, 567 .detect = macscsi_detect,
567 .release = macscsi_release, 568 .release = macscsi_release,
diff --git a/drivers/scsi/mac_scsi.h b/drivers/scsi/mac_scsi.h
index d26e331c6c12..7dc62fce1c4c 100644
--- a/drivers/scsi/mac_scsi.h
+++ b/drivers/scsi/mac_scsi.h
@@ -72,7 +72,8 @@
72#define NCR5380_queue_command macscsi_queue_command 72#define NCR5380_queue_command macscsi_queue_command
73#define NCR5380_abort macscsi_abort 73#define NCR5380_abort macscsi_abort
74#define NCR5380_bus_reset macscsi_bus_reset 74#define NCR5380_bus_reset macscsi_bus_reset
75#define NCR5380_proc_info macscsi_proc_info 75#define NCR5380_show_info macscsi_show_info
76#define NCR5380_write_info macscsi_write_info
76 77
77#define BOARD_NORMAL 0 78#define BOARD_NORMAL 0
78#define BOARD_NCR53C400 1 79#define BOARD_NCR53C400 1
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 9504ec0ec682..7373255aa1e8 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -39,6 +39,7 @@
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/proc_fs.h> 41#include <linux/proc_fs.h>
42#include <linux/seq_file.h>
42#include <linux/reboot.h> 43#include <linux/reboot.h>
43#include <linux/module.h> 44#include <linux/module.h>
44#include <linux/list.h> 45#include <linux/list.h>
@@ -2069,385 +2070,201 @@ mega_free_inquiry(void *inquiry, dma_addr_t dma_handle, struct pci_dev *pdev)
2069#ifdef CONFIG_PROC_FS 2070#ifdef CONFIG_PROC_FS
2070/* Following code handles /proc fs */ 2071/* Following code handles /proc fs */
2071 2072
2072#define CREATE_READ_PROC(string, func) create_proc_read_entry(string, \
2073 S_IRUSR | S_IFREG, \
2074 controller_proc_dir_entry, \
2075 func, adapter)
2076
2077/**
2078 * mega_create_proc_entry()
2079 * @index - index in soft state array
2080 * @parent - parent node for this /proc entry
2081 *
2082 * Creates /proc entries for our controllers.
2083 */
2084static void
2085mega_create_proc_entry(int index, struct proc_dir_entry *parent)
2086{
2087 struct proc_dir_entry *controller_proc_dir_entry = NULL;
2088 u8 string[64] = { 0 };
2089 adapter_t *adapter = hba_soft_state[index];
2090
2091 sprintf(string, "hba%d", adapter->host->host_no);
2092
2093 controller_proc_dir_entry =
2094 adapter->controller_proc_dir_entry = proc_mkdir(string, parent);
2095
2096 if(!controller_proc_dir_entry) {
2097 printk(KERN_WARNING "\nmegaraid: proc_mkdir failed\n");
2098 return;
2099 }
2100 adapter->proc_read = CREATE_READ_PROC("config", proc_read_config);
2101 adapter->proc_stat = CREATE_READ_PROC("stat", proc_read_stat);
2102 adapter->proc_mbox = CREATE_READ_PROC("mailbox", proc_read_mbox);
2103#if MEGA_HAVE_ENH_PROC
2104 adapter->proc_rr = CREATE_READ_PROC("rebuild-rate", proc_rebuild_rate);
2105 adapter->proc_battery = CREATE_READ_PROC("battery-status",
2106 proc_battery);
2107
2108 /*
2109 * Display each physical drive on its channel
2110 */
2111 adapter->proc_pdrvstat[0] = CREATE_READ_PROC("diskdrives-ch0",
2112 proc_pdrv_ch0);
2113 adapter->proc_pdrvstat[1] = CREATE_READ_PROC("diskdrives-ch1",
2114 proc_pdrv_ch1);
2115 adapter->proc_pdrvstat[2] = CREATE_READ_PROC("diskdrives-ch2",
2116 proc_pdrv_ch2);
2117 adapter->proc_pdrvstat[3] = CREATE_READ_PROC("diskdrives-ch3",
2118 proc_pdrv_ch3);
2119
2120 /*
2121 * Display a set of up to 10 logical drive through each of following
2122 * /proc entries
2123 */
2124 adapter->proc_rdrvstat[0] = CREATE_READ_PROC("raiddrives-0-9",
2125 proc_rdrv_10);
2126 adapter->proc_rdrvstat[1] = CREATE_READ_PROC("raiddrives-10-19",
2127 proc_rdrv_20);
2128 adapter->proc_rdrvstat[2] = CREATE_READ_PROC("raiddrives-20-29",
2129 proc_rdrv_30);
2130 adapter->proc_rdrvstat[3] = CREATE_READ_PROC("raiddrives-30-39",
2131 proc_rdrv_40);
2132#endif
2133}
2134
2135
2136/** 2073/**
2137 * proc_read_config() 2074 * proc_show_config()
2138 * @page - buffer to write the data in 2075 * @m - Synthetic file construction data
2139 * @start - where the actual data has been written in page 2076 * @v - File iterator
2140 * @offset - same meaning as the read system call
2141 * @count - same meaning as the read system call
2142 * @eof - set if no more data needs to be returned
2143 * @data - pointer to our soft state
2144 * 2077 *
2145 * Display configuration information about the controller. 2078 * Display configuration information about the controller.
2146 */ 2079 */
2147static int 2080static int
2148proc_read_config(char *page, char **start, off_t offset, int count, int *eof, 2081proc_show_config(struct seq_file *m, void *v)
2149 void *data)
2150{ 2082{
2151 2083
2152 adapter_t *adapter = (adapter_t *)data; 2084 adapter_t *adapter = m->private;
2153 int len = 0;
2154
2155 len += sprintf(page+len, "%s", MEGARAID_VERSION);
2156 2085
2086 seq_puts(m, MEGARAID_VERSION);
2157 if(adapter->product_info.product_name[0]) 2087 if(adapter->product_info.product_name[0])
2158 len += sprintf(page+len, "%s\n", 2088 seq_printf(m, "%s\n", adapter->product_info.product_name);
2159 adapter->product_info.product_name);
2160
2161 len += sprintf(page+len, "Controller Type: ");
2162 2089
2163 if( adapter->flag & BOARD_MEMMAP ) { 2090 seq_puts(m, "Controller Type: ");
2164 len += sprintf(page+len,
2165 "438/466/467/471/493/518/520/531/532\n");
2166 }
2167 else {
2168 len += sprintf(page+len,
2169 "418/428/434\n");
2170 }
2171 2091
2172 if(adapter->flag & BOARD_40LD) { 2092 if( adapter->flag & BOARD_MEMMAP )
2173 len += sprintf(page+len, 2093 seq_puts(m, "438/466/467/471/493/518/520/531/532\n");
2174 "Controller Supports 40 Logical Drives\n"); 2094 else
2175 } 2095 seq_puts(m, "418/428/434\n");
2176 2096
2177 if(adapter->flag & BOARD_64BIT) { 2097 if(adapter->flag & BOARD_40LD)
2178 len += sprintf(page+len, 2098 seq_puts(m, "Controller Supports 40 Logical Drives\n");
2179 "Controller capable of 64-bit memory addressing\n");
2180 }
2181 if( adapter->has_64bit_addr ) {
2182 len += sprintf(page+len,
2183 "Controller using 64-bit memory addressing\n");
2184 }
2185 else {
2186 len += sprintf(page+len,
2187 "Controller is not using 64-bit memory addressing\n");
2188 }
2189 2099
2190 len += sprintf(page+len, "Base = %08lx, Irq = %d, ", adapter->base, 2100 if(adapter->flag & BOARD_64BIT)
2191 adapter->host->irq); 2101 seq_puts(m, "Controller capable of 64-bit memory addressing\n");
2192 2102 if( adapter->has_64bit_addr )
2193 len += sprintf(page+len, "Logical Drives = %d, Channels = %d\n", 2103 seq_puts(m, "Controller using 64-bit memory addressing\n");
2194 adapter->numldrv, adapter->product_info.nchannels); 2104 else
2195 2105 seq_puts(m, "Controller is not using 64-bit memory addressing\n");
2196 len += sprintf(page+len, "Version =%s:%s, DRAM = %dMb\n", 2106
2197 adapter->fw_version, adapter->bios_version, 2107 seq_printf(m, "Base = %08lx, Irq = %d, ",
2198 adapter->product_info.dram_size); 2108 adapter->base, adapter->host->irq);
2199 2109
2200 len += sprintf(page+len, 2110 seq_printf(m, "Logical Drives = %d, Channels = %d\n",
2201 "Controller Queue Depth = %d, Driver Queue Depth = %d\n", 2111 adapter->numldrv, adapter->product_info.nchannels);
2202 adapter->product_info.max_commands, adapter->max_cmds); 2112
2203 2113 seq_printf(m, "Version =%s:%s, DRAM = %dMb\n",
2204 len += sprintf(page+len, "support_ext_cdb = %d\n", 2114 adapter->fw_version, adapter->bios_version,
2205 adapter->support_ext_cdb); 2115 adapter->product_info.dram_size);
2206 len += sprintf(page+len, "support_random_del = %d\n", 2116
2207 adapter->support_random_del); 2117 seq_printf(m, "Controller Queue Depth = %d, Driver Queue Depth = %d\n",
2208 len += sprintf(page+len, "boot_ldrv_enabled = %d\n", 2118 adapter->product_info.max_commands, adapter->max_cmds);
2209 adapter->boot_ldrv_enabled); 2119
2210 len += sprintf(page+len, "boot_ldrv = %d\n", 2120 seq_printf(m, "support_ext_cdb = %d\n", adapter->support_ext_cdb);
2211 adapter->boot_ldrv); 2121 seq_printf(m, "support_random_del = %d\n", adapter->support_random_del);
2212 len += sprintf(page+len, "boot_pdrv_enabled = %d\n", 2122 seq_printf(m, "boot_ldrv_enabled = %d\n", adapter->boot_ldrv_enabled);
2213 adapter->boot_pdrv_enabled); 2123 seq_printf(m, "boot_ldrv = %d\n", adapter->boot_ldrv);
2214 len += sprintf(page+len, "boot_pdrv_ch = %d\n", 2124 seq_printf(m, "boot_pdrv_enabled = %d\n", adapter->boot_pdrv_enabled);
2215 adapter->boot_pdrv_ch); 2125 seq_printf(m, "boot_pdrv_ch = %d\n", adapter->boot_pdrv_ch);
2216 len += sprintf(page+len, "boot_pdrv_tgt = %d\n", 2126 seq_printf(m, "boot_pdrv_tgt = %d\n", adapter->boot_pdrv_tgt);
2217 adapter->boot_pdrv_tgt); 2127 seq_printf(m, "quiescent = %d\n",
2218 len += sprintf(page+len, "quiescent = %d\n", 2128 atomic_read(&adapter->quiescent));
2219 atomic_read(&adapter->quiescent)); 2129 seq_printf(m, "has_cluster = %d\n", adapter->has_cluster);
2220 len += sprintf(page+len, "has_cluster = %d\n", 2130
2221 adapter->has_cluster); 2131 seq_puts(m, "\nModule Parameters:\n");
2222 2132 seq_printf(m, "max_cmd_per_lun = %d\n", max_cmd_per_lun);
2223 len += sprintf(page+len, "\nModule Parameters:\n"); 2133 seq_printf(m, "max_sectors_per_io = %d\n", max_sectors_per_io);
2224 len += sprintf(page+len, "max_cmd_per_lun = %d\n", 2134 return 0;
2225 max_cmd_per_lun);
2226 len += sprintf(page+len, "max_sectors_per_io = %d\n",
2227 max_sectors_per_io);
2228
2229 *eof = 1;
2230
2231 return len;
2232} 2135}
2233 2136
2234
2235
2236/** 2137/**
2237 * proc_read_stat() 2138 * proc_show_stat()
2238 * @page - buffer to write the data in 2139 * @m - Synthetic file construction data
2239 * @start - where the actual data has been written in page 2140 * @v - File iterator
2240 * @offset - same meaning as the read system call
2241 * @count - same meaning as the read system call
2242 * @eof - set if no more data needs to be returned
2243 * @data - pointer to our soft state
2244 * 2141 *
2245 * Diaplay statistical information about the I/O activity. 2142 * Display statistical information about the I/O activity.
2246 */ 2143 */
2247static int 2144static int
2248proc_read_stat(char *page, char **start, off_t offset, int count, int *eof, 2145proc_show_stat(struct seq_file *m, void *v)
2249 void *data)
2250{ 2146{
2251 adapter_t *adapter; 2147 adapter_t *adapter = m->private;
2252 int len; 2148#if MEGA_HAVE_STATS
2253 int i; 2149 int i;
2150#endif
2254 2151
2255 i = 0; /* avoid compilation warnings */ 2152 seq_puts(m, "Statistical Information for this controller\n");
2256 len = 0; 2153 seq_printf(m, "pend_cmds = %d\n", atomic_read(&adapter->pend_cmds));
2257 adapter = (adapter_t *)data;
2258
2259 len = sprintf(page, "Statistical Information for this controller\n");
2260 len += sprintf(page+len, "pend_cmds = %d\n",
2261 atomic_read(&adapter->pend_cmds));
2262#if MEGA_HAVE_STATS 2154#if MEGA_HAVE_STATS
2263 for(i = 0; i < adapter->numldrv; i++) { 2155 for(i = 0; i < adapter->numldrv; i++) {
2264 len += sprintf(page+len, "Logical Drive %d:\n", i); 2156 seq_printf(m, "Logical Drive %d:\n", i);
2265 2157 seq_printf(m, "\tReads Issued = %lu, Writes Issued = %lu\n",
2266 len += sprintf(page+len, 2158 adapter->nreads[i], adapter->nwrites[i]);
2267 "\tReads Issued = %lu, Writes Issued = %lu\n", 2159 seq_printf(m, "\tSectors Read = %lu, Sectors Written = %lu\n",
2268 adapter->nreads[i], adapter->nwrites[i]); 2160 adapter->nreadblocks[i], adapter->nwriteblocks[i]);
2269 2161 seq_printf(m, "\tRead errors = %lu, Write errors = %lu\n\n",
2270 len += sprintf(page+len, 2162 adapter->rd_errors[i], adapter->wr_errors[i]);
2271 "\tSectors Read = %lu, Sectors Written = %lu\n",
2272 adapter->nreadblocks[i], adapter->nwriteblocks[i]);
2273
2274 len += sprintf(page+len,
2275 "\tRead errors = %lu, Write errors = %lu\n\n",
2276 adapter->rd_errors[i], adapter->wr_errors[i]);
2277 } 2163 }
2278#else 2164#else
2279 len += sprintf(page+len, 2165 seq_puts(m, "IO and error counters not compiled in driver.\n");
2280 "IO and error counters not compiled in driver.\n");
2281#endif 2166#endif
2282 2167 return 0;
2283 *eof = 1;
2284
2285 return len;
2286} 2168}
2287 2169
2288 2170
2289/** 2171/**
2290 * proc_read_mbox() 2172 * proc_show_mbox()
2291 * @page - buffer to write the data in 2173 * @m - Synthetic file construction data
2292 * @start - where the actual data has been written in page 2174 * @v - File iterator
2293 * @offset - same meaning as the read system call
2294 * @count - same meaning as the read system call
2295 * @eof - set if no more data needs to be returned
2296 * @data - pointer to our soft state
2297 * 2175 *
2298 * Display mailbox information for the last command issued. This information 2176 * Display mailbox information for the last command issued. This information
2299 * is good for debugging. 2177 * is good for debugging.
2300 */ 2178 */
2301static int 2179static int
2302proc_read_mbox(char *page, char **start, off_t offset, int count, int *eof, 2180proc_show_mbox(struct seq_file *m, void *v)
2303 void *data)
2304{ 2181{
2305 2182 adapter_t *adapter = m->private;
2306 adapter_t *adapter = (adapter_t *)data;
2307 volatile mbox_t *mbox = adapter->mbox; 2183 volatile mbox_t *mbox = adapter->mbox;
2308 int len = 0; 2184
2309 2185 seq_puts(m, "Contents of Mail Box Structure\n");
2310 len = sprintf(page, "Contents of Mail Box Structure\n"); 2186 seq_printf(m, " Fw Command = 0x%02x\n", mbox->m_out.cmd);
2311 len += sprintf(page+len, " Fw Command = 0x%02x\n", 2187 seq_printf(m, " Cmd Sequence = 0x%02x\n", mbox->m_out.cmdid);
2312 mbox->m_out.cmd); 2188 seq_printf(m, " No of Sectors= %04d\n", mbox->m_out.numsectors);
2313 len += sprintf(page+len, " Cmd Sequence = 0x%02x\n", 2189 seq_printf(m, " LBA = 0x%02x\n", mbox->m_out.lba);
2314 mbox->m_out.cmdid); 2190 seq_printf(m, " DTA = 0x%08x\n", mbox->m_out.xferaddr);
2315 len += sprintf(page+len, " No of Sectors= %04d\n", 2191 seq_printf(m, " Logical Drive= 0x%02x\n", mbox->m_out.logdrv);
2316 mbox->m_out.numsectors); 2192 seq_printf(m, " No of SG Elmt= 0x%02x\n", mbox->m_out.numsgelements);
2317 len += sprintf(page+len, " LBA = 0x%02x\n", 2193 seq_printf(m, " Busy = %01x\n", mbox->m_in.busy);
2318 mbox->m_out.lba); 2194 seq_printf(m, " Status = 0x%02x\n", mbox->m_in.status);
2319 len += sprintf(page+len, " DTA = 0x%08x\n", 2195 return 0;
2320 mbox->m_out.xferaddr);
2321 len += sprintf(page+len, " Logical Drive= 0x%02x\n",
2322 mbox->m_out.logdrv);
2323 len += sprintf(page+len, " No of SG Elmt= 0x%02x\n",
2324 mbox->m_out.numsgelements);
2325 len += sprintf(page+len, " Busy = %01x\n",
2326 mbox->m_in.busy);
2327 len += sprintf(page+len, " Status = 0x%02x\n",
2328 mbox->m_in.status);
2329
2330 *eof = 1;
2331
2332 return len;
2333} 2196}
2334 2197
2335 2198
2336/** 2199/**
2337 * proc_rebuild_rate() 2200 * proc_show_rebuild_rate()
2338 * @page - buffer to write the data in 2201 * @m - Synthetic file construction data
2339 * @start - where the actual data has been written in page 2202 * @v - File iterator
2340 * @offset - same meaning as the read system call
2341 * @count - same meaning as the read system call
2342 * @eof - set if no more data needs to be returned
2343 * @data - pointer to our soft state
2344 * 2203 *
2345 * Display current rebuild rate 2204 * Display current rebuild rate
2346 */ 2205 */
2347static int 2206static int
2348proc_rebuild_rate(char *page, char **start, off_t offset, int count, int *eof, 2207proc_show_rebuild_rate(struct seq_file *m, void *v)
2349 void *data)
2350{ 2208{
2351 adapter_t *adapter = (adapter_t *)data; 2209 adapter_t *adapter = m->private;
2352 dma_addr_t dma_handle; 2210 dma_addr_t dma_handle;
2353 caddr_t inquiry; 2211 caddr_t inquiry;
2354 struct pci_dev *pdev; 2212 struct pci_dev *pdev;
2355 int len = 0;
2356 2213
2357 if( make_local_pdev(adapter, &pdev) != 0 ) { 2214 if( make_local_pdev(adapter, &pdev) != 0 )
2358 *eof = 1; 2215 return 0;
2359 return len;
2360 }
2361 2216
2362 if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) { 2217 if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL )
2363 free_local_pdev(pdev); 2218 goto free_pdev;
2364 *eof = 1;
2365 return len;
2366 }
2367 2219
2368 if( mega_adapinq(adapter, dma_handle) != 0 ) { 2220 if( mega_adapinq(adapter, dma_handle) != 0 ) {
2369 2221 seq_puts(m, "Adapter inquiry failed.\n");
2370 len = sprintf(page, "Adapter inquiry failed.\n");
2371
2372 printk(KERN_WARNING "megaraid: inquiry failed.\n"); 2222 printk(KERN_WARNING "megaraid: inquiry failed.\n");
2373 2223 goto free_inquiry;
2374 mega_free_inquiry(inquiry, dma_handle, pdev);
2375
2376 free_local_pdev(pdev);
2377
2378 *eof = 1;
2379
2380 return len;
2381 } 2224 }
2382 2225
2383 if( adapter->flag & BOARD_40LD ) { 2226 if( adapter->flag & BOARD_40LD )
2384 len = sprintf(page, "Rebuild Rate: [%d%%]\n", 2227 seq_printf(m, "Rebuild Rate: [%d%%]\n",
2385 ((mega_inquiry3 *)inquiry)->rebuild_rate); 2228 ((mega_inquiry3 *)inquiry)->rebuild_rate);
2386 } 2229 else
2387 else { 2230 seq_printf(m, "Rebuild Rate: [%d%%]\n",
2388 len = sprintf(page, "Rebuild Rate: [%d%%]\n",
2389 ((mraid_ext_inquiry *) 2231 ((mraid_ext_inquiry *)
2390 inquiry)->raid_inq.adapter_info.rebuild_rate); 2232 inquiry)->raid_inq.adapter_info.rebuild_rate);
2391 }
2392
2393 2233
2234free_inquiry:
2394 mega_free_inquiry(inquiry, dma_handle, pdev); 2235 mega_free_inquiry(inquiry, dma_handle, pdev);
2395 2236free_pdev:
2396 free_local_pdev(pdev); 2237 free_local_pdev(pdev);
2397 2238 return 0;
2398 *eof = 1;
2399
2400 return len;
2401} 2239}
2402 2240
2403 2241
2404/** 2242/**
2405 * proc_battery() 2243 * proc_show_battery()
2406 * @page - buffer to write the data in 2244 * @m - Synthetic file construction data
2407 * @start - where the actual data has been written in page 2245 * @v - File iterator
2408 * @offset - same meaning as the read system call
2409 * @count - same meaning as the read system call
2410 * @eof - set if no more data needs to be returned
2411 * @data - pointer to our soft state
2412 * 2246 *
2413 * Display information about the battery module on the controller. 2247 * Display information about the battery module on the controller.
2414 */ 2248 */
2415static int 2249static int
2416proc_battery(char *page, char **start, off_t offset, int count, int *eof, 2250proc_show_battery(struct seq_file *m, void *v)
2417 void *data)
2418{ 2251{
2419 adapter_t *adapter = (adapter_t *)data; 2252 adapter_t *adapter = m->private;
2420 dma_addr_t dma_handle; 2253 dma_addr_t dma_handle;
2421 caddr_t inquiry; 2254 caddr_t inquiry;
2422 struct pci_dev *pdev; 2255 struct pci_dev *pdev;
2423 u8 battery_status = 0; 2256 u8 battery_status;
2424 char str[256];
2425 int len = 0;
2426 2257
2427 if( make_local_pdev(adapter, &pdev) != 0 ) { 2258 if( make_local_pdev(adapter, &pdev) != 0 )
2428 *eof = 1; 2259 return 0;
2429 return len;
2430 }
2431 2260
2432 if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) { 2261 if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL )
2433 free_local_pdev(pdev); 2262 goto free_pdev;
2434 *eof = 1;
2435 return len;
2436 }
2437 2263
2438 if( mega_adapinq(adapter, dma_handle) != 0 ) { 2264 if( mega_adapinq(adapter, dma_handle) != 0 ) {
2439 2265 seq_printf(m, "Adapter inquiry failed.\n");
2440 len = sprintf(page, "Adapter inquiry failed.\n");
2441
2442 printk(KERN_WARNING "megaraid: inquiry failed.\n"); 2266 printk(KERN_WARNING "megaraid: inquiry failed.\n");
2443 2267 goto free_inquiry;
2444 mega_free_inquiry(inquiry, dma_handle, pdev);
2445
2446 free_local_pdev(pdev);
2447
2448 *eof = 1;
2449
2450 return len;
2451 } 2268 }
2452 2269
2453 if( adapter->flag & BOARD_40LD ) { 2270 if( adapter->flag & BOARD_40LD ) {
@@ -2461,146 +2278,80 @@ proc_battery(char *page, char **start, off_t offset, int count, int *eof,
2461 /* 2278 /*
2462 * Decode the battery status 2279 * Decode the battery status
2463 */ 2280 */
2464 sprintf(str, "Battery Status:[%d]", battery_status); 2281 seq_printf(m, "Battery Status:[%d]", battery_status);
2465 2282
2466 if(battery_status == MEGA_BATT_CHARGE_DONE) 2283 if(battery_status == MEGA_BATT_CHARGE_DONE)
2467 strcat(str, " Charge Done"); 2284 seq_puts(m, " Charge Done");
2468 2285
2469 if(battery_status & MEGA_BATT_MODULE_MISSING) 2286 if(battery_status & MEGA_BATT_MODULE_MISSING)
2470 strcat(str, " Module Missing"); 2287 seq_puts(m, " Module Missing");
2471 2288
2472 if(battery_status & MEGA_BATT_LOW_VOLTAGE) 2289 if(battery_status & MEGA_BATT_LOW_VOLTAGE)
2473 strcat(str, " Low Voltage"); 2290 seq_puts(m, " Low Voltage");
2474 2291
2475 if(battery_status & MEGA_BATT_TEMP_HIGH) 2292 if(battery_status & MEGA_BATT_TEMP_HIGH)
2476 strcat(str, " Temperature High"); 2293 seq_puts(m, " Temperature High");
2477 2294
2478 if(battery_status & MEGA_BATT_PACK_MISSING) 2295 if(battery_status & MEGA_BATT_PACK_MISSING)
2479 strcat(str, " Pack Missing"); 2296 seq_puts(m, " Pack Missing");
2480 2297
2481 if(battery_status & MEGA_BATT_CHARGE_INPROG) 2298 if(battery_status & MEGA_BATT_CHARGE_INPROG)
2482 strcat(str, " Charge In-progress"); 2299 seq_puts(m, " Charge In-progress");
2483 2300
2484 if(battery_status & MEGA_BATT_CHARGE_FAIL) 2301 if(battery_status & MEGA_BATT_CHARGE_FAIL)
2485 strcat(str, " Charge Fail"); 2302 seq_puts(m, " Charge Fail");
2486 2303
2487 if(battery_status & MEGA_BATT_CYCLES_EXCEEDED) 2304 if(battery_status & MEGA_BATT_CYCLES_EXCEEDED)
2488 strcat(str, " Cycles Exceeded"); 2305 seq_puts(m, " Cycles Exceeded");
2489
2490 len = sprintf(page, "%s\n", str);
2491 2306
2307 seq_putc(m, '\n');
2492 2308
2309free_inquiry:
2493 mega_free_inquiry(inquiry, dma_handle, pdev); 2310 mega_free_inquiry(inquiry, dma_handle, pdev);
2494 2311free_pdev:
2495 free_local_pdev(pdev); 2312 free_local_pdev(pdev);
2496 2313 return 0;
2497 *eof = 1;
2498
2499 return len;
2500}
2501
2502
2503/**
2504 * proc_pdrv_ch0()
2505 * @page - buffer to write the data in
2506 * @start - where the actual data has been written in page
2507 * @offset - same meaning as the read system call
2508 * @count - same meaning as the read system call
2509 * @eof - set if no more data needs to be returned
2510 * @data - pointer to our soft state
2511 *
2512 * Display information about the physical drives on physical channel 0.
2513 */
2514static int
2515proc_pdrv_ch0(char *page, char **start, off_t offset, int count, int *eof,
2516 void *data)
2517{
2518 adapter_t *adapter = (adapter_t *)data;
2519
2520 *eof = 1;
2521
2522 return (proc_pdrv(adapter, page, 0));
2523}
2524
2525
2526/**
2527 * proc_pdrv_ch1()
2528 * @page - buffer to write the data in
2529 * @start - where the actual data has been written in page
2530 * @offset - same meaning as the read system call
2531 * @count - same meaning as the read system call
2532 * @eof - set if no more data needs to be returned
2533 * @data - pointer to our soft state
2534 *
2535 * Display information about the physical drives on physical channel 1.
2536 */
2537static int
2538proc_pdrv_ch1(char *page, char **start, off_t offset, int count, int *eof,
2539 void *data)
2540{
2541 adapter_t *adapter = (adapter_t *)data;
2542
2543 *eof = 1;
2544
2545 return (proc_pdrv(adapter, page, 1));
2546} 2314}
2547 2315
2548 2316
2549/** 2317/*
2550 * proc_pdrv_ch2() 2318 * Display scsi inquiry
2551 * @page - buffer to write the data in
2552 * @start - where the actual data has been written in page
2553 * @offset - same meaning as the read system call
2554 * @count - same meaning as the read system call
2555 * @eof - set if no more data needs to be returned
2556 * @data - pointer to our soft state
2557 *
2558 * Display information about the physical drives on physical channel 2.
2559 */ 2319 */
2560static int 2320static void
2561proc_pdrv_ch2(char *page, char **start, off_t offset, int count, int *eof, 2321mega_print_inquiry(struct seq_file *m, char *scsi_inq)
2562 void *data)
2563{ 2322{
2564 adapter_t *adapter = (adapter_t *)data; 2323 int i;
2565
2566 *eof = 1;
2567
2568 return (proc_pdrv(adapter, page, 2));
2569}
2570 2324
2325 seq_puts(m, " Vendor: ");
2326 seq_write(m, scsi_inq + 8, 8);
2327 seq_puts(m, " Model: ");
2328 seq_write(m, scsi_inq + 16, 16);
2329 seq_puts(m, " Rev: ");
2330 seq_write(m, scsi_inq + 32, 4);
2331 seq_putc(m, '\n');
2571 2332
2572/** 2333 i = scsi_inq[0] & 0x1f;
2573 * proc_pdrv_ch3() 2334 seq_printf(m, " Type: %s ", scsi_device_type(i));
2574 * @page - buffer to write the data in
2575 * @start - where the actual data has been written in page
2576 * @offset - same meaning as the read system call
2577 * @count - same meaning as the read system call
2578 * @eof - set if no more data needs to be returned
2579 * @data - pointer to our soft state
2580 *
2581 * Display information about the physical drives on physical channel 3.
2582 */
2583static int
2584proc_pdrv_ch3(char *page, char **start, off_t offset, int count, int *eof,
2585 void *data)
2586{
2587 adapter_t *adapter = (adapter_t *)data;
2588 2335
2589 *eof = 1; 2336 seq_printf(m, " ANSI SCSI revision: %02x",
2337 scsi_inq[2] & 0x07);
2590 2338
2591 return (proc_pdrv(adapter, page, 3)); 2339 if( (scsi_inq[2] & 0x07) == 1 && (scsi_inq[3] & 0x0f) == 1 )
2340 seq_puts(m, " CCS\n");
2341 else
2342 seq_putc(m, '\n');
2592} 2343}
2593 2344
2594
2595/** 2345/**
2596 * proc_pdrv() 2346 * proc_show_pdrv()
2347 * @m - Synthetic file construction data
2597 * @page - buffer to write the data in 2348 * @page - buffer to write the data in
2598 * @adapter - pointer to our soft state 2349 * @adapter - pointer to our soft state
2599 * 2350 *
2600 * Display information about the physical drives. 2351 * Display information about the physical drives.
2601 */ 2352 */
2602static int 2353static int
2603proc_pdrv(adapter_t *adapter, char *page, int channel) 2354proc_show_pdrv(struct seq_file *m, adapter_t *adapter, int channel)
2604{ 2355{
2605 dma_addr_t dma_handle; 2356 dma_addr_t dma_handle;
2606 char *scsi_inq; 2357 char *scsi_inq;
@@ -2611,32 +2362,24 @@ proc_pdrv(adapter_t *adapter, char *page, int channel)
2611 u8 state; 2362 u8 state;
2612 int tgt; 2363 int tgt;
2613 int max_channels; 2364 int max_channels;
2614 int len = 0;
2615 char str[80];
2616 int i; 2365 int i;
2617 2366
2618 if( make_local_pdev(adapter, &pdev) != 0 ) { 2367 if( make_local_pdev(adapter, &pdev) != 0 )
2619 return len; 2368 return 0;
2620 }
2621 2369
2622 if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) { 2370 if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL )
2623 goto free_pdev; 2371 goto free_pdev;
2624 }
2625 2372
2626 if( mega_adapinq(adapter, dma_handle) != 0 ) { 2373 if( mega_adapinq(adapter, dma_handle) != 0 ) {
2627 len = sprintf(page, "Adapter inquiry failed.\n"); 2374 seq_puts(m, "Adapter inquiry failed.\n");
2628
2629 printk(KERN_WARNING "megaraid: inquiry failed.\n"); 2375 printk(KERN_WARNING "megaraid: inquiry failed.\n");
2630
2631 goto free_inquiry; 2376 goto free_inquiry;
2632 } 2377 }
2633 2378
2634 2379
2635 scsi_inq = pci_alloc_consistent(pdev, 256, &scsi_inq_dma_handle); 2380 scsi_inq = pci_alloc_consistent(pdev, 256, &scsi_inq_dma_handle);
2636
2637 if( scsi_inq == NULL ) { 2381 if( scsi_inq == NULL ) {
2638 len = sprintf(page, "memory not available for scsi inq.\n"); 2382 seq_puts(m, "memory not available for scsi inq.\n");
2639
2640 goto free_inquiry; 2383 goto free_inquiry;
2641 } 2384 }
2642 2385
@@ -2659,39 +2402,31 @@ proc_pdrv(adapter_t *adapter, char *page, int channel)
2659 i = channel*16 + tgt; 2402 i = channel*16 + tgt;
2660 2403
2661 state = *(pdrv_state + i); 2404 state = *(pdrv_state + i);
2662
2663 switch( state & 0x0F ) { 2405 switch( state & 0x0F ) {
2664
2665 case PDRV_ONLINE: 2406 case PDRV_ONLINE:
2666 sprintf(str, 2407 seq_printf(m, "Channel:%2d Id:%2d State: Online",
2667 "Channel:%2d Id:%2d State: Online", 2408 channel, tgt);
2668 channel, tgt);
2669 break; 2409 break;
2670 2410
2671 case PDRV_FAILED: 2411 case PDRV_FAILED:
2672 sprintf(str, 2412 seq_printf(m, "Channel:%2d Id:%2d State: Failed",
2673 "Channel:%2d Id:%2d State: Failed", 2413 channel, tgt);
2674 channel, tgt);
2675 break; 2414 break;
2676 2415
2677 case PDRV_RBLD: 2416 case PDRV_RBLD:
2678 sprintf(str, 2417 seq_printf(m, "Channel:%2d Id:%2d State: Rebuild",
2679 "Channel:%2d Id:%2d State: Rebuild", 2418 channel, tgt);
2680 channel, tgt);
2681 break; 2419 break;
2682 2420
2683 case PDRV_HOTSPARE: 2421 case PDRV_HOTSPARE:
2684 sprintf(str, 2422 seq_printf(m, "Channel:%2d Id:%2d State: Hot spare",
2685 "Channel:%2d Id:%2d State: Hot spare", 2423 channel, tgt);
2686 channel, tgt);
2687 break; 2424 break;
2688 2425
2689 default: 2426 default:
2690 sprintf(str, 2427 seq_printf(m, "Channel:%2d Id:%2d State: Un-configured",
2691 "Channel:%2d Id:%2d State: Un-configured", 2428 channel, tgt);
2692 channel, tgt);
2693 break; 2429 break;
2694
2695 } 2430 }
2696 2431
2697 /* 2432 /*
@@ -2710,11 +2445,8 @@ proc_pdrv(adapter_t *adapter, char *page, int channel)
2710 * Check for overflow. We print less than 240 2445 * Check for overflow. We print less than 240
2711 * characters for inquiry 2446 * characters for inquiry
2712 */ 2447 */
2713 if( (len + 240) >= PAGE_SIZE ) break; 2448 seq_puts(m, ".\n");
2714 2449 mega_print_inquiry(m, scsi_inq);
2715 len += sprintf(page+len, "%s.\n", str);
2716
2717 len += mega_print_inquiry(page+len, scsi_inq);
2718 } 2450 }
2719 2451
2720free_pci: 2452free_pci:
@@ -2723,150 +2455,68 @@ free_inquiry:
2723 mega_free_inquiry(inquiry, dma_handle, pdev); 2455 mega_free_inquiry(inquiry, dma_handle, pdev);
2724free_pdev: 2456free_pdev:
2725 free_local_pdev(pdev); 2457 free_local_pdev(pdev);
2726 2458 return 0;
2727 return len;
2728}
2729
2730
2731/*
2732 * Display scsi inquiry
2733 */
2734static int
2735mega_print_inquiry(char *page, char *scsi_inq)
2736{
2737 int len = 0;
2738 int i;
2739
2740 len = sprintf(page, " Vendor: ");
2741 for( i = 8; i < 16; i++ ) {
2742 len += sprintf(page+len, "%c", scsi_inq[i]);
2743 }
2744
2745 len += sprintf(page+len, " Model: ");
2746
2747 for( i = 16; i < 32; i++ ) {
2748 len += sprintf(page+len, "%c", scsi_inq[i]);
2749 }
2750
2751 len += sprintf(page+len, " Rev: ");
2752
2753 for( i = 32; i < 36; i++ ) {
2754 len += sprintf(page+len, "%c", scsi_inq[i]);
2755 }
2756
2757 len += sprintf(page+len, "\n");
2758
2759 i = scsi_inq[0] & 0x1f;
2760
2761 len += sprintf(page+len, " Type: %s ", scsi_device_type(i));
2762
2763 len += sprintf(page+len,
2764 " ANSI SCSI revision: %02x", scsi_inq[2] & 0x07);
2765
2766 if( (scsi_inq[2] & 0x07) == 1 && (scsi_inq[3] & 0x0f) == 1 )
2767 len += sprintf(page+len, " CCS\n");
2768 else
2769 len += sprintf(page+len, "\n");
2770
2771 return len;
2772} 2459}
2773 2460
2774
2775/** 2461/**
2776 * proc_rdrv_10() 2462 * proc_show_pdrv_ch0()
2777 * @page - buffer to write the data in 2463 * @m - Synthetic file construction data
2778 * @start - where the actual data has been written in page 2464 * @v - File iterator
2779 * @offset - same meaning as the read system call
2780 * @count - same meaning as the read system call
2781 * @eof - set if no more data needs to be returned
2782 * @data - pointer to our soft state
2783 * 2465 *
2784 * Display real time information about the logical drives 0 through 9. 2466 * Display information about the physical drives on physical channel 0.
2785 */ 2467 */
2786static int 2468static int
2787proc_rdrv_10(char *page, char **start, off_t offset, int count, int *eof, 2469proc_show_pdrv_ch0(struct seq_file *m, void *v)
2788 void *data)
2789{ 2470{
2790 adapter_t *adapter = (adapter_t *)data; 2471 return proc_show_pdrv(m, m->private, 0);
2791
2792 *eof = 1;
2793
2794 return (proc_rdrv(adapter, page, 0, 9));
2795} 2472}
2796 2473
2797 2474
2798/** 2475/**
2799 * proc_rdrv_20() 2476 * proc_show_pdrv_ch1()
2800 * @page - buffer to write the data in 2477 * @m - Synthetic file construction data
2801 * @start - where the actual data has been written in page 2478 * @v - File iterator
2802 * @offset - same meaning as the read system call
2803 * @count - same meaning as the read system call
2804 * @eof - set if no more data needs to be returned
2805 * @data - pointer to our soft state
2806 * 2479 *
2807 * Display real time information about the logical drives 0 through 9. 2480 * Display information about the physical drives on physical channel 1.
2808 */ 2481 */
2809static int 2482static int
2810proc_rdrv_20(char *page, char **start, off_t offset, int count, int *eof, 2483proc_show_pdrv_ch1(struct seq_file *m, void *v)
2811 void *data)
2812{ 2484{
2813 adapter_t *adapter = (adapter_t *)data; 2485 return proc_show_pdrv(m, m->private, 1);
2814
2815 *eof = 1;
2816
2817 return (proc_rdrv(adapter, page, 10, 19));
2818} 2486}
2819 2487
2820 2488
2821/** 2489/**
2822 * proc_rdrv_30() 2490 * proc_show_pdrv_ch2()
2823 * @page - buffer to write the data in 2491 * @m - Synthetic file construction data
2824 * @start - where the actual data has been written in page 2492 * @v - File iterator
2825 * @offset - same meaning as the read system call
2826 * @count - same meaning as the read system call
2827 * @eof - set if no more data needs to be returned
2828 * @data - pointer to our soft state
2829 * 2493 *
2830 * Display real time information about the logical drives 0 through 9. 2494 * Display information about the physical drives on physical channel 2.
2831 */ 2495 */
2832static int 2496static int
2833proc_rdrv_30(char *page, char **start, off_t offset, int count, int *eof, 2497proc_show_pdrv_ch2(struct seq_file *m, void *v)
2834 void *data)
2835{ 2498{
2836 adapter_t *adapter = (adapter_t *)data; 2499 return proc_show_pdrv(m, m->private, 2);
2837
2838 *eof = 1;
2839
2840 return (proc_rdrv(adapter, page, 20, 29));
2841} 2500}
2842 2501
2843 2502
2844/** 2503/**
2845 * proc_rdrv_40() 2504 * proc_show_pdrv_ch3()
2846 * @page - buffer to write the data in 2505 * @m - Synthetic file construction data
2847 * @start - where the actual data has been written in page 2506 * @v - File iterator
2848 * @offset - same meaning as the read system call
2849 * @count - same meaning as the read system call
2850 * @eof - set if no more data needs to be returned
2851 * @data - pointer to our soft state
2852 * 2507 *
2853 * Display real time information about the logical drives 0 through 9. 2508 * Display information about the physical drives on physical channel 3.
2854 */ 2509 */
2855static int 2510static int
2856proc_rdrv_40(char *page, char **start, off_t offset, int count, int *eof, 2511proc_show_pdrv_ch3(struct seq_file *m, void *v)
2857 void *data)
2858{ 2512{
2859 adapter_t *adapter = (adapter_t *)data; 2513 return proc_show_pdrv(m, m->private, 3);
2860
2861 *eof = 1;
2862
2863 return (proc_rdrv(adapter, page, 30, 39));
2864} 2514}
2865 2515
2866 2516
2867/** 2517/**
2868 * proc_rdrv() 2518 * proc_show_rdrv()
2869 * @page - buffer to write the data in 2519 * @m - Synthetic file construction data
2870 * @adapter - pointer to our soft state 2520 * @adapter - pointer to our soft state
2871 * @start - starting logical drive to display 2521 * @start - starting logical drive to display
2872 * @end - ending logical drive to display 2522 * @end - ending logical drive to display
@@ -2875,7 +2525,7 @@ proc_rdrv_40(char *page, char **start, off_t offset, int count, int *eof,
2875 * /proc/scsi/scsi interface 2525 * /proc/scsi/scsi interface
2876 */ 2526 */
2877static int 2527static int
2878proc_rdrv(adapter_t *adapter, char *page, int start, int end ) 2528proc_show_rdrv(struct seq_file *m, adapter_t *adapter, int start, int end )
2879{ 2529{
2880 dma_addr_t dma_handle; 2530 dma_addr_t dma_handle;
2881 logdrv_param *lparam; 2531 logdrv_param *lparam;
@@ -2887,29 +2537,18 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end )
2887 u8 *rdrv_state; 2537 u8 *rdrv_state;
2888 int num_ldrv; 2538 int num_ldrv;
2889 u32 array_sz; 2539 u32 array_sz;
2890 int len = 0;
2891 int i; 2540 int i;
2892 2541
2893 if( make_local_pdev(adapter, &pdev) != 0 ) { 2542 if( make_local_pdev(adapter, &pdev) != 0 )
2894 return len; 2543 return 0;
2895 }
2896 2544
2897 if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) { 2545 if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL )
2898 free_local_pdev(pdev); 2546 goto free_pdev;
2899 return len;
2900 }
2901 2547
2902 if( mega_adapinq(adapter, dma_handle) != 0 ) { 2548 if( mega_adapinq(adapter, dma_handle) != 0 ) {
2903 2549 seq_puts(m, "Adapter inquiry failed.\n");
2904 len = sprintf(page, "Adapter inquiry failed.\n");
2905
2906 printk(KERN_WARNING "megaraid: inquiry failed.\n"); 2550 printk(KERN_WARNING "megaraid: inquiry failed.\n");
2907 2551 goto free_inquiry;
2908 mega_free_inquiry(inquiry, dma_handle, pdev);
2909
2910 free_local_pdev(pdev);
2911
2912 return len;
2913 } 2552 }
2914 2553
2915 memset(&mc, 0, sizeof(megacmd_t)); 2554 memset(&mc, 0, sizeof(megacmd_t));
@@ -2935,13 +2574,8 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end )
2935 &disk_array_dma_handle); 2574 &disk_array_dma_handle);
2936 2575
2937 if( disk_array == NULL ) { 2576 if( disk_array == NULL ) {
2938 len = sprintf(page, "memory not available.\n"); 2577 seq_puts(m, "memory not available.\n");
2939 2578 goto free_inquiry;
2940 mega_free_inquiry(inquiry, dma_handle, pdev);
2941
2942 free_local_pdev(pdev);
2943
2944 return len;
2945 } 2579 }
2946 2580
2947 mc.xferaddr = (u32)disk_array_dma_handle; 2581 mc.xferaddr = (u32)disk_array_dma_handle;
@@ -2951,17 +2585,8 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end )
2951 mc.opcode = OP_DCMD_READ_CONFIG; 2585 mc.opcode = OP_DCMD_READ_CONFIG;
2952 2586
2953 if( mega_internal_command(adapter, &mc, NULL) ) { 2587 if( mega_internal_command(adapter, &mc, NULL) ) {
2954 2588 seq_puts(m, "40LD read config failed.\n");
2955 len = sprintf(page, "40LD read config failed.\n"); 2589 goto free_pci;
2956
2957 mega_free_inquiry(inquiry, dma_handle, pdev);
2958
2959 pci_free_consistent(pdev, array_sz, disk_array,
2960 disk_array_dma_handle);
2961
2962 free_local_pdev(pdev);
2963
2964 return len;
2965 } 2590 }
2966 2591
2967 } 2592 }
@@ -2969,24 +2594,10 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end )
2969 mc.cmd = NEW_READ_CONFIG_8LD; 2594 mc.cmd = NEW_READ_CONFIG_8LD;
2970 2595
2971 if( mega_internal_command(adapter, &mc, NULL) ) { 2596 if( mega_internal_command(adapter, &mc, NULL) ) {
2972
2973 mc.cmd = READ_CONFIG_8LD; 2597 mc.cmd = READ_CONFIG_8LD;
2974 2598 if( mega_internal_command(adapter, &mc, NULL) ) {
2975 if( mega_internal_command(adapter, &mc, 2599 seq_puts(m, "8LD read config failed.\n");
2976 NULL) ){ 2600 goto free_pci;
2977
2978 len = sprintf(page,
2979 "8LD read config failed.\n");
2980
2981 mega_free_inquiry(inquiry, dma_handle, pdev);
2982
2983 pci_free_consistent(pdev, array_sz,
2984 disk_array,
2985 disk_array_dma_handle);
2986
2987 free_local_pdev(pdev);
2988
2989 return len;
2990 } 2601 }
2991 } 2602 }
2992 } 2603 }
@@ -3006,29 +2617,23 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end )
3006 * Check for overflow. We print less than 240 characters for 2617 * Check for overflow. We print less than 240 characters for
3007 * information about each logical drive. 2618 * information about each logical drive.
3008 */ 2619 */
3009 if( (len + 240) >= PAGE_SIZE ) break; 2620 seq_printf(m, "Logical drive:%2d:, ", i);
3010
3011 len += sprintf(page+len, "Logical drive:%2d:, ", i);
3012 2621
3013 switch( rdrv_state[i] & 0x0F ) { 2622 switch( rdrv_state[i] & 0x0F ) {
3014 case RDRV_OFFLINE: 2623 case RDRV_OFFLINE:
3015 len += sprintf(page+len, "state: offline"); 2624 seq_puts(m, "state: offline");
3016 break; 2625 break;
3017
3018 case RDRV_DEGRADED: 2626 case RDRV_DEGRADED:
3019 len += sprintf(page+len, "state: degraded"); 2627 seq_puts(m, "state: degraded");
3020 break; 2628 break;
3021
3022 case RDRV_OPTIMAL: 2629 case RDRV_OPTIMAL:
3023 len += sprintf(page+len, "state: optimal"); 2630 seq_puts(m, "state: optimal");
3024 break; 2631 break;
3025
3026 case RDRV_DELETED: 2632 case RDRV_DELETED:
3027 len += sprintf(page+len, "state: deleted"); 2633 seq_puts(m, "state: deleted");
3028 break; 2634 break;
3029
3030 default: 2635 default:
3031 len += sprintf(page+len, "state: unknown"); 2636 seq_puts(m, "state: unknown");
3032 break; 2637 break;
3033 } 2638 }
3034 2639
@@ -3036,84 +2641,203 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end )
3036 * Check if check consistency or initialization is going on 2641 * Check if check consistency or initialization is going on
3037 * for this logical drive. 2642 * for this logical drive.
3038 */ 2643 */
3039 if( (rdrv_state[i] & 0xF0) == 0x20 ) { 2644 if( (rdrv_state[i] & 0xF0) == 0x20 )
3040 len += sprintf(page+len, 2645 seq_puts(m, ", check-consistency in progress");
3041 ", check-consistency in progress"); 2646 else if( (rdrv_state[i] & 0xF0) == 0x10 )
3042 } 2647 seq_puts(m, ", initialization in progress");
3043 else if( (rdrv_state[i] & 0xF0) == 0x10 ) {
3044 len += sprintf(page+len,
3045 ", initialization in progress");
3046 }
3047 2648
3048 len += sprintf(page+len, "\n"); 2649 seq_putc(m, '\n');
3049
3050 len += sprintf(page+len, "Span depth:%3d, ",
3051 lparam->span_depth);
3052
3053 len += sprintf(page+len, "RAID level:%3d, ",
3054 lparam->level);
3055
3056 len += sprintf(page+len, "Stripe size:%3d, ",
3057 lparam->stripe_sz ? lparam->stripe_sz/2: 128);
3058
3059 len += sprintf(page+len, "Row size:%3d\n",
3060 lparam->row_size);
3061 2650
2651 seq_printf(m, "Span depth:%3d, ", lparam->span_depth);
2652 seq_printf(m, "RAID level:%3d, ", lparam->level);
2653 seq_printf(m, "Stripe size:%3d, ",
2654 lparam->stripe_sz ? lparam->stripe_sz/2: 128);
2655 seq_printf(m, "Row size:%3d\n", lparam->row_size);
3062 2656
3063 len += sprintf(page+len, "Read Policy: "); 2657 seq_puts(m, "Read Policy: ");
3064
3065 switch(lparam->read_ahead) { 2658 switch(lparam->read_ahead) {
3066
3067 case NO_READ_AHEAD: 2659 case NO_READ_AHEAD:
3068 len += sprintf(page+len, "No read ahead, "); 2660 seq_puts(m, "No read ahead, ");
3069 break; 2661 break;
3070
3071 case READ_AHEAD: 2662 case READ_AHEAD:
3072 len += sprintf(page+len, "Read ahead, "); 2663 seq_puts(m, "Read ahead, ");
3073 break; 2664 break;
3074
3075 case ADAP_READ_AHEAD: 2665 case ADAP_READ_AHEAD:
3076 len += sprintf(page+len, "Adaptive, "); 2666 seq_puts(m, "Adaptive, ");
3077 break; 2667 break;
3078 2668
3079 } 2669 }
3080 2670
3081 len += sprintf(page+len, "Write Policy: "); 2671 seq_puts(m, "Write Policy: ");
3082
3083 switch(lparam->write_mode) { 2672 switch(lparam->write_mode) {
3084
3085 case WRMODE_WRITE_THRU: 2673 case WRMODE_WRITE_THRU:
3086 len += sprintf(page+len, "Write thru, "); 2674 seq_puts(m, "Write thru, ");
3087 break; 2675 break;
3088
3089 case WRMODE_WRITE_BACK: 2676 case WRMODE_WRITE_BACK:
3090 len += sprintf(page+len, "Write back, "); 2677 seq_puts(m, "Write back, ");
3091 break; 2678 break;
3092 } 2679 }
3093 2680
3094 len += sprintf(page+len, "Cache Policy: "); 2681 seq_puts(m, "Cache Policy: ");
3095
3096 switch(lparam->direct_io) { 2682 switch(lparam->direct_io) {
3097
3098 case CACHED_IO: 2683 case CACHED_IO:
3099 len += sprintf(page+len, "Cached IO\n\n"); 2684 seq_puts(m, "Cached IO\n\n");
3100 break; 2685 break;
3101
3102 case DIRECT_IO: 2686 case DIRECT_IO:
3103 len += sprintf(page+len, "Direct IO\n\n"); 2687 seq_puts(m, "Direct IO\n\n");
3104 break; 2688 break;
3105 } 2689 }
3106 } 2690 }
3107 2691
3108 mega_free_inquiry(inquiry, dma_handle, pdev); 2692free_pci:
3109
3110 pci_free_consistent(pdev, array_sz, disk_array, 2693 pci_free_consistent(pdev, array_sz, disk_array,
3111 disk_array_dma_handle); 2694 disk_array_dma_handle);
3112 2695free_inquiry:
2696 mega_free_inquiry(inquiry, dma_handle, pdev);
2697free_pdev:
3113 free_local_pdev(pdev); 2698 free_local_pdev(pdev);
2699 return 0;
2700}
2701
2702/**
2703 * proc_show_rdrv_10()
2704 * @m - Synthetic file construction data
2705 * @v - File iterator
2706 *
2707 * Display real time information about the logical drives 0 through 9.
2708 */
2709static int
2710proc_show_rdrv_10(struct seq_file *m, void *v)
2711{
2712 return proc_show_rdrv(m, m->private, 0, 9);
2713}
2714
2715
2716/**
2717 * proc_show_rdrv_20()
2718 * @m - Synthetic file construction data
2719 * @v - File iterator
2720 *
2721 * Display real time information about the logical drives 0 through 9.
2722 */
2723static int
2724proc_show_rdrv_20(struct seq_file *m, void *v)
2725{
2726 return proc_show_rdrv(m, m->private, 10, 19);
2727}
2728
2729
2730/**
2731 * proc_show_rdrv_30()
2732 * @m - Synthetic file construction data
2733 * @v - File iterator
2734 *
2735 * Display real time information about the logical drives 0 through 9.
2736 */
2737static int
2738proc_show_rdrv_30(struct seq_file *m, void *v)
2739{
2740 return proc_show_rdrv(m, m->private, 20, 29);
2741}
2742
2743
2744/**
2745 * proc_show_rdrv_40()
2746 * @m - Synthetic file construction data
2747 * @v - File iterator
2748 *
2749 * Display real time information about the logical drives 0 through 9.
2750 */
2751static int
2752proc_show_rdrv_40(struct seq_file *m, void *v)
2753{
2754 return proc_show_rdrv(m, m->private, 30, 39);
2755}
2756
2757
2758/*
2759 * seq_file wrappers for procfile show routines.
2760 */
2761static int mega_proc_open(struct inode *inode, struct file *file)
2762{
2763 adapter_t *adapter = proc_get_parent_data(inode);
2764 int (*show)(struct seq_file *, void *) = PDE_DATA(inode);
2765
2766 return single_open(file, show, adapter);
2767}
2768
2769static const struct file_operations mega_proc_fops = {
2770 .open = mega_proc_open,
2771 .read = seq_read,
2772 .llseek = seq_lseek,
2773 .release = seq_release,
2774};
2775
2776/*
2777 * Table of proc files we need to create.
2778 */
2779struct mega_proc_file {
2780 const char *name;
2781 unsigned short ptr_offset;
2782 int (*show) (struct seq_file *m, void *v);
2783};
2784
2785static const struct mega_proc_file mega_proc_files[] = {
2786 { "config", offsetof(adapter_t, proc_read), proc_show_config },
2787 { "stat", offsetof(adapter_t, proc_stat), proc_show_stat },
2788 { "mailbox", offsetof(adapter_t, proc_mbox), proc_show_mbox },
2789#if MEGA_HAVE_ENH_PROC
2790 { "rebuild-rate", offsetof(adapter_t, proc_rr), proc_show_rebuild_rate },
2791 { "battery-status", offsetof(adapter_t, proc_battery), proc_show_battery },
2792 { "diskdrives-ch0", offsetof(adapter_t, proc_pdrvstat[0]), proc_show_pdrv_ch0 },
2793 { "diskdrives-ch1", offsetof(adapter_t, proc_pdrvstat[1]), proc_show_pdrv_ch1 },
2794 { "diskdrives-ch2", offsetof(adapter_t, proc_pdrvstat[2]), proc_show_pdrv_ch2 },
2795 { "diskdrives-ch3", offsetof(adapter_t, proc_pdrvstat[3]), proc_show_pdrv_ch3 },
2796 { "raiddrives-0-9", offsetof(adapter_t, proc_rdrvstat[0]), proc_show_rdrv_10 },
2797 { "raiddrives-10-19", offsetof(adapter_t, proc_rdrvstat[1]), proc_show_rdrv_20 },
2798 { "raiddrives-20-29", offsetof(adapter_t, proc_rdrvstat[2]), proc_show_rdrv_30 },
2799 { "raiddrives-30-39", offsetof(adapter_t, proc_rdrvstat[3]), proc_show_rdrv_40 },
2800#endif
2801 { NULL }
2802};
3114 2803
3115 return len; 2804/**
2805 * mega_create_proc_entry()
2806 * @index - index in soft state array
2807 * @parent - parent node for this /proc entry
2808 *
2809 * Creates /proc entries for our controllers.
2810 */
2811static void
2812mega_create_proc_entry(int index, struct proc_dir_entry *parent)
2813{
2814 const struct mega_proc_file *f;
2815 adapter_t *adapter = hba_soft_state[index];
2816 struct proc_dir_entry *dir, *de, **ppde;
2817 u8 string[16];
2818
2819 sprintf(string, "hba%d", adapter->host->host_no);
2820
2821 dir = adapter->controller_proc_dir_entry =
2822 proc_mkdir_data(string, 0, parent, adapter);
2823 if(!dir) {
2824 printk(KERN_WARNING "\nmegaraid: proc_mkdir failed\n");
2825 return;
2826 }
2827
2828 for (f = mega_proc_files; f->name; f++) {
2829 de = proc_create_data(f->name, S_IRUSR, dir, &mega_proc_fops,
2830 f->show);
2831 if (!de) {
2832 printk(KERN_WARNING "\nmegaraid: proc_create failed\n");
2833 return;
2834 }
2835
2836 ppde = (void *)adapter + f->ptr_offset;
2837 *ppde = de;
2838 }
3116} 2839}
2840
3117#else 2841#else
3118static inline void mega_create_proc_entry(int index, struct proc_dir_entry *parent) 2842static inline void mega_create_proc_entry(int index, struct proc_dir_entry *parent)
3119{ 2843{
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index 4fb2adf6b80d..4d0ce4e78dfd 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -987,24 +987,7 @@ static int mega_init_scb (adapter_t *);
987static int mega_is_bios_enabled (adapter_t *); 987static int mega_is_bios_enabled (adapter_t *);
988 988
989#ifdef CONFIG_PROC_FS 989#ifdef CONFIG_PROC_FS
990static int mega_print_inquiry(char *, char *);
991static void mega_create_proc_entry(int, struct proc_dir_entry *); 990static void mega_create_proc_entry(int, struct proc_dir_entry *);
992static int proc_read_config(char *, char **, off_t, int, int *, void *);
993static int proc_read_stat(char *, char **, off_t, int, int *, void *);
994static int proc_read_mbox(char *, char **, off_t, int, int *, void *);
995static int proc_rebuild_rate(char *, char **, off_t, int, int *, void *);
996static int proc_battery(char *, char **, off_t, int, int *, void *);
997static int proc_pdrv_ch0(char *, char **, off_t, int, int *, void *);
998static int proc_pdrv_ch1(char *, char **, off_t, int, int *, void *);
999static int proc_pdrv_ch2(char *, char **, off_t, int, int *, void *);
1000static int proc_pdrv_ch3(char *, char **, off_t, int, int *, void *);
1001static int proc_pdrv(adapter_t *, char *, int);
1002static int proc_rdrv_10(char *, char **, off_t, int, int *, void *);
1003static int proc_rdrv_20(char *, char **, off_t, int, int *, void *);
1004static int proc_rdrv_30(char *, char **, off_t, int, int *, void *);
1005static int proc_rdrv_40(char *, char **, off_t, int, int *, void *);
1006static int proc_rdrv(adapter_t *, char *, int, int);
1007
1008static int mega_adapinq(adapter_t *, dma_addr_t); 991static int mega_adapinq(adapter_t *, dma_addr_t);
1009static int mega_internal_dev_inquiry(adapter_t *, u8, u8, dma_addr_t); 992static int mega_internal_dev_inquiry(adapter_t *, u8, u8, dma_addr_t);
1010#endif 993#endif
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
index 08685c4cf231..eec052c2670a 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
@@ -505,19 +505,6 @@ _ctl_fasync(int fd, struct file *filep, int mode)
505} 505}
506 506
507/** 507/**
508 * _ctl_release -
509 * @inode -
510 * @filep -
511 *
512 * Called when application releases the fasyn callback handler.
513 */
514static int
515_ctl_release(struct inode *inode, struct file *filep)
516{
517 return fasync_helper(-1, filep, 0, &async_queue);
518}
519
520/**
521 * _ctl_poll - 508 * _ctl_poll -
522 * @file - 509 * @file -
523 * @wait - 510 * @wait -
@@ -3027,7 +3014,6 @@ struct device_attribute *mpt2sas_dev_attrs[] = {
3027static const struct file_operations ctl_fops = { 3014static const struct file_operations ctl_fops = {
3028 .owner = THIS_MODULE, 3015 .owner = THIS_MODULE,
3029 .unlocked_ioctl = _ctl_ioctl, 3016 .unlocked_ioctl = _ctl_ioctl,
3030 .release = _ctl_release,
3031 .poll = _ctl_poll, 3017 .poll = _ctl_poll,
3032 .fasync = _ctl_fasync, 3018 .fasync = _ctl_fasync,
3033#ifdef CONFIG_COMPAT 3019#ifdef CONFIG_COMPAT
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index 054d5231c974..0b402b6f2d26 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -503,19 +503,6 @@ _ctl_fasync(int fd, struct file *filep, int mode)
503} 503}
504 504
505/** 505/**
506 * _ctl_release -
507 * @inode -
508 * @filep -
509 *
510 * Called when application releases the fasyn callback handler.
511 */
512static int
513_ctl_release(struct inode *inode, struct file *filep)
514{
515 return fasync_helper(-1, filep, 0, &async_queue);
516}
517
518/**
519 * _ctl_poll - 506 * _ctl_poll -
520 * @file - 507 * @file -
521 * @wait - 508 * @wait -
@@ -3233,7 +3220,6 @@ struct device_attribute *mpt3sas_dev_attrs[] = {
3233static const struct file_operations ctl_fops = { 3220static const struct file_operations ctl_fops = {
3234 .owner = THIS_MODULE, 3221 .owner = THIS_MODULE,
3235 .unlocked_ioctl = _ctl_ioctl, 3222 .unlocked_ioctl = _ctl_ioctl,
3236 .release = _ctl_release,
3237 .poll = _ctl_poll, 3223 .poll = _ctl_poll,
3238 .fasync = _ctl_fasync, 3224 .fasync = _ctl_fasync,
3239#ifdef CONFIG_COMPAT 3225#ifdef CONFIG_COMPAT
diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c
index c29d0dbb9660..e7f6661a8862 100644
--- a/drivers/scsi/mvme147.c
+++ b/drivers/scsi/mvme147.c
@@ -76,7 +76,8 @@ int mvme147_detect(struct scsi_host_template *tpnt)
76 called++; 76 called++;
77 77
78 tpnt->proc_name = "MVME147"; 78 tpnt->proc_name = "MVME147";
79 tpnt->proc_info = &wd33c93_proc_info; 79 tpnt->show_info = wd33c93_show_info,
80 tpnt->write_info = wd33c93_write_info,
80 81
81 instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata)); 82 instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata));
82 if (!instance) 83 if (!instance)
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 1cc0c1c69c88..1e3879dcbdcc 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -192,7 +192,7 @@ static int __init init_nsp32 (void);
192static void __exit exit_nsp32 (void); 192static void __exit exit_nsp32 (void);
193 193
194/* struct struct scsi_host_template */ 194/* struct struct scsi_host_template */
195static int nsp32_proc_info (struct Scsi_Host *, char *, char **, off_t, int, int); 195static int nsp32_show_info (struct seq_file *, struct Scsi_Host *);
196 196
197static int nsp32_detect (struct pci_dev *pdev); 197static int nsp32_detect (struct pci_dev *pdev);
198static int nsp32_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); 198static int nsp32_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
@@ -268,7 +268,7 @@ static void nsp32_dmessage(const char *, int, int, char *, ...);
268static struct scsi_host_template nsp32_template = { 268static struct scsi_host_template nsp32_template = {
269 .proc_name = "nsp32", 269 .proc_name = "nsp32",
270 .name = "Workbit NinjaSCSI-32Bi/UDE", 270 .name = "Workbit NinjaSCSI-32Bi/UDE",
271 .proc_info = nsp32_proc_info, 271 .show_info = nsp32_show_info,
272 .info = nsp32_info, 272 .info = nsp32_info,
273 .queuecommand = nsp32_queuecommand, 273 .queuecommand = nsp32_queuecommand,
274 .can_queue = 1, 274 .can_queue = 1,
@@ -1442,19 +1442,10 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id)
1442} 1442}
1443 1443
1444#undef SPRINTF 1444#undef SPRINTF
1445#define SPRINTF(args...) \ 1445#define SPRINTF(args...) seq_printf(m, ##args)
1446 do { \ 1446
1447 if(length > (pos - buffer)) { \ 1447static int nsp32_show_info(struct seq_file *m, struct Scsi_Host *host)
1448 pos += snprintf(pos, length - (pos - buffer) + 1, ## args); \
1449 nsp32_dbg(NSP32_DEBUG_PROC, "buffer=0x%p pos=0x%p length=%d %d\n", buffer, pos, length, length - (pos - buffer));\
1450 } \
1451 } while(0)
1452
1453static int nsp32_proc_info(struct Scsi_Host *host, char *buffer, char **start,
1454 off_t offset, int length, int inout)
1455{ 1448{
1456 char *pos = buffer;
1457 int thislength;
1458 unsigned long flags; 1449 unsigned long flags;
1459 nsp32_hw_data *data; 1450 nsp32_hw_data *data;
1460 int hostno; 1451 int hostno;
@@ -1463,11 +1454,6 @@ static int nsp32_proc_info(struct Scsi_Host *host, char *buffer, char **start,
1463 int id, speed; 1454 int id, speed;
1464 long model; 1455 long model;
1465 1456
1466 /* Write is not supported, just return. */
1467 if (inout == TRUE) {
1468 return -EINVAL;
1469 }
1470
1471 hostno = host->host_no; 1457 hostno = host->host_no;
1472 data = (nsp32_hw_data *)host->hostdata; 1458 data = (nsp32_hw_data *)host->hostdata;
1473 base = host->io_port; 1459 base = host->io_port;
@@ -1527,20 +1513,7 @@ static int nsp32_proc_info(struct Scsi_Host *host, char *buffer, char **start,
1527 } 1513 }
1528 SPRINTF("\n"); 1514 SPRINTF("\n");
1529 } 1515 }
1530 1516 return 0;
1531
1532 thislength = pos - (buffer + offset);
1533
1534 if(thislength < 0) {
1535 *start = NULL;
1536 return 0;
1537 }
1538
1539
1540 thislength = min(thislength, length);
1541 *start = buffer + offset;
1542
1543 return thislength;
1544} 1517}
1545#undef SPRINTF 1518#undef SPRINTF
1546 1519
diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c
index 2f72c9807b12..62f1a6031765 100644
--- a/drivers/scsi/pas16.c
+++ b/drivers/scsi/pas16.c
@@ -388,7 +388,8 @@ int __init pas16_detect(struct scsi_host_template * tpnt)
388 int count; 388 int count;
389 389
390 tpnt->proc_name = "pas16"; 390 tpnt->proc_name = "pas16";
391 tpnt->proc_info = &pas16_proc_info; 391 tpnt->show_info = pas16_show_info;
392 tpnt->write_info = pas16_write_info;
392 393
393 if (pas16_addr != 0) { 394 if (pas16_addr != 0) {
394 overrides[0].io_port = pas16_addr; 395 overrides[0].io_port = pas16_addr;
diff --git a/drivers/scsi/pas16.h b/drivers/scsi/pas16.h
index a04281cace2e..3721342835e9 100644
--- a/drivers/scsi/pas16.h
+++ b/drivers/scsi/pas16.h
@@ -163,7 +163,8 @@ static int pas16_bus_reset(Scsi_Cmnd *);
163#define NCR5380_queue_command pas16_queue_command 163#define NCR5380_queue_command pas16_queue_command
164#define NCR5380_abort pas16_abort 164#define NCR5380_abort pas16_abort
165#define NCR5380_bus_reset pas16_bus_reset 165#define NCR5380_bus_reset pas16_bus_reset
166#define NCR5380_proc_info pas16_proc_info 166#define NCR5380_show_info pas16_show_info
167#define NCR5380_write_info pas16_write_info
167 168
168/* 15 14 12 10 7 5 3 169/* 15 14 12 10 7 5 3
169 1101 0100 1010 1000 */ 170 1101 0100 1010 1000 */
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index b61a753eb896..987fbb1b244e 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -76,7 +76,7 @@ MODULE_PARM_DESC(free_ports, "Release IO ports after configuration? (default: 0
76 76
77static struct scsi_host_template nsp_driver_template = { 77static struct scsi_host_template nsp_driver_template = {
78 .proc_name = "nsp_cs", 78 .proc_name = "nsp_cs",
79 .proc_info = nsp_proc_info, 79 .show_info = nsp_show_info,
80 .name = "WorkBit NinjaSCSI-3/32Bi(16bit)", 80 .name = "WorkBit NinjaSCSI-3/32Bi(16bit)",
81 .info = nsp_info, 81 .info = nsp_info,
82 .queuecommand = nsp_queuecommand, 82 .queuecommand = nsp_queuecommand,
@@ -1365,33 +1365,19 @@ static const char *nsp_info(struct Scsi_Host *shpnt)
1365} 1365}
1366 1366
1367#undef SPRINTF 1367#undef SPRINTF
1368#define SPRINTF(args...) \ 1368#define SPRINTF(args...) seq_printf(m, ##args)
1369 do { \ 1369
1370 if(length > (pos - buffer)) { \ 1370static int nsp_show_info(struct seq_file *m, struct Scsi_Host *host)
1371 pos += snprintf(pos, length - (pos - buffer) + 1, ## args); \
1372 nsp_dbg(NSP_DEBUG_PROC, "buffer=0x%p pos=0x%p length=%d %d\n", buffer, pos, length, length - (pos - buffer));\
1373 } \
1374 } while(0)
1375
1376static int nsp_proc_info(struct Scsi_Host *host, char *buffer, char **start,
1377 off_t offset, int length, int inout)
1378{ 1371{
1379 int id; 1372 int id;
1380 char *pos = buffer;
1381 int thislength;
1382 int speed; 1373 int speed;
1383 unsigned long flags; 1374 unsigned long flags;
1384 nsp_hw_data *data; 1375 nsp_hw_data *data;
1385 int hostno; 1376 int hostno;
1386 1377
1387 if (inout) {
1388 return -EINVAL;
1389 }
1390
1391 hostno = host->host_no; 1378 hostno = host->host_no;
1392 data = (nsp_hw_data *)host->hostdata; 1379 data = (nsp_hw_data *)host->hostdata;
1393 1380
1394
1395 SPRINTF("NinjaSCSI status\n\n"); 1381 SPRINTF("NinjaSCSI status\n\n");
1396 SPRINTF("Driver version: $Revision: 1.23 $\n"); 1382 SPRINTF("Driver version: $Revision: 1.23 $\n");
1397 SPRINTF("SCSI host No.: %d\n", hostno); 1383 SPRINTF("SCSI host No.: %d\n", hostno);
@@ -1458,19 +1444,7 @@ static int nsp_proc_info(struct Scsi_Host *host, char *buffer, char **start,
1458 } 1444 }
1459 SPRINTF("\n"); 1445 SPRINTF("\n");
1460 } 1446 }
1461 1447 return 0;
1462 thislength = pos - (buffer + offset);
1463
1464 if(thislength < 0) {
1465 *start = NULL;
1466 return 0;
1467 }
1468
1469
1470 thislength = min(thislength, length);
1471 *start = buffer + offset;
1472
1473 return thislength;
1474} 1448}
1475#undef SPRINTF 1449#undef SPRINTF
1476 1450
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index 7fc9a9d0a448..afd64f0adc4b 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -292,13 +292,8 @@ static int nsp_cs_config (struct pcmcia_device *link);
292/* Linux SCSI subsystem specific functions */ 292/* Linux SCSI subsystem specific functions */
293static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht); 293static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht);
294static const char *nsp_info (struct Scsi_Host *shpnt); 294static const char *nsp_info (struct Scsi_Host *shpnt);
295static int nsp_proc_info ( 295static int nsp_show_info (struct seq_file *m,
296 struct Scsi_Host *host, 296 struct Scsi_Host *host);
297 char *buffer,
298 char **start,
299 off_t offset,
300 int length,
301 int inout);
302static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt); 297static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
303 298
304/* Error handler */ 299/* Error handler */
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index b46f5e906837..8e1b73775065 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3599,19 +3599,6 @@ static int pmcraid_chr_open(struct inode *inode, struct file *filep)
3599} 3599}
3600 3600
3601/** 3601/**
3602 * pmcraid_release - char node "release" entry point
3603 */
3604static int pmcraid_chr_release(struct inode *inode, struct file *filep)
3605{
3606 struct pmcraid_instance *pinstance = filep->private_data;
3607
3608 filep->private_data = NULL;
3609 fasync_helper(-1, filep, 0, &pinstance->aen_queue);
3610
3611 return 0;
3612}
3613
3614/**
3615 * pmcraid_fasync - Async notifier registration from applications 3602 * pmcraid_fasync - Async notifier registration from applications
3616 * 3603 *
3617 * This function adds the calling process to a driver global queue. When an 3604 * This function adds the calling process to a driver global queue. When an
@@ -4167,7 +4154,6 @@ static long pmcraid_chr_ioctl(
4167static const struct file_operations pmcraid_fops = { 4154static const struct file_operations pmcraid_fops = {
4168 .owner = THIS_MODULE, 4155 .owner = THIS_MODULE,
4169 .open = pmcraid_chr_open, 4156 .open = pmcraid_chr_open,
4170 .release = pmcraid_chr_release,
4171 .fasync = pmcraid_chr_fasync, 4157 .fasync = pmcraid_chr_fasync,
4172 .unlocked_ioctl = pmcraid_chr_ioctl, 4158 .unlocked_ioctl = pmcraid_chr_ioctl,
4173#ifdef CONFIG_COMPAT 4159#ifdef CONFIG_COMPAT
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index d164c9639361..1db8b26063b4 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -118,8 +118,9 @@ static inline void ppa_pb_release(ppa_struct *dev)
118 * Also gives a method to use a script to obtain optimum timings (TODO) 118 * Also gives a method to use a script to obtain optimum timings (TODO)
119 */ 119 */
120 120
121static inline int ppa_proc_write(ppa_struct *dev, char *buffer, int length) 121static inline int ppa_write_info(struct Scsi_Host *host, char *buffer, int length)
122{ 122{
123 ppa_struct *dev = ppa_dev(host);
123 unsigned long x; 124 unsigned long x;
124 125
125 if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) { 126 if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) {
@@ -137,35 +138,17 @@ static inline int ppa_proc_write(ppa_struct *dev, char *buffer, int length)
137 return -EINVAL; 138 return -EINVAL;
138} 139}
139 140
140static int ppa_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout) 141static int ppa_show_info(struct seq_file *m, struct Scsi_Host *host)
141{ 142{
142 int len = 0;
143 ppa_struct *dev = ppa_dev(host); 143 ppa_struct *dev = ppa_dev(host);
144 144
145 if (inout) 145 seq_printf(m, "Version : %s\n", PPA_VERSION);
146 return ppa_proc_write(dev, buffer, length); 146 seq_printf(m, "Parport : %s\n", dev->dev->port->name);
147 147 seq_printf(m, "Mode : %s\n", PPA_MODE_STRING[dev->mode]);
148 len += sprintf(buffer + len, "Version : %s\n", PPA_VERSION);
149 len +=
150 sprintf(buffer + len, "Parport : %s\n",
151 dev->dev->port->name);
152 len +=
153 sprintf(buffer + len, "Mode : %s\n",
154 PPA_MODE_STRING[dev->mode]);
155#if PPA_DEBUG > 0 148#if PPA_DEBUG > 0
156 len += 149 seq_printf(m, "recon_tmo : %lu\n", dev->recon_tmo);
157 sprintf(buffer + len, "recon_tmo : %lu\n", dev->recon_tmo);
158#endif 150#endif
159 151 return 0;
160 /* Request for beyond end of buffer */
161 if (offset > length)
162 return 0;
163
164 *start = buffer + offset;
165 len -= offset;
166 if (len > length)
167 len = length;
168 return len;
169} 152}
170 153
171static int device_check(ppa_struct *dev); 154static int device_check(ppa_struct *dev);
@@ -981,7 +964,8 @@ static int ppa_adjust_queue(struct scsi_device *device)
981static struct scsi_host_template ppa_template = { 964static struct scsi_host_template ppa_template = {
982 .module = THIS_MODULE, 965 .module = THIS_MODULE,
983 .proc_name = "ppa", 966 .proc_name = "ppa",
984 .proc_info = ppa_proc_info, 967 .show_info = ppa_show_info,
968 .write_info = ppa_write_info,
985 .name = "Iomega VPI0 (ppa) interface", 969 .name = "Iomega VPI0 (ppa) interface",
986 .queuecommand = ppa_queuecommand, 970 .queuecommand = ppa_queuecommand,
987 .eh_abort_handler = ppa_abort, 971 .eh_abort_handler = ppa_abort,
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index a083715843bd..5307bf86d5e0 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -5539,7 +5539,7 @@ static struct pci_driver qla2xxx_pci_driver = {
5539 .err_handler = &qla2xxx_err_handler, 5539 .err_handler = &qla2xxx_err_handler,
5540}; 5540};
5541 5541
5542static struct file_operations apidev_fops = { 5542static const struct file_operations apidev_fops = {
5543 .owner = THIS_MODULE, 5543 .owner = THIS_MODULE,
5544 .llseek = noop_llseek, 5544 .llseek = noop_llseek,
5545}; 5545};
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 5cda11c07c68..5add6f4e7928 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -2823,31 +2823,27 @@ static const char * scsi_debug_info(struct Scsi_Host * shp)
2823/* scsi_debug_proc_info 2823/* scsi_debug_proc_info
2824 * Used if the driver currently has no own support for /proc/scsi 2824 * Used if the driver currently has no own support for /proc/scsi
2825 */ 2825 */
2826static int scsi_debug_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, 2826static int scsi_debug_write_info(struct Scsi_Host *host, char *buffer, int length)
2827 int length, int inout)
2828{ 2827{
2829 int len, pos, begin; 2828 char arr[16];
2830 int orig_length; 2829 int opts;
2830 int minLen = length > 15 ? 15 : length;
2831 2831
2832 orig_length = length; 2832 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
2833 2833 return -EACCES;
2834 if (inout == 1) { 2834 memcpy(arr, buffer, minLen);
2835 char arr[16]; 2835 arr[minLen] = '\0';
2836 int minLen = length > 15 ? 15 : length; 2836 if (1 != sscanf(arr, "%d", &opts))
2837 return -EINVAL;
2838 scsi_debug_opts = opts;
2839 if (scsi_debug_every_nth != 0)
2840 scsi_debug_cmnd_count = 0;
2841 return length;
2842}
2837 2843
2838 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) 2844static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host)
2839 return -EACCES; 2845{
2840 memcpy(arr, buffer, minLen); 2846 seq_printf(m, "scsi_debug adapter driver, version "
2841 arr[minLen] = '\0';
2842 if (1 != sscanf(arr, "%d", &pos))
2843 return -EINVAL;
2844 scsi_debug_opts = pos;
2845 if (scsi_debug_every_nth != 0)
2846 scsi_debug_cmnd_count = 0;
2847 return length;
2848 }
2849 begin = 0;
2850 pos = len = sprintf(buffer, "scsi_debug adapter driver, version "
2851 "%s [%s]\n" 2847 "%s [%s]\n"
2852 "num_tgts=%d, shared (ram) size=%d MB, opts=0x%x, " 2848 "num_tgts=%d, shared (ram) size=%d MB, opts=0x%x, "
2853 "every_nth=%d(curr:%d)\n" 2849 "every_nth=%d(curr:%d)\n"
@@ -2862,15 +2858,7 @@ static int scsi_debug_proc_info(struct Scsi_Host *host, char *buffer, char **sta
2862 scsi_debug_sector_size, sdebug_cylinders_per, sdebug_heads, 2858 scsi_debug_sector_size, sdebug_cylinders_per, sdebug_heads,
2863 sdebug_sectors_per, num_aborts, num_dev_resets, num_bus_resets, 2859 sdebug_sectors_per, num_aborts, num_dev_resets, num_bus_resets,
2864 num_host_resets, dix_reads, dix_writes, dif_errors); 2860 num_host_resets, dix_reads, dix_writes, dif_errors);
2865 if (pos < offset) { 2861 return 0;
2866 len = 0;
2867 begin = pos;
2868 }
2869 *start = buffer + (offset - begin); /* Start of wanted data */
2870 len -= (offset - begin);
2871 if (len > length)
2872 len = length;
2873 return len;
2874} 2862}
2875 2863
2876static ssize_t sdebug_delay_show(struct device_driver * ddp, char * buf) 2864static ssize_t sdebug_delay_show(struct device_driver * ddp, char * buf)
@@ -3957,7 +3945,8 @@ write:
3957static DEF_SCSI_QCMD(scsi_debug_queuecommand) 3945static DEF_SCSI_QCMD(scsi_debug_queuecommand)
3958 3946
3959static struct scsi_host_template sdebug_driver_template = { 3947static struct scsi_host_template sdebug_driver_template = {
3960 .proc_info = scsi_debug_proc_info, 3948 .show_info = scsi_debug_show_info,
3949 .write_info = scsi_debug_write_info,
3961 .proc_name = sdebug_proc_name, 3950 .proc_name = sdebug_proc_name,
3962 .name = "SCSI DEBUG", 3951 .name = "SCSI DEBUG",
3963 .info = scsi_debug_info, 3952 .info = scsi_debug_info,
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index ad747dc337da..db66357211ed 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -45,58 +45,50 @@ static struct proc_dir_entry *proc_scsi;
45/* Protect sht->present and sht->proc_dir */ 45/* Protect sht->present and sht->proc_dir */
46static DEFINE_MUTEX(global_host_template_mutex); 46static DEFINE_MUTEX(global_host_template_mutex);
47 47
48/** 48static ssize_t proc_scsi_host_write(struct file *file, const char __user *buf,
49 * proc_scsi_read - handle read from /proc by calling host's proc_info() command 49 size_t count, loff_t *ppos)
50 * @buffer: passed to proc_info
51 * @start: passed to proc_info
52 * @offset: passed to proc_info
53 * @length: passed to proc_info
54 * @eof: returns whether length read was less than requested
55 * @data: pointer to a &struct Scsi_Host
56 */
57
58static int proc_scsi_read(char *buffer, char **start, off_t offset,
59 int length, int *eof, void *data)
60{
61 struct Scsi_Host *shost = data;
62 int n;
63
64 n = shost->hostt->proc_info(shost, buffer, start, offset, length, 0);
65 *eof = (n < length);
66
67 return n;
68}
69
70/**
71 * proc_scsi_write_proc - Handle write to /proc by calling host's proc_info()
72 * @file: not used
73 * @buf: source of data to write.
74 * @count: number of bytes (at most PROC_BLOCK_SIZE) to write.
75 * @data: pointer to &struct Scsi_Host
76 */
77static int proc_scsi_write_proc(struct file *file, const char __user *buf,
78 unsigned long count, void *data)
79{ 50{
80 struct Scsi_Host *shost = data; 51 struct Scsi_Host *shost = PDE_DATA(file_inode(file));
81 ssize_t ret = -ENOMEM; 52 ssize_t ret = -ENOMEM;
82 char *page; 53 char *page;
83 char *start;
84 54
85 if (count > PROC_BLOCK_SIZE) 55 if (count > PROC_BLOCK_SIZE)
86 return -EOVERFLOW; 56 return -EOVERFLOW;
87 57
58 if (!shost->hostt->write_info)
59 return -EINVAL;
60
88 page = (char *)__get_free_page(GFP_KERNEL); 61 page = (char *)__get_free_page(GFP_KERNEL);
89 if (page) { 62 if (page) {
90 ret = -EFAULT; 63 ret = -EFAULT;
91 if (copy_from_user(page, buf, count)) 64 if (copy_from_user(page, buf, count))
92 goto out; 65 goto out;
93 ret = shost->hostt->proc_info(shost, page, &start, 0, count, 1); 66 ret = shost->hostt->write_info(shost, page, count);
94 } 67 }
95out: 68out:
96 free_page((unsigned long)page); 69 free_page((unsigned long)page);
97 return ret; 70 return ret;
98} 71}
99 72
73static int proc_scsi_show(struct seq_file *m, void *v)
74{
75 struct Scsi_Host *shost = m->private;
76 return shost->hostt->show_info(m, shost);
77}
78
79static int proc_scsi_host_open(struct inode *inode, struct file *file)
80{
81 return single_open_size(file, proc_scsi_show, PDE_DATA(inode),
82 4 * PAGE_SIZE);
83}
84
85static const struct file_operations proc_scsi_fops = {
86 .open = proc_scsi_host_open,
87 .read = seq_read,
88 .llseek = seq_lseek,
89 .write = proc_scsi_host_write
90};
91
100/** 92/**
101 * scsi_proc_hostdir_add - Create directory in /proc for a scsi host 93 * scsi_proc_hostdir_add - Create directory in /proc for a scsi host
102 * @sht: owner of this directory 94 * @sht: owner of this directory
@@ -106,7 +98,7 @@ out:
106 98
107void scsi_proc_hostdir_add(struct scsi_host_template *sht) 99void scsi_proc_hostdir_add(struct scsi_host_template *sht)
108{ 100{
109 if (!sht->proc_info) 101 if (!sht->show_info)
110 return; 102 return;
111 103
112 mutex_lock(&global_host_template_mutex); 104 mutex_lock(&global_host_template_mutex);
@@ -125,7 +117,7 @@ void scsi_proc_hostdir_add(struct scsi_host_template *sht)
125 */ 117 */
126void scsi_proc_hostdir_rm(struct scsi_host_template *sht) 118void scsi_proc_hostdir_rm(struct scsi_host_template *sht)
127{ 119{
128 if (!sht->proc_info) 120 if (!sht->show_info)
129 return; 121 return;
130 122
131 mutex_lock(&global_host_template_mutex); 123 mutex_lock(&global_host_template_mutex);
@@ -151,16 +143,12 @@ void scsi_proc_host_add(struct Scsi_Host *shost)
151 return; 143 return;
152 144
153 sprintf(name,"%d", shost->host_no); 145 sprintf(name,"%d", shost->host_no);
154 p = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, 146 p = proc_create_data(name, S_IRUGO | S_IWUSR,
155 sht->proc_dir, proc_scsi_read, shost); 147 sht->proc_dir, &proc_scsi_fops, shost);
156 if (!p) { 148 if (!p)
157 printk(KERN_ERR "%s: Failed to register host %d in" 149 printk(KERN_ERR "%s: Failed to register host %d in"
158 "%s\n", __func__, shost->host_no, 150 "%s\n", __func__, shost->host_no,
159 sht->proc_name); 151 sht->proc_name);
160 return;
161 }
162
163 p->write_proc = proc_scsi_write_proc;
164} 152}
165 153
166/** 154/**
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 599568299fbe..bac55f7f69f9 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -1171,112 +1171,36 @@ printk("sym_user_command: data=%ld\n", uc->data);
1171#endif /* SYM_LINUX_USER_COMMAND_SUPPORT */ 1171#endif /* SYM_LINUX_USER_COMMAND_SUPPORT */
1172 1172
1173 1173
1174#ifdef SYM_LINUX_USER_INFO_SUPPORT
1175/*
1176 * Informations through the proc file system.
1177 */
1178struct info_str {
1179 char *buffer;
1180 int length;
1181 int offset;
1182 int pos;
1183};
1184
1185static void copy_mem_info(struct info_str *info, char *data, int len)
1186{
1187 if (info->pos + len > info->length)
1188 len = info->length - info->pos;
1189
1190 if (info->pos + len < info->offset) {
1191 info->pos += len;
1192 return;
1193 }
1194 if (info->pos < info->offset) {
1195 data += (info->offset - info->pos);
1196 len -= (info->offset - info->pos);
1197 }
1198
1199 if (len > 0) {
1200 memcpy(info->buffer + info->pos, data, len);
1201 info->pos += len;
1202 }
1203}
1204
1205static int copy_info(struct info_str *info, char *fmt, ...)
1206{
1207 va_list args;
1208 char buf[81];
1209 int len;
1210
1211 va_start(args, fmt);
1212 len = vsprintf(buf, fmt, args);
1213 va_end(args);
1214
1215 copy_mem_info(info, buf, len);
1216 return len;
1217}
1218
1219/* 1174/*
1220 * Copy formatted information into the input buffer. 1175 * Copy formatted information into the input buffer.
1221 */ 1176 */
1222static int sym_host_info(struct Scsi_Host *shost, char *ptr, off_t offset, int len) 1177static int sym_show_info(struct seq_file *m, struct Scsi_Host *shost)
1223{ 1178{
1179#ifdef SYM_LINUX_USER_INFO_SUPPORT
1224 struct sym_data *sym_data = shost_priv(shost); 1180 struct sym_data *sym_data = shost_priv(shost);
1225 struct pci_dev *pdev = sym_data->pdev; 1181 struct pci_dev *pdev = sym_data->pdev;
1226 struct sym_hcb *np = sym_data->ncb; 1182 struct sym_hcb *np = sym_data->ncb;
1227 struct info_str info;
1228
1229 info.buffer = ptr;
1230 info.length = len;
1231 info.offset = offset;
1232 info.pos = 0;
1233 1183
1234 copy_info(&info, "Chip " NAME53C "%s, device id 0x%x, " 1184 seq_printf(m, "Chip " NAME53C "%s, device id 0x%x, "
1235 "revision id 0x%x\n", np->s.chip_name, 1185 "revision id 0x%x\n", np->s.chip_name,
1236 pdev->device, pdev->revision); 1186 pdev->device, pdev->revision);
1237 copy_info(&info, "At PCI address %s, IRQ %u\n", 1187 seq_printf(m, "At PCI address %s, IRQ %u\n",
1238 pci_name(pdev), pdev->irq); 1188 pci_name(pdev), pdev->irq);
1239 copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n", 1189 seq_printf(m, "Min. period factor %d, %s SCSI BUS%s\n",
1240 (int) (np->minsync_dt ? np->minsync_dt : np->minsync), 1190 (int) (np->minsync_dt ? np->minsync_dt : np->minsync),
1241 np->maxwide ? "Wide" : "Narrow", 1191 np->maxwide ? "Wide" : "Narrow",
1242 np->minsync_dt ? ", DT capable" : ""); 1192 np->minsync_dt ? ", DT capable" : "");
1243 1193
1244 copy_info(&info, "Max. started commands %d, " 1194 seq_printf(m, "Max. started commands %d, "
1245 "max. commands per LUN %d\n", 1195 "max. commands per LUN %d\n",
1246 SYM_CONF_MAX_START, SYM_CONF_MAX_TAG); 1196 SYM_CONF_MAX_START, SYM_CONF_MAX_TAG);
1247 1197
1248 return info.pos > info.offset? info.pos - info.offset : 0; 1198 return 0;
1249}
1250#endif /* SYM_LINUX_USER_INFO_SUPPORT */
1251
1252/*
1253 * Entry point of the scsi proc fs of the driver.
1254 * - func = 0 means read (returns adapter infos)
1255 * - func = 1 means write (not yet merget from sym53c8xx)
1256 */
1257static int sym53c8xx_proc_info(struct Scsi_Host *shost, char *buffer,
1258 char **start, off_t offset, int length, int func)
1259{
1260 int retv;
1261
1262 if (func) {
1263#ifdef SYM_LINUX_USER_COMMAND_SUPPORT
1264 retv = sym_user_command(shost, buffer, length);
1265#else
1266 retv = -EINVAL;
1267#endif
1268 } else {
1269 if (start)
1270 *start = buffer;
1271#ifdef SYM_LINUX_USER_INFO_SUPPORT
1272 retv = sym_host_info(shost, buffer, offset, length);
1273#else 1199#else
1274 retv = -EINVAL; 1200 return -EINVAL;
1275#endif 1201#endif /* SYM_LINUX_USER_INFO_SUPPORT */
1276 }
1277
1278 return retv;
1279} 1202}
1203
1280#endif /* SYM_LINUX_PROC_INFO_SUPPORT */ 1204#endif /* SYM_LINUX_PROC_INFO_SUPPORT */
1281 1205
1282/* 1206/*
@@ -1742,7 +1666,10 @@ static struct scsi_host_template sym2_template = {
1742 .use_clustering = ENABLE_CLUSTERING, 1666 .use_clustering = ENABLE_CLUSTERING,
1743 .max_sectors = 0xFFFF, 1667 .max_sectors = 0xFFFF,
1744#ifdef SYM_LINUX_PROC_INFO_SUPPORT 1668#ifdef SYM_LINUX_PROC_INFO_SUPPORT
1745 .proc_info = sym53c8xx_proc_info, 1669 .show_info = sym_show_info,
1670#ifdef SYM_LINUX_USER_COMMAND_SUPPORT
1671 .write_info = sym_user_command,
1672#endif
1746 .proc_name = NAME53C8XX, 1673 .proc_name = NAME53C8XX,
1747#endif 1674#endif
1748}; 1675};
diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c
index d672d97fb84a..f1e4b4148c75 100644
--- a/drivers/scsi/t128.c
+++ b/drivers/scsi/t128.c
@@ -201,7 +201,8 @@ int __init t128_detect(struct scsi_host_template * tpnt){
201 int sig, count; 201 int sig, count;
202 202
203 tpnt->proc_name = "t128"; 203 tpnt->proc_name = "t128";
204 tpnt->proc_info = &t128_proc_info; 204 tpnt->show_info = t128_show_info;
205 tpnt->write_info = t128_write_info;
205 206
206 for (count = 0; current_override < NO_OVERRIDES; ++current_override) { 207 for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
207 base = 0; 208 base = 0;
diff --git a/drivers/scsi/t128.h b/drivers/scsi/t128.h
index ada1115079c9..1df82c28e56d 100644
--- a/drivers/scsi/t128.h
+++ b/drivers/scsi/t128.h
@@ -140,7 +140,8 @@ static int t128_bus_reset(struct scsi_cmnd *);
140#define NCR5380_queue_command t128_queue_command 140#define NCR5380_queue_command t128_queue_command
141#define NCR5380_abort t128_abort 141#define NCR5380_abort t128_abort
142#define NCR5380_bus_reset t128_bus_reset 142#define NCR5380_bus_reset t128_bus_reset
143#define NCR5380_proc_info t128_proc_info 143#define NCR5380_show_info t128_show_info
144#define NCR5380_write_info t128_write_info
144 145
145/* 15 14 12 10 7 5 3 146/* 15 14 12 10 7 5 3
146 1101 0100 1010 1000 */ 147 1101 0100 1010 1000 */
diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
index c0ee4ea28a19..41883a87931d 100644
--- a/drivers/scsi/wd33c93.c
+++ b/drivers/scsi/wd33c93.c
@@ -2054,22 +2054,16 @@ wd33c93_init(struct Scsi_Host *instance, const wd33c93_regs regs,
2054 printk(" Version %s - %s\n", WD33C93_VERSION, WD33C93_DATE); 2054 printk(" Version %s - %s\n", WD33C93_VERSION, WD33C93_DATE);
2055} 2055}
2056 2056
2057int 2057int wd33c93_write_info(struct Scsi_Host *instance, char *buf, int len)
2058wd33c93_proc_info(struct Scsi_Host *instance, char *buf, char **start, off_t off, int len, int in)
2059{ 2058{
2060
2061#ifdef PROC_INTERFACE 2059#ifdef PROC_INTERFACE
2062
2063 char *bp; 2060 char *bp;
2064 char tbuf[128];
2065 struct WD33C93_hostdata *hd; 2061 struct WD33C93_hostdata *hd;
2066 struct scsi_cmnd *cmd;
2067 int x; 2062 int x;
2068 static int stop = 0;
2069 2063
2070 hd = (struct WD33C93_hostdata *) instance->hostdata; 2064 hd = (struct WD33C93_hostdata *) instance->hostdata;
2071 2065
2072/* If 'in' is TRUE we need to _read_ the proc file. We accept the following 2066/* We accept the following
2073 * keywords (same format as command-line, but arguments are not optional): 2067 * keywords (same format as command-line, but arguments are not optional):
2074 * debug 2068 * debug
2075 * disconnect 2069 * disconnect
@@ -2083,145 +2077,124 @@ wd33c93_proc_info(struct Scsi_Host *instance, char *buf, char **start, off_t off
2083 * nosync 2077 * nosync
2084 */ 2078 */
2085 2079
2086 if (in) { 2080 buf[len] = '\0';
2087 buf[len] = '\0'; 2081 for (bp = buf; *bp; ) {
2088 for (bp = buf; *bp; ) { 2082 while (',' == *bp || ' ' == *bp)
2089 while (',' == *bp || ' ' == *bp) 2083 ++bp;
2090 ++bp; 2084 if (!strncmp(bp, "debug:", 6)) {
2091 if (!strncmp(bp, "debug:", 6)) { 2085 hd->args = simple_strtoul(bp+6, &bp, 0) & DB_MASK;
2092 hd->args = simple_strtoul(bp+6, &bp, 0) & DB_MASK; 2086 } else if (!strncmp(bp, "disconnect:", 11)) {
2093 } else if (!strncmp(bp, "disconnect:", 11)) { 2087 x = simple_strtoul(bp+11, &bp, 0);
2094 x = simple_strtoul(bp+11, &bp, 0); 2088 if (x < DIS_NEVER || x > DIS_ALWAYS)
2095 if (x < DIS_NEVER || x > DIS_ALWAYS) 2089 x = DIS_ADAPTIVE;
2096 x = DIS_ADAPTIVE; 2090 hd->disconnect = x;
2097 hd->disconnect = x; 2091 } else if (!strncmp(bp, "period:", 7)) {
2098 } else if (!strncmp(bp, "period:", 7)) { 2092 x = simple_strtoul(bp+7, &bp, 0);
2093 hd->default_sx_per =
2094 hd->sx_table[round_period((unsigned int) x,
2095 hd->sx_table)].period_ns;
2096 } else if (!strncmp(bp, "resync:", 7)) {
2097 set_resync(hd, (int)simple_strtoul(bp+7, &bp, 0));
2098 } else if (!strncmp(bp, "proc:", 5)) {
2099 hd->proc = simple_strtoul(bp+5, &bp, 0);
2100 } else if (!strncmp(bp, "nodma:", 6)) {
2101 hd->no_dma = simple_strtoul(bp+6, &bp, 0);
2102 } else if (!strncmp(bp, "level2:", 7)) {
2103 hd->level2 = simple_strtoul(bp+7, &bp, 0);
2104 } else if (!strncmp(bp, "burst:", 6)) {
2105 hd->dma_mode =
2106 simple_strtol(bp+6, &bp, 0) ? CTRL_BURST:CTRL_DMA;
2107 } else if (!strncmp(bp, "fast:", 5)) {
2108 x = !!simple_strtol(bp+5, &bp, 0);
2109 if (x != hd->fast)
2110 set_resync(hd, 0xff);
2111 hd->fast = x;
2112 } else if (!strncmp(bp, "nosync:", 7)) {
2099 x = simple_strtoul(bp+7, &bp, 0); 2113 x = simple_strtoul(bp+7, &bp, 0);
2100 hd->default_sx_per = 2114 set_resync(hd, x ^ hd->no_sync);
2101 hd->sx_table[round_period((unsigned int) x, 2115 hd->no_sync = x;
2102 hd->sx_table)].period_ns; 2116 } else {
2103 } else if (!strncmp(bp, "resync:", 7)) { 2117 break; /* unknown keyword,syntax-error,... */
2104 set_resync(hd, (int)simple_strtoul(bp+7, &bp, 0));
2105 } else if (!strncmp(bp, "proc:", 5)) {
2106 hd->proc = simple_strtoul(bp+5, &bp, 0);
2107 } else if (!strncmp(bp, "nodma:", 6)) {
2108 hd->no_dma = simple_strtoul(bp+6, &bp, 0);
2109 } else if (!strncmp(bp, "level2:", 7)) {
2110 hd->level2 = simple_strtoul(bp+7, &bp, 0);
2111 } else if (!strncmp(bp, "burst:", 6)) {
2112 hd->dma_mode =
2113 simple_strtol(bp+6, &bp, 0) ? CTRL_BURST:CTRL_DMA;
2114 } else if (!strncmp(bp, "fast:", 5)) {
2115 x = !!simple_strtol(bp+5, &bp, 0);
2116 if (x != hd->fast)
2117 set_resync(hd, 0xff);
2118 hd->fast = x;
2119 } else if (!strncmp(bp, "nosync:", 7)) {
2120 x = simple_strtoul(bp+7, &bp, 0);
2121 set_resync(hd, x ^ hd->no_sync);
2122 hd->no_sync = x;
2123 } else {
2124 break; /* unknown keyword,syntax-error,... */
2125 }
2126 } 2118 }
2127 return len;
2128 } 2119 }
2120 return len;
2121#else
2122 return 0;
2123#endif
2124}
2125
2126int
2127wd33c93_show_info(struct seq_file *m, struct Scsi_Host *instance)
2128{
2129#ifdef PROC_INTERFACE
2130 struct WD33C93_hostdata *hd;
2131 struct scsi_cmnd *cmd;
2132 int x;
2133
2134 hd = (struct WD33C93_hostdata *) instance->hostdata;
2129 2135
2130 spin_lock_irq(&hd->lock); 2136 spin_lock_irq(&hd->lock);
2131 bp = buf; 2137 if (hd->proc & PR_VERSION)
2132 *bp = '\0'; 2138 seq_printf(m, "\nVersion %s - %s.",
2133 if (hd->proc & PR_VERSION) {
2134 sprintf(tbuf, "\nVersion %s - %s.",
2135 WD33C93_VERSION, WD33C93_DATE); 2139 WD33C93_VERSION, WD33C93_DATE);
2136 strcat(bp, tbuf); 2140
2137 }
2138 if (hd->proc & PR_INFO) { 2141 if (hd->proc & PR_INFO) {
2139 sprintf(tbuf, "\nclock_freq=%02x no_sync=%02x no_dma=%d" 2142 seq_printf(m, "\nclock_freq=%02x no_sync=%02x no_dma=%d"
2140 " dma_mode=%02x fast=%d", 2143 " dma_mode=%02x fast=%d",
2141 hd->clock_freq, hd->no_sync, hd->no_dma, hd->dma_mode, hd->fast); 2144 hd->clock_freq, hd->no_sync, hd->no_dma, hd->dma_mode, hd->fast);
2142 strcat(bp, tbuf); 2145 seq_printf(m, "\nsync_xfer[] = ");
2143 strcat(bp, "\nsync_xfer[] = "); 2146 for (x = 0; x < 7; x++)
2144 for (x = 0; x < 7; x++) { 2147 seq_printf(m, "\t%02x", hd->sync_xfer[x]);
2145 sprintf(tbuf, "\t%02x", hd->sync_xfer[x]); 2148 seq_printf(m, "\nsync_stat[] = ");
2146 strcat(bp, tbuf); 2149 for (x = 0; x < 7; x++)
2147 } 2150 seq_printf(m, "\t%02x", hd->sync_stat[x]);
2148 strcat(bp, "\nsync_stat[] = ");
2149 for (x = 0; x < 7; x++) {
2150 sprintf(tbuf, "\t%02x", hd->sync_stat[x]);
2151 strcat(bp, tbuf);
2152 }
2153 } 2151 }
2154#ifdef PROC_STATISTICS 2152#ifdef PROC_STATISTICS
2155 if (hd->proc & PR_STATISTICS) { 2153 if (hd->proc & PR_STATISTICS) {
2156 strcat(bp, "\ncommands issued: "); 2154 seq_printf(m, "\ncommands issued: ");
2157 for (x = 0; x < 7; x++) { 2155 for (x = 0; x < 7; x++)
2158 sprintf(tbuf, "\t%ld", hd->cmd_cnt[x]); 2156 seq_printf(m, "\t%ld", hd->cmd_cnt[x]);
2159 strcat(bp, tbuf); 2157 seq_printf(m, "\ndisconnects allowed:");
2160 } 2158 for (x = 0; x < 7; x++)
2161 strcat(bp, "\ndisconnects allowed:"); 2159 seq_printf(m, "\t%ld", hd->disc_allowed_cnt[x]);
2162 for (x = 0; x < 7; x++) { 2160 seq_printf(m, "\ndisconnects done: ");
2163 sprintf(tbuf, "\t%ld", hd->disc_allowed_cnt[x]); 2161 for (x = 0; x < 7; x++)
2164 strcat(bp, tbuf); 2162 seq_printf(m, "\t%ld", hd->disc_done_cnt[x]);
2165 } 2163 seq_printf(m,
2166 strcat(bp, "\ndisconnects done: ");
2167 for (x = 0; x < 7; x++) {
2168 sprintf(tbuf, "\t%ld", hd->disc_done_cnt[x]);
2169 strcat(bp, tbuf);
2170 }
2171 sprintf(tbuf,
2172 "\ninterrupts: %ld, DATA_PHASE ints: %ld DMA, %ld PIO", 2164 "\ninterrupts: %ld, DATA_PHASE ints: %ld DMA, %ld PIO",
2173 hd->int_cnt, hd->dma_cnt, hd->pio_cnt); 2165 hd->int_cnt, hd->dma_cnt, hd->pio_cnt);
2174 strcat(bp, tbuf);
2175 } 2166 }
2176#endif 2167#endif
2177 if (hd->proc & PR_CONNECTED) { 2168 if (hd->proc & PR_CONNECTED) {
2178 strcat(bp, "\nconnected: "); 2169 seq_printf(m, "\nconnected: ");
2179 if (hd->connected) { 2170 if (hd->connected) {
2180 cmd = (struct scsi_cmnd *) hd->connected; 2171 cmd = (struct scsi_cmnd *) hd->connected;
2181 sprintf(tbuf, " %d:%d(%02x)", 2172 seq_printf(m, " %d:%d(%02x)",
2182 cmd->device->id, cmd->device->lun, cmd->cmnd[0]); 2173 cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2183 strcat(bp, tbuf);
2184 } 2174 }
2185 } 2175 }
2186 if (hd->proc & PR_INPUTQ) { 2176 if (hd->proc & PR_INPUTQ) {
2187 strcat(bp, "\ninput_Q: "); 2177 seq_printf(m, "\ninput_Q: ");
2188 cmd = (struct scsi_cmnd *) hd->input_Q; 2178 cmd = (struct scsi_cmnd *) hd->input_Q;
2189 while (cmd) { 2179 while (cmd) {
2190 sprintf(tbuf, " %d:%d(%02x)", 2180 seq_printf(m, " %d:%d(%02x)",
2191 cmd->device->id, cmd->device->lun, cmd->cmnd[0]); 2181 cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2192 strcat(bp, tbuf);
2193 cmd = (struct scsi_cmnd *) cmd->host_scribble; 2182 cmd = (struct scsi_cmnd *) cmd->host_scribble;
2194 } 2183 }
2195 } 2184 }
2196 if (hd->proc & PR_DISCQ) { 2185 if (hd->proc & PR_DISCQ) {
2197 strcat(bp, "\ndisconnected_Q:"); 2186 seq_printf(m, "\ndisconnected_Q:");
2198 cmd = (struct scsi_cmnd *) hd->disconnected_Q; 2187 cmd = (struct scsi_cmnd *) hd->disconnected_Q;
2199 while (cmd) { 2188 while (cmd) {
2200 sprintf(tbuf, " %d:%d(%02x)", 2189 seq_printf(m, " %d:%d(%02x)",
2201 cmd->device->id, cmd->device->lun, cmd->cmnd[0]); 2190 cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2202 strcat(bp, tbuf);
2203 cmd = (struct scsi_cmnd *) cmd->host_scribble; 2191 cmd = (struct scsi_cmnd *) cmd->host_scribble;
2204 } 2192 }
2205 } 2193 }
2206 strcat(bp, "\n"); 2194 seq_printf(m, "\n");
2207 spin_unlock_irq(&hd->lock); 2195 spin_unlock_irq(&hd->lock);
2208 *start = buf;
2209 if (stop) {
2210 stop = 0;
2211 return 0;
2212 }
2213 if (off > 0x40000) /* ALWAYS stop after 256k bytes have been read */
2214 stop = 1;
2215 if (hd->proc & PR_STOP) /* stop every other time */
2216 stop = 1;
2217 return strlen(bp);
2218
2219#else /* PROC_INTERFACE */
2220
2221 return 0;
2222
2223#endif /* PROC_INTERFACE */ 2196#endif /* PROC_INTERFACE */
2224 2197 return 0;
2225} 2198}
2226 2199
2227EXPORT_SYMBOL(wd33c93_host_reset); 2200EXPORT_SYMBOL(wd33c93_host_reset);
@@ -2229,4 +2202,5 @@ EXPORT_SYMBOL(wd33c93_init);
2229EXPORT_SYMBOL(wd33c93_abort); 2202EXPORT_SYMBOL(wd33c93_abort);
2230EXPORT_SYMBOL(wd33c93_queuecommand); 2203EXPORT_SYMBOL(wd33c93_queuecommand);
2231EXPORT_SYMBOL(wd33c93_intr); 2204EXPORT_SYMBOL(wd33c93_intr);
2232EXPORT_SYMBOL(wd33c93_proc_info); 2205EXPORT_SYMBOL(wd33c93_show_info);
2206EXPORT_SYMBOL(wd33c93_write_info);
diff --git a/drivers/scsi/wd33c93.h b/drivers/scsi/wd33c93.h
index 3b463d7304dc..08abe508e9ad 100644
--- a/drivers/scsi/wd33c93.h
+++ b/drivers/scsi/wd33c93.h
@@ -345,7 +345,8 @@ void wd33c93_init (struct Scsi_Host *instance, const wd33c93_regs regs,
345int wd33c93_abort (struct scsi_cmnd *cmd); 345int wd33c93_abort (struct scsi_cmnd *cmd);
346int wd33c93_queuecommand (struct Scsi_Host *h, struct scsi_cmnd *cmd); 346int wd33c93_queuecommand (struct Scsi_Host *h, struct scsi_cmnd *cmd);
347void wd33c93_intr (struct Scsi_Host *instance); 347void wd33c93_intr (struct Scsi_Host *instance);
348int wd33c93_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int); 348int wd33c93_show_info(struct seq_file *, struct Scsi_Host *);
349int wd33c93_write_info(struct Scsi_Host *, char *, int);
349int wd33c93_host_reset (struct scsi_cmnd *); 350int wd33c93_host_reset (struct scsi_cmnd *);
350 351
351#endif /* WD33C93_H */ 352#endif /* WD33C93_H */
diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index d89a5dfd3ade..f9a6e4b0affe 100644
--- a/drivers/scsi/wd7000.c
+++ b/drivers/scsi/wd7000.c
@@ -1296,9 +1296,9 @@ static void wd7000_revision(Adapter * host)
1296 1296
1297 1297
1298#undef SPRINTF 1298#undef SPRINTF
1299#define SPRINTF(args...) { if (pos < (buffer + length)) pos += sprintf (pos, ## args); } 1299#define SPRINTF(args...) { seq_printf(m, ## args); }
1300 1300
1301static int wd7000_set_info(char *buffer, int length, struct Scsi_Host *host) 1301static int wd7000_set_info(struct Scsi_Host *host, char *buffer, int length)
1302{ 1302{
1303 dprintk("Buffer = <%.*s>, length = %d\n", length, buffer, length); 1303 dprintk("Buffer = <%.*s>, length = %d\n", length, buffer, length);
1304 1304
@@ -1310,22 +1310,15 @@ static int wd7000_set_info(char *buffer, int length, struct Scsi_Host *host)
1310} 1310}
1311 1311
1312 1312
1313static int wd7000_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout) 1313static int wd7000_show_info(struct seq_file *m, struct Scsi_Host *host)
1314{ 1314{
1315 Adapter *adapter = (Adapter *)host->hostdata; 1315 Adapter *adapter = (Adapter *)host->hostdata;
1316 unsigned long flags; 1316 unsigned long flags;
1317 char *pos = buffer;
1318#ifdef WD7000_DEBUG 1317#ifdef WD7000_DEBUG
1319 Mailbox *ogmbs, *icmbs; 1318 Mailbox *ogmbs, *icmbs;
1320 short count; 1319 short count;
1321#endif 1320#endif
1322 1321
1323 /*
1324 * Has data been written to the file ?
1325 */
1326 if (inout)
1327 return (wd7000_set_info(buffer, length, host));
1328
1329 spin_lock_irqsave(host->host_lock, flags); 1322 spin_lock_irqsave(host->host_lock, flags);
1330 SPRINTF("Host scsi%d: Western Digital WD-7000 (rev %d.%d)\n", host->host_no, adapter->rev1, adapter->rev2); 1323 SPRINTF("Host scsi%d: Western Digital WD-7000 (rev %d.%d)\n", host->host_no, adapter->rev1, adapter->rev2);
1331 SPRINTF(" IO base: 0x%x\n", adapter->iobase); 1324 SPRINTF(" IO base: 0x%x\n", adapter->iobase);
@@ -1368,17 +1361,7 @@ static int wd7000_proc_info(struct Scsi_Host *host, char *buffer, char **start,
1368 1361
1369 spin_unlock_irqrestore(host->host_lock, flags); 1362 spin_unlock_irqrestore(host->host_lock, flags);
1370 1363
1371 /* 1364 return 0;
1372 * Calculate start of next buffer, and return value.
1373 */
1374 *start = buffer + offset;
1375
1376 if ((pos - buffer) < offset)
1377 return (0);
1378 else if ((pos - buffer - offset) < length)
1379 return (pos - buffer - offset);
1380 else
1381 return (length);
1382} 1365}
1383 1366
1384 1367
@@ -1413,7 +1396,8 @@ static __init int wd7000_detect(struct scsi_host_template *tpnt)
1413 for (i = 0; i < NUM_CONFIGS; biosptr[i++] = -1); 1396 for (i = 0; i < NUM_CONFIGS; biosptr[i++] = -1);
1414 1397
1415 tpnt->proc_name = "wd7000"; 1398 tpnt->proc_name = "wd7000";
1416 tpnt->proc_info = &wd7000_proc_info; 1399 tpnt->show_info = &wd7000_show_info;
1400 tpnt->write_info = wd7000_set_info;
1417 1401
1418 /* 1402 /*
1419 * Set up SCB free list, which is shared by all adapters 1403 * Set up SCB free list, which is shared by all adapters
@@ -1658,7 +1642,8 @@ MODULE_LICENSE("GPL");
1658 1642
1659static struct scsi_host_template driver_template = { 1643static struct scsi_host_template driver_template = {
1660 .proc_name = "wd7000", 1644 .proc_name = "wd7000",
1661 .proc_info = wd7000_proc_info, 1645 .show_info = wd7000_show_info,
1646 .write_info = wd7000_set_info,
1662 .name = "Western Digital WD-7000", 1647 .name = "Western Digital WD-7000",
1663 .detect = wd7000_detect, 1648 .detect = wd7000_detect,
1664 .release = wd7000_release, 1649 .release = wd7000_release,
diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c
index 362c214bcc0b..db790f9fc9db 100644
--- a/drivers/staging/comedi/proc.c
+++ b/drivers/staging/comedi/proc.c
@@ -31,17 +31,15 @@
31#include "comedidev.h" 31#include "comedidev.h"
32#include "comedi_internal.h" 32#include "comedi_internal.h"
33#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
34#include <linux/string.h> 34#include <linux/seq_file.h>
35 35
36static int comedi_read(char *buf, char **start, off_t offset, int len, 36static int comedi_read(struct seq_file *m, void *v)
37 int *eof, void *data)
38{ 37{
39 int i; 38 int i;
40 int devices_q = 0; 39 int devices_q = 0;
41 int l = 0;
42 struct comedi_driver *driv; 40 struct comedi_driver *driv;
43 41
44 l += sprintf(buf + l, 42 seq_printf(m,
45 "comedi version " COMEDI_RELEASE "\n" 43 "comedi version " COMEDI_RELEASE "\n"
46 "format string: %s\n", 44 "format string: %s\n",
47 "\"%2d: %-20s %-20s %4d\", i, " 45 "\"%2d: %-20s %-20s %4d\", i, "
@@ -49,42 +47,51 @@ static int comedi_read(char *buf, char **start, off_t offset, int len,
49 47
50 for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { 48 for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
51 struct comedi_device *dev = comedi_dev_from_minor(i); 49 struct comedi_device *dev = comedi_dev_from_minor(i);
52
53 if (!dev) 50 if (!dev)
54 continue; 51 continue;
55 52
56 if (dev->attached) { 53 if (dev->attached) {
57 devices_q = 1; 54 devices_q = 1;
58 l += sprintf(buf + l, "%2d: %-20s %-20s %4d\n", 55 seq_printf(m, "%2d: %-20s %-20s %4d\n",
59 i, 56 i, dev->driver->driver_name,
60 dev->driver->driver_name, 57 dev->board_name, dev->n_subdevices);
61 dev->board_name, dev->n_subdevices);
62 } 58 }
63 } 59 }
64 if (!devices_q) 60 if (!devices_q)
65 l += sprintf(buf + l, "no devices\n"); 61 seq_puts(m, "no devices\n");
66 62
67 for (driv = comedi_drivers; driv; driv = driv->next) { 63 for (driv = comedi_drivers; driv; driv = driv->next) {
68 l += sprintf(buf + l, "%s:\n", driv->driver_name); 64 seq_printf(m, "%s:\n", driv->driver_name);
69 for (i = 0; i < driv->num_names; i++) { 65 for (i = 0; i < driv->num_names; i++)
70 l += sprintf(buf + l, " %s\n", 66 seq_printf(m, " %s\n",
71 *(char **)((char *)driv->board_name + 67 *(char **)((char *)driv->board_name +
72 i * driv->offset)); 68 i * driv->offset));
73 } 69
74 if (!driv->num_names) 70 if (!driv->num_names)
75 l += sprintf(buf + l, " %s\n", driv->driver_name); 71 seq_printf(m, " %s\n", driv->driver_name);
76 } 72 }
77 73
78 return l; 74 return 0;
79} 75}
80 76
81void comedi_proc_init(void) 77/*
78 * seq_file wrappers for procfile show routines.
79 */
80static int comedi_proc_open(struct inode *inode, struct file *file)
82{ 81{
83 struct proc_dir_entry *comedi_proc; 82 return single_open(file, comedi_read, NULL);
83}
84
85static const struct file_operations comedi_proc_fops = {
86 .open = comedi_proc_open,
87 .read = seq_read,
88 .llseek = seq_lseek,
89 .release = seq_release,
90};
84 91
85 comedi_proc = create_proc_entry("comedi", S_IFREG | S_IRUGO, NULL); 92void comedi_proc_init(void)
86 if (comedi_proc) 93{
87 comedi_proc->read_proc = comedi_read; 94 proc_create("comedi", 0644, NULL, &comedi_proc_fops);
88} 95}
89 96
90void comedi_proc_cleanup(void) 97void comedi_proc_cleanup(void)
diff --git a/drivers/staging/csr/csr_wifi_hip_udi.c b/drivers/staging/csr/csr_wifi_hip_udi.c
index a65b822db698..a6b006b0e983 100644
--- a/drivers/staging/csr/csr_wifi_hip_udi.c
+++ b/drivers/staging/csr/csr_wifi_hip_udi.c
@@ -24,10 +24,50 @@
24 * 24 *
25 * --------------------------------------------------------------------------- 25 * ---------------------------------------------------------------------------
26 */ 26 */
27#include <linux/seq_file.h>
27#include "csr_wifi_hip_unifi.h" 28#include "csr_wifi_hip_unifi.h"
28#include "csr_wifi_hip_card.h" 29#include "csr_wifi_hip_card.h"
29 30
30 31
32static void unifi_print_unsafe_sdio_status(card_t *card, struct seq_file *m)
33{
34#ifdef CSR_UNSAFE_SDIO_ACCESS
35 s32 iostate;
36 CsrResult r;
37 static const char *const states[] = {
38 "AWAKE", "DROWSY", "TORPID"
39 };
40#define SHARED_READ_RETRY_LIMIT 10
41 u8 b;
42
43 seq_printf(m, "Host State: %s\n", states[card->host_state]);
44
45 r = unifi_check_io_status(card, &iostate);
46 if (iostate == 1) {
47 seq_puts(m, remaining, "I/O Check: F1 disabled\n");
48 } else {
49 if (iostate == 1) {
50 seq_puts(m, "I/O Check: pending interrupt\n");
51
52 seq_printf(m, "BH reason interrupt = %d\n", card->bh_reason_unifi);
53 seq_printf(m, "BH reason host = %d\n", card->bh_reason_host);
54
55 for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++) {
56 r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b);
57 if (r == CSR_RESULT_SUCCESS && !(b & 0x80)) {
58 seq_printf(m, "fhsr: %u (driver thinks is %u)\n",
59 b, card->from_host_signals_r);
60 break;
61 }
62 }
63
64 iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
65 seq_printf(m, "thsw: %u (driver thinks is %u)\n",
66 iostate, card->to_host_signals_w);
67 }
68#endif
69}
70
31/* 71/*
32 * --------------------------------------------------------------------------- 72 * ---------------------------------------------------------------------------
33 * unifi_print_status 73 * unifi_print_status
@@ -41,228 +81,93 @@
41 * None. 81 * None.
42 * --------------------------------------------------------------------------- 82 * ---------------------------------------------------------------------------
43 */ 83 */
44s32 unifi_print_status(card_t *card, char *str, s32 *remain) 84s32 unifi_print_status(card_t *card, struct seq_file *m)
45{ 85{
46 char *p = str; 86 sdio_config_data_t *cfg;
47 sdio_config_data_t *cfg; 87 u16 i, n;
48 u16 i, n; 88
49 s32 remaining = *remain; 89 i = n = 0;
50 s32 written; 90 seq_printf(m, "Chip ID %u\n", card->chip_id);
51#ifdef CSR_UNSAFE_SDIO_ACCESS 91 seq_printf(m, "Chip Version %04X\n", card->chip_version);
52 s32 iostate; 92 seq_printf(m, "HIP v%u.%u\n",
53 CsrResult r; 93 (card->config_data.version >> 8) & 0xFF,
54 static const char *const states[] = { 94 card->config_data.version & 0xFF);
55 "AWAKE", "DROWSY", "TORPID" 95 seq_printf(m, "Build %u: %s\n", card->build_id, card->build_id_string);
56 }; 96
57 #define SHARED_READ_RETRY_LIMIT 10 97 cfg = &card->config_data;
58 u8 b; 98
59#endif 99 seq_printf(m, "sdio ctrl offset %u\n", cfg->sdio_ctrl_offset);
60 100 seq_printf(m, "fromhost sigbuf handle %u\n", cfg->fromhost_sigbuf_handle);
61 if (remaining <= 0) 101 seq_printf(m, "tohost_sigbuf_handle %u\n", cfg->tohost_sigbuf_handle);
62 { 102 seq_printf(m, "num_fromhost_sig_frags %u\n", cfg->num_fromhost_sig_frags);
63 return 0; 103 seq_printf(m, "num_tohost_sig_frags %u\n", cfg->num_tohost_sig_frags);
64 } 104 seq_printf(m, "num_fromhost_data_slots %u\n", cfg->num_fromhost_data_slots);
65 105 seq_printf(m, "num_tohost_data_slots %u\n", cfg->num_tohost_data_slots);
66 i = n = 0; 106 seq_printf(m, "data_slot_size %u\n", cfg->data_slot_size);
67 written = scnprintf(p, remaining, "Chip ID %u\n", 107
68 (u16)card->chip_id); 108 /* Added by protocol version 0x0001 */
69 UNIFI_SNPRINTF_RET(p, remaining, written); 109 seq_printf(m, "overlay_size %u\n", cfg->overlay_size);
70 written = scnprintf(p, remaining, "Chip Version %04X\n", 110
71 card->chip_version); 111 /* Added by protocol version 0x0300 */
72 UNIFI_SNPRINTF_RET(p, remaining, written); 112 seq_printf(m, "data_slot_round %u\n", cfg->data_slot_round);
73 written = scnprintf(p, remaining, "HIP v%u.%u\n", 113 seq_printf(m, "sig_frag_size %u\n", cfg->sig_frag_size);
74 (card->config_data.version >> 8) & 0xFF, 114
75 card->config_data.version & 0xFF); 115 /* Added by protocol version 0x0300 */
76 UNIFI_SNPRINTF_RET(p, remaining, written); 116 seq_printf(m, "tohost_sig_pad %u\n", cfg->tohost_signal_padding);
77 written = scnprintf(p, remaining, "Build %u: %s\n", 117
78 card->build_id, card->build_id_string); 118 seq_puts(m, "\nInternal state:\n");
79 UNIFI_SNPRINTF_RET(p, remaining, written); 119
80 120 seq_printf(m, "Last PHY PANIC: %04x:%04x\n",
81 cfg = &card->config_data; 121 card->last_phy_panic_code, card->last_phy_panic_arg);
82 122 seq_printf(m, "Last MAC PANIC: %04x:%04x\n",
83 written = scnprintf(p, remaining, "sdio ctrl offset %u\n", 123 card->last_mac_panic_code, card->last_mac_panic_arg);
84 cfg->sdio_ctrl_offset); 124
85 UNIFI_SNPRINTF_RET(p, remaining, written); 125 seq_printf(m, "fhsr: %hu\n", (u16)card->from_host_signals_r);
86 written = scnprintf(p, remaining, "fromhost sigbuf handle %u\n", 126 seq_printf(m, "fhsw: %hu\n", (u16)card->from_host_signals_w);
87 cfg->fromhost_sigbuf_handle); 127 seq_printf(m, "thsr: %hu\n", (u16)card->to_host_signals_r);
88 UNIFI_SNPRINTF_RET(p, remaining, written); 128 seq_printf(m, "thsw: %hu\n", (u16)card->to_host_signals_w);
89 written = scnprintf(p, remaining, "tohost_sigbuf_handle %u\n", 129 seq_printf(m, "fh buffer contains: %d signals, %td bytes\n",
90 cfg->tohost_sigbuf_handle); 130 card->fh_buffer.count,
91 UNIFI_SNPRINTF_RET(p, remaining, written); 131 card->fh_buffer.ptr - card->fh_buffer.buf);
92 written = scnprintf(p, remaining, "num_fromhost_sig_frags %u\n", 132
93 cfg->num_fromhost_sig_frags); 133 seq_puts(m, "paused: ");
94 UNIFI_SNPRINTF_RET(p, remaining, written); 134 for (i = 0; i < ARRAY_SIZE(card->tx_q_paused_flag); i++)
95 written = scnprintf(p, remaining, "num_tohost_sig_frags %u\n", 135 seq_printf(m, card->tx_q_paused_flag[i] ? "1" : "0");
96 cfg->num_tohost_sig_frags); 136 seq_putc(m, '\n');
97 UNIFI_SNPRINTF_RET(p, remaining, written); 137
98 written = scnprintf(p, remaining, "num_fromhost_data_slots %u\n", 138 seq_printf(m, "fh command q: %u waiting, %u free of %u:\n",
99 cfg->num_fromhost_data_slots); 139 CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue),
100 UNIFI_SNPRINTF_RET(p, remaining, written); 140 CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue),
101 written = scnprintf(p, remaining, "num_tohost_data_slots %u\n", 141 UNIFI_SOFT_COMMAND_Q_LENGTH);
102 cfg->num_tohost_data_slots); 142
103 UNIFI_SNPRINTF_RET(p, remaining, written); 143 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
104 written = scnprintf(p, remaining, "data_slot_size %u\n", 144 seq_printf(m, "fh traffic q[%u]: %u waiting, %u free of %u:\n",
105 cfg->data_slot_size); 145 i,
106 UNIFI_SNPRINTF_RET(p, remaining, written); 146 CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]),
107 147 CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[i]),
108 /* Added by protocol version 0x0001 */ 148 UNIFI_SOFT_TRAFFIC_Q_LENGTH);
109 written = scnprintf(p, remaining, "overlay_size %u\n", 149
110 (u16)cfg->overlay_size); 150 seq_printf(m, "fh data slots free: %u\n",
111 UNIFI_SNPRINTF_RET(p, remaining, written); 151 card->from_host_data ? CardGetFreeFromHostDataSlots(card) : 0);
112 152
113 /* Added by protocol version 0x0300 */ 153 seq_puts(m, "From host data slots:");
114 written = scnprintf(p, remaining, "data_slot_round %u\n", 154 n = card->config_data.num_fromhost_data_slots;
115 cfg->data_slot_round); 155 for (i = 0; i < n && card->from_host_data; i++)
116 UNIFI_SNPRINTF_RET(p, remaining, written); 156 seq_printf(m, " %hu", (u16)card->from_host_data[i].bd.data_length);
117 written = scnprintf(p, remaining, "sig_frag_size %u\n", 157 seq_putc(m, '\n');
118 cfg->sig_frag_size); 158
119 UNIFI_SNPRINTF_RET(p, remaining, written); 159 seq_puts(m, "To host data slots:");
120 160 n = card->config_data.num_tohost_data_slots;
121 /* Added by protocol version 0x0300 */ 161 for (i = 0; i < n && card->to_host_data; i++)
122 written = scnprintf(p, remaining, "tohost_sig_pad %u\n", 162 seq_printf(m, " %hu", (u16)card->to_host_data[i].data_length);
123 cfg->tohost_signal_padding); 163 seq_putc(m, '\n');
124 UNIFI_SNPRINTF_RET(p, remaining, written); 164
125 165 unifi_print_unsafe_sdio_status(card, m);
126 written = scnprintf(p, remaining, "\nInternal state:\n"); 166
127 UNIFI_SNPRINTF_RET(p, remaining, written); 167 seq_puts(m, "\nStats:\n");
128 168 seq_printf(m, "Total SDIO bytes: R=%u W=%u\n",
129 written = scnprintf(p, remaining, "Last PHY PANIC: %04x:%04x\n", 169 card->sdio_bytes_read, card->sdio_bytes_written);
130 card->last_phy_panic_code, card->last_phy_panic_arg); 170
131 UNIFI_SNPRINTF_RET(p, remaining, written); 171 seq_printf(m, "Interrupts generated on card: %u\n", card->unifi_interrupt_seq);
132 written = scnprintf(p, remaining, "Last MAC PANIC: %04x:%04x\n", 172 return 0;
133 card->last_mac_panic_code, card->last_mac_panic_arg); 173}
134 UNIFI_SNPRINTF_RET(p, remaining, written);
135
136 written = scnprintf(p, remaining, "fhsr: %u\n",
137 (u16)card->from_host_signals_r);
138 UNIFI_SNPRINTF_RET(p, remaining, written);
139 written = scnprintf(p, remaining, "fhsw: %u\n",
140 (u16)card->from_host_signals_w);
141 UNIFI_SNPRINTF_RET(p, remaining, written);
142 written = scnprintf(p, remaining, "thsr: %u\n",
143 (u16)card->to_host_signals_r);
144 UNIFI_SNPRINTF_RET(p, remaining, written);
145 written = scnprintf(p, remaining, "thsw: %u\n",
146 (u16)card->to_host_signals_w);
147 UNIFI_SNPRINTF_RET(p, remaining, written);
148 written = scnprintf(p, remaining,
149 "fh buffer contains: %d signals, %td bytes\n",
150 card->fh_buffer.count,
151 card->fh_buffer.ptr - card->fh_buffer.buf);
152 UNIFI_SNPRINTF_RET(p, remaining, written);
153
154 written = scnprintf(p, remaining, "paused: ");
155 UNIFI_SNPRINTF_RET(p, remaining, written);
156 for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++)
157 {
158 written = scnprintf(p, remaining, card->tx_q_paused_flag[i]?"1" : "0");
159 UNIFI_SNPRINTF_RET(p, remaining, written);
160 }
161 written = scnprintf(p, remaining, "\n");
162 UNIFI_SNPRINTF_RET(p, remaining, written);
163
164 written = scnprintf(p, remaining,
165 "fh command q: %u waiting, %u free of %u:\n",
166 CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue),
167 CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue),
168 UNIFI_SOFT_COMMAND_Q_LENGTH);
169 UNIFI_SNPRINTF_RET(p, remaining, written);
170 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
171 {
172 written = scnprintf(p, remaining,
173 "fh traffic q[%u]: %u waiting, %u free of %u:\n",
174 i,
175 CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]),
176 CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[i]),
177 UNIFI_SOFT_TRAFFIC_Q_LENGTH);
178 UNIFI_SNPRINTF_RET(p, remaining, written);
179 }
180
181 written = scnprintf(p, remaining, "fh data slots free: %u\n",
182 card->from_host_data?CardGetFreeFromHostDataSlots(card) : 0);
183 UNIFI_SNPRINTF_RET(p, remaining, written);
184
185
186 written = scnprintf(p, remaining, "From host data slots:");
187 UNIFI_SNPRINTF_RET(p, remaining, written);
188 n = card->config_data.num_fromhost_data_slots;
189 for (i = 0; i < n && card->from_host_data; i++)
190 {
191 written = scnprintf(p, remaining, " %u",
192 (u16)card->from_host_data[i].bd.data_length);
193 UNIFI_SNPRINTF_RET(p, remaining, written);
194 }
195 written = scnprintf(p, remaining, "\n");
196 UNIFI_SNPRINTF_RET(p, remaining, written);
197
198 written = scnprintf(p, remaining, "To host data slots:");
199 UNIFI_SNPRINTF_RET(p, remaining, written);
200 n = card->config_data.num_tohost_data_slots;
201 for (i = 0; i < n && card->to_host_data; i++)
202 {
203 written = scnprintf(p, remaining, " %u",
204 (u16)card->to_host_data[i].data_length);
205 UNIFI_SNPRINTF_RET(p, remaining, written);
206 }
207
208 written = scnprintf(p, remaining, "\n");
209 UNIFI_SNPRINTF_RET(p, remaining, written);
210
211#ifdef CSR_UNSAFE_SDIO_ACCESS
212 written = scnprintf(p, remaining, "Host State: %s\n", states[card->host_state]);
213 UNIFI_SNPRINTF_RET(p, remaining, written);
214
215 r = unifi_check_io_status(card, &iostate);
216 if (iostate == 1)
217 {
218 written = scnprintf(p, remaining, "I/O Check: F1 disabled\n");
219 UNIFI_SNPRINTF_RET(p, remaining, written);
220 }
221 else
222 {
223 if (iostate == 1)
224 {
225 written = scnprintf(p, remaining, "I/O Check: pending interrupt\n");
226 UNIFI_SNPRINTF_RET(p, remaining, written);
227 }
228
229 written = scnprintf(p, remaining, "BH reason interrupt = %d\n",
230 card->bh_reason_unifi);
231 UNIFI_SNPRINTF_RET(p, remaining, written);
232 written = scnprintf(p, remaining, "BH reason host = %d\n",
233 card->bh_reason_host);
234 UNIFI_SNPRINTF_RET(p, remaining, written);
235
236 for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++)
237 {
238 r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b);
239 if ((r == CSR_RESULT_SUCCESS) && (!(b & 0x80)))
240 {
241 written = scnprintf(p, remaining, "fhsr: %u (driver thinks is %u)\n",
242 b, card->from_host_signals_r);
243 UNIFI_SNPRINTF_RET(p, remaining, written);
244 break;
245 }
246 }
247 iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
248 written = scnprintf(p, remaining, "thsw: %u (driver thinks is %u)\n",
249 iostate, card->to_host_signals_w);
250 UNIFI_SNPRINTF_RET(p, remaining, written);
251 }
252#endif
253
254 written = scnprintf(p, remaining, "\nStats:\n");
255 UNIFI_SNPRINTF_RET(p, remaining, written);
256 written = scnprintf(p, remaining, "Total SDIO bytes: R=%u W=%u\n",
257 card->sdio_bytes_read, card->sdio_bytes_written);
258
259 UNIFI_SNPRINTF_RET(p, remaining, written);
260 written = scnprintf(p, remaining, "Interrupts generated on card: %u\n",
261 card->unifi_interrupt_seq);
262 UNIFI_SNPRINTF_RET(p, remaining, written);
263
264 *remain = remaining;
265 return (p - str);
266} /* unifi_print_status() */
267
268
diff --git a/drivers/staging/csr/csr_wifi_hip_unifi_udi.h b/drivers/staging/csr/csr_wifi_hip_unifi_udi.h
index 9d85cfd57616..4126e85bfe9b 100644
--- a/drivers/staging/csr/csr_wifi_hip_unifi_udi.h
+++ b/drivers/staging/csr/csr_wifi_hip_unifi_udi.h
@@ -47,21 +47,6 @@ CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn);
47 * This is used in the linux /proc interface and might be useful 47 * This is used in the linux /proc interface and might be useful
48 * in other systems. 48 * in other systems.
49 */ 49 */
50s32 unifi_print_status(card_t *card, char *str, s32 *remain); 50s32 unifi_print_status(card_t *card, struct seq_file *m);
51
52#define UNIFI_SNPRINTF_RET(buf_p, remain, written) \
53 do { \
54 if (written >= remain) { \
55 if (remain >= 2) { \
56 buf_p[remain - 2] = '\n'; \
57 buf_p[remain - 1] = 0; \
58 } \
59 buf_p += remain; \
60 remain = 0; \
61 } else if (written > 0) { \
62 buf_p += written; \
63 remain -= written; \
64 } \
65 } while (0)
66 51
67#endif /* __CSR_WIFI_HIP_UNIFI_UDI_H__ */ 52#endif /* __CSR_WIFI_HIP_UNIFI_UDI_H__ */
diff --git a/drivers/staging/csr/drv.c b/drivers/staging/csr/drv.c
index 5520d6539f77..bdc25236ab00 100644
--- a/drivers/staging/csr/drv.c
+++ b/drivers/staging/csr/drv.c
@@ -1941,7 +1941,7 @@ uf_sme_queue_message(unifi_priv_t *priv, u8 *buffer, int length)
1941 * 1941 *
1942 **************************************************************************** 1942 ****************************************************************************
1943 */ 1943 */
1944static struct file_operations unifi_fops = { 1944static const struct file_operations unifi_fops = {
1945 .owner = THIS_MODULE, 1945 .owner = THIS_MODULE,
1946 .open = unifi_open, 1946 .open = unifi_open,
1947 .release = unifi_release, 1947 .release = unifi_release,
@@ -2041,7 +2041,7 @@ void uf_destroy_device_nodes(unifi_priv_t *priv)
2041 * ---------------------------------------------------------------- 2041 * ----------------------------------------------------------------
2042 */ 2042 */
2043static int 2043static int
2044uf_create_debug_device(struct file_operations *fops) 2044uf_create_debug_device(const struct file_operations *fops)
2045{ 2045{
2046 int ret; 2046 int ret;
2047 2047
diff --git a/drivers/staging/csr/io.c b/drivers/staging/csr/io.c
index af9c28f073b9..f9b5c22c00b8 100644
--- a/drivers/staging/csr/io.c
+++ b/drivers/staging/csr/io.c
@@ -31,6 +31,7 @@
31 * --------------------------------------------------------------------------- 31 * ---------------------------------------------------------------------------
32 */ 32 */
33#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
34#include <linux/seq_file.h>
34 35
35#include "csr_wifi_hip_unifi.h" 36#include "csr_wifi_hip_unifi.h"
36#include "csr_wifi_hip_unifiversion.h" 37#include "csr_wifi_hip_unifiversion.h"
@@ -76,9 +77,28 @@ DEFINE_SEMAPHORE(Unifi_instance_mutex);
76 */ 77 */
77DECLARE_WAIT_QUEUE_HEAD(Unifi_cleanup_wq); 78DECLARE_WAIT_QUEUE_HEAD(Unifi_cleanup_wq);
78 79
80#ifdef CONFIG_PROC_FS
81/*
82 * seq_file wrappers for procfile show routines.
83 */
84static int uf_proc_show(struct seq_file *m, void *v);
85
86#define UNIFI_DEBUG_TXT_BUFFER (8 * 1024)
87
88static int uf_proc_open(struct inode *inode, struct file *file)
89{
90 return single_open_size(file, uf_proc_show, PDE_DATA(inode),
91 UNIFI_DEBUG_TXT_BUFFER);
92}
93
94static const struct file_operations uf_proc_fops = {
95 .open = uf_proc_open,
96 .read = seq_read,
97 .llseek = seq_lseek,
98 .release = seq_release,
99};
79 100
80static int uf_read_proc(char *page, char **start, off_t offset, int count, 101#endif /* CONFIG_PROC_FS */
81 int *eof, void *data);
82 102
83#ifdef CSR_WIFI_RX_PATH_SPLIT 103#ifdef CSR_WIFI_RX_PATH_SPLIT
84 104
@@ -327,8 +347,8 @@ register_unifi_sdio(CsrSdioFunction *sdio_dev, int bus_id, struct device *dev)
327 * The following complex casting is in place in order to eliminate 64-bit compilation warning 347 * The following complex casting is in place in order to eliminate 64-bit compilation warning
328 * "cast to/from pointer from/to integer of different size" 348 * "cast to/from pointer from/to integer of different size"
329 */ 349 */
330 if (!create_proc_read_entry(priv->proc_entry_name, 0, 0, 350 if (!proc_create_data(priv->proc_entry_name, 0, NULL,
331 uf_read_proc, (void *)(long)priv->instance)) 351 &uf_proc_fops, (void *)(long)priv->instance))
332 { 352 {
333 unifi_error(priv, "unifi: can't create /proc/driver/unifi\n"); 353 unifi_error(priv, "unifi: can't create /proc/driver/unifi\n");
334 } 354 }
@@ -827,7 +847,7 @@ uf_put_instance(int inst)
827 847
828/* 848/*
829 * --------------------------------------------------------------------------- 849 * ---------------------------------------------------------------------------
830 * uf_read_proc 850 * uf_proc_show
831 * 851 *
832 * Read method for driver node in /proc/driver/unifi0 852 * Read method for driver node in /proc/driver/unifi0
833 * 853 *
@@ -844,107 +864,54 @@ uf_put_instance(int inst)
844 * --------------------------------------------------------------------------- 864 * ---------------------------------------------------------------------------
845 */ 865 */
846#ifdef CONFIG_PROC_FS 866#ifdef CONFIG_PROC_FS
847static int 867static int uf_proc_show(struct seq_file *m, void *v)
848uf_read_proc(char *page, char **start, off_t offset, int count,
849 int *eof, void *data)
850{ 868{
851#define UNIFI_DEBUG_TXT_BUFFER 8*1024 869 unifi_priv_t *priv;
852 unifi_priv_t *priv; 870 int i;
853 int actual_amount_to_copy; 871
854 char *p, *orig_p; 872 /*
855 s32 remain = UNIFI_DEBUG_TXT_BUFFER; 873 * The following complex casting is in place in order to eliminate
856 s32 written; 874 * 64-bit compilation warning "cast to/from pointer from/to integer of
857 int i; 875 * different size"
858 876 */
859 /* 877 priv = uf_find_instance((long)m->private);
860 * The following complex casting is in place in order to eliminate 64-bit compilation warning 878 if (!priv)
861 * "cast to/from pointer from/to integer of different size" 879 return 0;
862 */ 880
863 priv = uf_find_instance((int)(long)data); 881 seq_printf(m, "UniFi SDIO Driver: %s %s %s\n",
864 if (!priv) { 882 CSR_WIFI_VERSION, __DATE__, __TIME__);
865 return 0;
866 }
867
868 p = kmalloc( UNIFI_DEBUG_TXT_BUFFER, GFP_KERNEL );
869
870 orig_p = p;
871
872 written = scnprintf(p, remain, "UniFi SDIO Driver: %s %s %s\n",
873 CSR_WIFI_VERSION, __DATE__, __TIME__);
874 UNIFI_SNPRINTF_RET(p, remain, written);
875#ifdef CSR_SME_USERSPACE 883#ifdef CSR_SME_USERSPACE
876 written = scnprintf(p, remain, "SME: CSR userspace "); 884 seq_puts(m, "SME: CSR userspace ");
877 UNIFI_SNPRINTF_RET(p, remain, written);
878#ifdef CSR_SUPPORT_WEXT 885#ifdef CSR_SUPPORT_WEXT
879 written = scnprintf(p, remain, "with WEXT support\n"); 886 seq_puts(m, "with WEXT support\n");
880#else 887#else
881 written = scnprintf(p, remain, "\n"); 888 seq_putc(m, '\n');
882#endif /* CSR_SUPPORT_WEXT */ 889#endif /* CSR_SUPPORT_WEXT */
883 UNIFI_SNPRINTF_RET(p, remain, written);
884#endif /* CSR_SME_USERSPACE */ 890#endif /* CSR_SME_USERSPACE */
885#ifdef CSR_NATIVE_LINUX 891#ifdef CSR_NATIVE_LINUX
886 written = scnprintf(p, remain, "SME: native\n"); 892 seq_puts(m, "SME: native\n");
887 UNIFI_SNPRINTF_RET(p, remain, written);
888#endif 893#endif
889 894
890#ifdef CSR_SUPPORT_SME 895#ifdef CSR_SUPPORT_SME
891 written = scnprintf(p, remain, 896 seq_printf(m, "Firmware (ROM) build:%u, Patch:%u\n",
892 "Firmware (ROM) build:%u, Patch:%u\n", 897 priv->card_info.fw_build,
893 priv->card_info.fw_build, 898 priv->sme_versions.firmwarePatch);
894 priv->sme_versions.firmwarePatch);
895 UNIFI_SNPRINTF_RET(p, remain, written);
896#endif 899#endif
897 p += unifi_print_status(priv->card, p, &remain);
898
899 written = scnprintf(p, remain, "Last dbg str: %s\n",
900 priv->last_debug_string);
901 UNIFI_SNPRINTF_RET(p, remain, written);
902
903 written = scnprintf(p, remain, "Last dbg16:");
904 UNIFI_SNPRINTF_RET(p, remain, written);
905 for (i = 0; i < 8; i++) {
906 written = scnprintf(p, remain, " %04X",
907 priv->last_debug_word16[i]);
908 UNIFI_SNPRINTF_RET(p, remain, written);
909 }
910 written = scnprintf(p, remain, "\n");
911 UNIFI_SNPRINTF_RET(p, remain, written);
912 written = scnprintf(p, remain, " ");
913 UNIFI_SNPRINTF_RET(p, remain, written);
914 for (; i < 16; i++) {
915 written = scnprintf(p, remain, " %04X",
916 priv->last_debug_word16[i]);
917 UNIFI_SNPRINTF_RET(p, remain, written);
918 }
919 written = scnprintf(p, remain, "\n");
920 UNIFI_SNPRINTF_RET(p, remain, written);
921 *start = page;
922
923 written = UNIFI_DEBUG_TXT_BUFFER - remain;
924
925 if( offset >= written )
926 {
927 *eof = 1;
928 kfree( orig_p );
929 return(0);
930 }
931
932 if( offset + count > written )
933 {
934 actual_amount_to_copy = written - offset;
935 *eof = 1;
936 }
937 else
938 {
939 actual_amount_to_copy = count;
940 }
941 900
942 memcpy( page, &(orig_p[offset]), actual_amount_to_copy ); 901 unifi_print_status(priv->card, m);
943 902
944 kfree( orig_p ); 903 seq_printf(m, "Last dbg str: %s\n", priv->last_debug_string);
945 904
946 return( actual_amount_to_copy ); 905 seq_puts(m, "Last dbg16:");
947} /* uf_read_proc() */ 906 for (i = 0; i < 8; i++)
907 seq_printf(m, " %04X", priv->last_debug_word16[i]);
908 seq_putc(m, '\n');
909 seq_puts(m, " ");
910 for (; i < 16; i++)
911 seq_printf(m, " %04X", priv->last_debug_word16[i]);
912 seq_putc(m, '\n');
913 return 0;
914}
948#endif 915#endif
949 916
950 917
diff --git a/drivers/staging/cxt1e1/Makefile b/drivers/staging/cxt1e1/Makefile
index e99b82311823..b9ccb7650251 100644
--- a/drivers/staging/cxt1e1/Makefile
+++ b/drivers/staging/cxt1e1/Makefile
@@ -12,8 +12,9 @@ cxt1e1-y := \
12 linux.o \ 12 linux.o \
13 functions.o \ 13 functions.o \
14 hwprobe.o \ 14 hwprobe.o \
15 sbeproc.o \
16 pmc93x6_eeprom.o \ 15 pmc93x6_eeprom.o \
17 sbecrc.o \ 16 sbecrc.o \
18 comet_tables.o \ 17 comet_tables.o \
19 sbeid.o 18 sbeid.o
19
20cxt1e1-$(CONFIG_PROC_FS) += sbeproc.o
diff --git a/drivers/staging/cxt1e1/sbeproc.c b/drivers/staging/cxt1e1/sbeproc.c
index f42531c3d8da..49f10f0b7d29 100644
--- a/drivers/staging/cxt1e1/sbeproc.c
+++ b/drivers/staging/cxt1e1/sbeproc.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
22#include <linux/seq_file.h>
22#include <linux/sched.h> 23#include <linux/sched.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include "pmcc4_sysdep.h" 25#include "pmcc4_sysdep.h"
@@ -26,332 +27,193 @@
26#include "pmcc4_private.h" 27#include "pmcc4_private.h"
27#include "sbeproc.h" 28#include "sbeproc.h"
28 29
29/* forwards */ 30extern void sbecom_get_brdinfo(ci_t *, struct sbe_brd_info *, u_int8_t *);
30void sbecom_get_brdinfo (ci_t *, struct sbe_brd_info *, u_int8_t *);
31extern struct s_hdw_info hdw_info[MAX_BOARDS]; 31extern struct s_hdw_info hdw_info[MAX_BOARDS];
32 32
33#ifdef CONFIG_PROC_FS 33void sbecom_proc_brd_cleanup(ci_t *ci)
34
35/********************************************************************/
36/* procfs stuff */
37/********************************************************************/
38
39
40void
41sbecom_proc_brd_cleanup (ci_t * ci)
42{ 34{
43 if (ci->dir_dev) 35 if (ci->dir_dev) {
44 { 36 char dir[7 + SBE_IFACETMPL_SIZE + 1];
45 char dir[7 + SBE_IFACETMPL_SIZE + 1]; 37 snprintf(dir, sizeof(dir), "driver/%s", ci->devname);
46 snprintf(dir, sizeof(dir), "driver/%s", ci->devname); 38 remove_proc_entry("info", ci->dir_dev);
47 remove_proc_entry("info", ci->dir_dev); 39 remove_proc_entry(dir, NULL);
48 remove_proc_entry(dir, NULL); 40 ci->dir_dev = NULL;
49 ci->dir_dev = NULL; 41 }
50 }
51} 42}
52 43
53 44static void sbecom_proc_get_brdinfo(ci_t *ci, struct sbe_brd_info *bip)
54static int
55sbecom_proc_get_sbe_info (char *buffer, char **start, off_t offset,
56 int length, int *eof, void *priv)
57{ 45{
58 ci_t *ci = (ci_t *) priv; 46 hdw_info_t *hi = &hdw_info[ci->brdno];
59 int len = 0; 47 u_int8_t *bsn = 0;
60 char *spd; 48
61 struct sbe_brd_info *bip; 49 switch (hi->promfmt)
62 50 {
63 if (!(bip = OS_kmalloc (sizeof (struct sbe_brd_info)))) 51 case PROM_FORMAT_TYPE1:
64 { 52 bsn = (u_int8_t *) hi->mfg_info.pft1.Serial;
65 return -ENOMEM; 53 break;
66 } 54 case PROM_FORMAT_TYPE2:
67#if 0 55 bsn = (u_int8_t *) hi->mfg_info.pft2.Serial;
68 /** RLD DEBUG **/ 56 break;
69 pr_info(">> sbecom_proc_get_sbe_info: entered, offset %d. length %d.\n", 57 }
70 (int) offset, (int) length); 58
71#endif 59 sbecom_get_brdinfo (ci, bip, bsn);
72 60
73 { 61 pr_devel(">> sbecom_get_brdinfo: returned, first_if %p <%s> last_if %p <%s>\n",
74 hdw_info_t *hi = &hdw_info[ci->brdno]; 62 bip->first_iname, bip->first_iname,
75 63 bip->last_iname, bip->last_iname);
76 u_int8_t *bsn = 0; 64}
77
78 switch (hi->promfmt)
79 {
80 case PROM_FORMAT_TYPE1:
81 bsn = (u_int8_t *) hi->mfg_info.pft1.Serial;
82 break;
83 case PROM_FORMAT_TYPE2:
84 bsn = (u_int8_t *) hi->mfg_info.pft2.Serial;
85 break;
86 }
87
88 sbecom_get_brdinfo (ci, bip, bsn);
89 }
90
91#if 0
92 /** RLD DEBUG **/
93 pr_info(">> sbecom_get_brdinfo: returned, first_if %p <%s> last_if %p <%s>\n",
94 (char *) &bip->first_iname, (char *) &bip->first_iname,
95 (char *) &bip->last_iname, (char *) &bip->last_iname);
96#endif
97 len += sprintf (buffer + len, "Board Type: ");
98 switch (bip->brd_id)
99 {
100 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T3):
101 len += sprintf (buffer + len, "wanPMC-C1T3");
102 break;
103 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_E1):
104 len += sprintf (buffer + len, "wanPTMC-256T3 <E1>");
105 break;
106 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1):
107 len += sprintf (buffer + len, "wanPTMC-256T3 <T1>");
108 break;
109 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_C24TE1):
110 len += sprintf (buffer + len, "wanPTMC-C24TE1");
111 break;
112
113 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1):
114 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1_L):
115 len += sprintf (buffer + len, "wanPMC-C4T1E1");
116 break;
117 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1):
118 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1_L):
119 len += sprintf (buffer + len, "wanPMC-C2T1E1");
120 break;
121 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1):
122 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1_L):
123 len += sprintf (buffer + len, "wanPMC-C1T1E1");
124 break;
125
126 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1):
127 len += sprintf (buffer + len, "wanPCI-C4T1E1");
128 break;
129 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C2T1E1):
130 len += sprintf (buffer + len, "wanPCI-C2T1E1");
131 break;
132 case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C1T1E1):
133 len += sprintf (buffer + len, "wanPCI-C1T1E1");
134 break;
135
136 default:
137 len += sprintf (buffer + len, "unknown");
138 break;
139 }
140 len += sprintf (buffer + len, " [%08X]\n", bip->brd_id);
141 65
142 len += sprintf (buffer + len, "Board Number: %d\n", bip->brdno); 66/*
143 len += sprintf (buffer + len, "Hardware ID: 0x%02X\n", ci->hdw_bid); 67 * Describe the driver state through /proc
144 len += sprintf (buffer + len, "Board SN: %06X\n", bip->brd_sn); 68 */
145 len += sprintf(buffer + len, "Board MAC: %pMF\n", 69static int sbecom_proc_get_sbe_info(struct seq_file *m, void *v)
146 bip->brd_mac_addr); 70{
147 len += sprintf (buffer + len, "Ports: %d\n", ci->max_port); 71 ci_t *ci = m->private;
148 len += sprintf (buffer + len, "Channels: %d\n", bip->brd_chan_cnt); 72 char *spd;
73 struct sbe_brd_info *bip;
74
75 if (!(bip = OS_kmalloc(sizeof(struct sbe_brd_info))))
76 return -ENOMEM;
77
78 pr_devel(">> sbecom_proc_get_sbe_info: entered\n");
79
80 sbecom_proc_get_brdinfo(ci, bip);
81
82 seq_puts(m, "Board Type: ");
83 switch (bip->brd_id) {
84 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T3):
85 seq_puts(m, "wanPMC-C1T3");
86 break;
87 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_E1):
88 seq_puts(m, "wanPTMC-256T3 <E1>");
89 break;
90 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1):
91 seq_puts(m, "wanPTMC-256T3 <T1>");
92 break;
93 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_C24TE1):
94 seq_puts(m, "wanPTMC-C24TE1");
95 break;
96
97 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1):
98 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1_L):
99 seq_puts(m, "wanPMC-C4T1E1");
100 break;
101 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1):
102 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1_L):
103 seq_puts(m, "wanPMC-C2T1E1");
104 break;
105 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1):
106 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1_L):
107 seq_puts(m, "wanPMC-C1T1E1");
108 break;
109
110 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1):
111 seq_puts(m, "wanPCI-C4T1E1");
112 break;
113 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C2T1E1):
114 seq_puts(m, "wanPCI-C2T1E1");
115 break;
116 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C1T1E1):
117 seq_puts(m, "wanPCI-C1T1E1");
118 break;
119
120 default:
121 seq_puts(m, "unknown");
122 break;
123 }
124
125 seq_printf(m, " [%08X]\n", bip->brd_id);
126
127 seq_printf(m, "Board Number: %d\n", bip->brdno);
128 seq_printf(m, "Hardware ID: 0x%02X\n", ci->hdw_bid);
129 seq_printf(m, "Board SN: %06X\n", bip->brd_sn);
130 seq_printf(m, "Board MAC: %pMF\n", bip->brd_mac_addr);
131 seq_printf(m, "Ports: %d\n", ci->max_port);
132 seq_printf(m, "Channels: %d\n", bip->brd_chan_cnt);
149#if 1 133#if 1
150 len += sprintf (buffer + len, "Interface: %s -> %s\n", 134 seq_printf(m, "Interface: %s -> %s\n",
151 (char *) &bip->first_iname, (char *) &bip->last_iname); 135 bip->first_iname, bip->last_iname);
152#else 136#else
153 len += sprintf (buffer + len, "Interface: <not available> 1st %p lst %p\n", 137 seq_printf(m, "Interface: <not available> 1st %p lst %p\n",
154 (char *) &bip->first_iname, (char *) &bip->last_iname); 138 bip->first_iname, bip->last_iname);
155#endif 139#endif
156 140
157 switch (bip->brd_pci_speed) 141 switch (bip->brd_pci_speed) {
158 { 142 case BINFO_PCI_SPEED_33:
159 case BINFO_PCI_SPEED_33: 143 spd = "33Mhz";
160 spd = "33Mhz"; 144 break;
161 break; 145 case BINFO_PCI_SPEED_66:
162 case BINFO_PCI_SPEED_66: 146 spd = "66Mhz";
163 spd = "66Mhz"; 147 break;
164 break; 148 default:
165 default: 149 spd = "<not available>";
166 spd = "<not available>"; 150 break;
167 break; 151 }
168 } 152 seq_printf(m, "PCI Bus Speed: %s\n", spd);
169 len += sprintf (buffer + len, "PCI Bus Speed: %s\n", spd); 153 seq_printf(m, "Release: %s\n", ci->release);
170 len += sprintf (buffer + len, "Release: %s\n", ci->release);
171 154
172#ifdef SBE_PMCC4_ENABLE 155#ifdef SBE_PMCC4_ENABLE
173 { 156 {
174 extern int cxt1e1_max_mru; 157 extern int cxt1e1_max_mru;
175#if 0
176 extern int max_chans_used;
177 extern int cxt1e1_max_mtu;
178#endif
179 extern int max_rxdesc_used, max_txdesc_used;
180
181 len += sprintf (buffer + len, "\ncxt1e1_max_mru: %d\n", cxt1e1_max_mru);
182#if 0 158#if 0
183 len += sprintf (buffer + len, "\nmax_chans_used: %d\n", max_chans_used); 159 extern int max_chans_used;
184 len += sprintf (buffer + len, "cxt1e1_max_mtu: %d\n", cxt1e1_max_mtu); 160 extern int cxt1e1_max_mtu;
185#endif
186 len += sprintf (buffer + len, "max_rxdesc_used: %d\n", max_rxdesc_used);
187 len += sprintf (buffer + len, "max_txdesc_used: %d\n", max_txdesc_used);
188 }
189#endif
190
191 OS_kfree (bip); /* cleanup */
192
193 /***
194 * How to be a proc read function
195 * ------------------------------
196 * Prototype:
197 * int f(char *buffer, char **start, off_t offset,
198 * int count, int *peof, void *dat)
199 *
200 * Assume that the buffer is "count" bytes in size.
201 *
202 * If you know you have supplied all the data you
203 * have, set *peof.
204 *
205 * You have three ways to return data:
206 * 0) Leave *start = NULL. (This is the default.)
207 * Put the data of the requested offset at that
208 * offset within the buffer. Return the number (n)
209 * of bytes there are from the beginning of the
210 * buffer up to the last byte of data. If the
211 * number of supplied bytes (= n - offset) is
212 * greater than zero and you didn't signal eof
213 * and the reader is prepared to take more data
214 * you will be called again with the requested
215 * offset advanced by the number of bytes
216 * absorbed. This interface is useful for files
217 * no larger than the buffer.
218 * 1) Set *start = an unsigned long value less than
219 * the buffer address but greater than zero.
220 * Put the data of the requested offset at the
221 * beginning of the buffer. Return the number of
222 * bytes of data placed there. If this number is
223 * greater than zero and you didn't signal eof
224 * and the reader is prepared to take more data
225 * you will be called again with the requested
226 * offset advanced by *start. This interface is
227 * useful when you have a large file consisting
228 * of a series of blocks which you want to count
229 * and return as wholes.
230 * (Hack by Paul.Russell@rustcorp.com.au)
231 * 2) Set *start = an address within the buffer.
232 * Put the data of the requested offset at *start.
233 * Return the number of bytes of data placed there.
234 * If this number is greater than zero and you
235 * didn't signal eof and the reader is prepared to
236 * take more data you will be called again with the
237 * requested offset advanced by the number of bytes
238 * absorbed.
239 */
240
241#if 1
242 /* #4 - interpretation of above = set EOF, return len */
243 *eof = 1;
244#endif 161#endif
162 extern int max_rxdesc_used, max_txdesc_used;
245 163
164 seq_printf(m, "\ncxt1e1_max_mru: %d\n", cxt1e1_max_mru);
246#if 0 165#if 0
247 /* 166 seq_printf(m, "\nmax_chans_used: %d\n", max_chans_used);
248 * #1 - from net/wireless/atmel.c RLD NOTE -there's something wrong with 167 seq_printf(m, "cxt1e1_max_mtu: %d\n", cxt1e1_max_mtu);
249 * this plagarized code which results in this routine being called TWICE.
250 * The second call returns ZERO, resulting in hidden failure, but at
251 * least only a single message set is being displayed.
252 */
253 if (len <= offset + length)
254 *eof = 1;
255 *start = buffer + offset;
256 len -= offset;
257 if (len > length)
258 len = length;
259 if (len < 0)
260 len = 0;
261#endif
262
263#if 0 /* #2 from net/tokenring/olympic.c +
264 * lanstreamer.c */
265 {
266 off_t begin = 0;
267 int size = 0;
268 off_t pos = 0;
269
270 size = len;
271 pos = begin + size;
272 if (pos < offset)
273 {
274 len = 0;
275 begin = pos;
276 }
277 *start = buffer + (offset - begin); /* Start of wanted data */
278 len -= (offset - begin); /* Start slop */
279 if (len > length)
280 len = length; /* Ending slop */
281 }
282#endif 168#endif
283 169 seq_printf(m, "max_rxdesc_used: %d\n", max_rxdesc_used);
284#if 0 /* #3 from 170 seq_printf(m, "max_txdesc_used: %d\n", max_txdesc_used);
285 * char/ftape/lowlevel/ftape-proc.c */ 171 }
286 len = strlen (buffer);
287 *start = NULL;
288 if (offset + length >= len)
289 *eof = 1;
290 else
291 *eof = 0;
292#endif
293
294#if 0
295 pr_info(">> proc_fs: returned len = %d., start %p\n", len, start); /* RLD DEBUG */
296#endif 172#endif
297 173
298/*** 174 kfree(bip);
299 using NONE: returns = 314.314.314.
300 using #1 : returns = 314, 0.
301 using #2 : returns = 314, 0, 0.
302 using #3 : returns = 314, 314.
303 using #4 : returns = 314, 314.
304***/
305 175
306 return len; 176 pr_devel(">> proc_fs: finished\n");
177 return 0;
307} 178}
308 179
309/* initialize the /proc subsystem for the specific SBE driver */ 180/*
310 181 * seq_file wrappers for procfile show routines.
311int __init 182 */
312sbecom_proc_brd_init (ci_t * ci) 183static int sbecom_proc_open(struct inode *inode, struct file *file)
313{ 184{
314 struct proc_dir_entry *e; 185 return single_open(file, sbecom_proc_get_sbe_info, PDE_DATA(inode));
315 char dir[7 + SBE_IFACETMPL_SIZE + 1];
316
317 /* create a directory in the root procfs */
318 snprintf(dir, sizeof(dir), "driver/%s", ci->devname);
319 ci->dir_dev = proc_mkdir(dir, NULL);
320 if (!ci->dir_dev)
321 {
322 pr_err("Unable to create directory /proc/driver/%s\n", ci->devname);
323 goto fail;
324 }
325 e = create_proc_read_entry ("info", S_IFREG | S_IRUGO,
326 ci->dir_dev, sbecom_proc_get_sbe_info, ci);
327 if (!e)
328 {
329 pr_err("Unable to create entry /proc/driver/%s/info\n", ci->devname);
330 goto fail;
331 }
332 return 0;
333
334fail:
335 sbecom_proc_brd_cleanup (ci);
336 return 1;
337} 186}
338 187
339#else /*** ! CONFIG_PROC_FS ***/ 188static const struct file_operations sbecom_proc_fops = {
189 .open = sbecom_proc_open,
190 .read = seq_read,
191 .llseek = seq_lseek,
192 .release = seq_release,
193};
340 194
341/* stubbed off dummy routines */ 195/*
342 196 * Initialize the /proc subsystem for the specific SBE driver
343void 197 */
344sbecom_proc_brd_cleanup (ci_t * ci) 198int __init sbecom_proc_brd_init(ci_t *ci)
345{
346}
347
348int __init
349sbecom_proc_brd_init (ci_t * ci)
350{ 199{
351 return 0; 200 char dir[7 + SBE_IFACETMPL_SIZE + 1];
352}
353
354#endif /*** CONFIG_PROC_FS ***/
355 201
202 snprintf(dir, sizeof(dir), "driver/%s", ci->devname);
203 ci->dir_dev = proc_mkdir(dir, NULL);
204 if (!ci->dir_dev) {
205 pr_err("Unable to create directory /proc/driver/%s\n", ci->devname);
206 goto fail;
207 }
208
209 if (!proc_create_data("info", S_IFREG | S_IRUGO, ci->dir_dev,
210 &sbecom_proc_fops, ci)) {
211 pr_err("Unable to create entry /proc/driver/%s/info\n", ci->devname);
212 goto fail;
213 }
214 return 0;
356 215
357/*** End-of-File ***/ 216fail:
217 sbecom_proc_brd_cleanup(ci);
218 return 1;
219}
diff --git a/drivers/staging/cxt1e1/sbeproc.h b/drivers/staging/cxt1e1/sbeproc.h
index e82be6afd1e8..e5c072cf1952 100644
--- a/drivers/staging/cxt1e1/sbeproc.h
+++ b/drivers/staging/cxt1e1/sbeproc.h
@@ -23,10 +23,20 @@
23 23
24 24
25#ifdef CONFIG_PROC_FS 25#ifdef CONFIG_PROC_FS
26#ifdef __KERNEL__
27void sbecom_proc_brd_cleanup (ci_t *); 26void sbecom_proc_brd_cleanup (ci_t *);
28int __init sbecom_proc_brd_init (ci_t *); 27int __init sbecom_proc_brd_init (ci_t *);
29 28
30#endif /*** __KERNEL__ ***/ 29#else
30
31static inline void sbecom_proc_brd_cleanup(ci_t * ci)
32{
33}
34
35static inline int __init sbecom_proc_brd_init(ci_t * ci)
36{
37 return 0;
38}
39
31#endif /*** CONFIG_PROC_FS ***/ 40#endif /*** CONFIG_PROC_FS ***/
41
32#endif /*** _INC_SBEPROC_H_ ***/ 42#endif /*** _INC_SBEPROC_H_ ***/
diff --git a/drivers/staging/dgrp/dgrp_common.c b/drivers/staging/dgrp/dgrp_common.c
index 3553998b72bc..9a9b45624ba9 100644
--- a/drivers/staging/dgrp/dgrp_common.c
+++ b/drivers/staging/dgrp/dgrp_common.c
@@ -167,34 +167,3 @@ void dgrp_carrier(struct ch_struct *ch)
167 ch->ch_flag &= ~CH_PHYS_CD; 167 ch->ch_flag &= ~CH_PHYS_CD;
168 168
169} 169}
170
171/**
172 * dgrp_chk_perm() -- check permissions for net device
173 * @inode: pointer to inode structure for the net communication device
174 * @op: operation to be tested
175 *
176 * The file permissions and ownerships are tested to determine whether
177 * the operation "op" is permitted on the file pointed to by the inode.
178 * Returns 0 if the operation is permitted, -EACCESS otherwise
179 */
180int dgrp_chk_perm(int mode, int op)
181{
182 if (!uid_eq(GLOBAL_ROOT_UID, current_euid()))
183 mode >>= 6;
184 else if (in_egroup_p(GLOBAL_ROOT_GID))
185 mode >>= 3;
186
187 if ((mode & op & 0007) == op)
188 return 0;
189
190 if (capable(CAP_SYS_ADMIN))
191 return 0;
192
193 return -EACCES;
194}
195
196/* dgrp_chk_perm wrapper for permission call in struct inode_operations */
197int dgrp_inode_permission(struct inode *inode, int op)
198{
199 return dgrp_chk_perm(inode->i_mode, op);
200}
diff --git a/drivers/staging/dgrp/dgrp_common.h b/drivers/staging/dgrp/dgrp_common.h
index 2832b8e26c4b..23aba6c4d22c 100644
--- a/drivers/staging/dgrp/dgrp_common.h
+++ b/drivers/staging/dgrp/dgrp_common.h
@@ -49,20 +49,20 @@ extern struct dgrp_poll_data dgrp_poll_data;
49extern void dgrp_poll_handler(unsigned long arg); 49extern void dgrp_poll_handler(unsigned long arg);
50 50
51/* from dgrp_mon_ops.c */ 51/* from dgrp_mon_ops.c */
52extern void dgrp_register_mon_hook(struct proc_dir_entry *de); 52extern const struct file_operations dgrp_mon_ops;
53 53
54/* from dgrp_tty.c */ 54/* from dgrp_tty.c */
55extern int dgrp_tty_init(struct nd_struct *nd); 55extern int dgrp_tty_init(struct nd_struct *nd);
56extern void dgrp_tty_uninit(struct nd_struct *nd); 56extern void dgrp_tty_uninit(struct nd_struct *nd);
57 57
58/* from dgrp_ports_ops.c */ 58/* from dgrp_ports_ops.c */
59extern void dgrp_register_ports_hook(struct proc_dir_entry *de); 59extern const struct file_operations dgrp_ports_ops;
60 60
61/* from dgrp_net_ops.c */ 61/* from dgrp_net_ops.c */
62extern void dgrp_register_net_hook(struct proc_dir_entry *de); 62extern const struct file_operations dgrp_net_ops;
63 63
64/* from dgrp_dpa_ops.c */ 64/* from dgrp_dpa_ops.c */
65extern void dgrp_register_dpa_hook(struct proc_dir_entry *de); 65extern const struct file_operations dgrp_dpa_ops;
66extern void dgrp_dpa_data(struct nd_struct *, int, u8 *, int); 66extern void dgrp_dpa_data(struct nd_struct *, int, u8 *, int);
67 67
68/* from dgrp_sysfs.c */ 68/* from dgrp_sysfs.c */
@@ -76,61 +76,6 @@ extern void dgrp_create_tty_sysfs(struct un_struct *un, struct device *c);
76extern void dgrp_remove_tty_sysfs(struct device *c); 76extern void dgrp_remove_tty_sysfs(struct device *c);
77 77
78/* from dgrp_specproc.c */ 78/* from dgrp_specproc.c */
79/*
80 * The list of DGRP entries with r/w capabilities. These
81 * magic numbers are used for identification purposes.
82 */
83enum {
84 DGRP_CONFIG = 1, /* Configure portservers */
85 DGRP_NETDIR = 2, /* Directory for "net" devices */
86 DGRP_MONDIR = 3, /* Directory for "mon" devices */
87 DGRP_PORTSDIR = 4, /* Directory for "ports" devices */
88 DGRP_INFO = 5, /* Get info. about the running module */
89 DGRP_NODEINFO = 6, /* Get info. about the configured nodes */
90 DGRP_DPADIR = 7, /* Directory for the "dpa" devices */
91};
92
93/*
94 * Directions for proc handlers
95 */
96enum {
97 INBOUND = 1, /* Data being written to kernel */
98 OUTBOUND = 2, /* Data being read from the kernel */
99};
100
101/**
102 * dgrp_proc_entry: structure for dgrp proc dirs
103 * @id: ID number associated with this particular entry. Should be
104 * unique across all of DGRP.
105 * @name: text name associated with the /proc entry
106 * @mode: file access permisssions for the /proc entry
107 * @child: pointer to table describing a subdirectory for this entry
108 * @de: pointer to directory entry for this object once registered. Used
109 * to grab the handle of the object for unregistration
110 * @excl_sem: semaphore to provide exclusive to struct
111 * @excl_cnt: counter of current accesses
112 *
113 * Each entry in a DGRP proc directory is described with a
114 * dgrp_proc_entry structure. A collection of these
115 * entries (in an array) represents the members associated
116 * with a particular /proc directory, and is referred to
117 * as a table. All tables are terminated by an entry with
118 * zeros for every member.
119 */
120struct dgrp_proc_entry {
121 int id; /* Integer identifier */
122 const char *name; /* ASCII identifier */
123 mode_t mode; /* File access permissions */
124 struct dgrp_proc_entry *child; /* Child pointer */
125
126 /* file ops to use, pass NULL to use default */
127 struct file_operations *proc_file_ops;
128
129 struct proc_dir_entry *de; /* proc entry pointer */
130 struct semaphore excl_sem; /* Protects exclusive access var */
131 int excl_cnt; /* Counts number of curr accesses */
132};
133
134extern void dgrp_unregister_proc(void); 79extern void dgrp_unregister_proc(void);
135extern void dgrp_register_proc(void); 80extern void dgrp_register_proc(void);
136 81
@@ -144,8 +89,6 @@ extern void dgrp_register_proc(void);
144 *-----------------------------------------------------------------------*/ 89 *-----------------------------------------------------------------------*/
145 90
146void dgrp_carrier(struct ch_struct *ch); 91void dgrp_carrier(struct ch_struct *ch);
147extern int dgrp_inode_permission(struct inode *inode, int op);
148extern int dgrp_chk_perm(int mode, int op);
149 92
150 93
151/* 94/*
diff --git a/drivers/staging/dgrp/dgrp_dpa_ops.c b/drivers/staging/dgrp/dgrp_dpa_ops.c
index ca10a3362e29..114799cddd85 100644
--- a/drivers/staging/dgrp/dgrp_dpa_ops.c
+++ b/drivers/staging/dgrp/dgrp_dpa_ops.c
@@ -40,6 +40,7 @@
40#include <linux/cred.h> 40#include <linux/cred.h>
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <linux/ratelimit.h> 42#include <linux/ratelimit.h>
43#include <linux/slab.h>
43#include <asm/unaligned.h> 44#include <asm/unaligned.h>
44 45
45#include "dgrp_common.h" 46#include "dgrp_common.h"
@@ -52,7 +53,7 @@ static long dgrp_dpa_ioctl(struct file *file, unsigned int cmd,
52 unsigned long arg); 53 unsigned long arg);
53static unsigned int dgrp_dpa_select(struct file *, struct poll_table_struct *); 54static unsigned int dgrp_dpa_select(struct file *, struct poll_table_struct *);
54 55
55static const struct file_operations dpa_ops = { 56const struct file_operations dgrp_dpa_ops = {
56 .owner = THIS_MODULE, 57 .owner = THIS_MODULE,
57 .read = dgrp_dpa_read, 58 .read = dgrp_dpa_read,
58 .poll = dgrp_dpa_select, 59 .poll = dgrp_dpa_select,
@@ -61,12 +62,6 @@ static const struct file_operations dpa_ops = {
61 .release = dgrp_dpa_release, 62 .release = dgrp_dpa_release,
62}; 63};
63 64
64static struct inode_operations dpa_inode_ops = {
65 .permission = dgrp_inode_permission
66};
67
68
69
70struct digi_node { 65struct digi_node {
71 uint nd_state; /* Node state: 1 = up, 0 = down. */ 66 uint nd_state; /* Node state: 1 = up, 0 = down. */
72 uint nd_chan_count; /* Number of channels found */ 67 uint nd_chan_count; /* Number of channels found */
@@ -111,17 +106,6 @@ struct digi_debug {
111#define DIGI_SETDEBUG (('d'<<8) | 247) /* set debug info */ 106#define DIGI_SETDEBUG (('d'<<8) | 247) /* set debug info */
112 107
113 108
114void dgrp_register_dpa_hook(struct proc_dir_entry *de)
115{
116 struct nd_struct *node = de->data;
117
118 de->proc_iops = &dpa_inode_ops;
119 rcu_assign_pointer(de->proc_fops, &dpa_ops);
120
121 node->nd_dpa_de = de;
122 spin_lock_init(&node->nd_dpa_lock);
123}
124
125/* 109/*
126 * dgrp_dpa_open -- open the DPA device for a particular PortServer 110 * dgrp_dpa_open -- open the DPA device for a particular PortServer
127 */ 111 */
@@ -130,8 +114,6 @@ static int dgrp_dpa_open(struct inode *inode, struct file *file)
130 struct nd_struct *nd; 114 struct nd_struct *nd;
131 int rtn = 0; 115 int rtn = 0;
132 116
133 struct proc_dir_entry *de;
134
135 rtn = try_module_get(THIS_MODULE); 117 rtn = try_module_get(THIS_MODULE);
136 if (!rtn) 118 if (!rtn)
137 return -ENXIO; 119 return -ENXIO;
@@ -154,12 +136,7 @@ static int dgrp_dpa_open(struct inode *inode, struct file *file)
154 /* 136 /*
155 * Get the node pointer, and fail if it doesn't exist. 137 * Get the node pointer, and fail if it doesn't exist.
156 */ 138 */
157 de = PDE(inode); 139 nd = PDE_DATA(inode);
158 if (!de) {
159 rtn = -ENXIO;
160 goto done;
161 }
162 nd = (struct nd_struct *)de->data;
163 if (!nd) { 140 if (!nd) {
164 rtn = -ENXIO; 141 rtn = -ENXIO;
165 goto done; 142 goto done;
diff --git a/drivers/staging/dgrp/dgrp_mon_ops.c b/drivers/staging/dgrp/dgrp_mon_ops.c
index b484fccb494e..d18be4180e3b 100644
--- a/drivers/staging/dgrp/dgrp_mon_ops.c
+++ b/drivers/staging/dgrp/dgrp_mon_ops.c
@@ -37,6 +37,7 @@
37#include <linux/tty.h> 37#include <linux/tty.h>
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <asm/unaligned.h> 39#include <asm/unaligned.h>
40#include <linux/slab.h>
40#include <linux/proc_fs.h> 41#include <linux/proc_fs.h>
41#include <linux/uaccess.h> 42#include <linux/uaccess.h>
42 43
@@ -49,7 +50,7 @@ static ssize_t dgrp_mon_read(struct file *, char __user *, size_t, loff_t *);
49static long dgrp_mon_ioctl(struct file *file, unsigned int cmd, 50static long dgrp_mon_ioctl(struct file *file, unsigned int cmd,
50 unsigned long arg); 51 unsigned long arg);
51 52
52static const struct file_operations mon_ops = { 53const struct file_operations dgrp_mon_ops = {
53 .owner = THIS_MODULE, 54 .owner = THIS_MODULE,
54 .read = dgrp_mon_read, 55 .read = dgrp_mon_read,
55 .unlocked_ioctl = dgrp_mon_ioctl, 56 .unlocked_ioctl = dgrp_mon_ioctl,
@@ -57,20 +58,6 @@ static const struct file_operations mon_ops = {
57 .release = dgrp_mon_release, 58 .release = dgrp_mon_release,
58}; 59};
59 60
60static struct inode_operations mon_inode_ops = {
61 .permission = dgrp_inode_permission
62};
63
64void dgrp_register_mon_hook(struct proc_dir_entry *de)
65{
66 struct nd_struct *node = de->data;
67
68 de->proc_iops = &mon_inode_ops;
69 rcu_assign_pointer(de->proc_fops, &mon_ops);
70 node->nd_mon_de = de;
71 sema_init(&node->nd_mon_semaphore, 1);
72}
73
74/** 61/**
75 * dgrp_mon_open() -- open /proc/dgrp/ports device for a PortServer 62 * dgrp_mon_open() -- open /proc/dgrp/ports device for a PortServer
76 * @inode: struct inode * 63 * @inode: struct inode *
@@ -81,7 +68,6 @@ void dgrp_register_mon_hook(struct proc_dir_entry *de)
81static int dgrp_mon_open(struct inode *inode, struct file *file) 68static int dgrp_mon_open(struct inode *inode, struct file *file)
82{ 69{
83 struct nd_struct *nd; 70 struct nd_struct *nd;
84 struct proc_dir_entry *de;
85 struct timeval tv; 71 struct timeval tv;
86 uint32_t time; 72 uint32_t time;
87 u8 *buf; 73 u8 *buf;
@@ -109,13 +95,7 @@ static int dgrp_mon_open(struct inode *inode, struct file *file)
109 /* 95 /*
110 * Get the node pointer, and fail if it doesn't exist. 96 * Get the node pointer, and fail if it doesn't exist.
111 */ 97 */
112 de = PDE(inode); 98 nd = PDE_DATA(inode);
113 if (!de) {
114 rtn = -ENXIO;
115 goto done;
116 }
117
118 nd = (struct nd_struct *)de->data;
119 if (!nd) { 99 if (!nd) {
120 rtn = -ENXIO; 100 rtn = -ENXIO;
121 goto done; 101 goto done;
diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c
index 64f48ffb9d4e..5b7833f593ff 100644
--- a/drivers/staging/dgrp/dgrp_net_ops.c
+++ b/drivers/staging/dgrp/dgrp_net_ops.c
@@ -35,7 +35,7 @@
35 35
36#include <linux/module.h> 36#include <linux/module.h>
37#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
38#include <linux/types.h> 38#include <linux/slab.h>
39#include <linux/string.h> 39#include <linux/string.h>
40#include <linux/device.h> 40#include <linux/device.h>
41#include <linux/tty.h> 41#include <linux/tty.h>
@@ -72,7 +72,7 @@ static long dgrp_net_ioctl(struct file *file, unsigned int cmd,
72static unsigned int dgrp_net_select(struct file *file, 72static unsigned int dgrp_net_select(struct file *file,
73 struct poll_table_struct *table); 73 struct poll_table_struct *table);
74 74
75static const struct file_operations net_ops = { 75const struct file_operations dgrp_net_ops = {
76 .owner = THIS_MODULE, 76 .owner = THIS_MODULE,
77 .read = dgrp_net_read, 77 .read = dgrp_net_read,
78 .write = dgrp_net_write, 78 .write = dgrp_net_write,
@@ -82,23 +82,6 @@ static const struct file_operations net_ops = {
82 .release = dgrp_net_release, 82 .release = dgrp_net_release,
83}; 83};
84 84
85static struct inode_operations net_inode_ops = {
86 .permission = dgrp_inode_permission
87};
88
89void dgrp_register_net_hook(struct proc_dir_entry *de)
90{
91 struct nd_struct *node = de->data;
92
93 de->proc_iops = &net_inode_ops;
94 rcu_assign_pointer(de->proc_fops, &net_ops);
95 node->nd_net_de = de;
96 sema_init(&node->nd_net_semaphore, 1);
97 node->nd_state = NS_CLOSED;
98 dgrp_create_node_class_sysfs_files(node);
99}
100
101
102/** 85/**
103 * dgrp_dump() -- prints memory for debugging purposes. 86 * dgrp_dump() -- prints memory for debugging purposes.
104 * @mem: Memory location which should be printed to the console 87 * @mem: Memory location which should be printed to the console
@@ -801,7 +784,6 @@ out_err:
801static int dgrp_net_open(struct inode *inode, struct file *file) 784static int dgrp_net_open(struct inode *inode, struct file *file)
802{ 785{
803 struct nd_struct *nd; 786 struct nd_struct *nd;
804 struct proc_dir_entry *de;
805 ulong lock_flags; 787 ulong lock_flags;
806 int rtn; 788 int rtn;
807 789
@@ -825,13 +807,7 @@ static int dgrp_net_open(struct inode *inode, struct file *file)
825 /* 807 /*
826 * Get the node pointer, and fail if it doesn't exist. 808 * Get the node pointer, and fail if it doesn't exist.
827 */ 809 */
828 de = PDE(inode); 810 nd = PDE_DATA(inode);
829 if (!de) {
830 rtn = -ENXIO;
831 goto done;
832 }
833
834 nd = (struct nd_struct *) de->data;
835 if (!nd) { 811 if (!nd) {
836 rtn = -ENXIO; 812 rtn = -ENXIO;
837 goto done; 813 goto done;
diff --git a/drivers/staging/dgrp/dgrp_ports_ops.c b/drivers/staging/dgrp/dgrp_ports_ops.c
index f93dc1f262f5..4ce030815f27 100644
--- a/drivers/staging/dgrp/dgrp_ports_ops.c
+++ b/drivers/staging/dgrp/dgrp_ports_ops.c
@@ -47,7 +47,7 @@
47/* File operation declarations */ 47/* File operation declarations */
48static int dgrp_ports_open(struct inode *, struct file *); 48static int dgrp_ports_open(struct inode *, struct file *);
49 49
50static const struct file_operations ports_ops = { 50const struct file_operations dgrp_ports_ops = {
51 .owner = THIS_MODULE, 51 .owner = THIS_MODULE,
52 .open = dgrp_ports_open, 52 .open = dgrp_ports_open,
53 .read = seq_read, 53 .read = seq_read,
@@ -55,20 +55,6 @@ static const struct file_operations ports_ops = {
55 .release = seq_release 55 .release = seq_release
56}; 56};
57 57
58static struct inode_operations ports_inode_ops = {
59 .permission = dgrp_inode_permission
60};
61
62
63void dgrp_register_ports_hook(struct proc_dir_entry *de)
64{
65 struct nd_struct *node = de->data;
66
67 de->proc_iops = &ports_inode_ops;
68 rcu_assign_pointer(de->proc_fops, &ports_ops);
69 node->nd_ports_de = de;
70}
71
72static void *dgrp_ports_seq_start(struct seq_file *seq, loff_t *pos) 58static void *dgrp_ports_seq_start(struct seq_file *seq, loff_t *pos)
73{ 59{
74 if (*pos == 0) 60 if (*pos == 0)
@@ -163,7 +149,7 @@ static int dgrp_ports_open(struct inode *inode, struct file *file)
163 rtn = seq_open(file, &ports_seq_ops); 149 rtn = seq_open(file, &ports_seq_ops);
164 if (!rtn) { 150 if (!rtn) {
165 seq = file->private_data; 151 seq = file->private_data;
166 seq->private = PDE(inode)->data; 152 seq->private = PDE_DATA(inode);
167 } 153 }
168 154
169 return rtn; 155 return rtn;
diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c
index d66712c8aa94..205d80ef4455 100644
--- a/drivers/staging/dgrp/dgrp_specproc.c
+++ b/drivers/staging/dgrp/dgrp_specproc.c
@@ -37,6 +37,7 @@
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/cred.h> 38#include <linux/cred.h>
39#include <linux/proc_fs.h> 39#include <linux/proc_fs.h>
40#include <linux/slab.h>
40#include <linux/ctype.h> 41#include <linux/ctype.h>
41#include <linux/seq_file.h> 42#include <linux/seq_file.h>
42#include <linux/uaccess.h> 43#include <linux/uaccess.h>
@@ -44,43 +45,17 @@
44 45
45#include "dgrp_common.h" 46#include "dgrp_common.h"
46 47
47static struct dgrp_proc_entry dgrp_table[];
48static struct proc_dir_entry *dgrp_proc_dir_entry; 48static struct proc_dir_entry *dgrp_proc_dir_entry;
49 49
50static int dgrp_add_id(long id); 50static int dgrp_add_id(long id);
51static int dgrp_remove_nd(struct nd_struct *nd); 51static int dgrp_remove_nd(struct nd_struct *nd);
52static void unregister_dgrp_device(struct proc_dir_entry *de); 52static struct proc_dir_entry *add_proc_file(struct nd_struct *node,
53static void register_dgrp_device(struct nd_struct *node,
54 struct proc_dir_entry *root, 53 struct proc_dir_entry *root,
55 void (*register_hook)(struct proc_dir_entry *de)); 54 const struct file_operations *fops);
56 55
57/* File operation declarations */ 56/* File operation declarations */
58static int dgrp_gen_proc_open(struct inode *, struct file *);
59static int dgrp_gen_proc_close(struct inode *, struct file *);
60static int parse_write_config(char *); 57static int parse_write_config(char *);
61 58
62
63static const struct file_operations dgrp_proc_file_ops = {
64 .owner = THIS_MODULE,
65 .open = dgrp_gen_proc_open,
66 .release = dgrp_gen_proc_close,
67};
68
69static struct inode_operations proc_inode_ops = {
70 .permission = dgrp_inode_permission
71};
72
73
74static void register_proc_table(struct dgrp_proc_entry *,
75 struct proc_dir_entry *);
76static void unregister_proc_table(struct dgrp_proc_entry *,
77 struct proc_dir_entry *);
78
79static struct dgrp_proc_entry dgrp_net_table[];
80static struct dgrp_proc_entry dgrp_mon_table[];
81static struct dgrp_proc_entry dgrp_ports_table[];
82static struct dgrp_proc_entry dgrp_dpa_table[];
83
84static ssize_t dgrp_config_proc_write(struct file *file, 59static ssize_t dgrp_config_proc_write(struct file *file,
85 const char __user *buffer, 60 const char __user *buffer,
86 size_t count, loff_t *pos); 61 size_t count, loff_t *pos);
@@ -89,7 +64,7 @@ static int dgrp_nodeinfo_proc_open(struct inode *inode, struct file *file);
89static int dgrp_info_proc_open(struct inode *inode, struct file *file); 64static int dgrp_info_proc_open(struct inode *inode, struct file *file);
90static int dgrp_config_proc_open(struct inode *inode, struct file *file); 65static int dgrp_config_proc_open(struct inode *inode, struct file *file);
91 66
92static struct file_operations config_proc_file_ops = { 67static const struct file_operations config_proc_file_ops = {
93 .owner = THIS_MODULE, 68 .owner = THIS_MODULE,
94 .open = dgrp_config_proc_open, 69 .open = dgrp_config_proc_open,
95 .read = seq_read, 70 .read = seq_read,
@@ -98,7 +73,7 @@ static struct file_operations config_proc_file_ops = {
98 .write = dgrp_config_proc_write, 73 .write = dgrp_config_proc_write,
99}; 74};
100 75
101static struct file_operations info_proc_file_ops = { 76static const struct file_operations info_proc_file_ops = {
102 .owner = THIS_MODULE, 77 .owner = THIS_MODULE,
103 .open = dgrp_info_proc_open, 78 .open = dgrp_info_proc_open,
104 .read = seq_read, 79 .read = seq_read,
@@ -106,7 +81,7 @@ static struct file_operations info_proc_file_ops = {
106 .release = single_release, 81 .release = single_release,
107}; 82};
108 83
109static struct file_operations nodeinfo_proc_file_ops = { 84static const struct file_operations nodeinfo_proc_file_ops = {
110 .owner = THIS_MODULE, 85 .owner = THIS_MODULE,
111 .open = dgrp_nodeinfo_proc_open, 86 .open = dgrp_nodeinfo_proc_open,
112 .read = seq_read, 87 .read = seq_read,
@@ -114,71 +89,25 @@ static struct file_operations nodeinfo_proc_file_ops = {
114 .release = seq_release, 89 .release = seq_release,
115}; 90};
116 91
117static struct dgrp_proc_entry dgrp_table[] = {
118 {
119 .id = DGRP_CONFIG,
120 .name = "config",
121 .mode = 0644,
122 .proc_file_ops = &config_proc_file_ops,
123 },
124 {
125 .id = DGRP_INFO,
126 .name = "info",
127 .mode = 0644,
128 .proc_file_ops = &info_proc_file_ops,
129 },
130 {
131 .id = DGRP_NODEINFO,
132 .name = "nodeinfo",
133 .mode = 0644,
134 .proc_file_ops = &nodeinfo_proc_file_ops,
135 },
136 {
137 .id = DGRP_NETDIR,
138 .name = "net",
139 .mode = 0500,
140 .child = dgrp_net_table
141 },
142 {
143 .id = DGRP_MONDIR,
144 .name = "mon",
145 .mode = 0500,
146 .child = dgrp_mon_table
147 },
148 {
149 .id = DGRP_PORTSDIR,
150 .name = "ports",
151 .mode = 0500,
152 .child = dgrp_ports_table
153 },
154 {
155 .id = DGRP_DPADIR,
156 .name = "dpa",
157 .mode = 0500,
158 .child = dgrp_dpa_table
159 }
160};
161
162static struct proc_dir_entry *net_entry_pointer; 92static struct proc_dir_entry *net_entry_pointer;
163static struct proc_dir_entry *mon_entry_pointer; 93static struct proc_dir_entry *mon_entry_pointer;
164static struct proc_dir_entry *dpa_entry_pointer; 94static struct proc_dir_entry *dpa_entry_pointer;
165static struct proc_dir_entry *ports_entry_pointer; 95static struct proc_dir_entry *ports_entry_pointer;
166 96
167static struct dgrp_proc_entry dgrp_net_table[] = { 97static void remove_files(struct nd_struct *nd)
168 {0} 98{
169}; 99 char buf[3];
170 100 ID_TO_CHAR(nd->nd_ID, buf);
171static struct dgrp_proc_entry dgrp_mon_table[] = { 101 dgrp_remove_node_class_sysfs_files(nd);
172 {0} 102 if (nd->nd_net_de)
173}; 103 remove_proc_entry(buf, net_entry_pointer);
174 104 if (nd->nd_mon_de)
175static struct dgrp_proc_entry dgrp_ports_table[] = { 105 remove_proc_entry(buf, mon_entry_pointer);
176 {0} 106 if (nd->nd_dpa_de)
177}; 107 remove_proc_entry(buf, dpa_entry_pointer);
178 108 if (nd->nd_ports_de)
179static struct dgrp_proc_entry dgrp_dpa_table[] = { 109 remove_proc_entry(buf, ports_entry_pointer);
180 {0} 110}
181};
182 111
183void dgrp_unregister_proc(void) 112void dgrp_unregister_proc(void)
184{ 113{
@@ -188,12 +117,19 @@ void dgrp_unregister_proc(void)
188 ports_entry_pointer = NULL; 117 ports_entry_pointer = NULL;
189 118
190 if (dgrp_proc_dir_entry) { 119 if (dgrp_proc_dir_entry) {
191 unregister_proc_table(dgrp_table, dgrp_proc_dir_entry); 120 struct nd_struct *nd;
192 remove_proc_entry(dgrp_proc_dir_entry->name, 121 list_for_each_entry(nd, &nd_struct_list, list)
193 dgrp_proc_dir_entry->parent); 122 remove_files(nd);
123 remove_proc_entry("dgrp/config", NULL);
124 remove_proc_entry("dgrp/info", NULL);
125 remove_proc_entry("dgrp/nodeinfo", NULL);
126 remove_proc_entry("dgrp/net", NULL);
127 remove_proc_entry("dgrp/mon", NULL);
128 remove_proc_entry("dgrp/dpa", NULL);
129 remove_proc_entry("dgrp/ports", NULL);
130 remove_proc_entry("dgrp", NULL);
194 dgrp_proc_dir_entry = NULL; 131 dgrp_proc_dir_entry = NULL;
195 } 132 }
196
197} 133}
198 134
199void dgrp_register_proc(void) 135void dgrp_register_proc(void)
@@ -201,211 +137,16 @@ void dgrp_register_proc(void)
201 /* 137 /*
202 * Register /proc/dgrp 138 * Register /proc/dgrp
203 */ 139 */
204 dgrp_proc_dir_entry = proc_create("dgrp", S_IFDIR, NULL, 140 dgrp_proc_dir_entry = proc_mkdir("dgrp", NULL);
205 &dgrp_proc_file_ops); 141 if (!dgrp_proc_dir_entry)
206 register_proc_table(dgrp_table, dgrp_proc_dir_entry);
207}
208
209/*
210 * /proc/sys support
211 */
212static int dgrp_proc_match(int len, const char *name, struct proc_dir_entry *de)
213{
214 if (!de || !de->low_ino)
215 return 0;
216 if (de->namelen != len)
217 return 0;
218 return !memcmp(name, de->name, len);
219}
220
221
222/*
223 * Scan the entries in table and add them all to /proc at the position
224 * referred to by "root"
225 */
226static void register_proc_table(struct dgrp_proc_entry *table,
227 struct proc_dir_entry *root)
228{
229 struct proc_dir_entry *de;
230 int len;
231 mode_t mode;
232
233 if (table == NULL)
234 return; 142 return;
235 if (root == NULL) 143 proc_create("dgrp/config", 0644, NULL, &config_proc_file_ops);
236 return; 144 proc_create("dgrp/info", 0644, NULL, &info_proc_file_ops);
237 145 proc_create("dgrp/nodeinfo", 0644, NULL, &nodeinfo_proc_file_ops);
238 for (; table->id; table++) { 146 net_entry_pointer = proc_mkdir_mode("dgrp/net", 0500, NULL);
239 /* Can't do anything without a proc name. */ 147 mon_entry_pointer = proc_mkdir_mode("dgrp/mon", 0500, NULL);
240 if (!table->name) 148 dpa_entry_pointer = proc_mkdir_mode("dgrp/dpa", 0500, NULL);
241 continue; 149 ports_entry_pointer = proc_mkdir_mode("dgrp/ports", 0500, NULL);
242
243 /* Maybe we can't do anything with it... */
244 if (!table->proc_file_ops &&
245 !table->child) {
246 pr_warn("dgrp: Can't register %s\n",
247 table->name);
248 continue;
249 }
250
251 len = strlen(table->name);
252 mode = table->mode;
253
254 de = NULL;
255 if (!table->child)
256 mode |= S_IFREG;
257 else {
258 mode |= S_IFDIR;
259 for (de = root->subdir; de; de = de->next) {
260 if (dgrp_proc_match(len, table->name, de))
261 break;
262 }
263 /* If the subdir exists already, de is non-NULL */
264 }
265
266 if (!de) {
267 de = create_proc_entry(table->name, mode, root);
268 if (!de)
269 continue;
270 de->data = (void *) table;
271 if (!table->child) {
272 de->proc_iops = &proc_inode_ops;
273 if (table->proc_file_ops)
274 rcu_assign_pointer(de->proc_fops,
275 table->proc_file_ops);
276 else
277 rcu_assign_pointer(de->proc_fops,
278 &dgrp_proc_file_ops);
279 }
280 }
281 table->de = de;
282 if (de->mode & S_IFDIR)
283 register_proc_table(table->child, de);
284
285 if (table->id == DGRP_NETDIR)
286 net_entry_pointer = de;
287
288 if (table->id == DGRP_MONDIR)
289 mon_entry_pointer = de;
290
291 if (table->id == DGRP_DPADIR)
292 dpa_entry_pointer = de;
293
294 if (table->id == DGRP_PORTSDIR)
295 ports_entry_pointer = de;
296 }
297}
298
299/*
300 * Unregister a /proc sysctl table and any subdirectories.
301 */
302static void unregister_proc_table(struct dgrp_proc_entry *table,
303 struct proc_dir_entry *root)
304{
305 struct proc_dir_entry *de;
306 struct nd_struct *tmp;
307
308 if (table == NULL)
309 return;
310
311 list_for_each_entry(tmp, &nd_struct_list, list) {
312 if ((table == dgrp_net_table) && (tmp->nd_net_de)) {
313 unregister_dgrp_device(tmp->nd_net_de);
314 dgrp_remove_node_class_sysfs_files(tmp);
315 }
316
317 if ((table == dgrp_mon_table) && (tmp->nd_mon_de))
318 unregister_dgrp_device(tmp->nd_mon_de);
319
320 if ((table == dgrp_dpa_table) && (tmp->nd_dpa_de))
321 unregister_dgrp_device(tmp->nd_dpa_de);
322
323 if ((table == dgrp_ports_table) && (tmp->nd_ports_de))
324 unregister_dgrp_device(tmp->nd_ports_de);
325 }
326
327 for (; table->id; table++) {
328 de = table->de;
329
330 if (!de)
331 continue;
332 if (de->mode & S_IFDIR) {
333 if (!table->child) {
334 pr_alert("dgrp: malformed sysctl tree on free\n");
335 continue;
336 }
337 unregister_proc_table(table->child, de);
338
339 /* Don't unregister directories which still have entries */
340 if (de->subdir)
341 continue;
342 }
343
344 /* Don't unregister proc entries that are still being used.. */
345 if ((atomic_read(&de->count)) != 1) {
346 pr_alert("proc entry %s in use, not removing\n",
347 de->name);
348 continue;
349 }
350
351 remove_proc_entry(de->name, de->parent);
352 table->de = NULL;
353 }
354}
355
356static int dgrp_gen_proc_open(struct inode *inode, struct file *file)
357{
358 struct proc_dir_entry *de;
359 struct dgrp_proc_entry *entry;
360 int ret = 0;
361
362 de = (struct proc_dir_entry *) PDE(file_inode(file));
363 if (!de || !de->data) {
364 ret = -ENXIO;
365 goto done;
366 }
367
368 entry = (struct dgrp_proc_entry *) de->data;
369 if (!entry) {
370 ret = -ENXIO;
371 goto done;
372 }
373
374 down(&entry->excl_sem);
375
376 if (entry->excl_cnt)
377 ret = -EBUSY;
378 else
379 entry->excl_cnt++;
380
381 up(&entry->excl_sem);
382
383done:
384 return ret;
385}
386
387static int dgrp_gen_proc_close(struct inode *inode, struct file *file)
388{
389 struct proc_dir_entry *de;
390 struct dgrp_proc_entry *entry;
391
392 de = (struct proc_dir_entry *) PDE(file_inode(file));
393 if (!de || !de->data)
394 goto done;
395
396 entry = (struct dgrp_proc_entry *) de->data;
397 if (!entry)
398 goto done;
399
400 down(&entry->excl_sem);
401
402 if (entry->excl_cnt)
403 entry->excl_cnt = 0;
404
405 up(&entry->excl_sem);
406
407done:
408 return 0;
409} 150}
410 151
411static void *dgrp_config_proc_start(struct seq_file *m, loff_t *pos) 152static void *dgrp_config_proc_start(struct seq_file *m, loff_t *pos)
@@ -736,6 +477,10 @@ static int dgrp_add_id(long id)
736 init_waitqueue_head(&nd->nd_tx_waitq); 477 init_waitqueue_head(&nd->nd_tx_waitq);
737 init_waitqueue_head(&nd->nd_mon_wqueue); 478 init_waitqueue_head(&nd->nd_mon_wqueue);
738 init_waitqueue_head(&nd->nd_dpa_wqueue); 479 init_waitqueue_head(&nd->nd_dpa_wqueue);
480 sema_init(&nd->nd_mon_semaphore, 1);
481 sema_init(&nd->nd_net_semaphore, 1);
482 spin_lock_init(&nd->nd_dpa_lock);
483 nd->nd_state = NS_CLOSED;
739 for (i = 0; i < SEQ_MAX; i++) 484 for (i = 0; i < SEQ_MAX; i++)
740 init_waitqueue_head(&nd->nd_seq_wque[i]); 485 init_waitqueue_head(&nd->nd_seq_wque[i]);
741 486
@@ -750,12 +495,12 @@ static int dgrp_add_id(long id)
750 if (ret) 495 if (ret)
751 goto error_out; 496 goto error_out;
752 497
753 register_dgrp_device(nd, net_entry_pointer, dgrp_register_net_hook); 498 dgrp_create_node_class_sysfs_files(nd);
754 register_dgrp_device(nd, mon_entry_pointer, dgrp_register_mon_hook); 499 nd->nd_net_de = add_proc_file(nd, net_entry_pointer, &dgrp_net_ops);
755 register_dgrp_device(nd, dpa_entry_pointer, dgrp_register_dpa_hook); 500 nd->nd_mon_de = add_proc_file(nd, mon_entry_pointer, &dgrp_mon_ops);
756 register_dgrp_device(nd, ports_entry_pointer, 501 nd->nd_dpa_de = add_proc_file(nd, dpa_entry_pointer, &dgrp_dpa_ops);
757 dgrp_register_ports_hook); 502 nd->nd_ports_de = add_proc_file(nd, ports_entry_pointer,
758 503 &dgrp_ports_ops);
759 return 0; 504 return 0;
760 505
761 /* FIXME this guy should free the tty driver stored in nd and destroy 506 /* FIXME this guy should free the tty driver stored in nd and destroy
@@ -774,16 +519,7 @@ static int dgrp_remove_nd(struct nd_struct *nd)
774 if (nd->nd_tty_ref_cnt) 519 if (nd->nd_tty_ref_cnt)
775 return -EBUSY; 520 return -EBUSY;
776 521
777 if (nd->nd_net_de) { 522 remove_files(nd);
778 unregister_dgrp_device(nd->nd_net_de);
779 dgrp_remove_node_class_sysfs_files(nd);
780 }
781
782 unregister_dgrp_device(nd->nd_mon_de);
783
784 unregister_dgrp_device(nd->nd_ports_de);
785
786 unregister_dgrp_device(nd->nd_dpa_de);
787 523
788 dgrp_tty_uninit(nd); 524 dgrp_tty_uninit(nd);
789 525
@@ -795,38 +531,11 @@ static int dgrp_remove_nd(struct nd_struct *nd)
795 return 0; 531 return 0;
796} 532}
797 533
798static void register_dgrp_device(struct nd_struct *node, 534static struct proc_dir_entry *add_proc_file(struct nd_struct *node,
799 struct proc_dir_entry *root, 535 struct proc_dir_entry *root,
800 void (*register_hook)(struct proc_dir_entry *de)) 536 const struct file_operations *fops)
801{ 537{
802 char buf[3]; 538 char buf[3];
803 struct proc_dir_entry *de;
804
805 ID_TO_CHAR(node->nd_ID, buf); 539 ID_TO_CHAR(node->nd_ID, buf);
806 540 return proc_create_data(buf, 0600, root, fops, node);
807 de = create_proc_entry(buf, 0600 | S_IFREG, root);
808 if (!de)
809 return;
810
811 de->data = (void *) node;
812
813 if (register_hook)
814 register_hook(de);
815
816}
817
818static void unregister_dgrp_device(struct proc_dir_entry *de)
819{
820 if (!de)
821 return;
822
823 /* Don't unregister proc entries that are still being used.. */
824 if ((atomic_read(&de->count)) != 1) {
825 pr_alert("%s - proc entry %s in use. Not removing.\n",
826 __func__, de->name);
827 return;
828 }
829
830 remove_proc_entry(de->name, de->parent);
831 de = NULL;
832} 541}
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
index 5337b415d450..21b369e0150f 100644
--- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
+++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
@@ -19,6 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
22#include <linux/seq_file.h>
22#include <linux/string.h> 23#include <linux/string.h>
23#include <linux/vmalloc.h> 24#include <linux/vmalloc.h>
24#include <linux/netdevice.h> 25#include <linux/netdevice.h>
@@ -29,70 +30,55 @@
29#define FT1000_PROC "ft1000" 30#define FT1000_PROC "ft1000"
30#define MAX_FILE_LEN 255 31#define MAX_FILE_LEN 255
31 32
32#define PUTM_TO_PAGE(len, page, args...) \ 33#define seq_putx(m, message, size, var) \
33 len += snprintf(page+len, PAGE_SIZE - len, args) 34 seq_printf(m, message); \
34
35#define PUTX_TO_PAGE(len, page, message, size, var) \
36 len += snprintf(page+len, PAGE_SIZE - len, message); \
37 for(i = 0; i < (size - 1); i++) { \ 35 for(i = 0; i < (size - 1); i++) { \
38 len += snprintf(page+len, PAGE_SIZE - len, "%02x:", var[i]); \ 36 seq_printf(m, "%02x:", var[i]); \
39 } \ 37 } \
40 len += snprintf(page+len, PAGE_SIZE - len, "%02x\n", var[i]) 38 seq_printf(m, "%02x\n", var[i])
41 39
42#define PUTD_TO_PAGE(len, page, message, size, var) \ 40#define seq_putd(m, message, size, var) \
43 len += snprintf(page+len, PAGE_SIZE - len, message); \ 41 seq_printf(m, message); \
44 for(i = 0; i < (size - 1); i++) { \ 42 for(i = 0; i < (size - 1); i++) { \
45 len += snprintf(page+len, PAGE_SIZE - len, "%d.", var[i]); \ 43 seq_printf(m, "%d.", var[i]); \
46 } \ 44 } \
47 len += snprintf(page+len, PAGE_SIZE - len, "%d\n", var[i]) 45 seq_printf(m, "%d\n", var[i])
48 46
49static int ft1000ReadProc(char *page, char **start, off_t off, 47static int ft1000ReadProc(struct seq_file *m, void *v)
50 int count, int *eof, void *data)
51{ 48{
52 struct net_device *dev; 49 static const char *status[] = {
53 int len;
54 int i;
55 struct ft1000_info *info;
56 char *status[] = {
57 "Idle (Disconnect)", "Searching", "Active (Connected)", 50 "Idle (Disconnect)", "Searching", "Active (Connected)",
58 "Waiting for L2", "Sleep", "No Coverage", "", "" 51 "Waiting for L2", "Sleep", "No Coverage", "", ""
59 }; 52 };
60 char *signal[] = { "", "*", "**", "***", "****" }; 53 static const char *signal[] = { "", "*", "**", "***", "****" };
54
55 struct net_device *dev = m->private;
56 struct ft1000_info *info = netdev_priv(dev);
57 int i;
61 int strength; 58 int strength;
62 int quality; 59 int quality;
63 struct timeval tv; 60 struct timeval tv;
64 time_t delta; 61 time_t delta;
65 62
66 dev = (struct net_device *)data;
67 info = netdev_priv(dev);
68
69 if (off > 0) {
70 *eof = 1;
71 return 0;
72 }
73
74 /* Wrap-around */
75
76 if (info->AsicID == ELECTRABUZZ_ID) { 63 if (info->AsicID == ELECTRABUZZ_ID) {
77 if (info->ProgConStat != 0xFF) { 64 if (info->ProgConStat != 0xFF) {
78 info->LedStat = 65 info->LedStat =
79 ft1000_read_dpram(dev, FT1000_DSP_LED); 66 ft1000_read_dpram(dev, FT1000_DSP_LED);
80 info->ConStat = 67 info->ConStat =
81 ft1000_read_dpram(dev, 68 ft1000_read_dpram(dev, FT1000_DSP_CON_STATE);
82 FT1000_DSP_CON_STATE);
83 } else { 69 } else {
84 info->ConStat = 0xf; 70 info->ConStat = 0xf;
85 } 71 }
86 } else { 72 } else {
87 if (info->ProgConStat != 0xFF) { 73 if (info->ProgConStat != 0xFF) {
88 info->LedStat = 74 info->LedStat =
89 ntohs(ft1000_read_dpram_mag_16 75 ntohs(ft1000_read_dpram_mag_16(
90 (dev, FT1000_MAG_DSP_LED, 76 dev, FT1000_MAG_DSP_LED,
91 FT1000_MAG_DSP_LED_INDX)); 77 FT1000_MAG_DSP_LED_INDX));
92 info->ConStat = 78 info->ConStat =
93 ntohs(ft1000_read_dpram_mag_16 79 ntohs(ft1000_read_dpram_mag_16(
94 (dev, FT1000_MAG_DSP_CON_STATE, 80 dev, FT1000_MAG_DSP_CON_STATE,
95 FT1000_MAG_DSP_CON_STATE_INDX)); 81 FT1000_MAG_DSP_CON_STATE_INDX));
96 } else { 82 } else {
97 info->ConStat = 0xf; 83 info->ConStat = 0xf;
98 } 84 }
@@ -135,36 +121,46 @@ static int ft1000ReadProc(char *page, char **start, off_t off,
135 } 121 }
136 122
137 do_gettimeofday(&tv); 123 do_gettimeofday(&tv);
138 delta = (tv.tv_sec - info->ConTm); 124 delta = tv.tv_sec - info->ConTm;
139 len = 0; 125 seq_printf(m, "Connection Time: %02ld:%02ld:%02ld\n",
140 PUTM_TO_PAGE(len, page, "Connection Time: %02ld:%02ld:%02ld\n",
141 ((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60)); 126 ((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60));
142 PUTM_TO_PAGE(len, page, "Connection Time[s]: %ld\n", delta); 127 seq_printf(m, "Connection Time[s]: %ld\n", delta);
143 PUTM_TO_PAGE(len, page, "Asic ID: %s\n", 128 seq_printf(m, "Asic ID: %s\n",
144 (info->AsicID) == 129 info->AsicID ==
145 ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC"); 130 ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC");
146 PUTX_TO_PAGE(len, page, "SKU: ", SKUSZ, info->Sku); 131 seq_putx(m, "SKU: ", SKUSZ, info->Sku);
147 PUTX_TO_PAGE(len, page, "EUI64: ", EUISZ, info->eui64); 132 seq_putx(m, "EUI64: ", EUISZ, info->eui64);
148 PUTD_TO_PAGE(len, page, "DSP version number: ", DSPVERSZ, info->DspVer); 133 seq_putd(m, "DSP version number: ", DSPVERSZ, info->DspVer);
149 PUTX_TO_PAGE(len, page, "Hardware Serial Number: ", HWSERNUMSZ, 134 seq_putx(m, "Hardware Serial Number: ", HWSERNUMSZ, info->HwSerNum);
150 info->HwSerNum); 135 seq_putx(m, "Caliberation Version: ", CALVERSZ, info->RfCalVer);
151 PUTX_TO_PAGE(len, page, "Caliberation Version: ", CALVERSZ, 136 seq_putd(m, "Caliberation Date: ", CALDATESZ, info->RfCalDate);
152 info->RfCalVer); 137 seq_printf(m, "Media State: %s\n",
153 PUTD_TO_PAGE(len, page, "Caliberation Date: ", CALDATESZ,
154 info->RfCalDate);
155 PUTM_TO_PAGE(len, page, "Media State: %s\n",
156 (info->mediastate) ? "link" : "no link"); 138 (info->mediastate) ? "link" : "no link");
157 PUTM_TO_PAGE(len, page, "Connection Status: %s\n", 139 seq_printf(m, "Connection Status: %s\n", status[info->ConStat & 0x7]);
158 status[((info->ConStat) & 0x7)]); 140 seq_printf(m, "RX packets: %ld\n", info->stats.rx_packets);
159 PUTM_TO_PAGE(len, page, "RX packets: %ld\n", info->stats.rx_packets); 141 seq_printf(m, "TX packets: %ld\n", info->stats.tx_packets);
160 PUTM_TO_PAGE(len, page, "TX packets: %ld\n", info->stats.tx_packets); 142 seq_printf(m, "RX bytes: %ld\n", info->stats.rx_bytes);
161 PUTM_TO_PAGE(len, page, "RX bytes: %ld\n", info->stats.rx_bytes); 143 seq_printf(m, "TX bytes: %ld\n", info->stats.tx_bytes);
162 PUTM_TO_PAGE(len, page, "TX bytes: %ld\n", info->stats.tx_bytes); 144 seq_printf(m, "Signal Strength: %s\n", signal[strength]);
163 PUTM_TO_PAGE(len, page, "Signal Strength: %s\n", signal[strength]); 145 seq_printf(m, "Signal Quality: %s\n", signal[quality]);
164 PUTM_TO_PAGE(len, page, "Signal Quality: %s\n", signal[quality]); 146 return 0;
165 return len; 147}
148
149/*
150 * seq_file wrappers for procfile show routines.
151 */
152static int ft1000_proc_open(struct inode *inode, struct file *file)
153{
154 return single_open(file, ft1000ReadProc, PDE_DATA(inode));
166} 155}
167 156
157static const struct file_operations ft1000_proc_fops = {
158 .open = ft1000_proc_open,
159 .read = seq_read,
160 .llseek = seq_lseek,
161 .release = seq_release,
162};
163
168static int ft1000NotifyProc(struct notifier_block *this, unsigned long event, 164static int ft1000NotifyProc(struct notifier_block *this, unsigned long event,
169 void *ptr) 165 void *ptr)
170{ 166{
@@ -176,8 +172,8 @@ static int ft1000NotifyProc(struct notifier_block *this, unsigned long event,
176 switch (event) { 172 switch (event) {
177 case NETDEV_CHANGENAME: 173 case NETDEV_CHANGENAME:
178 remove_proc_entry(info->netdevname, info->ft1000_proc_dir); 174 remove_proc_entry(info->netdevname, info->ft1000_proc_dir);
179 create_proc_read_entry(dev->name, 0644, info->ft1000_proc_dir, 175 proc_create_data(dev->name, 0644, info->ft1000_proc_dir,
180 ft1000ReadProc, dev); 176 &ft1000_proc_fops, dev);
181 snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); 177 snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name);
182 break; 178 break;
183 } 179 }
@@ -195,8 +191,10 @@ void ft1000InitProc(struct net_device *dev)
195 info = netdev_priv(dev); 191 info = netdev_priv(dev);
196 192
197 info->ft1000_proc_dir = proc_mkdir(FT1000_PROC, init_net.proc_net); 193 info->ft1000_proc_dir = proc_mkdir(FT1000_PROC, init_net.proc_net);
198 create_proc_read_entry(dev->name, 0644, info->ft1000_proc_dir, 194
199 ft1000ReadProc, dev); 195 proc_create_data(dev->name, 0644, info->ft1000_proc_dir,
196 &ft1000_proc_fops, dev);
197
200 snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); 198 snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name);
201 register_netdevice_notifier(&ft1000_netdev_notifier); 199 register_netdevice_notifier(&ft1000_netdev_notifier);
202} 200}
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
index 297389e8c608..3251d2e073b5 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
@@ -55,7 +55,7 @@ int numofmsgbuf = 0;
55// 55//
56// Table of entry-point routines for char device 56// Table of entry-point routines for char device
57// 57//
58static struct file_operations ft1000fops = 58static const struct file_operations ft1000fops =
59{ 59{
60 .unlocked_ioctl = ft1000_ioctl, 60 .unlocked_ioctl = ft1000_ioctl,
61 .poll = ft1000_poll_dev, 61 .poll = ft1000_poll_dev,
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
index b99640637fe0..d8294d6c9560 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
@@ -22,6 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/proc_fs.h> 24#include <linux/proc_fs.h>
25#include <linux/seq_file.h>
25#include <linux/netdevice.h> 26#include <linux/netdevice.h>
26 27
27 28
@@ -30,22 +31,17 @@
30#define FT1000_PROC_DIR "ft1000" 31#define FT1000_PROC_DIR "ft1000"
31 32
32 33
33#define PUTM_TO_PAGE(len,page,args...) \ 34#define seq_putx(m, message, size, var) \
34 len += snprintf(page+len, PAGE_SIZE - len, args) 35 seq_printf(m, message); \
36 for(i = 0; i < (size - 1); i++) \
37 seq_printf(m, "%02x:", var[i]); \
38 seq_printf(m, "%02x\n", var[i])
35 39
36#define PUTX_TO_PAGE(len,page,message,size,var) \ 40#define seq_putd(m, message, size, var) \
37 len += snprintf(page+len, PAGE_SIZE - len, message); \ 41 seq_printf(m, message); \
38 for (i = 0; i < (size - 1); i++) {\ 42 for(i = 0; i < (size - 1); i++) \
39 len += snprintf(page+len, PAGE_SIZE - len, "%02x:", var[i]); \ 43 seq_printf(m, "%d.", var[i]); \
40 } \ 44 seq_printf(m, "%d\n", var[i])
41 len += snprintf(page+len, PAGE_SIZE - len, "%02x\n", var[i])
42
43#define PUTD_TO_PAGE(len,page,message,size,var) \
44 len += snprintf(page+len, PAGE_SIZE - len, message); \
45 for (i = 0; i < (size - 1); i++) {\
46 len += snprintf(page+len, PAGE_SIZE - len, "%d.", var[i]); \
47 } \
48 len += snprintf(page+len, PAGE_SIZE - len, "%d\n", var[i])
49 45
50 46
51#define FTNET_PROC init_net.proc_net 47#define FTNET_PROC init_net.proc_net
@@ -55,19 +51,9 @@ int ft1000_read_dpram16 (struct ft1000_usb *ft1000dev, u16 indx,
55 u8 *buffer, u8 highlow); 51 u8 *buffer, u8 highlow);
56 52
57 53
58static int 54static int ft1000ReadProc(struct seq_file *m, void *v)
59ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof,
60 void *data)
61{ 55{
62 struct net_device *dev; 56 static const char *status[] = {
63 int len;
64 int i;
65 unsigned short ledStat;
66 unsigned short conStat;
67
68 struct ft1000_info *info;
69
70 char *status[] = {
71 "Idle (Disconnect)", 57 "Idle (Disconnect)",
72 "Searching", 58 "Searching",
73 "Active (Connected)", 59 "Active (Connected)",
@@ -77,22 +63,18 @@ ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof,
77 "", 63 "",
78 "", 64 "",
79 }; 65 };
66 static const char *signal[] = { "", "*", "**", "***", "****" };
80 67
81 char *signal[] = { "", "*", "**", "***", "****" }; 68 struct net_device *dev = m->private;
69 struct ft1000_info *info = netdev_priv(dev);
70 int i;
71 unsigned short ledStat;
72 unsigned short conStat;
82 int strength; 73 int strength;
83 int quality; 74 int quality;
84 struct timeval tv; 75 struct timeval tv;
85 time_t delta; 76 time_t delta;
86 77
87 dev = (struct net_device *) data;
88 info = netdev_priv(dev);
89
90 if (off > 0) {
91 *eof = 1;
92 return 0;
93 }
94
95
96 if (info->ProgConStat != 0xFF) { 78 if (info->ProgConStat != 0xFF) {
97 ft1000_read_dpram16(info->priv, FT1000_MAG_DSP_LED, 79 ft1000_read_dpram16(info->priv, FT1000_MAG_DSP_LED,
98 (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX); 80 (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX);
@@ -144,36 +126,43 @@ ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof,
144 quality = 0; 126 quality = 0;
145 } 127 }
146 128
147 len = 0; 129 seq_printf(m, "Connection Time: %02ld:%02ld:%02ld\n",
148 PUTM_TO_PAGE(len, page, "Connection Time: %02ld:%02ld:%02ld\n",
149 ((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60)); 130 ((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60));
150 PUTM_TO_PAGE(len, page, "Connection Time[s]: %ld\n", delta); 131 seq_printf(m, "Connection Time[s]: %ld\n", delta);
151 PUTM_TO_PAGE(len, page, "Asic ID: %s\n", 132 seq_printf(m, "Asic ID: %s\n",
152 (info->AsicID) == 133 (info->AsicID) == ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC");
153 ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC"); 134 seq_putx(m, "SKU: ", SKUSZ, info->Sku);
154 PUTX_TO_PAGE(len, page, "SKU: ", SKUSZ, info->Sku); 135 seq_putx(m, "EUI64: ", EUISZ, info->eui64);
155 PUTX_TO_PAGE(len, page, "EUI64: ", EUISZ, info->eui64); 136 seq_putd(m, "DSP version number: ", DSPVERSZ, info->DspVer);
156 PUTD_TO_PAGE(len, page, "DSP version number: ", DSPVERSZ, info->DspVer); 137 seq_putx(m, "Hardware Serial Number: ", HWSERNUMSZ, info->HwSerNum);
157 PUTX_TO_PAGE(len, page, "Hardware Serial Number: ", HWSERNUMSZ, 138 seq_putx(m, "Caliberation Version: ", CALVERSZ, info->RfCalVer);
158 info->HwSerNum); 139 seq_putd(m, "Caliberation Date: ", CALDATESZ, info->RfCalDate);
159 PUTX_TO_PAGE(len, page, "Caliberation Version: ", CALVERSZ, 140 seq_printf(m, "Media State: %s\n", (info->mediastate) ? "link" : "no link");
160 info->RfCalVer); 141 seq_printf(m, "Connection Status: %s\n", status[info->ConStat & 0x7]);
161 PUTD_TO_PAGE(len, page, "Caliberation Date: ", CALDATESZ, 142 seq_printf(m, "RX packets: %ld\n", info->stats.rx_packets);
162 info->RfCalDate); 143 seq_printf(m, "TX packets: %ld\n", info->stats.tx_packets);
163 PUTM_TO_PAGE(len, page, "Media State: %s\n", 144 seq_printf(m, "RX bytes: %ld\n", info->stats.rx_bytes);
164 (info->mediastate) ? "link" : "no link"); 145 seq_printf(m, "TX bytes: %ld\n", info->stats.tx_bytes);
165 PUTM_TO_PAGE(len, page, "Connection Status: %s\n", 146 seq_printf(m, "Signal Strength: %s\n", signal[strength]);
166 status[((info->ConStat) & 0x7)]); 147 seq_printf(m, "Signal Quality: %s\n", signal[quality]);
167 PUTM_TO_PAGE(len, page, "RX packets: %ld\n", info->stats.rx_packets); 148 return 0;
168 PUTM_TO_PAGE(len, page, "TX packets: %ld\n", info->stats.tx_packets); 149}
169 PUTM_TO_PAGE(len, page, "RX bytes: %ld\n", info->stats.rx_bytes); 150
170 PUTM_TO_PAGE(len, page, "TX bytes: %ld\n", info->stats.tx_bytes); 151/*
171 PUTM_TO_PAGE(len, page, "Signal Strength: %s\n", signal[strength]); 152 * seq_file wrappers for procfile show routines.
172 PUTM_TO_PAGE(len, page, "Signal Quality: %s\n", signal[quality]); 153 */
173 154static int ft1000_proc_open(struct inode *inode, struct file *file)
174 return len; 155{
156 return single_open(file, ft1000ReadProc, PDE_DATA(inode));
175} 157}
176 158
159static const struct file_operations ft1000_proc_fops = {
160 .open = ft1000_proc_open,
161 .read = seq_read,
162 .llseek = seq_lseek,
163 .release = seq_release,
164};
165
177static int 166static int
178ft1000NotifyProc(struct notifier_block *this, unsigned long event, void *ptr) 167ft1000NotifyProc(struct notifier_block *this, unsigned long event, void *ptr)
179{ 168{
@@ -186,9 +175,9 @@ ft1000NotifyProc(struct notifier_block *this, unsigned long event, void *ptr)
186 switch (event) { 175 switch (event) {
187 case NETDEV_CHANGENAME: 176 case NETDEV_CHANGENAME:
188 remove_proc_entry(info->netdevname, info->ft1000_proc_dir); 177 remove_proc_entry(info->netdevname, info->ft1000_proc_dir);
189 ft1000_proc_file = create_proc_read_entry(dev->name, 0644, 178 ft1000_proc_file =
190 info->ft1000_proc_dir, 179 proc_create_data(dev->name, 0644, info->ft1000_proc_dir,
191 ft1000ReadProc, dev); 180 &ft1000_proc_fops, dev);
192 snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); 181 snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name);
193 break; 182 break;
194 } 183 }
@@ -217,10 +206,10 @@ int ft1000_init_proc(struct net_device *dev)
217 } 206 }
218 207
219 ft1000_proc_file = 208 ft1000_proc_file =
220 create_proc_read_entry(dev->name, 0644, 209 proc_create_data(dev->name, 0644, info->ft1000_proc_dir,
221 info->ft1000_proc_dir, ft1000ReadProc, dev); 210 &ft1000_proc_fops, dev);
222 211
223 if (ft1000_proc_file == NULL) { 212 if (!ft1000_proc_file) {
224 printk(KERN_WARNING "Unable to create /proc entry.\n"); 213 printk(KERN_WARNING "Unable to create /proc entry.\n");
225 goto fail_entry; 214 goto fail_entry;
226 } 215 }
diff --git a/drivers/staging/keucr/scsiglue.c b/drivers/staging/keucr/scsiglue.c
index 083b20e6253e..48e1005349da 100644
--- a/drivers/staging/keucr/scsiglue.c
+++ b/drivers/staging/keucr/scsiglue.c
@@ -229,26 +229,18 @@ void usb_stor_report_bus_reset(struct us_data *us)
229 229
230/* we use this macro to help us write into the buffer */ 230/* we use this macro to help us write into the buffer */
231#undef SPRINTF 231#undef SPRINTF
232#define SPRINTF(args...) \ 232#define SPRINTF(args...) seq_printf(m, ##args)
233 do { \
234 if (pos < buffer+length) \
235 pos += sprintf(pos, ## args); \
236 } while (0)
237 233
238/* 234static int write_info(struct Scsi_Host *host, char *buffer, int length)
239 * proc_info() 235{
240 */ 236 return length;
241static int proc_info(struct Scsi_Host *host, char *buffer, char **start, 237}
242 off_t offset, int length, int inout) 238
239static int show_info(struct seq_file *m, struct Scsi_Host *host)
243{ 240{
244 struct us_data *us = host_to_us(host); 241 struct us_data *us = host_to_us(host);
245 char *pos = buffer;
246 const char *string; 242 const char *string;
247 243
248 /* pr_info("scsiglue --- proc_info\n"); */
249 if (inout)
250 return length;
251
252 /* print the controller name */ 244 /* print the controller name */
253 SPRINTF(" Host scsi%d: usb-storage\n", host->host_no); 245 SPRINTF(" Host scsi%d: usb-storage\n", host->host_no);
254 246
@@ -278,29 +270,17 @@ static int proc_info(struct Scsi_Host *host, char *buffer, char **start,
278 SPRINTF(" Transport: %s\n", us->transport_name); 270 SPRINTF(" Transport: %s\n", us->transport_name);
279 271
280 /* show the device flags */ 272 /* show the device flags */
281 if (pos < buffer + length) { 273 SPRINTF(" Quirks:");
282 pos += sprintf(pos, " Quirks:");
283 274
284#define US_FLAG(name, value) \ 275#define US_FLAG(name, value) \
285 do { \ 276 do { \
286 if (us->fflags & value) \ 277 if (us->fflags & value) \
287 pos += sprintf(pos, " " #name); \ 278 SPRINTF(" " #name); \
288 } while (0); 279 } while (0);
289US_DO_ALL_FLAGS 280US_DO_ALL_FLAGS
290#undef US_FLAG 281#undef US_FLAG
291 282 seq_putc(m, '\n');
292 *(pos++) = '\n'; 283 return 0;
293 }
294
295 /* Calculate start of next buffer, and return value. */
296 *start = buffer + offset;
297
298 if ((pos - buffer) < offset)
299 return 0;
300 else if ((pos - buffer - offset) < length)
301 return pos - buffer - offset;
302 else
303 return length;
304} 284}
305 285
306/*********************************************************************** 286/***********************************************************************
@@ -351,7 +331,8 @@ struct scsi_host_template usb_stor_host_template = {
351 /* basic userland interface stuff */ 331 /* basic userland interface stuff */
352 .name = "eucr-storage", 332 .name = "eucr-storage",
353 .proc_name = "eucr-storage", 333 .proc_name = "eucr-storage",
354 .proc_info = proc_info, 334 .write_info = write_info,
335 .show_info = show_info,
355 .info = host_info, 336 .info = host_info,
356 337
357 /* command interface -- queued only */ 338 /* command interface -- queued only */
diff --git a/drivers/staging/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h
index 70ea4145b4c8..edacc8001640 100644
--- a/drivers/staging/rtl8187se/r8180.h
+++ b/drivers/staging/rtl8187se/r8180.h
@@ -372,7 +372,6 @@ typedef struct r8180_priv
372 struct Stats stats; 372 struct Stats stats;
373 struct _link_detect_t link_detect; //YJ,add,080828 373 struct _link_detect_t link_detect; //YJ,add,080828
374 struct iw_statistics wstats; 374 struct iw_statistics wstats;
375 struct proc_dir_entry *dir_dev;
376 375
377 /*RX stuff*/ 376 /*RX stuff*/
378 u32 *rxring; 377 u32 *rxring;
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index d10d75e8a33f..f7c1d9905ec6 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -36,6 +36,8 @@
36#include <linux/syscalls.h> 36#include <linux/syscalls.h>
37#include <linux/eeprom_93cx6.h> 37#include <linux/eeprom_93cx6.h>
38#include <linux/interrupt.h> 38#include <linux/interrupt.h>
39#include <linux/proc_fs.h>
40#include <linux/seq_file.h>
39 41
40#include "r8180_hw.h" 42#include "r8180_hw.h"
41#include "r8180.h" 43#include "r8180.h"
@@ -204,51 +206,35 @@ void rtl8180_start_tx_beacon(struct net_device *dev);
204 206
205static struct proc_dir_entry *rtl8180_proc; 207static struct proc_dir_entry *rtl8180_proc;
206 208
207static int proc_get_registers(char *page, char **start, 209static int proc_get_registers(struct seq_file *m, void *v)
208 off_t offset, int count,
209 int *eof, void *data)
210{ 210{
211 struct net_device *dev = data; 211 struct net_device *dev = m->private;
212 int len = 0; 212 int i, n, max = 0xff;
213 int i, n;
214 int max = 0xff;
215 213
216 /* This dump the current register page */ 214 /* This dump the current register page */
217 for (n = 0; n <= max;) { 215 for (n = 0; n <= max;) {
218 len += snprintf(page + len, count - len, "\nD: %2x > ", n); 216 seq_printf(m, "\nD: %2x > ", n);
219 217
220 for (i = 0; i < 16 && n <= max; i++, n++) 218 for (i = 0; i < 16 && n <= max; i++, n++)
221 len += snprintf(page + len, count - len, "%2x ", 219 seq_printf(m, "%2x ", read_nic_byte(dev, n));
222 read_nic_byte(dev, n));
223 } 220 }
224 len += snprintf(page + len, count - len, "\n"); 221 seq_putc(m, '\n');
225 222 return 0;
226 *eof = 1;
227 return len;
228} 223}
229 224
230int get_curr_tx_free_desc(struct net_device *dev, int priority); 225int get_curr_tx_free_desc(struct net_device *dev, int priority);
231 226
232static int proc_get_stats_hw(char *page, char **start, 227static int proc_get_stats_hw(struct seq_file *m, void *v)
233 off_t offset, int count,
234 int *eof, void *data)
235{ 228{
236 int len = 0; 229 return 0;
237
238 *eof = 1;
239 return len;
240} 230}
241 231
242static int proc_get_stats_rx(char *page, char **start, 232static int proc_get_stats_rx(struct seq_file *m, void *v)
243 off_t offset, int count,
244 int *eof, void *data)
245{ 233{
246 struct net_device *dev = data; 234 struct net_device *dev = m->private;
247 struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); 235 struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
248 236
249 int len = 0; 237 seq_printf(m,
250
251 len += snprintf(page + len, count - len,
252 "RX OK: %lu\n" 238 "RX OK: %lu\n"
253 "RX Retry: %lu\n" 239 "RX Retry: %lu\n"
254 "RX CRC Error(0-500): %lu\n" 240 "RX CRC Error(0-500): %lu\n"
@@ -263,22 +249,17 @@ static int proc_get_stats_rx(char *page, char **start,
263 priv->stats.rxicverr 249 priv->stats.rxicverr
264 ); 250 );
265 251
266 *eof = 1; 252 return 0;
267 return len;
268} 253}
269 254
270static int proc_get_stats_tx(char *page, char **start, 255static int proc_get_stats_tx(struct seq_file *m, void *v)
271 off_t offset, int count,
272 int *eof, void *data)
273{ 256{
274 struct net_device *dev = data; 257 struct net_device *dev = m->private;
275 struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); 258 struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
276
277 int len = 0;
278 unsigned long totalOK; 259 unsigned long totalOK;
279 260
280 totalOK = priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint; 261 totalOK = priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint;
281 len += snprintf(page + len, count - len, 262 seq_printf(m,
282 "TX OK: %lu\n" 263 "TX OK: %lu\n"
283 "TX Error: %lu\n" 264 "TX Error: %lu\n"
284 "TX Retry: %lu\n" 265 "TX Retry: %lu\n"
@@ -291,8 +272,7 @@ static int proc_get_stats_tx(char *page, char **start,
291 priv->stats.txbeaconerr 272 priv->stats.txbeaconerr
292 ); 273 );
293 274
294 *eof = 1; 275 return 0;
295 return len;
296} 276}
297 277
298void rtl8180_proc_module_init(void) 278void rtl8180_proc_module_init(void)
@@ -308,59 +288,61 @@ void rtl8180_proc_module_remove(void)
308 288
309void rtl8180_proc_remove_one(struct net_device *dev) 289void rtl8180_proc_remove_one(struct net_device *dev)
310{ 290{
311 struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); 291 remove_proc_subtree(dev->name, rtl8180_proc);
312 if (priv->dir_dev) {
313 remove_proc_entry("stats-hw", priv->dir_dev);
314 remove_proc_entry("stats-tx", priv->dir_dev);
315 remove_proc_entry("stats-rx", priv->dir_dev);
316 remove_proc_entry("registers", priv->dir_dev);
317 priv->dir_dev = NULL;
318 }
319} 292}
320 293
321void rtl8180_proc_init_one(struct net_device *dev) 294/*
295 * seq_file wrappers for procfile show routines.
296 */
297static int rtl8180_proc_open(struct inode *inode, struct file *file)
322{ 298{
323 struct proc_dir_entry *e; 299 struct net_device *dev = proc_get_parent_data(inode);
324 struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); 300 int (*show)(struct seq_file *, void *) = PDE_DATA(inode);
325 301
326 priv->dir_dev = rtl8180_proc; 302 return single_open(file, show, dev);
327 if (!priv->dir_dev) { 303}
328 DMESGE("Unable to initialize /proc/net/r8180/%s\n",
329 dev->name);
330 return;
331 }
332 304
333 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, 305static const struct file_operations rtl8180_proc_fops = {
334 priv->dir_dev, proc_get_stats_hw, dev); 306 .open = rtl8180_proc_open,
335 if (!e) { 307 .read = seq_read,
336 DMESGE("Unable to initialize " 308 .llseek = seq_lseek,
337 "/proc/net/r8180/%s/stats-hw\n", 309 .release = seq_release,
338 dev->name); 310};
339 }
340 311
341 e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, 312/*
342 priv->dir_dev, proc_get_stats_rx, dev); 313 * Table of proc files we need to create.
343 if (!e) { 314 */
344 DMESGE("Unable to initialize " 315struct rtl8180_proc_file {
345 "/proc/net/r8180/%s/stats-rx\n", 316 char name[12];
346 dev->name); 317 int (*show)(struct seq_file *, void *);
347 } 318};
348 319
320static const struct rtl8180_proc_file rtl8180_proc_files[] = {
321 { "stats-hw", &proc_get_stats_hw },
322 { "stats-rx", &proc_get_stats_rx },
323 { "stats-tx", &proc_get_stats_tx },
324 { "registers", &proc_get_registers },
325 { "" }
326};
327
328void rtl8180_proc_init_one(struct net_device *dev)
329{
330 const struct rtl8180_proc_file *f;
331 struct proc_dir_entry *dir;
349 332
350 e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, 333 dir = proc_mkdir_data(dev->name, 0, rtl8180_proc, dev);
351 priv->dir_dev, proc_get_stats_tx, dev); 334 if (!dir) {
352 if (!e) { 335 DMESGE("Unable to initialize /proc/net/r8180/%s\n", dev->name);
353 DMESGE("Unable to initialize " 336 return;
354 "/proc/net/r8180/%s/stats-tx\n",
355 dev->name);
356 } 337 }
357 338
358 e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, 339 for (f = rtl8180_proc_files; f->name[0]; f++) {
359 priv->dir_dev, proc_get_registers, dev); 340 if (!proc_create_data(f->name, S_IFREG | S_IRUGO, dir,
360 if (!e) { 341 &rtl8180_proc_fops, f->show)) {
361 DMESGE("Unable to initialize " 342 DMESGE("Unable to initialize /proc/net/r8180/%s/%s\n",
362 "/proc/net/r8180/%s/registers\n", 343 dev->name, f->name);
363 dev->name); 344 return;
345 }
364 } 346 }
365} 347}
366 348
diff --git a/drivers/staging/rtl8192e/rtl8192e/Makefile b/drivers/staging/rtl8192e/rtl8192e/Makefile
index 313a92ec6833..a2c4fb4ba1af 100644
--- a/drivers/staging/rtl8192e/rtl8192e/Makefile
+++ b/drivers/staging/rtl8192e/rtl8192e/Makefile
@@ -7,7 +7,6 @@ r8192e_pci-objs := \
7 r8190P_rtl8256.o \ 7 r8190P_rtl8256.o \
8 rtl_cam.o \ 8 rtl_cam.o \
9 rtl_core.o \ 9 rtl_core.o \
10 rtl_debug.o \
11 rtl_dm.o \ 10 rtl_dm.o \
12 rtl_eeprom.o \ 11 rtl_eeprom.o \
13 rtl_ethtool.o \ 12 rtl_ethtool.o \
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 4ebf99b30975..2b6c61c5d3d8 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -2966,8 +2966,6 @@ static int rtl8192_pci_probe(struct pci_dev *pdev,
2966 goto err_free_irq; 2966 goto err_free_irq;
2967 RT_TRACE(COMP_INIT, "dev name: %s\n", dev->name); 2967 RT_TRACE(COMP_INIT, "dev name: %s\n", dev->name);
2968 2968
2969 rtl8192_proc_init_one(dev);
2970
2971 if (priv->polling_timer_on == 0) 2969 if (priv->polling_timer_on == 0)
2972 check_rfctrl_gpio_timer((unsigned long)dev); 2970 check_rfctrl_gpio_timer((unsigned long)dev);
2973 2971
@@ -3003,7 +3001,6 @@ static void rtl8192_pci_disconnect(struct pci_dev *pdev)
3003 del_timer_sync(&priv->gpio_polling_timer); 3001 del_timer_sync(&priv->gpio_polling_timer);
3004 cancel_delayed_work(&priv->gpio_change_rf_wq); 3002 cancel_delayed_work(&priv->gpio_change_rf_wq);
3005 priv->polling_timer_on = 0; 3003 priv->polling_timer_on = 0;
3006 rtl8192_proc_remove_one(dev);
3007 rtl8192_down(dev, true); 3004 rtl8192_down(dev, true);
3008 deinit_hal_dm(dev); 3005 deinit_hal_dm(dev);
3009 if (priv->pFirmware) { 3006 if (priv->pFirmware) {
@@ -3093,7 +3090,6 @@ static int __init rtl8192_pci_module_init(void)
3093 printk(KERN_INFO "\nLinux kernel driver for RTL8192E WLAN cards\n"); 3090 printk(KERN_INFO "\nLinux kernel driver for RTL8192E WLAN cards\n");
3094 printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan Driver\n"); 3091 printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan Driver\n");
3095 3092
3096 rtl8192_proc_module_init();
3097 if (0 != pci_register_driver(&rtl8192_pci_driver)) { 3093 if (0 != pci_register_driver(&rtl8192_pci_driver)) {
3098 DMESG("No device found"); 3094 DMESG("No device found");
3099 /*pci_unregister_driver (&rtl8192_pci_driver);*/ 3095 /*pci_unregister_driver (&rtl8192_pci_driver);*/
@@ -3107,7 +3103,6 @@ static void __exit rtl8192_pci_module_exit(void)
3107 pci_unregister_driver(&rtl8192_pci_driver); 3103 pci_unregister_driver(&rtl8192_pci_driver);
3108 3104
3109 RT_TRACE(COMP_DOWN, "Exiting"); 3105 RT_TRACE(COMP_DOWN, "Exiting");
3110 rtl8192_proc_module_remove();
3111} 3106}
3112 3107
3113void check_rfctrl_gpio_timer(unsigned long data) 3108void check_rfctrl_gpio_timer(unsigned long data)
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index 320d5fc026b4..87d4d349c890 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -1085,10 +1085,4 @@ void ActUpdateChannelAccessSetting(struct net_device *dev,
1085 enum wireless_mode WirelessMode, 1085 enum wireless_mode WirelessMode,
1086 struct channel_access_setting *ChnlAccessSetting); 1086 struct channel_access_setting *ChnlAccessSetting);
1087 1087
1088/* proc stuff from rtl_debug.c */
1089void rtl8192_proc_init_one(struct net_device *dev);
1090void rtl8192_proc_remove_one(struct net_device *dev);
1091void rtl8192_proc_module_init(void);
1092void rtl8192_proc_module_remove(void);
1093
1094#endif 1088#endif
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_debug.c b/drivers/staging/rtl8192e/rtl8192e/rtl_debug.c
deleted file mode 100644
index c19b14cd6f77..000000000000
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_debug.c
+++ /dev/null
@@ -1,1029 +0,0 @@
1/******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3 *
4 * Based on the r8180 driver, which is:
5 * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 *
19 * The full GNU General Public License is included in this distribution in the
20 * file called LICENSE.
21 *
22 * Contact Information:
23 * wlanfae <wlanfae@realtek.com>
24******************************************************************************/
25#include "rtl_core.h"
26#include "r8192E_phy.h"
27#include "r8192E_phyreg.h"
28#include "r8190P_rtl8256.h" /* RTL8225 Radio frontend */
29#include "r8192E_cmdpkt.h"
30
31/****************************************************************************
32 -----------------------------PROCFS STUFF-------------------------
33*****************************************************************************/
34/*This part is related to PROC, which will record some statistics. */
35static struct proc_dir_entry *rtl8192_proc;
36
37static int proc_get_stats_ap(char *page, char **start,
38 off_t offset, int count,
39 int *eof, void *data)
40{
41 struct net_device *dev = data;
42 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
43 struct rtllib_device *ieee = priv->rtllib;
44 struct rtllib_network *target;
45 int len = 0;
46
47 list_for_each_entry(target, &ieee->network_list, list) {
48
49 len += snprintf(page + len, count - len,
50 "%s ", target->ssid);
51
52 if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0)
53 len += snprintf(page + len, count - len,
54 "WPA\n");
55 else
56 len += snprintf(page + len, count - len,
57 "non_WPA\n");
58
59 }
60
61 *eof = 1;
62 return len;
63}
64
65static int proc_get_registers_0(char *page, char **start,
66 off_t offset, int count,
67 int *eof, void *data)
68{
69 struct net_device *dev = data;
70
71 int len = 0;
72 int i, n, page0;
73
74 int max = 0xff;
75 page0 = 0x000;
76
77 len += snprintf(page + len, count - len,
78 "\n####################page %x##################\n ",
79 (page0>>8));
80 len += snprintf(page + len, count - len,
81 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
82 "0C 0D 0E 0F");
83 for (n = 0; n <= max;) {
84 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
85 for (i = 0; i < 16 && n <= max; n++, i++)
86 len += snprintf(page + len, count - len,
87 "%2.2x ", read_nic_byte(dev,
88 (page0 | n)));
89 }
90 len += snprintf(page + len, count - len, "\n");
91 *eof = 1;
92 return len;
93
94}
95static int proc_get_registers_1(char *page, char **start,
96 off_t offset, int count,
97 int *eof, void *data)
98{
99 struct net_device *dev = data;
100
101 int len = 0;
102 int i, n, page0;
103
104 int max = 0xff;
105 page0 = 0x100;
106
107 /* This dump the current register page */
108 len += snprintf(page + len, count - len,
109 "\n####################page %x##################\n ",
110 (page0>>8));
111 len += snprintf(page + len, count - len,
112 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
113 "0C 0D 0E 0F");
114 for (n = 0; n <= max;) {
115 len += snprintf(page + len, count - len,
116 "\nD: %2x > ", n);
117 for (i = 0; i < 16 && n <= max; i++, n++)
118 len += snprintf(page + len, count - len,
119 "%2.2x ", read_nic_byte(dev,
120 (page0 | n)));
121 }
122 len += snprintf(page + len, count - len, "\n");
123 *eof = 1;
124 return len;
125
126}
127static int proc_get_registers_2(char *page, char **start,
128 off_t offset, int count,
129 int *eof, void *data)
130{
131 struct net_device *dev = data;
132
133 int len = 0;
134 int i, n, page0;
135
136 int max = 0xff;
137 page0 = 0x200;
138
139 /* This dump the current register page */
140 len += snprintf(page + len, count - len,
141 "\n####################page %x##################\n ",
142 (page0 >> 8));
143 len += snprintf(page + len, count - len,
144 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C "
145 "0D 0E 0F");
146 for (n = 0; n <= max;) {
147 len += snprintf(page + len, count - len,
148 "\nD: %2x > ", n);
149 for (i = 0; i < 16 && n <= max; i++, n++)
150 len += snprintf(page + len, count - len,
151 "%2.2x ", read_nic_byte(dev,
152 (page0 | n)));
153 }
154 len += snprintf(page + len, count - len, "\n");
155 *eof = 1;
156 return len;
157
158}
159static int proc_get_registers_3(char *page, char **start,
160 off_t offset, int count,
161 int *eof, void *data)
162{
163 struct net_device *dev = data;
164
165 int len = 0;
166 int i, n, page0;
167
168 int max = 0xff;
169 page0 = 0x300;
170
171 /* This dump the current register page */
172 len += snprintf(page + len, count - len,
173 "\n####################page %x##################\n ",
174 (page0>>8));
175 len += snprintf(page + len, count - len,
176 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
177 "0C 0D 0E 0F");
178 for (n = 0; n <= max;) {
179 len += snprintf(page + len, count - len,
180 "\nD: %2x > ", n);
181 for (i = 0; i < 16 && n <= max; i++, n++)
182 len += snprintf(page + len, count - len,
183 "%2.2x ", read_nic_byte(dev,
184 (page0 | n)));
185 }
186 len += snprintf(page + len, count - len, "\n");
187 *eof = 1;
188 return len;
189
190}
191static int proc_get_registers_4(char *page, char **start,
192 off_t offset, int count,
193 int *eof, void *data)
194{
195 struct net_device *dev = data;
196
197 int len = 0;
198 int i, n, page0;
199
200 int max = 0xff;
201 page0 = 0x400;
202
203 /* This dump the current register page */
204 len += snprintf(page + len, count - len,
205 "\n####################page %x##################\n ",
206 (page0>>8));
207 len += snprintf(page + len, count - len,
208 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
209 "0C 0D 0E 0F");
210 for (n = 0; n <= max;) {
211 len += snprintf(page + len, count - len,
212 "\nD: %2x > ", n);
213 for (i = 0; i < 16 && n <= max; i++, n++)
214 len += snprintf(page + len, count - len,
215 "%2.2x ", read_nic_byte(dev,
216 (page0 | n)));
217 }
218 len += snprintf(page + len, count - len, "\n");
219 *eof = 1;
220 return len;
221
222}
223static int proc_get_registers_5(char *page, char **start,
224 off_t offset, int count,
225 int *eof, void *data)
226{
227 struct net_device *dev = data;
228
229 int len = 0;
230 int i, n, page0;
231
232 int max = 0xff;
233 page0 = 0x500;
234
235 /* This dump the current register page */
236 len += snprintf(page + len, count - len,
237 "\n####################page %x##################\n ",
238 (page0 >> 8));
239 len += snprintf(page + len, count - len,
240 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
241 "0C 0D 0E 0F");
242 for (n = 0; n <= max;) {
243 len += snprintf(page + len, count - len,
244 "\nD: %2x > ", n);
245 for (i = 0; i < 16 && n <= max; i++, n++)
246 len += snprintf(page + len, count - len,
247 "%2.2x ", read_nic_byte(dev,
248 (page0 | n)));
249 }
250 len += snprintf(page + len, count - len, "\n");
251 *eof = 1;
252 return len;
253
254}
255static int proc_get_registers_6(char *page, char **start,
256 off_t offset, int count,
257 int *eof, void *data)
258{
259 struct net_device *dev = data;
260
261 int len = 0;
262 int i, n, page0;
263
264 int max = 0xff;
265 page0 = 0x600;
266
267 /* This dump the current register page */
268 len += snprintf(page + len, count - len,
269 "\n####################page %x##################\n ",
270 (page0>>8));
271 len += snprintf(page + len, count - len,
272 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
273 "0C 0D 0E 0F");
274 for (n = 0; n <= max;) {
275 len += snprintf(page + len, count - len,
276 "\nD: %2x > ", n);
277 for (i = 0; i < 16 && n <= max; i++, n++)
278 len += snprintf(page + len, count - len,
279 "%2.2x ", read_nic_byte(dev,
280 (page0 | n)));
281 }
282 len += snprintf(page + len, count - len, "\n");
283 *eof = 1;
284 return len;
285
286}
287static int proc_get_registers_7(char *page, char **start,
288 off_t offset, int count,
289 int *eof, void *data)
290{
291 struct net_device *dev = data;
292
293 int len = 0;
294 int i, n, page0;
295
296 int max = 0xff;
297 page0 = 0x700;
298
299 /* This dump the current register page */
300 len += snprintf(page + len, count - len,
301 "\n####################page %x##################\n ",
302 (page0 >> 8));
303 len += snprintf(page + len, count - len,
304 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C "
305 "0D 0E 0F");
306 for (n = 0; n <= max;) {
307 len += snprintf(page + len, count - len,
308 "\nD: %2x > ", n);
309 for (i = 0; i < 16 && n <= max; i++, n++)
310 len += snprintf(page + len, count - len,
311 "%2.2x ", read_nic_byte(dev,
312 (page0 | n)));
313 }
314 len += snprintf(page + len, count - len, "\n");
315 *eof = 1;
316 return len;
317
318}
319static int proc_get_registers_8(char *page, char **start,
320 off_t offset, int count,
321 int *eof, void *data)
322{
323 struct net_device *dev = data;
324
325 int len = 0;
326 int i, n, page0;
327
328 int max = 0xff;
329 page0 = 0x800;
330
331 /* This dump the current register page */
332 len += snprintf(page + len, count - len,
333 "\n####################page %x##################\n",
334 (page0 >> 8));
335 for (n = 0; n <= max;) {
336 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
337 for (i = 0; i < 4 && n <= max; n += 4, i++)
338 len += snprintf(page + len, count - len,
339 "%8.8x ", rtl8192_QueryBBReg(dev,
340 (page0 | n), bMaskDWord));
341 }
342 len += snprintf(page + len, count - len, "\n");
343 *eof = 1;
344 return len;
345
346}
347static int proc_get_registers_9(char *page, char **start,
348 off_t offset, int count,
349 int *eof, void *data)
350{
351 struct net_device *dev = data;
352
353 int len = 0;
354 int i, n, page0;
355
356 int max = 0xff;
357 page0 = 0x900;
358
359 /* This dump the current register page */
360 len += snprintf(page + len, count - len,
361 "\n####################page %x##################\n",
362 (page0>>8));
363 for (n = 0; n <= max;) {
364 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
365 for (i = 0; i < 4 && n <= max; n += 4, i++)
366 len += snprintf(page + len, count - len,
367 "%8.8x ", rtl8192_QueryBBReg(dev,
368 (page0 | n), bMaskDWord));
369 }
370 len += snprintf(page + len, count - len, "\n");
371 *eof = 1;
372 return len;
373}
374static int proc_get_registers_a(char *page, char **start,
375 off_t offset, int count,
376 int *eof, void *data)
377{
378 struct net_device *dev = data;
379
380 int len = 0;
381 int i, n, page0;
382
383 int max = 0xff;
384 page0 = 0xa00;
385
386 /* This dump the current register page */
387 len += snprintf(page + len, count - len,
388 "\n####################page %x##################\n",
389 (page0>>8));
390 for (n = 0; n <= max;) {
391 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
392 for (i = 0; i < 4 && n <= max; n += 4, i++)
393 len += snprintf(page + len, count - len,
394 "%8.8x ", rtl8192_QueryBBReg(dev,
395 (page0 | n), bMaskDWord));
396 }
397 len += snprintf(page + len, count - len, "\n");
398 *eof = 1;
399 return len;
400}
401static int proc_get_registers_b(char *page, char **start,
402 off_t offset, int count,
403 int *eof, void *data)
404{
405 struct net_device *dev = data;
406
407 int len = 0;
408 int i, n, page0;
409
410 int max = 0xff;
411 page0 = 0xb00;
412
413 /* This dump the current register page */
414 len += snprintf(page + len, count - len,
415 "\n####################page %x##################\n",
416 (page0 >> 8));
417 for (n = 0; n <= max;) {
418 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
419 for (i = 0; i < 4 && n <= max; n += 4, i++)
420 len += snprintf(page + len, count - len,
421 "%8.8x ", rtl8192_QueryBBReg(dev,
422 (page0 | n), bMaskDWord));
423 }
424 len += snprintf(page + len, count - len, "\n");
425 *eof = 1;
426 return len;
427}
428static int proc_get_registers_c(char *page, char **start,
429 off_t offset, int count,
430 int *eof, void *data)
431{
432 struct net_device *dev = data;
433
434 int len = 0;
435 int i, n, page0;
436
437 int max = 0xff;
438 page0 = 0xc00;
439
440 /* This dump the current register page */
441 len += snprintf(page + len, count - len,
442 "\n####################page %x##################\n",
443 (page0>>8));
444 for (n = 0; n <= max;) {
445 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
446 for (i = 0; i < 4 && n <= max; n += 4, i++)
447 len += snprintf(page + len, count - len,
448 "%8.8x ", rtl8192_QueryBBReg(dev,
449 (page0 | n), bMaskDWord));
450 }
451 len += snprintf(page + len, count - len, "\n");
452 *eof = 1;
453 return len;
454}
455static int proc_get_registers_d(char *page, char **start,
456 off_t offset, int count,
457 int *eof, void *data)
458{
459 struct net_device *dev = data;
460
461 int len = 0;
462 int i, n, page0;
463
464 int max = 0xff;
465 page0 = 0xd00;
466
467 /* This dump the current register page */
468 len += snprintf(page + len, count - len,
469 "\n####################page %x##################\n",
470 (page0>>8));
471 for (n = 0; n <= max;) {
472 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
473 for (i = 0; i < 4 && n <= max; n += 4, i++)
474 len += snprintf(page + len, count - len,
475 "%8.8x ", rtl8192_QueryBBReg(dev,
476 (page0 | n), bMaskDWord));
477 }
478 len += snprintf(page + len, count - len, "\n");
479 *eof = 1;
480 return len;
481}
482static int proc_get_registers_e(char *page, char **start,
483 off_t offset, int count,
484 int *eof, void *data)
485{
486 struct net_device *dev = data;
487
488 int len = 0;
489 int i, n, page0;
490
491 int max = 0xff;
492 page0 = 0xe00;
493
494 /* This dump the current register page */
495 len += snprintf(page + len, count - len,
496 "\n####################page %x##################\n",
497 (page0>>8));
498 for (n = 0; n <= max;) {
499 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
500 for (i = 0; i < 4 && n <= max; n += 4, i++)
501 len += snprintf(page + len, count - len,
502 "%8.8x ", rtl8192_QueryBBReg(dev,
503 (page0 | n), bMaskDWord));
504 }
505 len += snprintf(page + len, count - len, "\n");
506 *eof = 1;
507 return len;
508}
509
510static int proc_get_reg_rf_a(char *page, char **start,
511 off_t offset, int count,
512 int *eof, void *data)
513{
514 struct net_device *dev = data;
515
516 int len = 0;
517 int i, n;
518
519 int max = 0xff;
520
521 /* This dump the current register page */
522 len += snprintf(page + len, count - len,
523 "\n#################### RF-A ##################\n ");
524 for (n = 0; n <= max;) {
525 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
526 for (i = 0; i < 4 && n <= max; n += 4, i++)
527 len += snprintf(page + len, count - len,
528 "%8.8x ", rtl8192_phy_QueryRFReg(dev,
529 (enum rf90_radio_path)RF90_PATH_A, n,
530 bMaskDWord));
531 }
532 len += snprintf(page + len, count - len, "\n");
533 *eof = 1;
534 return len;
535}
536
537static int proc_get_reg_rf_b(char *page, char **start,
538 off_t offset, int count,
539 int *eof, void *data)
540{
541 struct net_device *dev = data;
542
543 int len = 0;
544 int i, n;
545
546 int max = 0xff;
547
548 /* This dump the current register page */
549 len += snprintf(page + len, count - len,
550 "\n#################### RF-B ##################\n ");
551 for (n = 0; n <= max;) {
552 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
553 for (i = 0; i < 4 && n <= max; n += 4, i++)
554 len += snprintf(page + len, count - len,
555 "%8.8x ", rtl8192_phy_QueryRFReg(dev,
556 (enum rf90_radio_path)RF90_PATH_B, n,
557 bMaskDWord));
558 }
559 len += snprintf(page + len, count - len, "\n");
560 *eof = 1;
561 return len;
562}
563
564static int proc_get_reg_rf_c(char *page, char **start,
565 off_t offset, int count,
566 int *eof, void *data)
567{
568 struct net_device *dev = data;
569
570 int len = 0;
571 int i, n;
572
573 int max = 0xff;
574
575 /* This dump the current register page */
576 len += snprintf(page + len, count - len,
577 "\n#################### RF-C ##################\n");
578 for (n = 0; n <= max;) {
579 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
580 for (i = 0; i < 4 && n <= max; n += 4, i++)
581 len += snprintf(page + len, count - len,
582 "%8.8x ", rtl8192_phy_QueryRFReg(dev,
583 (enum rf90_radio_path)RF90_PATH_C, n,
584 bMaskDWord));
585 }
586 len += snprintf(page + len, count - len, "\n");
587 *eof = 1;
588 return len;
589}
590
591static int proc_get_reg_rf_d(char *page, char **start,
592 off_t offset, int count,
593 int *eof, void *data)
594{
595 struct net_device *dev = data;
596
597 int len = 0;
598 int i, n;
599
600 int max = 0xff;
601
602 /* This dump the current register page */
603 len += snprintf(page + len, count - len,
604 "\n#################### RF-D ##################\n ");
605 for (n = 0; n <= max;) {
606 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
607 for (i = 0; i < 4 && n <= max; n += 4, i++)
608 len += snprintf(page + len, count - len,
609 "%8.8x ", rtl8192_phy_QueryRFReg(dev,
610 (enum rf90_radio_path)RF90_PATH_D, n,
611 bMaskDWord));
612 }
613 len += snprintf(page + len, count - len, "\n");
614 *eof = 1;
615 return len;
616}
617
618static int proc_get_cam_register_1(char *page, char **start,
619 off_t offset, int count,
620 int *eof, void *data)
621{
622 struct net_device *dev = data;
623 u32 target_command = 0;
624 u32 target_content = 0;
625 u8 entry_i = 0;
626 u32 ulStatus;
627 int len = 0;
628 int i = 100, j = 0;
629
630 /* This dump the current register page */
631 len += snprintf(page + len, count - len,
632 "\n#################### SECURITY CAM (0-10) ######"
633 "############\n ");
634 for (j = 0; j < 11; j++) {
635 len += snprintf(page + len, count - len, "\nD: %2x > ", j);
636 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
637 target_command = entry_i+CAM_CONTENT_COUNT*j;
638 target_command = target_command | BIT31;
639
640 while ((i--) >= 0) {
641 ulStatus = read_nic_dword(dev, RWCAM);
642 if (ulStatus & BIT31)
643 continue;
644 else
645 break;
646 }
647 write_nic_dword(dev, RWCAM, target_command);
648 target_content = read_nic_dword(dev, RCAMO);
649 len += snprintf(page + len, count - len, "%8.8x ",
650 target_content);
651 }
652 }
653
654 len += snprintf(page + len, count - len, "\n");
655 *eof = 1;
656 return len;
657}
658
659static int proc_get_cam_register_2(char *page, char **start,
660 off_t offset, int count,
661 int *eof, void *data)
662{
663 struct net_device *dev = data;
664 u32 target_command = 0;
665 u32 target_content = 0;
666 u8 entry_i = 0;
667 u32 ulStatus;
668 int len = 0;
669 int i = 100, j = 0;
670
671 /* This dump the current register page */
672 len += snprintf(page + len, count - len,
673 "\n#################### SECURITY CAM (11-21) "
674 "##################\n ");
675 for (j = 11; j < 22; j++) {
676 len += snprintf(page + len, count - len, "\nD: %2x > ", j);
677 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
678 target_command = entry_i + CAM_CONTENT_COUNT * j;
679 target_command = target_command | BIT31;
680
681 while ((i--) >= 0) {
682 ulStatus = read_nic_dword(dev, RWCAM);
683 if (ulStatus & BIT31)
684 continue;
685 else
686 break;
687 }
688 write_nic_dword(dev, RWCAM, target_command);
689 target_content = read_nic_dword(dev, RCAMO);
690 len += snprintf(page + len, count - len, "%8.8x ",
691 target_content);
692 }
693 }
694
695 len += snprintf(page + len, count - len, "\n");
696 *eof = 1;
697 return len;
698}
699
700static int proc_get_cam_register_3(char *page, char **start,
701 off_t offset, int count,
702 int *eof, void *data)
703{
704 struct net_device *dev = data;
705 u32 target_command = 0;
706 u32 target_content = 0;
707 u8 entry_i = 0;
708 u32 ulStatus;
709 int len = 0;
710 int i = 100, j = 0;
711
712 /* This dump the current register page */
713 len += snprintf(page + len, count - len,
714 "\n#################### SECURITY CAM (22-31) ######"
715 "############\n ");
716 for (j = 22; j < TOTAL_CAM_ENTRY; j++) {
717 len += snprintf(page + len, count - len, "\nD: %2x > ", j);
718 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
719 target_command = entry_i + CAM_CONTENT_COUNT * j;
720 target_command = target_command | BIT31;
721
722 while ((i--) >= 0) {
723 ulStatus = read_nic_dword(dev, RWCAM);
724 if (ulStatus & BIT31)
725 continue;
726 else
727 break;
728 }
729 write_nic_dword(dev, RWCAM, target_command);
730 target_content = read_nic_dword(dev, RCAMO);
731 len += snprintf(page + len, count - len, "%8.8x ",
732 target_content);
733 }
734 }
735
736 len += snprintf(page + len, count - len, "\n");
737 *eof = 1;
738 return len;
739}
740static int proc_get_stats_tx(char *page, char **start,
741 off_t offset, int count,
742 int *eof, void *data)
743{
744 struct net_device *dev = data;
745 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
746
747 int len = 0;
748
749 len += snprintf(page + len, count - len,
750 "TX VI priority ok int: %lu\n"
751 "TX VO priority ok int: %lu\n"
752 "TX BE priority ok int: %lu\n"
753 "TX BK priority ok int: %lu\n"
754 "TX MANAGE priority ok int: %lu\n"
755 "TX BEACON priority ok int: %lu\n"
756 "TX BEACON priority error int: %lu\n"
757 "TX CMDPKT priority ok int: %lu\n"
758 "TX queue stopped?: %d\n"
759 "TX fifo overflow: %lu\n"
760 "TX total data packets %lu\n"
761 "TX total data bytes :%lu\n",
762 priv->stats.txviokint,
763 priv->stats.txvookint,
764 priv->stats.txbeokint,
765 priv->stats.txbkokint,
766 priv->stats.txmanageokint,
767 priv->stats.txbeaconokint,
768 priv->stats.txbeaconerr,
769 priv->stats.txcmdpktokint,
770 netif_queue_stopped(dev),
771 priv->stats.txoverflow,
772 priv->rtllib->stats.tx_packets,
773 priv->rtllib->stats.tx_bytes
774
775
776 );
777
778 *eof = 1;
779 return len;
780}
781
782
783
784static int proc_get_stats_rx(char *page, char **start,
785 off_t offset, int count,
786 int *eof, void *data)
787{
788 struct net_device *dev = data;
789 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
790
791 int len = 0;
792
793 len += snprintf(page + len, count - len,
794 "RX packets: %lu\n"
795 "RX data crc err: %lu\n"
796 "RX mgmt crc err: %lu\n"
797 "RX desc err: %lu\n"
798 "RX rx overflow error: %lu\n",
799 priv->stats.rxint,
800 priv->stats.rxdatacrcerr,
801 priv->stats.rxmgmtcrcerr,
802 priv->stats.rxrdu,
803 priv->stats.rxoverflow);
804
805 *eof = 1;
806 return len;
807}
808
809void rtl8192_proc_module_init(void)
810{
811 RT_TRACE(COMP_INIT, "Initializing proc filesystem");
812 rtl8192_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net);
813}
814
815
816void rtl8192_proc_module_remove(void)
817{
818 remove_proc_entry(DRV_NAME, init_net.proc_net);
819}
820
821
822void rtl8192_proc_remove_one(struct net_device *dev)
823{
824 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
825
826 printk(KERN_INFO "dev name %s\n", dev->name);
827
828 if (priv->dir_dev) {
829 remove_proc_entry("stats-tx", priv->dir_dev);
830 remove_proc_entry("stats-rx", priv->dir_dev);
831 remove_proc_entry("stats-ap", priv->dir_dev);
832 remove_proc_entry("registers-0", priv->dir_dev);
833 remove_proc_entry("registers-1", priv->dir_dev);
834 remove_proc_entry("registers-2", priv->dir_dev);
835 remove_proc_entry("registers-3", priv->dir_dev);
836 remove_proc_entry("registers-4", priv->dir_dev);
837 remove_proc_entry("registers-5", priv->dir_dev);
838 remove_proc_entry("registers-6", priv->dir_dev);
839 remove_proc_entry("registers-7", priv->dir_dev);
840 remove_proc_entry("registers-8", priv->dir_dev);
841 remove_proc_entry("registers-9", priv->dir_dev);
842 remove_proc_entry("registers-a", priv->dir_dev);
843 remove_proc_entry("registers-b", priv->dir_dev);
844 remove_proc_entry("registers-c", priv->dir_dev);
845 remove_proc_entry("registers-d", priv->dir_dev);
846 remove_proc_entry("registers-e", priv->dir_dev);
847 remove_proc_entry("RF-A", priv->dir_dev);
848 remove_proc_entry("RF-B", priv->dir_dev);
849 remove_proc_entry("RF-C", priv->dir_dev);
850 remove_proc_entry("RF-D", priv->dir_dev);
851 remove_proc_entry("SEC-CAM-1", priv->dir_dev);
852 remove_proc_entry("SEC-CAM-2", priv->dir_dev);
853 remove_proc_entry("SEC-CAM-3", priv->dir_dev);
854 remove_proc_entry("wlan0", rtl8192_proc);
855 priv->dir_dev = NULL;
856 }
857}
858
859
860void rtl8192_proc_init_one(struct net_device *dev)
861{
862 struct proc_dir_entry *e;
863 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
864
865 priv->dir_dev = create_proc_entry(dev->name,
866 S_IFDIR | S_IRUGO | S_IXUGO,
867 rtl8192_proc);
868 if (!priv->dir_dev) {
869 RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192"
870 "/%s\n", dev->name);
871 return;
872 }
873 e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
874 priv->dir_dev, proc_get_stats_rx, dev);
875
876 if (!e)
877 RT_TRACE(COMP_ERR, "Unable to initialize "
878 "/proc/net/rtl8192/%s/stats-rx\n",
879 dev->name);
880
881 e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
882 priv->dir_dev, proc_get_stats_tx, dev);
883
884 if (!e)
885 RT_TRACE(COMP_ERR, "Unable to initialize "
886 "/proc/net/rtl8192/%s/stats-tx\n",
887 dev->name);
888
889 e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
890 priv->dir_dev, proc_get_stats_ap, dev);
891
892 if (!e)
893 RT_TRACE(COMP_ERR, "Unable to initialize "
894 "/proc/net/rtl8192/%s/stats-ap\n",
895 dev->name);
896
897 e = create_proc_read_entry("registers-0", S_IFREG | S_IRUGO,
898 priv->dir_dev, proc_get_registers_0, dev);
899 if (!e)
900 RT_TRACE(COMP_ERR, "Unable to initialize "
901 "/proc/net/rtl8192/%s/registers-0\n",
902 dev->name);
903 e = create_proc_read_entry("registers-1", S_IFREG | S_IRUGO,
904 priv->dir_dev, proc_get_registers_1, dev);
905 if (!e)
906 RT_TRACE(COMP_ERR, "Unable to initialize "
907 "/proc/net/rtl8192/%s/registers-1\n",
908 dev->name);
909 e = create_proc_read_entry("registers-2", S_IFREG | S_IRUGO,
910 priv->dir_dev, proc_get_registers_2, dev);
911 if (!e)
912 RT_TRACE(COMP_ERR, "Unable to initialize "
913 "/proc/net/rtl8192/%s/registers-2\n",
914 dev->name);
915 e = create_proc_read_entry("registers-3", S_IFREG | S_IRUGO,
916 priv->dir_dev, proc_get_registers_3, dev);
917 if (!e)
918 RT_TRACE(COMP_ERR, "Unable to initialize "
919 "/proc/net/rtl8192/%s/registers-3\n",
920 dev->name);
921 e = create_proc_read_entry("registers-4", S_IFREG | S_IRUGO,
922 priv->dir_dev, proc_get_registers_4, dev);
923 if (!e)
924 RT_TRACE(COMP_ERR, "Unable to initialize "
925 "/proc/net/rtl8192/%s/registers-4\n",
926 dev->name);
927 e = create_proc_read_entry("registers-5", S_IFREG | S_IRUGO,
928 priv->dir_dev, proc_get_registers_5, dev);
929 if (!e)
930 RT_TRACE(COMP_ERR, "Unable to initialize "
931 "/proc/net/rtl8192/%s/registers-5\n",
932 dev->name);
933 e = create_proc_read_entry("registers-6", S_IFREG | S_IRUGO,
934 priv->dir_dev, proc_get_registers_6, dev);
935 if (!e)
936 RT_TRACE(COMP_ERR, "Unable to initialize "
937 "/proc/net/rtl8192/%s/registers-6\n",
938 dev->name);
939 e = create_proc_read_entry("registers-7", S_IFREG | S_IRUGO,
940 priv->dir_dev, proc_get_registers_7, dev);
941 if (!e)
942 RT_TRACE(COMP_ERR, "Unable to initialize "
943 "/proc/net/rtl8192/%s/registers-7\n",
944 dev->name);
945 e = create_proc_read_entry("registers-8", S_IFREG | S_IRUGO,
946 priv->dir_dev, proc_get_registers_8, dev);
947 if (!e)
948 RT_TRACE(COMP_ERR, "Unable to initialize "
949 "/proc/net/rtl8192/%s/registers-8\n",
950 dev->name);
951 e = create_proc_read_entry("registers-9", S_IFREG | S_IRUGO,
952 priv->dir_dev, proc_get_registers_9, dev);
953 if (!e)
954 RT_TRACE(COMP_ERR, "Unable to initialize "
955 "/proc/net/rtl8192/%s/registers-9\n",
956 dev->name);
957 e = create_proc_read_entry("registers-a", S_IFREG | S_IRUGO,
958 priv->dir_dev, proc_get_registers_a, dev);
959 if (!e)
960 RT_TRACE(COMP_ERR, "Unable to initialize "
961 "/proc/net/rtl8192/%s/registers-a\n",
962 dev->name);
963 e = create_proc_read_entry("registers-b", S_IFREG | S_IRUGO,
964 priv->dir_dev, proc_get_registers_b, dev);
965 if (!e)
966 RT_TRACE(COMP_ERR, "Unable to initialize "
967 "/proc/net/rtl8192/%s/registers-b\n",
968 dev->name);
969 e = create_proc_read_entry("registers-c", S_IFREG | S_IRUGO,
970 priv->dir_dev, proc_get_registers_c, dev);
971 if (!e)
972 RT_TRACE(COMP_ERR, "Unable to initialize "
973 "/proc/net/rtl8192/%s/registers-c\n",
974 dev->name);
975 e = create_proc_read_entry("registers-d", S_IFREG | S_IRUGO,
976 priv->dir_dev, proc_get_registers_d, dev);
977 if (!e)
978 RT_TRACE(COMP_ERR, "Unable to initialize "
979 "/proc/net/rtl8192/%s/registers-d\n",
980 dev->name);
981 e = create_proc_read_entry("registers-e", S_IFREG | S_IRUGO,
982 priv->dir_dev, proc_get_registers_e, dev);
983 if (!e)
984 RT_TRACE(COMP_ERR, "Unable to initialize "
985 "/proc/net/rtl8192/%s/registers-e\n",
986 dev->name);
987 e = create_proc_read_entry("RF-A", S_IFREG | S_IRUGO,
988 priv->dir_dev, proc_get_reg_rf_a, dev);
989 if (!e)
990 RT_TRACE(COMP_ERR, "Unable to initialize "
991 "/proc/net/rtl8192/%s/RF-A\n",
992 dev->name);
993 e = create_proc_read_entry("RF-B", S_IFREG | S_IRUGO,
994 priv->dir_dev, proc_get_reg_rf_b, dev);
995 if (!e)
996 RT_TRACE(COMP_ERR, "Unable to initialize "
997 "/proc/net/rtl8192/%s/RF-B\n",
998 dev->name);
999 e = create_proc_read_entry("RF-C", S_IFREG | S_IRUGO,
1000 priv->dir_dev, proc_get_reg_rf_c, dev);
1001 if (!e)
1002 RT_TRACE(COMP_ERR, "Unable to initialize "
1003 "/proc/net/rtl8192/%s/RF-C\n",
1004 dev->name);
1005 e = create_proc_read_entry("RF-D", S_IFREG | S_IRUGO,
1006 priv->dir_dev, proc_get_reg_rf_d, dev);
1007 if (!e)
1008 RT_TRACE(COMP_ERR, "Unable to initialize "
1009 "/proc/net/rtl8192/%s/RF-D\n",
1010 dev->name);
1011 e = create_proc_read_entry("SEC-CAM-1", S_IFREG | S_IRUGO,
1012 priv->dir_dev, proc_get_cam_register_1, dev);
1013 if (!e)
1014 RT_TRACE(COMP_ERR, "Unable to initialize "
1015 "/proc/net/rtl8192/%s/SEC-CAM-1\n",
1016 dev->name);
1017 e = create_proc_read_entry("SEC-CAM-2", S_IFREG | S_IRUGO,
1018 priv->dir_dev, proc_get_cam_register_2, dev);
1019 if (!e)
1020 RT_TRACE(COMP_ERR, "Unable to initialize "
1021 "/proc/net/rtl8192/%s/SEC-CAM-2\n",
1022 dev->name);
1023 e = create_proc_read_entry("SEC-CAM-3", S_IFREG | S_IRUGO,
1024 priv->dir_dev, proc_get_cam_register_3, dev);
1025 if (!e)
1026 RT_TRACE(COMP_ERR, "Unable to initialize "
1027 "/proc/net/rtl8192/%s/SEC-CAM-3\n",
1028 dev->name);
1029}
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index 4217b88e6fc3..e51cb49ce10e 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -412,19 +412,18 @@ static int rtllib_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
412} 412}
413 413
414 414
415static char *rtllib_ccmp_print_stats(char *p, void *priv) 415static void rtllib_ccmp_print_stats(struct seq_file *m, void *priv)
416{ 416{
417 struct rtllib_ccmp_data *ccmp = priv; 417 struct rtllib_ccmp_data *ccmp = priv;
418 p += sprintf(p, "key[%d] alg=CCMP key_set=%d " 418 seq_printf(m,
419 "tx_pn=%pM rx_pn=%pM " 419 "key[%d] alg=CCMP key_set=%d "
420 "format_errors=%d replays=%d decrypt_errors=%d\n", 420 "tx_pn=%pM rx_pn=%pM "
421 ccmp->key_idx, ccmp->key_set, 421 "format_errors=%d replays=%d decrypt_errors=%d\n",
422 ccmp->tx_pn, ccmp->rx_pn, 422 ccmp->key_idx, ccmp->key_set,
423 ccmp->dot11RSNAStatsCCMPFormatErrors, 423 ccmp->tx_pn, ccmp->rx_pn,
424 ccmp->dot11RSNAStatsCCMPReplays, 424 ccmp->dot11RSNAStatsCCMPFormatErrors,
425 ccmp->dot11RSNAStatsCCMPDecryptErrors); 425 ccmp->dot11RSNAStatsCCMPReplays,
426 426 ccmp->dot11RSNAStatsCCMPDecryptErrors);
427 return p;
428} 427}
429 428
430static struct lib80211_crypto_ops rtllib_crypt_ccmp = { 429static struct lib80211_crypto_ops rtllib_crypt_ccmp = {
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index 800925053fb0..5cfd73baf1cc 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -708,30 +708,30 @@ static int rtllib_tkip_get_key(void *key, int len, u8 *seq, void *priv)
708} 708}
709 709
710 710
711static char *rtllib_tkip_print_stats(char *p, void *priv) 711static void rtllib_tkip_print_stats(struct seq_file *m, void *priv)
712{ 712{
713 struct rtllib_tkip_data *tkip = priv; 713 struct rtllib_tkip_data *tkip = priv;
714 p += sprintf(p, "key[%d] alg=TKIP key_set=%d " 714 seq_printf(m,
715 "tx_pn=%02x%02x%02x%02x%02x%02x " 715 "key[%d] alg=TKIP key_set=%d "
716 "rx_pn=%02x%02x%02x%02x%02x%02x " 716 "tx_pn=%02x%02x%02x%02x%02x%02x "
717 "replays=%d icv_errors=%d local_mic_failures=%d\n", 717 "rx_pn=%02x%02x%02x%02x%02x%02x "
718 tkip->key_idx, tkip->key_set, 718 "replays=%d icv_errors=%d local_mic_failures=%d\n",
719 (tkip->tx_iv32 >> 24) & 0xff, 719 tkip->key_idx, tkip->key_set,
720 (tkip->tx_iv32 >> 16) & 0xff, 720 (tkip->tx_iv32 >> 24) & 0xff,
721 (tkip->tx_iv32 >> 8) & 0xff, 721 (tkip->tx_iv32 >> 16) & 0xff,
722 tkip->tx_iv32 & 0xff, 722 (tkip->tx_iv32 >> 8) & 0xff,
723 (tkip->tx_iv16 >> 8) & 0xff, 723 tkip->tx_iv32 & 0xff,
724 tkip->tx_iv16 & 0xff, 724 (tkip->tx_iv16 >> 8) & 0xff,
725 (tkip->rx_iv32 >> 24) & 0xff, 725 tkip->tx_iv16 & 0xff,
726 (tkip->rx_iv32 >> 16) & 0xff, 726 (tkip->rx_iv32 >> 24) & 0xff,
727 (tkip->rx_iv32 >> 8) & 0xff, 727 (tkip->rx_iv32 >> 16) & 0xff,
728 tkip->rx_iv32 & 0xff, 728 (tkip->rx_iv32 >> 8) & 0xff,
729 (tkip->rx_iv16 >> 8) & 0xff, 729 tkip->rx_iv32 & 0xff,
730 tkip->rx_iv16 & 0xff, 730 (tkip->rx_iv16 >> 8) & 0xff,
731 tkip->dot11RSNAStatsTKIPReplays, 731 tkip->rx_iv16 & 0xff,
732 tkip->dot11RSNAStatsTKIPICVErrors, 732 tkip->dot11RSNAStatsTKIPReplays,
733 tkip->dot11RSNAStatsTKIPLocalMICFailures); 733 tkip->dot11RSNAStatsTKIPICVErrors,
734 return p; 734 tkip->dot11RSNAStatsTKIPLocalMICFailures);
735} 735}
736 736
737static struct lib80211_crypto_ops rtllib_crypt_tkip = { 737static struct lib80211_crypto_ops rtllib_crypt_tkip = {
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_wep.c b/drivers/staging/rtl8192e/rtllib_crypt_wep.c
index 8cdf38913a33..c4df6e01ef74 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_wep.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c
@@ -247,12 +247,10 @@ static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
247} 247}
248 248
249 249
250static char *prism2_wep_print_stats(char *p, void *priv) 250static void prism2_wep_print_stats(struct seq_file *m, void *priv)
251{ 251{
252 struct prism2_wep_data *wep = priv; 252 struct prism2_wep_data *wep = priv;
253 p += sprintf(p, "key[%d] alg=WEP len=%d\n", 253 seq_printf(m, "key[%d] alg=WEP len=%d\n", wep->key_idx, wep->key_len);
254 wep->key_idx, wep->key_len);
255 return p;
256} 254}
257 255
258static struct lib80211_crypto_ops rtllib_crypt_wep = { 256static struct lib80211_crypto_ops rtllib_crypt_wep = {
diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c
index f9dae958a5d4..84ea721d5d8e 100644
--- a/drivers/staging/rtl8192e/rtllib_module.c
+++ b/drivers/staging/rtl8192e/rtllib_module.c
@@ -208,61 +208,51 @@ static int debug = \
208 ; 208 ;
209static struct proc_dir_entry *rtllib_proc; 209static struct proc_dir_entry *rtllib_proc;
210 210
211static int show_debug_level(char *page, char **start, off_t offset, 211static int show_debug_level(struct seq_file *m, void *v)
212 int count, int *eof, void *data)
213{ 212{
214 return snprintf(page, count, "0x%08X\n", rtllib_debug_level); 213 return seq_printf(m, "0x%08X\n", rtllib_debug_level);
215} 214}
216 215
217static int store_debug_level(struct file *file, const char __user *buffer, 216static ssize_t write_debug_level(struct file *file, const char __user *buffer,
218 unsigned long count, void *data) 217 size_t count, loff_t *ppos)
219{ 218{
220 char buf[] = "0x00000000";
221 unsigned long len = min((unsigned long)sizeof(buf) - 1, count);
222 char *p = (char *)buf;
223 unsigned long val; 219 unsigned long val;
220 int err = kstrtoul_from_user(buffer, count, 0, &val);
221 if (err)
222 return err;
223 rtllib_debug_level = val;
224 return count;
225}
224 226
225 if (copy_from_user(buf, buffer, len)) 227static int open_debug_level(struct inode *inode, struct file *file)
226 return count; 228{
227 buf[len] = 0; 229 return single_open(file, show_debug_level, NULL);
228 if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
229 p++;
230 if (p[0] == 'x' || p[0] == 'X')
231 p++;
232 val = simple_strtoul(p, &p, 16);
233 } else
234 val = simple_strtoul(p, &p, 10);
235 if (p == buf)
236 printk(KERN_INFO DRV_NAME
237 ": %s is not in hex or decimal form.\n", buf);
238 else
239 rtllib_debug_level = val;
240
241 return strnlen(buf, count);
242} 230}
243 231
232static const struct file_operations fops = {
233 .open = open_debug_level,
234 .read = seq_read,
235 .llseek = seq_lseek,
236 .write = write_debug_level
237};
238
244int __init rtllib_init(void) 239int __init rtllib_init(void)
245{ 240{
246 struct proc_dir_entry *e; 241 struct proc_dir_entry *e;
247 242
248 rtllib_debug_level = debug; 243 rtllib_debug_level = debug;
249 rtllib_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); 244 rtllib_proc = proc_mkdir(DRV_NAME, init_net.proc_net);
250 if (rtllib_proc == NULL) { 245 if (rtllib_proc == NULL) {
251 RTLLIB_ERROR("Unable to create " DRV_NAME 246 RTLLIB_ERROR("Unable to create " DRV_NAME
252 " proc directory\n"); 247 " proc directory\n");
253 return -EIO; 248 return -EIO;
254 } 249 }
255 e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR, 250 e = proc_create("debug_level", S_IRUGO | S_IWUSR, rtllib_proc, &fops);
256 rtllib_proc);
257 if (!e) { 251 if (!e) {
258 remove_proc_entry(DRV_NAME, init_net.proc_net); 252 remove_proc_entry(DRV_NAME, init_net.proc_net);
259 rtllib_proc = NULL; 253 rtllib_proc = NULL;
260 return -EIO; 254 return -EIO;
261 } 255 }
262 e->read_proc = show_debug_level;
263 e->write_proc = store_debug_level;
264 e->data = NULL;
265
266 return 0; 256 return 0;
267} 257}
268 258
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
index 76c56e5aed79..e0870c05a5e0 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
@@ -243,39 +243,34 @@ static int debug = \
243 ; 243 ;
244struct proc_dir_entry *ieee80211_proc; 244struct proc_dir_entry *ieee80211_proc;
245 245
246static int show_debug_level(char *page, char **start, off_t offset, 246static int show_debug_level(struct seq_file *m, void *v)
247 int count, int *eof, void *data)
248{ 247{
249 return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); 248 return seq_printf(m, "0x%08X\n", ieee80211_debug_level);
250} 249}
251 250
252static int store_debug_level(struct file *file, const char *buffer, 251static ssize_t write_debug_level(struct file *file, const char __user *buffer,
253 unsigned long count, void *data) 252 size_t count, loff_t *ppos)
254{ 253{
255 char buf[] = "0x00000000";
256 unsigned long len = min_t(unsigned long, sizeof(buf) - 1, count);
257 char *p = (char *)buf;
258 unsigned long val; 254 unsigned long val;
255 int err = kstrtoul_from_user(buffer, count, 0, &val);
256 if (err)
257 return err;
258 ieee80211_debug_level = val;
259 return count;
260}
259 261
260 if (copy_from_user(buf, buffer, len)) 262static int open_debug_level(struct inode *inode, struct file *file)
261 return count; 263{
262 buf[len] = 0; 264 return single_open(file, show_debug_level, NULL);
263 if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
264 p++;
265 if (p[0] == 'x' || p[0] == 'X')
266 p++;
267 val = simple_strtoul(p, &p, 16);
268 } else
269 val = simple_strtoul(p, &p, 10);
270 if (p == buf)
271 printk(KERN_INFO DRV_NAME
272 ": %s is not in hex or decimal form.\n", buf);
273 else
274 ieee80211_debug_level = val;
275
276 return strnlen(buf, count);
277} 265}
278 266
267static const struct file_operations fops = {
268 .open = open_debug_level,
269 .read = seq_read,
270 .llseek = seq_lseek,
271 .write = write_debug_level
272};
273
279int __init ieee80211_debug_init(void) 274int __init ieee80211_debug_init(void)
280{ 275{
281 struct proc_dir_entry *e; 276 struct proc_dir_entry *e;
@@ -288,17 +283,13 @@ int __init ieee80211_debug_init(void)
288 " proc directory\n"); 283 " proc directory\n");
289 return -EIO; 284 return -EIO;
290 } 285 }
291 e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR, 286 e = proc_create("debug_level", S_IRUGO | S_IWUSR,
292 ieee80211_proc); 287 ieee80211_proc, &fops);
293 if (!e) { 288 if (!e) {
294 remove_proc_entry(DRV_NAME, init_net.proc_net); 289 remove_proc_entry(DRV_NAME, init_net.proc_net);
295 ieee80211_proc = NULL; 290 ieee80211_proc = NULL;
296 return -EIO; 291 return -EIO;
297 } 292 }
298 e->read_proc = show_debug_level;
299 e->write_proc = store_debug_level;
300 e->data = NULL;
301
302 return 0; 293 return 0;
303} 294}
304 295
diff --git a/drivers/staging/rtl8192u/ieee80211/proc.c b/drivers/staging/rtl8192u/ieee80211/proc.c
index 6eda928e4090..c426dfdd9fdd 100644
--- a/drivers/staging/rtl8192u/ieee80211/proc.c
+++ b/drivers/staging/rtl8192u/ieee80211/proc.c
@@ -99,7 +99,7 @@ static int crypto_info_open(struct inode *inode, struct file *file)
99 return seq_open(file, &crypto_seq_ops); 99 return seq_open(file, &crypto_seq_ops);
100} 100}
101 101
102static struct file_operations proc_crypto_ops = { 102static const struct file_operations proc_crypto_ops = {
103 .open = crypto_info_open, 103 .open = crypto_info_open,
104 .read = seq_read, 104 .read = seq_read,
105 .llseek = seq_lseek, 105 .llseek = seq_lseek,
@@ -108,9 +108,5 @@ static struct file_operations proc_crypto_ops = {
108 108
109void __init crypto_init_proc(void) 109void __init crypto_init_proc(void)
110{ 110{
111 struct proc_dir_entry *proc; 111 proc_create("crypto", 0, NULL, &proc_crypto_ops);
112
113 proc = create_proc_entry("crypto", 0, NULL);
114 if (proc)
115 proc->proc_fops = &proc_crypto_ops;
116} 112}
diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h
index e538e026b512..bedeb330ad4f 100644
--- a/drivers/staging/rtl8192u/r8192U.h
+++ b/drivers/staging/rtl8192u/r8192U.h
@@ -946,7 +946,6 @@ typedef struct r8192_priv {
946 /*stats*/ 946 /*stats*/
947 struct Stats stats; 947 struct Stats stats;
948 struct iw_statistics wstats; 948 struct iw_statistics wstats;
949 struct proc_dir_entry *dir_dev;
950 949
951 /*RX stuff*/ 950 /*RX stuff*/
952// u32 *rxring; 951// u32 *rxring;
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index f7de2f6d49a5..145923397556 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -71,6 +71,8 @@ double __extendsfdf2(float a) {return a;}
71//#include "r8192xU_phyreg.h" 71//#include "r8192xU_phyreg.h"
72#include <linux/usb.h> 72#include <linux/usb.h>
73#include <linux/slab.h> 73#include <linux/slab.h>
74#include <linux/proc_fs.h>
75#include <linux/seq_file.h>
74// FIXME: check if 2.6.7 is ok 76// FIXME: check if 2.6.7 is ok
75 77
76#ifdef CONFIG_RTL8192_PM 78#ifdef CONFIG_RTL8192_PM
@@ -472,103 +474,73 @@ void watch_dog_timer_callback(unsigned long data);
472 474
473static struct proc_dir_entry *rtl8192_proc; 475static struct proc_dir_entry *rtl8192_proc;
474 476
475static int proc_get_stats_ap(char *page, char **start, off_t offset, int count, 477static int proc_get_stats_ap(struct seq_file *m, void *v)
476 int *eof, void *data)
477{ 478{
478 struct net_device *dev = data; 479 struct net_device *dev = m->private;
479 struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); 480 struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
480 struct ieee80211_device *ieee = priv->ieee80211; 481 struct ieee80211_device *ieee = priv->ieee80211;
481 struct ieee80211_network *target; 482 struct ieee80211_network *target;
482 483
483 int len = 0;
484
485 list_for_each_entry(target, &ieee->network_list, list) { 484 list_for_each_entry(target, &ieee->network_list, list) {
486 485 const char *wpa = "non_WPA";
487 len += snprintf(page + len, count - len, "%s ", target->ssid);
488
489 if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) 486 if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0)
490 len += snprintf(page + len, count - len, "WPA\n"); 487 wpa = "WPA";
491 else 488
492 len += snprintf(page + len, count - len, "non_WPA\n"); 489 seq_printf(m, "%s %s\n", target->ssid, wpa);
493 } 490 }
494 491
495 *eof = 1; 492 return 0;
496 return len;
497} 493}
498 494
499static int proc_get_registers(char *page, char **start, 495static int proc_get_registers(struct seq_file *m, void *v)
500 off_t offset, int count,
501 int *eof, void *data)
502{ 496{
503 struct net_device *dev = data; 497 struct net_device *dev = m->private;
504// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); 498 int i,n, max = 0xff;
505 499
506 int len = 0; 500 seq_puts(m, "\n####################page 0##################\n ");
507 int i,n;
508
509 int max=0xff;
510
511 /* This dump the current register page */
512 len += snprintf(page + len, count - len,
513 "\n####################page 0##################\n ");
514 501
515 for (n=0;n<=max;) { 502 for (n=0;n<=max;) {
516 //printk( "\nD: %2x> ", n); 503 //printk( "\nD: %2x> ", n);
517 len += snprintf(page + len, count - len, 504 seq_printf(m, "\nD: %2x > ",n);
518 "\nD: %2x > ",n);
519 505
520 for (i=0;i<16 && n<=max;i++,n++) 506 for (i=0;i<16 && n<=max;i++,n++)
521 len += snprintf(page + len, count - len, 507 seq_printf(m, "%2x ",read_nic_byte(dev,0x000|n));
522 "%2x ",read_nic_byte(dev,0x000|n));
523 508
524 // printk("%2x ",read_nic_byte(dev,n)); 509 // printk("%2x ",read_nic_byte(dev,n));
525 } 510 }
526 len += snprintf(page + len, count - len, 511
527 "\n####################page 1##################\n "); 512 seq_puts(m, "\n####################page 1##################\n ");
528 for (n=0;n<=max;) { 513 for (n=0;n<=max;) {
529 //printk( "\nD: %2x> ", n); 514 //printk( "\nD: %2x> ", n);
530 len += snprintf(page + len, count - len, 515 seq_printf(m, "\nD: %2x > ",n);
531 "\nD: %2x > ",n);
532 516
533 for (i=0;i<16 && n<=max;i++,n++) 517 for (i=0;i<16 && n<=max;i++,n++)
534 len += snprintf(page + len, count - len, 518 seq_printf(m, "%2x ",read_nic_byte(dev,0x100|n));
535 "%2x ",read_nic_byte(dev,0x100|n));
536 519
537 // printk("%2x ",read_nic_byte(dev,n)); 520 // printk("%2x ",read_nic_byte(dev,n));
538 } 521 }
539 len += snprintf(page + len, count - len, 522
540 "\n####################page 3##################\n "); 523 seq_puts(m, "\n####################page 3##################\n ");
541 for (n=0;n<=max;) { 524 for (n=0;n<=max;) {
542 //printk( "\nD: %2x> ", n); 525 //printk( "\nD: %2x> ", n);
543 len += snprintf(page + len, count - len, 526 seq_printf(m, "\nD: %2x > ",n);
544 "\nD: %2x > ",n);
545 527
546 for(i=0;i<16 && n<=max;i++,n++) 528 for(i=0;i<16 && n<=max;i++,n++)
547 len += snprintf(page + len, count - len, 529 seq_printf(m, "%2x ",read_nic_byte(dev,0x300|n));
548 "%2x ",read_nic_byte(dev,0x300|n));
549 530
550 // printk("%2x ",read_nic_byte(dev,n)); 531 // printk("%2x ",read_nic_byte(dev,n));
551 } 532 }
552 533
553 len += snprintf(page + len, count - len,"\n"); 534 seq_putc(m, '\n');
554 *eof = 1; 535 return 0;
555 return len;
556} 536}
557 537
558 538static int proc_get_stats_tx(struct seq_file *m, void *v)
559
560
561
562static int proc_get_stats_tx(char *page, char **start,
563 off_t offset, int count,
564 int *eof, void *data)
565{ 539{
566 struct net_device *dev = data; 540 struct net_device *dev = m->private;
567 struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); 541 struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
568 542
569 int len = 0; 543 seq_printf(m,
570
571 len += snprintf(page + len, count - len,
572 "TX VI priority ok int: %lu\n" 544 "TX VI priority ok int: %lu\n"
573 "TX VI priority error int: %lu\n" 545 "TX VI priority error int: %lu\n"
574 "TX VO priority ok int: %lu\n" 546 "TX VO priority ok int: %lu\n"
@@ -629,22 +601,15 @@ static int proc_get_stats_tx(char *page, char **start,
629// priv->stats.txbeaconerr 601// priv->stats.txbeaconerr
630 ); 602 );
631 603
632 *eof = 1; 604 return 0;
633 return len;
634} 605}
635 606
636 607static int proc_get_stats_rx(struct seq_file *m, void *v)
637
638static int proc_get_stats_rx(char *page, char **start,
639 off_t offset, int count,
640 int *eof, void *data)
641{ 608{
642 struct net_device *dev = data; 609 struct net_device *dev = m->private;
643 struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); 610 struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
644 611
645 int len = 0; 612 seq_printf(m,
646
647 len += snprintf(page + len, count - len,
648 "RX packets: %lu\n" 613 "RX packets: %lu\n"
649 "RX urb status error: %lu\n" 614 "RX urb status error: %lu\n"
650 "RX invalid urb error: %lu\n", 615 "RX invalid urb error: %lu\n",
@@ -652,9 +617,9 @@ static int proc_get_stats_rx(char *page, char **start,
652 priv->stats.rxstaterr, 617 priv->stats.rxstaterr,
653 priv->stats.rxurberr); 618 priv->stats.rxurberr);
654 619
655 *eof = 1; 620 return 0;
656 return len;
657} 621}
622
658void rtl8192_proc_module_init(void) 623void rtl8192_proc_module_init(void)
659{ 624{
660 RT_TRACE(COMP_INIT, "Initializing proc filesystem"); 625 RT_TRACE(COMP_INIT, "Initializing proc filesystem");
@@ -667,74 +632,70 @@ void rtl8192_proc_module_remove(void)
667 remove_proc_entry(RTL819xU_MODULE_NAME, init_net.proc_net); 632 remove_proc_entry(RTL819xU_MODULE_NAME, init_net.proc_net);
668} 633}
669 634
670 635/*
671void rtl8192_proc_remove_one(struct net_device *dev) 636 * seq_file wrappers for procfile show routines.
637 */
638static int rtl8192_proc_open(struct inode *inode, struct file *file)
672{ 639{
673 struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); 640 struct net_device *dev = proc_get_parent_data(inode);
641 int (*show)(struct seq_file *, void *) = PDE_DATA(inode);
674 642
675 643 return single_open(file, show, dev);
676 if (priv->dir_dev) {
677 // remove_proc_entry("stats-hw", priv->dir_dev);
678 remove_proc_entry("stats-tx", priv->dir_dev);
679 remove_proc_entry("stats-rx", priv->dir_dev);
680 // remove_proc_entry("stats-ieee", priv->dir_dev);
681 remove_proc_entry("stats-ap", priv->dir_dev);
682 remove_proc_entry("registers", priv->dir_dev);
683 // remove_proc_entry("cck-registers",priv->dir_dev);
684 // remove_proc_entry("ofdm-registers",priv->dir_dev);
685 //remove_proc_entry(dev->name, rtl8192_proc);
686 remove_proc_entry("wlan0", rtl8192_proc);
687 priv->dir_dev = NULL;
688 }
689} 644}
690 645
646static const struct file_operations rtl8192_proc_fops = {
647 .open = rtl8192_proc_open,
648 .read = seq_read,
649 .llseek = seq_lseek,
650 .release = seq_release,
651};
691 652
692void rtl8192_proc_init_one(struct net_device *dev) 653/*
693{ 654 * Table of proc files we need to create.
694 struct proc_dir_entry *e; 655 */
695 struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); 656struct rtl8192_proc_file {
696 priv->dir_dev = proc_mkdir(dev->name, rtl8192_proc); 657 char name[12];
697 if (!priv->dir_dev) { 658 int (*show)(struct seq_file *, void *);
698 RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", 659};
699 dev->name);
700 return;
701 }
702 e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
703 priv->dir_dev, proc_get_stats_rx, dev);
704
705 if (!e) {
706 RT_TRACE(COMP_ERR,"Unable to initialize "
707 "/proc/net/rtl8192/%s/stats-rx\n",
708 dev->name);
709 }
710
711 660
712 e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, 661static const struct rtl8192_proc_file rtl8192_proc_files[] = {
713 priv->dir_dev, proc_get_stats_tx, dev); 662 { "stats-rx", &proc_get_stats_rx },
663 { "stats-tx", &proc_get_stats_tx },
664 { "stats-ap", &proc_get_stats_ap },
665 { "registers", &proc_get_registers },
666 { "" }
667};
714 668
715 if (!e) { 669void rtl8192_proc_init_one(struct net_device *dev)
716 RT_TRACE(COMP_ERR, "Unable to initialize " 670{
717 "/proc/net/rtl8192/%s/stats-tx\n", 671 const struct rtl8192_proc_file *f;
718 dev->name); 672 struct proc_dir_entry *dir;
719 }
720 673
721 e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, 674 if (rtl8192_proc) {
722 priv->dir_dev, proc_get_stats_ap, dev); 675 dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev);
676 if (!dir) {
677 RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n",
678 dev->name);
679 return;
680 }
723 681
724 if (!e) { 682 for (f = rtl8192_proc_files; f->name[0]; f++) {
725 RT_TRACE(COMP_ERR, "Unable to initialize " 683 if (!proc_create_data(f->name, S_IFREG | S_IRUGO, dir,
726 "/proc/net/rtl8192/%s/stats-ap\n", 684 &rtl8192_proc_fops, f->show)) {
727 dev->name); 685 RT_TRACE(COMP_ERR, "Unable to initialize "
686 "/proc/net/rtl8192/%s/%s\n",
687 dev->name, f->name);
688 return;
689 }
690 }
728 } 691 }
692}
729 693
730 e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, 694void rtl8192_proc_remove_one(struct net_device *dev)
731 priv->dir_dev, proc_get_registers, dev); 695{
732 if (!e) { 696 remove_proc_subtree(dev->name, rtl8192_proc);
733 RT_TRACE(COMP_ERR, "Unable to initialize "
734 "/proc/net/rtl8192/%s/registers\n",
735 dev->name);
736 }
737} 697}
698
738/**************************************************************************** 699/****************************************************************************
739 -----------------------------MISC STUFF------------------------- 700 -----------------------------MISC STUFF-------------------------
740*****************************************************************************/ 701*****************************************************************************/
diff --git a/drivers/staging/rts5139/rts51x_scsi.c b/drivers/staging/rts5139/rts51x_scsi.c
index b58f1dfe006d..610870546406 100644
--- a/drivers/staging/rts5139/rts51x_scsi.c
+++ b/drivers/staging/rts5139/rts51x_scsi.c
@@ -1968,18 +1968,16 @@ int slave_configure(struct scsi_device *sdev)
1968 1968
1969/* we use this macro to help us write into the buffer */ 1969/* we use this macro to help us write into the buffer */
1970#undef SPRINTF 1970#undef SPRINTF
1971#define SPRINTF(args...) \ 1971#define SPRINTF(args...) seq_printf(m, ##args)
1972 do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0)
1973 1972
1974int proc_info(struct Scsi_Host *host, char *buffer, 1973static int write_info(struct Scsi_Host *host, char *buffer, int length)
1975 char **start, off_t offset, int length, int inout)
1976{ 1974{
1977 char *pos = buffer;
1978
1979 /* if someone is sending us data, just throw it away */ 1975 /* if someone is sending us data, just throw it away */
1980 if (inout) 1976 return length;
1981 return length; 1977}
1982 1978
1979static int show_info(struct seq_file *m, struct Scsi_Host *host)
1980{
1983 /* print the controller name */ 1981 /* print the controller name */
1984 SPRINTF(" Host scsi%d: %s\n", host->host_no, RTS51X_NAME); 1982 SPRINTF(" Host scsi%d: %s\n", host->host_no, RTS51X_NAME);
1985 1983
@@ -1988,18 +1986,7 @@ int proc_info(struct Scsi_Host *host, char *buffer,
1988 SPRINTF(" Product: RTS51xx USB Card Reader\n"); 1986 SPRINTF(" Product: RTS51xx USB Card Reader\n");
1989 SPRINTF(" Version: %s\n", DRIVER_VERSION); 1987 SPRINTF(" Version: %s\n", DRIVER_VERSION);
1990 SPRINTF(" Build: %s\n", __TIME__); 1988 SPRINTF(" Build: %s\n", __TIME__);
1991 1989 return 0;
1992 /*
1993 * Calculate start of next buffer, and return value.
1994 */
1995 *start = buffer + offset;
1996
1997 if ((pos - buffer) < offset)
1998 return 0;
1999 else if ((pos - buffer - offset) < length)
2000 return pos - buffer - offset;
2001 else
2002 return length;
2003} 1990}
2004 1991
2005/* queue a command */ 1992/* queue a command */
@@ -2100,7 +2087,8 @@ struct scsi_host_template rts51x_host_template = {
2100 /* basic userland interface stuff */ 2087 /* basic userland interface stuff */
2101 .name = RTS51X_NAME, 2088 .name = RTS51X_NAME,
2102 .proc_name = RTS51X_NAME, 2089 .proc_name = RTS51X_NAME,
2103 .proc_info = proc_info, 2090 .show_info = show_info,
2091 .write_info = write_info,
2104 .info = rts5139_info, 2092 .info = rts5139_info,
2105 2093
2106 /* command interface -- queued only */ 2094 /* command interface -- queued only */
diff --git a/drivers/staging/rts5139/rts51x_scsi.h b/drivers/staging/rts5139/rts51x_scsi.h
index 3a5213611d21..1a0d70566186 100644
--- a/drivers/staging/rts5139/rts51x_scsi.h
+++ b/drivers/staging/rts5139/rts51x_scsi.h
@@ -147,8 +147,6 @@ struct scsi_cmnd;
147 147
148int slave_alloc(struct scsi_device *sdev); 148int slave_alloc(struct scsi_device *sdev);
149int slave_configure(struct scsi_device *sdev); 149int slave_configure(struct scsi_device *sdev);
150int proc_info(struct Scsi_Host *host, char *buffer,
151 char **start, off_t offset, int length, int inout);
152int queuecommand(struct Scsi_Host *, struct scsi_cmnd *); 150int queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
153int command_abort(struct scsi_cmnd *srb); 151int command_abort(struct scsi_cmnd *srb);
154int bus_reset(struct scsi_cmnd *srb); 152int bus_reset(struct scsi_cmnd *srb);
diff --git a/drivers/staging/silicom/Makefile b/drivers/staging/silicom/Makefile
index 80e6d12d156b..ca8359481c48 100644
--- a/drivers/staging/silicom/Makefile
+++ b/drivers/staging/silicom/Makefile
@@ -4,6 +4,3 @@
4 4
5obj-$(CONFIG_BPCTL) += bpctl_mod.o 5obj-$(CONFIG_BPCTL) += bpctl_mod.o
6obj-$(CONFIG_SBYPASS) += bypasslib/ 6obj-$(CONFIG_SBYPASS) += bypasslib/
7
8
9bpctl_mod-objs := bp_mod.o bp_proc.o
diff --git a/drivers/staging/silicom/bp_proc.c b/drivers/staging/silicom/bp_proc.c
deleted file mode 100644
index a01ca97b7665..000000000000
--- a/drivers/staging/silicom/bp_proc.c
+++ /dev/null
@@ -1,1327 +0,0 @@
1/******************************************************************************/
2/* */
3/* Copyright (c) 2004-2006 Silicom, Ltd */
4/* All rights reserved. */
5/* */
6/* This program is free software; you can redistribute it and/or modify */
7/* it under the terms of the GNU General Public License as published by */
8/* the Free Software Foundation, located in the file LICENSE. */
9/* */
10/* */
11/******************************************************************************/
12
13#if defined(CONFIG_SMP) && !defined(__SMP__)
14#define __SMP__
15#endif
16
17#include <linux/proc_fs.h>
18#include <linux/netdevice.h>
19#include <asm/uaccess.h>
20/* #include <linux/smp_lock.h> */
21#include "bp_mod.h"
22
23#define BP_PROC_DIR "bypass"
24/* #define BYPASS_SUPPORT "bypass" */
25
26#ifdef BYPASS_SUPPORT
27
28#define GPIO6_SET_ENTRY_SD "gpio6_set"
29#define GPIO6_CLEAR_ENTRY_SD "gpio6_clear"
30
31#define GPIO7_SET_ENTRY_SD "gpio7_set"
32#define GPIO7_CLEAR_ENTRY_SD "gpio7_clear"
33
34#define PULSE_SET_ENTRY_SD "pulse_set"
35#define ZERO_SET_ENTRY_SD "zero_set"
36#define PULSE_GET1_ENTRY_SD "pulse_get1"
37#define PULSE_GET2_ENTRY_SD "pulse_get2"
38
39#define CMND_ON_ENTRY_SD "cmnd_on"
40#define CMND_OFF_ENTRY_SD "cmnd_off"
41#define RESET_CONT_ENTRY_SD "reset_cont"
42
43 /*COMMANDS*/
44#define BYPASS_INFO_ENTRY_SD "bypass_info"
45#define BYPASS_SLAVE_ENTRY_SD "bypass_slave"
46#define BYPASS_CAPS_ENTRY_SD "bypass_caps"
47#define WD_SET_CAPS_ENTRY_SD "wd_set_caps"
48#define BYPASS_ENTRY_SD "bypass"
49#define BYPASS_CHANGE_ENTRY_SD "bypass_change"
50#define BYPASS_WD_ENTRY_SD "bypass_wd"
51#define WD_EXPIRE_TIME_ENTRY_SD "wd_expire_time"
52#define RESET_BYPASS_WD_ENTRY_SD "reset_bypass_wd"
53#define DIS_BYPASS_ENTRY_SD "dis_bypass"
54#define BYPASS_PWUP_ENTRY_SD "bypass_pwup"
55#define BYPASS_PWOFF_ENTRY_SD "bypass_pwoff"
56#define STD_NIC_ENTRY_SD "std_nic"
57#define STD_NIC_ENTRY_SD "std_nic"
58#define TAP_ENTRY_SD "tap"
59#define TAP_CHANGE_ENTRY_SD "tap_change"
60#define DIS_TAP_ENTRY_SD "dis_tap"
61#define TAP_PWUP_ENTRY_SD "tap_pwup"
62#define TWO_PORT_LINK_ENTRY_SD "two_port_link"
63#define WD_EXP_MODE_ENTRY_SD "wd_exp_mode"
64#define WD_AUTORESET_ENTRY_SD "wd_autoreset"
65#define TPL_ENTRY_SD "tpl"
66#define WAIT_AT_PWUP_ENTRY_SD "wait_at_pwup"
67#define HW_RESET_ENTRY_SD "hw_reset"
68#define DISC_ENTRY_SD "disc"
69#define DISC_CHANGE_ENTRY_SD "disc_change"
70#define DIS_DISC_ENTRY_SD "dis_disc"
71#define DISC_PWUP_ENTRY_SD "disc_pwup"
72
73static struct proc_dir_entry *bp_procfs_dir;
74
75static struct proc_dir_entry *proc_getdir(char *name,
76 struct proc_dir_entry *proc_dir)
77{
78 struct proc_dir_entry *pde = proc_dir;
79 for (pde = pde->subdir; pde; pde = pde->next) {
80 if (pde->namelen && (strcmp(name, pde->name) == 0)) {
81 /* directory exists */
82 break;
83 }
84 }
85 if (pde == (struct proc_dir_entry *)0) {
86 /* create the directory */
87 pde = create_proc_entry(name, S_IFDIR, proc_dir);
88 if (pde == (struct proc_dir_entry *)0)
89 return pde;
90 }
91 return pde;
92}
93
94int
95bypass_proc_create_entry_sd(struct pfs_unit *pfs_unit_curr,
96 char *proc_name,
97 write_proc_t *write_proc,
98 read_proc_t *read_proc,
99 struct proc_dir_entry *parent_pfs, void *data)
100{
101 strcpy(pfs_unit_curr->proc_name, proc_name);
102 pfs_unit_curr->proc_entry = create_proc_entry(pfs_unit_curr->proc_name,
103 S_IFREG | S_IRUSR |
104 S_IWUSR | S_IRGRP |
105 S_IROTH, parent_pfs);
106 if (pfs_unit_curr->proc_entry == 0)
107 return -1;
108
109 pfs_unit_curr->proc_entry->read_proc = read_proc;
110 pfs_unit_curr->proc_entry->write_proc = write_proc;
111 pfs_unit_curr->proc_entry->data = data;
112
113 return 0;
114
115}
116
117int
118get_bypass_info_pfs(char *page, char **start, off_t off, int count,
119 int *eof, void *data)
120{
121 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
122 int len = 0;
123
124 len += sprintf(page, "Name\t\t\t%s\n", pbp_device_block->bp_name);
125 len +=
126 sprintf(page + len, "Firmware version\t0x%x\n",
127 pbp_device_block->bp_fw_ver);
128
129 *eof = 1;
130 return len;
131}
132
133int
134get_bypass_slave_pfs(char *page, char **start, off_t off, int count,
135 int *eof, void *data)
136{
137 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
138
139 struct pci_dev *pci_slave_dev = pbp_device_block->bp_slave;
140 struct net_device *net_slave_dev;
141 int len = 0;
142
143 if (is_bypass_fn(pbp_device_block)) {
144 net_slave_dev = pci_get_drvdata(pci_slave_dev);
145 if (net_slave_dev)
146 len = sprintf(page, "%s\n", net_slave_dev->name);
147 else
148 len = sprintf(page, "fail\n");
149 } else
150 len = sprintf(page, "fail\n");
151
152 *eof = 1;
153 return len;
154}
155
156int
157get_bypass_caps_pfs(char *page, char **start, off_t off, int count,
158 int *eof, void *data)
159{
160 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
161
162 int len = 0, ret = 0;
163
164 ret = get_bypass_caps_fn(pbp_device_block);
165 if (ret == BP_NOT_CAP)
166 len = sprintf(page, "-1\n");
167 else
168 len = sprintf(page, "0x%x\n", ret);
169 *eof = 1;
170 return len;
171
172}
173
174int
175get_wd_set_caps_pfs(char *page, char **start, off_t off, int count,
176 int *eof, void *data)
177{
178 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
179
180 int len = 0, ret = 0;
181
182 ret = get_wd_set_caps_fn(pbp_device_block);
183 if (ret == BP_NOT_CAP)
184 len = sprintf(page, "-1\n");
185 else
186 len = sprintf(page, "0x%x\n", ret);
187 *eof = 1;
188 return len;
189}
190
191int
192set_bypass_pfs(struct file *file, const char *buffer,
193 unsigned long count, void *data)
194{
195
196 char kbuf[256];
197 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
198
199 int bypass_param = 0, length = 0;
200
201 if (count > (sizeof(kbuf) - 1))
202 return -1;
203
204 if (copy_from_user(&kbuf, buffer, count))
205 return -1;
206
207 kbuf[count] = '\0';
208 length = strlen(kbuf);
209 if (kbuf[length - 1] == '\n')
210 kbuf[--length] = '\0';
211
212 if (strcmp(kbuf, "on") == 0)
213 bypass_param = 1;
214 else if (strcmp(kbuf, "off") == 0)
215 bypass_param = 0;
216
217 set_bypass_fn(pbp_device_block, bypass_param);
218
219 return count;
220}
221
222int
223set_tap_pfs(struct file *file, const char *buffer,
224 unsigned long count, void *data)
225{
226
227 char kbuf[256];
228 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
229
230 int tap_param = 0, length = 0;
231
232 if (count > (sizeof(kbuf) - 1))
233 return -1;
234
235 if (copy_from_user(&kbuf, buffer, count))
236 return -1;
237
238 kbuf[count] = '\0';
239 length = strlen(kbuf);
240 if (kbuf[length - 1] == '\n')
241 kbuf[--length] = '\0';
242
243 if (strcmp(kbuf, "on") == 0)
244 tap_param = 1;
245 else if (strcmp(kbuf, "off") == 0)
246 tap_param = 0;
247
248 set_tap_fn(pbp_device_block, tap_param);
249
250 return count;
251}
252
253int
254set_disc_pfs(struct file *file, const char *buffer,
255 unsigned long count, void *data)
256{
257
258 char kbuf[256];
259 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
260
261 int tap_param = 0, length = 0;
262
263 if (count > (sizeof(kbuf) - 1))
264 return -1;
265
266 if (copy_from_user(&kbuf, buffer, count))
267 return -1;
268
269 kbuf[count] = '\0';
270 length = strlen(kbuf);
271 if (kbuf[length - 1] == '\n')
272 kbuf[--length] = '\0';
273
274 if (strcmp(kbuf, "on") == 0)
275 tap_param = 1;
276 else if (strcmp(kbuf, "off") == 0)
277 tap_param = 0;
278
279 set_disc_fn(pbp_device_block, tap_param);
280
281 return count;
282}
283
284int
285get_bypass_pfs(char *page, char **start, off_t off, int count,
286 int *eof, void *data)
287{
288 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
289
290 int len = 0, ret = 0;
291
292 ret = get_bypass_fn(pbp_device_block);
293 if (ret == BP_NOT_CAP)
294 len = sprintf(page, "fail\n");
295 else if (ret == 1)
296 len = sprintf(page, "on\n");
297 else if (ret == 0)
298 len = sprintf(page, "off\n");
299
300 *eof = 1;
301 return len;
302}
303
304int
305get_tap_pfs(char *page, char **start, off_t off, int count,
306 int *eof, void *data)
307{
308 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
309
310 int len = 0, ret = 0;
311
312 ret = get_tap_fn(pbp_device_block);
313 if (ret == BP_NOT_CAP)
314 len = sprintf(page, "fail\n");
315 else if (ret == 1)
316 len = sprintf(page, "on\n");
317 else if (ret == 0)
318 len = sprintf(page, "off\n");
319
320 *eof = 1;
321 return len;
322}
323
324int
325get_disc_pfs(char *page, char **start, off_t off, int count,
326 int *eof, void *data)
327{
328 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
329
330 int len = 0, ret = 0;
331
332 ret = get_disc_fn(pbp_device_block);
333 if (ret == BP_NOT_CAP)
334 len = sprintf(page, "fail\n");
335 else if (ret == 1)
336 len = sprintf(page, "on\n");
337 else if (ret == 0)
338 len = sprintf(page, "off\n");
339
340 *eof = 1;
341 return len;
342}
343
344int
345get_bypass_change_pfs(char *page, char **start, off_t off, int count,
346 int *eof, void *data)
347{
348 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
349
350 int len = 0, ret = 0;
351
352 ret = get_bypass_change_fn(pbp_device_block);
353 if (ret == 1)
354 len = sprintf(page, "on\n");
355 else if (ret == 0)
356 len = sprintf(page, "off\n");
357 else
358 len = sprintf(page, "fail\n");
359
360 *eof = 1;
361 return len;
362}
363
364int
365get_tap_change_pfs(char *page, char **start, off_t off, int count,
366 int *eof, void *data)
367{
368 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
369
370 int len = 0, ret = 0;
371
372 ret = get_tap_change_fn(pbp_device_block);
373 if (ret == 1)
374 len = sprintf(page, "on\n");
375 else if (ret == 0)
376 len = sprintf(page, "off\n");
377 else
378 len = sprintf(page, "fail\n");
379
380 *eof = 1;
381 return len;
382}
383
384int
385get_disc_change_pfs(char *page, char **start, off_t off, int count,
386 int *eof, void *data)
387{
388 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
389
390 int len = 0, ret = 0;
391
392 ret = get_disc_change_fn(pbp_device_block);
393 if (ret == 1)
394 len = sprintf(page, "on\n");
395 else if (ret == 0)
396 len = sprintf(page, "off\n");
397 else
398 len = sprintf(page, "fail\n");
399
400 *eof = 1;
401 return len;
402}
403
404int
405set_bypass_wd_pfs(struct file *file, const char *buffer,
406 unsigned long count, void *data)
407{
408
409 char kbuf[256];
410 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
411
412 unsigned int timeout = 0;
413 char *timeout_ptr = kbuf;
414
415 if (copy_from_user(&kbuf, buffer, count))
416 return -1;
417
418 timeout_ptr = kbuf;
419 timeout = atoi(&timeout_ptr);
420
421 set_bypass_wd_fn(pbp_device_block, timeout);
422
423 return count;
424}
425
426int
427get_bypass_wd_pfs(char *page, char **start, off_t off, int count,
428 int *eof, void *data)
429{
430 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
431
432 int len = 0, ret = 0, timeout = 0;
433
434 ret = get_bypass_wd_fn(pbp_device_block, &timeout);
435 if (ret == BP_NOT_CAP)
436 len = sprintf(page, "fail\n");
437 else if (timeout == -1)
438 len = sprintf(page, "unknown\n");
439 else if (timeout == 0)
440 len = sprintf(page, "disable\n");
441 else
442 len = sprintf(page, "%d\n", timeout);
443
444 *eof = 1;
445 return len;
446}
447
448int
449get_wd_expire_time_pfs(char *page, char **start, off_t off, int count,
450 int *eof, void *data)
451{
452 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
453
454 int len = 0, ret = 0, timeout = 0;
455
456 ret = get_wd_expire_time_fn(pbp_device_block, &timeout);
457 if (ret == BP_NOT_CAP)
458 len = sprintf(page, "fail\n");
459 else if (timeout == -1)
460 len = sprintf(page, "expire\n");
461 else if (timeout == 0)
462 len = sprintf(page, "disable\n");
463
464 else
465 len = sprintf(page, "%d\n", timeout);
466 *eof = 1;
467 return len;
468}
469
470int
471get_tpl_pfs(char *page, char **start, off_t off, int count,
472 int *eof, void *data)
473{
474 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
475
476 int len = 0, ret = 0;
477
478 ret = get_tpl_fn(pbp_device_block);
479 if (ret == BP_NOT_CAP)
480 len = sprintf(page, "fail\n");
481 else if (ret == 1)
482 len = sprintf(page, "on\n");
483 else if (ret == 0)
484 len = sprintf(page, "off\n");
485
486 *eof = 1;
487 return len;
488}
489
490#ifdef PMC_FIX_FLAG
491int
492get_wait_at_pwup_pfs(char *page, char **start, off_t off, int count,
493 int *eof, void *data)
494{
495 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
496
497 int len = 0, ret = 0;
498
499 ret = get_bp_wait_at_pwup_fn(pbp_device_block);
500 if (ret == BP_NOT_CAP)
501 len = sprintf(page, "fail\n");
502 else if (ret == 1)
503 len = sprintf(page, "on\n");
504 else if (ret == 0)
505 len = sprintf(page, "off\n");
506
507 *eof = 1;
508 return len;
509}
510
511int
512get_hw_reset_pfs(char *page, char **start, off_t off, int count,
513 int *eof, void *data)
514{
515 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
516
517 int len = 0, ret = 0;
518
519 ret = get_bp_hw_reset_fn(pbp_device_block);
520 if (ret == BP_NOT_CAP)
521 len = sprintf(page, "fail\n");
522 else if (ret == 1)
523 len = sprintf(page, "on\n");
524 else if (ret == 0)
525 len = sprintf(page, "off\n");
526
527 *eof = 1;
528 return len;
529}
530
531#endif /*PMC_WAIT_FLAG */
532
533int
534reset_bypass_wd_pfs(char *page, char **start, off_t off, int count,
535 int *eof, void *data)
536{
537 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
538
539 int len = 0, ret = 0;
540
541 ret = reset_bypass_wd_timer_fn(pbp_device_block);
542 if (ret == BP_NOT_CAP)
543 len = sprintf(page, "fail\n");
544 else if (ret == 0)
545 len = sprintf(page, "disable\n");
546 else if (ret == 1)
547 len = sprintf(page, "success\n");
548
549 *eof = 1;
550 return len;
551}
552
553int
554set_dis_bypass_pfs(struct file *file, const char *buffer,
555 unsigned long count, void *data)
556{
557
558 char kbuf[256];
559 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
560
561 int bypass_param = 0, length = 0;
562
563 if (copy_from_user(&kbuf, buffer, count))
564 return -1;
565
566 kbuf[count] = '\0';
567 length = strlen(kbuf);
568 if (kbuf[length - 1] == '\n')
569 kbuf[--length] = '\0';
570
571 if (strcmp(kbuf, "on") == 0)
572 bypass_param = 1;
573 else if (strcmp(kbuf, "off") == 0)
574 bypass_param = 0;
575
576 set_dis_bypass_fn(pbp_device_block, bypass_param);
577
578 return count;
579}
580
581int
582set_dis_tap_pfs(struct file *file, const char *buffer,
583 unsigned long count, void *data)
584{
585
586 char kbuf[256];
587 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
588
589 int tap_param = 0, length = 0;
590
591 if (copy_from_user(&kbuf, buffer, count))
592 return -1;
593
594 kbuf[count] = '\0';
595 length = strlen(kbuf);
596 if (kbuf[length - 1] == '\n')
597 kbuf[--length] = '\0';
598
599 if (strcmp(kbuf, "on") == 0)
600 tap_param = 1;
601 else if (strcmp(kbuf, "off") == 0)
602 tap_param = 0;
603
604 set_dis_tap_fn(pbp_device_block, tap_param);
605
606 return count;
607}
608
609int
610set_dis_disc_pfs(struct file *file, const char *buffer,
611 unsigned long count, void *data)
612{
613
614 char kbuf[256];
615 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
616
617 int tap_param = 0, length = 0;
618
619 if (copy_from_user(&kbuf, buffer, count))
620 return -1;
621
622 kbuf[count] = '\0';
623 length = strlen(kbuf);
624 if (kbuf[length - 1] == '\n')
625 kbuf[--length] = '\0';
626
627 if (strcmp(kbuf, "on") == 0)
628 tap_param = 1;
629 else if (strcmp(kbuf, "off") == 0)
630 tap_param = 0;
631
632 set_dis_disc_fn(pbp_device_block, tap_param);
633
634 return count;
635}
636
637int
638get_dis_bypass_pfs(char *page, char **start, off_t off, int count,
639 int *eof, void *data)
640{
641 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
642
643 int len = 0, ret = 0;
644
645 ret = get_dis_bypass_fn(pbp_device_block);
646 if (ret == BP_NOT_CAP)
647 len = sprintf(page, "fail\n");
648 else if (ret == 0)
649 len = sprintf(page, "off\n");
650 else
651 len = sprintf(page, "on\n");
652
653 *eof = 1;
654 return len;
655}
656
657int
658get_dis_tap_pfs(char *page, char **start, off_t off, int count,
659 int *eof, void *data)
660{
661 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
662
663 int len = 0, ret = 0;
664
665 ret = get_dis_tap_fn(pbp_device_block);
666 if (ret == BP_NOT_CAP)
667 len = sprintf(page, "fail\n");
668 else if (ret == 0)
669 len = sprintf(page, "off\n");
670 else
671 len = sprintf(page, "on\n");
672
673 *eof = 1;
674 return len;
675}
676
677int
678get_dis_disc_pfs(char *page, char **start, off_t off, int count,
679 int *eof, void *data)
680{
681 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
682
683 int len = 0, ret = 0;
684
685 ret = get_dis_disc_fn(pbp_device_block);
686 if (ret == BP_NOT_CAP)
687 len = sprintf(page, "fail\n");
688 else if (ret == 0)
689 len = sprintf(page, "off\n");
690 else
691 len = sprintf(page, "on\n");
692
693 *eof = 1;
694 return len;
695}
696
697int
698set_bypass_pwup_pfs(struct file *file, const char *buffer,
699 unsigned long count, void *data)
700{
701
702 char kbuf[256];
703 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
704
705 int bypass_param = 0, length = 0;
706
707 if (copy_from_user(&kbuf, buffer, count))
708 return -1;
709
710 kbuf[count] = '\0';
711 length = strlen(kbuf);
712 if (kbuf[length - 1] == '\n')
713 kbuf[--length] = '\0';
714
715 if (strcmp(kbuf, "on") == 0)
716 bypass_param = 1;
717 else if (strcmp(kbuf, "off") == 0)
718 bypass_param = 0;
719
720 set_bypass_pwup_fn(pbp_device_block, bypass_param);
721
722 return count;
723}
724
725int
726set_bypass_pwoff_pfs(struct file *file, const char *buffer,
727 unsigned long count, void *data)
728{
729
730 char kbuf[256];
731 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
732
733 int bypass_param = 0, length = 0;
734
735 if (copy_from_user(&kbuf, buffer, count))
736 return -1;
737
738 kbuf[count] = '\0';
739 length = strlen(kbuf);
740 if (kbuf[length - 1] == '\n')
741 kbuf[--length] = '\0';
742
743 if (strcmp(kbuf, "on") == 0)
744 bypass_param = 1;
745 else if (strcmp(kbuf, "off") == 0)
746 bypass_param = 0;
747
748 set_bypass_pwoff_fn(pbp_device_block, bypass_param);
749
750 return count;
751}
752
753int
754set_tap_pwup_pfs(struct file *file, const char *buffer,
755 unsigned long count, void *data)
756{
757
758 char kbuf[256];
759 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
760
761 int tap_param = 0, length = 0;
762
763 if (copy_from_user(&kbuf, buffer, count))
764 return -1;
765
766 kbuf[count] = '\0';
767 length = strlen(kbuf);
768 if (kbuf[length - 1] == '\n')
769 kbuf[--length] = '\0';
770
771 if (strcmp(kbuf, "on") == 0)
772 tap_param = 1;
773 else if (strcmp(kbuf, "off") == 0)
774 tap_param = 0;
775
776 set_tap_pwup_fn(pbp_device_block, tap_param);
777
778 return count;
779}
780
781int
782set_disc_pwup_pfs(struct file *file, const char *buffer,
783 unsigned long count, void *data)
784{
785
786 char kbuf[256];
787 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
788
789 int tap_param = 0, length = 0;
790
791 if (copy_from_user(&kbuf, buffer, count))
792 return -1;
793
794 kbuf[count] = '\0';
795 length = strlen(kbuf);
796 if (kbuf[length - 1] == '\n')
797 kbuf[--length] = '\0';
798
799 if (strcmp(kbuf, "on") == 0)
800 tap_param = 1;
801 else if (strcmp(kbuf, "off") == 0)
802 tap_param = 0;
803
804 set_disc_pwup_fn(pbp_device_block, tap_param);
805
806 return count;
807}
808
809int
810get_bypass_pwup_pfs(char *page, char **start, off_t off, int count,
811 int *eof, void *data)
812{
813 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
814
815 int len = 0, ret = 0;
816
817 ret = get_bypass_pwup_fn(pbp_device_block);
818 if (ret == BP_NOT_CAP)
819 len = sprintf(page, "fail\n");
820 else if (ret == 0)
821 len = sprintf(page, "off\n");
822 else
823 len = sprintf(page, "on\n");
824
825 *eof = 1;
826 return len;
827}
828
829int
830get_bypass_pwoff_pfs(char *page, char **start, off_t off, int count,
831 int *eof, void *data)
832{
833 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
834
835 int len = 0, ret = 0;
836
837 ret = get_bypass_pwoff_fn(pbp_device_block);
838 if (ret == BP_NOT_CAP)
839 len = sprintf(page, "fail\n");
840 else if (ret == 0)
841 len = sprintf(page, "off\n");
842 else
843 len = sprintf(page, "on\n");
844
845 *eof = 1;
846 return len;
847}
848
849int
850get_tap_pwup_pfs(char *page, char **start, off_t off, int count,
851 int *eof, void *data)
852{
853 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
854
855 int len = 0, ret = 0;
856
857 ret = get_tap_pwup_fn(pbp_device_block);
858 if (ret == BP_NOT_CAP)
859 len = sprintf(page, "fail\n");
860 else if (ret == 0)
861 len = sprintf(page, "off\n");
862 else
863 len = sprintf(page, "on\n");
864
865 *eof = 1;
866 return len;
867}
868
869int
870get_disc_pwup_pfs(char *page, char **start, off_t off, int count,
871 int *eof, void *data)
872{
873 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
874
875 int len = 0, ret = 0;
876
877 ret = get_disc_pwup_fn(pbp_device_block);
878 if (ret == BP_NOT_CAP)
879 len = sprintf(page, "fail\n");
880 else if (ret == 0)
881 len = sprintf(page, "off\n");
882 else
883 len = sprintf(page, "on\n");
884
885 *eof = 1;
886 return len;
887}
888
889int
890set_std_nic_pfs(struct file *file, const char *buffer,
891 unsigned long count, void *data)
892{
893
894 char kbuf[256];
895 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
896
897 int bypass_param = 0, length = 0;
898
899 if (copy_from_user(&kbuf, buffer, count))
900 return -1;
901
902 kbuf[count] = '\0';
903 length = strlen(kbuf);
904 if (kbuf[length - 1] == '\n')
905 kbuf[--length] = '\0';
906
907 if (strcmp(kbuf, "on") == 0)
908 bypass_param = 1;
909 else if (strcmp(kbuf, "off") == 0)
910 bypass_param = 0;
911
912 set_std_nic_fn(pbp_device_block, bypass_param);
913
914 return count;
915}
916
917int
918get_std_nic_pfs(char *page, char **start, off_t off, int count,
919 int *eof, void *data)
920{
921 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
922
923 int len = 0, ret = 0;
924
925 ret = get_std_nic_fn(pbp_device_block);
926 if (ret == BP_NOT_CAP)
927 len = sprintf(page, "fail\n");
928 else if (ret == 0)
929 len = sprintf(page, "off\n");
930 else
931 len = sprintf(page, "on\n");
932
933 *eof = 1;
934 return len;
935}
936
937int
938get_wd_exp_mode_pfs(char *page, char **start, off_t off, int count,
939 int *eof, void *data)
940{
941 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
942
943 int len = 0, ret = 0;
944
945 ret = get_wd_exp_mode_fn(pbp_device_block);
946 if (ret == 1)
947 len = sprintf(page, "tap\n");
948 else if (ret == 0)
949 len = sprintf(page, "bypass\n");
950 else if (ret == 2)
951 len = sprintf(page, "disc\n");
952
953 else
954 len = sprintf(page, "fail\n");
955
956 *eof = 1;
957 return len;
958}
959
960int
961set_wd_exp_mode_pfs(struct file *file, const char *buffer,
962 unsigned long count, void *data)
963{
964
965 char kbuf[256];
966 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
967
968 int bypass_param = 0, length = 0;
969
970 if (count > (sizeof(kbuf) - 1))
971 return -1;
972
973 if (copy_from_user(&kbuf, buffer, count))
974 return -1;
975
976 kbuf[count] = '\0';
977 length = strlen(kbuf);
978 if (kbuf[length - 1] == '\n')
979 kbuf[--length] = '\0';
980
981 if (strcmp(kbuf, "tap") == 0)
982 bypass_param = 1;
983 else if (strcmp(kbuf, "bypass") == 0)
984 bypass_param = 0;
985 else if (strcmp(kbuf, "disc") == 0)
986 bypass_param = 2;
987
988 set_wd_exp_mode_fn(pbp_device_block, bypass_param);
989
990 return count;
991}
992
993int
994get_wd_autoreset_pfs(char *page, char **start, off_t off, int count,
995 int *eof, void *data)
996{
997 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
998
999 int len = 0, ret = 0;
1000
1001 ret = get_wd_autoreset_fn(pbp_device_block);
1002 if (ret >= 0)
1003 len = sprintf(page, "%d\n", ret);
1004 else
1005 len = sprintf(page, "fail\n");
1006
1007 *eof = 1;
1008 return len;
1009}
1010
1011int
1012set_wd_autoreset_pfs(struct file *file, const char *buffer,
1013 unsigned long count, void *data)
1014{
1015 char kbuf[256];
1016 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
1017 u32 timeout = 0;
1018 char *timeout_ptr = kbuf;
1019
1020 if (copy_from_user(&kbuf, buffer, count))
1021 return -1;
1022
1023 timeout_ptr = kbuf;
1024 timeout = atoi(&timeout_ptr);
1025
1026 set_wd_autoreset_fn(pbp_device_block, timeout);
1027
1028 return count;
1029}
1030
1031int
1032set_tpl_pfs(struct file *file, const char *buffer,
1033 unsigned long count, void *data)
1034{
1035
1036 char kbuf[256];
1037 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
1038
1039 int tpl_param = 0, length = 0;
1040
1041 if (count > (sizeof(kbuf) - 1))
1042 return -1;
1043
1044 if (copy_from_user(&kbuf, buffer, count))
1045 return -1;
1046
1047 kbuf[count] = '\0';
1048 length = strlen(kbuf);
1049 if (kbuf[length - 1] == '\n')
1050 kbuf[--length] = '\0';
1051
1052 if (strcmp(kbuf, "on") == 0)
1053 tpl_param = 1;
1054 else if (strcmp(kbuf, "off") == 0)
1055 tpl_param = 0;
1056
1057 set_tpl_fn(pbp_device_block, tpl_param);
1058
1059 return count;
1060}
1061
1062#ifdef PMC_FIX_FLAG
1063int
1064set_wait_at_pwup_pfs(struct file *file, const char *buffer,
1065 unsigned long count, void *data)
1066{
1067
1068 char kbuf[256];
1069 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
1070
1071 int tpl_param = 0, length = 0;
1072
1073 if (count > (sizeof(kbuf) - 1))
1074 return -1;
1075
1076 if (copy_from_user(&kbuf, buffer, count))
1077 return -1;
1078
1079 kbuf[count] = '\0';
1080 length = strlen(kbuf);
1081 if (kbuf[length - 1] == '\n')
1082 kbuf[--length] = '\0';
1083
1084 if (strcmp(kbuf, "on") == 0)
1085 tpl_param = 1;
1086 else if (strcmp(kbuf, "off") == 0)
1087 tpl_param = 0;
1088
1089 set_bp_wait_at_pwup_fn(pbp_device_block, tpl_param);
1090
1091 return count;
1092}
1093
1094int
1095set_hw_reset_pfs(struct file *file, const char *buffer,
1096 unsigned long count, void *data)
1097{
1098
1099 char kbuf[256];
1100 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
1101
1102 int tpl_param = 0, length = 0;
1103
1104 if (count > (sizeof(kbuf) - 1))
1105 return -1;
1106
1107 if (copy_from_user(&kbuf, buffer, count))
1108 return -1;
1109
1110 kbuf[count] = '\0';
1111 length = strlen(kbuf);
1112 if (kbuf[length - 1] == '\n')
1113 kbuf[--length] = '\0';
1114
1115 if (strcmp(kbuf, "on") == 0)
1116 tpl_param = 1;
1117 else if (strcmp(kbuf, "off") == 0)
1118 tpl_param = 0;
1119
1120 set_bp_hw_reset_fn(pbp_device_block, tpl_param);
1121
1122 return count;
1123}
1124
1125#endif /*PMC_FIX_FLAG */
1126
1127int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block)
1128{
1129 struct bypass_pfs_sd *current_pfs = &(pbp_device_block->bypass_pfs_set);
1130 static struct proc_dir_entry *procfs_dir;
1131 int ret = 0;
1132
1133 sprintf(current_pfs->dir_name, "bypass_%s", dev->name);
1134
1135 if (!bp_procfs_dir)
1136 return -1;
1137
1138 /* create device proc dir */
1139 procfs_dir = proc_getdir(current_pfs->dir_name, bp_procfs_dir);
1140 if (procfs_dir == 0) {
1141 printk(KERN_DEBUG "Could not create procfs directory %s\n",
1142 current_pfs->dir_name);
1143 return -1;
1144 }
1145 current_pfs->bypass_entry = procfs_dir;
1146
1147 if (bypass_proc_create_entry(&(current_pfs->bypass_info), BYPASS_INFO_ENTRY_SD, NULL, /* write */
1148 get_bypass_info_pfs, /* read */
1149 procfs_dir, pbp_device_block))
1150 ret = -1;
1151
1152 if (pbp_device_block->bp_caps & SW_CTL_CAP) {
1153
1154 /* Create set param proc's */
1155 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_slave), BYPASS_SLAVE_ENTRY_SD, NULL, /* write */
1156 get_bypass_slave_pfs, /* read */
1157 procfs_dir, pbp_device_block))
1158 ret = -1;
1159
1160 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_caps), BYPASS_CAPS_ENTRY_SD, NULL, /* write */
1161 get_bypass_caps_pfs, /* read */
1162 procfs_dir, pbp_device_block))
1163 ret = -1;
1164
1165 if (bypass_proc_create_entry_sd(&(current_pfs->wd_set_caps), WD_SET_CAPS_ENTRY_SD, NULL, /* write */
1166 get_wd_set_caps_pfs, /* read */
1167 procfs_dir, pbp_device_block))
1168 ret = -1;
1169 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_wd), BYPASS_WD_ENTRY_SD, set_bypass_wd_pfs, /* write */
1170 get_bypass_wd_pfs, /* read */
1171 procfs_dir, pbp_device_block))
1172 ret = -1;
1173
1174 if (bypass_proc_create_entry_sd(&(current_pfs->wd_expire_time), WD_EXPIRE_TIME_ENTRY_SD, NULL, /* write */
1175 get_wd_expire_time_pfs, /* read */
1176 procfs_dir, pbp_device_block))
1177 ret = -1;
1178
1179 if (bypass_proc_create_entry_sd(&(current_pfs->reset_bypass_wd), RESET_BYPASS_WD_ENTRY_SD, NULL, /* write */
1180 reset_bypass_wd_pfs, /* read */
1181 procfs_dir, pbp_device_block))
1182 ret = -1;
1183
1184 if (bypass_proc_create_entry_sd(&(current_pfs->std_nic), STD_NIC_ENTRY_SD, set_std_nic_pfs, /* write */
1185 get_std_nic_pfs, /* read */
1186 procfs_dir, pbp_device_block))
1187 ret = -1;
1188
1189 if (pbp_device_block->bp_caps & BP_CAP) {
1190 if (bypass_proc_create_entry_sd(&(current_pfs->bypass), BYPASS_ENTRY_SD, set_bypass_pfs, /* write */
1191 get_bypass_pfs, /* read */
1192 procfs_dir,
1193 pbp_device_block))
1194 ret = -1;
1195
1196 if (bypass_proc_create_entry_sd(&(current_pfs->dis_bypass), DIS_BYPASS_ENTRY_SD, set_dis_bypass_pfs, /* write */
1197 get_dis_bypass_pfs, /* read */
1198 procfs_dir,
1199 pbp_device_block))
1200 ret = -1;
1201
1202 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_pwup), BYPASS_PWUP_ENTRY_SD, set_bypass_pwup_pfs, /* write */
1203 get_bypass_pwup_pfs, /* read */
1204 procfs_dir,
1205 pbp_device_block))
1206 ret = -1;
1207 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_pwoff), BYPASS_PWOFF_ENTRY_SD, set_bypass_pwoff_pfs, /* write */
1208 get_bypass_pwoff_pfs, /* read */
1209 procfs_dir,
1210 pbp_device_block))
1211 ret = -1;
1212
1213 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_change), BYPASS_CHANGE_ENTRY_SD, NULL, /* write */
1214 get_bypass_change_pfs, /* read */
1215 procfs_dir,
1216 pbp_device_block))
1217 ret = -1;
1218 }
1219
1220 if (pbp_device_block->bp_caps & TAP_CAP) {
1221
1222 if (bypass_proc_create_entry_sd(&(current_pfs->tap), TAP_ENTRY_SD, set_tap_pfs, /* write */
1223 get_tap_pfs, /* read */
1224 procfs_dir,
1225 pbp_device_block))
1226 ret = -1;
1227
1228 if (bypass_proc_create_entry_sd(&(current_pfs->dis_tap), DIS_TAP_ENTRY_SD, set_dis_tap_pfs, /* write */
1229 get_dis_tap_pfs, /* read */
1230 procfs_dir,
1231 pbp_device_block))
1232 ret = -1;
1233
1234 if (bypass_proc_create_entry_sd(&(current_pfs->tap_pwup), TAP_PWUP_ENTRY_SD, set_tap_pwup_pfs, /* write */
1235 get_tap_pwup_pfs, /* read */
1236 procfs_dir,
1237 pbp_device_block))
1238 ret = -1;
1239
1240 if (bypass_proc_create_entry_sd(&(current_pfs->tap_change), TAP_CHANGE_ENTRY_SD, NULL, /* write */
1241 get_tap_change_pfs, /* read */
1242 procfs_dir,
1243 pbp_device_block))
1244 ret = -1;
1245 }
1246 if (pbp_device_block->bp_caps & DISC_CAP) {
1247
1248 if (bypass_proc_create_entry_sd(&(current_pfs->tap), DISC_ENTRY_SD, set_disc_pfs, /* write */
1249 get_disc_pfs, /* read */
1250 procfs_dir,
1251 pbp_device_block))
1252 ret = -1;
1253#if 1
1254
1255 if (bypass_proc_create_entry_sd(&(current_pfs->dis_tap), DIS_DISC_ENTRY_SD, set_dis_disc_pfs, /* write */
1256 get_dis_disc_pfs, /* read */
1257 procfs_dir,
1258 pbp_device_block))
1259 ret = -1;
1260#endif
1261
1262 if (bypass_proc_create_entry_sd(&(current_pfs->tap_pwup), DISC_PWUP_ENTRY_SD, set_disc_pwup_pfs, /* write */
1263 get_disc_pwup_pfs, /* read */
1264 procfs_dir,
1265 pbp_device_block))
1266 ret = -1;
1267
1268 if (bypass_proc_create_entry_sd(&(current_pfs->tap_change), DISC_CHANGE_ENTRY_SD, NULL, /* write */
1269 get_disc_change_pfs, /* read */
1270 procfs_dir,
1271 pbp_device_block))
1272 ret = -1;
1273 }
1274
1275 if (bypass_proc_create_entry_sd(&(current_pfs->wd_exp_mode), WD_EXP_MODE_ENTRY_SD, set_wd_exp_mode_pfs, /* write */
1276 get_wd_exp_mode_pfs, /* read */
1277 procfs_dir, pbp_device_block))
1278 ret = -1;
1279
1280 if (bypass_proc_create_entry_sd(&(current_pfs->wd_autoreset), WD_AUTORESET_ENTRY_SD, set_wd_autoreset_pfs, /* write */
1281 get_wd_autoreset_pfs, /* read */
1282 procfs_dir, pbp_device_block))
1283 ret = -1;
1284 if (bypass_proc_create_entry_sd(&(current_pfs->tpl), TPL_ENTRY_SD, set_tpl_pfs, /* write */
1285 get_tpl_pfs, /* read */
1286 procfs_dir, pbp_device_block))
1287 ret = -1;
1288#ifdef PMC_FIX_FLAG
1289 if (bypass_proc_create_entry_sd(&(current_pfs->tpl), WAIT_AT_PWUP_ENTRY_SD, set_wait_at_pwup_pfs, /* write */
1290 get_wait_at_pwup_pfs, /* read */
1291 procfs_dir, pbp_device_block))
1292 ret = -1;
1293 if (bypass_proc_create_entry_sd(&(current_pfs->tpl), HW_RESET_ENTRY_SD, set_hw_reset_pfs, /* write */
1294 get_hw_reset_pfs, /* read */
1295 procfs_dir, pbp_device_block))
1296 ret = -1;
1297
1298#endif
1299
1300 }
1301 if (ret < 0)
1302 printk(KERN_DEBUG "Create proc entry failed\n");
1303
1304 return ret;
1305}
1306
1307int bypass_proc_remove_dev_sd(bpctl_dev_t *pbp_device_block)
1308{
1309
1310 struct bypass_pfs_sd *current_pfs = &pbp_device_block->bypass_pfs_set;
1311 struct proc_dir_entry *pde = current_pfs->bypass_entry, *pde_curr =
1312 NULL;
1313 char name[256];
1314
1315 for (pde = pde->subdir; pde;) {
1316 strcpy(name, pde->name);
1317 pde_curr = pde;
1318 pde = pde->next;
1319 remove_proc_entry(name, current_pfs->bypass_entry);
1320 }
1321 if (!pde)
1322 remove_proc_entry(current_pfs->dir_name, bp_procfs_dir);
1323
1324 return 0;
1325}
1326
1327#endif /* BYPASS_SUPPORT */
diff --git a/drivers/staging/silicom/bp_mod.c b/drivers/staging/silicom/bpctl_mod.c
index 45a222723207..b7e570ccb759 100644
--- a/drivers/staging/silicom/bp_mod.c
+++ b/drivers/staging/silicom/bpctl_mod.c
@@ -35,7 +35,6 @@
35#define BP_MOD_DESCR "Silicom Bypass-SD Control driver" 35#define BP_MOD_DESCR "Silicom Bypass-SD Control driver"
36#define BP_SYNC_FLAG 1 36#define BP_SYNC_FLAG 1
37 37
38static int Device_Open = 0;
39static int major_num = 0; 38static int major_num = 0;
40 39
41MODULE_AUTHOR("Anna Lukin, annal@silicom.co.il"); 40MODULE_AUTHOR("Anna Lukin, annal@silicom.co.il");
@@ -60,35 +59,9 @@ typedef enum {
60 bp_none, 59 bp_none,
61} bp_media_type; 60} bp_media_type;
62 61
63struct pfs_unit_sd {
64 struct proc_dir_entry *proc_entry;
65 char proc_name[32];
66};
67
68struct bypass_pfs_sd { 62struct bypass_pfs_sd {
69 char dir_name[32]; 63 char dir_name[32];
70 struct proc_dir_entry *bypass_entry; 64 struct proc_dir_entry *bypass_entry;
71 struct pfs_unit_sd bypass_info;
72 struct pfs_unit_sd bypass_slave;
73 struct pfs_unit_sd bypass_caps;
74 struct pfs_unit_sd wd_set_caps;
75 struct pfs_unit_sd bypass;
76 struct pfs_unit_sd bypass_change;
77 struct pfs_unit_sd bypass_wd;
78 struct pfs_unit_sd wd_expire_time;
79 struct pfs_unit_sd reset_bypass_wd;
80 struct pfs_unit_sd dis_bypass;
81 struct pfs_unit_sd bypass_pwup;
82 struct pfs_unit_sd bypass_pwoff;
83 struct pfs_unit_sd std_nic;
84 struct pfs_unit_sd tap;
85 struct pfs_unit_sd dis_tap;
86 struct pfs_unit_sd tap_pwup;
87 struct pfs_unit_sd tap_change;
88 struct pfs_unit_sd wd_exp_mode;
89 struct pfs_unit_sd wd_autoreset;
90 struct pfs_unit_sd tpl;
91
92}; 65};
93 66
94typedef struct _bpctl_dev { 67typedef struct _bpctl_dev {
@@ -315,27 +288,6 @@ static struct notifier_block bp_notifier_block = {
315 .notifier_call = bp_device_event, 288 .notifier_call = bp_device_event,
316}; 289};
317 290
318static int device_open(struct inode *inode, struct file *file)
319{
320#ifdef DEBUG
321 printk("device_open(%p)\n", file);
322#endif
323 Device_Open++;
324/*
325* Initialize the message
326*/
327 return SUCCESS;
328}
329
330static int device_release(struct inode *inode, struct file *file)
331{
332#ifdef DEBUG
333 printk("device_release(%p,%p)\n", inode, file);
334#endif
335 Device_Open--;
336 return SUCCESS;
337}
338
339int is_bypass_fn(bpctl_dev_t *pbpctl_dev); 291int is_bypass_fn(bpctl_dev_t *pbpctl_dev);
340int wdt_time_left(bpctl_dev_t *pbpctl_dev); 292int wdt_time_left(bpctl_dev_t *pbpctl_dev);
341 293
@@ -1728,62 +1680,33 @@ int gpio6_clear_fn(bpctl_dev_t *pbpctl_dev)
1728} 1680}
1729#endif /*BYPASS_DEBUG */ 1681#endif /*BYPASS_DEBUG */
1730 1682
1731static bpctl_dev_t *get_status_port_fn(bpctl_dev_t *pbpctl_dev) 1683static bpctl_dev_t *lookup_port(bpctl_dev_t *dev)
1732{ 1684{
1733 int idx_dev = 0; 1685 bpctl_dev_t *p;
1734 1686 int n;
1735 if (pbpctl_dev == NULL) 1687 for (n = 0, p = bpctl_dev_arr; n < device_num && p->pdev; n++) {
1736 return NULL; 1688 if (p->bus == dev->bus
1737 1689 && p->slot == dev->slot
1738 if ((pbpctl_dev->func == 0) || (pbpctl_dev->func == 2)) { 1690 && p->func == (dev->func ^ 1))
1739 for (idx_dev = 0; 1691 return p;
1740 ((bpctl_dev_arr[idx_dev].pdev != NULL) 1692 }
1741 && (idx_dev < device_num)); idx_dev++) { 1693 return NULL;
1742 if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->bus) 1694}
1743 && (bpctl_dev_arr[idx_dev].slot == pbpctl_dev->slot)
1744 && ((bpctl_dev_arr[idx_dev].func == 1)
1745 && (pbpctl_dev->func == 0))) {
1746
1747 return &(bpctl_dev_arr[idx_dev]);
1748 }
1749 if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->bus) &&
1750 (bpctl_dev_arr[idx_dev].slot == pbpctl_dev->slot) &&
1751 ((bpctl_dev_arr[idx_dev].func == 3)
1752 && (pbpctl_dev->func == 2))) {
1753 1695
1754 return &(bpctl_dev_arr[idx_dev]); 1696static bpctl_dev_t *get_status_port_fn(bpctl_dev_t *pbpctl_dev)
1755 } 1697{
1756 } 1698 if (pbpctl_dev) {
1699 if (pbpctl_dev->func == 0 || pbpctl_dev->func == 2)
1700 return lookup_port(pbpctl_dev);
1757 } 1701 }
1758 return NULL; 1702 return NULL;
1759} 1703}
1760 1704
1761static bpctl_dev_t *get_master_port_fn(bpctl_dev_t *pbpctl_dev) 1705static bpctl_dev_t *get_master_port_fn(bpctl_dev_t *pbpctl_dev)
1762{ 1706{
1763 int idx_dev = 0; 1707 if (pbpctl_dev) {
1764 1708 if (pbpctl_dev->func == 1 || pbpctl_dev->func == 3)
1765 if (pbpctl_dev == NULL) 1709 return lookup_port(pbpctl_dev);
1766 return NULL;
1767
1768 if ((pbpctl_dev->func == 1) || (pbpctl_dev->func == 3)) {
1769 for (idx_dev = 0;
1770 ((bpctl_dev_arr[idx_dev].pdev != NULL)
1771 && (idx_dev < device_num)); idx_dev++) {
1772 if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->bus)
1773 && (bpctl_dev_arr[idx_dev].slot == pbpctl_dev->slot)
1774 && ((bpctl_dev_arr[idx_dev].func == 0)
1775 && (pbpctl_dev->func == 1))) {
1776
1777 return &(bpctl_dev_arr[idx_dev]);
1778 }
1779 if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->bus) &&
1780 (bpctl_dev_arr[idx_dev].slot == pbpctl_dev->slot) &&
1781 ((bpctl_dev_arr[idx_dev].func == 2)
1782 && (pbpctl_dev->func == 3))) {
1783
1784 return &(bpctl_dev_arr[idx_dev]);
1785 }
1786 }
1787 } 1710 }
1788 return NULL; 1711 return NULL;
1789} 1712}
@@ -5858,11 +5781,9 @@ static long device_ioctl(struct file *file, /* see include/linux/fs.h */
5858 return ret; 5781 return ret;
5859} 5782}
5860 5783
5861struct file_operations Fops = { 5784static const struct file_operations Fops = {
5862 .owner = THIS_MODULE, 5785 .owner = THIS_MODULE,
5863 .unlocked_ioctl = device_ioctl, 5786 .unlocked_ioctl = device_ioctl,
5864 .open = device_open,
5865 .release = device_release, /* a.k.a. close */
5866}; 5787};
5867 5788
5868#ifndef PCI_DEVICE 5789#ifndef PCI_DEVICE
@@ -6686,6 +6607,118 @@ static bpmod_info_t tx_ctl_pci_tbl[] = {
6686 {0,} 6607 {0,}
6687}; 6608};
6688 6609
6610static void find_fw(bpctl_dev_t *dev)
6611{
6612 unsigned long mmio_start, mmio_len;
6613 struct pci_dev *pdev1 = dev->pdev;
6614
6615 if ((OLD_IF_SERIES(dev->subdevice)) ||
6616 (INTEL_IF_SERIES(dev->subdevice)))
6617 dev->bp_fw_ver = 0xff;
6618 else
6619 dev->bp_fw_ver = bypass_fw_ver(dev);
6620
6621 if (dev->bp_10gb == 1 && dev->bp_fw_ver == 0xff) {
6622 int cnt = 100;
6623 while (cnt--) {
6624 iounmap((void *)dev->mem_map);
6625 mmio_start = pci_resource_start(pdev1, 0);
6626 mmio_len = pci_resource_len(pdev1, 0);
6627
6628 dev->mem_map = (unsigned long)
6629 ioremap(mmio_start, mmio_len);
6630
6631 dev->bp_fw_ver = bypass_fw_ver(dev);
6632 if (dev-> bp_fw_ver == 0xa8)
6633 break;
6634 }
6635 }
6636 /* dev->bp_fw_ver=0xa8; */
6637 printk("firmware version: 0x%x\n", dev->bp_fw_ver);
6638}
6639
6640static int init_one(bpctl_dev_t *dev, bpmod_info_t *info, struct pci_dev *pdev1)
6641{
6642 unsigned long mmio_start, mmio_len;
6643
6644 dev->pdev = pdev1;
6645 mmio_start = pci_resource_start(pdev1, 0);
6646 mmio_len = pci_resource_len(pdev1, 0);
6647
6648 dev->desc = dev_desc[info->index].name;
6649 dev->name = info->bp_name;
6650 dev->device = info->device;
6651 dev->vendor = info->vendor;
6652 dev->subdevice = info->subdevice;
6653 dev->subvendor = info->subvendor;
6654 dev->func = PCI_FUNC(pdev1->devfn);
6655 dev->slot = PCI_SLOT(pdev1->devfn);
6656 dev->bus = pdev1->bus->number;
6657 dev->mem_map = (unsigned long)ioremap(mmio_start, mmio_len);
6658#ifdef BP_SYNC_FLAG
6659 spin_lock_init(&dev->bypass_wr_lock);
6660#endif
6661 if (BP10G9_IF_SERIES(dev->subdevice))
6662 dev->bp_10g9 = 1;
6663 if (BP10G_IF_SERIES(dev->subdevice))
6664 dev->bp_10g = 1;
6665 if (PEG540_IF_SERIES(dev->subdevice))
6666 dev->bp_540 = 1;
6667 if (PEGF5_IF_SERIES(dev->subdevice))
6668 dev->bp_fiber5 = 1;
6669 if (PEG80_IF_SERIES(dev->subdevice))
6670 dev->bp_i80 = 1;
6671 if (PEGF80_IF_SERIES(dev->subdevice))
6672 dev->bp_i80 = 1;
6673 if ((dev->subdevice & 0xa00) == 0xa00)
6674 dev->bp_i80 = 1;
6675 if (BP10GB_IF_SERIES(dev->subdevice)) {
6676 if (dev->ifindex == 0) {
6677 unregister_chrdev(major_num, DEVICE_NAME);
6678 printk("Please load network driver for %s adapter!\n",
6679 dev->name);
6680 return -1;
6681 }
6682
6683 if (dev->ndev && !(dev->ndev->flags & IFF_UP)) {
6684 unregister_chrdev(major_num, DEVICE_NAME);
6685 printk("Please bring up network interfaces for %s adapter!\n",
6686 dev->name);
6687 return -1;
6688 }
6689 dev->bp_10gb = 1;
6690 }
6691
6692 if (!dev->bp_10g9) {
6693 if (is_bypass_fn(dev)) {
6694 printk(KERN_INFO "%s found, ",
6695 dev->name);
6696 find_fw(dev);
6697 }
6698 dev->wdt_status = WDT_STATUS_UNKNOWN;
6699 dev->reset_time = 0;
6700 atomic_set(&dev->wdt_busy, 0);
6701 dev->bp_status_un = 1;
6702
6703 bypass_caps_init(dev);
6704
6705 init_bypass_wd_auto(dev);
6706 init_bypass_tpl_auto(dev);
6707 if (NOKIA_SERIES(dev->subdevice))
6708 reset_cont(dev);
6709 }
6710#ifdef BP_SELF_TEST
6711 if ((dev->bp_tx_data = kzalloc(BPTEST_DATA_LEN, GFP_KERNEL))) {
6712 memset(dev->bp_tx_data, 0xff, 6);
6713 memset(dev->bp_tx_data + 6, 0x0, 1);
6714 memset(dev->bp_tx_data + 7, 0xaa, 5);
6715 *(__be16 *)(dev->bp_tx_data + 12) = htons(ETH_P_BPTEST);
6716 } else
6717 printk("bp_ctl: Memory allocation error!\n");
6718#endif
6719 return 0;
6720}
6721
6689/* 6722/*
6690* Initialize the module - Register the character device 6723* Initialize the module - Register the character device
6691*/ 6724*/
@@ -6694,7 +6727,7 @@ static int __init bypass_init_module(void)
6694{ 6727{
6695 int ret_val, idx, idx_dev = 0; 6728 int ret_val, idx, idx_dev = 0;
6696 struct pci_dev *pdev1 = NULL; 6729 struct pci_dev *pdev1 = NULL;
6697 unsigned long mmio_start, mmio_len; 6730 bpctl_dev_t *dev;
6698 6731
6699 printk(BP_MOD_DESCR " v" BP_MOD_VER "\n"); 6732 printk(BP_MOD_DESCR " v" BP_MOD_VER "\n");
6700 ret_val = register_chrdev(major_num, DEVICE_NAME, &Fops); 6733 ret_val = register_chrdev(major_num, DEVICE_NAME, &Fops);
@@ -6729,181 +6762,16 @@ static int __init bypass_init_module(void)
6729 memset(bpctl_dev_arr, 0, ((device_num) * sizeof(bpctl_dev_t))); 6762 memset(bpctl_dev_arr, 0, ((device_num) * sizeof(bpctl_dev_t)));
6730 6763
6731 pdev1 = NULL; 6764 pdev1 = NULL;
6765 dev = bpctl_dev_arr;
6732 for (idx = 0; tx_ctl_pci_tbl[idx].vendor; idx++) { 6766 for (idx = 0; tx_ctl_pci_tbl[idx].vendor; idx++) {
6733 while ((pdev1 = pci_get_subsys(tx_ctl_pci_tbl[idx].vendor, 6767 while ((pdev1 = pci_get_subsys(tx_ctl_pci_tbl[idx].vendor,
6734 tx_ctl_pci_tbl[idx].device, 6768 tx_ctl_pci_tbl[idx].device,
6735 tx_ctl_pci_tbl[idx].subvendor, 6769 tx_ctl_pci_tbl[idx].subvendor,
6736 tx_ctl_pci_tbl[idx].subdevice, 6770 tx_ctl_pci_tbl[idx].subdevice,
6737 pdev1))) { 6771 pdev1))) {
6738 bpctl_dev_arr[idx_dev].pdev = pdev1; 6772 if (init_one(dev, &tx_ctl_pci_tbl[idx], pdev1) < 0)
6739 6773 return -1;
6740 mmio_start = pci_resource_start(pdev1, 0); 6774 dev++;
6741 mmio_len = pci_resource_len(pdev1, 0);
6742
6743 bpctl_dev_arr[idx_dev].desc =
6744 dev_desc[tx_ctl_pci_tbl[idx].index].name;
6745 bpctl_dev_arr[idx_dev].name =
6746 tx_ctl_pci_tbl[idx].bp_name;
6747 bpctl_dev_arr[idx_dev].device =
6748 tx_ctl_pci_tbl[idx].device;
6749 bpctl_dev_arr[idx_dev].vendor =
6750 tx_ctl_pci_tbl[idx].vendor;
6751 bpctl_dev_arr[idx_dev].subdevice =
6752 tx_ctl_pci_tbl[idx].subdevice;
6753 bpctl_dev_arr[idx_dev].subvendor =
6754 tx_ctl_pci_tbl[idx].subvendor;
6755 /* bpctl_dev_arr[idx_dev].pdev=pdev1; */
6756 bpctl_dev_arr[idx_dev].func = PCI_FUNC(pdev1->devfn);
6757 bpctl_dev_arr[idx_dev].slot = PCI_SLOT(pdev1->devfn);
6758 bpctl_dev_arr[idx_dev].bus = pdev1->bus->number;
6759 bpctl_dev_arr[idx_dev].mem_map =
6760 (unsigned long)ioremap(mmio_start, mmio_len);
6761#ifdef BP_SYNC_FLAG
6762 spin_lock_init(&bpctl_dev_arr[idx_dev].bypass_wr_lock);
6763#endif
6764 if (BP10G9_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice))
6765 bpctl_dev_arr[idx_dev].bp_10g9 = 1;
6766 if (BP10G_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice))
6767 bpctl_dev_arr[idx_dev].bp_10g = 1;
6768 if (PEG540_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice)) {
6769
6770 bpctl_dev_arr[idx_dev].bp_540 = 1;
6771 }
6772 if (PEGF5_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice))
6773 bpctl_dev_arr[idx_dev].bp_fiber5 = 1;
6774 if (PEG80_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice))
6775 bpctl_dev_arr[idx_dev].bp_i80 = 1;
6776 if (PEGF80_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice))
6777 bpctl_dev_arr[idx_dev].bp_i80 = 1;
6778 if ((bpctl_dev_arr[idx_dev].subdevice & 0xa00) == 0xa00)
6779 bpctl_dev_arr[idx_dev].bp_i80 = 1;
6780 if (BP10GB_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice)) {
6781 if (bpctl_dev_arr[idx_dev].ifindex == 0) {
6782 unregister_chrdev(major_num,
6783 DEVICE_NAME);
6784 printk
6785 ("Please load network driver for %s adapter!\n",
6786 bpctl_dev_arr[idx_dev].name);
6787 return -1;
6788 }
6789
6790 if (bpctl_dev_arr[idx_dev].ndev) {
6791 if (!
6792 (bpctl_dev_arr[idx_dev].ndev->
6793 flags & IFF_UP)) {
6794 if (!
6795 (bpctl_dev_arr[idx_dev].
6796 ndev->flags & IFF_UP)) {
6797 unregister_chrdev
6798 (major_num,
6799 DEVICE_NAME);
6800 printk
6801 ("Please bring up network interfaces for %s adapter!\n",
6802 bpctl_dev_arr
6803 [idx_dev].name);
6804 return -1;
6805 }
6806
6807 }
6808 }
6809 bpctl_dev_arr[idx_dev].bp_10gb = 1;
6810 }
6811
6812 if (!bpctl_dev_arr[idx_dev].bp_10g9) {
6813
6814 if (is_bypass_fn(&bpctl_dev_arr[idx_dev])) {
6815 printk(KERN_INFO "%s found, ",
6816 bpctl_dev_arr[idx_dev].name);
6817 if ((OLD_IF_SERIES
6818 (bpctl_dev_arr[idx_dev].subdevice))
6819 ||
6820 (INTEL_IF_SERIES
6821 (bpctl_dev_arr[idx_dev].
6822 subdevice)))
6823 bpctl_dev_arr[idx_dev].
6824 bp_fw_ver = 0xff;
6825 else
6826 bpctl_dev_arr[idx_dev].
6827 bp_fw_ver =
6828 bypass_fw_ver(&bpctl_dev_arr
6829 [idx_dev]);
6830 if ((bpctl_dev_arr[idx_dev].bp_10gb ==
6831 1)
6832 && (bpctl_dev_arr[idx_dev].
6833 bp_fw_ver == 0xff)) {
6834 int cnt = 100;
6835 while (cnt--) {
6836 iounmap((void
6837 *)
6838 (bpctl_dev_arr
6839 [idx_dev].
6840 mem_map));
6841 mmio_start =
6842 pci_resource_start
6843 (pdev1, 0);
6844 mmio_len =
6845 pci_resource_len
6846 (pdev1, 0);
6847
6848 bpctl_dev_arr[idx_dev].
6849 mem_map =
6850 (unsigned long)
6851 ioremap(mmio_start,
6852 mmio_len);
6853
6854 bpctl_dev_arr[idx_dev].
6855 bp_fw_ver =
6856 bypass_fw_ver
6857 (&bpctl_dev_arr
6858 [idx_dev]);
6859 if (bpctl_dev_arr
6860 [idx_dev].
6861 bp_fw_ver == 0xa8)
6862 break;
6863
6864 }
6865 }
6866 /* bpctl_dev_arr[idx_dev].bp_fw_ver=0xa8; */
6867 printk("firmware version: 0x%x\n",
6868 bpctl_dev_arr[idx_dev].
6869 bp_fw_ver);
6870 }
6871 bpctl_dev_arr[idx_dev].wdt_status =
6872 WDT_STATUS_UNKNOWN;
6873 bpctl_dev_arr[idx_dev].reset_time = 0;
6874 atomic_set(&bpctl_dev_arr[idx_dev].wdt_busy, 0);
6875 bpctl_dev_arr[idx_dev].bp_status_un = 1;
6876
6877 bypass_caps_init(&bpctl_dev_arr[idx_dev]);
6878
6879 init_bypass_wd_auto(&bpctl_dev_arr[idx_dev]);
6880 init_bypass_tpl_auto(&bpctl_dev_arr[idx_dev]);
6881 if (NOKIA_SERIES
6882 (bpctl_dev_arr[idx_dev].subdevice))
6883 reset_cont(&bpctl_dev_arr[idx_dev]);
6884 }
6885#ifdef BP_SELF_TEST
6886 if ((bpctl_dev_arr[idx_dev].bp_tx_data =
6887 kmalloc(BPTEST_DATA_LEN, GFP_KERNEL))) {
6888
6889 memset(bpctl_dev_arr[idx_dev].bp_tx_data, 0x0,
6890 BPTEST_DATA_LEN);
6891
6892 memset(bpctl_dev_arr[idx_dev].bp_tx_data, 0xff,
6893 6);
6894 memset(bpctl_dev_arr[idx_dev].bp_tx_data + 6,
6895 0x0, 1);
6896 memset(bpctl_dev_arr[idx_dev].bp_tx_data + 7,
6897 0xaa, 5);
6898
6899 *(__be16 *) (bpctl_dev_arr[idx_dev].bp_tx_data +
6900 12) = htons(ETH_P_BPTEST);
6901
6902 } else
6903 printk("bp_ctl: Memory allocation error!\n");
6904#endif
6905 idx_dev++;
6906
6907 } 6775 }
6908 } 6776 }
6909 if_scan_init(); 6777 if_scan_init();
@@ -6913,33 +6781,27 @@ static int __init bypass_init_module(void)
6913 { 6781 {
6914 6782
6915 bpctl_dev_t *pbpctl_dev_c = NULL; 6783 bpctl_dev_t *pbpctl_dev_c = NULL;
6916 for (idx_dev = 0; 6784 for (idx_dev = 0, dev = bpctl_dev_arr;
6917 ((bpctl_dev_arr[idx_dev].pdev != NULL) 6785 idx_dev < device_num && dev->pdev;
6918 && (idx_dev < device_num)); idx_dev++) { 6786 idx_dev++, dev++) {
6919 if (bpctl_dev_arr[idx_dev].bp_10g9) { 6787 if (dev->bp_10g9) {
6920 pbpctl_dev_c = 6788 pbpctl_dev_c = get_status_port_fn(dev);
6921 get_status_port_fn(&bpctl_dev_arr[idx_dev]); 6789 if (is_bypass_fn(dev)) {
6922 if (is_bypass_fn(&bpctl_dev_arr[idx_dev])) {
6923 printk(KERN_INFO "%s found, ", 6790 printk(KERN_INFO "%s found, ",
6924 bpctl_dev_arr[idx_dev].name); 6791 dev->name);
6925 bpctl_dev_arr[idx_dev].bp_fw_ver = 6792 dev->bp_fw_ver = bypass_fw_ver(dev);
6926 bypass_fw_ver(&bpctl_dev_arr
6927 [idx_dev]);
6928 printk("firmware version: 0x%x\n", 6793 printk("firmware version: 0x%x\n",
6929 bpctl_dev_arr[idx_dev]. 6794 dev->bp_fw_ver);
6930 bp_fw_ver);
6931
6932 } 6795 }
6933 bpctl_dev_arr[idx_dev].wdt_status = 6796 dev->wdt_status = WDT_STATUS_UNKNOWN;
6934 WDT_STATUS_UNKNOWN; 6797 dev->reset_time = 0;
6935 bpctl_dev_arr[idx_dev].reset_time = 0; 6798 atomic_set(&dev->wdt_busy, 0);
6936 atomic_set(&bpctl_dev_arr[idx_dev].wdt_busy, 0); 6799 dev->bp_status_un = 1;
6937 bpctl_dev_arr[idx_dev].bp_status_un = 1;
6938 6800
6939 bypass_caps_init(&bpctl_dev_arr[idx_dev]); 6801 bypass_caps_init(dev);
6940 6802
6941 init_bypass_wd_auto(&bpctl_dev_arr[idx_dev]); 6803 init_bypass_wd_auto(dev);
6942 init_bypass_tpl_auto(&bpctl_dev_arr[idx_dev]); 6804 init_bypass_tpl_auto(dev);
6943 6805
6944 } 6806 }
6945 6807
@@ -7336,78 +7198,11 @@ EXPORT_SYMBOL_NOVERS(bp_if_scan_sd);
7336 7198
7337#define BP_PROC_DIR "bypass" 7199#define BP_PROC_DIR "bypass"
7338 7200
7339#define GPIO6_SET_ENTRY_SD "gpio6_set"
7340#define GPIO6_CLEAR_ENTRY_SD "gpio6_clear"
7341
7342#define GPIO7_SET_ENTRY_SD "gpio7_set"
7343#define GPIO7_CLEAR_ENTRY_SD "gpio7_clear"
7344
7345#define PULSE_SET_ENTRY_SD "pulse_set"
7346#define ZERO_SET_ENTRY_SD "zero_set"
7347#define PULSE_GET1_ENTRY_SD "pulse_get1"
7348#define PULSE_GET2_ENTRY_SD "pulse_get2"
7349
7350#define CMND_ON_ENTRY_SD "cmnd_on"
7351#define CMND_OFF_ENTRY_SD "cmnd_off"
7352#define RESET_CONT_ENTRY_SD "reset_cont"
7353
7354 /*COMMANDS*/
7355#define BYPASS_INFO_ENTRY_SD "bypass_info"
7356#define BYPASS_SLAVE_ENTRY_SD "bypass_slave"
7357#define BYPASS_CAPS_ENTRY_SD "bypass_caps"
7358#define WD_SET_CAPS_ENTRY_SD "wd_set_caps"
7359#define BYPASS_ENTRY_SD "bypass"
7360#define BYPASS_CHANGE_ENTRY_SD "bypass_change"
7361#define BYPASS_WD_ENTRY_SD "bypass_wd"
7362#define WD_EXPIRE_TIME_ENTRY_SD "wd_expire_time"
7363#define RESET_BYPASS_WD_ENTRY_SD "reset_bypass_wd"
7364#define DIS_BYPASS_ENTRY_SD "dis_bypass"
7365#define BYPASS_PWUP_ENTRY_SD "bypass_pwup"
7366#define BYPASS_PWOFF_ENTRY_SD "bypass_pwoff"
7367#define STD_NIC_ENTRY_SD "std_nic"
7368#define STD_NIC_ENTRY_SD "std_nic"
7369#define TAP_ENTRY_SD "tap"
7370#define TAP_CHANGE_ENTRY_SD "tap_change"
7371#define DIS_TAP_ENTRY_SD "dis_tap"
7372#define TAP_PWUP_ENTRY_SD "tap_pwup"
7373#define TWO_PORT_LINK_ENTRY_SD "two_port_link"
7374#define WD_EXP_MODE_ENTRY_SD "wd_exp_mode"
7375#define WD_AUTORESET_ENTRY_SD "wd_autoreset"
7376#define TPL_ENTRY_SD "tpl"
7377#define WAIT_AT_PWUP_ENTRY_SD "wait_at_pwup"
7378#define HW_RESET_ENTRY_SD "hw_reset"
7379#define DISC_ENTRY_SD "disc"
7380#define DISC_CHANGE_ENTRY_SD "disc_change"
7381#define DIS_DISC_ENTRY_SD "dis_disc"
7382#define DISC_PWUP_ENTRY_SD "disc_pwup"
7383static struct proc_dir_entry *bp_procfs_dir; 7201static struct proc_dir_entry *bp_procfs_dir;
7384 7202
7385static struct proc_dir_entry *proc_getdir(char *name,
7386 struct proc_dir_entry *proc_dir)
7387{
7388 struct proc_dir_entry *pde = proc_dir;
7389
7390 for (pde = pde->subdir; pde; pde = pde->next) {
7391 if (pde->namelen && (strcmp(name, pde->name) == 0)) {
7392 /* directory exists */
7393 break;
7394 }
7395 }
7396 if (pde == (struct proc_dir_entry *)0) {
7397 /* create the directory */
7398 pde = proc_mkdir(name, proc_dir);
7399 if (pde == (struct proc_dir_entry *)0) {
7400
7401 return pde;
7402 }
7403 }
7404
7405 return pde;
7406}
7407
7408int bp_proc_create(void) 7203int bp_proc_create(void)
7409{ 7204{
7410 bp_procfs_dir = proc_getdir(BP_PROC_DIR, init_net.proc_net); 7205 bp_procfs_dir = proc_mkdir(BP_PROC_DIR, init_net.proc_net);
7411 if (bp_procfs_dir == (struct proc_dir_entry *)0) { 7206 if (bp_procfs_dir == (struct proc_dir_entry *)0) {
7412 printk(KERN_DEBUG 7207 printk(KERN_DEBUG
7413 "Could not create procfs nicinfo directory %s\n", 7208 "Could not create procfs nicinfo directory %s\n",
@@ -7417,144 +7212,99 @@ int bp_proc_create(void)
7417 return 0; 7212 return 0;
7418} 7213}
7419 7214
7420int 7215static int procfs_add(char *proc_name, const struct file_operations *fops,
7421bypass_proc_create_entry_sd(struct pfs_unit_sd *pfs_unit_curr, 7216 bpctl_dev_t *dev)
7422 char *proc_name,
7423 write_proc_t *write_proc,
7424 read_proc_t *read_proc,
7425 struct proc_dir_entry *parent_pfs, void *data)
7426{ 7217{
7427 strcpy(pfs_unit_curr->proc_name, proc_name); 7218 struct bypass_pfs_sd *pfs = &dev->bypass_pfs_set;
7428 pfs_unit_curr->proc_entry = create_proc_entry(pfs_unit_curr->proc_name, 7219 if (!proc_create_data(proc_name, 0644, pfs->bypass_entry, fops, dev))
7429 S_IFREG | S_IRUSR |
7430 S_IWUSR | S_IRGRP |
7431 S_IROTH, parent_pfs);
7432 if (pfs_unit_curr->proc_entry == NULL)
7433 return -1; 7220 return -1;
7434
7435 pfs_unit_curr->proc_entry->read_proc = read_proc;
7436 pfs_unit_curr->proc_entry->write_proc = write_proc;
7437 pfs_unit_curr->proc_entry->data = data;
7438
7439 return 0; 7221 return 0;
7440
7441} 7222}
7442 7223
7443int 7224#define RO_FOPS(name) \
7444get_bypass_info_pfs(char *page, char **start, off_t off, int count, 7225static int name##_open(struct inode *inode, struct file *file) \
7445 int *eof, void *data) 7226{ \
7446{ 7227 return single_open(file, show_##name, PDE_DATA(inode));\
7447 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7228} \
7448 int len = 0; 7229static const struct file_operations name##_ops = { \
7449 7230 .open = name##_open, \
7450 len += sprintf(page, "Name\t\t\t%s\n", pbp_device_block->name); 7231 .read = seq_read, \
7451 len += 7232 .llseek = seq_lseek, \
7452 sprintf(page + len, "Firmware version\t0x%x\n", 7233 .release = single_release, \
7453 pbp_device_block->bp_fw_ver); 7234};
7454 7235
7455 *eof = 1; 7236#define RW_FOPS(name) \
7456 return len; 7237static int name##_open(struct inode *inode, struct file *file) \
7457} 7238{ \
7239 return single_open(file, show_##name, PDE_DATA(inode));\
7240} \
7241static const struct file_operations name##_ops = { \
7242 .open = name##_open, \
7243 .read = seq_read, \
7244 .write = name##_write, \
7245 .llseek = seq_lseek, \
7246 .release = single_release, \
7247};
7458 7248
7459int 7249static int show_bypass_info(struct seq_file *m, void *v)
7460get_bypass_slave_pfs(char *page, char **start, off_t off, int count,
7461 int *eof, void *data)
7462{ 7250{
7463 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7251 bpctl_dev_t *dev = m->private;
7464 7252
7465 int len = 0; 7253 seq_printf(m, "Name\t\t\t%s\n", dev->name);
7466 bpctl_dev_t *pbp_device_block_slave = NULL; 7254 seq_printf(m, "Firmware version\t0x%x\n", dev->bp_fw_ver);
7467 int idx_dev = 0; 7255 return 0;
7468 struct net_device *net_slave_dev = NULL;
7469
7470 if ((pbp_device_block->func == 0) || (pbp_device_block->func == 2)) {
7471 for (idx_dev = 0;
7472 ((bpctl_dev_arr[idx_dev].pdev != NULL)
7473 && (idx_dev < device_num)); idx_dev++) {
7474 if ((bpctl_dev_arr[idx_dev].bus ==
7475 pbp_device_block->bus)
7476 && (bpctl_dev_arr[idx_dev].slot ==
7477 pbp_device_block->slot)) {
7478 if ((pbp_device_block->func == 0)
7479 && (bpctl_dev_arr[idx_dev].func == 1)) {
7480 pbp_device_block_slave =
7481 &bpctl_dev_arr[idx_dev];
7482 break;
7483 }
7484 if ((pbp_device_block->func == 2) &&
7485 (bpctl_dev_arr[idx_dev].func == 3)) {
7486 pbp_device_block_slave =
7487 &bpctl_dev_arr[idx_dev];
7488 break;
7489 }
7490 }
7491 }
7492 } else
7493 pbp_device_block_slave = pbp_device_block;
7494 if (!pbp_device_block_slave) {
7495 len = sprintf(page, "fail\n");
7496 *eof = 1;
7497 return len;
7498 }
7499 net_slave_dev = pbp_device_block_slave->ndev;
7500 if (net_slave_dev)
7501 len = sprintf(page, "%s\n", net_slave_dev->name);
7502
7503 *eof = 1;
7504 return len;
7505} 7256}
7257RO_FOPS(bypass_info)
7506 7258
7507int 7259static int show_bypass_slave(struct seq_file *m, void *v)
7508get_bypass_caps_pfs(char *page, char **start, off_t off, int count,
7509 int *eof, void *data)
7510{ 7260{
7511 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7261 bpctl_dev_t *dev = m->private;
7512 7262 bpctl_dev_t *slave = get_status_port_fn(dev);
7513 int len = 0, ret = 0; 7263 if (!slave)
7264 slave = dev;
7265 if (!slave)
7266 seq_printf(m, "fail\n");
7267 else if (slave->ndev)
7268 seq_printf(m, "%s\n", slave->ndev->name);
7269 return 0;
7270}
7271RO_FOPS(bypass_slave)
7514 7272
7515 ret = get_bypass_caps_fn(pbp_device_block); 7273static int show_bypass_caps(struct seq_file *m, void *v)
7274{
7275 bpctl_dev_t *dev = m->private;
7276 int ret = get_bypass_caps_fn(dev);
7516 if (ret == BP_NOT_CAP) 7277 if (ret == BP_NOT_CAP)
7517 len = sprintf(page, "-1\n"); 7278 seq_printf(m, "-1\n");
7518 else 7279 else
7519 len = sprintf(page, "0x%x\n", ret); 7280 seq_printf(m, "0x%x\n", ret);
7520 *eof = 1; 7281 return 0;
7521 return len;
7522
7523} 7282}
7283RO_FOPS(bypass_caps)
7524 7284
7525int 7285static int show_wd_set_caps(struct seq_file *m, void *v)
7526get_wd_set_caps_pfs(char *page, char **start, off_t off, int count,
7527 int *eof, void *data)
7528{ 7286{
7529 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7287 bpctl_dev_t *dev = m->private;
7530 7288 int ret = get_wd_set_caps_fn(dev);
7531 int len = 0, ret = 0;
7532
7533 ret = get_wd_set_caps_fn(pbp_device_block);
7534 if (ret == BP_NOT_CAP) 7289 if (ret == BP_NOT_CAP)
7535 len = sprintf(page, "-1\n"); 7290 seq_printf(m, "-1\n");
7536 else 7291 else
7537 len = sprintf(page, "0x%x\n", ret); 7292 seq_printf(m, "0x%x\n", ret);
7538 *eof = 1; 7293 return 0;
7539 return len;
7540} 7294}
7295RO_FOPS(wd_set_caps)
7541 7296
7542int 7297static int user_on_off(const void __user *buffer, size_t count)
7543set_bypass_pfs(struct file *file, const char *buffer,
7544 unsigned long count, void *data)
7545{ 7298{
7546 7299
7547 char kbuf[256]; 7300 char kbuf[256];
7548 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7301 int length = 0;
7549
7550 int bypass_param = 0, length = 0;
7551 7302
7552 if (count > (sizeof(kbuf) - 1)) 7303 if (count > (sizeof(kbuf) - 1))
7553 return -1; 7304 return -1;
7554 7305
7555 if (copy_from_user(&kbuf, buffer, count)) { 7306 if (copy_from_user(&kbuf, buffer, count))
7556 return -1; 7307 return -1;
7557 }
7558 7308
7559 kbuf[count] = '\0'; 7309 kbuf[count] = '\0';
7560 length = strlen(kbuf); 7310 length = strlen(kbuf);
@@ -7562,806 +7312,467 @@ set_bypass_pfs(struct file *file, const char *buffer,
7562 kbuf[--length] = '\0'; 7312 kbuf[--length] = '\0';
7563 7313
7564 if (strcmp(kbuf, "on") == 0) 7314 if (strcmp(kbuf, "on") == 0)
7565 bypass_param = 1; 7315 return 1;
7566 else if (strcmp(kbuf, "off") == 0) 7316 if (strcmp(kbuf, "off") == 0)
7567 bypass_param = 0; 7317 return 0;
7568 7318 return 0;
7569 set_bypass_fn(pbp_device_block, bypass_param);
7570
7571 return count;
7572} 7319}
7573 7320
7574int 7321static ssize_t bypass_write(struct file *file, const char __user *buffer,
7575set_tap_pfs(struct file *file, const char *buffer, 7322 size_t count, loff_t *pos)
7576 unsigned long count, void *data)
7577{ 7323{
7578 7324 int bypass_param = user_on_off(buffer, count);
7579 char kbuf[256]; 7325 if (bypass_param < 0)
7580 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
7581
7582 int tap_param = 0, length = 0;
7583
7584 if (count > (sizeof(kbuf) - 1))
7585 return -1; 7326 return -1;
7586 7327
7587 if (copy_from_user(&kbuf, buffer, count)) { 7328 set_bypass_fn(PDE_DATA(file_inode(file)), bypass_param);
7588 return -1;
7589 }
7590
7591 kbuf[count] = '\0';
7592 length = strlen(kbuf);
7593 if (kbuf[length - 1] == '\n')
7594 kbuf[--length] = '\0';
7595
7596 if (strcmp(kbuf, "on") == 0)
7597 tap_param = 1;
7598 else if (strcmp(kbuf, "off") == 0)
7599 tap_param = 0;
7600
7601 set_tap_fn(pbp_device_block, tap_param);
7602
7603 return count; 7329 return count;
7604} 7330}
7605 7331static int show_bypass(struct seq_file *m, void *v)
7606int
7607set_disc_pfs(struct file *file, const char *buffer,
7608 unsigned long count, void *data)
7609{ 7332{
7333 bpctl_dev_t *dev = m->private;
7334 int ret = get_bypass_fn(dev);
7335 if (ret == BP_NOT_CAP)
7336 seq_printf(m, "fail\n");
7337 else if (ret == 1)
7338 seq_printf(m, "on\n");
7339 else if (ret == 0)
7340 seq_printf(m, "off\n");
7341 return 0;
7342}
7343RW_FOPS(bypass)
7610 7344
7611 char kbuf[256]; 7345static ssize_t tap_write(struct file *file, const char __user *buffer,
7612 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7346 size_t count, loff_t *pos)
7613 7347{
7614 int tap_param = 0, length = 0; 7348 int tap_param = user_on_off(buffer, count);
7615 7349 if (tap_param < 0)
7616 if (count > (sizeof(kbuf) - 1))
7617 return -1;
7618
7619 if (copy_from_user(&kbuf, buffer, count)) {
7620 return -1; 7350 return -1;
7621 }
7622
7623 kbuf[count] = '\0';
7624 length = strlen(kbuf);
7625 if (kbuf[length - 1] == '\n')
7626 kbuf[--length] = '\0';
7627
7628 if (strcmp(kbuf, "on") == 0)
7629 tap_param = 1;
7630 else if (strcmp(kbuf, "off") == 0)
7631 tap_param = 0;
7632
7633 set_disc_fn(pbp_device_block, tap_param);
7634 7351
7352 set_tap_fn(PDE_DATA(file_inode(file)), tap_param);
7635 return count; 7353 return count;
7636} 7354}
7637 7355static int show_tap(struct seq_file *m, void *v)
7638int
7639get_bypass_pfs(char *page, char **start, off_t off, int count,
7640 int *eof, void *data)
7641{ 7356{
7642 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7357 bpctl_dev_t *dev = m->private;
7643 7358 int ret = get_tap_fn(dev);
7644 int len = 0, ret = 0;
7645
7646 ret = get_bypass_fn(pbp_device_block);
7647 if (ret == BP_NOT_CAP) 7359 if (ret == BP_NOT_CAP)
7648 len = sprintf(page, "fail\n"); 7360 seq_printf(m, "fail\n");
7649 else if (ret == 1) 7361 else if (ret == 1)
7650 len = sprintf(page, "on\n"); 7362 seq_printf(m, "on\n");
7651 else if (ret == 0) 7363 else if (ret == 0)
7652 len = sprintf(page, "off\n"); 7364 seq_printf(m, "off\n");
7653 7365 return 0;
7654 *eof = 1;
7655 return len;
7656} 7366}
7367RW_FOPS(tap)
7657 7368
7658int 7369static ssize_t disc_write(struct file *file, const char __user *buffer,
7659get_tap_pfs(char *page, char **start, off_t off, int count, 7370 size_t count, loff_t *pos)
7660 int *eof, void *data)
7661{ 7371{
7662 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7372 int tap_param = user_on_off(buffer, count);
7663 7373 if (tap_param < 0)
7664 int len = 0, ret = 0; 7374 return -1;
7665
7666 ret = get_tap_fn(pbp_device_block);
7667 if (ret == BP_NOT_CAP)
7668 len = sprintf(page, "fail\n");
7669 else if (ret == 1)
7670 len = sprintf(page, "on\n");
7671 else if (ret == 0)
7672 len = sprintf(page, "off\n");
7673 7375
7674 *eof = 1; 7376 set_disc_fn(PDE_DATA(file_inode(file)), tap_param);
7675 return len; 7377 return count;
7676} 7378}
7677 7379static int show_disc(struct seq_file *m, void *v)
7678int
7679get_disc_pfs(char *page, char **start, off_t off, int count,
7680 int *eof, void *data)
7681{ 7380{
7682 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7381 bpctl_dev_t *dev = m->private;
7683 7382 int ret = get_disc_fn(dev);
7684 int len = 0, ret = 0;
7685
7686 ret = get_disc_fn(pbp_device_block);
7687 if (ret == BP_NOT_CAP) 7383 if (ret == BP_NOT_CAP)
7688 len = sprintf(page, "fail\n"); 7384 seq_printf(m, "fail\n");
7689 else if (ret == 1) 7385 else if (ret == 1)
7690 len = sprintf(page, "on\n"); 7386 seq_printf(m, "on\n");
7691 else if (ret == 0) 7387 else if (ret == 0)
7692 len = sprintf(page, "off\n"); 7388 seq_printf(m, "off\n");
7693 7389 return 0;
7694 *eof = 1;
7695 return len;
7696} 7390}
7391RW_FOPS(disc)
7697 7392
7698int 7393static int show_bypass_change(struct seq_file *m, void *v)
7699get_bypass_change_pfs(char *page, char **start, off_t off, int count,
7700 int *eof, void *data)
7701{ 7394{
7702 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7395 bpctl_dev_t *dev = m->private;
7703 7396 int ret = get_bypass_change_fn(dev);
7704 int len = 0, ret = 0;
7705
7706 ret = get_bypass_change_fn(pbp_device_block);
7707 if (ret == 1) 7397 if (ret == 1)
7708 len = sprintf(page, "on\n"); 7398 seq_printf(m, "on\n");
7709 else if (ret == 0) 7399 else if (ret == 0)
7710 len = sprintf(page, "off\n"); 7400 seq_printf(m, "off\n");
7711 else 7401 else
7712 len = sprintf(page, "fail\n"); 7402 seq_printf(m, "fail\n");
7713 7403 return 0;
7714 *eof = 1;
7715 return len;
7716} 7404}
7405RO_FOPS(bypass_change)
7717 7406
7718int 7407static int show_tap_change(struct seq_file *m, void *v)
7719get_tap_change_pfs(char *page, char **start, off_t off, int count,
7720 int *eof, void *data)
7721{ 7408{
7722 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7409 bpctl_dev_t *dev = m->private;
7723 7410 int ret = get_tap_change_fn(dev);
7724 int len = 0, ret = 0;
7725
7726 ret = get_tap_change_fn(pbp_device_block);
7727 if (ret == 1) 7411 if (ret == 1)
7728 len = sprintf(page, "on\n"); 7412 seq_printf(m, "on\n");
7729 else if (ret == 0) 7413 else if (ret == 0)
7730 len = sprintf(page, "off\n"); 7414 seq_printf(m, "off\n");
7731 else 7415 else
7732 len = sprintf(page, "fail\n"); 7416 seq_printf(m, "fail\n");
7733 7417 return 0;
7734 *eof = 1;
7735 return len;
7736} 7418}
7419RO_FOPS(tap_change)
7737 7420
7738int 7421static int show_disc_change(struct seq_file *m, void *v)
7739get_disc_change_pfs(char *page, char **start, off_t off, int count,
7740 int *eof, void *data)
7741{ 7422{
7742 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7423 bpctl_dev_t *dev = m->private;
7743 7424 int ret = get_disc_change_fn(dev);
7744 int len = 0, ret = 0;
7745
7746 ret = get_disc_change_fn(pbp_device_block);
7747 if (ret == 1) 7425 if (ret == 1)
7748 len = sprintf(page, "on\n"); 7426 seq_printf(m, "on\n");
7749 else if (ret == 0) 7427 else if (ret == 0)
7750 len = sprintf(page, "off\n"); 7428 seq_printf(m, "off\n");
7751 else 7429 else
7752 len = sprintf(page, "fail\n"); 7430 seq_printf(m, "fail\n");
7753 7431 return 0;
7754 *eof = 1;
7755 return len;
7756}
7757
7758#define isdigit(c) (c >= '0' && c <= '9')
7759__inline static int atoi(char **s)
7760{
7761 int i = 0;
7762 while (isdigit(**s))
7763 i = i * 10 + *((*s)++) - '0';
7764 return i;
7765} 7432}
7433RO_FOPS(disc_change)
7766 7434
7767int 7435static ssize_t bypass_wd_write(struct file *file, const char __user *buffer,
7768set_bypass_wd_pfs(struct file *file, const char *buffer, 7436 size_t count, loff_t *pos)
7769 unsigned long count, void *data)
7770{ 7437{
7771 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7438 bpctl_dev_t *dev = PDE_DATA(file_inode(file));
7772 int timeout; 7439 int timeout;
7773 int ret; 7440 int ret = kstrtoint_from_user(buffer, count, 10, &timeout);
7774
7775 ret = kstrtoint_from_user(buffer, count, 10, &timeout);
7776 if (ret) 7441 if (ret)
7777 return ret; 7442 return ret;
7778 set_bypass_wd_fn(pbp_device_block, timeout); 7443 set_bypass_wd_fn(dev, timeout);
7779
7780 return count; 7444 return count;
7781} 7445}
7782 7446static int show_bypass_wd(struct seq_file *m, void *v)
7783int
7784get_bypass_wd_pfs(char *page, char **start, off_t off, int count,
7785 int *eof, void *data)
7786{ 7447{
7787 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7448 bpctl_dev_t *dev = m->private;
7449 int ret = 0, timeout = 0;
7788 7450
7789 int len = 0, ret = 0, timeout = 0; 7451 ret = get_bypass_wd_fn(dev, &timeout);
7790
7791 ret = get_bypass_wd_fn(pbp_device_block, &timeout);
7792 if (ret == BP_NOT_CAP) 7452 if (ret == BP_NOT_CAP)
7793 len = sprintf(page, "fail\n"); 7453 seq_printf(m, "fail\n");
7794 else if (timeout == -1) 7454 else if (timeout == -1)
7795 len = sprintf(page, "unknown\n"); 7455 seq_printf(m, "unknown\n");
7796 else if (timeout == 0) 7456 else if (timeout == 0)
7797 len = sprintf(page, "disable\n"); 7457 seq_printf(m, "disable\n");
7798 else 7458 else
7799 len = sprintf(page, "%d\n", timeout); 7459 seq_printf(m, "%d\n", timeout);
7800 7460 return 0;
7801 *eof = 1;
7802 return len;
7803} 7461}
7462RW_FOPS(bypass_wd)
7804 7463
7805int 7464static int show_wd_expire_time(struct seq_file *m, void *v)
7806get_wd_expire_time_pfs(char *page, char **start, off_t off, int count,
7807 int *eof, void *data)
7808{ 7465{
7809 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7466 bpctl_dev_t *dev = m->private;
7810 7467 int ret = 0, timeout = 0;
7811 int len = 0, ret = 0, timeout = 0; 7468 ret = get_wd_expire_time_fn(dev, &timeout);
7812
7813 ret = get_wd_expire_time_fn(pbp_device_block, &timeout);
7814 if (ret == BP_NOT_CAP) 7469 if (ret == BP_NOT_CAP)
7815 len = sprintf(page, "fail\n"); 7470 seq_printf(m, "fail\n");
7816 else if (timeout == -1) 7471 else if (timeout == -1)
7817 len = sprintf(page, "expire\n"); 7472 seq_printf(m, "expire\n");
7818 else if (timeout == 0) 7473 else if (timeout == 0)
7819 len = sprintf(page, "disable\n"); 7474 seq_printf(m, "disable\n");
7820
7821 else 7475 else
7822 len = sprintf(page, "%d\n", timeout); 7476 seq_printf(m, "%d\n", timeout);
7823 *eof = 1; 7477 return 0;
7824 return len;
7825} 7478}
7479RO_FOPS(wd_expire_time)
7826 7480
7827int 7481static ssize_t tpl_write(struct file *file, const char __user *buffer,
7828get_tpl_pfs(char *page, char **start, off_t off, int count, 7482 size_t count, loff_t *pos)
7829 int *eof, void *data)
7830{ 7483{
7831 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7484 bpctl_dev_t *dev = PDE_DATA(file_inode(file));
7832 7485 int tpl_param = user_on_off(buffer, count);
7833 int len = 0, ret = 0; 7486 if (tpl_param < 0)
7487 return -1;
7834 7488
7835 ret = get_tpl_fn(pbp_device_block); 7489 set_tpl_fn(dev, tpl_param);
7490 return count;
7491}
7492static int show_tpl(struct seq_file *m, void *v)
7493{
7494 bpctl_dev_t *dev = m->private;
7495 int ret = get_tpl_fn(dev);
7836 if (ret == BP_NOT_CAP) 7496 if (ret == BP_NOT_CAP)
7837 len = sprintf(page, "fail\n"); 7497 seq_printf(m, "fail\n");
7838 else if (ret == 1) 7498 else if (ret == 1)
7839 len = sprintf(page, "on\n"); 7499 seq_printf(m, "on\n");
7840 else if (ret == 0) 7500 else if (ret == 0)
7841 len = sprintf(page, "off\n"); 7501 seq_printf(m, "off\n");
7842 7502 return 0;
7843 *eof = 1;
7844 return len;
7845} 7503}
7504RW_FOPS(tpl)
7846 7505
7847#ifdef PMC_FIX_FLAG 7506#ifdef PMC_FIX_FLAG
7848int 7507static ssize_t wait_at_pwup_write(struct file *file, const char __user *buffer,
7849get_wait_at_pwup_pfs(char *page, char **start, off_t off, int count, 7508 size_t count, loff_t *pos)
7850 int *eof, void *data)
7851{ 7509{
7852 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7510 bpctl_dev_t *dev = PDE_DATA(file_inode(file));
7853 7511 int tpl_param = user_on_off(buffer, count);
7854 int len = 0, ret = 0; 7512 if (tpl_param < 0)
7513 return -1;
7855 7514
7856 ret = get_bp_wait_at_pwup_fn(pbp_device_block); 7515 set_bp_wait_at_pwup_fn(dev, tpl_param);
7516 return count;
7517}
7518static int show_wait_at_pwup(struct seq_file *m, void *v)
7519{
7520 bpctl_dev_t *dev = m->private;
7521 int ret = get_bp_wait_at_pwup_fn(dev);
7857 if (ret == BP_NOT_CAP) 7522 if (ret == BP_NOT_CAP)
7858 len = sprintf(page, "fail\n"); 7523 seq_printf(m, "fail\n");
7859 else if (ret == 1) 7524 else if (ret == 1)
7860 len = sprintf(page, "on\n"); 7525 seq_printf(m, "on\n");
7861 else if (ret == 0) 7526 else if (ret == 0)
7862 len = sprintf(page, "off\n"); 7527 seq_printf(m, "off\n");
7863 7528 return 0;
7864 *eof = 1;
7865 return len;
7866} 7529}
7530RW_FOPS(wait_at_pwup)
7867 7531
7868int 7532static ssize_t hw_reset_write(struct file *file, const char __user *buffer,
7869get_hw_reset_pfs(char *page, char **start, off_t off, int count, 7533 size_t count, loff_t *pos)
7870 int *eof, void *data)
7871{ 7534{
7872 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7535 bpctl_dev_t *dev = PDE_DATA(file_inode(file));
7873 7536 int tpl_param = user_on_off(buffer, count);
7874 int len = 0, ret = 0; 7537 if (tpl_param < 0)
7538 return -1;
7875 7539
7876 ret = get_bp_hw_reset_fn(pbp_device_block); 7540 set_bp_hw_reset_fn(dev, tpl_param);
7541 return count;
7542}
7543static int show_hw_reset(struct seq_file *m, void *v)
7544{
7545 bpctl_dev_t *dev = m->private;
7546 int ret = get_bp_hw_reset_fn(dev);
7877 if (ret == BP_NOT_CAP) 7547 if (ret == BP_NOT_CAP)
7878 len = sprintf(page, "fail\n"); 7548 seq_printf(m, "fail\n");
7879 else if (ret == 1) 7549 else if (ret == 1)
7880 len = sprintf(page, "on\n"); 7550 seq_printf(m, "on\n");
7881 else if (ret == 0) 7551 else if (ret == 0)
7882 len = sprintf(page, "off\n"); 7552 seq_printf(m, "off\n");
7883 7553 return 0;
7884 *eof = 1;
7885 return len;
7886} 7554}
7555RW_FOPS(hw_reset)
7887 7556
7888#endif /*PMC_WAIT_FLAG */ 7557#endif /*PMC_WAIT_FLAG */
7889 7558
7890int 7559static int show_reset_bypass_wd(struct seq_file *m, void *v)
7891reset_bypass_wd_pfs(char *page, char **start, off_t off, int count,
7892 int *eof, void *data)
7893{ 7560{
7894 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7561 bpctl_dev_t *dev = m->private;
7895 7562 int ret = reset_bypass_wd_timer_fn(dev);
7896 int len = 0, ret = 0;
7897
7898 ret = reset_bypass_wd_timer_fn(pbp_device_block);
7899 if (ret == BP_NOT_CAP) 7563 if (ret == BP_NOT_CAP)
7900 len = sprintf(page, "fail\n"); 7564 seq_printf(m, "fail\n");
7901 else if (ret == 0) 7565 else if (ret == 0)
7902 len = sprintf(page, "disable\n"); 7566 seq_printf(m, "disable\n");
7903 else if (ret == 1) 7567 else if (ret == 1)
7904 len = sprintf(page, "success\n"); 7568 seq_printf(m, "success\n");
7905 7569 return 0;
7906 *eof = 1;
7907 return len;
7908} 7570}
7571RO_FOPS(reset_bypass_wd)
7909 7572
7910int 7573static ssize_t dis_bypass_write(struct file *file, const char __user *buffer,
7911set_dis_bypass_pfs(struct file *file, const char *buffer, 7574 size_t count, loff_t *pos)
7912 unsigned long count, void *data)
7913{ 7575{
7914 7576 int bypass_param = user_on_off(buffer, count);
7915 char kbuf[256]; 7577 if (bypass_param < 0)
7916 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
7917
7918 int bypass_param = 0, length = 0;
7919
7920 if (count >= sizeof(kbuf))
7921 return -EINVAL; 7578 return -EINVAL;
7922 7579
7923 if (copy_from_user(&kbuf, buffer, count)) { 7580 set_dis_bypass_fn(PDE_DATA(file_inode(file)), bypass_param);
7924 return -1;
7925 }
7926
7927 kbuf[count] = '\0';
7928 length = strlen(kbuf);
7929 if (kbuf[length - 1] == '\n')
7930 kbuf[--length] = '\0';
7931
7932 if (strcmp(kbuf, "on") == 0)
7933 bypass_param = 1;
7934 else if (strcmp(kbuf, "off") == 0)
7935 bypass_param = 0;
7936
7937 set_dis_bypass_fn(pbp_device_block, bypass_param);
7938
7939 return count; 7581 return count;
7940} 7582}
7941 7583static int show_dis_bypass(struct seq_file *m, void *v)
7942int
7943set_dis_tap_pfs(struct file *file, const char *buffer,
7944 unsigned long count, void *data)
7945{ 7584{
7946 7585 bpctl_dev_t *dev = m->private;
7947 char kbuf[256]; 7586 int ret = get_dis_bypass_fn(dev);
7948 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7587 if (ret == BP_NOT_CAP)
7949 7588 seq_printf(m, "fail\n");
7950 int tap_param = 0, length = 0; 7589 else if (ret == 0)
7951 7590 seq_printf(m, "off\n");
7952 if (count >= sizeof(kbuf)) 7591 else
7953 return -EINVAL; 7592 seq_printf(m, "on\n");
7954 7593 return 0;
7955 if (copy_from_user(&kbuf, buffer, count)) {
7956 return -1;
7957 }
7958
7959 kbuf[count] = '\0';
7960 length = strlen(kbuf);
7961 if (kbuf[length - 1] == '\n')
7962 kbuf[--length] = '\0';
7963
7964 if (strcmp(kbuf, "on") == 0)
7965 tap_param = 1;
7966 else if (strcmp(kbuf, "off") == 0)
7967 tap_param = 0;
7968
7969 set_dis_tap_fn(pbp_device_block, tap_param);
7970
7971 return count;
7972} 7594}
7595RW_FOPS(dis_bypass)
7973 7596
7974int 7597static ssize_t dis_tap_write(struct file *file, const char __user *buffer,
7975set_dis_disc_pfs(struct file *file, const char *buffer, 7598 size_t count, loff_t *pos)
7976 unsigned long count, void *data)
7977{ 7599{
7978 7600 int tap_param = user_on_off(buffer, count);
7979 char kbuf[256]; 7601 if (tap_param < 0)
7980 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
7981
7982 int tap_param = 0, length = 0;
7983
7984 if (count >= sizeof(kbuf))
7985 return -EINVAL; 7602 return -EINVAL;
7986 7603
7987 if (copy_from_user(&kbuf, buffer, count)) { 7604 set_dis_tap_fn(PDE_DATA(file_inode(file)), tap_param);
7988 return -1;
7989 }
7990
7991 kbuf[count] = '\0';
7992 length = strlen(kbuf);
7993 if (kbuf[length - 1] == '\n')
7994 kbuf[--length] = '\0';
7995
7996 if (strcmp(kbuf, "on") == 0)
7997 tap_param = 1;
7998 else if (strcmp(kbuf, "off") == 0)
7999 tap_param = 0;
8000
8001 set_dis_disc_fn(pbp_device_block, tap_param);
8002
8003 return count; 7605 return count;
8004} 7606}
8005 7607static int show_dis_tap(struct seq_file *m, void *v)
8006int
8007get_dis_bypass_pfs(char *page, char **start, off_t off, int count,
8008 int *eof, void *data)
8009{ 7608{
8010 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7609 bpctl_dev_t *dev = m->private;
8011 7610 int ret = get_dis_tap_fn(dev);
8012 int len = 0, ret = 0;
8013
8014 ret = get_dis_bypass_fn(pbp_device_block);
8015 if (ret == BP_NOT_CAP) 7611 if (ret == BP_NOT_CAP)
8016 len = sprintf(page, "fail\n"); 7612 seq_printf(m, "fail\n");
8017 else if (ret == 0) 7613 else if (ret == 0)
8018 len = sprintf(page, "off\n"); 7614 seq_printf(m, "off\n");
8019 else 7615 else
8020 len = sprintf(page, "on\n"); 7616 seq_printf(m, "on\n");
8021 7617 return 0;
8022 *eof = 1;
8023 return len;
8024} 7618}
7619RW_FOPS(dis_tap)
8025 7620
8026int 7621static ssize_t dis_disc_write(struct file *file, const char __user *buffer,
8027get_dis_tap_pfs(char *page, char **start, off_t off, int count, 7622 size_t count, loff_t *pos)
8028 int *eof, void *data)
8029{ 7623{
8030 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7624 int tap_param = user_on_off(buffer, count);
8031 7625 if (tap_param < 0)
8032 int len = 0, ret = 0; 7626 return -EINVAL;
8033
8034 ret = get_dis_tap_fn(pbp_device_block);
8035 if (ret == BP_NOT_CAP)
8036 len = sprintf(page, "fail\n");
8037 else if (ret == 0)
8038 len = sprintf(page, "off\n");
8039 else
8040 len = sprintf(page, "on\n");
8041 7627
8042 *eof = 1; 7628 set_dis_disc_fn(PDE_DATA(file_inode(file)), tap_param);
8043 return len; 7629 return count;
8044} 7630}
8045 7631static int show_dis_disc(struct seq_file *m, void *v)
8046int
8047get_dis_disc_pfs(char *page, char **start, off_t off, int count,
8048 int *eof, void *data)
8049{ 7632{
8050 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7633 bpctl_dev_t *dev = m->private;
8051 7634 int ret = get_dis_disc_fn(dev);
8052 int len = 0, ret = 0;
8053
8054 ret = get_dis_disc_fn(pbp_device_block);
8055 if (ret == BP_NOT_CAP) 7635 if (ret == BP_NOT_CAP)
8056 len = sprintf(page, "fail\n"); 7636 seq_printf(m, "fail\n");
8057 else if (ret == 0) 7637 else if (ret == 0)
8058 len = sprintf(page, "off\n"); 7638 seq_printf(m, "off\n");
8059 else 7639 else
8060 len = sprintf(page, "on\n"); 7640 seq_printf(m, "on\n");
8061 7641 return 0;
8062 *eof = 1;
8063 return len;
8064}
8065
8066int
8067set_bypass_pwup_pfs(struct file *file, const char *buffer,
8068 unsigned long count, void *data)
8069{
8070
8071 char kbuf[256];
8072 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
8073
8074 int bypass_param = 0, length = 0;
8075
8076 if (count >= sizeof(kbuf))
8077 return -EINVAL;
8078
8079 if (copy_from_user(&kbuf, buffer, count)) {
8080 return -1;
8081 }
8082
8083 kbuf[count] = '\0';
8084 length = strlen(kbuf);
8085 if (kbuf[length - 1] == '\n')
8086 kbuf[--length] = '\0';
8087
8088 if (strcmp(kbuf, "on") == 0)
8089 bypass_param = 1;
8090 else if (strcmp(kbuf, "off") == 0)
8091 bypass_param = 0;
8092
8093 set_bypass_pwup_fn(pbp_device_block, bypass_param);
8094
8095 return count;
8096} 7642}
7643RW_FOPS(dis_disc)
8097 7644
8098int 7645static ssize_t bypass_pwup_write(struct file *file, const char __user *buffer,
8099set_bypass_pwoff_pfs(struct file *file, const char *buffer, 7646 size_t count, loff_t *pos)
8100 unsigned long count, void *data)
8101{ 7647{
8102 7648 int bypass_param = user_on_off(buffer, count);
8103 char kbuf[256]; 7649 if (bypass_param < 0)
8104 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
8105
8106 int bypass_param = 0, length = 0;
8107
8108 if (count >= sizeof(kbuf))
8109 return -EINVAL; 7650 return -EINVAL;
8110 7651
8111 if (copy_from_user(&kbuf, buffer, count)) { 7652 set_bypass_pwup_fn(PDE_DATA(file_inode(file)), bypass_param);
8112 return -1;
8113 }
8114
8115 kbuf[count] = '\0';
8116 length = strlen(kbuf);
8117 if (kbuf[length - 1] == '\n')
8118 kbuf[--length] = '\0';
8119
8120 if (strcmp(kbuf, "on") == 0)
8121 bypass_param = 1;
8122 else if (strcmp(kbuf, "off") == 0)
8123 bypass_param = 0;
8124
8125 set_bypass_pwoff_fn(pbp_device_block, bypass_param);
8126
8127 return count; 7653 return count;
8128} 7654}
8129 7655static int show_bypass_pwup(struct seq_file *m, void *v)
8130int
8131set_tap_pwup_pfs(struct file *file, const char *buffer,
8132 unsigned long count, void *data)
8133{ 7656{
8134 7657 bpctl_dev_t *dev = m->private;
8135 char kbuf[256]; 7658 int ret = get_bypass_pwup_fn(dev);
8136 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7659 if (ret == BP_NOT_CAP)
8137 7660 seq_printf(m, "fail\n");
8138 int tap_param = 0, length = 0; 7661 else if (ret == 0)
8139 7662 seq_printf(m, "off\n");
8140 if (count >= sizeof(kbuf)) 7663 else
8141 return -EINVAL; 7664 seq_printf(m, "on\n");
8142 7665 return 0;
8143 if (copy_from_user(&kbuf, buffer, count)) {
8144 return -1;
8145 }
8146
8147 kbuf[count] = '\0';
8148 length = strlen(kbuf);
8149 if (kbuf[length - 1] == '\n')
8150 kbuf[--length] = '\0';
8151
8152 if (strcmp(kbuf, "on") == 0)
8153 tap_param = 1;
8154 else if (strcmp(kbuf, "off") == 0)
8155 tap_param = 0;
8156
8157 set_tap_pwup_fn(pbp_device_block, tap_param);
8158
8159 return count;
8160} 7666}
7667RW_FOPS(bypass_pwup)
8161 7668
8162int 7669static ssize_t bypass_pwoff_write(struct file *file, const char __user *buffer,
8163set_disc_pwup_pfs(struct file *file, const char *buffer, 7670 size_t count, loff_t *pos)
8164 unsigned long count, void *data)
8165{ 7671{
8166 7672 int bypass_param = user_on_off(buffer, count);
8167 char kbuf[256]; 7673 if (bypass_param < 0)
8168 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
8169
8170 int tap_param = 0, length = 0;
8171
8172 if (count >= sizeof(kbuf))
8173 return -EINVAL; 7674 return -EINVAL;
8174 7675
8175 if (copy_from_user(&kbuf, buffer, count)) { 7676 set_bypass_pwoff_fn(PDE_DATA(file_inode(file)), bypass_param);
8176 return -1;
8177 }
8178
8179 kbuf[count] = '\0';
8180 length = strlen(kbuf);
8181 if (kbuf[length - 1] == '\n')
8182 kbuf[--length] = '\0';
8183
8184 if (strcmp(kbuf, "on") == 0)
8185 tap_param = 1;
8186 else if (strcmp(kbuf, "off") == 0)
8187 tap_param = 0;
8188
8189 set_disc_pwup_fn(pbp_device_block, tap_param);
8190
8191 return count; 7677 return count;
8192} 7678}
8193 7679static int show_bypass_pwoff(struct seq_file *m, void *v)
8194int
8195get_bypass_pwup_pfs(char *page, char **start, off_t off, int count,
8196 int *eof, void *data)
8197{ 7680{
8198 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7681 bpctl_dev_t *dev = m->private;
8199 7682 int ret = get_bypass_pwoff_fn(dev);
8200 int len = 0, ret = 0;
8201
8202 ret = get_bypass_pwup_fn(pbp_device_block);
8203 if (ret == BP_NOT_CAP) 7683 if (ret == BP_NOT_CAP)
8204 len = sprintf(page, "fail\n"); 7684 seq_printf(m, "fail\n");
8205 else if (ret == 0) 7685 else if (ret == 0)
8206 len = sprintf(page, "off\n"); 7686 seq_printf(m, "off\n");
8207 else 7687 else
8208 len = sprintf(page, "on\n"); 7688 seq_printf(m, "on\n");
8209 7689 return 0;
8210 *eof = 1;
8211 return len;
8212} 7690}
7691RW_FOPS(bypass_pwoff)
8213 7692
8214int 7693static ssize_t tap_pwup_write(struct file *file, const char __user *buffer,
8215get_bypass_pwoff_pfs(char *page, char **start, off_t off, int count, 7694 size_t count, loff_t *pos)
8216 int *eof, void *data)
8217{ 7695{
8218 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7696 int tap_param = user_on_off(buffer, count);
8219 7697 if (tap_param < 0)
8220 int len = 0, ret = 0; 7698 return -EINVAL;
8221
8222 ret = get_bypass_pwoff_fn(pbp_device_block);
8223 if (ret == BP_NOT_CAP)
8224 len = sprintf(page, "fail\n");
8225 else if (ret == 0)
8226 len = sprintf(page, "off\n");
8227 else
8228 len = sprintf(page, "on\n");
8229 7699
8230 *eof = 1; 7700 set_tap_pwup_fn(PDE_DATA(file_inode(file)), tap_param);
8231 return len; 7701 return count;
8232} 7702}
8233 7703static int show_tap_pwup(struct seq_file *m, void *v)
8234int
8235get_tap_pwup_pfs(char *page, char **start, off_t off, int count,
8236 int *eof, void *data)
8237{ 7704{
8238 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7705 bpctl_dev_t *dev = m->private;
8239 7706 int ret = get_tap_pwup_fn(dev);
8240 int len = 0, ret = 0;
8241
8242 ret = get_tap_pwup_fn(pbp_device_block);
8243 if (ret == BP_NOT_CAP) 7707 if (ret == BP_NOT_CAP)
8244 len = sprintf(page, "fail\n"); 7708 seq_printf(m, "fail\n");
8245 else if (ret == 0) 7709 else if (ret == 0)
8246 len = sprintf(page, "off\n"); 7710 seq_printf(m, "off\n");
8247 else 7711 else
8248 len = sprintf(page, "on\n"); 7712 seq_printf(m, "on\n");
8249 7713 return 0;
8250 *eof = 1;
8251 return len;
8252} 7714}
7715RW_FOPS(tap_pwup)
8253 7716
8254int 7717static ssize_t disc_pwup_write(struct file *file, const char __user *buffer,
8255get_disc_pwup_pfs(char *page, char **start, off_t off, int count, 7718 size_t count, loff_t *pos)
8256 int *eof, void *data)
8257{ 7719{
8258 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7720 int tap_param = user_on_off(buffer, count);
8259 7721 if (tap_param < 0)
8260 int len = 0, ret = 0; 7722 return -EINVAL;
8261 7723
8262 ret = get_disc_pwup_fn(pbp_device_block); 7724 set_disc_pwup_fn(PDE_DATA(file_inode(file)), tap_param);
7725 return count;
7726}
7727static int show_disc_pwup(struct seq_file *m, void *v)
7728{
7729 bpctl_dev_t *dev = m->private;
7730 int ret = get_disc_pwup_fn(dev);
8263 if (ret == BP_NOT_CAP) 7731 if (ret == BP_NOT_CAP)
8264 len = sprintf(page, "fail\n"); 7732 seq_printf(m, "fail\n");
8265 else if (ret == 0) 7733 else if (ret == 0)
8266 len = sprintf(page, "off\n"); 7734 seq_printf(m, "off\n");
8267 else 7735 else
8268 len = sprintf(page, "on\n"); 7736 seq_printf(m, "on\n");
8269 7737 return 0;
8270 *eof = 1;
8271 return len;
8272} 7738}
7739RW_FOPS(disc_pwup)
8273 7740
8274int 7741static ssize_t std_nic_write(struct file *file, const char __user *buffer,
8275set_std_nic_pfs(struct file *file, const char *buffer, 7742 size_t count, loff_t *pos)
8276 unsigned long count, void *data)
8277{ 7743{
8278 7744 int bypass_param = user_on_off(buffer, count);
8279 char kbuf[256]; 7745 if (bypass_param < 0)
8280 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
8281
8282 int bypass_param = 0, length = 0;
8283
8284 if (count >= sizeof(kbuf))
8285 return -EINVAL; 7746 return -EINVAL;
8286 7747
8287 if (copy_from_user(&kbuf, buffer, count)) { 7748 set_std_nic_fn(PDE_DATA(file_inode(file)), bypass_param);
8288 return -1;
8289 }
8290
8291 kbuf[count] = '\0';
8292 length = strlen(kbuf);
8293 if (kbuf[length - 1] == '\n')
8294 kbuf[--length] = '\0';
8295
8296 if (strcmp(kbuf, "on") == 0)
8297 bypass_param = 1;
8298 else if (strcmp(kbuf, "off") == 0)
8299 bypass_param = 0;
8300
8301 set_std_nic_fn(pbp_device_block, bypass_param);
8302
8303 return count; 7749 return count;
8304} 7750}
8305 7751static int show_std_nic(struct seq_file *m, void *v)
8306int
8307get_std_nic_pfs(char *page, char **start, off_t off, int count,
8308 int *eof, void *data)
8309{ 7752{
8310 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7753 bpctl_dev_t *dev = m->private;
8311 7754 int ret = get_std_nic_fn(dev);
8312 int len = 0, ret = 0;
8313
8314 ret = get_std_nic_fn(pbp_device_block);
8315 if (ret == BP_NOT_CAP) 7755 if (ret == BP_NOT_CAP)
8316 len = sprintf(page, "fail\n"); 7756 seq_printf(m, "fail\n");
8317 else if (ret == 0) 7757 else if (ret == 0)
8318 len = sprintf(page, "off\n"); 7758 seq_printf(m, "off\n");
8319 else 7759 else
8320 len = sprintf(page, "on\n"); 7760 seq_printf(m, "on\n");
8321 7761 return 0;
8322 *eof = 1;
8323 return len;
8324}
8325
8326int
8327get_wd_exp_mode_pfs(char *page, char **start, off_t off, int count,
8328 int *eof, void *data)
8329{
8330 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
8331
8332 int len = 0, ret = 0;
8333
8334 ret = get_wd_exp_mode_fn(pbp_device_block);
8335 if (ret == 1)
8336 len = sprintf(page, "tap\n");
8337 else if (ret == 0)
8338 len = sprintf(page, "bypass\n");
8339 else if (ret == 2)
8340 len = sprintf(page, "disc\n");
8341
8342 else
8343 len = sprintf(page, "fail\n");
8344
8345 *eof = 1;
8346 return len;
8347} 7762}
7763RW_FOPS(std_nic)
8348 7764
8349int 7765static ssize_t wd_exp_mode_write(struct file *file, const char __user *buffer,
8350set_wd_exp_mode_pfs(struct file *file, const char *buffer, 7766 size_t count, loff_t *pos)
8351 unsigned long count, void *data)
8352{ 7767{
8353
8354 char kbuf[256]; 7768 char kbuf[256];
8355 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
8356
8357 int bypass_param = 0, length = 0; 7769 int bypass_param = 0, length = 0;
8358 7770
8359 if (count > (sizeof(kbuf) - 1)) 7771 if (count > (sizeof(kbuf) - 1))
8360 return -1; 7772 return -1;
8361 7773
8362 if (copy_from_user(&kbuf, buffer, count)) { 7774 if (copy_from_user(&kbuf, buffer, count))
8363 return -1; 7775 return -1;
8364 }
8365 7776
8366 kbuf[count] = '\0'; 7777 kbuf[count] = '\0';
8367 length = strlen(kbuf); 7778 length = strlen(kbuf);
@@ -8375,143 +7786,47 @@ set_wd_exp_mode_pfs(struct file *file, const char *buffer,
8375 else if (strcmp(kbuf, "disc") == 0) 7786 else if (strcmp(kbuf, "disc") == 0)
8376 bypass_param = 2; 7787 bypass_param = 2;
8377 7788
8378 set_wd_exp_mode_fn(pbp_device_block, bypass_param); 7789 set_wd_exp_mode_fn(PDE_DATA(file_inode(file)), bypass_param);
8379 7790
8380 return count; 7791 return count;
8381} 7792}
8382 7793static int show_wd_exp_mode(struct seq_file *m, void *v)
8383int
8384get_wd_autoreset_pfs(char *page, char **start, off_t off, int count,
8385 int *eof, void *data)
8386{ 7794{
8387 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7795 bpctl_dev_t *dev = m->private;
8388 7796 int ret = get_wd_exp_mode_fn(dev);
8389 int len = 0, ret = 0; 7797 if (ret == 1)
8390 7798 seq_printf(m, "tap\n");
8391 ret = get_wd_autoreset_fn(pbp_device_block); 7799 else if (ret == 0)
8392 if (ret >= 0) 7800 seq_printf(m, "bypass\n");
8393 len = sprintf(page, "%d\n", ret); 7801 else if (ret == 2)
7802 seq_printf(m, "disc\n");
8394 else 7803 else
8395 len = sprintf(page, "fail\n"); 7804 seq_printf(m, "fail\n");
8396 7805 return 0;
8397 *eof = 1;
8398 return len;
8399} 7806}
7807RW_FOPS(wd_exp_mode)
8400 7808
8401int 7809static ssize_t wd_autoreset_write(struct file *file, const char __user *buffer,
8402set_wd_autoreset_pfs(struct file *file, const char *buffer, 7810 size_t count, loff_t *pos)
8403 unsigned long count, void *data)
8404{ 7811{
8405 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
8406 int timeout; 7812 int timeout;
8407 int ret; 7813 int ret = kstrtoint_from_user(buffer, count, 10, &timeout);
8408
8409 ret = kstrtoint_from_user(buffer, count, 10, &timeout);
8410 if (ret) 7814 if (ret)
8411 return ret; 7815 return ret;
8412 set_wd_autoreset_fn(pbp_device_block, timeout); 7816 set_wd_autoreset_fn(PDE_DATA(file_inode(file)), timeout);
8413
8414 return count;
8415}
8416
8417int
8418set_tpl_pfs(struct file *file, const char *buffer,
8419 unsigned long count, void *data)
8420{
8421
8422 char kbuf[256];
8423 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
8424
8425 int tpl_param = 0, length = 0;
8426
8427 if (count > (sizeof(kbuf) - 1))
8428 return -1;
8429
8430 if (copy_from_user(&kbuf, buffer, count)) {
8431 return -1;
8432 }
8433
8434 kbuf[count] = '\0';
8435 length = strlen(kbuf);
8436 if (kbuf[length - 1] == '\n')
8437 kbuf[--length] = '\0';
8438
8439 if (strcmp(kbuf, "on") == 0)
8440 tpl_param = 1;
8441 else if (strcmp(kbuf, "off") == 0)
8442 tpl_param = 0;
8443
8444 set_tpl_fn(pbp_device_block, tpl_param);
8445
8446 return count; 7817 return count;
8447} 7818}
8448 7819static int show_wd_autoreset(struct seq_file *m, void *v)
8449#ifdef PMC_FIX_FLAG
8450int
8451set_wait_at_pwup_pfs(struct file *file, const char *buffer,
8452 unsigned long count, void *data)
8453{
8454
8455 char kbuf[256];
8456 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
8457
8458 int tpl_param = 0, length = 0;
8459
8460 if (count > (sizeof(kbuf) - 1))
8461 return -1;
8462
8463 if (copy_from_user(&kbuf, buffer, count)) {
8464 return -1;
8465 }
8466
8467 kbuf[count] = '\0';
8468 length = strlen(kbuf);
8469 if (kbuf[length - 1] == '\n')
8470 kbuf[--length] = '\0';
8471
8472 if (strcmp(kbuf, "on") == 0)
8473 tpl_param = 1;
8474 else if (strcmp(kbuf, "off") == 0)
8475 tpl_param = 0;
8476
8477 set_bp_wait_at_pwup_fn(pbp_device_block, tpl_param);
8478
8479 return count;
8480}
8481
8482int
8483set_hw_reset_pfs(struct file *file, const char *buffer,
8484 unsigned long count, void *data)
8485{ 7820{
8486 7821 bpctl_dev_t *dev = m->private;
8487 char kbuf[256]; 7822 int ret = get_wd_autoreset_fn(dev);
8488 bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; 7823 if (ret >= 0)
8489 7824 seq_printf(m, "%d\n", ret);
8490 int tpl_param = 0, length = 0; 7825 else
8491 7826 seq_printf(m, "fail\n");
8492 if (count > (sizeof(kbuf) - 1)) 7827 return 0;
8493 return -1;
8494
8495 if (copy_from_user(&kbuf, buffer, count)) {
8496 return -1;
8497 }
8498
8499 kbuf[count] = '\0';
8500 length = strlen(kbuf);
8501 if (kbuf[length - 1] == '\n')
8502 kbuf[--length] = '\0';
8503
8504 if (strcmp(kbuf, "on") == 0)
8505 tpl_param = 1;
8506 else if (strcmp(kbuf, "off") == 0)
8507 tpl_param = 0;
8508
8509 set_bp_hw_reset_fn(pbp_device_block, tpl_param);
8510
8511 return count;
8512} 7828}
8513 7829RW_FOPS(wd_autoreset)
8514#endif /*PMC_FIX_FLAG */
8515 7830
8516int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block) 7831int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block)
8517{ 7832{
@@ -8528,168 +7843,54 @@ int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block)
8528 return -1; 7843 return -1;
8529 7844
8530 /* create device proc dir */ 7845 /* create device proc dir */
8531 procfs_dir = proc_getdir(current_pfs->dir_name, bp_procfs_dir); 7846 procfs_dir = proc_mkdir(current_pfs->dir_name, bp_procfs_dir);
8532 if (procfs_dir == 0) { 7847 if (!procfs_dir) {
8533 printk(KERN_DEBUG "Could not create procfs directory %s\n", 7848 printk(KERN_DEBUG "Could not create procfs directory %s\n",
8534 current_pfs->dir_name); 7849 current_pfs->dir_name);
8535 return -1; 7850 return -1;
8536 } 7851 }
8537 current_pfs->bypass_entry = procfs_dir; 7852 current_pfs->bypass_entry = procfs_dir;
8538 7853
8539 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_info), BYPASS_INFO_ENTRY_SD, NULL, /* write */ 7854#define ENTRY(x) ret |= procfs_add(#x, &x##_ops, pbp_device_block)
8540 get_bypass_info_pfs, /* read */ 7855 ENTRY(bypass_info);
8541 procfs_dir, pbp_device_block))
8542 ret = -1;
8543
8544 if (pbp_device_block->bp_caps & SW_CTL_CAP) { 7856 if (pbp_device_block->bp_caps & SW_CTL_CAP) {
8545
8546 /* Create set param proc's */ 7857 /* Create set param proc's */
8547 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_slave), BYPASS_SLAVE_ENTRY_SD, NULL, /* write */ 7858 ENTRY(bypass_slave);
8548 get_bypass_slave_pfs, /* read */ 7859 ENTRY(bypass_caps);
8549 procfs_dir, pbp_device_block)) 7860 ENTRY(wd_set_caps);
8550 ret = -1; 7861 ENTRY(bypass_wd);
8551 7862 ENTRY(wd_expire_time);
8552 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_caps), BYPASS_CAPS_ENTRY_SD, NULL, /* write */ 7863 ENTRY(reset_bypass_wd);
8553 get_bypass_caps_pfs, /* read */ 7864 ENTRY(std_nic);
8554 procfs_dir, pbp_device_block))
8555 ret = -1;
8556
8557 if (bypass_proc_create_entry_sd(&(current_pfs->wd_set_caps), WD_SET_CAPS_ENTRY_SD, NULL, /* write */
8558 get_wd_set_caps_pfs, /* read */
8559 procfs_dir, pbp_device_block))
8560 ret = -1;
8561 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_wd), BYPASS_WD_ENTRY_SD, set_bypass_wd_pfs, /* write */
8562 get_bypass_wd_pfs, /* read */
8563 procfs_dir, pbp_device_block))
8564 ret = -1;
8565
8566 if (bypass_proc_create_entry_sd(&(current_pfs->wd_expire_time), WD_EXPIRE_TIME_ENTRY_SD, NULL, /* write */
8567 get_wd_expire_time_pfs, /* read */
8568 procfs_dir, pbp_device_block))
8569 ret = -1;
8570
8571 if (bypass_proc_create_entry_sd(&(current_pfs->reset_bypass_wd), RESET_BYPASS_WD_ENTRY_SD, NULL, /* write */
8572 reset_bypass_wd_pfs, /* read */
8573 procfs_dir, pbp_device_block))
8574 ret = -1;
8575
8576 if (bypass_proc_create_entry_sd(&(current_pfs->std_nic), STD_NIC_ENTRY_SD, set_std_nic_pfs, /* write */
8577 get_std_nic_pfs, /* read */
8578 procfs_dir, pbp_device_block))
8579 ret = -1;
8580
8581 if (pbp_device_block->bp_caps & BP_CAP) { 7865 if (pbp_device_block->bp_caps & BP_CAP) {
8582 if (bypass_proc_create_entry_sd(&(current_pfs->bypass), BYPASS_ENTRY_SD, set_bypass_pfs, /* write */ 7866 ENTRY(bypass);
8583 get_bypass_pfs, /* read */ 7867 ENTRY(dis_bypass);
8584 procfs_dir, 7868 ENTRY(bypass_pwup);
8585 pbp_device_block)) 7869 ENTRY(bypass_pwoff);
8586 ret = -1; 7870 ENTRY(bypass_change);
8587
8588 if (bypass_proc_create_entry_sd(&(current_pfs->dis_bypass), DIS_BYPASS_ENTRY_SD, set_dis_bypass_pfs, /* write */
8589 get_dis_bypass_pfs, /* read */
8590 procfs_dir,
8591 pbp_device_block))
8592 ret = -1;
8593
8594 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_pwup), BYPASS_PWUP_ENTRY_SD, set_bypass_pwup_pfs, /* write */
8595 get_bypass_pwup_pfs, /* read */
8596 procfs_dir,
8597 pbp_device_block))
8598 ret = -1;
8599 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_pwoff), BYPASS_PWOFF_ENTRY_SD, set_bypass_pwoff_pfs, /* write */
8600 get_bypass_pwoff_pfs, /* read */
8601 procfs_dir,
8602 pbp_device_block))
8603 ret = -1;
8604
8605 if (bypass_proc_create_entry_sd(&(current_pfs->bypass_change), BYPASS_CHANGE_ENTRY_SD, NULL, /* write */
8606 get_bypass_change_pfs, /* read */
8607 procfs_dir,
8608 pbp_device_block))
8609 ret = -1;
8610 } 7871 }
8611
8612 if (pbp_device_block->bp_caps & TAP_CAP) { 7872 if (pbp_device_block->bp_caps & TAP_CAP) {
8613 7873 ENTRY(tap);
8614 if (bypass_proc_create_entry_sd(&(current_pfs->tap), TAP_ENTRY_SD, set_tap_pfs, /* write */ 7874 ENTRY(dis_tap);
8615 get_tap_pfs, /* read */ 7875 ENTRY(tap_pwup);
8616 procfs_dir, 7876 ENTRY(tap_change);
8617 pbp_device_block))
8618 ret = -1;
8619
8620 if (bypass_proc_create_entry_sd(&(current_pfs->dis_tap), DIS_TAP_ENTRY_SD, set_dis_tap_pfs, /* write */
8621 get_dis_tap_pfs, /* read */
8622 procfs_dir,
8623 pbp_device_block))
8624 ret = -1;
8625
8626 if (bypass_proc_create_entry_sd(&(current_pfs->tap_pwup), TAP_PWUP_ENTRY_SD, set_tap_pwup_pfs, /* write */
8627 get_tap_pwup_pfs, /* read */
8628 procfs_dir,
8629 pbp_device_block))
8630 ret = -1;
8631
8632 if (bypass_proc_create_entry_sd(&(current_pfs->tap_change), TAP_CHANGE_ENTRY_SD, NULL, /* write */
8633 get_tap_change_pfs, /* read */
8634 procfs_dir,
8635 pbp_device_block))
8636 ret = -1;
8637 } 7877 }
8638 if (pbp_device_block->bp_caps & DISC_CAP) { 7878 if (pbp_device_block->bp_caps & DISC_CAP) {
8639 7879 ENTRY(disc);
8640 if (bypass_proc_create_entry_sd(&(current_pfs->tap), DISC_ENTRY_SD, set_disc_pfs, /* write */ 7880 ENTRY(dis_disc);
8641 get_disc_pfs, /* read */ 7881 ENTRY(disc_pwup);
8642 procfs_dir, 7882 ENTRY(disc_change);
8643 pbp_device_block))
8644 ret = -1;
8645#if 1
8646
8647 if (bypass_proc_create_entry_sd(&(current_pfs->dis_tap), DIS_DISC_ENTRY_SD, set_dis_disc_pfs, /* write */
8648 get_dis_disc_pfs, /* read */
8649 procfs_dir,
8650 pbp_device_block))
8651 ret = -1;
8652#endif
8653
8654 if (bypass_proc_create_entry_sd(&(current_pfs->tap_pwup), DISC_PWUP_ENTRY_SD, set_disc_pwup_pfs, /* write */
8655 get_disc_pwup_pfs, /* read */
8656 procfs_dir,
8657 pbp_device_block))
8658 ret = -1;
8659
8660 if (bypass_proc_create_entry_sd(&(current_pfs->tap_change), DISC_CHANGE_ENTRY_SD, NULL, /* write */
8661 get_disc_change_pfs, /* read */
8662 procfs_dir,
8663 pbp_device_block))
8664 ret = -1;
8665 } 7883 }
8666 7884
8667 if (bypass_proc_create_entry_sd(&(current_pfs->wd_exp_mode), WD_EXP_MODE_ENTRY_SD, set_wd_exp_mode_pfs, /* write */ 7885 ENTRY(wd_exp_mode);
8668 get_wd_exp_mode_pfs, /* read */ 7886 ENTRY(wd_autoreset);
8669 procfs_dir, pbp_device_block)) 7887 ENTRY(tpl);
8670 ret = -1;
8671
8672 if (bypass_proc_create_entry_sd(&(current_pfs->wd_autoreset), WD_AUTORESET_ENTRY_SD, set_wd_autoreset_pfs, /* write */
8673 get_wd_autoreset_pfs, /* read */
8674 procfs_dir, pbp_device_block))
8675 ret = -1;
8676 if (bypass_proc_create_entry_sd(&(current_pfs->tpl), TPL_ENTRY_SD, set_tpl_pfs, /* write */
8677 get_tpl_pfs, /* read */
8678 procfs_dir, pbp_device_block))
8679 ret = -1;
8680#ifdef PMC_FIX_FLAG 7888#ifdef PMC_FIX_FLAG
8681 if (bypass_proc_create_entry_sd(&(current_pfs->tpl), WAIT_AT_PWUP_ENTRY_SD, set_wait_at_pwup_pfs, /* write */ 7889 ENTRY(wait_at_pwup);
8682 get_wait_at_pwup_pfs, /* read */ 7890 ENTRY(hw_reset);
8683 procfs_dir, pbp_device_block))
8684 ret = -1;
8685 if (bypass_proc_create_entry_sd(&(current_pfs->tpl), HW_RESET_ENTRY_SD, set_hw_reset_pfs, /* write */
8686 get_hw_reset_pfs, /* read */
8687 procfs_dir, pbp_device_block))
8688 ret = -1;
8689
8690#endif 7891#endif
8691
8692 } 7892 }
7893#undef ENTRY
8693 if (ret < 0) 7894 if (ret < 0)
8694 printk(KERN_DEBUG "Create proc entry failed\n"); 7895 printk(KERN_DEBUG "Create proc entry failed\n");
8695 7896
@@ -8700,21 +7901,7 @@ int bypass_proc_remove_dev_sd(bpctl_dev_t *pbp_device_block)
8700{ 7901{
8701 7902
8702 struct bypass_pfs_sd *current_pfs = &pbp_device_block->bypass_pfs_set; 7903 struct bypass_pfs_sd *current_pfs = &pbp_device_block->bypass_pfs_set;
8703 struct proc_dir_entry *pde = current_pfs->bypass_entry, *pde_curr = 7904 remove_proc_subtree(current_pfs->dir_name, bp_procfs_dir);
8704 NULL;
8705 char name[256];
8706
8707 if (!pde)
8708 return 0;
8709 for (pde = pde->subdir; pde;) {
8710 strcpy(name, pde->name);
8711 pde_curr = pde;
8712 pde = pde->next;
8713 remove_proc_entry(name, current_pfs->bypass_entry);
8714 }
8715 if (!pde)
8716 remove_proc_entry(current_pfs->dir_name, bp_procfs_dir);
8717 current_pfs->bypass_entry = NULL; 7905 current_pfs->bypass_entry = NULL;
8718
8719 return 0; 7906 return 0;
8720} 7907}
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index be4f6c2ca3ff..08b250f01dae 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -60,6 +60,7 @@
60 */ 60 */
61#undef __NO_VERSION__ 61#undef __NO_VERSION__
62 62
63#include <linux/file.h>
63#include "device.h" 64#include "device.h"
64#include "card.h" 65#include "card.h"
65#include "channel.h" 66#include "channel.h"
@@ -2737,83 +2738,50 @@ static int Config_FileGetParameter(unsigned char *string,
2737 return true; 2738 return true;
2738} 2739}
2739 2740
2740int Config_FileOperation(PSDevice pDevice, bool fwrite, unsigned char *Parameter) { 2741int Config_FileOperation(PSDevice pDevice,bool fwrite,unsigned char *Parameter)
2741 unsigned char *config_path = CONFIG_PATH; 2742{
2742 unsigned char *buffer = NULL; 2743 unsigned char *buffer = kmalloc(1024, GFP_KERNEL);
2743 unsigned char tmpbuffer[20]; 2744 unsigned char tmpbuffer[20];
2744 struct file *filp = NULL; 2745 struct file *file;
2745 mm_segment_t old_fs = get_fs(); 2746 int result=0;
2746 //int oldfsuid=0,oldfsgid=0;
2747 int result = 0;
2748
2749 set_fs(KERNEL_DS);
2750
2751 /* Can't do this anymore, so we rely on correct filesystem permissions:
2752 //Make sure a caller can read or write power as root
2753 oldfsuid=current->cred->fsuid;
2754 oldfsgid=current->cred->fsgid;
2755 current->cred->fsuid = 0;
2756 current->cred->fsgid = 0;
2757 */
2758
2759 //open file
2760 filp = filp_open(config_path, O_RDWR, 0);
2761 if (IS_ERR(filp)) {
2762 printk("Config_FileOperation:open file fail?\n");
2763 result = -1;
2764 goto error2;
2765 }
2766 2747
2767 if (!(filp->f_op) || !(filp->f_op->read) || !(filp->f_op->write)) { 2748 if (!buffer) {
2768 printk("file %s cann't readable or writable?\n", config_path);
2769 result = -1;
2770 goto error1;
2771 }
2772
2773 buffer = kmalloc(1024, GFP_KERNEL);
2774 if (buffer == NULL) {
2775 printk("allocate mem for file fail?\n"); 2749 printk("allocate mem for file fail?\n");
2776 result = -1; 2750 return -1;
2777 goto error1; 2751 }
2752 file = filp_open(CONFIG_PATH, O_RDONLY, 0);
2753 if (IS_ERR(file)) {
2754 kfree(buffer);
2755 printk("Config_FileOperation:open file fail?\n");
2756 return -1;
2778 } 2757 }
2779 2758
2780 if (filp->f_op->read(filp, buffer, 1024, &filp->f_pos) < 0) { 2759 if (kernel_read(file, 0, buffer, 1024) < 0) {
2781 printk("read file error?\n"); 2760 printk("read file error?\n");
2782 result = -1; 2761 result = -1;
2783 goto error1; 2762 goto error1;
2784 } 2763 }
2785 2764
2786 if (Config_FileGetParameter("ZONETYPE", tmpbuffer, buffer) != true) { 2765 if (Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer)!=true) {
2787 printk("get parameter error?\n"); 2766 printk("get parameter error?\n");
2788 result = -1; 2767 result = -1;
2789 goto error1; 2768 goto error1;
2790 } 2769 }
2791 2770
2792 if (memcmp(tmpbuffer, "USA", 3) == 0) { 2771 if (memcmp(tmpbuffer,"USA",3)==0) {
2793 result = ZoneType_USA; 2772 result = ZoneType_USA;
2794 } else if (memcmp(tmpbuffer, "JAPAN", 5) == 0) { 2773 } else if(memcmp(tmpbuffer,"JAPAN",5)==0) {
2795 result = ZoneType_Japan; 2774 result = ZoneType_Japan;
2796 } else if (memcmp(tmpbuffer, "EUROPE", 5) == 0) { 2775 } else if(memcmp(tmpbuffer,"EUROPE",5)==0) {
2797 result = ZoneType_Europe; 2776 result = ZoneType_Europe;
2798 } else { 2777 } else {
2799 result = -1; 2778 result = -1;
2800 printk("Unknown Zonetype[%s]?\n", tmpbuffer); 2779 printk("Unknown Zonetype[%s]?\n",tmpbuffer);
2801 } 2780 }
2802 2781
2803error1: 2782error1:
2804 kfree(buffer); 2783 kfree(buffer);
2805 2784 fput(file);
2806 if (filp_close(filp, NULL))
2807 printk("Config_FileOperation:close file fail\n");
2808
2809error2:
2810 set_fs(old_fs);
2811
2812 /*
2813 current->cred->fsuid=oldfsuid;
2814 current->cred->fsgid=oldfsgid;
2815 */
2816
2817 return result; 2785 return result;
2818} 2786}
2819 2787
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 2161af83eaa0..3a3fdc58b6da 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -46,6 +46,7 @@
46 */ 46 */
47#undef __NO_VERSION__ 47#undef __NO_VERSION__
48 48
49#include <linux/file.h>
49#include "device.h" 50#include "device.h"
50#include "card.h" 51#include "card.h"
51#include "baseband.h" 52#include "baseband.h"
@@ -1273,53 +1274,29 @@ static int Config_FileGetParameter(unsigned char *string,
1273/* if read fails, return NULL, or return data pointer */ 1274/* if read fails, return NULL, or return data pointer */
1274static unsigned char *Config_FileOperation(struct vnt_private *pDevice) 1275static unsigned char *Config_FileOperation(struct vnt_private *pDevice)
1275{ 1276{
1276 unsigned char *config_path = CONFIG_PATH; 1277 unsigned char *buffer = kmalloc(1024, GFP_KERNEL);
1277 unsigned char *buffer = NULL; 1278 struct file *file;
1278 struct file *filp=NULL;
1279 mm_segment_t old_fs = get_fs();
1280 1279
1281 int result = 0; 1280 if (!buffer) {
1282 1281 printk("allocate mem for file fail?\n");
1283 set_fs (KERNEL_DS); 1282 return NULL;
1284 1283 }
1285 /* open file */
1286 filp = filp_open(config_path, O_RDWR, 0);
1287 if (IS_ERR(filp)) {
1288 printk("Config_FileOperation file Not exist\n");
1289 result=-1;
1290 goto error2;
1291 }
1292
1293 if(!(filp->f_op) || !(filp->f_op->read) ||!(filp->f_op->write)) {
1294 printk("file %s is not read or writeable?\n",config_path);
1295 result = -1;
1296 goto error1;
1297 }
1298
1299 buffer = kmalloc(1024, GFP_KERNEL);
1300 if(buffer==NULL) {
1301 printk("allocate mem for file fail?\n");
1302 result = -1;
1303 goto error1;
1304 }
1305
1306 if(filp->f_op->read(filp, buffer, 1024, &filp->f_pos)<0) {
1307 printk("read file error?\n");
1308 result = -1;
1309 }
1310 1284
1311error1: 1285 file = filp_open(CONFIG_PATH, O_RDONLY, 0);
1312 if(filp_close(filp,NULL)) 1286 if (IS_ERR(file)) {
1313 printk("Config_FileOperation:close file fail\n"); 1287 kfree(buffer);
1288 printk("Config_FileOperation file Not exist\n");
1289 return NULL;
1290 }
1314 1291
1315error2: 1292 if (kernel_read(file, 0, buffer, 1024) < 0) {
1316 set_fs (old_fs); 1293 printk("read file error?\n");
1294 kfree(buffer);
1295 buffer = NULL;
1296 }
1317 1297
1318if(result!=0) { 1298 fput(file);
1319 kfree(buffer); 1299 return buffer;
1320 buffer=NULL;
1321}
1322 return buffer;
1323} 1300}
1324 1301
1325/* return --->-1:fail; >=0:successful */ 1302/* return --->-1:fail; >=0:successful */
diff --git a/drivers/staging/wlags49_h2/wl_main.c b/drivers/staging/wlags49_h2/wl_main.c
index f5f120a62460..c4264e8c877d 100644
--- a/drivers/staging/wlags49_h2/wl_main.c
+++ b/drivers/staging/wlags49_h2/wl_main.c
@@ -73,6 +73,7 @@
73 73
74#include <linux/module.h> 74#include <linux/module.h>
75#include <linux/proc_fs.h> 75#include <linux/proc_fs.h>
76#include <linux/seq_file.h>
76#include <linux/types.h> 77#include <linux/types.h>
77#include <linux/kernel.h> 78#include <linux/kernel.h>
78// #include <linux/sched.h> 79// #include <linux/sched.h>
@@ -144,10 +145,23 @@
144void wl_isr_handler( unsigned long p ); 145void wl_isr_handler( unsigned long p );
145 146
146#if 0 //SCULL_USE_PROC /* don't waste space if unused */ 147#if 0 //SCULL_USE_PROC /* don't waste space if unused */
147//int scull_read_procmem(char *buf, char **start, off_t offset, int len, int unused); 148static int scull_read_procmem(struct seq_file *m, void *v);
148int scull_read_procmem(char *buf, char **start, off_t offset, int len, int *eof, void *data );
149static int write_int(struct file *file, const char *buffer, unsigned long count, void *data); 149static int write_int(struct file *file, const char *buffer, unsigned long count, void *data);
150static void proc_write(const char *name, write_proc_t *w, void *data); 150
151/*
152 * seq_file wrappers for procfile show routines.
153 */
154static int scull_read_procmem_open(struct inode *inode, struct file *file)
155{
156 return single_open(file, scull_read_procmem, PDE_DATA(inode));
157}
158
159static const struct file_operations scull_read_procmem_fops = {
160 .open = scull_read_procmem_open,
161 .read = seq_read,
162 .llseek = seq_lseek,
163 .release = seq_release,
164};
151 165
152#endif /* SCULL_USE_PROC */ 166#endif /* SCULL_USE_PROC */
153 167
@@ -908,9 +922,8 @@ int wl_insert( struct net_device *dev )
908 } 922 }
909 923
910#if 0 //SCULL_USE_PROC /* don't waste space if unused */ 924#if 0 //SCULL_USE_PROC /* don't waste space if unused */
911 create_proc_read_entry( "wlags", 0, NULL, scull_read_procmem, dev ); 925 proc_create_data( "wlags", 0, NULL, &scull_read_procmem_fops, dev );
912 proc_mkdir("driver/wlags49", 0); 926 proc_mkdir("driver/wlags49", 0);
913 proc_write("driver/wlags49/wlags49_type", write_int, &lp->wlags49_type);
914#endif /* SCULL_USE_PROC */ 927#endif /* SCULL_USE_PROC */
915 928
916 DBG_LEAVE( DbgInfo ); 929 DBG_LEAVE( DbgInfo );
@@ -2097,7 +2110,7 @@ static void __exit wl_module_exit( void )
2097 2110
2098 wl_adapter_cleanup_module( ); 2111 wl_adapter_cleanup_module( );
2099#if 0 //SCULL_USE_PROC /* don't waste space if unused */ 2112#if 0 //SCULL_USE_PROC /* don't waste space if unused */
2100 remove_proc_entry( "wlags", NULL ); //;?why so a-symmetric compared to location of create_proc_read_entry 2113 remove_proc_entry( "wlags", NULL ); //;?why so a-symmetric compared to location of proc_create_data
2101#endif 2114#endif
2102 2115
2103 DBG_LEAVE( DbgInfo ); 2116 DBG_LEAVE( DbgInfo );
@@ -3531,229 +3544,215 @@ void wl_wds_netdev_deregister( struct wl_private *lp )
3531/* 3544/*
3532 * The proc filesystem: function to read and entry 3545 * The proc filesystem: function to read and entry
3533 */ 3546 */
3534int printf_hcf_16( char *s, char *buf, hcf_16* p, int n ); 3547static void printf_hcf_16(struct seq_file *m, const char *s, hcf_16 *p, int n)
3535int printf_hcf_16( char *s, char *buf, hcf_16* p, int n ) { 3548{
3549 int i, len;
3536 3550
3537int i, len; 3551 seq_printf(m, "%-20.20s: ", s);
3552 len = 22;
3538 3553
3539 len = sprintf(buf, "%s", s ); 3554 for (i = 0; i < n; i++) {
3540 while ( len < 20 ) len += sprintf(buf+len, " " ); 3555 if (len % 80 > 75)
3541 len += sprintf(buf+len,": " ); 3556 seq_putc(m, '\n');
3542 for ( i = 0; i < n; i++ ) { 3557 seq_printf(m, "%04X ", p[i]);
3543 if ( len % 80 > 75 ) {
3544 len += sprintf(buf+len,"\n" );
3545 }
3546 len += sprintf(buf+len,"%04X ", p[i] );
3547 } 3558 }
3548 len += sprintf(buf+len,"\n" ); 3559 seq_putc(m, '\n');
3549 return len; 3560}
3550} // printf_hcf_16
3551 3561
3552int printf_hcf_8( char *s, char *buf, hcf_8* p, int n ); 3562static void printf_hcf_8(struct seq_file *m, const char *s, hcf_8 *p, int n)
3553int printf_hcf_8( char *s, char *buf, hcf_8* p, int n ) { 3563{
3564 int i, len;
3554 3565
3555int i, len; 3566 seq_printf(m, "%-20.20s: ", s);
3567 len = 22;
3556 3568
3557 len = sprintf(buf, "%s", s ); 3569 for (i = 0; i <= n; i++) {
3558 while ( len < 20 ) len += sprintf(buf+len, " " ); 3570 if (len % 80 > 77)
3559 len += sprintf(buf+len,": " ); 3571 seq_putc(m, '\n');
3560 for ( i = 0; i <= n; i++ ) { 3572 seq_printf(m, "%02X ", p[i]);
3561 if ( len % 80 > 77 ) {
3562 len += sprintf(buf+len,"\n" );
3563 }
3564 len += sprintf(buf+len,"%02X ", p[i] );
3565 } 3573 }
3566 len += sprintf(buf+len,"\n" ); 3574 seq_putc(m, '\n');
3567 return len; 3575}
3568} // printf_hcf8
3569 3576
3570int printf_strct( char *s, char *buf, hcf_16* p ); 3577static void printf_strct(struct seq_file *m, const char *s, hcf_16 *p)
3571int printf_strct( char *s, char *buf, hcf_16* p ) { 3578{
3579 int i, len;
3572 3580
3573int i, len; 3581 seq_printf(m, "%-20.20s: ", s);
3582 len = 22;
3574 3583
3575 len = sprintf(buf, "%s", s );
3576 while ( len < 20 ) len += sprintf(buf+len, " " );
3577 len += sprintf(buf+len,": " );
3578 for ( i = 0; i <= *p; i++ ) { 3584 for ( i = 0; i <= *p; i++ ) {
3579 if ( len % 80 > 75 ) { 3585 if (len % 80 > 75)
3580 len += sprintf(buf+len,"\n" ); 3586 seq_putc(m, '\n');
3581 } 3587 seq_printf(m,"%04X ", p[i]);
3582 len += sprintf(buf+len,"%04X ", p[i] );
3583 } 3588 }
3584 len += sprintf(buf+len,"\n" ); 3589 seq_putc(m, '\n');
3585 return len; 3590}
3586} // printf_strct
3587 3591
3588int scull_read_procmem(char *buf, char **start, off_t offset, int len, int *eof, void *data ) 3592int scull_read_procmem(struct seq_file *m, void *v)
3589{ 3593{
3590 struct wl_private *lp = NULL; 3594 struct wl_private *lp = m->private;
3591 IFBP ifbp; 3595 IFBP ifbp;
3592 CFG_HERMES_TALLIES_STRCT *p; 3596 CFG_HERMES_TALLIES_STRCT *p;
3593 3597
3594 #define LIMIT (PAGE_SIZE-80) /* don't print any more after this size */
3595
3596 len=0;
3597
3598 lp = ((struct net_device *)data)->priv;
3599 if (lp == NULL) { 3598 if (lp == NULL) {
3600 len += sprintf(buf+len,"No wl_private in scull_read_procmem\n" ); 3599 seq_puts(m, "No wl_private in scull_read_procmem\n" );
3601 } else if ( lp->wlags49_type == 0 ){ 3600 } else if ( lp->wlags49_type == 0 ){
3602 ifbp = &lp->hcfCtx; 3601 ifbp = &lp->hcfCtx;
3603 len += sprintf(buf+len,"Magic: 0x%04X\n", ifbp->IFB_Magic ); 3602 seq_printf(m, "Magic: 0x%04X\n", ifbp->IFB_Magic );
3604 len += sprintf(buf+len,"IOBase: 0x%04X\n", ifbp->IFB_IOBase ); 3603 seq_printf(m, "IOBase: 0x%04X\n", ifbp->IFB_IOBase );
3605 len += sprintf(buf+len,"LinkStat: 0x%04X\n", ifbp->IFB_LinkStat ); 3604 seq_printf(m, "LinkStat: 0x%04X\n", ifbp->IFB_LinkStat );
3606 len += sprintf(buf+len,"DSLinkStat: 0x%04X\n", ifbp->IFB_DSLinkStat ); 3605 seq_printf(m, "DSLinkStat: 0x%04X\n", ifbp->IFB_DSLinkStat );
3607 len += sprintf(buf+len,"TickIni: 0x%08lX\n", ifbp->IFB_TickIni ); 3606 seq_printf(m, "TickIni: 0x%08lX\n", ifbp->IFB_TickIni );
3608 len += sprintf(buf+len,"TickCnt: 0x%04X\n", ifbp->IFB_TickCnt ); 3607 seq_printf(m, "TickCnt: 0x%04X\n", ifbp->IFB_TickCnt );
3609 len += sprintf(buf+len,"IntOffCnt: 0x%04X\n", ifbp->IFB_IntOffCnt ); 3608 seq_printf(m, "IntOffCnt: 0x%04X\n", ifbp->IFB_IntOffCnt );
3610 len += printf_hcf_16( "IFB_FWIdentity", &buf[len], 3609 printf_hcf_16(m, "IFB_FWIdentity",
3611 &ifbp->IFB_FWIdentity.len, ifbp->IFB_FWIdentity.len + 1 ); 3610 &ifbp->IFB_FWIdentity.len, ifbp->IFB_FWIdentity.len + 1 );
3612 } else if ( lp->wlags49_type == 1 ) { 3611 } else if ( lp->wlags49_type == 1 ) {
3613 len += sprintf(buf+len,"Channel: 0x%04X\n", lp->Channel ); 3612 seq_printf(m, "Channel: 0x%04X\n", lp->Channel );
3614/****** len += sprintf(buf+len,"slock: %d\n", lp->slock ); */ 3613/****** seq_printf(m, "slock: %d\n", lp->slock ); */
3615//x struct tq_struct "task: 0x%04X\n", lp->task ); 3614//x struct tq_struct "task: 0x%04X\n", lp->task );
3616//x struct net_device_stats "stats: 0x%04X\n", lp->stats ); 3615//x struct net_device_stats "stats: 0x%04X\n", lp->stats );
3617#ifdef WIRELESS_EXT 3616#ifdef WIRELESS_EXT
3618//x struct iw_statistics "wstats: 0x%04X\n", lp->wstats ); 3617//x struct iw_statistics "wstats: 0x%04X\n", lp->wstats );
3619//x len += sprintf(buf+len,"spy_number: 0x%04X\n", lp->spy_number ); 3618//x seq_printf(m, "spy_number: 0x%04X\n", lp->spy_number );
3620//x u_char spy_address[IW_MAX_SPY][ETH_ALEN]; 3619//x u_char spy_address[IW_MAX_SPY][ETH_ALEN];
3621//x struct iw_quality spy_stat[IW_MAX_SPY]; 3620//x struct iw_quality spy_stat[IW_MAX_SPY];
3622#endif // WIRELESS_EXT 3621#endif // WIRELESS_EXT
3623 len += sprintf(buf+len,"IFB: 0x%p\n", &lp->hcfCtx ); 3622 seq_printf(m, "IFB: 0x%p\n", &lp->hcfCtx );
3624 len += sprintf(buf+len,"flags: %#.8lX\n", lp->flags ); //;?use this format from now on 3623 seq_printf(m, "flags: %#.8lX\n", lp->flags ); //;?use this format from now on
3625 len += sprintf(buf+len,"DebugFlag(wl_private) 0x%04X\n", lp->DebugFlag ); 3624 seq_printf(m, "DebugFlag(wl_private) 0x%04X\n", lp->DebugFlag );
3626#if DBG 3625#if DBG
3627 len += sprintf(buf+len,"DebugFlag (DbgInfo): 0x%08lX\n", DbgInfo->DebugFlag ); 3626 seq_printf(m, "DebugFlag (DbgInfo): 0x%08lX\n", DbgInfo->DebugFlag );
3628#endif // DBG 3627#endif // DBG
3629 len += sprintf(buf+len,"is_registered: 0x%04X\n", lp->is_registered ); 3628 seq_printf(m, "is_registered: 0x%04X\n", lp->is_registered );
3630//x CFG_DRV_INFO_STRCT "driverInfo: 0x%04X\n", lp->driverInfo ); 3629//x CFG_DRV_INFO_STRCT "driverInfo: 0x%04X\n", lp->driverInfo );
3631 len += printf_strct( "driverInfo", &buf[len], (hcf_16*)&lp->driverInfo ); 3630 printf_strct( m, "driverInfo", (hcf_16*)&lp->driverInfo );
3632//x CFG_IDENTITY_STRCT "driverIdentity: 0x%04X\n", lp->driverIdentity ); 3631//x CFG_IDENTITY_STRCT "driverIdentity: 0x%04X\n", lp->driverIdentity );
3633 len += printf_strct( "driverIdentity", &buf[len], (hcf_16*)&lp->driverIdentity ); 3632 printf_strct( m, "driverIdentity", (hcf_16*)&lp->driverIdentity );
3634//x CFG_FW_IDENTITY_STRCT "StationIdentity: 0x%04X\n", lp->StationIdentity ); 3633//x CFG_FW_IDENTITY_STRCT "StationIdentity: 0x%04X\n", lp->StationIdentity );
3635 len += printf_strct( "StationIdentity", &buf[len], (hcf_16*)&lp->StationIdentity ); 3634 printf_strct( m, "StationIdentity", (hcf_16*)&lp->StationIdentity );
3636//x CFG_PRI_IDENTITY_STRCT "PrimaryIdentity: 0x%04X\n", lp->PrimaryIdentity ); 3635//x CFG_PRI_IDENTITY_STRCT "PrimaryIdentity: 0x%04X\n", lp->PrimaryIdentity );
3637 len += printf_strct( "PrimaryIdentity", &buf[len], (hcf_16*)&lp->hcfCtx.IFB_PRIIdentity ); 3636 printf_strct( m, "PrimaryIdentity", (hcf_16*)&lp->hcfCtx.IFB_PRIIdentity );
3638 len += printf_strct( "PrimarySupplier", &buf[len], (hcf_16*)&lp->hcfCtx.IFB_PRISup ); 3637 printf_strct( m, "PrimarySupplier", (hcf_16*)&lp->hcfCtx.IFB_PRISup );
3639//x CFG_PRI_IDENTITY_STRCT "NICIdentity: 0x%04X\n", lp->NICIdentity ); 3638//x CFG_PRI_IDENTITY_STRCT "NICIdentity: 0x%04X\n", lp->NICIdentity );
3640 len += printf_strct( "NICIdentity", &buf[len], (hcf_16*)&lp->NICIdentity ); 3639 printf_strct( m, "NICIdentity", (hcf_16*)&lp->NICIdentity );
3641//x ltv_t "ltvRecord: 0x%04X\n", lp->ltvRecord ); 3640//x ltv_t "ltvRecord: 0x%04X\n", lp->ltvRecord );
3642 len += sprintf(buf+len,"txBytes: 0x%08lX\n", lp->txBytes ); 3641 seq_printf(m, "txBytes: 0x%08lX\n", lp->txBytes );
3643 len += sprintf(buf+len,"maxPort: 0x%04X\n", lp->maxPort ); /* 0 for STA, 6 for AP */ 3642 seq_printf(m, "maxPort: 0x%04X\n", lp->maxPort ); /* 0 for STA, 6 for AP */
3644 /* Elements used for async notification from hardware */ 3643 /* Elements used for async notification from hardware */
3645//x RID_LOG_STRCT RidList[10]; 3644//x RID_LOG_STRCT RidList[10];
3646//x ltv_t "updatedRecord: 0x%04X\n", lp->updatedRecord ); 3645//x ltv_t "updatedRecord: 0x%04X\n", lp->updatedRecord );
3647//x PROBE_RESP "ProbeResp: 0x%04X\n", lp->ProbeResp ); 3646//x PROBE_RESP "ProbeResp: 0x%04X\n", lp->ProbeResp );
3648//x ASSOC_STATUS_STRCT "assoc_stat: 0x%04X\n", lp->assoc_stat ); 3647//x ASSOC_STATUS_STRCT "assoc_stat: 0x%04X\n", lp->assoc_stat );
3649//x SECURITY_STATUS_STRCT "sec_stat: 0x%04X\n", lp->sec_stat ); 3648//x SECURITY_STATUS_STRCT "sec_stat: 0x%04X\n", lp->sec_stat );
3650//x u_char lookAheadBuf[WVLAN_MAX_LOOKAHEAD]; 3649//x u_char lookAheadBuf[WVLAN_MAX_LOOKAHEAD];
3651 len += sprintf(buf+len,"PortType: 0x%04X\n", lp->PortType ); // 1 - 3 (1 [Normal] | 3 [AdHoc]) 3650 seq_printf(m, "PortType: 0x%04X\n", lp->PortType ); // 1 - 3 (1 [Normal] | 3 [AdHoc])
3652 len += sprintf(buf+len,"Channel: 0x%04X\n", lp->Channel ); // 0 - 14 (0) 3651 seq_printf(m, "Channel: 0x%04X\n", lp->Channel ); // 0 - 14 (0)
3653//x hcf_16 TxRateControl[2]; 3652//x hcf_16 TxRateControl[2];
3654 len += sprintf(buf+len,"TxRateControl[2]: 0x%04X 0x%04X\n", 3653 seq_printf(m, "TxRateControl[2]: 0x%04X 0x%04X\n",
3655 lp->TxRateControl[0], lp->TxRateControl[1] ); 3654 lp->TxRateControl[0], lp->TxRateControl[1] );
3656 len += sprintf(buf+len,"DistanceBetweenAPs: 0x%04X\n", lp->DistanceBetweenAPs ); // 1 - 3 (1) 3655 seq_printf(m, "DistanceBetweenAPs: 0x%04X\n", lp->DistanceBetweenAPs ); // 1 - 3 (1)
3657 len += sprintf(buf+len,"RTSThreshold: 0x%04X\n", lp->RTSThreshold ); // 0 - 2347 (2347) 3656 seq_printf(m, "RTSThreshold: 0x%04X\n", lp->RTSThreshold ); // 0 - 2347 (2347)
3658 len += sprintf(buf+len,"PMEnabled: 0x%04X\n", lp->PMEnabled ); // 0 - 2, 8001 - 8002 (0) 3657 seq_printf(m, "PMEnabled: 0x%04X\n", lp->PMEnabled ); // 0 - 2, 8001 - 8002 (0)
3659 len += sprintf(buf+len,"MicrowaveRobustness: 0x%04X\n", lp->MicrowaveRobustness );// 0 - 1 (0) 3658 seq_printf(m, "MicrowaveRobustness: 0x%04X\n", lp->MicrowaveRobustness );// 0 - 1 (0)
3660 len += sprintf(buf+len,"CreateIBSS: 0x%04X\n", lp->CreateIBSS ); // 0 - 1 (0) 3659 seq_printf(m, "CreateIBSS: 0x%04X\n", lp->CreateIBSS ); // 0 - 1 (0)
3661 len += sprintf(buf+len,"MulticastReceive: 0x%04X\n", lp->MulticastReceive ); // 0 - 1 (1) 3660 seq_printf(m, "MulticastReceive: 0x%04X\n", lp->MulticastReceive ); // 0 - 1 (1)
3662 len += sprintf(buf+len,"MaxSleepDuration: 0x%04X\n", lp->MaxSleepDuration ); // 0 - 65535 (100) 3661 seq_printf(m, "MaxSleepDuration: 0x%04X\n", lp->MaxSleepDuration ); // 0 - 65535 (100)
3663//x hcf_8 MACAddress[ETH_ALEN]; 3662//x hcf_8 MACAddress[ETH_ALEN];
3664 len += printf_hcf_8( "MACAddress", &buf[len], lp->MACAddress, ETH_ALEN ); 3663 printf_hcf_8(m, "MACAddress", lp->MACAddress, ETH_ALEN );
3665//x char NetworkName[HCF_MAX_NAME_LEN+1]; 3664//x char NetworkName[HCF_MAX_NAME_LEN+1];
3666 len += sprintf(buf+len,"NetworkName: %.32s\n", lp->NetworkName ); 3665 seq_printf(m, "NetworkName: %.32s\n", lp->NetworkName );
3667//x char StationName[HCF_MAX_NAME_LEN+1]; 3666//x char StationName[HCF_MAX_NAME_LEN+1];
3668 len += sprintf(buf+len,"EnableEncryption: 0x%04X\n", lp->EnableEncryption ); // 0 - 1 (0) 3667 seq_printf(m, "EnableEncryption: 0x%04X\n", lp->EnableEncryption ); // 0 - 1 (0)
3669//x char Key1[MAX_KEY_LEN+1]; 3668//x char Key1[MAX_KEY_LEN+1];
3670 len += printf_hcf_8( "Key1", &buf[len], lp->Key1, MAX_KEY_LEN ); 3669 printf_hcf_8( m, "Key1", lp->Key1, MAX_KEY_LEN );
3671//x char Key2[MAX_KEY_LEN+1]; 3670//x char Key2[MAX_KEY_LEN+1];
3672//x char Key3[MAX_KEY_LEN+1]; 3671//x char Key3[MAX_KEY_LEN+1];
3673//x char Key4[MAX_KEY_LEN+1]; 3672//x char Key4[MAX_KEY_LEN+1];
3674 len += sprintf(buf+len,"TransmitKeyID: 0x%04X\n", lp->TransmitKeyID ); // 1 - 4 (1) 3673 seq_printf(m, "TransmitKeyID: 0x%04X\n", lp->TransmitKeyID ); // 1 - 4 (1)
3675//x CFG_DEFAULT_KEYS_STRCT "DefaultKeys: 0x%04X\n", lp->DefaultKeys ); 3674//x CFG_DEFAULT_KEYS_STRCT "DefaultKeys: 0x%04X\n", lp->DefaultKeys );
3676//x u_char mailbox[MB_SIZE]; 3675//x u_char mailbox[MB_SIZE];
3677//x char szEncryption[MAX_ENC_LEN]; 3676//x char szEncryption[MAX_ENC_LEN];
3678 len += sprintf(buf+len,"driverEnable: 0x%04X\n", lp->driverEnable ); 3677 seq_printf(m, "driverEnable: 0x%04X\n", lp->driverEnable );
3679 len += sprintf(buf+len,"wolasEnable: 0x%04X\n", lp->wolasEnable ); 3678 seq_printf(m, "wolasEnable: 0x%04X\n", lp->wolasEnable );
3680 len += sprintf(buf+len,"atimWindow: 0x%04X\n", lp->atimWindow ); 3679 seq_printf(m, "atimWindow: 0x%04X\n", lp->atimWindow );
3681 len += sprintf(buf+len,"holdoverDuration: 0x%04X\n", lp->holdoverDuration ); 3680 seq_printf(m, "holdoverDuration: 0x%04X\n", lp->holdoverDuration );
3682//x hcf_16 MulticastRate[2]; 3681//x hcf_16 MulticastRate[2];
3683 len += sprintf(buf+len,"authentication: 0x%04X\n", lp->authentication ); // is this AP specific? 3682 seq_printf(m, "authentication: 0x%04X\n", lp->authentication ); // is this AP specific?
3684 len += sprintf(buf+len,"promiscuousMode: 0x%04X\n", lp->promiscuousMode ); 3683 seq_printf(m, "promiscuousMode: 0x%04X\n", lp->promiscuousMode );
3685 len += sprintf(buf+len,"DownloadFirmware: 0x%04X\n", lp->DownloadFirmware ); // 0 - 2 (0 [None] | 1 [STA] | 2 [AP]) 3684 seq_printf(m, "DownloadFirmware: 0x%04X\n", lp->DownloadFirmware ); // 0 - 2 (0 [None] | 1 [STA] | 2 [AP])
3686 len += sprintf(buf+len,"AuthKeyMgmtSuite: 0x%04X\n", lp->AuthKeyMgmtSuite ); 3685 seq_printf(m, "AuthKeyMgmtSuite: 0x%04X\n", lp->AuthKeyMgmtSuite );
3687 len += sprintf(buf+len,"loadBalancing: 0x%04X\n", lp->loadBalancing ); 3686 seq_printf(m, "loadBalancing: 0x%04X\n", lp->loadBalancing );
3688 len += sprintf(buf+len,"mediumDistribution: 0x%04X\n", lp->mediumDistribution ); 3687 seq_printf(m, "mediumDistribution: 0x%04X\n", lp->mediumDistribution );
3689 len += sprintf(buf+len,"txPowLevel: 0x%04X\n", lp->txPowLevel ); 3688 seq_printf(m, "txPowLevel: 0x%04X\n", lp->txPowLevel );
3690// len += sprintf(buf+len,"shortRetryLimit: 0x%04X\n", lp->shortRetryLimit ); 3689// seq_printf(m, "shortRetryLimit: 0x%04X\n", lp->shortRetryLimit );
3691// len += sprintf(buf+len,"longRetryLimit: 0x%04X\n", lp->longRetryLimit ); 3690// seq_printf(m, "longRetryLimit: 0x%04X\n", lp->longRetryLimit );
3692//x hcf_16 srsc[2]; 3691//x hcf_16 srsc[2];
3693//x hcf_16 brsc[2]; 3692//x hcf_16 brsc[2];
3694 len += sprintf(buf+len,"connectionControl: 0x%04X\n", lp->connectionControl ); 3693 seq_printf(m, "connectionControl: 0x%04X\n", lp->connectionControl );
3695//x //hcf_16 probeDataRates[2]; 3694//x //hcf_16 probeDataRates[2];
3696 len += sprintf(buf+len,"ownBeaconInterval: 0x%04X\n", lp->ownBeaconInterval ); 3695 seq_printf(m, "ownBeaconInterval: 0x%04X\n", lp->ownBeaconInterval );
3697 len += sprintf(buf+len,"coexistence: 0x%04X\n", lp->coexistence ); 3696 seq_printf(m, "coexistence: 0x%04X\n", lp->coexistence );
3698//x WVLAN_FRAME "txF: 0x%04X\n", lp->txF ); 3697//x WVLAN_FRAME "txF: 0x%04X\n", lp->txF );
3699//x WVLAN_LFRAME txList[DEFAULT_NUM_TX_FRAMES]; 3698//x WVLAN_LFRAME txList[DEFAULT_NUM_TX_FRAMES];
3700//x struct list_head "txFree: 0x%04X\n", lp->txFree ); 3699//x struct list_head "txFree: 0x%04X\n", lp->txFree );
3701//x struct list_head txQ[WVLAN_MAX_TX_QUEUES]; 3700//x struct list_head txQ[WVLAN_MAX_TX_QUEUES];
3702 len += sprintf(buf+len,"netif_queue_on: 0x%04X\n", lp->netif_queue_on ); 3701 seq_printf(m, "netif_queue_on: 0x%04X\n", lp->netif_queue_on );
3703 len += sprintf(buf+len,"txQ_count: 0x%04X\n", lp->txQ_count ); 3702 seq_printf(m, "txQ_count: 0x%04X\n", lp->txQ_count );
3704//x DESC_STRCT "desc_rx: 0x%04X\n", lp->desc_rx ); 3703//x DESC_STRCT "desc_rx: 0x%04X\n", lp->desc_rx );
3705//x DESC_STRCT "desc_tx: 0x%04X\n", lp->desc_tx ); 3704//x DESC_STRCT "desc_tx: 0x%04X\n", lp->desc_tx );
3706//x WVLAN_PORT_STATE "portState: 0x%04X\n", lp->portState ); 3705//x WVLAN_PORT_STATE "portState: 0x%04X\n", lp->portState );
3707//x ScanResult "scan_results: 0x%04X\n", lp->scan_results ); 3706//x ScanResult "scan_results: 0x%04X\n", lp->scan_results );
3708//x ProbeResult "probe_results: 0x%04X\n", lp->probe_results ); 3707//x ProbeResult "probe_results: 0x%04X\n", lp->probe_results );
3709 len += sprintf(buf+len,"probe_num_aps: 0x%04X\n", lp->probe_num_aps ); 3708 seq_printf(m, "probe_num_aps: 0x%04X\n", lp->probe_num_aps );
3710 len += sprintf(buf+len,"use_dma: 0x%04X\n", lp->use_dma ); 3709 seq_printf(m, "use_dma: 0x%04X\n", lp->use_dma );
3711//x DMA_STRCT "dma: 0x%04X\n", lp->dma ); 3710//x DMA_STRCT "dma: 0x%04X\n", lp->dma );
3712#ifdef USE_RTS 3711#ifdef USE_RTS
3713 len += sprintf(buf+len,"useRTS: 0x%04X\n", lp->useRTS ); 3712 seq_printf(m, "useRTS: 0x%04X\n", lp->useRTS );
3714#endif // USE_RTS 3713#endif // USE_RTS
3715#if 1 //;? (HCF_TYPE) & HCF_TYPE_AP 3714#if 1 //;? (HCF_TYPE) & HCF_TYPE_AP
3716 //;?should we restore this to allow smaller memory footprint 3715 //;?should we restore this to allow smaller memory footprint
3717 //;?I guess not. This should be brought under Debug mode only 3716 //;?I guess not. This should be brought under Debug mode only
3718 len += sprintf(buf+len,"DTIMPeriod: 0x%04X\n", lp->DTIMPeriod ); // 1 - 255 (1) 3717 seq_printf(m, "DTIMPeriod: 0x%04X\n", lp->DTIMPeriod ); // 1 - 255 (1)
3719 len += sprintf(buf+len,"multicastPMBuffering: 0x%04X\n", lp->multicastPMBuffering ); 3718 seq_printf(m, "multicastPMBuffering: 0x%04X\n", lp->multicastPMBuffering );
3720 len += sprintf(buf+len,"RejectAny: 0x%04X\n", lp->RejectAny ); // 0 - 1 (0) 3719 seq_printf(m, "RejectAny: 0x%04X\n", lp->RejectAny ); // 0 - 1 (0)
3721 len += sprintf(buf+len,"ExcludeUnencrypted: 0x%04X\n", lp->ExcludeUnencrypted ); // 0 - 1 (1) 3720 seq_printf(m, "ExcludeUnencrypted: 0x%04X\n", lp->ExcludeUnencrypted ); // 0 - 1 (1)
3722 len += sprintf(buf+len,"intraBSSRelay: 0x%04X\n", lp->intraBSSRelay ); 3721 seq_printf(m, "intraBSSRelay: 0x%04X\n", lp->intraBSSRelay );
3723 len += sprintf(buf+len,"wlags49_type: 0x%08lX\n", lp->wlags49_type ); 3722 seq_printf(m, "wlags49_type: 0x%08lX\n", lp->wlags49_type );
3724#ifdef USE_WDS 3723#ifdef USE_WDS
3725//x WVLAN_WDS_IF wds_port[NUM_WDS_PORTS]; 3724//x WVLAN_WDS_IF wds_port[NUM_WDS_PORTS];
3726#endif // USE_WDS 3725#endif // USE_WDS
3727#endif // HCF_AP 3726#endif // HCF_AP
3728 } else if ( lp->wlags49_type == 2 ){ 3727 } else if ( lp->wlags49_type == 2 ){
3729 len += sprintf(buf+len,"tallies to be added\n" ); 3728 seq_printf(m, "tallies to be added\n" );
3730//Hermes Tallies (IFB substructure) { 3729//Hermes Tallies (IFB substructure) {
3731 p = &lp->hcfCtx.IFB_NIC_Tallies; 3730 p = &lp->hcfCtx.IFB_NIC_Tallies;
3732 len += sprintf(buf+len,"TxUnicastFrames: %08lX\n", p->TxUnicastFrames ); 3731 seq_printf(m, "TxUnicastFrames: %08lX\n", p->TxUnicastFrames );
3733 len += sprintf(buf+len,"TxMulticastFrames: %08lX\n", p->TxMulticastFrames ); 3732 seq_printf(m, "TxMulticastFrames: %08lX\n", p->TxMulticastFrames );
3734 len += sprintf(buf+len,"TxFragments: %08lX\n", p->TxFragments ); 3733 seq_printf(m, "TxFragments: %08lX\n", p->TxFragments );
3735 len += sprintf(buf+len,"TxUnicastOctets: %08lX\n", p->TxUnicastOctets ); 3734 seq_printf(m, "TxUnicastOctets: %08lX\n", p->TxUnicastOctets );
3736 len += sprintf(buf+len,"TxMulticastOctets: %08lX\n", p->TxMulticastOctets ); 3735 seq_printf(m, "TxMulticastOctets: %08lX\n", p->TxMulticastOctets );
3737 len += sprintf(buf+len,"TxDeferredTransmissions: %08lX\n", p->TxDeferredTransmissions ); 3736 seq_printf(m, "TxDeferredTransmissions: %08lX\n", p->TxDeferredTransmissions );
3738 len += sprintf(buf+len,"TxSingleRetryFrames: %08lX\n", p->TxSingleRetryFrames ); 3737 seq_printf(m, "TxSingleRetryFrames: %08lX\n", p->TxSingleRetryFrames );
3739 len += sprintf(buf+len,"TxMultipleRetryFrames: %08lX\n", p->TxMultipleRetryFrames ); 3738 seq_printf(m, "TxMultipleRetryFrames: %08lX\n", p->TxMultipleRetryFrames );
3740 len += sprintf(buf+len,"TxRetryLimitExceeded: %08lX\n", p->TxRetryLimitExceeded ); 3739 seq_printf(m, "TxRetryLimitExceeded: %08lX\n", p->TxRetryLimitExceeded );
3741 len += sprintf(buf+len,"TxDiscards: %08lX\n", p->TxDiscards ); 3740 seq_printf(m, "TxDiscards: %08lX\n", p->TxDiscards );
3742 len += sprintf(buf+len,"RxUnicastFrames: %08lX\n", p->RxUnicastFrames ); 3741 seq_printf(m, "RxUnicastFrames: %08lX\n", p->RxUnicastFrames );
3743 len += sprintf(buf+len,"RxMulticastFrames: %08lX\n", p->RxMulticastFrames ); 3742 seq_printf(m, "RxMulticastFrames: %08lX\n", p->RxMulticastFrames );
3744 len += sprintf(buf+len,"RxFragments: %08lX\n", p->RxFragments ); 3743 seq_printf(m, "RxFragments: %08lX\n", p->RxFragments );
3745 len += sprintf(buf+len,"RxUnicastOctets: %08lX\n", p->RxUnicastOctets ); 3744 seq_printf(m, "RxUnicastOctets: %08lX\n", p->RxUnicastOctets );
3746 len += sprintf(buf+len,"RxMulticastOctets: %08lX\n", p->RxMulticastOctets ); 3745 seq_printf(m, "RxMulticastOctets: %08lX\n", p->RxMulticastOctets );
3747 len += sprintf(buf+len,"RxFCSErrors: %08lX\n", p->RxFCSErrors ); 3746 seq_printf(m, "RxFCSErrors: %08lX\n", p->RxFCSErrors );
3748 len += sprintf(buf+len,"RxDiscardsNoBuffer: %08lX\n", p->RxDiscardsNoBuffer ); 3747 seq_printf(m, "RxDiscardsNoBuffer: %08lX\n", p->RxDiscardsNoBuffer );
3749 len += sprintf(buf+len,"TxDiscardsWrongSA: %08lX\n", p->TxDiscardsWrongSA ); 3748 seq_printf(m, "TxDiscardsWrongSA: %08lX\n", p->TxDiscardsWrongSA );
3750 len += sprintf(buf+len,"RxWEPUndecryptable: %08lX\n", p->RxWEPUndecryptable ); 3749 seq_printf(m, "RxWEPUndecryptable: %08lX\n", p->RxWEPUndecryptable );
3751 len += sprintf(buf+len,"RxMsgInMsgFragments: %08lX\n", p->RxMsgInMsgFragments ); 3750 seq_printf(m, "RxMsgInMsgFragments: %08lX\n", p->RxMsgInMsgFragments );
3752 len += sprintf(buf+len,"RxMsgInBadMsgFragments: %08lX\n", p->RxMsgInBadMsgFragments ); 3751 seq_printf(m, "RxMsgInBadMsgFragments: %08lX\n", p->RxMsgInBadMsgFragments );
3753 len += sprintf(buf+len,"RxDiscardsWEPICVError: %08lX\n", p->RxDiscardsWEPICVError ); 3752 seq_printf(m, "RxDiscardsWEPICVError: %08lX\n", p->RxDiscardsWEPICVError );
3754 len += sprintf(buf+len,"RxDiscardsWEPExcluded: %08lX\n", p->RxDiscardsWEPExcluded ); 3753 seq_printf(m, "RxDiscardsWEPExcluded: %08lX\n", p->RxDiscardsWEPExcluded );
3755#if (HCF_EXT) & HCF_EXT_TALLIES_FW 3754#if (HCF_EXT) & HCF_EXT_TALLIES_FW
3756 //to be added ;? 3755 //to be added ;?
3757#endif // HCF_EXT_TALLIES_FW 3756#endif // HCF_EXT_TALLIES_FW
3758 } else if ( lp->wlags49_type & 0x8000 ) { //;?kludgy but it is unclear to me were else to place this 3757 } else if ( lp->wlags49_type & 0x8000 ) { //;?kludgy but it is unclear to me were else to place this
3759#if DBG 3758#if DBG
@@ -3761,27 +3760,19 @@ int scull_read_procmem(char *buf, char **start, off_t offset, int len, int *eof,
3761#endif // DBG 3760#endif // DBG
3762 lp->wlags49_type = 0; //default to IFB again ;? 3761 lp->wlags49_type = 0; //default to IFB again ;?
3763 } else { 3762 } else {
3764 len += sprintf(buf+len,"unknown value for wlags49_type: 0x%08lX\n", lp->wlags49_type ); 3763 seq_printf(m, "unknown value for wlags49_type: 0x%08lX\n", lp->wlags49_type );
3765 len += sprintf(buf+len,"0x0000 - IFB\n" ); 3764 seq_puts(m,
3766 len += sprintf(buf+len,"0x0001 - wl_private\n" ); 3765 "0x0000 - IFB\n"
3767 len += sprintf(buf+len,"0x0002 - Tallies\n" ); 3766 "0x0001 - wl_private\n"
3768 len += sprintf(buf+len,"0x8xxx - Change debufflag\n" ); 3767 "0x0002 - Tallies\n"
3769 len += sprintf(buf+len,"ERROR 0001\nWARNING 0002\nNOTICE 0004\nTRACE 0008\n" ); 3768 "0x8xxx - Change debufflag\n"
3770 len += sprintf(buf+len,"VERBOSE 0010\nPARAM 0020\nBREAK 0040\nRX 0100\n" ); 3769 "ERROR 0001\nWARNING 0002\nNOTICE 0004\nTRACE 0008\n"
3771 len += sprintf(buf+len,"TX 0200\nDS 0400\n" ); 3770 "VERBOSE 0010\nPARAM 0020\nBREAK 0040\nRX 0100\n"
3772 } 3771 "TX 0200\nDS 0400\n");
3773 return len; 3772 }
3773 return 0;
3774} // scull_read_procmem 3774} // scull_read_procmem
3775 3775
3776static void proc_write(const char *name, write_proc_t *w, void *data)
3777{
3778 struct proc_dir_entry * entry = create_proc_entry(name, S_IFREG | S_IWUSR, NULL);
3779 if (entry) {
3780 entry->write_proc = w;
3781 entry->data = data;
3782 }
3783} // proc_write
3784
3785static int write_int(struct file *file, const char *buffer, unsigned long count, void *data) 3776static int write_int(struct file *file, const char *buffer, unsigned long count, void *data)
3786{ 3777{
3787 static char proc_number[11]; 3778 static char proc_number[11];
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 2d444b1ccd33..7c908141cc8a 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -79,11 +79,10 @@ static void tcm_loop_release_cmd(struct se_cmd *se_cmd)
79 kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); 79 kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
80} 80}
81 81
82static int tcm_loop_proc_info(struct Scsi_Host *host, char *buffer, 82static int tcm_loop_show_info(struct seq_file *m, struct Scsi_Host *host)
83 char **start, off_t offset,
84 int length, int inout)
85{ 83{
86 return sprintf(buffer, "tcm_loop_proc_info()\n"); 84 seq_printf(m, "tcm_loop_proc_info()\n");
85 return 0;
87} 86}
88 87
89static int tcm_loop_driver_probe(struct device *); 88static int tcm_loop_driver_probe(struct device *);
@@ -336,7 +335,7 @@ static int tcm_loop_slave_configure(struct scsi_device *sd)
336} 335}
337 336
338static struct scsi_host_template tcm_loop_driver_template = { 337static struct scsi_host_template tcm_loop_driver_template = {
339 .proc_info = tcm_loop_proc_info, 338 .show_info = tcm_loop_show_info,
340 .proc_name = "tcm_loopback", 339 .proc_name = "tcm_loopback",
341 .name = "TCM_Loopback", 340 .name = "TCM_Loopback",
342 .queuecommand = tcm_loop_queuecommand, 341 .queuecommand = tcm_loop_queuecommand,
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 8fbb6d22cdc8..f87dbfd32770 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1711,7 +1711,7 @@ static int uart_proc_show(struct seq_file *m, void *v)
1711 1711
1712static int uart_proc_open(struct inode *inode, struct file *file) 1712static int uart_proc_open(struct inode *inode, struct file *file)
1713{ 1713{
1714 return single_open(file, uart_proc_show, PDE(inode)->data); 1714 return single_open(file, uart_proc_show, PDE_DATA(inode));
1715} 1715}
1716 1716
1717static const struct file_operations uart_proc_fops = { 1717static const struct file_operations uart_proc_fops = {
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index a690d64217f4..073b938f9135 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -221,7 +221,7 @@ static int proc_udc_show(struct seq_file *s, void *unused)
221 221
222static int proc_udc_open(struct inode *inode, struct file *file) 222static int proc_udc_open(struct inode *inode, struct file *file)
223{ 223{
224 return single_open(file, proc_udc_show, PDE(inode)->data); 224 return single_open(file, proc_udc_show, PDE_DATA(inode));
225} 225}
226 226
227static const struct file_operations proc_ops = { 227static const struct file_operations proc_ops = {
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index c377ff84bf2c..f394f295d63d 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -727,7 +727,6 @@ static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value)
727} 727}
728 728
729static const struct file_operations ffs_ep0_operations = { 729static const struct file_operations ffs_ep0_operations = {
730 .owner = THIS_MODULE,
731 .llseek = no_llseek, 730 .llseek = no_llseek,
732 731
733 .open = ffs_ep0_open, 732 .open = ffs_ep0_open,
@@ -947,7 +946,6 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code,
947} 946}
948 947
949static const struct file_operations ffs_epfile_operations = { 948static const struct file_operations ffs_epfile_operations = {
950 .owner = THIS_MODULE,
951 .llseek = no_llseek, 949 .llseek = no_llseek,
952 950
953 .open = ffs_epfile_open, 951 .open = ffs_epfile_open,
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 7c2a101d19ac..2d8c1cfea699 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -2010,47 +2010,37 @@ static int fsl_udc_stop(struct usb_gadget *g,
2010 2010
2011static const char proc_filename[] = "driver/fsl_usb2_udc"; 2011static const char proc_filename[] = "driver/fsl_usb2_udc";
2012 2012
2013static int fsl_proc_read(char *page, char **start, off_t off, int count, 2013static int fsl_proc_read(struct seq_file *m, void *v)
2014 int *eof, void *_dev)
2015{ 2014{
2016 char *buf = page;
2017 char *next = buf;
2018 unsigned size = count;
2019 unsigned long flags; 2015 unsigned long flags;
2020 int t, i; 2016 int i;
2021 u32 tmp_reg; 2017 u32 tmp_reg;
2022 struct fsl_ep *ep = NULL; 2018 struct fsl_ep *ep = NULL;
2023 struct fsl_req *req; 2019 struct fsl_req *req;
2024 2020
2025 struct fsl_udc *udc = udc_controller; 2021 struct fsl_udc *udc = udc_controller;
2026 if (off != 0)
2027 return 0;
2028 2022
2029 spin_lock_irqsave(&udc->lock, flags); 2023 spin_lock_irqsave(&udc->lock, flags);
2030 2024
2031 /* ------basic driver information ---- */ 2025 /* ------basic driver information ---- */
2032 t = scnprintf(next, size, 2026 seq_printf(m,
2033 DRIVER_DESC "\n" 2027 DRIVER_DESC "\n"
2034 "%s version: %s\n" 2028 "%s version: %s\n"
2035 "Gadget driver: %s\n\n", 2029 "Gadget driver: %s\n\n",
2036 driver_name, DRIVER_VERSION, 2030 driver_name, DRIVER_VERSION,
2037 udc->driver ? udc->driver->driver.name : "(none)"); 2031 udc->driver ? udc->driver->driver.name : "(none)");
2038 size -= t;
2039 next += t;
2040 2032
2041 /* ------ DR Registers ----- */ 2033 /* ------ DR Registers ----- */
2042 tmp_reg = fsl_readl(&dr_regs->usbcmd); 2034 tmp_reg = fsl_readl(&dr_regs->usbcmd);
2043 t = scnprintf(next, size, 2035 seq_printf(m,
2044 "USBCMD reg:\n" 2036 "USBCMD reg:\n"
2045 "SetupTW: %d\n" 2037 "SetupTW: %d\n"
2046 "Run/Stop: %s\n\n", 2038 "Run/Stop: %s\n\n",
2047 (tmp_reg & USB_CMD_SUTW) ? 1 : 0, 2039 (tmp_reg & USB_CMD_SUTW) ? 1 : 0,
2048 (tmp_reg & USB_CMD_RUN_STOP) ? "Run" : "Stop"); 2040 (tmp_reg & USB_CMD_RUN_STOP) ? "Run" : "Stop");
2049 size -= t;
2050 next += t;
2051 2041
2052 tmp_reg = fsl_readl(&dr_regs->usbsts); 2042 tmp_reg = fsl_readl(&dr_regs->usbsts);
2053 t = scnprintf(next, size, 2043 seq_printf(m,
2054 "USB Status Reg:\n" 2044 "USB Status Reg:\n"
2055 "Dr Suspend: %d Reset Received: %d System Error: %s " 2045 "Dr Suspend: %d Reset Received: %d System Error: %s "
2056 "USB Error Interrupt: %s\n\n", 2046 "USB Error Interrupt: %s\n\n",
@@ -2058,11 +2048,9 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count,
2058 (tmp_reg & USB_STS_RESET) ? 1 : 0, 2048 (tmp_reg & USB_STS_RESET) ? 1 : 0,
2059 (tmp_reg & USB_STS_SYS_ERR) ? "Err" : "Normal", 2049 (tmp_reg & USB_STS_SYS_ERR) ? "Err" : "Normal",
2060 (tmp_reg & USB_STS_ERR) ? "Err detected" : "No err"); 2050 (tmp_reg & USB_STS_ERR) ? "Err detected" : "No err");
2061 size -= t;
2062 next += t;
2063 2051
2064 tmp_reg = fsl_readl(&dr_regs->usbintr); 2052 tmp_reg = fsl_readl(&dr_regs->usbintr);
2065 t = scnprintf(next, size, 2053 seq_printf(m,
2066 "USB Interrupt Enable Reg:\n" 2054 "USB Interrupt Enable Reg:\n"
2067 "Sleep Enable: %d SOF Received Enable: %d " 2055 "Sleep Enable: %d SOF Received Enable: %d "
2068 "Reset Enable: %d\n" 2056 "Reset Enable: %d\n"
@@ -2076,33 +2064,25 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count,
2076 (tmp_reg & USB_INTR_PTC_DETECT_EN) ? 1 : 0, 2064 (tmp_reg & USB_INTR_PTC_DETECT_EN) ? 1 : 0,
2077 (tmp_reg & USB_INTR_ERR_INT_EN) ? 1 : 0, 2065 (tmp_reg & USB_INTR_ERR_INT_EN) ? 1 : 0,
2078 (tmp_reg & USB_INTR_INT_EN) ? 1 : 0); 2066 (tmp_reg & USB_INTR_INT_EN) ? 1 : 0);
2079 size -= t;
2080 next += t;
2081 2067
2082 tmp_reg = fsl_readl(&dr_regs->frindex); 2068 tmp_reg = fsl_readl(&dr_regs->frindex);
2083 t = scnprintf(next, size, 2069 seq_printf(m,
2084 "USB Frame Index Reg: Frame Number is 0x%x\n\n", 2070 "USB Frame Index Reg: Frame Number is 0x%x\n\n",
2085 (tmp_reg & USB_FRINDEX_MASKS)); 2071 (tmp_reg & USB_FRINDEX_MASKS));
2086 size -= t;
2087 next += t;
2088 2072
2089 tmp_reg = fsl_readl(&dr_regs->deviceaddr); 2073 tmp_reg = fsl_readl(&dr_regs->deviceaddr);
2090 t = scnprintf(next, size, 2074 seq_printf(m,
2091 "USB Device Address Reg: Device Addr is 0x%x\n\n", 2075 "USB Device Address Reg: Device Addr is 0x%x\n\n",
2092 (tmp_reg & USB_DEVICE_ADDRESS_MASK)); 2076 (tmp_reg & USB_DEVICE_ADDRESS_MASK));
2093 size -= t;
2094 next += t;
2095 2077
2096 tmp_reg = fsl_readl(&dr_regs->endpointlistaddr); 2078 tmp_reg = fsl_readl(&dr_regs->endpointlistaddr);
2097 t = scnprintf(next, size, 2079 seq_printf(m,
2098 "USB Endpoint List Address Reg: " 2080 "USB Endpoint List Address Reg: "
2099 "Device Addr is 0x%x\n\n", 2081 "Device Addr is 0x%x\n\n",
2100 (tmp_reg & USB_EP_LIST_ADDRESS_MASK)); 2082 (tmp_reg & USB_EP_LIST_ADDRESS_MASK));
2101 size -= t;
2102 next += t;
2103 2083
2104 tmp_reg = fsl_readl(&dr_regs->portsc1); 2084 tmp_reg = fsl_readl(&dr_regs->portsc1);
2105 t = scnprintf(next, size, 2085 seq_printf(m,
2106 "USB Port Status&Control Reg:\n" 2086 "USB Port Status&Control Reg:\n"
2107 "Port Transceiver Type : %s Port Speed: %s\n" 2087 "Port Transceiver Type : %s Port Speed: %s\n"
2108 "PHY Low Power Suspend: %s Port Reset: %s " 2088 "PHY Low Power Suspend: %s Port Reset: %s "
@@ -2111,7 +2091,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count,
2111 "Port Enable/Disable Change: %s\n" 2091 "Port Enable/Disable Change: %s\n"
2112 "Port Enabled/Disabled: %s " 2092 "Port Enabled/Disabled: %s "
2113 "Current Connect Status: %s\n\n", ( { 2093 "Current Connect Status: %s\n\n", ( {
2114 char *s; 2094 const char *s;
2115 switch (tmp_reg & PORTSCX_PTS_FSLS) { 2095 switch (tmp_reg & PORTSCX_PTS_FSLS) {
2116 case PORTSCX_PTS_UTMI: 2096 case PORTSCX_PTS_UTMI:
2117 s = "UTMI"; break; 2097 s = "UTMI"; break;
@@ -2137,13 +2117,11 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count,
2137 "Not correct", 2117 "Not correct",
2138 (tmp_reg & PORTSCX_CURRENT_CONNECT_STATUS) ? 2118 (tmp_reg & PORTSCX_CURRENT_CONNECT_STATUS) ?
2139 "Attached" : "Not-Att"); 2119 "Attached" : "Not-Att");
2140 size -= t;
2141 next += t;
2142 2120
2143 tmp_reg = fsl_readl(&dr_regs->usbmode); 2121 tmp_reg = fsl_readl(&dr_regs->usbmode);
2144 t = scnprintf(next, size, 2122 seq_printf(m,
2145 "USB Mode Reg: Controller Mode is: %s\n\n", ( { 2123 "USB Mode Reg: Controller Mode is: %s\n\n", ( {
2146 char *s; 2124 const char *s;
2147 switch (tmp_reg & USB_MODE_CTRL_MODE_HOST) { 2125 switch (tmp_reg & USB_MODE_CTRL_MODE_HOST) {
2148 case USB_MODE_CTRL_MODE_IDLE: 2126 case USB_MODE_CTRL_MODE_IDLE:
2149 s = "Idle"; break; 2127 s = "Idle"; break;
@@ -2156,103 +2134,87 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count,
2156 } 2134 }
2157 s; 2135 s;
2158 } )); 2136 } ));
2159 size -= t;
2160 next += t;
2161 2137
2162 tmp_reg = fsl_readl(&dr_regs->endptsetupstat); 2138 tmp_reg = fsl_readl(&dr_regs->endptsetupstat);
2163 t = scnprintf(next, size, 2139 seq_printf(m,
2164 "Endpoint Setup Status Reg: SETUP on ep 0x%x\n\n", 2140 "Endpoint Setup Status Reg: SETUP on ep 0x%x\n\n",
2165 (tmp_reg & EP_SETUP_STATUS_MASK)); 2141 (tmp_reg & EP_SETUP_STATUS_MASK));
2166 size -= t;
2167 next += t;
2168 2142
2169 for (i = 0; i < udc->max_ep / 2; i++) { 2143 for (i = 0; i < udc->max_ep / 2; i++) {
2170 tmp_reg = fsl_readl(&dr_regs->endptctrl[i]); 2144 tmp_reg = fsl_readl(&dr_regs->endptctrl[i]);
2171 t = scnprintf(next, size, "EP Ctrl Reg [0x%x]: = [0x%x]\n", 2145 seq_printf(m, "EP Ctrl Reg [0x%x]: = [0x%x]\n", i, tmp_reg);
2172 i, tmp_reg);
2173 size -= t;
2174 next += t;
2175 } 2146 }
2176 tmp_reg = fsl_readl(&dr_regs->endpointprime); 2147 tmp_reg = fsl_readl(&dr_regs->endpointprime);
2177 t = scnprintf(next, size, "EP Prime Reg = [0x%x]\n\n", tmp_reg); 2148 seq_printf(m, "EP Prime Reg = [0x%x]\n\n", tmp_reg);
2178 size -= t;
2179 next += t;
2180 2149
2181#ifndef CONFIG_ARCH_MXC 2150#ifndef CONFIG_ARCH_MXC
2182 if (udc->pdata->have_sysif_regs) { 2151 if (udc->pdata->have_sysif_regs) {
2183 tmp_reg = usb_sys_regs->snoop1; 2152 tmp_reg = usb_sys_regs->snoop1;
2184 t = scnprintf(next, size, "Snoop1 Reg : = [0x%x]\n\n", tmp_reg); 2153 seq_printf(m, "Snoop1 Reg : = [0x%x]\n\n", tmp_reg);
2185 size -= t;
2186 next += t;
2187 2154
2188 tmp_reg = usb_sys_regs->control; 2155 tmp_reg = usb_sys_regs->control;
2189 t = scnprintf(next, size, "General Control Reg : = [0x%x]\n\n", 2156 seq_printf(m, "General Control Reg : = [0x%x]\n\n", tmp_reg);
2190 tmp_reg);
2191 size -= t;
2192 next += t;
2193 } 2157 }
2194#endif 2158#endif
2195 2159
2196 /* ------fsl_udc, fsl_ep, fsl_request structure information ----- */ 2160 /* ------fsl_udc, fsl_ep, fsl_request structure information ----- */
2197 ep = &udc->eps[0]; 2161 ep = &udc->eps[0];
2198 t = scnprintf(next, size, "For %s Maxpkt is 0x%x index is 0x%x\n", 2162 seq_printf(m, "For %s Maxpkt is 0x%x index is 0x%x\n",
2199 ep->ep.name, ep_maxpacket(ep), ep_index(ep)); 2163 ep->ep.name, ep_maxpacket(ep), ep_index(ep));
2200 size -= t;
2201 next += t;
2202 2164
2203 if (list_empty(&ep->queue)) { 2165 if (list_empty(&ep->queue)) {
2204 t = scnprintf(next, size, "its req queue is empty\n\n"); 2166 seq_puts(m, "its req queue is empty\n\n");
2205 size -= t;
2206 next += t;
2207 } else { 2167 } else {
2208 list_for_each_entry(req, &ep->queue, queue) { 2168 list_for_each_entry(req, &ep->queue, queue) {
2209 t = scnprintf(next, size, 2169 seq_printf(m,
2210 "req %p actual 0x%x length 0x%x buf %p\n", 2170 "req %p actual 0x%x length 0x%x buf %p\n",
2211 &req->req, req->req.actual, 2171 &req->req, req->req.actual,
2212 req->req.length, req->req.buf); 2172 req->req.length, req->req.buf);
2213 size -= t;
2214 next += t;
2215 } 2173 }
2216 } 2174 }
2217 /* other gadget->eplist ep */ 2175 /* other gadget->eplist ep */
2218 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { 2176 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) {
2219 if (ep->ep.desc) { 2177 if (ep->ep.desc) {
2220 t = scnprintf(next, size, 2178 seq_printf(m,
2221 "\nFor %s Maxpkt is 0x%x " 2179 "\nFor %s Maxpkt is 0x%x "
2222 "index is 0x%x\n", 2180 "index is 0x%x\n",
2223 ep->ep.name, ep_maxpacket(ep), 2181 ep->ep.name, ep_maxpacket(ep),
2224 ep_index(ep)); 2182 ep_index(ep));
2225 size -= t;
2226 next += t;
2227 2183
2228 if (list_empty(&ep->queue)) { 2184 if (list_empty(&ep->queue)) {
2229 t = scnprintf(next, size, 2185 seq_puts(m, "its req queue is empty\n\n");
2230 "its req queue is empty\n\n");
2231 size -= t;
2232 next += t;
2233 } else { 2186 } else {
2234 list_for_each_entry(req, &ep->queue, queue) { 2187 list_for_each_entry(req, &ep->queue, queue) {
2235 t = scnprintf(next, size, 2188 seq_printf(m,
2236 "req %p actual 0x%x length " 2189 "req %p actual 0x%x length "
2237 "0x%x buf %p\n", 2190 "0x%x buf %p\n",
2238 &req->req, req->req.actual, 2191 &req->req, req->req.actual,
2239 req->req.length, req->req.buf); 2192 req->req.length, req->req.buf);
2240 size -= t; 2193 } /* end for each_entry of ep req */
2241 next += t; 2194 } /* end for else */
2242 } /* end for each_entry of ep req */ 2195 } /* end for if(ep->queue) */
2243 } /* end for else */ 2196 } /* end (ep->desc) */
2244 } /* end for if(ep->queue) */
2245 } /* end (ep->desc) */
2246 2197
2247 spin_unlock_irqrestore(&udc->lock, flags); 2198 spin_unlock_irqrestore(&udc->lock, flags);
2199 return 0;
2200}
2248 2201
2249 *eof = 1; 2202/*
2250 return count - size; 2203 * seq_file wrappers for procfile show routines.
2204 */
2205static int fsl_proc_open(struct inode *inode, struct file *file)
2206{
2207 return single_open(file, fsl_proc_read, NULL);
2251} 2208}
2252 2209
2253#define create_proc_file() create_proc_read_entry(proc_filename, \ 2210static const struct file_operations fsl_proc_fops = {
2254 0, NULL, fsl_proc_read, NULL) 2211 .open = fsl_proc_open,
2212 .read = seq_read,
2213 .llseek = seq_lseek,
2214 .release = seq_release,
2215};
2255 2216
2217#define create_proc_file() proc_create(proc_filename, 0, NULL, &fsl_proc_fops)
2256#define remove_proc_file() remove_proc_entry(proc_filename, NULL) 2218#define remove_proc_file() remove_proc_entry(proc_filename, NULL)
2257 2219
2258#else /* !CONFIG_USB_GADGET_DEBUG_FILES */ 2220#else /* !CONFIG_USB_GADGET_DEBUG_FILES */
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 991aba390d9d..480eeb7cfd92 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -35,6 +35,7 @@
35#include <linux/list.h> 35#include <linux/list.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
38#include <linux/seq_file.h>
38#include <linux/device.h> 39#include <linux/device.h>
39#include <linux/usb/ch9.h> 40#include <linux/usb/ch9.h>
40#include <linux/usb/gadget.h> 41#include <linux/usb/gadget.h>
@@ -1005,7 +1006,7 @@ static const struct usb_gadget_ops goku_ops = {
1005 1006
1006/*-------------------------------------------------------------------------*/ 1007/*-------------------------------------------------------------------------*/
1007 1008
1008static inline char *dmastr(void) 1009static inline const char *dmastr(void)
1009{ 1010{
1010 if (use_dma == 0) 1011 if (use_dma == 0)
1011 return "(dma disabled)"; 1012 return "(dma disabled)";
@@ -1022,13 +1023,10 @@ static const char proc_node_name [] = "driver/udc";
1022#define FOURBITS "%s%s%s%s" 1023#define FOURBITS "%s%s%s%s"
1023#define EIGHTBITS FOURBITS FOURBITS 1024#define EIGHTBITS FOURBITS FOURBITS
1024 1025
1025static void 1026static void dump_intmask(struct seq_file *m, const char *label, u32 mask)
1026dump_intmask(const char *label, u32 mask, char **next, unsigned *size)
1027{ 1027{
1028 int t;
1029
1030 /* int_status is the same format ... */ 1028 /* int_status is the same format ... */
1031 t = scnprintf(*next, *size, 1029 seq_printf(m,
1032 "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n", 1030 "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n",
1033 label, mask, 1031 label, mask,
1034 (mask & INT_PWRDETECT) ? " power" : "", 1032 (mask & INT_PWRDETECT) ? " power" : "",
@@ -1055,33 +1053,23 @@ dump_intmask(const char *label, u32 mask, char **next, unsigned *size)
1055 (mask & INT_ENDPOINT0) ? " ep0" : "", 1053 (mask & INT_ENDPOINT0) ? " ep0" : "",
1056 (mask & INT_USBRESET) ? " reset" : "", 1054 (mask & INT_USBRESET) ? " reset" : "",
1057 (mask & INT_SUSPEND) ? " suspend" : ""); 1055 (mask & INT_SUSPEND) ? " suspend" : "");
1058 *size -= t;
1059 *next += t;
1060} 1056}
1061 1057
1062 1058
1063static int 1059static int udc_proc_read(struct seq_file *m, void *v)
1064udc_proc_read(char *buffer, char **start, off_t off, int count,
1065 int *eof, void *_dev)
1066{ 1060{
1067 char *buf = buffer; 1061 struct goku_udc *dev = m->private;
1068 struct goku_udc *dev = _dev;
1069 struct goku_udc_regs __iomem *regs = dev->regs; 1062 struct goku_udc_regs __iomem *regs = dev->regs;
1070 char *next = buf;
1071 unsigned size = count;
1072 unsigned long flags; 1063 unsigned long flags;
1073 int i, t, is_usb_connected; 1064 int i, is_usb_connected;
1074 u32 tmp; 1065 u32 tmp;
1075 1066
1076 if (off != 0)
1077 return 0;
1078
1079 local_irq_save(flags); 1067 local_irq_save(flags);
1080 1068
1081 /* basic device status */ 1069 /* basic device status */
1082 tmp = readl(&regs->power_detect); 1070 tmp = readl(&regs->power_detect);
1083 is_usb_connected = tmp & PW_DETECT; 1071 is_usb_connected = tmp & PW_DETECT;
1084 t = scnprintf(next, size, 1072 seq_printf(m,
1085 "%s - %s\n" 1073 "%s - %s\n"
1086 "%s version: %s %s\n" 1074 "%s version: %s %s\n"
1087 "Gadget driver: %s\n" 1075 "Gadget driver: %s\n"
@@ -1093,7 +1081,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1093 is_usb_connected 1081 is_usb_connected
1094 ? ((tmp & PW_PULLUP) ? "full speed" : "powered") 1082 ? ((tmp & PW_PULLUP) ? "full speed" : "powered")
1095 : "disconnected", 1083 : "disconnected",
1096 ({char *state; 1084 ({const char *state;
1097 switch(dev->ep0state){ 1085 switch(dev->ep0state){
1098 case EP0_DISCONNECT: state = "ep0_disconnect"; break; 1086 case EP0_DISCONNECT: state = "ep0_disconnect"; break;
1099 case EP0_IDLE: state = "ep0_idle"; break; 1087 case EP0_IDLE: state = "ep0_idle"; break;
@@ -1105,27 +1093,24 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1105 default: state = "ep0_?"; break; 1093 default: state = "ep0_?"; break;
1106 } state; }) 1094 } state; })
1107 ); 1095 );
1108 size -= t;
1109 next += t;
1110 1096
1111 dump_intmask("int_status", readl(&regs->int_status), &next, &size); 1097 dump_intmask(m, "int_status", readl(&regs->int_status));
1112 dump_intmask("int_enable", readl(&regs->int_enable), &next, &size); 1098 dump_intmask(m, "int_enable", readl(&regs->int_enable));
1113 1099
1114 if (!is_usb_connected || !dev->driver || (tmp & PW_PULLUP) == 0) 1100 if (!is_usb_connected || !dev->driver || (tmp & PW_PULLUP) == 0)
1115 goto done; 1101 goto done;
1116 1102
1117 /* registers for (active) device and ep0 */ 1103 /* registers for (active) device and ep0 */
1118 t = scnprintf(next, size, "\nirqs %lu\ndataset %02x " 1104 if (seq_printf(m, "\nirqs %lu\ndataset %02x "
1119 "single.bcs %02x.%02x state %x addr %u\n", 1105 "single.bcs %02x.%02x state %x addr %u\n",
1120 dev->irqs, readl(&regs->DataSet), 1106 dev->irqs, readl(&regs->DataSet),
1121 readl(&regs->EPxSingle), readl(&regs->EPxBCS), 1107 readl(&regs->EPxSingle), readl(&regs->EPxBCS),
1122 readl(&regs->UsbState), 1108 readl(&regs->UsbState),
1123 readl(&regs->address)); 1109 readl(&regs->address)) < 0)
1124 size -= t; 1110 goto done;
1125 next += t;
1126 1111
1127 tmp = readl(&regs->dma_master); 1112 tmp = readl(&regs->dma_master);
1128 t = scnprintf(next, size, 1113 if (seq_printf(m,
1129 "dma %03X =" EIGHTBITS "%s %s\n", tmp, 1114 "dma %03X =" EIGHTBITS "%s %s\n", tmp,
1130 (tmp & MST_EOPB_DIS) ? " eopb-" : "", 1115 (tmp & MST_EOPB_DIS) ? " eopb-" : "",
1131 (tmp & MST_EOPB_ENA) ? " eopb+" : "", 1116 (tmp & MST_EOPB_ENA) ? " eopb+" : "",
@@ -1140,9 +1125,8 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1140 (tmp & MST_WR_ENA) ? " OUT" : "", 1125 (tmp & MST_WR_ENA) ? " OUT" : "",
1141 (tmp & MST_CONNECTION) 1126 (tmp & MST_CONNECTION)
1142 ? "ep1in/ep2out" 1127 ? "ep1in/ep2out"
1143 : "ep1out/ep2in"); 1128 : "ep1out/ep2in") < 0)
1144 size -= t; 1129 goto done;
1145 next += t;
1146 1130
1147 /* dump endpoint queues */ 1131 /* dump endpoint queues */
1148 for (i = 0; i < 4; i++) { 1132 for (i = 0; i < 4; i++) {
@@ -1153,7 +1137,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1153 continue; 1137 continue;
1154 1138
1155 tmp = readl(ep->reg_status); 1139 tmp = readl(ep->reg_status);
1156 t = scnprintf(next, size, 1140 if (seq_printf(m,
1157 "%s %s max %u %s, irqs %lu, " 1141 "%s %s max %u %s, irqs %lu, "
1158 "status %02x (%s) " FOURBITS "\n", 1142 "status %02x (%s) " FOURBITS "\n",
1159 ep->ep.name, 1143 ep->ep.name,
@@ -1186,18 +1170,12 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1186 (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "", 1170 (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "",
1187 (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "", 1171 (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "",
1188 (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : "" 1172 (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : ""
1189 ); 1173 ) < 0)
1190 if (t <= 0 || t > size)
1191 goto done; 1174 goto done;
1192 size -= t;
1193 next += t;
1194 1175
1195 if (list_empty(&ep->queue)) { 1176 if (list_empty(&ep->queue)) {
1196 t = scnprintf(next, size, "\t(nothing queued)\n"); 1177 if (seq_puts(m, "\t(nothing queued)\n") < 0)
1197 if (t <= 0 || t > size)
1198 goto done; 1178 goto done;
1199 size -= t;
1200 next += t;
1201 continue; 1179 continue;
1202 } 1180 }
1203 list_for_each_entry(req, &ep->queue, queue) { 1181 list_for_each_entry(req, &ep->queue, queue) {
@@ -1211,23 +1189,34 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1211 } else 1189 } else
1212 tmp = req->req.actual; 1190 tmp = req->req.actual;
1213 1191
1214 t = scnprintf(next, size, 1192 if (seq_printf(m,
1215 "\treq %p len %u/%u buf %p\n", 1193 "\treq %p len %u/%u buf %p\n",
1216 &req->req, tmp, req->req.length, 1194 &req->req, tmp, req->req.length,
1217 req->req.buf); 1195 req->req.buf) < 0)
1218 if (t <= 0 || t > size)
1219 goto done; 1196 goto done;
1220 size -= t;
1221 next += t;
1222 } 1197 }
1223 } 1198 }
1224 1199
1225done: 1200done:
1226 local_irq_restore(flags); 1201 local_irq_restore(flags);
1227 *eof = 1; 1202 return 0;
1228 return count - size; 1203}
1204
1205/*
1206 * seq_file wrappers for procfile show routines.
1207 */
1208static int udc_proc_open(struct inode *inode, struct file *file)
1209{
1210 return single_open(file, udc_proc_read, PDE_DATA(file_inode(file)));
1229} 1211}
1230 1212
1213static const struct file_operations udc_proc_fops = {
1214 .open = udc_proc_open,
1215 .read = seq_read,
1216 .llseek = seq_lseek,
1217 .release = seq_release,
1218};
1219
1231#endif /* CONFIG_USB_GADGET_DEBUG_FILES */ 1220#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
1232 1221
1233/*-------------------------------------------------------------------------*/ 1222/*-------------------------------------------------------------------------*/
@@ -1796,7 +1785,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1796 1785
1797 1786
1798#ifdef CONFIG_USB_GADGET_DEBUG_FILES 1787#ifdef CONFIG_USB_GADGET_DEBUG_FILES
1799 create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev); 1788 proc_create_data(proc_node_name, 0, NULL, &udc_proc_fops, dev);
1800#endif 1789#endif
1801 1790
1802 retval = usb_add_gadget_udc_release(&pdev->dev, &dev->gadget, 1791 retval = usb_add_gadget_udc_release(&pdev->dev, &dev->gadget,
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index e2b2e9cf254a..dda0dc4a5567 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -887,7 +887,6 @@ ep_open (struct inode *inode, struct file *fd)
887 887
888/* used before endpoint configuration */ 888/* used before endpoint configuration */
889static const struct file_operations ep_config_operations = { 889static const struct file_operations ep_config_operations = {
890 .owner = THIS_MODULE,
891 .llseek = no_llseek, 890 .llseek = no_llseek,
892 891
893 .open = ep_open, 892 .open = ep_open,
@@ -1940,7 +1939,6 @@ dev_open (struct inode *inode, struct file *fd)
1940} 1939}
1941 1940
1942static const struct file_operations dev_init_operations = { 1941static const struct file_operations dev_init_operations = {
1943 .owner = THIS_MODULE,
1944 .llseek = no_llseek, 1942 .llseek = no_llseek,
1945 1943
1946 .open = dev_open, 1944 .open = dev_open,
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c
index b943d8cdfbf7..67128be1e1b7 100644
--- a/drivers/usb/gadget/lpc32xx_udc.c
+++ b/drivers/usb/gadget/lpc32xx_udc.c
@@ -565,7 +565,7 @@ static int proc_udc_show(struct seq_file *s, void *unused)
565 565
566static int proc_udc_open(struct inode *inode, struct file *file) 566static int proc_udc_open(struct inode *inode, struct file *file)
567{ 567{
568 return single_open(file, proc_udc_show, PDE(inode)->data); 568 return single_open(file, proc_udc_show, PDE_DATA(inode));
569} 569}
570 570
571static const struct file_operations proc_ops = { 571static const struct file_operations proc_ops = {
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index d9297eebbf73..1e4cfb05f70b 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -1065,7 +1065,7 @@ static int rndis_proc_show(struct seq_file *m, void *v)
1065static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, 1065static ssize_t rndis_proc_write(struct file *file, const char __user *buffer,
1066 size_t count, loff_t *ppos) 1066 size_t count, loff_t *ppos)
1067{ 1067{
1068 rndis_params *p = PDE(file_inode(file))->data; 1068 rndis_params *p = PDE_DATA(file_inode(file));
1069 u32 speed = 0; 1069 u32 speed = 0;
1070 int i, fl_speed = 0; 1070 int i, fl_speed = 0;
1071 1071
@@ -1109,7 +1109,7 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer,
1109 1109
1110static int rndis_proc_open(struct inode *inode, struct file *file) 1110static int rndis_proc_open(struct inode *inode, struct file *file)
1111{ 1111{
1112 return single_open(file, rndis_proc_show, PDE(inode)->data); 1112 return single_open(file, rndis_proc_show, PDE_DATA(inode));
1113} 1113}
1114 1114
1115static const struct file_operations rndis_proc_fops = { 1115static const struct file_operations rndis_proc_fops = {
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 974480c516fa..b04e8ece4d35 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -2175,7 +2175,7 @@ static int proc_isp1362_show(struct seq_file *s, void *unused)
2175 2175
2176static int proc_isp1362_open(struct inode *inode, struct file *file) 2176static int proc_isp1362_open(struct inode *inode, struct file *file)
2177{ 2177{
2178 return single_open(file, proc_isp1362_show, PDE(inode)->data); 2178 return single_open(file, proc_isp1362_show, PDE_DATA(inode));
2179} 2179}
2180 2180
2181static const struct file_operations proc_ops = { 2181static const struct file_operations proc_ops = {
@@ -2192,14 +2192,11 @@ static void create_debug_file(struct isp1362_hcd *isp1362_hcd)
2192{ 2192{
2193 struct proc_dir_entry *pde; 2193 struct proc_dir_entry *pde;
2194 2194
2195 pde = create_proc_entry(proc_filename, 0, NULL); 2195 pde = proc_create_data(proc_filename, 0, NULL, &proc_ops, isp1362_hcd);
2196 if (pde == NULL) { 2196 if (pde == NULL) {
2197 pr_warning("%s: Failed to create debug file '%s'\n", __func__, proc_filename); 2197 pr_warning("%s: Failed to create debug file '%s'\n", __func__, proc_filename);
2198 return; 2198 return;
2199 } 2199 }
2200
2201 pde->proc_fops = &proc_ops;
2202 pde->data = isp1362_hcd;
2203 isp1362_hcd->pde = pde; 2200 isp1362_hcd->pde = pde;
2204} 2201}
2205 2202
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 15ed7e8d887f..ad4483efb6d6 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1494,7 +1494,7 @@ static int proc_sl811h_show(struct seq_file *s, void *unused)
1494 1494
1495static int proc_sl811h_open(struct inode *inode, struct file *file) 1495static int proc_sl811h_open(struct inode *inode, struct file *file)
1496{ 1496{
1497 return single_open(file, proc_sl811h_show, PDE(inode)->data); 1497 return single_open(file, proc_sl811h_show, PDE_DATA(inode));
1498} 1498}
1499 1499
1500static const struct file_operations proc_ops = { 1500static const struct file_operations proc_ops = {
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
index 42ad2e6d86c4..b6ab515bfc6c 100644
--- a/drivers/usb/misc/yurex.c
+++ b/drivers/usb/misc/yurex.c
@@ -407,8 +407,6 @@ static int yurex_release(struct inode *inode, struct file *file)
407 if (dev == NULL) 407 if (dev == NULL)
408 return -ENODEV; 408 return -ENODEV;
409 409
410 yurex_fasync(-1, file, 0);
411
412 /* decrement the count on our device */ 410 /* decrement the count on our device */
413 kref_put(&dev->kref, yurex_delete); 411 kref_put(&dev->kref, yurex_delete);
414 return 0; 412 return 0;
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 4faa982807f2..92b05d95ec5e 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -437,22 +437,21 @@ void usb_stor_report_bus_reset(struct us_data *us)
437 * /proc/scsi/ functions 437 * /proc/scsi/ functions
438 ***********************************************************************/ 438 ***********************************************************************/
439 439
440static int write_info(struct Scsi_Host *host, char *buffer, int length)
441{
442 /* if someone is sending us data, just throw it away */
443 return length;
444}
445
440/* we use this macro to help us write into the buffer */ 446/* we use this macro to help us write into the buffer */
441#undef SPRINTF 447#undef SPRINTF
442#define SPRINTF(args...) \ 448#define SPRINTF(args...) seq_printf(m, ## args)
443 do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0)
444 449
445static int proc_info (struct Scsi_Host *host, char *buffer, 450static int show_info (struct seq_file *m, struct Scsi_Host *host)
446 char **start, off_t offset, int length, int inout)
447{ 451{
448 struct us_data *us = host_to_us(host); 452 struct us_data *us = host_to_us(host);
449 char *pos = buffer;
450 const char *string; 453 const char *string;
451 454
452 /* if someone is sending us data, just throw it away */
453 if (inout)
454 return length;
455
456 /* print the controller name */ 455 /* print the controller name */
457 SPRINTF(" Host scsi%d: usb-storage\n", host->host_no); 456 SPRINTF(" Host scsi%d: usb-storage\n", host->host_no);
458 457
@@ -482,28 +481,14 @@ static int proc_info (struct Scsi_Host *host, char *buffer,
482 SPRINTF(" Transport: %s\n", us->transport_name); 481 SPRINTF(" Transport: %s\n", us->transport_name);
483 482
484 /* show the device flags */ 483 /* show the device flags */
485 if (pos < buffer + length) { 484 SPRINTF(" Quirks:");
486 pos += sprintf(pos, " Quirks:");
487 485
488#define US_FLAG(name, value) \ 486#define US_FLAG(name, value) \
489 if (us->fflags & value) pos += sprintf(pos, " " #name); 487 if (us->fflags & value) seq_printf(m, " " #name);
490US_DO_ALL_FLAGS 488US_DO_ALL_FLAGS
491#undef US_FLAG 489#undef US_FLAG
492 490 seq_putc(m, '\n');
493 *(pos++) = '\n'; 491 return 0;
494 }
495
496 /*
497 * Calculate start of next buffer, and return value.
498 */
499 *start = buffer + offset;
500
501 if ((pos - buffer) < offset)
502 return (0);
503 else if ((pos - buffer - offset) < length)
504 return (pos - buffer - offset);
505 else
506 return (length);
507} 492}
508 493
509/*********************************************************************** 494/***********************************************************************
@@ -548,7 +533,8 @@ struct scsi_host_template usb_stor_host_template = {
548 /* basic userland interface stuff */ 533 /* basic userland interface stuff */
549 .name = "usb-storage", 534 .name = "usb-storage",
550 .proc_name = "usb-storage", 535 .proc_name = "usb-storage",
551 .proc_info = proc_info, 536 .show_info = show_info,
537 .write_info = write_info,
552 .info = host_info, 538 .info = host_info,
553 539
554 /* command interface -- queued only */ 540 /* command interface -- queued only */
diff --git a/drivers/video/bfin_adv7393fb.c b/drivers/video/bfin_adv7393fb.c
index 8d411a3c9966..a54f7f7d763b 100644
--- a/drivers/video/bfin_adv7393fb.c
+++ b/drivers/video/bfin_adv7393fb.c
@@ -333,29 +333,23 @@ static int proc_output(char *buf)
333 return p - buf; 333 return p - buf;
334} 334}
335 335
336static int 336static ssize_t
337adv7393_read_proc(char *page, char **start, off_t off, 337adv7393_read_proc(struct file *file, char __user *buf,
338 int count, int *eof, void *data) 338 size_t size, loff_t *ppos)
339{ 339{
340 int len; 340 static const char message[] = "Usage:\n"
341 341 "echo 0x[REG][Value] > adv7393\n"
342 len = proc_output(page); 342 "example: echo 0x1234 >adv7393\n"
343 if (len <= off + count) 343 "writes 0x34 into Register 0x12\n";
344 *eof = 1; 344 return simple_read_from_buffer(buf, size, ppos, message,
345 *start = page + off; 345 sizeof(message));
346 len -= off;
347 if (len > count)
348 len = count;
349 if (len < 0)
350 len = 0;
351 return len;
352} 346}
353 347
354static int 348static ssize_t
355adv7393_write_proc(struct file *file, const char __user * buffer, 349adv7393_write_proc(struct file *file, const char __user * buffer,
356 size_t count, void *data) 350 size_t count, loff_t *ppos)
357{ 351{
358 struct adv7393fb_device *fbdev = data; 352 struct adv7393fb_device *fbdev = PDE_DATA(file_inode(file));
359 unsigned int val; 353 unsigned int val;
360 int ret; 354 int ret;
361 355
@@ -368,6 +362,12 @@ adv7393_write_proc(struct file *file, const char __user * buffer,
368 return count; 362 return count;
369} 363}
370 364
365static const struct file_operations fops = {
366 .read = adv7393_read_proc,
367 .write = adv7393_write_proc,
368 .llseek = default_llseek,
369};
370
371static int bfin_adv7393_fb_probe(struct i2c_client *client, 371static int bfin_adv7393_fb_probe(struct i2c_client *client,
372 const struct i2c_device_id *id) 372 const struct i2c_device_id *id)
373{ 373{
@@ -506,17 +506,12 @@ static int bfin_adv7393_fb_probe(struct i2c_client *client,
506 fbdev->info.node, fbdev->info.fix.id); 506 fbdev->info.node, fbdev->info.fix.id);
507 dev_info(&client->dev, "fb memory address : 0x%p\n", fbdev->fb_mem); 507 dev_info(&client->dev, "fb memory address : 0x%p\n", fbdev->fb_mem);
508 508
509 entry = create_proc_entry("driver/adv7393", 0, NULL); 509 entry = proc_create_data("driver/adv7393", 0, NULL, &fops, fbdev);
510 if (!entry) { 510 if (!entry) {
511 dev_err(&client->dev, "unable to create /proc entry\n"); 511 dev_err(&client->dev, "unable to create /proc entry\n");
512 ret = -EFAULT; 512 ret = -EFAULT;
513 goto free_fb; 513 goto free_fb;
514 } 514 }
515
516 entry->read_proc = adv7393_read_proc;
517 entry->write_proc = adv7393_write_proc;
518 entry->data = fbdev;
519
520 return 0; 515 return 0;
521 516
522free_fb: 517free_fb:
diff --git a/drivers/video/pxa3xx-gcu.c b/drivers/video/pxa3xx-gcu.c
index 6c984eacc7e3..97563c55af63 100644
--- a/drivers/video/pxa3xx-gcu.c
+++ b/drivers/video/pxa3xx-gcu.c
@@ -101,7 +101,6 @@ struct pxa3xx_gcu_priv {
101 dma_addr_t shared_phys; 101 dma_addr_t shared_phys;
102 struct resource *resource_mem; 102 struct resource *resource_mem;
103 struct miscdevice misc_dev; 103 struct miscdevice misc_dev;
104 struct file_operations misc_fops;
105 wait_queue_head_t wait_idle; 104 wait_queue_head_t wait_idle;
106 wait_queue_head_t wait_free; 105 wait_queue_head_t wait_free;
107 spinlock_t spinlock; 106 spinlock_t spinlock;
@@ -369,15 +368,20 @@ pxa3xx_gcu_wait_free(struct pxa3xx_gcu_priv *priv)
369 368
370/* Misc device layer */ 369/* Misc device layer */
371 370
371static inline struct pxa3xx_gcu_priv *file_dev(struct file *file)
372{
373 struct miscdevice *dev = file->private_data;
374 return container_of(dev, struct pxa3xx_gcu_priv, misc_dev);
375}
376
372static ssize_t 377static ssize_t
373pxa3xx_gcu_misc_write(struct file *filp, const char *buff, 378pxa3xx_gcu_misc_write(struct file *file, const char *buff,
374 size_t count, loff_t *offp) 379 size_t count, loff_t *offp)
375{ 380{
376 int ret; 381 int ret;
377 unsigned long flags; 382 unsigned long flags;
378 struct pxa3xx_gcu_batch *buffer; 383 struct pxa3xx_gcu_batch *buffer;
379 struct pxa3xx_gcu_priv *priv = 384 struct pxa3xx_gcu_priv *priv = file_dev(file);
380 container_of(filp->f_op, struct pxa3xx_gcu_priv, misc_fops);
381 385
382 int words = count / 4; 386 int words = count / 4;
383 387
@@ -450,11 +454,10 @@ pxa3xx_gcu_misc_write(struct file *filp, const char *buff,
450 454
451 455
452static long 456static long
453pxa3xx_gcu_misc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 457pxa3xx_gcu_misc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
454{ 458{
455 unsigned long flags; 459 unsigned long flags;
456 struct pxa3xx_gcu_priv *priv = 460 struct pxa3xx_gcu_priv *priv = file_dev(file);
457 container_of(filp->f_op, struct pxa3xx_gcu_priv, misc_fops);
458 461
459 switch (cmd) { 462 switch (cmd) {
460 case PXA3XX_GCU_IOCTL_RESET: 463 case PXA3XX_GCU_IOCTL_RESET:
@@ -471,11 +474,10 @@ pxa3xx_gcu_misc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
471} 474}
472 475
473static int 476static int
474pxa3xx_gcu_misc_mmap(struct file *filp, struct vm_area_struct *vma) 477pxa3xx_gcu_misc_mmap(struct file *file, struct vm_area_struct *vma)
475{ 478{
476 unsigned int size = vma->vm_end - vma->vm_start; 479 unsigned int size = vma->vm_end - vma->vm_start;
477 struct pxa3xx_gcu_priv *priv = 480 struct pxa3xx_gcu_priv *priv = file_dev(file);
478 container_of(filp->f_op, struct pxa3xx_gcu_priv, misc_fops);
479 481
480 switch (vma->vm_pgoff) { 482 switch (vma->vm_pgoff) {
481 case 0: 483 case 0:
@@ -574,6 +576,13 @@ free_buffers(struct platform_device *dev,
574 priv->free = NULL; 576 priv->free = NULL;
575} 577}
576 578
579static const struct file_operations misc_fops = {
580 .owner = THIS_MODULE,
581 .write = pxa3xx_gcu_misc_write,
582 .unlocked_ioctl = pxa3xx_gcu_misc_ioctl,
583 .mmap = pxa3xx_gcu_misc_mmap
584};
585
577static int pxa3xx_gcu_probe(struct platform_device *dev) 586static int pxa3xx_gcu_probe(struct platform_device *dev)
578{ 587{
579 int i, ret, irq; 588 int i, ret, irq;
@@ -601,14 +610,9 @@ static int pxa3xx_gcu_probe(struct platform_device *dev)
601 * container_of(). This isn't really necessary as we have a fixed minor 610 * container_of(). This isn't really necessary as we have a fixed minor
602 * number anyway, but this is to avoid statics. */ 611 * number anyway, but this is to avoid statics. */
603 612
604 priv->misc_fops.owner = THIS_MODULE;
605 priv->misc_fops.write = pxa3xx_gcu_misc_write;
606 priv->misc_fops.unlocked_ioctl = pxa3xx_gcu_misc_ioctl;
607 priv->misc_fops.mmap = pxa3xx_gcu_misc_mmap;
608
609 priv->misc_dev.minor = MISCDEV_MINOR, 613 priv->misc_dev.minor = MISCDEV_MINOR,
610 priv->misc_dev.name = DRV_NAME, 614 priv->misc_dev.name = DRV_NAME,
611 priv->misc_dev.fops = &priv->misc_fops, 615 priv->misc_dev.fops = &misc_fops,
612 616
613 /* register misc device */ 617 /* register misc device */
614 ret = misc_register(&priv->misc_dev); 618 ret = misc_register(&priv->misc_dev);
diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c
index 73b33837e12c..1c15ee7456b6 100644
--- a/drivers/zorro/proc.c
+++ b/drivers/zorro/proc.c
@@ -47,9 +47,7 @@ proc_bus_zorro_lseek(struct file *file, loff_t off, int whence)
47static ssize_t 47static ssize_t
48proc_bus_zorro_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 48proc_bus_zorro_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
49{ 49{
50 struct inode *ino = file_inode(file); 50 struct zorro_dev *z = PDE_DATA(file_inode(file));
51 struct proc_dir_entry *dp = PDE(ino);
52 struct zorro_dev *z = dp->data;
53 struct ConfigDev cd; 51 struct ConfigDev cd;
54 loff_t pos = *ppos; 52 loff_t pos = *ppos;
55 53
@@ -141,7 +139,7 @@ static int __init zorro_proc_attach_device(unsigned int slot)
141 &zorro_autocon[slot]); 139 &zorro_autocon[slot]);
142 if (!entry) 140 if (!entry)
143 return -ENOMEM; 141 return -ENOMEM;
144 entry->size = sizeof(struct zorro_dev); 142 proc_set_size(entry, sizeof(struct zorro_dev));
145 return 0; 143 return 0;
146} 144}
147 145