aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/cciss.txt4
-rw-r--r--Documentation/connector/cn_test.c194
-rw-r--r--Documentation/connector/connector.txt133
-rw-r--r--Documentation/dontdiff1
-rw-r--r--Documentation/feature-removal-schedule.txt9
-rw-r--r--Documentation/kdump/kdump.txt11
-rw-r--r--Documentation/oops-tracing.txt25
-rw-r--r--Documentation/pm.txt6
-rw-r--r--Documentation/scsi/00-INDEX2
-rw-r--r--Documentation/scsi/scsi_eh.txt479
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt124
-rw-r--r--Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl10
-rw-r--r--MAINTAINERS5
-rw-r--r--Makefile4
-rw-r--r--arch/arm/mach-pxa/Kconfig49
-rw-r--r--arch/arm/mach-pxa/Makefile1
-rw-r--r--arch/arm/mach-pxa/corgi.c37
-rw-r--r--arch/arm/mach-pxa/corgi_lcd.c197
-rw-r--r--arch/arm/mach-pxa/corgi_ssp.c66
-rw-r--r--arch/arm/mach-pxa/sharpsl.h34
-rw-r--r--arch/arm/mach-pxa/spitz.c380
-rw-r--r--arch/i386/kernel/reboot.c7
-rw-r--r--arch/i386/kernel/smpboot.c2
-rw-r--r--arch/i386/kernel/traps.c5
-rw-r--r--arch/m68knommu/platform/68328/head-de2.S135
-rw-r--r--arch/ppc/kernel/temp.c1
-rw-r--r--arch/ppc/kernel/time.c1
-rw-r--r--arch/ppc/kernel/vmlinux.lds.S4
-rw-r--r--arch/ppc/platforms/chrp_time.c1
-rw-r--r--arch/ppc/syslib/prep_nvram.c1
-rw-r--r--arch/ppc64/kernel/asm-offsets.c1
-rw-r--r--arch/ppc64/kernel/entry.S18
-rw-r--r--arch/ppc64/kernel/pSeries_setup.c2
-rw-r--r--arch/sparc/kernel/module.c9
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c31
-rw-r--r--arch/sparc/lib/mul.S2
-rw-r--r--arch/sparc/lib/rem.S2
-rw-r--r--arch/sparc/lib/sdiv.S2
-rw-r--r--arch/sparc/lib/udiv.S2
-rw-r--r--arch/sparc/lib/umul.S2
-rw-r--r--arch/sparc/lib/urem.S2
-rw-r--r--arch/x86_64/kernel/e820.c1
-rw-r--r--arch/x86_64/kernel/mce.c2
-rw-r--r--arch/x86_64/kernel/nmi.c8
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/base/attribute_container.c5
-rw-r--r--drivers/base/class.c10
-rw-r--r--drivers/base/firmware_class.c9
-rw-r--r--drivers/base/map.c3
-rw-r--r--drivers/base/platform.c3
-rw-r--r--drivers/block/cciss.c639
-rw-r--r--drivers/block/cciss.h10
-rw-r--r--drivers/block/cciss_cmd.h8
-rw-r--r--drivers/block/cciss_scsi.c69
-rw-r--r--drivers/block/pktcdvd.c85
-rw-r--r--drivers/block/scsi_ioctl.c1
-rw-r--r--drivers/char/amiserial.c4
-rw-r--r--drivers/char/watchdog/Kconfig102
-rw-r--r--drivers/char/watchdog/Makefile8
-rw-r--r--drivers/char/watchdog/i6300esb.c527
-rw-r--r--drivers/char/watchdog/ibmasr.c405
-rw-r--r--drivers/char/watchdog/mpcore_wdt.c434
-rw-r--r--drivers/char/watchdog/mv64x60_wdt.c252
-rw-r--r--drivers/char/watchdog/pcwd_pci.c44
-rw-r--r--drivers/char/watchdog/s3c2410_wdt.c2
-rw-r--r--drivers/char/watchdog/sbc8360.c414
-rw-r--r--drivers/char/watchdog/w83977f_wdt.c543
-rw-r--r--drivers/connector/Kconfig13
-rw-r--r--drivers/connector/Makefile3
-rw-r--r--drivers/connector/cn_queue.c173
-rw-r--r--drivers/connector/connector.c486
-rw-r--r--drivers/i2c/busses/i2c-keywest.c1
-rw-r--r--drivers/ide/ide-iops.c41
-rw-r--r--drivers/ide/pci/cmd64x.c2
-rw-r--r--drivers/ide/pci/hpt34x.c2
-rw-r--r--drivers/ieee1394/sbp2.c8
-rw-r--r--drivers/input/keyboard/Kconfig11
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/spitzkbd.c478
-rw-r--r--drivers/input/touchscreen/Kconfig6
-rw-r--r--drivers/input/touchscreen/corgi_ts.c70
-rw-r--r--drivers/isdn/sc/init.c4
-rw-r--r--drivers/media/radio/radio-aimslab.c2
-rw-r--r--drivers/media/radio/radio-aztech.c2
-rw-r--r--drivers/media/radio/radio-cadet.c2
-rw-r--r--drivers/media/radio/radio-gemtek.c2
-rw-r--r--drivers/media/radio/radio-rtrack2.c2
-rw-r--r--drivers/media/radio/radio-sf16fmi.c2
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c2
-rw-r--r--drivers/media/radio/radio-terratec.c2
-rw-r--r--drivers/media/radio/radio-typhoon.c2
-rw-r--r--drivers/media/radio/radio-zoltrix.c2
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c7
-rw-r--r--drivers/mmc/wbsd.c441
-rw-r--r--drivers/mmc/wbsd.h23
-rw-r--r--drivers/net/arcnet/com90io.c4
-rw-r--r--drivers/net/bnx2.c2
-rw-r--r--drivers/net/hamradio/6pack.c2
-rw-r--r--drivers/net/hamradio/baycom_epp.c17
-rw-r--r--drivers/net/hamradio/bpqether.c2
-rw-r--r--drivers/net/hamradio/dmascc.c10
-rw-r--r--drivers/net/hamradio/hdlcdrv.c16
-rw-r--r--drivers/net/hamradio/mkiss.c2
-rw-r--r--drivers/net/hamradio/scc.c2
-rw-r--r--drivers/net/hamradio/yam.c28
-rw-r--r--drivers/net/tg3.c10
-rw-r--r--drivers/net/wireless/orinoco_cs.c1
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c12
-rw-r--r--drivers/sbus/char/bpp.c3
-rw-r--r--drivers/sbus/char/display7seg.c2
-rw-r--r--drivers/sbus/char/vfc_i2c.c3
-rw-r--r--drivers/scsi/3w-9xxx.c30
-rw-r--r--drivers/scsi/Kconfig7
-rw-r--r--drivers/scsi/Makefile1
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c22
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c7
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h17
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c18
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c4
-rw-r--r--drivers/scsi/scsi_lib.c138
-rw-r--r--drivers/scsi/scsi_priv.h1
-rw-r--r--drivers/scsi/scsi_scan.c88
-rw-r--r--drivers/scsi/scsi_sysfs.c28
-rw-r--r--drivers/scsi/scsi_transport_sas.c820
-rw-r--r--drivers/scsi/sg.c4
-rw-r--r--drivers/tc/zs.c2
-rw-r--r--drivers/video/Kconfig3
-rw-r--r--drivers/video/backlight/corgi_bl.c25
-rw-r--r--drivers/video/console/fbcon.c18
-rw-r--r--drivers/video/console/fbcon.h2
-rw-r--r--drivers/video/console/font_10x18.c4
-rw-r--r--drivers/video/console/font_6x11.c4
-rw-r--r--drivers/video/console/font_7x14.c4
-rw-r--r--drivers/video/console/font_8x16.c4
-rw-r--r--drivers/video/console/font_8x8.c4
-rw-r--r--drivers/video/console/font_acorn_8x8.c4
-rw-r--r--drivers/video/console/font_mini_4x6.c4
-rw-r--r--drivers/video/console/font_pearl_8x8.c4
-rw-r--r--drivers/video/console/font_sun12x22.c4
-rw-r--r--drivers/video/console/font_sun8x16.c4
-rw-r--r--drivers/video/console/fonts.c9
-rw-r--r--drivers/video/matrox/matroxfb_base.c13
-rw-r--r--drivers/video/pm3fb.c3
-rw-r--r--fs/namei.c2
-rw-r--r--fs/nfsd/nfs4proc.c24
-rw-r--r--fs/nfsd/nfs4state.c90
-rw-r--r--fs/open.c98
-rw-r--r--fs/reiserfs/file.c11
-rw-r--r--fs/reiserfs/inode.c16
-rw-r--r--include/asm-alpha/pgtable.h7
-rw-r--r--include/asm-arm/arch-pxa/akita.h30
-rw-r--r--include/asm-arm/arch-pxa/corgi.h12
-rw-r--r--include/asm-arm/arch-pxa/sharpsl.h32
-rw-r--r--include/asm-arm/arch-pxa/spitz.h158
-rw-r--r--include/asm-arm/pgtable.h5
-rw-r--r--include/asm-arm26/pgtable.h5
-rw-r--r--include/asm-frv/pgtable.h3
-rw-r--r--include/asm-h8300/pgtable.h2
-rw-r--r--include/asm-i386/pgtable.h3
-rw-r--r--include/asm-ia64/pgtable.h4
-rw-r--r--include/asm-m32r/pgtable.h3
-rw-r--r--include/asm-m68k/pgtable.h3
-rw-r--r--include/asm-m68knommu/cacheflush.h29
-rw-r--r--include/asm-m68knommu/pgtable.h2
-rw-r--r--include/asm-m68knommu/scatterlist.h6
-rw-r--r--include/asm-m68knommu/system.h54
-rw-r--r--include/asm-mips/pgtable.h12
-rw-r--r--include/asm-parisc/pgtable.h3
-rw-r--r--include/asm-ppc/mv64x60.h8
-rw-r--r--include/asm-ppc/pgtable.h11
-rw-r--r--include/asm-ppc/segment.h1
-rw-r--r--include/asm-sh/pgtable.h3
-rw-r--r--include/asm-sh64/pgtable.h3
-rw-r--r--include/asm-x86_64/pgtable.h3
-rw-r--r--include/asm-xtensa/pgtable.h6
-rw-r--r--include/linux/audit.h36
-rw-r--r--include/linux/connector.h158
-rw-r--r--include/linux/fb.h2
-rw-r--r--include/linux/font.h10
-rw-r--r--include/linux/kernel.h4
-rw-r--r--include/linux/netlink.h1
-rw-r--r--include/linux/nfsd/xdr4.h15
-rw-r--r--include/linux/pci_ids.h48
-rw-r--r--include/linux/pktcdvd.h3
-rw-r--r--include/linux/sched.h11
-rw-r--r--include/linux/security.h5
-rw-r--r--include/linux/sysctl.h3
-rw-r--r--include/linux/videodev2.h109
-rw-r--r--include/net/ax25.h31
-rw-r--r--include/net/netrom.h32
-rw-r--r--include/scsi/scsi_device.h4
-rw-r--r--include/scsi/scsi_transport_fc.h8
-rw-r--r--include/scsi/scsi_transport_sas.h100
-rw-r--r--include/sound/core.h8
-rw-r--r--include/sound/cs46xx.h14
-rw-r--r--include/sound/emu10k1.h7
-rw-r--r--include/sound/pcm.h5
-rw-r--r--include/sound/pcm_oss.h3
-rw-r--r--include/sound/trident.h17
-rw-r--r--include/sound/version.h2
-rw-r--r--include/sound/ymfpci.h22
-rw-r--r--include/video/pm3fb.h3
-rw-r--r--include/video/w100fb.h1
-rw-r--r--init/initramfs.c12
-rw-r--r--kernel/audit.c128
-rw-r--r--kernel/auditsc.c327
-rw-r--r--kernel/module.c11
-rw-r--r--kernel/sched.c8
-rw-r--r--kernel/timer.c9
-rw-r--r--mm/mempolicy.c7
-rw-r--r--mm/page_alloc.c3
-rw-r--r--mm/vmscan.c4
-rw-r--r--net/ax25/af_ax25.c46
-rw-r--r--net/ax25/ax25_ip.c6
-rw-r--r--net/core/pktgen.c13
-rw-r--r--net/dccp/ccids/ccid3.c8
-rw-r--r--net/ipv4/ipconfig.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_ftp.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_irc.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netbios_ns.c19
-rw-r--r--net/ipv4/netfilter/ip_conntrack_tftp.c6
-rw-r--r--net/ipv4/netfilter/ipt_MASQUERADE.c6
-rw-r--r--net/ipv4/netfilter/ipt_REDIRECT.c16
-rw-r--r--net/irda/ircomm/ircomm_tty.c9
-rw-r--r--net/netrom/af_netrom.c28
-rw-r--r--net/netrom/nr_dev.c54
-rw-r--r--net/netrom/nr_in.c15
-rw-r--r--net/netrom/nr_subr.c7
-rw-r--r--net/netrom/sysctl_net_netrom.c12
-rw-r--r--net/rose/af_rose.c8
-rw-r--r--net/rose/rose_dev.c2
-rw-r--r--net/sunrpc/svcsock.c86
-rw-r--r--scripts/mod/modpost.c6
-rw-r--r--security/Kconfig1
-rw-r--r--security/Makefile2
-rw-r--r--security/inode.c347
-rw-r--r--security/seclvl.c228
-rw-r--r--security/selinux/avc.c4
-rw-r--r--security/selinux/hooks.c2
-rw-r--r--security/selinux/ss/services.c4
-rw-r--r--sound/arm/Kconfig1
-rw-r--r--sound/arm/aaci.c2
-rw-r--r--sound/arm/sa11xx-uda1341.c7
-rw-r--r--sound/core/Kconfig14
-rw-r--r--sound/core/control.c12
-rw-r--r--sound/core/control_compat.c8
-rw-r--r--sound/core/device.c2
-rw-r--r--sound/core/hwdep.c2
-rw-r--r--sound/core/info.c8
-rw-r--r--sound/core/init.c187
-rw-r--r--sound/core/memalloc.c3
-rw-r--r--sound/core/memory.c4
-rw-r--r--sound/core/oss/mixer_oss.c26
-rw-r--r--sound/core/oss/pcm_oss.c17
-rw-r--r--sound/core/oss/pcm_plugin.c2
-rw-r--r--sound/core/pcm.c6
-rw-r--r--sound/core/pcm_lib.c117
-rw-r--r--sound/core/pcm_memory.c4
-rw-r--r--sound/core/pcm_native.c11
-rw-r--r--sound/core/rawmidi.c16
-rw-r--r--sound/core/seq/instr/ainstr_gf1.c2
-rw-r--r--sound/core/seq/instr/ainstr_iw.c6
-rw-r--r--sound/core/seq/oss/seq_oss_init.c2
-rw-r--r--sound/core/seq/oss/seq_oss_midi.c6
-rw-r--r--sound/core/seq/oss/seq_oss_readq.c2
-rw-r--r--sound/core/seq/oss/seq_oss_synth.c4
-rw-r--r--sound/core/seq/oss/seq_oss_timer.c2
-rw-r--r--sound/core/seq/oss/seq_oss_writeq.c2
-rw-r--r--sound/core/seq/seq.c8
-rw-r--r--sound/core/seq/seq_clientmgr.c9
-rw-r--r--sound/core/seq/seq_device.c2
-rw-r--r--sound/core/seq/seq_dummy.c2
-rw-r--r--sound/core/seq/seq_fifo.c2
-rw-r--r--sound/core/seq/seq_instr.c4
-rw-r--r--sound/core/seq/seq_memory.c2
-rw-r--r--sound/core/seq/seq_midi.c2
-rw-r--r--sound/core/seq/seq_midi_event.c2
-rw-r--r--sound/core/seq/seq_ports.c4
-rw-r--r--sound/core/seq/seq_prioq.c2
-rw-r--r--sound/core/seq/seq_queue.c2
-rw-r--r--sound/core/seq/seq_system.c4
-rw-r--r--sound/core/seq/seq_timer.c2
-rw-r--r--sound/core/seq/seq_virmidi.c6
-rw-r--r--sound/core/sound.c15
-rw-r--r--sound/core/timer.c10
-rw-r--r--sound/drivers/Kconfig5
-rw-r--r--sound/drivers/dummy.c8
-rw-r--r--sound/drivers/mpu401/mpu401.c26
-rw-r--r--sound/drivers/mpu401/mpu401_uart.c2
-rw-r--r--sound/drivers/mtpav.c5
-rw-r--r--sound/drivers/opl3/opl3_lib.c2
-rw-r--r--sound/drivers/opl3/opl3_oss.c2
-rw-r--r--sound/drivers/opl4/opl4_lib.c2
-rw-r--r--sound/drivers/serial-u16550.c28
-rw-r--r--sound/drivers/virmidi.c4
-rw-r--r--sound/drivers/vx/vx_core.c2
-rw-r--r--sound/drivers/vx/vx_pcm.c2
-rw-r--r--sound/i2c/cs8427.c2
-rw-r--r--sound/i2c/i2c.c4
-rw-r--r--sound/i2c/l3/uda1341.c6
-rw-r--r--sound/i2c/other/ak4114.c2
-rw-r--r--sound/i2c/other/ak4117.c2
-rw-r--r--sound/i2c/tea6330t.c2
-rw-r--r--sound/isa/Kconfig18
-rw-r--r--sound/isa/ad1816a/ad1816a_lib.c2
-rw-r--r--sound/isa/ad1848/ad1848.c37
-rw-r--r--sound/isa/ad1848/ad1848_lib.c2
-rw-r--r--sound/isa/cmi8330.c77
-rw-r--r--sound/isa/cs423x/cs4231.c46
-rw-r--r--sound/isa/cs423x/cs4231_lib.c2
-rw-r--r--sound/isa/cs423x/cs4236.c97
-rw-r--r--sound/isa/es1688/es1688.c61
-rw-r--r--sound/isa/es1688/es1688_lib.c2
-rw-r--r--sound/isa/es18xx.c83
-rw-r--r--sound/isa/gus/gus_main.c2
-rw-r--r--sound/isa/gus/gus_mem_proc.c4
-rw-r--r--sound/isa/gus/gus_pcm.c2
-rw-r--r--sound/isa/gus/gusclassic.c115
-rw-r--r--sound/isa/gus/gusextreme.c49
-rw-r--r--sound/isa/gus/gusmax.c145
-rw-r--r--sound/isa/gus/interwave.c167
-rw-r--r--sound/isa/opl3sa2.c38
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c13
-rw-r--r--sound/isa/sb/emu8000.c2
-rw-r--r--sound/isa/sb/emu8000_pcm.c2
-rw-r--r--sound/isa/sb/sb16.c144
-rw-r--r--sound/isa/sb/sb16_csp.c2
-rw-r--r--sound/isa/sb/sb8.c62
-rw-r--r--sound/isa/sb/sb_common.c2
-rw-r--r--sound/isa/sgalaxy.c65
-rw-r--r--sound/isa/sscape.c22
-rw-r--r--sound/isa/wavefront/wavefront.c5
-rw-r--r--sound/mips/Kconfig1
-rw-r--r--sound/mips/au1x00.c5
-rw-r--r--sound/parisc/harmony.c2
-rw-r--r--sound/pci/Kconfig12
-rw-r--r--sound/pci/Makefile2
-rw-r--r--sound/pci/ac97/ac97_codec.c5
-rw-r--r--sound/pci/ac97/ac97_id.h1
-rw-r--r--sound/pci/ac97/ac97_patch.c24
-rw-r--r--sound/pci/ac97/ak4531_codec.c2
-rw-r--r--sound/pci/ad1889.c1090
-rw-r--r--sound/pci/ad1889.h189
-rw-r--r--sound/pci/ali5451/ali5451.c27
-rw-r--r--sound/pci/als4000.c1
-rw-r--r--sound/pci/atiixp.c4
-rw-r--r--sound/pci/atiixp_modem.c3
-rw-r--r--sound/pci/au88x0/au88x0.c29
-rw-r--r--sound/pci/azt3328.c3
-rw-r--r--sound/pci/bt87x.c13
-rw-r--r--sound/pci/ca0106/ca0106_main.c7
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c18
-rw-r--r--sound/pci/cmipci.c29
-rw-r--r--sound/pci/cs4281.c14
-rw-r--r--sound/pci/cs46xx/cs46xx.c1
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c28
-rw-r--r--sound/pci/emu10k1/emu10k1.c1
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c7
-rw-r--r--sound/pci/emu10k1/emu10k1x.c7
-rw-r--r--sound/pci/emu10k1/emufx.c20
-rw-r--r--sound/pci/emu10k1/emupcm.c10
-rw-r--r--sound/pci/emu10k1/p16v.c4
-rw-r--r--sound/pci/ens1370.c10
-rw-r--r--sound/pci/es1938.c10
-rw-r--r--sound/pci/es1968.c26
-rw-r--r--sound/pci/fm801.c3
-rw-r--r--sound/pci/hda/hda_codec.c6
-rw-r--r--sound/pci/hda/hda_codec.h1
-rw-r--r--sound/pci/hda/hda_generic.c4
-rw-r--r--sound/pci/hda/hda_intel.c93
-rw-r--r--sound/pci/hda/hda_proc.c2
-rw-r--r--sound/pci/hda/patch_analog.c6
-rw-r--r--sound/pci/hda/patch_cmedia.c2
-rw-r--r--sound/pci/hda/patch_realtek.c8
-rw-r--r--sound/pci/hda/patch_si3054.c3
-rw-r--r--sound/pci/hda/patch_sigmatel.c4
-rw-r--r--sound/pci/ice1712/aureon.c2
-rw-r--r--sound/pci/ice1712/ice1712.c9
-rw-r--r--sound/pci/ice1712/ice1724.c9
-rw-r--r--sound/pci/ice1712/juli.c2
-rw-r--r--sound/pci/ice1712/phase.c4
-rw-r--r--sound/pci/ice1712/pontis.c2
-rw-r--r--sound/pci/intel8x0.c91
-rw-r--r--sound/pci/intel8x0m.c64
-rw-r--r--sound/pci/korg1212/korg1212.c3
-rw-r--r--sound/pci/maestro3.c32
-rw-r--r--sound/pci/mixart/mixart.c5
-rw-r--r--sound/pci/nm256/nm256.c20
-rw-r--r--sound/pci/rme32.c21
-rw-r--r--sound/pci/rme96.c26
-rw-r--r--sound/pci/rme9652/hdsp.c9
-rw-r--r--sound/pci/rme9652/hdspm.c13
-rw-r--r--sound/pci/rme9652/rme9652.c8
-rw-r--r--sound/pci/sonicvibes.c10
-rw-r--r--sound/pci/trident/trident.c1
-rw-r--r--sound/pci/trident/trident_main.c4
-rw-r--r--sound/pci/via82xx.c14
-rw-r--r--sound/pci/via82xx_modem.c3
-rw-r--r--sound/pci/vx222/vx222.c1
-rw-r--r--sound/pci/ymfpci/ymfpci.c1
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c6
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf_core.c2
-rw-r--r--sound/ppc/Kconfig15
-rw-r--r--sound/ppc/pmac.c3
-rw-r--r--sound/ppc/powermac.c3
-rw-r--r--sound/ppc/tumbler.c23
-rw-r--r--sound/sparc/Kconfig3
-rw-r--r--sound/sparc/amd7930.c5
-rw-r--r--sound/sparc/cs4231.c7
-rw-r--r--sound/sparc/dbri.c234
-rw-r--r--sound/synth/emux/emux.c2
-rw-r--r--sound/synth/emux/emux_seq.c2
-rw-r--r--sound/synth/emux/soundfont.c8
-rw-r--r--sound/synth/util_mem.c2
-rw-r--r--sound/usb/usbaudio.c18
-rw-r--r--sound/usb/usbmidi.c6
-rw-r--r--sound/usb/usbmixer.c10
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c2
420 files changed, 12481 insertions, 3467 deletions
diff --git a/Documentation/cciss.txt b/Documentation/cciss.txt
index c8f9a73111da..68a711fb82cf 100644
--- a/Documentation/cciss.txt
+++ b/Documentation/cciss.txt
@@ -17,7 +17,9 @@ This driver is known to work with the following cards:
17 * SA P600 17 * SA P600
18 * SA P800 18 * SA P800
19 * SA E400 19 * SA E400
20 * SA E300 20 * SA P400i
21 * SA E200
22 * SA E200i
21 23
22If nodes are not already created in the /dev/cciss directory, run as root: 24If nodes are not already created in the /dev/cciss directory, run as root:
23 25
diff --git a/Documentation/connector/cn_test.c b/Documentation/connector/cn_test.c
new file mode 100644
index 000000000000..b7de82e9c0e0
--- /dev/null
+++ b/Documentation/connector/cn_test.c
@@ -0,0 +1,194 @@
1/*
2 * cn_test.c
3 *
4 * 2004-2005 Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/skbuff.h>
26#include <linux/timer.h>
27
28#include "connector.h"
29
30static struct cb_id cn_test_id = { 0x123, 0x456 };
31static char cn_test_name[] = "cn_test";
32static struct sock *nls;
33static struct timer_list cn_test_timer;
34
35void cn_test_callback(void *data)
36{
37 struct cn_msg *msg = (struct cn_msg *)data;
38
39 printk("%s: %lu: idx=%x, val=%x, seq=%u, ack=%u, len=%d: %s.\n",
40 __func__, jiffies, msg->id.idx, msg->id.val,
41 msg->seq, msg->ack, msg->len, (char *)msg->data);
42}
43
44static int cn_test_want_notify(void)
45{
46 struct cn_ctl_msg *ctl;
47 struct cn_notify_req *req;
48 struct cn_msg *msg = NULL;
49 int size, size0;
50 struct sk_buff *skb;
51 struct nlmsghdr *nlh;
52 u32 group = 1;
53
54 size0 = sizeof(*msg) + sizeof(*ctl) + 3 * sizeof(*req);
55
56 size = NLMSG_SPACE(size0);
57
58 skb = alloc_skb(size, GFP_ATOMIC);
59 if (!skb) {
60 printk(KERN_ERR "Failed to allocate new skb with size=%u.\n",
61 size);
62
63 return -ENOMEM;
64 }
65
66 nlh = NLMSG_PUT(skb, 0, 0x123, NLMSG_DONE, size - sizeof(*nlh));
67
68 msg = (struct cn_msg *)NLMSG_DATA(nlh);
69
70 memset(msg, 0, size0);
71
72 msg->id.idx = -1;
73 msg->id.val = -1;
74 msg->seq = 0x123;
75 msg->ack = 0x345;
76 msg->len = size0 - sizeof(*msg);
77
78 ctl = (struct cn_ctl_msg *)(msg + 1);
79
80 ctl->idx_notify_num = 1;
81 ctl->val_notify_num = 2;
82 ctl->group = group;
83 ctl->len = msg->len - sizeof(*ctl);
84
85 req = (struct cn_notify_req *)(ctl + 1);
86
87 /*
88 * Idx.
89 */
90 req->first = cn_test_id.idx;
91 req->range = 10;
92
93 /*
94 * Val 0.
95 */
96 req++;
97 req->first = cn_test_id.val;
98 req->range = 10;
99
100 /*
101 * Val 1.
102 */
103 req++;
104 req->first = cn_test_id.val + 20;
105 req->range = 10;
106
107 NETLINK_CB(skb).dst_groups = ctl->group;
108 //netlink_broadcast(nls, skb, 0, ctl->group, GFP_ATOMIC);
109 netlink_unicast(nls, skb, 0, 0);
110
111 printk(KERN_INFO "Request was sent. Group=0x%x.\n", ctl->group);
112
113 return 0;
114
115nlmsg_failure:
116 printk(KERN_ERR "Failed to send %u.%u\n", msg->seq, msg->ack);
117 kfree_skb(skb);
118 return -EINVAL;
119}
120
121static u32 cn_test_timer_counter;
122static void cn_test_timer_func(unsigned long __data)
123{
124 struct cn_msg *m;
125 char data[32];
126
127 m = kmalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC);
128 if (m) {
129 memset(m, 0, sizeof(*m) + sizeof(data));
130
131 memcpy(&m->id, &cn_test_id, sizeof(m->id));
132 m->seq = cn_test_timer_counter;
133 m->len = sizeof(data);
134
135 m->len =
136 scnprintf(data, sizeof(data), "counter = %u",
137 cn_test_timer_counter) + 1;
138
139 memcpy(m + 1, data, m->len);
140
141 cn_netlink_send(m, 0, gfp_any());
142 kfree(m);
143 }
144
145 cn_test_timer_counter++;
146
147 mod_timer(&cn_test_timer, jiffies + HZ);
148}
149
150static int cn_test_init(void)
151{
152 int err;
153
154 err = cn_add_callback(&cn_test_id, cn_test_name, cn_test_callback);
155 if (err)
156 goto err_out;
157 cn_test_id.val++;
158 err = cn_add_callback(&cn_test_id, cn_test_name, cn_test_callback);
159 if (err) {
160 cn_del_callback(&cn_test_id);
161 goto err_out;
162 }
163
164 init_timer(&cn_test_timer);
165 cn_test_timer.function = cn_test_timer_func;
166 cn_test_timer.expires = jiffies + HZ;
167 cn_test_timer.data = 0;
168 add_timer(&cn_test_timer);
169
170 return 0;
171
172 err_out:
173 if (nls && nls->sk_socket)
174 sock_release(nls->sk_socket);
175
176 return err;
177}
178
179static void cn_test_fini(void)
180{
181 del_timer_sync(&cn_test_timer);
182 cn_del_callback(&cn_test_id);
183 cn_test_id.val--;
184 cn_del_callback(&cn_test_id);
185 if (nls && nls->sk_socket)
186 sock_release(nls->sk_socket);
187}
188
189module_init(cn_test_init);
190module_exit(cn_test_fini);
191
192MODULE_LICENSE("GPL");
193MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
194MODULE_DESCRIPTION("Connector's test module");
diff --git a/Documentation/connector/connector.txt b/Documentation/connector/connector.txt
new file mode 100644
index 000000000000..54a0a14bfbe3
--- /dev/null
+++ b/Documentation/connector/connector.txt
@@ -0,0 +1,133 @@
1/*****************************************/
2Kernel Connector.
3/*****************************************/
4
5Kernel connector - new netlink based userspace <-> kernel space easy
6to use communication module.
7
8Connector driver adds possibility to connect various agents using
9netlink based network. One must register callback and
10identifier. When driver receives special netlink message with
11appropriate identifier, appropriate callback will be called.
12
13From the userspace point of view it's quite straightforward:
14
15 socket();
16 bind();
17 send();
18 recv();
19
20But if kernelspace want to use full power of such connections, driver
21writer must create special sockets, must know about struct sk_buff
22handling... Connector allows any kernelspace agents to use netlink
23based networking for inter-process communication in a significantly
24easier way:
25
26int cn_add_callback(struct cb_id *id, char *name, void (*callback) (void *));
27void cn_netlink_send(struct cn_msg *msg, u32 __group, int gfp_mask);
28
29struct cb_id
30{
31 __u32 idx;
32 __u32 val;
33};
34
35idx and val are unique identifiers which must be registered in
36connector.h for in-kernel usage. void (*callback) (void *) - is a
37callback function which will be called when message with above idx.val
38will be received by connector core. Argument for that function must
39be dereferenced to struct cn_msg *.
40
41struct cn_msg
42{
43 struct cb_id id;
44
45 __u32 seq;
46 __u32 ack;
47
48 __u32 len; /* Length of the following data */
49 __u8 data[0];
50};
51
52/*****************************************/
53Connector interfaces.
54/*****************************************/
55
56int cn_add_callback(struct cb_id *id, char *name, void (*callback) (void *));
57
58Registers new callback with connector core.
59
60struct cb_id *id - unique connector's user identifier.
61 It must be registered in connector.h for legal in-kernel users.
62char *name - connector's callback symbolic name.
63void (*callback) (void *) - connector's callback.
64 Argument must be dereferenced to struct cn_msg *.
65
66void cn_del_callback(struct cb_id *id);
67
68Unregisters new callback with connector core.
69
70struct cb_id *id - unique connector's user identifier.
71
72void cn_netlink_send(struct cn_msg *msg, u32 __groups, int gfp_mask);
73
74Sends message to the specified groups. It can be safely called from
75any context, but may silently fail under strong memory pressure.
76
77struct cn_msg * - message header(with attached data).
78u32 __group - destination group.
79 If __group is zero, then appropriate group will
80 be searched through all registered connector users,
81 and message will be delivered to the group which was
82 created for user with the same ID as in msg.
83 If __group is not zero, then message will be delivered
84 to the specified group.
85int gfp_mask - GFP mask.
86
87Note: When registering new callback user, connector core assigns
88netlink group to the user which is equal to it's id.idx.
89
90/*****************************************/
91Protocol description.
92/*****************************************/
93
94Current offers transport layer with fixed header. Recommended
95protocol which uses such header is following:
96
97msg->seq and msg->ack are used to determine message genealogy. When
98someone sends message it puts there locally unique sequence and random
99acknowledge numbers. Sequence number may be copied into
100nlmsghdr->nlmsg_seq too.
101
102Sequence number is incremented with each message to be sent.
103
104If we expect reply to our message, then sequence number in received
105message MUST be the same as in original message, and acknowledge
106number MUST be the same + 1.
107
108If we receive message and it's sequence number is not equal to one we
109are expecting, then it is new message. If we receive message and it's
110sequence number is the same as one we are expecting, but it's
111acknowledge is not equal acknowledge number in original message + 1,
112then it is new message.
113
114Obviously, protocol header contains above id.
115
116connector allows event notification in the following form: kernel
117driver or userspace process can ask connector to notify it when
118selected id's will be turned on or off(registered or unregistered it's
119callback). It is done by sending special command to connector
120driver(it also registers itself with id={-1, -1}).
121
122As example of usage Documentation/connector now contains cn_test.c -
123testing module which uses connector to request notification and to
124send messages.
125
126/*****************************************/
127Reliability.
128/*****************************************/
129
130Netlink itself is not reliable protocol, that means that messages can
131be lost due to memory pressure or process' receiving queue overflowed,
132so caller is warned must be prepared. That is why struct cn_msg [main
133connector's message header] contains u32 seq and u32 ack fields.
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index 96bea278bbf6..24adfe9af3ca 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -55,6 +55,7 @@ aic7*seq.h*
55aicasm 55aicasm
56aicdb.h* 56aicdb.h*
57asm 57asm
58asm-offsets.*
58asm_offsets.* 59asm_offsets.*
59autoconf.h* 60autoconf.h*
60bbootsect 61bbootsect
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 784e08c1c80a..b67189a8d8d4 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -17,15 +17,6 @@ Who: Greg Kroah-Hartman <greg@kroah.com>
17 17
18--------------------------- 18---------------------------
19 19
20What: io_remap_page_range() (macro or function)
21When: September 2005
22Why: Replaced by io_remap_pfn_range() which allows more memory space
23 addressabilty (by using a pfn) and supports sparc & sparc64
24 iospace as part of the pfn.
25Who: Randy Dunlap <rddunlap@osdl.org>
26
27---------------------------
28
29What: RAW driver (CONFIG_RAW_DRIVER) 20What: RAW driver (CONFIG_RAW_DRIVER)
30When: December 2005 21When: December 2005
31Why: declared obsolete since kernel 2.6.3 22Why: declared obsolete since kernel 2.6.3
diff --git a/Documentation/kdump/kdump.txt b/Documentation/kdump/kdump.txt
index 1f5f7d28c9e6..5f08f9ce6046 100644
--- a/Documentation/kdump/kdump.txt
+++ b/Documentation/kdump/kdump.txt
@@ -66,11 +66,11 @@ SETUP
66 c) Enable "/proc/vmcore support" (Optional, in Pseudo filesystems). 66 c) Enable "/proc/vmcore support" (Optional, in Pseudo filesystems).
67 CONFIG_PROC_VMCORE=y 67 CONFIG_PROC_VMCORE=y
68 d) Disable SMP support and build a UP kernel (Until it is fixed). 68 d) Disable SMP support and build a UP kernel (Until it is fixed).
69 CONFIG_SMP=n 69 CONFIG_SMP=n
70 e) Enable "Local APIC support on uniprocessors". 70 e) Enable "Local APIC support on uniprocessors".
71 CONFIG_X86_UP_APIC=y 71 CONFIG_X86_UP_APIC=y
72 f) Enable "IO-APIC support on uniprocessors" 72 f) Enable "IO-APIC support on uniprocessors"
73 CONFIG_X86_UP_IOAPIC=y 73 CONFIG_X86_UP_IOAPIC=y
74 74
75 Note: i) Options a) and b) depend upon "Configure standard kernel features 75 Note: i) Options a) and b) depend upon "Configure standard kernel features
76 (for small systems)" (under General setup). 76 (for small systems)" (under General setup).
@@ -95,6 +95,11 @@ SETUP
95 hence have memory less than 4GB. 95 hence have memory less than 4GB.
96 iii) Specify "irqpoll" as command line parameter. This reduces driver 96 iii) Specify "irqpoll" as command line parameter. This reduces driver
97 initialization failures in second kernel due to shared interrupts. 97 initialization failures in second kernel due to shared interrupts.
98 iv) <root-dev> needs to be specified in a format corresponding to
99 the root device name in the output of mount command.
100 v) If you have built the drivers required to mount root file
101 system as modules in <second-kernel>, then, specify
102 --initrd=<initrd-for-second-kernel>.
98 103
995) System reboots into the second kernel when a panic occurs. A module can be 1045) System reboots into the second kernel when a panic occurs. A module can be
100 written to force the panic or "ALT-SysRq-c" can be used initiate a crash 105 written to force the panic or "ALT-SysRq-c" can be used initiate a crash
diff --git a/Documentation/oops-tracing.txt b/Documentation/oops-tracing.txt
index da711028e5f7..66eaaab7773d 100644
--- a/Documentation/oops-tracing.txt
+++ b/Documentation/oops-tracing.txt
@@ -205,8 +205,8 @@ Phone: 701-234-7556
205Tainted kernels: 205Tainted kernels:
206 206
207Some oops reports contain the string 'Tainted: ' after the program 207Some oops reports contain the string 'Tainted: ' after the program
208counter, this indicates that the kernel has been tainted by some 208counter. This indicates that the kernel has been tainted by some
209mechanism. The string is followed by a series of position sensitive 209mechanism. The string is followed by a series of position-sensitive
210characters, each representing a particular tainted value. 210characters, each representing a particular tainted value.
211 211
212 1: 'G' if all modules loaded have a GPL or compatible license, 'P' if 212 1: 'G' if all modules loaded have a GPL or compatible license, 'P' if
@@ -214,16 +214,25 @@ characters, each representing a particular tainted value.
214 MODULE_LICENSE or with a MODULE_LICENSE that is not recognised by 214 MODULE_LICENSE or with a MODULE_LICENSE that is not recognised by
215 insmod as GPL compatible are assumed to be proprietary. 215 insmod as GPL compatible are assumed to be proprietary.
216 216
217 2: 'F' if any module was force loaded by insmod -f, ' ' if all 217 2: 'F' if any module was force loaded by "insmod -f", ' ' if all
218 modules were loaded normally. 218 modules were loaded normally.
219 219
220 3: 'S' if the oops occurred on an SMP kernel running on hardware that 220 3: 'S' if the oops occurred on an SMP kernel running on hardware that
221 hasn't been certified as safe to run multiprocessor. 221 hasn't been certified as safe to run multiprocessor.
222 Currently this occurs only on various Athlons that are not 222 Currently this occurs only on various Athlons that are not
223 SMP capable. 223 SMP capable.
224
225 4: 'R' if a module was force unloaded by "rmmod -f", ' ' if all
226 modules were unloaded normally.
227
228 5: 'M' if any processor has reported a Machine Check Exception,
229 ' ' if no Machine Check Exceptions have occurred.
230
231 6: 'B' if a page-release function has found a bad page reference or
232 some unexpected page flags.
224 233
225The primary reason for the 'Tainted: ' string is to tell kernel 234The primary reason for the 'Tainted: ' string is to tell kernel
226debuggers if this is a clean kernel or if anything unusual has 235debuggers if this is a clean kernel or if anything unusual has
227occurred. Tainting is permanent, even if an offending module is 236occurred. Tainting is permanent: even if an offending module is
228unloading the tainted value remains to indicate that the kernel is not 237unloaded, the tainted value remains to indicate that the kernel is not
229trustworthy. 238trustworthy.
diff --git a/Documentation/pm.txt b/Documentation/pm.txt
index cc63ae18d147..2ea1149bf6b0 100644
--- a/Documentation/pm.txt
+++ b/Documentation/pm.txt
@@ -38,6 +38,12 @@ system the associated daemon will exit gracefully.
38 38
39Driver Interface -- OBSOLETE, DO NOT USE! 39Driver Interface -- OBSOLETE, DO NOT USE!
40----------------************************* 40----------------*************************
41
42Note: pm_register(), pm_access(), pm_dev_idle() and friends are
43obsolete. Please do not use them. Instead you should properly hook
44your driver into the driver model, and use its suspend()/resume()
45callbacks to do this kind of stuff.
46
41If you are writing a new driver or maintaining an old driver, it 47If you are writing a new driver or maintaining an old driver, it
42should include power management support. Without power management 48should include power management support. Without power management
43support, a single driver may prevent a system with power management 49support, a single driver may prevent a system with power management
diff --git a/Documentation/scsi/00-INDEX b/Documentation/scsi/00-INDEX
index f9cb5bdcce41..fef92ebf266f 100644
--- a/Documentation/scsi/00-INDEX
+++ b/Documentation/scsi/00-INDEX
@@ -60,6 +60,8 @@ scsi.txt
60 - short blurb on using SCSI support as a module. 60 - short blurb on using SCSI support as a module.
61scsi_mid_low_api.txt 61scsi_mid_low_api.txt
62 - info on API between SCSI layer and low level drivers 62 - info on API between SCSI layer and low level drivers
63scsi_eh.txt
64 - info on SCSI midlayer error handling infrastructure
63st.txt 65st.txt
64 - info on scsi tape driver 66 - info on scsi tape driver
65sym53c500_cs.txt 67sym53c500_cs.txt
diff --git a/Documentation/scsi/scsi_eh.txt b/Documentation/scsi/scsi_eh.txt
new file mode 100644
index 000000000000..534a50922a7b
--- /dev/null
+++ b/Documentation/scsi/scsi_eh.txt
@@ -0,0 +1,479 @@
1
2SCSI EH
3======================================
4
5 This document describes SCSI midlayer error handling infrastructure.
6Please refer to Documentation/scsi/scsi_mid_low_api.txt for more
7information regarding SCSI midlayer.
8
9TABLE OF CONTENTS
10
11[1] How SCSI commands travel through the midlayer and to EH
12 [1-1] struct scsi_cmnd
13 [1-2] How do scmd's get completed?
14 [1-2-1] Completing a scmd w/ scsi_done
15 [1-2-2] Completing a scmd w/ timeout
16 [1-3] How EH takes over
17[2] How SCSI EH works
18 [2-1] EH through fine-grained callbacks
19 [2-1-1] Overview
20 [2-1-2] Flow of scmds through EH
21 [2-1-3] Flow of control
22 [2-2] EH through hostt->eh_strategy_handler()
23 [2-2-1] Pre hostt->eh_strategy_handler() SCSI midlayer conditions
24 [2-2-2] Post hostt->eh_strategy_handler() SCSI midlayer conditions
25 [2-2-3] Things to consider
26
27
28[1] How SCSI commands travel through the midlayer and to EH
29
30[1-1] struct scsi_cmnd
31
32 Each SCSI command is represented with struct scsi_cmnd (== scmd). A
33scmd has two list_head's to link itself into lists. The two are
34scmd->list and scmd->eh_entry. The former is used for free list or
35per-device allocated scmd list and not of much interest to this EH
36discussion. The latter is used for completion and EH lists and unless
37otherwise stated scmds are always linked using scmd->eh_entry in this
38discussion.
39
40
41[1-2] How do scmd's get completed?
42
43 Once LLDD gets hold of a scmd, either the LLDD will complete the
44command by calling scsi_done callback passed from midlayer when
45invoking hostt->queuecommand() or SCSI midlayer will time it out.
46
47
48[1-2-1] Completing a scmd w/ scsi_done
49
50 For all non-EH commands, scsi_done() is the completion callback. It
51does the following.
52
53 1. Delete timeout timer. If it fails, it means that timeout timer
54 has expired and is going to finish the command. Just return.
55
56 2. Link scmd to per-cpu scsi_done_q using scmd->en_entry
57
58 3. Raise SCSI_SOFTIRQ
59
60 SCSI_SOFTIRQ handler scsi_softirq calls scsi_decide_disposition() to
61determine what to do with the command. scsi_decide_disposition()
62looks at the scmd->result value and sense data to determine what to do
63with the command.
64
65 - SUCCESS
66 scsi_finish_command() is invoked for the command. The
67 function does some maintenance choirs and notify completion by
68 calling scmd->done() callback, which, for fs requests, would
69 be HLD completion callback - sd:sd_rw_intr, sr:rw_intr,
70 st:st_intr.
71
72 - NEEDS_RETRY
73 - ADD_TO_MLQUEUE
74 scmd is requeued to blk queue.
75
76 - otherwise
77 scsi_eh_scmd_add(scmd, 0) is invoked for the command. See
78 [1-3] for details of this funciton.
79
80
81[1-2-2] Completing a scmd w/ timeout
82
83 The timeout handler is scsi_times_out(). When a timeout occurs, this
84function
85
86 1. invokes optional hostt->eh_timedout() callback. Return value can
87 be one of
88
89 - EH_HANDLED
90 This indicates that eh_timedout() dealt with the timeout. The
91 scmd is passed to __scsi_done() and thus linked into per-cpu
92 scsi_done_q. Normal command completion described in [1-2-1]
93 follows.
94
95 - EH_RESET_TIMER
96 This indicates that more time is required to finish the
97 command. Timer is restarted. This action is counted as a
98 retry and only allowed scmd->allowed + 1(!) times. Once the
99 limit is reached, action for EH_NOT_HANDLED is taken instead.
100
101 *NOTE* This action is racy as the LLDD could finish the scmd
102 after the timeout has expired but before it's added back. In
103 such cases, scsi_done() would think that timeout has occurred
104 and return without doing anything. We lose completion and the
105 command will time out again.
106
107 - EH_NOT_HANDLED
108 This is the same as when eh_timedout() callback doesn't exist.
109 Step #2 is taken.
110
111 2. scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD) is invoked for the
112 command. See [1-3] for more information.
113
114
115[1-3] How EH takes over
116
117 scmds enter EH via scsi_eh_scmd_add(), which does the following.
118
119 1. Turns on scmd->eh_eflags as requested. It's 0 for error
120 completions and SCSI_EH_CANCEL_CMD for timeouts.
121
122 2. Links scmd->eh_entry to shost->eh_cmd_q
123
124 3. Sets SHOST_RECOVERY bit in shost->shost_state
125
126 4. Increments shost->host_failed
127
128 5. Wakes up SCSI EH thread if shost->host_busy == shost->host_failed
129
130 As can be seen above, once any scmd is added to shost->eh_cmd_q,
131SHOST_RECOVERY shost_state bit is turned on. This prevents any new
132scmd to be issued from blk queue to the host; eventually, all scmds on
133the host either complete normally, fail and get added to eh_cmd_q, or
134time out and get added to shost->eh_cmd_q.
135
136 If all scmds either complete or fail, the number of in-flight scmds
137becomes equal to the number of failed scmds - i.e. shost->host_busy ==
138shost->host_failed. This wakes up SCSI EH thread. So, once woken up,
139SCSI EH thread can expect that all in-flight commands have failed and
140are linked on shost->eh_cmd_q.
141
142 Note that this does not mean lower layers are quiescent. If a LLDD
143completed a scmd with error status, the LLDD and lower layers are
144assumed to forget about the scmd at that point. However, if a scmd
145has timed out, unless hostt->eh_timedout() made lower layers forget
146about the scmd, which currently no LLDD does, the command is still
147active as long as lower layers are concerned and completion could
148occur at any time. Of course, all such completions are ignored as the
149timer has already expired.
150
151 We'll talk about how SCSI EH takes actions to abort - make LLDD
152forget about - timed out scmds later.
153
154
155[2] How SCSI EH works
156
157 LLDD's can implement SCSI EH actions in one of the following two
158ways.
159
160 - Fine-grained EH callbacks
161 LLDD can implement fine-grained EH callbacks and let SCSI
162 midlayer drive error handling and call appropriate callbacks.
163 This will be dicussed further in [2-1].
164
165 - eh_strategy_handler() callback
166 This is one big callback which should perform whole error
167 handling. As such, it should do all choirs SCSI midlayer
168 performs during recovery. This will be discussed in [2-2].
169
170 Once recovery is complete, SCSI EH resumes normal operation by
171calling scsi_restart_operations(), which
172
173 1. Checks if door locking is needed and locks door.
174
175 2. Clears SHOST_RECOVERY shost_state bit
176
177 3. Wakes up waiters on shost->host_wait. This occurs if someone
178 calls scsi_block_when_processing_errors() on the host.
179 (*QUESTION* why is it needed? All operations will be blocked
180 anyway after it reaches blk queue.)
181
182 4. Kicks queues in all devices on the host in the asses
183
184
185[2-1] EH through fine-grained callbacks
186
187[2-1-1] Overview
188
189 If eh_strategy_handler() is not present, SCSI midlayer takes charge
190of driving error handling. EH's goals are two - make LLDD, host and
191device forget about timed out scmds and make them ready for new
192commands. A scmd is said to be recovered if the scmd is forgotten by
193lower layers and lower layers are ready to process or fail the scmd
194again.
195
196 To achieve these goals, EH performs recovery actions with increasing
197severity. Some actions are performed by issueing SCSI commands and
198others are performed by invoking one of the following fine-grained
199hostt EH callbacks. Callbacks may be omitted and omitted ones are
200considered to fail always.
201
202int (* eh_abort_handler)(struct scsi_cmnd *);
203int (* eh_device_reset_handler)(struct scsi_cmnd *);
204int (* eh_bus_reset_handler)(struct scsi_cmnd *);
205int (* eh_host_reset_handler)(struct scsi_cmnd *);
206
207 Higher-severity actions are taken only when lower-severity actions
208cannot recover some of failed scmds. Also, note that failure of the
209highest-severity action means EH failure and results in offlining of
210all unrecovered devices.
211
212 During recovery, the following rules are followed
213
214 - Recovery actions are performed on failed scmds on the to do list,
215 eh_work_q. If a recovery action succeeds for a scmd, recovered
216 scmds are removed from eh_work_q.
217
218 Note that single recovery action on a scmd can recover multiple
219 scmds. e.g. resetting a device recovers all failed scmds on the
220 device.
221
222 - Higher severity actions are taken iff eh_work_q is not empty after
223 lower severity actions are complete.
224
225 - EH reuses failed scmds to issue commands for recovery. For
226 timed-out scmds, SCSI EH ensures that LLDD forgets about a scmd
227 before reusing it for EH commands.
228
229 When a scmd is recovered, the scmd is moved from eh_work_q to EH
230local eh_done_q using scsi_eh_finish_cmd(). After all scmds are
231recovered (eh_work_q is empty), scsi_eh_flush_done_q() is invoked to
232either retry or error-finish (notify upper layer of failure) recovered
233scmds.
234
235 scmds are retried iff its sdev is still online (not offlined during
236EH), REQ_FAILFAST is not set and ++scmd->retries is less than
237scmd->allowed.
238
239
240[2-1-2] Flow of scmds through EH
241
242 1. Error completion / time out
243 ACTION: scsi_eh_scmd_add() is invoked for scmd
244 - set scmd->eh_eflags
245 - add scmd to shost->eh_cmd_q
246 - set SHOST_RECOVERY
247 - shost->host_failed++
248 LOCKING: shost->host_lock
249
250 2. EH starts
251 ACTION: move all scmds to EH's local eh_work_q. shost->eh_cmd_q
252 is cleared.
253 LOCKING: shost->host_lock (not strictly necessary, just for
254 consistency)
255
256 3. scmd recovered
257 ACTION: scsi_eh_finish_cmd() is invoked to EH-finish scmd
258 - shost->host_failed--
259 - clear scmd->eh_eflags
260 - scsi_setup_cmd_retry()
261 - move from local eh_work_q to local eh_done_q
262 LOCKING: none
263
264 4. EH completes
265 ACTION: scsi_eh_flush_done_q() retries scmds or notifies upper
266 layer of failure.
267 - scmd is removed from eh_done_q and scmd->eh_entry is cleared
268 - if retry is necessary, scmd is requeued using
269 scsi_queue_insert()
270 - otherwise, scsi_finish_command() is invoked for scmd
271 LOCKING: queue or finish function performs appropriate locking
272
273
274[2-1-3] Flow of control
275
276 EH through fine-grained callbacks start from scsi_unjam_host().
277
278<<scsi_unjam_host>>
279
280 1. Lock shost->host_lock, splice_init shost->eh_cmd_q into local
281 eh_work_q and unlock host_lock. Note that shost->eh_cmd_q is
282 cleared by this action.
283
284 2. Invoke scsi_eh_get_sense.
285
286 <<scsi_eh_get_sense>>
287
288 This action is taken for each error-completed
289 (!SCSI_EH_CANCEL_CMD) commands without valid sense data. Most
290 SCSI transports/LLDDs automatically acquire sense data on
291 command failures (autosense). Autosense is recommended for
292 performance reasons and as sense information could get out of
293 sync inbetween occurrence of CHECK CONDITION and this action.
294
295 Note that if autosense is not supported, scmd->sense_buffer
296 contains invalid sense data when error-completing the scmd
297 with scsi_done(). scsi_decide_disposition() always returns
298 FAILED in such cases thus invoking SCSI EH. When the scmd
299 reaches here, sense data is acquired and
300 scsi_decide_disposition() is called again.
301
302 1. Invoke scsi_request_sense() which issues REQUEST_SENSE
303 command. If fails, no action. Note that taking no action
304 causes higher-severity recovery to be taken for the scmd.
305
306 2. Invoke scsi_decide_disposition() on the scmd
307
308 - SUCCESS
309 scmd->retries is set to scmd->allowed preventing
310 scsi_eh_flush_done_q() from retrying the scmd and
311 scsi_eh_finish_cmd() is invoked.
312
313 - NEEDS_RETRY
314 scsi_eh_finish_cmd() invoked
315
316 - otherwise
317 No action.
318
319 3. If !list_empty(&eh_work_q), invoke scsi_eh_abort_cmds().
320
321 <<scsi_eh_abort_cmds>>
322
323 This action is taken for each timed out command.
324 hostt->eh_abort_handler() is invoked for each scmd. The
325 handler returns SUCCESS if it has succeeded to make LLDD and
326 all related hardware forget about the scmd.
327
328 If a timedout scmd is successfully aborted and the sdev is
329 either offline or ready, scsi_eh_finish_cmd() is invoked for
330 the scmd. Otherwise, the scmd is left in eh_work_q for
331 higher-severity actions.
332
333 Note that both offline and ready status mean that the sdev is
334 ready to process new scmds, where processing also implies
335 immediate failing; thus, if a sdev is in one of the two
336 states, no further recovery action is needed.
337
338 Device readiness is tested using scsi_eh_tur() which issues
339 TEST_UNIT_READY command. Note that the scmd must have been
340 aborted successfully before reusing it for TEST_UNIT_READY.
341
342 4. If !list_empty(&eh_work_q), invoke scsi_eh_ready_devs()
343
344 <<scsi_eh_ready_devs>>
345
346 This function takes four increasingly more severe measures to
347 make failed sdevs ready for new commands.
348
349 1. Invoke scsi_eh_stu()
350
351 <<scsi_eh_stu>>
352
353 For each sdev which has failed scmds with valid sense data
354 of which scsi_check_sense()'s verdict is FAILED,
355 START_STOP_UNIT command is issued w/ start=1. Note that
356 as we explicitly choose error-completed scmds, it is known
357 that lower layers have forgotten about the scmd and we can
358 reuse it for STU.
359
360 If STU succeeds and the sdev is either offline or ready,
361 all failed scmds on the sdev are EH-finished with
362 scsi_eh_finish_cmd().
363
364 *NOTE* If hostt->eh_abort_handler() isn't implemented or
365 failed, we may still have timed out scmds at this point
366 and STU doesn't make lower layers forget about those
367 scmds. Yet, this function EH-finish all scmds on the sdev
368 if STU succeeds leaving lower layers in an inconsistent
369 state. It seems that STU action should be taken only when
370 a sdev has no timed out scmd.
371
372 2. If !list_empty(&eh_work_q), invoke scsi_eh_bus_device_reset().
373
374 <<scsi_eh_bus_device_reset>>
375
376 This action is very similar to scsi_eh_stu() except that,
377 instead of issuing STU, hostt->eh_device_reset_handler()
378 is used. Also, as we're not issuing SCSI commands and
379 resetting clears all scmds on the sdev, there is no need
380 to choose error-completed scmds.
381
382 3. If !list_empty(&eh_work_q), invoke scsi_eh_bus_reset()
383
384 <<scsi_eh_bus_reset>>
385
386 hostt->eh_bus_reset_handler() is invoked for each channel
387 with failed scmds. If bus reset succeeds, all failed
388 scmds on all ready or offline sdevs on the channel are
389 EH-finished.
390
391 4. If !list_empty(&eh_work_q), invoke scsi_eh_host_reset()
392
393 <<scsi_eh_host_reset>>
394
395 This is the last resort. hostt->eh_host_reset_handler()
396 is invoked. If host reset succeeds, all failed scmds on
397 all ready or offline sdevs on the host are EH-finished.
398
399 5. If !list_empty(&eh_work_q), invoke scsi_eh_offline_sdevs()
400
401 <<scsi_eh_offline_sdevs>>
402
403 Take all sdevs which still have unrecovered scmds offline
404 and EH-finish the scmds.
405
406 5. Invoke scsi_eh_flush_done_q().
407
408 <<scsi_eh_flush_done_q>>
409
410 At this point all scmds are recovered (or given up) and
411 put on eh_done_q by scsi_eh_finish_cmd(). This function
412 flushes eh_done_q by either retrying or notifying upper
413 layer of failure of the scmds.
414
415
416[2-2] EH through hostt->eh_strategy_handler()
417
418 hostt->eh_strategy_handler() is invoked in the place of
419scsi_unjam_host() and it is responsible for whole recovery process.
420On completion, the handler should have made lower layers forget about
421all failed scmds and either ready for new commands or offline. Also,
422it should perform SCSI EH maintenance choirs to maintain integrity of
423SCSI midlayer. IOW, of the steps described in [2-1-2], all steps
424except for #1 must be implemented by eh_strategy_handler().
425
426
427[2-2-1] Pre hostt->eh_strategy_handler() SCSI midlayer conditions
428
429 The following conditions are true on entry to the handler.
430
431 - Each failed scmd's eh_flags field is set appropriately.
432
433 - Each failed scmd is linked on scmd->eh_cmd_q by scmd->eh_entry.
434
435 - SHOST_RECOVERY is set.
436
437 - shost->host_failed == shost->host_busy
438
439
440[2-2-2] Post hostt->eh_strategy_handler() SCSI midlayer conditions
441
442 The following conditions must be true on exit from the handler.
443
444 - shost->host_failed is zero.
445
446 - Each scmd's eh_eflags field is cleared.
447
448 - Each scmd is in such a state that scsi_setup_cmd_retry() on the
449 scmd doesn't make any difference.
450
451 - shost->eh_cmd_q is cleared.
452
453 - Each scmd->eh_entry is cleared.
454
455 - Either scsi_queue_insert() or scsi_finish_command() is called on
456 each scmd. Note that the handler is free to use scmd->retries and
457 ->allowed to limit the number of retries.
458
459
460[2-2-3] Things to consider
461
462 - Know that timed out scmds are still active on lower layers. Make
463 lower layers forget about them before doing anything else with
464 those scmds.
465
466 - For consistency, when accessing/modifying shost data structure,
467 grab shost->host_lock.
468
469 - On completion, each failed sdev must have forgotten about all
470 active scmds.
471
472 - On completion, each failed sdev must be ready for new commands or
473 offline.
474
475
476--
477Tejun Heo
478htejun@gmail.com
47911th September 2005
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index ebfcdf28485f..13cba955cb5a 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -75,7 +75,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
75 adsp_map - PCM device number maps assigned to the 2st OSS device. 75 adsp_map - PCM device number maps assigned to the 2st OSS device.
76 - Default: 1 76 - Default: 1
77 nonblock_open 77 nonblock_open
78 - Don't block opening busy PCM devices. 78 - Don't block opening busy PCM devices. Default: 1
79 79
80 For example, when dsp_map=2, /dev/dsp will be mapped to PCM #2 of 80 For example, when dsp_map=2, /dev/dsp will be mapped to PCM #2 of
81 the card #0. Similarly, when adsp_map=0, /dev/adsp will be mapped 81 the card #0. Similarly, when adsp_map=0, /dev/adsp will be mapped
@@ -148,6 +148,16 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
148 Module supports up to 8 cards. This module does not support autoprobe 148 Module supports up to 8 cards. This module does not support autoprobe
149 thus main port must be specified!!! Other ports are optional. 149 thus main port must be specified!!! Other ports are optional.
150 150
151 Module snd-ad1889
152 -----------------
153
154 Module for Analog Devices AD1889 chips.
155
156 ac97_quirk - AC'97 workaround for strange hardware
157 See the description of intel8x0 module for details.
158
159 This module supports up to 8 cards.
160
151 Module snd-ali5451 161 Module snd-ali5451
152 ------------------ 162 ------------------
153 163
@@ -189,15 +199,20 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
189 Module snd-atiixp 199 Module snd-atiixp
190 ----------------- 200 -----------------
191 201
192 Module for ATI IXP 150/200/250 AC97 controllers. 202 Module for ATI IXP 150/200/250/400 AC97 controllers.
193 203
194 ac97_clock - AC'97 clock (defalut = 48000) 204 ac97_clock - AC'97 clock (default = 48000)
195 ac97_quirk - AC'97 workaround for strange hardware 205 ac97_quirk - AC'97 workaround for strange hardware
196 See the description of intel8x0 module for details. 206 See "AC97 Quirk Option" section below.
197 spdif_aclink - S/PDIF transfer over AC-link (default = 1) 207 spdif_aclink - S/PDIF transfer over AC-link (default = 1)
198 208
199 This module supports up to 8 cards and autoprobe. 209 This module supports up to 8 cards and autoprobe.
200 210
211 ATI IXP has two different methods to control SPDIF output. One is
212 over AC-link and another is over the "direct" SPDIF output. The
213 implementation depends on the motherboard, and you'll need to
214 choose the correct one via spdif_aclink module option.
215
201 Module snd-atiixp-modem 216 Module snd-atiixp-modem
202 ----------------------- 217 -----------------------
203 218
@@ -230,7 +245,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
230 The hardware EQ hardware and SPDIF is only present in the Vortex2 and 245 The hardware EQ hardware and SPDIF is only present in the Vortex2 and
231 Advantage. 246 Advantage.
232 247
233 Note: Some ALSA mixer applicactions don't handle the SPDIF samplerate 248 Note: Some ALSA mixer applications don't handle the SPDIF sample rate
234 control correctly. If you have problems regarding this, try 249 control correctly. If you have problems regarding this, try
235 another ALSA compliant mixer (alsamixer works). 250 another ALSA compliant mixer (alsamixer works).
236 251
@@ -302,7 +317,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
302 317
303 mpu_port - 0x300,0x310,0x320,0x330, 0 = disable (default) 318 mpu_port - 0x300,0x310,0x320,0x330, 0 = disable (default)
304 fm_port - 0x388 (default), 0 = disable (default) 319 fm_port - 0x388 (default), 0 = disable (default)
305 soft_ac3 - Sofware-conversion of raw SPDIF packets (model 033 only) 320 soft_ac3 - Software-conversion of raw SPDIF packets (model 033 only)
306 (default = 1) 321 (default = 1)
307 joystick_port - Joystick port address (0 = disable, 1 = auto-detect) 322 joystick_port - Joystick port address (0 = disable, 1 = auto-detect)
308 323
@@ -384,7 +399,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
384 Module for PCI sound cards based on CS4610/CS4612/CS4614/CS4615/CS4622/ 399 Module for PCI sound cards based on CS4610/CS4612/CS4614/CS4615/CS4622/
385 CS4624/CS4630/CS4280 PCI chips. 400 CS4624/CS4630/CS4280 PCI chips.
386 401
387 external_amp - Force to enable external amplifer. 402 external_amp - Force to enable external amplifier.
388 thinkpad - Force to enable Thinkpad's CLKRUN control. 403 thinkpad - Force to enable Thinkpad's CLKRUN control.
389 mmap_valid - Support OSS mmap mode (default = 0). 404 mmap_valid - Support OSS mmap mode (default = 0).
390 405
@@ -620,7 +635,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
620 VIA VT8251/VT8237A 635 VIA VT8251/VT8237A
621 636
622 model - force the model name 637 model - force the model name
623 position_fix - Fix DMA pointer (0 = FIFO size, 1 = none, 2 = POSBUF) 638 position_fix - Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size)
624 639
625 Module supports up to 8 cards. 640 Module supports up to 8 cards.
626 641
@@ -656,6 +671,11 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
656 allout 5-jack in back, 2-jack in front, SPDIF out 671 allout 5-jack in back, 2-jack in front, SPDIF out
657 auto auto-config reading BIOS (default) 672 auto auto-config reading BIOS (default)
658 673
674 If the default configuration doesn't work and one of the above
675 matches with your device, report it together with the PCI
676 subsystem ID (output of "lspci -nv") to ALSA BTS or alsa-devel
677 ML (see the section "Links and Addresses").
678
659 Note 2: If you get click noises on output, try the module option 679 Note 2: If you get click noises on output, try the module option
660 position_fix=1 or 2. position_fix=1 will use the SD_LPIB 680 position_fix=1 or 2. position_fix=1 will use the SD_LPIB
661 register value without FIFO size correction as the current 681 register value without FIFO size correction as the current
@@ -783,20 +803,13 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
783 803
784 ac97_clock - AC'97 codec clock base (0 = auto-detect) 804 ac97_clock - AC'97 codec clock base (0 = auto-detect)
785 ac97_quirk - AC'97 workaround for strange hardware 805 ac97_quirk - AC'97 workaround for strange hardware
786 The following strings are accepted: 806 See "AC97 Quirk Option" section below.
787 default = don't override the default setting
788 disable = disable the quirk
789 hp_only = use headphone control as master
790 swap_hp = swap headphone and master controls
791 swap_surround = swap master and surround controls
792 ad_sharing = for AD1985, turn on OMS bit and use headphone
793 alc_jack = for ALC65x, turn on the jack sense mode
794 inv_eapd = inverted EAPD implementation
795 mute_led = bind EAPD bit for turning on/off mute LED
796 For backward compatibility, the corresponding integer
797 value -1, 0, ... are accepted, too.
798 buggy_irq - Enable workaround for buggy interrupts on some 807 buggy_irq - Enable workaround for buggy interrupts on some
799 motherboards (default off) 808 motherboards (default yes on nForce chips,
809 otherwise off)
810 buggy_semaphore - Enable workaround for hardwares with buggy
811 semaphores (e.g. on some ASUS laptops)
812 (default off)
800 813
801 Module supports autoprobe and multiple bus-master chips (max 8). 814 Module supports autoprobe and multiple bus-master chips (max 8).
802 815
@@ -808,13 +821,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
808 motherboard has these devices, use the ns558 or snd-mpu401 821 motherboard has these devices, use the ns558 or snd-mpu401
809 modules, respectively. 822 modules, respectively.
810 823
811 The ac97_quirk option is used to enable/override the workaround
812 for specific devices. Some hardware have swapped output pins
813 between Master and Headphone, or Surround. The driver provides
814 the auto-detection of known problematic devices, but some might
815 be unknown or wrongly detected. In such a case, pass the proper
816 value with this option.
817
818 The power-management is supported. 824 The power-management is supported.
819 825
820 Module snd-intel8x0m 826 Module snd-intel8x0m
@@ -966,7 +972,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
966 with machines with other (most likely CS423x or OPL3SAx) chips, 972 with machines with other (most likely CS423x or OPL3SAx) chips,
967 even though the device is detected in lspci. In such a case, try 973 even though the device is detected in lspci. In such a case, try
968 other drivers, e.g. snd-cs4232 or snd-opl3sa2. Some has ISA-PnP 974 other drivers, e.g. snd-cs4232 or snd-opl3sa2. Some has ISA-PnP
969 but some doesn't have ISA PnP. You'll need to speicfy isapnp=0 975 but some doesn't have ISA PnP. You'll need to specify isapnp=0
970 and proper hardware parameters in the case without ISA PnP. 976 and proper hardware parameters in the case without ISA PnP.
971 977
972 Note: some laptops need a workaround for AC97 RESET. For the 978 Note: some laptops need a workaround for AC97 RESET. For the
@@ -1302,7 +1308,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1302 channels 1308 channels
1303 [VIA8233/C, 8235, 8237 only] 1309 [VIA8233/C, 8235, 8237 only]
1304 ac97_quirk - AC'97 workaround for strange hardware 1310 ac97_quirk - AC'97 workaround for strange hardware
1305 See the description of intel8x0 module for details. 1311 See "AC97 Quirk Option" section below.
1306 1312
1307 Module supports autoprobe and multiple bus-master chips (max 8). 1313 Module supports autoprobe and multiple bus-master chips (max 8).
1308 1314
@@ -1327,16 +1333,17 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1327 "lspci -nv"). 1333 "lspci -nv").
1328 If dxs_support=5 does not work, try dxs_support=4; if it 1334 If dxs_support=5 does not work, try dxs_support=4; if it
1329 doesn't work too, try dxs_support=1. (dxs_support=1 is 1335 doesn't work too, try dxs_support=1. (dxs_support=1 is
1330 usually for old motherboards. The correct implementated 1336 usually for old motherboards. The correct implemented
1331 board should work with 4 or 5.) If it still doesn't 1337 board should work with 4 or 5.) If it still doesn't
1332 work and the default setting is ok, dxs_support=3 is the 1338 work and the default setting is ok, dxs_support=3 is the
1333 right choice. If the default setting doesn't work at all, 1339 right choice. If the default setting doesn't work at all,
1334 try dxs_support=2 to disable the DXS channels. 1340 try dxs_support=2 to disable the DXS channels.
1335 In any cases, please let us know the result and the 1341 In any cases, please let us know the result and the
1336 subsystem vendor/device ids. 1342 subsystem vendor/device ids. See "Links and Addresses"
1343 below.
1337 1344
1338 Note: for the MPU401 on VIA823x, use snd-mpu401 driver 1345 Note: for the MPU401 on VIA823x, use snd-mpu401 driver
1339 additonally. The mpu_port option is for VIA686 chips only. 1346 additionally. The mpu_port option is for VIA686 chips only.
1340 1347
1341 Module snd-via82xx-modem 1348 Module snd-via82xx-modem
1342 ------------------------ 1349 ------------------------
@@ -1398,8 +1405,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1398 Module supports up to 8 cards. The module is compiled only when 1405 Module supports up to 8 cards. The module is compiled only when
1399 PCMCIA is supported on kernel. 1406 PCMCIA is supported on kernel.
1400 1407
1401 To activate the driver via the card manager, you'll need to set 1408 With the older 2.6.x kernel, to activate the driver via the card
1402 up /etc/pcmcia/vxpocket.conf. See the sound/pcmcia/vx/vxpocket.c. 1409 manager, you'll need to set up /etc/pcmcia/vxpocket.conf. See the
1410 sound/pcmcia/vx/vxpocket.c. 2.6.13 or later kernel requires no
1411 longer require a config file.
1403 1412
1404 When the driver is compiled as a module and the hotplug firmware 1413 When the driver is compiled as a module and the hotplug firmware
1405 is supported, the firmware data is loaded via hotplug automatically. 1414 is supported, the firmware data is loaded via hotplug automatically.
@@ -1411,6 +1420,9 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1411 1420
1412 Note: the driver is build only when CONFIG_ISA is set. 1421 Note: the driver is build only when CONFIG_ISA is set.
1413 1422
1423 Note2: snd-vxp440 driver is merged to snd-vxpocket driver since
1424 ALSA 1.0.10.
1425
1414 Module snd-ymfpci 1426 Module snd-ymfpci
1415 ----------------- 1427 -----------------
1416 1428
@@ -1436,6 +1448,37 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1436 Note: the driver is build only when CONFIG_ISA is set. 1448 Note: the driver is build only when CONFIG_ISA is set.
1437 1449
1438 1450
1451AC97 Quirk Option
1452=================
1453
1454The ac97_quirk option is used to enable/override the workaround for
1455specific devices on drivers for on-board AC'97 controllers like
1456snd-intel8x0. Some hardware have swapped output pins between Master
1457and Headphone, or Surround (thanks to confusion of AC'97
1458specifications from version to version :-)
1459
1460The driver provides the auto-detection of known problematic devices,
1461but some might be unknown or wrongly detected. In such a case, pass
1462the proper value with this option.
1463
1464The following strings are accepted:
1465 - default Don't override the default setting
1466 - disable Disable the quirk
1467 - hp_only Bind Master and Headphone controls as a single control
1468 - swap_hp Swap headphone and master controls
1469 - swap_surround Swap master and surround controls
1470 - ad_sharing For AD1985, turn on OMS bit and use headphone
1471 - alc_jack For ALC65x, turn on the jack sense mode
1472 - inv_eapd Inverted EAPD implementation
1473 - mute_led Bind EAPD bit for turning on/off mute LED
1474
1475For backward compatibility, the corresponding integer value -1, 0,
1476... are accepted, too.
1477
1478For example, if "Master" volume control has no effect on your device
1479but only "Headphone" does, pass ac97_quirk=hp_only module option.
1480
1481
1439Configuring Non-ISAPNP Cards 1482Configuring Non-ISAPNP Cards
1440============================ 1483============================
1441 1484
@@ -1553,6 +1596,8 @@ Proc interfaces (/proc/asound)
1553 - whole-frag write only whole fragments (optimization affecting 1596 - whole-frag write only whole fragments (optimization affecting
1554 playback only) 1597 playback only)
1555 - no-silence do not fill silence ahead to avoid clicks 1598 - no-silence do not fill silence ahead to avoid clicks
1599 - buggy-ptr Returns the whitespace blocks in GETOPTR ioctl
1600 instead of filled blocks
1556 1601
1557 Example: echo "x11amp 128 16384" > /proc/asound/card0/pcm0p/oss 1602 Example: echo "x11amp 128 16384" > /proc/asound/card0/pcm0p/oss
1558 echo "squake 0 0 disable" > /proc/asound/card0/pcm0c/oss 1603 echo "squake 0 0 disable" > /proc/asound/card0/pcm0c/oss
@@ -1589,9 +1634,14 @@ commands to the snd-page-alloc driver:
1589 use. 1634 use.
1590 1635
1591 1636
1592Links 1637Links and Addresses
1593===== 1638===================
1594 1639
1595 ALSA project homepage 1640 ALSA project homepage
1596 http://www.alsa-project.org 1641 http://www.alsa-project.org
1597 1642
1643 ALSA Bug Tracking System
1644 https://bugtrack.alsa-project.org/bugs/
1645
1646 ALSA Developers ML
1647 mailto:alsa-devel@lists.sourceforge.net
diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
index 0475478c2484..24e85520890b 100644
--- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
@@ -447,7 +447,7 @@
447 .... 447 ....
448 448
449 /* allocate a chip-specific data with zero filled */ 449 /* allocate a chip-specific data with zero filled */
450 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 450 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
451 if (chip == NULL) 451 if (chip == NULL)
452 return -ENOMEM; 452 return -ENOMEM;
453 453
@@ -949,7 +949,7 @@
949 After allocating a card instance via 949 After allocating a card instance via
950 <function>snd_card_new()</function> (with 950 <function>snd_card_new()</function> (with
951 <constant>NULL</constant> on the 4th arg), call 951 <constant>NULL</constant> on the 4th arg), call
952 <function>kcalloc()</function>. 952 <function>kzalloc()</function>.
953 953
954 <informalexample> 954 <informalexample>
955 <programlisting> 955 <programlisting>
@@ -958,7 +958,7 @@
958 mychip_t *chip; 958 mychip_t *chip;
959 card = snd_card_new(index[dev], id[dev], THIS_MODULE, NULL); 959 card = snd_card_new(index[dev], id[dev], THIS_MODULE, NULL);
960 ..... 960 .....
961 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 961 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
962]]> 962]]>
963 </programlisting> 963 </programlisting>
964 </informalexample> 964 </informalexample>
@@ -1136,7 +1136,7 @@
1136 return -ENXIO; 1136 return -ENXIO;
1137 } 1137 }
1138 1138
1139 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1139 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1140 if (chip == NULL) { 1140 if (chip == NULL) {
1141 pci_disable_device(pci); 1141 pci_disable_device(pci);
1142 return -ENOMEM; 1142 return -ENOMEM;
@@ -1292,7 +1292,7 @@
1292 need to initialize this number as -1 before actual allocation, 1292 need to initialize this number as -1 before actual allocation,
1293 since irq 0 is valid. The port address and its resource pointer 1293 since irq 0 is valid. The port address and its resource pointer
1294 can be initialized as null by 1294 can be initialized as null by
1295 <function>kcalloc()</function> automatically, so you 1295 <function>kzalloc()</function> automatically, so you
1296 don't have to take care of resetting them. 1296 don't have to take care of resetting them.
1297 </para> 1297 </para>
1298 1298
diff --git a/MAINTAINERS b/MAINTAINERS
index a67bf7d315d7..d1e0eb46d201 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -370,7 +370,10 @@ W: http://atmelwlandriver.sourceforge.net/
370S: Maintained 370S: Maintained
371 371
372AUDIT SUBSYSTEM 372AUDIT SUBSYSTEM
373L: linux-audit@redhat.com (subscribers-only) 373P: David Woodhouse
374M: dwmw2@infradead.org
375L: linux-audit@redhat.com
376W: http://people.redhat.com/sgrubb/audit/
374S: Maintained 377S: Maintained
375 378
376AX.25 NETWORK LAYER 379AX.25 NETWORK LAYER
diff --git a/Makefile b/Makefile
index 45e5a38fbc7a..4e0d7c68d223 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 13 3SUBLEVEL = 14
4EXTRAVERSION = 4EXTRAVERSION =-rc1
5NAME=Affluent Albatross 5NAME=Affluent Albatross
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index 405a55f2287c..3e5f69bb5ac4 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -20,40 +20,66 @@ config ARCH_PXA_IDP
20 select PXA25x 20 select PXA25x
21 21
22config PXA_SHARPSL 22config PXA_SHARPSL
23 bool "SHARP SL-5600 and SL-C7xx Models" 23 bool "SHARP Zaurus SL-5600, SL-C7xx and SL-Cxx00 Models"
24 select PXA25x
25 select SHARP_SCOOP 24 select SHARP_SCOOP
26 select SHARP_PARAM 25 select SHARP_PARAM
27 help 26 help
28 Say Y here if you intend to run this kernel on a 27 Say Y here if you intend to run this kernel on a
29 Sharp SL-5600 (Poodle), Sharp SL-C700 (Corgi), 28 Sharp Zaurus SL-5600 (Poodle), SL-C700 (Corgi),
30 SL-C750 (Shepherd) or a Sharp SL-C760 (Husky) 29 SL-C750 (Shepherd), SL-C760 (Husky), SL-C1000 (Akita),
31 handheld computer. 30 SL-C3000 (Spitz) or SL-C3100 (Borzoi) handheld computer.
32 31
33endchoice 32endchoice
34 33
34if PXA_SHARPSL
35
36choice
37 prompt "Select target Sharp Zaurus device range"
38
39config PXA_SHARPSL_25x
40 bool "Sharp PXA25x models (SL-5600 and SL-C7xx)"
41 select PXA25x
42
43config PXA_SHARPSL_27x
44 bool "Sharp PXA270 models (SL-Cxx00)"
45 select PXA27x
46
47endchoice
48
49endif
50
35endmenu 51endmenu
36 52
37config MACH_POODLE 53config MACH_POODLE
38 bool "Enable Sharp SL-5600 (Poodle) Support" 54 bool "Enable Sharp SL-5600 (Poodle) Support"
39 depends PXA_SHARPSL 55 depends PXA_SHARPSL_25x
40 select SHARP_LOCOMO 56 select SHARP_LOCOMO
41 57
42config MACH_CORGI 58config MACH_CORGI
43 bool "Enable Sharp SL-C700 (Corgi) Support" 59 bool "Enable Sharp SL-C700 (Corgi) Support"
44 depends PXA_SHARPSL 60 depends PXA_SHARPSL_25x
45 select PXA_SHARP_C7xx 61 select PXA_SHARP_C7xx
46 62
47config MACH_SHEPHERD 63config MACH_SHEPHERD
48 bool "Enable Sharp SL-C750 (Shepherd) Support" 64 bool "Enable Sharp SL-C750 (Shepherd) Support"
49 depends PXA_SHARPSL 65 depends PXA_SHARPSL_25x
50 select PXA_SHARP_C7xx 66 select PXA_SHARP_C7xx
51 67
52config MACH_HUSKY 68config MACH_HUSKY
53 bool "Enable Sharp SL-C760 (Husky) Support" 69 bool "Enable Sharp SL-C760 (Husky) Support"
54 depends PXA_SHARPSL 70 depends PXA_SHARPSL_25x
55 select PXA_SHARP_C7xx 71 select PXA_SHARP_C7xx
56 72
73config MACH_SPITZ
74 bool "Enable Sharp Zaurus SL-3000 (Spitz) Support"
75 depends PXA_SHARPSL_27x
76 select PXA_SHARP_Cxx00
77
78config MACH_BORZOI
79 bool "Enable Sharp Zaurus SL-3100 (Borzoi) Support"
80 depends PXA_SHARPSL_27x
81 select PXA_SHARP_Cxx00
82
57config PXA25x 83config PXA25x
58 bool 84 bool
59 help 85 help
@@ -74,4 +100,9 @@ config PXA_SHARP_C7xx
74 help 100 help
75 Enable support for all Sharp C7xx models 101 Enable support for all Sharp C7xx models
76 102
103config PXA_SHARP_Cxx00
104 bool
105 help
106 Enable common support for Sharp Cxx00 models
107
77endif 108endif
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index 33dae99ec2d8..f609a0f232cb 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_ARCH_LUBBOCK) += lubbock.o
12obj-$(CONFIG_MACH_MAINSTONE) += mainstone.o 12obj-$(CONFIG_MACH_MAINSTONE) += mainstone.o
13obj-$(CONFIG_ARCH_PXA_IDP) += idp.o 13obj-$(CONFIG_ARCH_PXA_IDP) += idp.o
14obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o corgi_ssp.o corgi_lcd.o ssp.o 14obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o corgi_ssp.o corgi_lcd.o ssp.o
15obj-$(CONFIG_PXA_SHARP_Cxx00) += spitz.o corgi_ssp.o corgi_lcd.o ssp.o
15obj-$(CONFIG_MACH_POODLE) += poodle.o 16obj-$(CONFIG_MACH_POODLE) += poodle.o
16 17
17# Support for blinky lights 18# Support for blinky lights
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index 07b5dd453565..426c2bc517eb 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -41,6 +41,7 @@
41#include <asm/hardware/scoop.h> 41#include <asm/hardware/scoop.h>
42 42
43#include "generic.h" 43#include "generic.h"
44#include "sharpsl.h"
44 45
45 46
46/* 47/*
@@ -94,14 +95,30 @@ struct platform_device corgissp_device = {
94 .id = -1, 95 .id = -1,
95}; 96};
96 97
98struct corgissp_machinfo corgi_ssp_machinfo = {
99 .port = 1,
100 .cs_lcdcon = CORGI_GPIO_LCDCON_CS,
101 .cs_ads7846 = CORGI_GPIO_ADS7846_CS,
102 .cs_max1111 = CORGI_GPIO_MAX1111_CS,
103 .clk_lcdcon = 76,
104 .clk_ads7846 = 2,
105 .clk_max1111 = 8,
106};
107
97 108
98/* 109/*
99 * Corgi Backlight Device 110 * Corgi Backlight Device
100 */ 111 */
112static struct corgibl_machinfo corgi_bl_machinfo = {
113 .max_intensity = 0x2f,
114 .set_bl_intensity = corgi_bl_set_intensity,
115};
116
101static struct platform_device corgibl_device = { 117static struct platform_device corgibl_device = {
102 .name = "corgi-bl", 118 .name = "corgi-bl",
103 .dev = { 119 .dev = {
104 .parent = &corgifb_device.dev, 120 .parent = &corgifb_device.dev,
121 .platform_data = &corgi_bl_machinfo,
105 }, 122 },
106 .id = -1, 123 .id = -1,
107}; 124};
@@ -119,12 +136,29 @@ static struct platform_device corgikbd_device = {
119/* 136/*
120 * Corgi Touch Screen Device 137 * Corgi Touch Screen Device
121 */ 138 */
139static struct resource corgits_resources[] = {
140 [0] = {
141 .start = CORGI_IRQ_GPIO_TP_INT,
142 .end = CORGI_IRQ_GPIO_TP_INT,
143 .flags = IORESOURCE_IRQ,
144 },
145};
146
147static struct corgits_machinfo corgi_ts_machinfo = {
148 .get_hsync_len = corgi_get_hsync_len,
149 .put_hsync = corgi_put_hsync,
150 .wait_hsync = corgi_wait_hsync,
151};
152
122static struct platform_device corgits_device = { 153static struct platform_device corgits_device = {
123 .name = "corgi-ts", 154 .name = "corgi-ts",
124 .dev = { 155 .dev = {
125 .parent = &corgissp_device.dev, 156 .parent = &corgissp_device.dev,
157 .platform_data = &corgi_ts_machinfo,
126 }, 158 },
127 .id = -1, 159 .id = -1,
160 .num_resources = ARRAY_SIZE(corgits_resources),
161 .resource = corgits_resources,
128}; 162};
129 163
130 164
@@ -225,7 +259,10 @@ static struct platform_device *devices[] __initdata = {
225 259
226static void __init corgi_init(void) 260static void __init corgi_init(void)
227{ 261{
262 corgi_ssp_set_machinfo(&corgi_ssp_machinfo);
263
228 pxa_gpio_mode(CORGI_GPIO_USB_PULLUP | GPIO_OUT); 264 pxa_gpio_mode(CORGI_GPIO_USB_PULLUP | GPIO_OUT);
265 pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN);
229 pxa_set_udc_info(&udc_info); 266 pxa_set_udc_info(&udc_info);
230 pxa_set_mci_info(&corgi_mci_platform_data); 267 pxa_set_mci_info(&corgi_mci_platform_data);
231 268
diff --git a/arch/arm/mach-pxa/corgi_lcd.c b/arch/arm/mach-pxa/corgi_lcd.c
index deac29c00290..c5efcd04fcbc 100644
--- a/arch/arm/mach-pxa/corgi_lcd.c
+++ b/arch/arm/mach-pxa/corgi_lcd.c
@@ -1,10 +1,14 @@
1/* 1/*
2 * linux/drivers/video/w100fb.c 2 * linux/drivers/video/w100fb.c
3 * 3 *
4 * Corgi LCD Specific Code for ATI Imageon w100 (Wallaby) 4 * Corgi/Spitz LCD Specific Code
5 * 5 *
6 * Copyright (C) 2005 Richard Purdie 6 * Copyright (C) 2005 Richard Purdie
7 * 7 *
8 * Connectivity:
9 * Corgi - LCD to ATI Imageon w100 (Wallaby)
10 * Spitz - LCD to PXA Framebuffer
11 *
8 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 13 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 14 * published by the Free Software Foundation.
@@ -14,9 +18,17 @@
14#include <linux/delay.h> 18#include <linux/delay.h>
15#include <linux/kernel.h> 19#include <linux/kernel.h>
16#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/module.h>
22#include <asm/mach-types.h>
23#include <asm/arch/akita.h>
17#include <asm/arch/corgi.h> 24#include <asm/arch/corgi.h>
25#include <asm/arch/hardware.h>
26#include <asm/arch/pxa-regs.h>
27#include <asm/arch/sharpsl.h>
28#include <asm/arch/spitz.h>
29#include <asm/hardware/scoop.h>
18#include <asm/mach/sharpsl_param.h> 30#include <asm/mach/sharpsl_param.h>
19#include <video/w100fb.h> 31#include "generic.h"
20 32
21/* Register Addresses */ 33/* Register Addresses */
22#define RESCTL_ADRS 0x00 34#define RESCTL_ADRS 0x00
@@ -134,10 +146,10 @@ static void lcdtg_set_common_voltage(u8 base_data, u8 data)
134} 146}
135 147
136/* Set Phase Adjuct */ 148/* Set Phase Adjuct */
137static void lcdtg_set_phadadj(struct w100fb_par *par) 149static void lcdtg_set_phadadj(int mode)
138{ 150{
139 int adj; 151 int adj;
140 switch(par->xres) { 152 switch(mode) {
141 case 480: 153 case 480:
142 case 640: 154 case 640:
143 /* Setting for VGA */ 155 /* Setting for VGA */
@@ -161,7 +173,7 @@ static void lcdtg_set_phadadj(struct w100fb_par *par)
161 173
162static int lcd_inited; 174static int lcd_inited;
163 175
164static void lcdtg_hw_init(struct w100fb_par *par) 176static void lcdtg_hw_init(int mode)
165{ 177{
166 if (!lcd_inited) { 178 if (!lcd_inited) {
167 int comadj; 179 int comadj;
@@ -215,7 +227,7 @@ static void lcdtg_hw_init(struct w100fb_par *par)
215 corgi_ssp_lcdtg_send(PICTRL_ADRS, 0); 227 corgi_ssp_lcdtg_send(PICTRL_ADRS, 0);
216 228
217 /* Set Phase Adjuct */ 229 /* Set Phase Adjuct */
218 lcdtg_set_phadadj(par); 230 lcdtg_set_phadadj(mode);
219 231
220 /* Initialize for Input Signals from ATI */ 232 /* Initialize for Input Signals from ATI */
221 corgi_ssp_lcdtg_send(POLCTRL_ADRS, POLCTRL_SYNC_POL_RISE | POLCTRL_EN_POL_RISE 233 corgi_ssp_lcdtg_send(POLCTRL_ADRS, POLCTRL_SYNC_POL_RISE | POLCTRL_EN_POL_RISE
@@ -224,10 +236,10 @@ static void lcdtg_hw_init(struct w100fb_par *par)
224 236
225 lcd_inited=1; 237 lcd_inited=1;
226 } else { 238 } else {
227 lcdtg_set_phadadj(par); 239 lcdtg_set_phadadj(mode);
228 } 240 }
229 241
230 switch(par->xres) { 242 switch(mode) {
231 case 480: 243 case 480:
232 case 640: 244 case 640:
233 /* Set Lcd Resolution (VGA) */ 245 /* Set Lcd Resolution (VGA) */
@@ -242,7 +254,7 @@ static void lcdtg_hw_init(struct w100fb_par *par)
242 } 254 }
243} 255}
244 256
245static void lcdtg_suspend(struct w100fb_par *par) 257static void lcdtg_suspend(void)
246{ 258{
247 /* 60Hz x 2 frame = 16.7msec x 2 = 33.4 msec */ 259 /* 60Hz x 2 frame = 16.7msec x 2 = 33.4 msec */
248 mdelay(34); 260 mdelay(34);
@@ -276,15 +288,30 @@ static void lcdtg_suspend(struct w100fb_par *par)
276 lcd_inited = 0; 288 lcd_inited = 0;
277} 289}
278 290
279static struct w100_tg_info corgi_lcdtg_info = {
280 .change=lcdtg_hw_init,
281 .suspend=lcdtg_suspend,
282 .resume=lcdtg_hw_init,
283};
284 291
285/* 292/*
286 * Corgi w100 Frame Buffer Device 293 * Corgi w100 Frame Buffer Device
287 */ 294 */
295#ifdef CONFIG_PXA_SHARP_C7xx
296
297#include <video/w100fb.h>
298
299static void w100_lcdtg_suspend(struct w100fb_par *par)
300{
301 lcdtg_suspend();
302}
303
304static void w100_lcdtg_init(struct w100fb_par *par)
305{
306 lcdtg_hw_init(par->xres);
307}
308
309
310static struct w100_tg_info corgi_lcdtg_info = {
311 .change = w100_lcdtg_init,
312 .suspend = w100_lcdtg_suspend,
313 .resume = w100_lcdtg_init,
314};
288 315
289static struct w100_mem_info corgi_fb_mem = { 316static struct w100_mem_info corgi_fb_mem = {
290 .ext_cntl = 0x00040003, 317 .ext_cntl = 0x00040003,
@@ -394,3 +421,145 @@ struct platform_device corgifb_device = {
394 }, 421 },
395 422
396}; 423};
424#endif
425
426
427/*
428 * Spitz PXA Frame Buffer Device
429 */
430#ifdef CONFIG_PXA_SHARP_Cxx00
431
432#include <asm/arch/pxafb.h>
433
434void spitz_lcd_power(int on)
435{
436 if (on)
437 lcdtg_hw_init(480);
438 else
439 lcdtg_suspend();
440}
441
442#endif
443
444
445/*
446 * Corgi/Spitz Touchscreen to LCD interface
447 */
448static unsigned long (*get_hsync_time)(struct device *dev);
449
450static void inline sharpsl_wait_sync(int gpio)
451{
452 while((GPLR(gpio) & GPIO_bit(gpio)) == 0);
453 while((GPLR(gpio) & GPIO_bit(gpio)) != 0);
454}
455
456#ifdef CONFIG_PXA_SHARP_C7xx
457unsigned long corgi_get_hsync_len(void)
458{
459 if (!get_hsync_time)
460 get_hsync_time = symbol_get(w100fb_get_hsynclen);
461 if (!get_hsync_time)
462 return 0;
463
464 return get_hsync_time(&corgifb_device.dev);
465}
466
467void corgi_put_hsync(void)
468{
469 if (get_hsync_time)
470 symbol_put(w100fb_get_hsynclen);
471}
472
473void corgi_wait_hsync(void)
474{
475 sharpsl_wait_sync(CORGI_GPIO_HSYNC);
476}
477#endif
478
479#ifdef CONFIG_PXA_SHARP_Cxx00
480unsigned long spitz_get_hsync_len(void)
481{
482 if (!get_hsync_time)
483 get_hsync_time = symbol_get(pxafb_get_hsync_time);
484 if (!get_hsync_time)
485 return 0;
486
487 return pxafb_get_hsync_time(&pxafb_device.dev);
488}
489
490void spitz_put_hsync(void)
491{
492 if (get_hsync_time)
493 symbol_put(pxafb_get_hsync_time);
494}
495
496void spitz_wait_hsync(void)
497{
498 sharpsl_wait_sync(SPITZ_GPIO_HSYNC);
499}
500#endif
501
502/*
503 * Corgi/Spitz Backlight Power
504 */
505#ifdef CONFIG_PXA_SHARP_C7xx
506void corgi_bl_set_intensity(int intensity)
507{
508 if (intensity > 0x10)
509 intensity += 0x10;
510
511 /* Bits 0-4 are accessed via the SSP interface */
512 corgi_ssp_blduty_set(intensity & 0x1f);
513
514 /* Bit 5 is via SCOOP */
515 if (intensity & 0x0020)
516 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
517 else
518 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
519}
520#endif
521
522
523#if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
524void spitz_bl_set_intensity(int intensity)
525{
526 if (intensity > 0x10)
527 intensity += 0x10;
528
529 /* Bits 0-4 are accessed via the SSP interface */
530 corgi_ssp_blduty_set(intensity & 0x1f);
531
532 /* Bit 5 is via SCOOP */
533 if (intensity & 0x0020)
534 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
535 else
536 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
537
538 if (intensity)
539 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
540 else
541 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
542}
543#endif
544
545#ifdef CONFIG_MACH_AKITA
546void akita_bl_set_intensity(int intensity)
547{
548 if (intensity > 0x10)
549 intensity += 0x10;
550
551 /* Bits 0-4 are accessed via the SSP interface */
552 corgi_ssp_blduty_set(intensity & 0x1f);
553
554 /* Bit 5 is via IO-Expander */
555 if (intensity & 0x0020)
556 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT);
557 else
558 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT);
559
560 if (intensity)
561 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON);
562 else
563 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON);
564}
565#endif
diff --git a/arch/arm/mach-pxa/corgi_ssp.c b/arch/arm/mach-pxa/corgi_ssp.c
index 366a9bde3d8b..0ef428287055 100644
--- a/arch/arm/mach-pxa/corgi_ssp.c
+++ b/arch/arm/mach-pxa/corgi_ssp.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * SSP control code for Sharp Corgi devices 2 * SSP control code for Sharp Corgi devices
3 * 3 *
4 * Copyright (c) 2004 Richard Purdie 4 * Copyright (c) 2004-2005 Richard Purdie
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -17,14 +17,16 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/device.h> 18#include <linux/device.h>
19#include <asm/hardware.h> 19#include <asm/hardware.h>
20#include <asm/mach-types.h>
20 21
21#include <asm/arch/ssp.h> 22#include <asm/arch/ssp.h>
22#include <asm/arch/corgi.h>
23#include <asm/arch/pxa-regs.h> 23#include <asm/arch/pxa-regs.h>
24#include "sharpsl.h"
24 25
25static DEFINE_SPINLOCK(corgi_ssp_lock); 26static DEFINE_SPINLOCK(corgi_ssp_lock);
26static struct ssp_dev corgi_ssp_dev; 27static struct ssp_dev corgi_ssp_dev;
27static struct ssp_state corgi_ssp_state; 28static struct ssp_state corgi_ssp_state;
29static struct corgissp_machinfo *ssp_machinfo;
28 30
29/* 31/*
30 * There are three devices connected to the SSP interface: 32 * There are three devices connected to the SSP interface:
@@ -48,12 +50,12 @@ unsigned long corgi_ssp_ads7846_putget(ulong data)
48 unsigned long ret,flag; 50 unsigned long ret,flag;
49 51
50 spin_lock_irqsave(&corgi_ssp_lock, flag); 52 spin_lock_irqsave(&corgi_ssp_lock, flag);
51 GPCR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); 53 GPCR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846);
52 54
53 ssp_write_word(&corgi_ssp_dev,data); 55 ssp_write_word(&corgi_ssp_dev,data);
54 ret = ssp_read_word(&corgi_ssp_dev); 56 ret = ssp_read_word(&corgi_ssp_dev);
55 57
56 GPSR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); 58 GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846);
57 spin_unlock_irqrestore(&corgi_ssp_lock, flag); 59 spin_unlock_irqrestore(&corgi_ssp_lock, flag);
58 60
59 return ret; 61 return ret;
@@ -66,12 +68,12 @@ unsigned long corgi_ssp_ads7846_putget(ulong data)
66void corgi_ssp_ads7846_lock(void) 68void corgi_ssp_ads7846_lock(void)
67{ 69{
68 spin_lock(&corgi_ssp_lock); 70 spin_lock(&corgi_ssp_lock);
69 GPCR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); 71 GPCR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846);
70} 72}
71 73
72void corgi_ssp_ads7846_unlock(void) 74void corgi_ssp_ads7846_unlock(void)
73{ 75{
74 GPSR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); 76 GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846);
75 spin_unlock(&corgi_ssp_lock); 77 spin_unlock(&corgi_ssp_lock);
76} 78}
77 79
@@ -97,23 +99,27 @@ EXPORT_SYMBOL(corgi_ssp_ads7846_get);
97 */ 99 */
98unsigned long corgi_ssp_dac_put(ulong data) 100unsigned long corgi_ssp_dac_put(ulong data)
99{ 101{
100 unsigned long flag; 102 unsigned long flag, sscr1 = SSCR1_SPH;
101 103
102 spin_lock_irqsave(&corgi_ssp_lock, flag); 104 spin_lock_irqsave(&corgi_ssp_lock, flag);
103 GPCR0 = GPIO_bit(CORGI_GPIO_LCDCON_CS); 105
106 if (machine_is_spitz() || machine_is_akita() || machine_is_borzoi())
107 sscr1 = 0;
104 108
105 ssp_disable(&corgi_ssp_dev); 109 ssp_disable(&corgi_ssp_dev);
106 ssp_config(&corgi_ssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), SSCR1_SPH, 0, SSCR0_SerClkDiv(76)); 110 ssp_config(&corgi_ssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), sscr1, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_lcdcon));
107 ssp_enable(&corgi_ssp_dev); 111 ssp_enable(&corgi_ssp_dev);
108 112
113 GPCR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon);
109 ssp_write_word(&corgi_ssp_dev,data); 114 ssp_write_word(&corgi_ssp_dev,data);
110 /* Read null data back from device to prevent SSP overflow */ 115 /* Read null data back from device to prevent SSP overflow */
111 ssp_read_word(&corgi_ssp_dev); 116 ssp_read_word(&corgi_ssp_dev);
117 GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon);
112 118
113 ssp_disable(&corgi_ssp_dev); 119 ssp_disable(&corgi_ssp_dev);
114 ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(2)); 120 ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_ads7846));
115 ssp_enable(&corgi_ssp_dev); 121 ssp_enable(&corgi_ssp_dev);
116 GPSR0 = GPIO_bit(CORGI_GPIO_LCDCON_CS); 122
117 spin_unlock_irqrestore(&corgi_ssp_lock, flag); 123 spin_unlock_irqrestore(&corgi_ssp_lock, flag);
118 124
119 return 0; 125 return 0;
@@ -141,9 +147,9 @@ int corgi_ssp_max1111_get(ulong data)
141 int voltage,voltage1,voltage2; 147 int voltage,voltage1,voltage2;
142 148
143 spin_lock_irqsave(&corgi_ssp_lock, flag); 149 spin_lock_irqsave(&corgi_ssp_lock, flag);
144 GPCR0 = GPIO_bit(CORGI_GPIO_MAX1111_CS); 150 GPCR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111);
145 ssp_disable(&corgi_ssp_dev); 151 ssp_disable(&corgi_ssp_dev);
146 ssp_config(&corgi_ssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), 0, 0, SSCR0_SerClkDiv(8)); 152 ssp_config(&corgi_ssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_max1111));
147 ssp_enable(&corgi_ssp_dev); 153 ssp_enable(&corgi_ssp_dev);
148 154
149 udelay(1); 155 udelay(1);
@@ -161,9 +167,9 @@ int corgi_ssp_max1111_get(ulong data)
161 voltage2=ssp_read_word(&corgi_ssp_dev); 167 voltage2=ssp_read_word(&corgi_ssp_dev);
162 168
163 ssp_disable(&corgi_ssp_dev); 169 ssp_disable(&corgi_ssp_dev);
164 ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(2)); 170 ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_ads7846));
165 ssp_enable(&corgi_ssp_dev); 171 ssp_enable(&corgi_ssp_dev);
166 GPSR0 = GPIO_bit(CORGI_GPIO_MAX1111_CS); 172 GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111);
167 spin_unlock_irqrestore(&corgi_ssp_lock, flag); 173 spin_unlock_irqrestore(&corgi_ssp_lock, flag);
168 174
169 if (voltage1 & 0xc0 || voltage2 & 0x3f) 175 if (voltage1 & 0xc0 || voltage2 & 0x3f)
@@ -179,25 +185,31 @@ EXPORT_SYMBOL(corgi_ssp_max1111_get);
179/* 185/*
180 * Support Routines 186 * Support Routines
181 */ 187 */
182int __init corgi_ssp_probe(struct device *dev) 188
189void __init corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo)
190{
191 ssp_machinfo = machinfo;
192}
193
194static int __init corgi_ssp_probe(struct device *dev)
183{ 195{
184 int ret; 196 int ret;
185 197
186 /* Chip Select - Disable All */ 198 /* Chip Select - Disable All */
187 GPDR0 |= GPIO_bit(CORGI_GPIO_LCDCON_CS); /* output */ 199 GPDR(ssp_machinfo->cs_lcdcon) |= GPIO_bit(ssp_machinfo->cs_lcdcon); /* output */
188 GPSR0 = GPIO_bit(CORGI_GPIO_LCDCON_CS); /* High - Disable LCD Control/Timing Gen */ 200 GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon); /* High - Disable LCD Control/Timing Gen */
189 GPDR0 |= GPIO_bit(CORGI_GPIO_MAX1111_CS); /* output */ 201 GPDR(ssp_machinfo->cs_max1111) |= GPIO_bit(ssp_machinfo->cs_max1111); /* output */
190 GPSR0 = GPIO_bit(CORGI_GPIO_MAX1111_CS); /* High - Disable MAX1111*/ 202 GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111); /* High - Disable MAX1111*/
191 GPDR0 |= GPIO_bit(CORGI_GPIO_ADS7846_CS); /* output */ 203 GPDR(ssp_machinfo->cs_ads7846) |= GPIO_bit(ssp_machinfo->cs_ads7846); /* output */
192 GPSR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); /* High - Disable ADS7846*/ 204 GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); /* High - Disable ADS7846*/
193 205
194 ret=ssp_init(&corgi_ssp_dev,1); 206 ret = ssp_init(&corgi_ssp_dev,ssp_machinfo->port);
195 207
196 if (ret) 208 if (ret)
197 printk(KERN_ERR "Unable to register SSP handler!\n"); 209 printk(KERN_ERR "Unable to register SSP handler!\n");
198 else { 210 else {
199 ssp_disable(&corgi_ssp_dev); 211 ssp_disable(&corgi_ssp_dev);
200 ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(2)); 212 ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_ads7846));
201 ssp_enable(&corgi_ssp_dev); 213 ssp_enable(&corgi_ssp_dev);
202 } 214 }
203 215
@@ -222,9 +234,9 @@ static int corgi_ssp_suspend(struct device *dev, pm_message_t state, u32 level)
222static int corgi_ssp_resume(struct device *dev, u32 level) 234static int corgi_ssp_resume(struct device *dev, u32 level)
223{ 235{
224 if (level == RESUME_POWER_ON) { 236 if (level == RESUME_POWER_ON) {
225 GPSR0 = GPIO_bit(CORGI_GPIO_LCDCON_CS); /* High - Disable LCD Control/Timing Gen */ 237 GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon); /* High - Disable LCD Control/Timing Gen */
226 GPSR0 = GPIO_bit(CORGI_GPIO_MAX1111_CS); /* High - Disable MAX1111*/ 238 GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111); /* High - Disable MAX1111*/
227 GPSR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); /* High - Disable ADS7846*/ 239 GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); /* High - Disable ADS7846*/
228 ssp_restore_state(&corgi_ssp_dev,&corgi_ssp_state); 240 ssp_restore_state(&corgi_ssp_dev,&corgi_ssp_state);
229 ssp_enable(&corgi_ssp_dev); 241 ssp_enable(&corgi_ssp_dev);
230 } 242 }
diff --git a/arch/arm/mach-pxa/sharpsl.h b/arch/arm/mach-pxa/sharpsl.h
new file mode 100644
index 000000000000..3977a77aacdd
--- /dev/null
+++ b/arch/arm/mach-pxa/sharpsl.h
@@ -0,0 +1,34 @@
1/*
2 * SharpSL SSP Driver
3 */
4
5struct corgissp_machinfo {
6 int port;
7 int cs_lcdcon;
8 int cs_ads7846;
9 int cs_max1111;
10 int clk_lcdcon;
11 int clk_ads7846;
12 int clk_max1111;
13};
14
15void corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo);
16
17/*
18 * SharpSL Backlight
19 */
20
21void corgi_bl_set_intensity(int intensity);
22void spitz_bl_set_intensity(int intensity);
23void akita_bl_set_intensity(int intensity);
24
25/*
26 * SharpSL Touchscreen Driver
27 */
28
29unsigned long corgi_get_hsync_len(void);
30unsigned long spitz_get_hsync_len(void);
31void corgi_put_hsync(void);
32void spitz_put_hsync(void);
33void corgi_wait_hsync(void);
34void spitz_wait_hsync(void);
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
new file mode 100644
index 000000000000..568afe3d6e1a
--- /dev/null
+++ b/arch/arm/mach-pxa/spitz.c
@@ -0,0 +1,380 @@
1/*
2 * Support for Sharp SL-Cxx00 Series of PDAs
3 * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi)
4 *
5 * Copyright (c) 2005 Richard Purdie
6 *
7 * Based on Sharp's 2.4 kernel patches/lubbock.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/device.h>
18#include <linux/delay.h>
19#include <linux/major.h>
20#include <linux/fs.h>
21#include <linux/interrupt.h>
22#include <linux/mmc/host.h>
23
24#include <asm/setup.h>
25#include <asm/memory.h>
26#include <asm/mach-types.h>
27#include <asm/hardware.h>
28#include <asm/irq.h>
29#include <asm/io.h>
30
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33#include <asm/mach/irq.h>
34
35#include <asm/arch/pxa-regs.h>
36#include <asm/arch/irq.h>
37#include <asm/arch/mmc.h>
38#include <asm/arch/udc.h>
39#include <asm/arch/ohci.h>
40#include <asm/arch/pxafb.h>
41#include <asm/arch/akita.h>
42#include <asm/arch/spitz.h>
43#include <asm/arch/sharpsl.h>
44
45#include <asm/mach/sharpsl_param.h>
46#include <asm/hardware/scoop.h>
47
48#include "generic.h"
49#include "sharpsl.h"
50
51/*
52 * Spitz SCOOP Device #1
53 */
54static struct resource spitz_scoop_resources[] = {
55 [0] = {
56 .start = 0x10800000,
57 .end = 0x10800fff,
58 .flags = IORESOURCE_MEM,
59 },
60};
61
62static struct scoop_config spitz_scoop_setup = {
63 .io_dir = SPITZ_SCP_IO_DIR,
64 .io_out = SPITZ_SCP_IO_OUT,
65 .suspend_clr = SPITZ_SCP_SUS_CLR,
66 .suspend_set = SPITZ_SCP_SUS_SET,
67};
68
69struct platform_device spitzscoop_device = {
70 .name = "sharp-scoop",
71 .id = 0,
72 .dev = {
73 .platform_data = &spitz_scoop_setup,
74 },
75 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
76 .resource = spitz_scoop_resources,
77};
78
79/*
80 * Spitz SCOOP Device #2
81 */
82static struct resource spitz_scoop2_resources[] = {
83 [0] = {
84 .start = 0x08800040,
85 .end = 0x08800fff,
86 .flags = IORESOURCE_MEM,
87 },
88};
89
90static struct scoop_config spitz_scoop2_setup = {
91 .io_dir = SPITZ_SCP2_IO_DIR,
92 .io_out = SPITZ_SCP2_IO_OUT,
93 .suspend_clr = SPITZ_SCP2_SUS_CLR,
94 .suspend_set = SPITZ_SCP2_SUS_SET,
95};
96
97struct platform_device spitzscoop2_device = {
98 .name = "sharp-scoop",
99 .id = 1,
100 .dev = {
101 .platform_data = &spitz_scoop2_setup,
102 },
103 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
104 .resource = spitz_scoop2_resources,
105};
106
107static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
108{
109 .dev = &spitzscoop_device.dev,
110 .irq = SPITZ_IRQ_GPIO_CF_IRQ,
111 .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
112 .cd_irq_str = "PCMCIA0 CD",
113},{
114 .dev = &spitzscoop2_device.dev,
115 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
116 .cd_irq = -1,
117},
118};
119
120
121/*
122 * Spitz SSP Device
123 *
124 * Set the parent as the scoop device because a lot of SSP devices
125 * also use scoop functions and this makes the power up/down order
126 * work correctly.
127 */
128struct platform_device spitzssp_device = {
129 .name = "corgi-ssp",
130 .dev = {
131 .parent = &spitzscoop_device.dev,
132 },
133 .id = -1,
134};
135
136struct corgissp_machinfo spitz_ssp_machinfo = {
137 .port = 2,
138 .cs_lcdcon = SPITZ_GPIO_LCDCON_CS,
139 .cs_ads7846 = SPITZ_GPIO_ADS7846_CS,
140 .cs_max1111 = SPITZ_GPIO_MAX1111_CS,
141 .clk_lcdcon = 520,
142 .clk_ads7846 = 14,
143 .clk_max1111 = 56,
144};
145
146
147/*
148 * Spitz Backlight Device
149 */
150static struct corgibl_machinfo spitz_bl_machinfo = {
151 .max_intensity = 0x2f,
152};
153
154static struct platform_device spitzbl_device = {
155 .name = "corgi-bl",
156 .dev = {
157 .platform_data = &spitz_bl_machinfo,
158 },
159 .id = -1,
160};
161
162
163/*
164 * Spitz Keyboard Device
165 */
166static struct platform_device spitzkbd_device = {
167 .name = "spitz-keyboard",
168 .id = -1,
169};
170
171
172/*
173 * Spitz Touch Screen Device
174 */
175static struct resource spitzts_resources[] = {
176 [0] = {
177 .start = SPITZ_IRQ_GPIO_TP_INT,
178 .end = SPITZ_IRQ_GPIO_TP_INT,
179 .flags = IORESOURCE_IRQ,
180 },
181};
182
183static struct corgits_machinfo spitz_ts_machinfo = {
184 .get_hsync_len = spitz_get_hsync_len,
185 .put_hsync = spitz_put_hsync,
186 .wait_hsync = spitz_wait_hsync,
187};
188
189static struct platform_device spitzts_device = {
190 .name = "corgi-ts",
191 .dev = {
192 .parent = &spitzssp_device.dev,
193 .platform_data = &spitz_ts_machinfo,
194 },
195 .id = -1,
196 .num_resources = ARRAY_SIZE(spitzts_resources),
197 .resource = spitzts_resources,
198};
199
200
201/*
202 * MMC/SD Device
203 *
204 * The card detect interrupt isn't debounced so we delay it by 250ms
205 * to give the card a chance to fully insert/eject.
206 */
207
208static struct pxamci_platform_data spitz_mci_platform_data;
209
210static int spitz_mci_init(struct device *dev, irqreturn_t (*spitz_detect_int)(int, void *, struct pt_regs *), void *data)
211{
212 int err;
213
214 /* setup GPIO for PXA27x MMC controller */
215 pxa_gpio_mode(GPIO32_MMCCLK_MD);
216 pxa_gpio_mode(GPIO112_MMCCMD_MD);
217 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
218 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
219 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
220 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
221 pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT | GPIO_IN);
222 pxa_gpio_mode(SPITZ_GPIO_nSD_WP | GPIO_IN);
223
224 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
225
226 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, SA_INTERRUPT,
227 "MMC card detect", data);
228 if (err) {
229 printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
230 return -1;
231 }
232
233 set_irq_type(SPITZ_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
234
235 return 0;
236}
237
238/* Power control is shared with one of the CF slots so we have a mess */
239static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
240{
241 struct pxamci_platform_data* p_d = dev->platform_data;
242
243 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
244
245 if (( 1 << vdd) & p_d->ocr_mask) {
246 /* printk(KERN_DEBUG "%s: on\n", __FUNCTION__); */
247 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
248 mdelay(2);
249 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | 0x04);
250 } else {
251 /* printk(KERN_DEBUG "%s: off\n", __FUNCTION__); */
252 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr & ~0x04);
253
254 if (!(cpr | 0x02)) {
255 mdelay(1);
256 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
257 }
258 }
259}
260
261static int spitz_mci_get_ro(struct device *dev)
262{
263 return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP);
264}
265
266static void spitz_mci_exit(struct device *dev, void *data)
267{
268 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
269}
270
271static struct pxamci_platform_data spitz_mci_platform_data = {
272 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
273 .init = spitz_mci_init,
274 .get_ro = spitz_mci_get_ro,
275 .setpower = spitz_mci_setpower,
276 .exit = spitz_mci_exit,
277};
278
279
280/*
281 * Spitz PXA Framebuffer
282 */
283static struct pxafb_mach_info spitz_pxafb_info __initdata = {
284 .pixclock = 19231,
285 .xres = 480,
286 .yres = 640,
287 .bpp = 16,
288 .hsync_len = 40,
289 .left_margin = 46,
290 .right_margin = 125,
291 .vsync_len = 3,
292 .upper_margin = 1,
293 .lower_margin = 0,
294 .sync = 0,
295 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM,
296 .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH,
297 .pxafb_lcd_power = spitz_lcd_power,
298};
299
300
301static struct platform_device *devices[] __initdata = {
302 &spitzscoop_device,
303 &spitzssp_device,
304 &spitzkbd_device,
305 &spitzts_device,
306 &spitzbl_device,
307 &spitzbattery_device,
308};
309
310static void __init common_init(void)
311{
312 PMCR = 0x00;
313
314 /* setup sleep mode values */
315 PWER = 0x00000002;
316 PFER = 0x00000000;
317 PRER = 0x00000002;
318 PGSR0 = 0x0158C000;
319 PGSR1 = 0x00FF0080;
320 PGSR2 = 0x0001C004;
321
322 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
323 PCFR |= PCFR_OPDE;
324
325 corgi_ssp_set_machinfo(&spitz_ssp_machinfo);
326
327 pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN);
328
329 platform_add_devices(devices, ARRAY_SIZE(devices));
330 pxa_set_mci_info(&spitz_mci_platform_data);
331 pxafb_device.dev.parent = &spitzssp_device.dev;
332 set_pxa_fb_info(&spitz_pxafb_info);
333}
334
335static void __init spitz_init(void)
336{
337 scoop_num = 2;
338 scoop_devs = &spitz_pcmcia_scoop[0];
339 spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity;
340
341 common_init();
342
343 platform_device_register(&spitzscoop2_device);
344}
345
346static void __init fixup_spitz(struct machine_desc *desc,
347 struct tag *tags, char **cmdline, struct meminfo *mi)
348{
349 sharpsl_save_param();
350 mi->nr_banks = 1;
351 mi->bank[0].start = 0xa0000000;
352 mi->bank[0].node = 0;
353 mi->bank[0].size = (64*1024*1024);
354}
355
356#ifdef CONFIG_MACH_SPITZ
357MACHINE_START(SPITZ, "SHARP Spitz")
358 .phys_ram = 0xa0000000,
359 .phys_io = 0x40000000,
360 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
361 .fixup = fixup_spitz,
362 .map_io = pxa_map_io,
363 .init_irq = pxa_init_irq,
364 .init_machine = spitz_init,
365 .timer = &pxa_timer,
366MACHINE_END
367#endif
368
369#ifdef CONFIG_MACH_BORZOI
370MACHINE_START(BORZOI, "SHARP Borzoi")
371 .phys_ram = 0xa0000000,
372 .phys_io = 0x40000000,
373 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
374 .fixup = fixup_spitz,
375 .map_io = pxa_map_io,
376 .init_irq = pxa_init_irq,
377 .init_machine = spitz_init,
378 .timer = &pxa_timer,
379MACHINE_END
380#endif
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
index 1cbb9c0f4704..350ea6680f63 100644
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -11,6 +11,7 @@
11#include <linux/mc146818rtc.h> 11#include <linux/mc146818rtc.h>
12#include <linux/efi.h> 12#include <linux/efi.h>
13#include <linux/dmi.h> 13#include <linux/dmi.h>
14#include <linux/ctype.h>
14#include <asm/uaccess.h> 15#include <asm/uaccess.h>
15#include <asm/apic.h> 16#include <asm/apic.h>
16#include <asm/desc.h> 17#include <asm/desc.h>
@@ -28,8 +29,6 @@ static int reboot_thru_bios;
28 29
29#ifdef CONFIG_SMP 30#ifdef CONFIG_SMP
30static int reboot_cpu = -1; 31static int reboot_cpu = -1;
31/* shamelessly grabbed from lib/vsprintf.c for readability */
32#define is_digit(c) ((c) >= '0' && (c) <= '9')
33#endif 32#endif
34static int __init reboot_setup(char *str) 33static int __init reboot_setup(char *str)
35{ 34{
@@ -49,9 +48,9 @@ static int __init reboot_setup(char *str)
49 break; 48 break;
50#ifdef CONFIG_SMP 49#ifdef CONFIG_SMP
51 case 's': /* "smp" reboot by executing reset on BSP or other CPU*/ 50 case 's': /* "smp" reboot by executing reset on BSP or other CPU*/
52 if (is_digit(*(str+1))) { 51 if (isdigit(*(str+1))) {
53 reboot_cpu = (int) (*(str+1) - '0'); 52 reboot_cpu = (int) (*(str+1) - '0');
54 if (is_digit(*(str+2))) 53 if (isdigit(*(str+2)))
55 reboot_cpu = reboot_cpu*10 + (int)(*(str+2) - '0'); 54 reboot_cpu = reboot_cpu*10 + (int)(*(str+2) - '0');
56 } 55 }
57 /* we will leave sorting out the final value 56 /* we will leave sorting out the final value
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index c70cd2a08304..5f0a95d76a4f 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -202,7 +202,7 @@ static void __devinit smp_store_cpu_info(int id)
202 goto valid_k7; 202 goto valid_k7;
203 203
204 /* If we get here, it's not a certified SMP capable AMD system. */ 204 /* If we get here, it's not a certified SMP capable AMD system. */
205 tainted |= TAINT_UNSAFE_SMP; 205 add_taint(TAINT_UNSAFE_SMP);
206 } 206 }
207 207
208valid_k7: 208valid_k7:
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 09a58cb6daa7..431a551e46ea 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -807,8 +807,9 @@ void math_error(void __user *eip)
807 cwd = get_fpu_cwd(task); 807 cwd = get_fpu_cwd(task);
808 swd = get_fpu_swd(task); 808 swd = get_fpu_swd(task);
809 switch (swd & ~cwd & 0x3f) { 809 switch (swd & ~cwd & 0x3f) {
810 case 0x000: 810 case 0x000: /* No unmasked exception */
811 default: 811 return;
812 default: /* Multiple exceptions */
812 break; 813 break;
813 case 0x001: /* Invalid Op */ 814 case 0x001: /* Invalid Op */
814 /* 815 /*
diff --git a/arch/m68knommu/platform/68328/head-de2.S b/arch/m68knommu/platform/68328/head-de2.S
new file mode 100644
index 000000000000..94c5a1609a75
--- /dev/null
+++ b/arch/m68knommu/platform/68328/head-de2.S
@@ -0,0 +1,135 @@
1#include <linux/config.h>
2
3#if defined(CONFIG_RAM32MB)
4#define MEM_END 0x02000000 /* Memory size 32Mb */
5#elif defined(CONFIG_RAM16MB)
6#define MEM_END 0x01000000 /* Memory size 16Mb */
7#else
8#define MEM_END 0x00800000 /* Memory size 8Mb */
9#endif
10
11#undef CRT_DEBUG
12
13.macro PUTC CHAR
14#ifdef CRT_DEBUG
15 moveq #\CHAR, %d7
16 jsr putc
17#endif
18.endm
19
20 .global _start
21 .global _rambase
22 .global _ramvec
23 .global _ramstart
24 .global _ramend
25
26 .data
27
28/*
29 * Set up the usable of RAM stuff
30 */
31_rambase:
32 .long 0
33_ramvec:
34 .long 0
35_ramstart:
36 .long 0
37_ramend:
38 .long 0
39
40 .text
41
42_start:
43
44/*
45 * Setup initial stack
46 */
47 /* disable all interrupts */
48 movew #0x2700, %sr
49 movel #-1, 0xfffff304
50 movel #MEM_END-4, %sp
51
52 PUTC '\r'
53 PUTC '\n'
54 PUTC 'A'
55 PUTC 'B'
56
57/*
58 * Determine end of RAM
59 */
60
61 movel #MEM_END, %a0
62 movel %a0, _ramend
63
64 PUTC 'C'
65
66/*
67 * Move ROM filesystem above bss :-)
68 */
69
70 moveal #_sbss, %a0 /* romfs at the start of bss */
71 moveal #_ebss, %a1 /* Set up destination */
72 movel %a0, %a2 /* Copy of bss start */
73
74 movel 8(%a0), %d1 /* Get size of ROMFS */
75 addql #8, %d1 /* Allow for rounding */
76 andl #0xfffffffc, %d1 /* Whole words */
77
78 addl %d1, %a0 /* Copy from end */
79 addl %d1, %a1 /* Copy from end */
80 movel %a1, _ramstart /* Set start of ram */
81
821:
83 movel -(%a0), %d0 /* Copy dword */
84 movel %d0, -(%a1)
85 cmpl %a0, %a2 /* Check if at end */
86 bne 1b
87
88 PUTC 'D'
89
90/*
91 * Initialize BSS segment to 0
92 */
93
94 lea _sbss, %a0
95 lea _ebss, %a1
96
97 /* Copy 0 to %a0 until %a0 == %a1 */
982: cmpal %a0, %a1
99 beq 1f
100 clrl (%a0)+
101 bra 2b
1021:
103
104 PUTC 'E'
105
106/*
107 * Load the current task pointer and stack
108 */
109
110 lea init_thread_union, %a0
111 lea 0x2000(%a0), %sp
112
113 PUTC 'F'
114 PUTC '\r'
115 PUTC '\n'
116
117/*
118 * Go
119 */
120
121 jmp start_kernel
122
123/*
124 * Local functions
125 */
126
127#ifdef CRT_DEBUG
128putc:
129 moveb %d7, 0xfffff907
1301:
131 movew 0xfffff906, %d7
132 andw #0x2000, %d7
133 beq 1b
134 rts
135#endif
diff --git a/arch/ppc/kernel/temp.c b/arch/ppc/kernel/temp.c
index fe8bb634ead0..26bd8ea35a4e 100644
--- a/arch/ppc/kernel/temp.c
+++ b/arch/ppc/kernel/temp.c
@@ -21,7 +21,6 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/init.h> 22#include <linux/init.h>
23 23
24#include <asm/segment.h>
25#include <asm/io.h> 24#include <asm/io.h>
26#include <asm/reg.h> 25#include <asm/reg.h>
27#include <asm/nvram.h> 26#include <asm/nvram.h>
diff --git a/arch/ppc/kernel/time.c b/arch/ppc/kernel/time.c
index a3c5281a5d2d..22d7fd1e0aea 100644
--- a/arch/ppc/kernel/time.c
+++ b/arch/ppc/kernel/time.c
@@ -58,7 +58,6 @@
58#include <linux/init.h> 58#include <linux/init.h>
59#include <linux/profile.h> 59#include <linux/profile.h>
60 60
61#include <asm/segment.h>
62#include <asm/io.h> 61#include <asm/io.h>
63#include <asm/nvram.h> 62#include <asm/nvram.h>
64#include <asm/cache.h> 63#include <asm/cache.h>
diff --git a/arch/ppc/kernel/vmlinux.lds.S b/arch/ppc/kernel/vmlinux.lds.S
index 9353584fb710..17d2db7e537d 100644
--- a/arch/ppc/kernel/vmlinux.lds.S
+++ b/arch/ppc/kernel/vmlinux.lds.S
@@ -96,6 +96,9 @@ SECTIONS
96 *(.init.text) 96 *(.init.text)
97 _einittext = .; 97 _einittext = .;
98 } 98 }
99 /* .exit.text is discarded at runtime, not link time,
100 to deal with references from __bug_table */
101 .exit.text : { *(.exit.text) }
99 .init.data : { 102 .init.data : {
100 *(.init.data); 103 *(.init.data);
101 __vtop_table_begin = .; 104 __vtop_table_begin = .;
@@ -190,5 +193,6 @@ SECTIONS
190 /* Sections to be discarded. */ 193 /* Sections to be discarded. */
191 /DISCARD/ : { 194 /DISCARD/ : {
192 *(.exitcall.exit) 195 *(.exitcall.exit)
196 *(.exit.data)
193 } 197 }
194} 198}
diff --git a/arch/ppc/platforms/chrp_time.c b/arch/ppc/platforms/chrp_time.c
index 4864a7de3daa..6037ce7796f5 100644
--- a/arch/ppc/platforms/chrp_time.c
+++ b/arch/ppc/platforms/chrp_time.c
@@ -22,7 +22,6 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/bcd.h> 23#include <linux/bcd.h>
24 24
25#include <asm/segment.h>
26#include <asm/io.h> 25#include <asm/io.h>
27#include <asm/nvram.h> 26#include <asm/nvram.h>
28#include <asm/prom.h> 27#include <asm/prom.h>
diff --git a/arch/ppc/syslib/prep_nvram.c b/arch/ppc/syslib/prep_nvram.c
index 2bcf8a16d1c9..8599850ca772 100644
--- a/arch/ppc/syslib/prep_nvram.c
+++ b/arch/ppc/syslib/prep_nvram.c
@@ -15,7 +15,6 @@
15#include <linux/ioport.h> 15#include <linux/ioport.h>
16 16
17#include <asm/sections.h> 17#include <asm/sections.h>
18#include <asm/segment.h>
19#include <asm/io.h> 18#include <asm/io.h>
20#include <asm/machdep.h> 19#include <asm/machdep.h>
21#include <asm/prep_nvram.h> 20#include <asm/prep_nvram.h>
diff --git a/arch/ppc64/kernel/asm-offsets.c b/arch/ppc64/kernel/asm-offsets.c
index 17e35d0fed09..1ff4fa05a973 100644
--- a/arch/ppc64/kernel/asm-offsets.c
+++ b/arch/ppc64/kernel/asm-offsets.c
@@ -68,6 +68,7 @@ int main(void)
68 DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr)); 68 DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr));
69#endif /* CONFIG_ALTIVEC */ 69#endif /* CONFIG_ALTIVEC */
70 DEFINE(MM, offsetof(struct task_struct, mm)); 70 DEFINE(MM, offsetof(struct task_struct, mm));
71 DEFINE(AUDITCONTEXT, offsetof(struct task_struct, audit_context));
71 72
72 DEFINE(DCACHEL1LINESIZE, offsetof(struct ppc64_caches, dline_size)); 73 DEFINE(DCACHEL1LINESIZE, offsetof(struct ppc64_caches, dline_size));
73 DEFINE(DCACHEL1LOGLINESIZE, offsetof(struct ppc64_caches, log_dline_size)); 74 DEFINE(DCACHEL1LOGLINESIZE, offsetof(struct ppc64_caches, log_dline_size));
diff --git a/arch/ppc64/kernel/entry.S b/arch/ppc64/kernel/entry.S
index d133a49cdf89..e8c0bbf4d000 100644
--- a/arch/ppc64/kernel/entry.S
+++ b/arch/ppc64/kernel/entry.S
@@ -276,12 +276,22 @@ _GLOBAL(ppc64_rt_sigsuspend)
276_GLOBAL(ppc32_rt_sigsuspend) 276_GLOBAL(ppc32_rt_sigsuspend)
277 bl .save_nvgprs 277 bl .save_nvgprs
278 bl .sys32_rt_sigsuspend 278 bl .sys32_rt_sigsuspend
279 /* If sigsuspend() returns zero, we are going into a signal handler */
28070: cmpdi 0,r3,0 27970: cmpdi 0,r3,0
281 beq .ret_from_except 280 /* If it returned an error, we need to return via syscall_exit to set
282 /* If it returned -EINTR, we need to return via syscall_exit to set
283 the SO bit in cr0 and potentially stop for ptrace. */ 281 the SO bit in cr0 and potentially stop for ptrace. */
284 b syscall_exit 282 bne syscall_exit
283 /* If sigsuspend() returns zero, we are going into a signal handler. We
284 may need to call audit_syscall_exit() to mark the exit from sigsuspend() */
285#ifdef CONFIG_AUDIT
286 ld r3,PACACURRENT(r13)
287 ld r4,AUDITCONTEXT(r3)
288 cmpdi 0,r4,0
289 beq .ret_from_except /* No audit_context: Leave immediately. */
290 li r4, 2 /* AUDITSC_FAILURE */
291 li r5,-4 /* It's always -EINTR */
292 bl .audit_syscall_exit
293#endif
294 b .ret_from_except
285 295
286_GLOBAL(ppc_fork) 296_GLOBAL(ppc_fork)
287 bl .save_nvgprs 297 bl .save_nvgprs
diff --git a/arch/ppc64/kernel/pSeries_setup.c b/arch/ppc64/kernel/pSeries_setup.c
index bfadccc7b8be..3009701eb90d 100644
--- a/arch/ppc64/kernel/pSeries_setup.c
+++ b/arch/ppc64/kernel/pSeries_setup.c
@@ -238,8 +238,8 @@ static void __init pSeries_setup_arch(void)
238 238
239 /* Find and initialize PCI host bridges */ 239 /* Find and initialize PCI host bridges */
240 init_pci_config_tokens(); 240 init_pci_config_tokens();
241 eeh_init();
242 find_and_init_phbs(); 241 find_and_init_phbs();
242 eeh_init();
243 243
244#ifdef CONFIG_DUMMY_CONSOLE 244#ifdef CONFIG_DUMMY_CONSOLE
245 conswitchp = &dummy_con; 245 conswitchp = &dummy_con;
diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c
index 7931d6f92819..787d5f1347ec 100644
--- a/arch/sparc/kernel/module.c
+++ b/arch/sparc/kernel/module.c
@@ -10,6 +10,7 @@
10#include <linux/vmalloc.h> 10#include <linux/vmalloc.h>
11#include <linux/fs.h> 11#include <linux/fs.h>
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/ctype.h>
13 14
14void *module_alloc(unsigned long size) 15void *module_alloc(unsigned long size)
15{ 16{
@@ -37,7 +38,7 @@ void module_free(struct module *mod, void *module_region)
37} 38}
38 39
39/* Make generic code ignore STT_REGISTER dummy undefined symbols, 40/* Make generic code ignore STT_REGISTER dummy undefined symbols,
40 * and replace references to .func with func as in ppc64's dedotify. 41 * and replace references to .func with _Func
41 */ 42 */
42int module_frob_arch_sections(Elf_Ehdr *hdr, 43int module_frob_arch_sections(Elf_Ehdr *hdr,
43 Elf_Shdr *sechdrs, 44 Elf_Shdr *sechdrs,
@@ -64,8 +65,10 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
64 sym[i].st_shndx = SHN_ABS; 65 sym[i].st_shndx = SHN_ABS;
65 else { 66 else {
66 char *name = strtab + sym[i].st_name; 67 char *name = strtab + sym[i].st_name;
67 if (name[0] == '.') 68 if (name[0] == '.') {
68 memmove(name, name+1, strlen(name)); 69 name[0] = '_';
70 name[1] = toupper(name[1]);
71 }
69 } 72 }
70 } 73 }
71 } 74 }
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index f84809333624..1c8fd0fd9305 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -97,19 +97,12 @@ extern void ___rw_write_enter(void);
97/* Alias functions whose names begin with "." and export the aliases. 97/* Alias functions whose names begin with "." and export the aliases.
98 * The module references will be fixed up by module_frob_arch_sections. 98 * The module references will be fixed up by module_frob_arch_sections.
99 */ 99 */
100#define DOT_ALIAS2(__ret, __x, __arg1, __arg2) \ 100extern int _Div(int, int);
101 extern __ret __x(__arg1, __arg2); \ 101extern int _Mul(int, int);
102 asm(".weak " #__x);\ 102extern int _Rem(int, int);
103 asm(#__x "=." #__x); 103extern unsigned _Udiv(unsigned, unsigned);
104 104extern unsigned _Umul(unsigned, unsigned);
105DOT_ALIAS2(int, div, int, int) 105extern unsigned _Urem(unsigned, unsigned);
106DOT_ALIAS2(int, mul, int, int)
107DOT_ALIAS2(int, rem, int, int)
108DOT_ALIAS2(unsigned, udiv, unsigned, unsigned)
109DOT_ALIAS2(unsigned, umul, unsigned, unsigned)
110DOT_ALIAS2(unsigned, urem, unsigned, unsigned)
111
112#undef DOT_ALIAS2
113 106
114/* used by various drivers */ 107/* used by various drivers */
115EXPORT_SYMBOL(sparc_cpu_model); 108EXPORT_SYMBOL(sparc_cpu_model);
@@ -320,12 +313,12 @@ EXPORT_SYMBOL(__lshrdi3);
320EXPORT_SYMBOL(__muldi3); 313EXPORT_SYMBOL(__muldi3);
321EXPORT_SYMBOL(__divdi3); 314EXPORT_SYMBOL(__divdi3);
322 315
323EXPORT_SYMBOL(rem); 316EXPORT_SYMBOL(_Rem);
324EXPORT_SYMBOL(urem); 317EXPORT_SYMBOL(_Urem);
325EXPORT_SYMBOL(mul); 318EXPORT_SYMBOL(_Mul);
326EXPORT_SYMBOL(umul); 319EXPORT_SYMBOL(_Umul);
327EXPORT_SYMBOL(div); 320EXPORT_SYMBOL(_Div);
328EXPORT_SYMBOL(udiv); 321EXPORT_SYMBOL(_Udiv);
329 322
330#ifdef CONFIG_DEBUG_BUGVERBOSE 323#ifdef CONFIG_DEBUG_BUGVERBOSE
331EXPORT_SYMBOL(do_BUG); 324EXPORT_SYMBOL(do_BUG);
diff --git a/arch/sparc/lib/mul.S b/arch/sparc/lib/mul.S
index 83dffbc2f62f..da693560d878 100644
--- a/arch/sparc/lib/mul.S
+++ b/arch/sparc/lib/mul.S
@@ -16,7 +16,9 @@
16 */ 16 */
17 17
18 .globl .mul 18 .globl .mul
19 .globl _Mul
19.mul: 20.mul:
21_Mul: /* needed for export */
20 mov %o0, %y ! multiplier -> Y 22 mov %o0, %y ! multiplier -> Y
21 andncc %o0, 0xfff, %g0 ! test bits 12..31 23 andncc %o0, 0xfff, %g0 ! test bits 12..31
22 be Lmul_shortway ! if zero, can do it the short way 24 be Lmul_shortway ! if zero, can do it the short way
diff --git a/arch/sparc/lib/rem.S b/arch/sparc/lib/rem.S
index 44508148d055..bf015a90d07e 100644
--- a/arch/sparc/lib/rem.S
+++ b/arch/sparc/lib/rem.S
@@ -43,7 +43,9 @@
43 43
44 44
45 .globl .rem 45 .globl .rem
46 .globl _Rem
46.rem: 47.rem:
48_Rem: /* needed for export */
47 ! compute sign of result; if neither is negative, no problem 49 ! compute sign of result; if neither is negative, no problem
48 orcc %o1, %o0, %g0 ! either negative? 50 orcc %o1, %o0, %g0 ! either negative?
49 bge 2f ! no, go do the divide 51 bge 2f ! no, go do the divide
diff --git a/arch/sparc/lib/sdiv.S b/arch/sparc/lib/sdiv.S
index e0ad80b6f63d..af9451629d0b 100644
--- a/arch/sparc/lib/sdiv.S
+++ b/arch/sparc/lib/sdiv.S
@@ -43,7 +43,9 @@
43 43
44 44
45 .globl .div 45 .globl .div
46 .globl _Div
46.div: 47.div:
48_Div: /* needed for export */
47 ! compute sign of result; if neither is negative, no problem 49 ! compute sign of result; if neither is negative, no problem
48 orcc %o1, %o0, %g0 ! either negative? 50 orcc %o1, %o0, %g0 ! either negative?
49 bge 2f ! no, go do the divide 51 bge 2f ! no, go do the divide
diff --git a/arch/sparc/lib/udiv.S b/arch/sparc/lib/udiv.S
index 2abfc6b0f3e9..169e01da6715 100644
--- a/arch/sparc/lib/udiv.S
+++ b/arch/sparc/lib/udiv.S
@@ -43,7 +43,9 @@
43 43
44 44
45 .globl .udiv 45 .globl .udiv
46 .globl _Udiv
46.udiv: 47.udiv:
48_Udiv: /* needed for export */
47 49
48 ! Ready to divide. Compute size of quotient; scale comparand. 50 ! Ready to divide. Compute size of quotient; scale comparand.
49 orcc %o1, %g0, %o5 51 orcc %o1, %g0, %o5
diff --git a/arch/sparc/lib/umul.S b/arch/sparc/lib/umul.S
index a784720a8a22..f0e5b20a2536 100644
--- a/arch/sparc/lib/umul.S
+++ b/arch/sparc/lib/umul.S
@@ -21,7 +21,9 @@
21 */ 21 */
22 22
23 .globl .umul 23 .globl .umul
24 .globl _Umul
24.umul: 25.umul:
26_Umul: /* needed for export */
25 or %o0, %o1, %o4 27 or %o0, %o1, %o4
26 mov %o0, %y ! multiplier -> Y 28 mov %o0, %y ! multiplier -> Y
27 29
diff --git a/arch/sparc/lib/urem.S b/arch/sparc/lib/urem.S
index ec7f0c502c56..6b92bdc8b04c 100644
--- a/arch/sparc/lib/urem.S
+++ b/arch/sparc/lib/urem.S
@@ -41,7 +41,9 @@
41 */ 41 */
42 42
43 .globl .urem 43 .globl .urem
44 .globl _Urem
44.urem: 45.urem:
46_Urem: /* needed for export */
45 47
46 ! Ready to divide. Compute size of quotient; scale comparand. 48 ! Ready to divide. Compute size of quotient; scale comparand.
47 orcc %o1, %g0, %o5 49 orcc %o1, %g0, %o5
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index eb7929eea7b3..4e34b0f9d613 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -28,6 +28,7 @@ extern char _end[];
28 * PFN of last memory page. 28 * PFN of last memory page.
29 */ 29 */
30unsigned long end_pfn; 30unsigned long end_pfn;
31EXPORT_SYMBOL(end_pfn);
31 32
32/* 33/*
33 * end_pfn only includes RAM, while end_pfn_map includes all e820 entries. 34 * end_pfn only includes RAM, while end_pfn_map includes all e820 entries.
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index 969365c0771b..08203b07f4bd 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -217,7 +217,7 @@ void do_machine_check(struct pt_regs * regs, long error_code)
217 panicm_found = 1; 217 panicm_found = 1;
218 } 218 }
219 219
220 tainted |= TAINT_MACHINE_CHECK; 220 add_taint(TAINT_MACHINE_CHECK);
221 } 221 }
222 222
223 /* Never do anything final in the polling timer */ 223 /* Never do anything final in the polling timer */
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 4388b8a5bae7..39d445e16f22 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -366,7 +366,7 @@ static void setup_k7_watchdog(void)
366 | K7_NMI_EVENT; 366 | K7_NMI_EVENT;
367 367
368 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0); 368 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0);
369 wrmsr(MSR_K7_PERFCTR0, -(cpu_khz/nmi_hz*1000), -1); 369 wrmsrl(MSR_K7_PERFCTR0, -((u64)cpu_khz * 1000 / nmi_hz));
370 apic_write(APIC_LVTPC, APIC_DM_NMI); 370 apic_write(APIC_LVTPC, APIC_DM_NMI);
371 evntsel |= K7_EVNTSEL_ENABLE; 371 evntsel |= K7_EVNTSEL_ENABLE;
372 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0); 372 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0);
@@ -407,8 +407,8 @@ static int setup_p4_watchdog(void)
407 407
408 wrmsr(MSR_P4_CRU_ESCR0, P4_NMI_CRU_ESCR0, 0); 408 wrmsr(MSR_P4_CRU_ESCR0, P4_NMI_CRU_ESCR0, 0);
409 wrmsr(MSR_P4_IQ_CCCR0, P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE, 0); 409 wrmsr(MSR_P4_IQ_CCCR0, P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE, 0);
410 Dprintk("setting P4_IQ_COUNTER0 to 0x%08lx\n", -(cpu_khz/nmi_hz*1000)); 410 Dprintk("setting P4_IQ_COUNTER0 to 0x%08lx\n", -(cpu_khz * 1000UL / nmi_hz));
411 wrmsr(MSR_P4_IQ_COUNTER0, -(cpu_khz/nmi_hz*1000), -1); 411 wrmsrl(MSR_P4_IQ_COUNTER0, -((u64)cpu_khz * 1000 / nmi_hz));
412 apic_write(APIC_LVTPC, APIC_DM_NMI); 412 apic_write(APIC_LVTPC, APIC_DM_NMI);
413 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0); 413 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0);
414 return 1; 414 return 1;
@@ -506,7 +506,7 @@ void nmi_watchdog_tick (struct pt_regs * regs, unsigned reason)
506 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0); 506 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0);
507 apic_write(APIC_LVTPC, APIC_DM_NMI); 507 apic_write(APIC_LVTPC, APIC_DM_NMI);
508 } 508 }
509 wrmsr(nmi_perfctr_msr, -(cpu_khz/nmi_hz*1000), -1); 509 wrmsrl(nmi_perfctr_msr, -((u64)cpu_khz * 1000 / nmi_hz));
510 } 510 }
511} 511}
512 512
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 46d655fab115..48f446d3c671 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -4,6 +4,8 @@ menu "Device Drivers"
4 4
5source "drivers/base/Kconfig" 5source "drivers/base/Kconfig"
6 6
7source "drivers/connector/Kconfig"
8
7source "drivers/mtd/Kconfig" 9source "drivers/mtd/Kconfig"
8 10
9source "drivers/parport/Kconfig" 11source "drivers/parport/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 86c8654a0ca9..1a109a6dd953 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -17,6 +17,8 @@ obj-$(CONFIG_PNP) += pnp/
17# default. 17# default.
18obj-y += char/ 18obj-y += char/
19 19
20obj-$(CONFIG_CONNECTOR) += connector/
21
20# i810fb and intelfb depend on char/agp/ 22# i810fb and intelfb depend on char/agp/
21obj-$(CONFIG_FB_I810) += video/i810/ 23obj-$(CONFIG_FB_I810) += video/i810/
22obj-$(CONFIG_FB_INTEL) += video/intelfb/ 24obj-$(CONFIG_FB_INTEL) += video/intelfb/
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
index 373e7b728fa7..6b2eb6f39b4d 100644
--- a/drivers/base/attribute_container.c
+++ b/drivers/base/attribute_container.c
@@ -152,12 +152,13 @@ attribute_container_add_device(struct device *dev,
152 152
153 if (!cont->match(cont, dev)) 153 if (!cont->match(cont, dev))
154 continue; 154 continue;
155 ic = kmalloc(sizeof(struct internal_container), GFP_KERNEL); 155
156 ic = kzalloc(sizeof(*ic), GFP_KERNEL);
156 if (!ic) { 157 if (!ic) {
157 dev_printk(KERN_ERR, dev, "failed to allocate class container\n"); 158 dev_printk(KERN_ERR, dev, "failed to allocate class container\n");
158 continue; 159 continue;
159 } 160 }
160 memset(ic, 0, sizeof(struct internal_container)); 161
161 ic->cont = cont; 162 ic->cont = cont;
162 class_device_initialize(&ic->classdev); 163 class_device_initialize(&ic->classdev);
163 ic->classdev.dev = get_device(dev); 164 ic->classdev.dev = get_device(dev);
diff --git a/drivers/base/class.c b/drivers/base/class.c
index d164c32a97ad..3b112e3542f8 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -189,12 +189,11 @@ struct class *class_create(struct module *owner, char *name)
189 struct class *cls; 189 struct class *cls;
190 int retval; 190 int retval;
191 191
192 cls = kmalloc(sizeof(struct class), GFP_KERNEL); 192 cls = kzalloc(sizeof(*cls), GFP_KERNEL);
193 if (!cls) { 193 if (!cls) {
194 retval = -ENOMEM; 194 retval = -ENOMEM;
195 goto error; 195 goto error;
196 } 196 }
197 memset(cls, 0x00, sizeof(struct class));
198 197
199 cls->name = name; 198 cls->name = name;
200 cls->owner = owner; 199 cls->owner = owner;
@@ -500,13 +499,13 @@ int class_device_add(struct class_device *class_dev)
500 /* add the needed attributes to this device */ 499 /* add the needed attributes to this device */
501 if (MAJOR(class_dev->devt)) { 500 if (MAJOR(class_dev->devt)) {
502 struct class_device_attribute *attr; 501 struct class_device_attribute *attr;
503 attr = kmalloc(sizeof(*attr), GFP_KERNEL); 502 attr = kzalloc(sizeof(*attr), GFP_KERNEL);
504 if (!attr) { 503 if (!attr) {
505 error = -ENOMEM; 504 error = -ENOMEM;
506 kobject_del(&class_dev->kobj); 505 kobject_del(&class_dev->kobj);
507 goto register_done; 506 goto register_done;
508 } 507 }
509 memset(attr, sizeof(*attr), 0x00); 508
510 attr->attr.name = "dev"; 509 attr->attr.name = "dev";
511 attr->attr.mode = S_IRUGO; 510 attr->attr.mode = S_IRUGO;
512 attr->attr.owner = parent->owner; 511 attr->attr.owner = parent->owner;
@@ -577,12 +576,11 @@ struct class_device *class_device_create(struct class *cls, dev_t devt,
577 if (cls == NULL || IS_ERR(cls)) 576 if (cls == NULL || IS_ERR(cls))
578 goto error; 577 goto error;
579 578
580 class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL); 579 class_dev = kzalloc(sizeof(*class_dev), GFP_KERNEL);
581 if (!class_dev) { 580 if (!class_dev) {
582 retval = -ENOMEM; 581 retval = -ENOMEM;
583 goto error; 582 goto error;
584 } 583 }
585 memset(class_dev, 0x00, sizeof(struct class_device));
586 584
587 class_dev->devt = devt; 585 class_dev->devt = devt;
588 class_dev->dev = device; 586 class_dev->dev = device;
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 5bfa2e9a7c26..4acb2c5733c3 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -301,9 +301,9 @@ fw_register_class_device(struct class_device **class_dev_p,
301 const char *fw_name, struct device *device) 301 const char *fw_name, struct device *device)
302{ 302{
303 int retval; 303 int retval;
304 struct firmware_priv *fw_priv = kmalloc(sizeof (struct firmware_priv), 304 struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv),
305 GFP_KERNEL); 305 GFP_KERNEL);
306 struct class_device *class_dev = kmalloc(sizeof (struct class_device), 306 struct class_device *class_dev = kzalloc(sizeof(*class_dev),
307 GFP_KERNEL); 307 GFP_KERNEL);
308 308
309 *class_dev_p = NULL; 309 *class_dev_p = NULL;
@@ -313,8 +313,6 @@ fw_register_class_device(struct class_device **class_dev_p,
313 retval = -ENOMEM; 313 retval = -ENOMEM;
314 goto error_kfree; 314 goto error_kfree;
315 } 315 }
316 memset(fw_priv, 0, sizeof (*fw_priv));
317 memset(class_dev, 0, sizeof (*class_dev));
318 316
319 init_completion(&fw_priv->completion); 317 init_completion(&fw_priv->completion);
320 fw_priv->attr_data = firmware_attr_data_tmpl; 318 fw_priv->attr_data = firmware_attr_data_tmpl;
@@ -402,14 +400,13 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
402 if (!firmware_p) 400 if (!firmware_p)
403 return -EINVAL; 401 return -EINVAL;
404 402
405 *firmware_p = firmware = kmalloc(sizeof (struct firmware), GFP_KERNEL); 403 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
406 if (!firmware) { 404 if (!firmware) {
407 printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", 405 printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n",
408 __FUNCTION__); 406 __FUNCTION__);
409 retval = -ENOMEM; 407 retval = -ENOMEM;
410 goto out; 408 goto out;
411 } 409 }
412 memset(firmware, 0, sizeof (*firmware));
413 410
414 retval = fw_setup_class_device(firmware, &class_dev, name, device, 411 retval = fw_setup_class_device(firmware, &class_dev, name, device,
415 hotplug); 412 hotplug);
diff --git a/drivers/base/map.c b/drivers/base/map.c
index 2f455d86793c..b449dae6f0d3 100644
--- a/drivers/base/map.c
+++ b/drivers/base/map.c
@@ -135,7 +135,7 @@ retry:
135struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem) 135struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem)
136{ 136{
137 struct kobj_map *p = kmalloc(sizeof(struct kobj_map), GFP_KERNEL); 137 struct kobj_map *p = kmalloc(sizeof(struct kobj_map), GFP_KERNEL);
138 struct probe *base = kmalloc(sizeof(struct probe), GFP_KERNEL); 138 struct probe *base = kzalloc(sizeof(*base), GFP_KERNEL);
139 int i; 139 int i;
140 140
141 if ((p == NULL) || (base == NULL)) { 141 if ((p == NULL) || (base == NULL)) {
@@ -144,7 +144,6 @@ struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem)
144 return NULL; 144 return NULL;
145 } 145 }
146 146
147 memset(base, 0, sizeof(struct probe));
148 base->dev = 1; 147 base->dev = 1;
149 base->range = ~0; 148 base->range = ~0;
150 base->get = base_probe; 149 base->get = base_probe;
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 3a5f4c991797..361e204209eb 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -225,13 +225,12 @@ struct platform_device *platform_device_register_simple(char *name, unsigned int
225 struct platform_object *pobj; 225 struct platform_object *pobj;
226 int retval; 226 int retval;
227 227
228 pobj = kmalloc(sizeof(struct platform_object) + sizeof(struct resource) * num, GFP_KERNEL); 228 pobj = kzalloc(sizeof(*pobj) + sizeof(struct resource) * num, GFP_KERNEL);
229 if (!pobj) { 229 if (!pobj) {
230 retval = -ENOMEM; 230 retval = -ENOMEM;
231 goto error; 231 goto error;
232 } 232 }
233 233
234 memset(pobj, 0, sizeof(*pobj));
235 pobj->pdev.name = name; 234 pobj->pdev.name = name;
236 pobj->pdev.id = id; 235 pobj->pdev.id = id;
237 pobj->pdev.dev.release = platform_device_release_simple; 236 pobj->pdev.dev.release = platform_device_release_simple;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 28f2c177a541..c56f995aadad 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -47,14 +47,14 @@
47#include <linux/completion.h> 47#include <linux/completion.h>
48 48
49#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) 49#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
50#define DRIVER_NAME "HP CISS Driver (v 2.6.6)" 50#define DRIVER_NAME "HP CISS Driver (v 2.6.8)"
51#define DRIVER_VERSION CCISS_DRIVER_VERSION(2,6,6) 51#define DRIVER_VERSION CCISS_DRIVER_VERSION(2,6,8)
52 52
53/* Embedded module documentation macros - see modules.h */ 53/* Embedded module documentation macros - see modules.h */
54MODULE_AUTHOR("Hewlett-Packard Company"); 54MODULE_AUTHOR("Hewlett-Packard Company");
55MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 2.6.6"); 55MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 2.6.8");
56MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400" 56MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400"
57 " SA6i P600 P800 E400 E300"); 57 " SA6i P600 P800 P400 P400i E200 E200i");
58MODULE_LICENSE("GPL"); 58MODULE_LICENSE("GPL");
59 59
60#include "cciss_cmd.h" 60#include "cciss_cmd.h"
@@ -83,12 +83,22 @@ static const struct pci_device_id cciss_pci_device_id[] = {
83 0x0E11, 0x4091, 0, 0, 0}, 83 0x0E11, 0x4091, 0, 0, 0},
84 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSA, 84 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSA,
85 0x103C, 0x3225, 0, 0, 0}, 85 0x103C, 0x3225, 0, 0, 0},
86 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSB, 86 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC,
87 0x103c, 0x3223, 0, 0, 0}, 87 0x103c, 0x3223, 0, 0, 0},
88 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 88 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC,
89 0x103c, 0x3231, 0, 0, 0}, 89 0x103c, 0x3234, 0, 0, 0},
90 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 90 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC,
91 0x103c, 0x3233, 0, 0, 0}, 91 0x103c, 0x3235, 0, 0, 0},
92 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD,
93 0x103c, 0x3211, 0, 0, 0},
94 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD,
95 0x103c, 0x3212, 0, 0, 0},
96 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD,
97 0x103c, 0x3213, 0, 0, 0},
98 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD,
99 0x103c, 0x3214, 0, 0, 0},
100 { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD,
101 0x103c, 0x3215, 0, 0, 0},
92 {0,} 102 {0,}
93}; 103};
94MODULE_DEVICE_TABLE(pci, cciss_pci_device_id); 104MODULE_DEVICE_TABLE(pci, cciss_pci_device_id);
@@ -111,8 +121,13 @@ static struct board_type products[] = {
111 { 0x40910E11, "Smart Array 6i", &SA5_access}, 121 { 0x40910E11, "Smart Array 6i", &SA5_access},
112 { 0x3225103C, "Smart Array P600", &SA5_access}, 122 { 0x3225103C, "Smart Array P600", &SA5_access},
113 { 0x3223103C, "Smart Array P800", &SA5_access}, 123 { 0x3223103C, "Smart Array P800", &SA5_access},
114 { 0x3231103C, "Smart Array E400", &SA5_access}, 124 { 0x3234103C, "Smart Array P400", &SA5_access},
115 { 0x3233103C, "Smart Array E300", &SA5_access}, 125 { 0x3235103C, "Smart Array P400i", &SA5_access},
126 { 0x3211103C, "Smart Array E200i", &SA5_access},
127 { 0x3212103C, "Smart Array E200", &SA5_access},
128 { 0x3213103C, "Smart Array E200i", &SA5_access},
129 { 0x3214103C, "Smart Array E200i", &SA5_access},
130 { 0x3215103C, "Smart Array E200i", &SA5_access},
116}; 131};
117 132
118/* How long to wait (in millesconds) for board to go into simple mode */ 133/* How long to wait (in millesconds) for board to go into simple mode */
@@ -140,15 +155,26 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
140 155
141static int revalidate_allvol(ctlr_info_t *host); 156static int revalidate_allvol(ctlr_info_t *host);
142static int cciss_revalidate(struct gendisk *disk); 157static int cciss_revalidate(struct gendisk *disk);
143static int deregister_disk(struct gendisk *disk); 158static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk);
144static int register_new_disk(ctlr_info_t *h); 159static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, int clear_all);
145 160
161static void cciss_read_capacity(int ctlr, int logvol, ReadCapdata_struct *buf,
162 int withirq, unsigned int *total_size, unsigned int *block_size);
163static void cciss_geometry_inquiry(int ctlr, int logvol,
164 int withirq, unsigned int total_size,
165 unsigned int block_size, InquiryData_struct *inq_buff,
166 drive_info_struct *drv);
146static void cciss_getgeometry(int cntl_num); 167static void cciss_getgeometry(int cntl_num);
147 168
148static void start_io( ctlr_info_t *h); 169static void start_io( ctlr_info_t *h);
149static int sendcmd( __u8 cmd, int ctlr, void *buff, size_t size, 170static int sendcmd( __u8 cmd, int ctlr, void *buff, size_t size,
150 unsigned int use_unit_num, unsigned int log_unit, __u8 page_code, 171 unsigned int use_unit_num, unsigned int log_unit, __u8 page_code,
151 unsigned char *scsi3addr, int cmd_type); 172 unsigned char *scsi3addr, int cmd_type);
173static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size,
174 unsigned int use_unit_num, unsigned int log_unit, __u8 page_code,
175 int cmd_type);
176
177static void fail_all_cmds(unsigned long ctlr);
152 178
153#ifdef CONFIG_PROC_FS 179#ifdef CONFIG_PROC_FS
154static int cciss_proc_get_info(char *buffer, char **start, off_t offset, 180static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
@@ -265,7 +291,7 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
265 for(i=0; i<=h->highest_lun; i++) { 291 for(i=0; i<=h->highest_lun; i++) {
266 292
267 drv = &h->drv[i]; 293 drv = &h->drv[i];
268 if (drv->block_size == 0) 294 if (drv->heads == 0)
269 continue; 295 continue;
270 296
271 vol_sz = drv->nr_blocks; 297 vol_sz = drv->nr_blocks;
@@ -363,6 +389,8 @@ static CommandList_struct * cmd_alloc(ctlr_info_t *h, int get_from_pool)
363 return NULL; 389 return NULL;
364 memset(c, 0, sizeof(CommandList_struct)); 390 memset(c, 0, sizeof(CommandList_struct));
365 391
392 c->cmdindex = -1;
393
366 c->err_info = (ErrorInfo_struct *)pci_alloc_consistent( 394 c->err_info = (ErrorInfo_struct *)pci_alloc_consistent(
367 h->pdev, sizeof(ErrorInfo_struct), 395 h->pdev, sizeof(ErrorInfo_struct),
368 &err_dma_handle); 396 &err_dma_handle);
@@ -393,6 +421,8 @@ static CommandList_struct * cmd_alloc(ctlr_info_t *h, int get_from_pool)
393 err_dma_handle = h->errinfo_pool_dhandle 421 err_dma_handle = h->errinfo_pool_dhandle
394 + i*sizeof(ErrorInfo_struct); 422 + i*sizeof(ErrorInfo_struct);
395 h->nr_allocs++; 423 h->nr_allocs++;
424
425 c->cmdindex = i;
396 } 426 }
397 427
398 c->busaddr = (__u32) cmd_dma_handle; 428 c->busaddr = (__u32) cmd_dma_handle;
@@ -453,6 +483,11 @@ static int cciss_open(struct inode *inode, struct file *filep)
453 printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name); 483 printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name);
454#endif /* CCISS_DEBUG */ 484#endif /* CCISS_DEBUG */
455 485
486 if (host->busy_initializing)
487 return -EBUSY;
488
489 if (host->busy_initializing || drv->busy_configuring)
490 return -EBUSY;
456 /* 491 /*
457 * Root is allowed to open raw volume zero even if it's not configured 492 * Root is allowed to open raw volume zero even if it's not configured
458 * so array config can still work. Root is also allowed to open any 493 * so array config can still work. Root is also allowed to open any
@@ -796,10 +831,10 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
796 return(0); 831 return(0);
797 } 832 }
798 case CCISS_DEREGDISK: 833 case CCISS_DEREGDISK:
799 return deregister_disk(disk); 834 return rebuild_lun_table(host, disk);
800 835
801 case CCISS_REGNEWD: 836 case CCISS_REGNEWD:
802 return register_new_disk(host); 837 return rebuild_lun_table(host, NULL);
803 838
804 case CCISS_PASSTHRU: 839 case CCISS_PASSTHRU:
805 { 840 {
@@ -1143,48 +1178,323 @@ static int revalidate_allvol(ctlr_info_t *host)
1143 return 0; 1178 return 0;
1144} 1179}
1145 1180
1146static int deregister_disk(struct gendisk *disk) 1181/* This function will check the usage_count of the drive to be updated/added.
1182 * If the usage_count is zero then the drive information will be updated and
1183 * the disk will be re-registered with the kernel. If not then it will be
1184 * left alone for the next reboot. The exception to this is disk 0 which
1185 * will always be left registered with the kernel since it is also the
1186 * controller node. Any changes to disk 0 will show up on the next
1187 * reboot.
1188*/
1189static void cciss_update_drive_info(int ctlr, int drv_index)
1190 {
1191 ctlr_info_t *h = hba[ctlr];
1192 struct gendisk *disk;
1193 ReadCapdata_struct *size_buff = NULL;
1194 InquiryData_struct *inq_buff = NULL;
1195 unsigned int block_size;
1196 unsigned int total_size;
1197 unsigned long flags = 0;
1198 int ret = 0;
1199
1200 /* if the disk already exists then deregister it before proceeding*/
1201 if (h->drv[drv_index].raid_level != -1){
1202 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags);
1203 h->drv[drv_index].busy_configuring = 1;
1204 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1205 ret = deregister_disk(h->gendisk[drv_index],
1206 &h->drv[drv_index], 0);
1207 h->drv[drv_index].busy_configuring = 0;
1208 }
1209
1210 /* If the disk is in use return */
1211 if (ret)
1212 return;
1213
1214
1215 /* Get information about the disk and modify the driver sturcture */
1216 size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL);
1217 if (size_buff == NULL)
1218 goto mem_msg;
1219 inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL);
1220 if (inq_buff == NULL)
1221 goto mem_msg;
1222
1223 cciss_read_capacity(ctlr, drv_index, size_buff, 1,
1224 &total_size, &block_size);
1225 cciss_geometry_inquiry(ctlr, drv_index, 1, total_size, block_size,
1226 inq_buff, &h->drv[drv_index]);
1227
1228 ++h->num_luns;
1229 disk = h->gendisk[drv_index];
1230 set_capacity(disk, h->drv[drv_index].nr_blocks);
1231
1232
1233 /* if it's the controller it's already added */
1234 if (drv_index){
1235 disk->queue = blk_init_queue(do_cciss_request, &h->lock);
1236
1237 /* Set up queue information */
1238 disk->queue->backing_dev_info.ra_pages = READ_AHEAD;
1239 blk_queue_bounce_limit(disk->queue, hba[ctlr]->pdev->dma_mask);
1240
1241 /* This is a hardware imposed limit. */
1242 blk_queue_max_hw_segments(disk->queue, MAXSGENTRIES);
1243
1244 /* This is a limit in the driver and could be eliminated. */
1245 blk_queue_max_phys_segments(disk->queue, MAXSGENTRIES);
1246
1247 blk_queue_max_sectors(disk->queue, 512);
1248
1249 disk->queue->queuedata = hba[ctlr];
1250
1251 blk_queue_hardsect_size(disk->queue,
1252 hba[ctlr]->drv[drv_index].block_size);
1253
1254 h->drv[drv_index].queue = disk->queue;
1255 add_disk(disk);
1256 }
1257
1258freeret:
1259 kfree(size_buff);
1260 kfree(inq_buff);
1261 return;
1262mem_msg:
1263 printk(KERN_ERR "cciss: out of memory\n");
1264 goto freeret;
1265}
1266
1267/* This function will find the first index of the controllers drive array
1268 * that has a -1 for the raid_level and will return that index. This is
1269 * where new drives will be added. If the index to be returned is greater
1270 * than the highest_lun index for the controller then highest_lun is set
1271 * to this new index. If there are no available indexes then -1 is returned.
1272*/
1273static int cciss_find_free_drive_index(int ctlr)
1147{ 1274{
1275 int i;
1276
1277 for (i=0; i < CISS_MAX_LUN; i++){
1278 if (hba[ctlr]->drv[i].raid_level == -1){
1279 if (i > hba[ctlr]->highest_lun)
1280 hba[ctlr]->highest_lun = i;
1281 return i;
1282 }
1283 }
1284 return -1;
1285}
1286
1287/* This function will add and remove logical drives from the Logical
1288 * drive array of the controller and maintain persistancy of ordering
1289 * so that mount points are preserved until the next reboot. This allows
1290 * for the removal of logical drives in the middle of the drive array
1291 * without a re-ordering of those drives.
1292 * INPUT
1293 * h = The controller to perform the operations on
1294 * del_disk = The disk to remove if specified. If the value given
1295 * is NULL then no disk is removed.
1296*/
1297static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1298{
1299 int ctlr = h->ctlr;
1300 int num_luns;
1301 ReportLunData_struct *ld_buff = NULL;
1302 drive_info_struct *drv = NULL;
1303 int return_code;
1304 int listlength = 0;
1305 int i;
1306 int drv_found;
1307 int drv_index = 0;
1308 __u32 lunid = 0;
1148 unsigned long flags; 1309 unsigned long flags;
1310
1311 /* Set busy_configuring flag for this operation */
1312 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags);
1313 if (h->num_luns >= CISS_MAX_LUN){
1314 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1315 return -EINVAL;
1316 }
1317
1318 if (h->busy_configuring){
1319 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1320 return -EBUSY;
1321 }
1322 h->busy_configuring = 1;
1323
1324 /* if del_disk is NULL then we are being called to add a new disk
1325 * and update the logical drive table. If it is not NULL then
1326 * we will check if the disk is in use or not.
1327 */
1328 if (del_disk != NULL){
1329 drv = get_drv(del_disk);
1330 drv->busy_configuring = 1;
1331 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1332 return_code = deregister_disk(del_disk, drv, 1);
1333 drv->busy_configuring = 0;
1334 h->busy_configuring = 0;
1335 return return_code;
1336 } else {
1337 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1338 if (!capable(CAP_SYS_RAWIO))
1339 return -EPERM;
1340
1341 ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL);
1342 if (ld_buff == NULL)
1343 goto mem_msg;
1344
1345 return_code = sendcmd_withirq(CISS_REPORT_LOG, ctlr, ld_buff,
1346 sizeof(ReportLunData_struct), 0, 0, 0,
1347 TYPE_CMD);
1348
1349 if (return_code == IO_OK){
1350 listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[0])) << 24;
1351 listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[1])) << 16;
1352 listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[2])) << 8;
1353 listlength |= 0xff & (unsigned int)(ld_buff->LUNListLength[3]);
1354 } else{ /* reading number of logical volumes failed */
1355 printk(KERN_WARNING "cciss: report logical volume"
1356 " command failed\n");
1357 listlength = 0;
1358 goto freeret;
1359 }
1360
1361 num_luns = listlength / 8; /* 8 bytes per entry */
1362 if (num_luns > CISS_MAX_LUN){
1363 num_luns = CISS_MAX_LUN;
1364 printk(KERN_WARNING "cciss: more luns configured"
1365 " on controller than can be handled by"
1366 " this driver.\n");
1367 }
1368
1369 /* Compare controller drive array to drivers drive array.
1370 * Check for updates in the drive information and any new drives
1371 * on the controller.
1372 */
1373 for (i=0; i < num_luns; i++){
1374 int j;
1375
1376 drv_found = 0;
1377
1378 lunid = (0xff &
1379 (unsigned int)(ld_buff->LUN[i][3])) << 24;
1380 lunid |= (0xff &
1381 (unsigned int)(ld_buff->LUN[i][2])) << 16;
1382 lunid |= (0xff &
1383 (unsigned int)(ld_buff->LUN[i][1])) << 8;
1384 lunid |= 0xff &
1385 (unsigned int)(ld_buff->LUN[i][0]);
1386
1387 /* Find if the LUN is already in the drive array
1388 * of the controller. If so then update its info
1389 * if not is use. If it does not exist then find
1390 * the first free index and add it.
1391 */
1392 for (j=0; j <= h->highest_lun; j++){
1393 if (h->drv[j].LunID == lunid){
1394 drv_index = j;
1395 drv_found = 1;
1396 }
1397 }
1398
1399 /* check if the drive was found already in the array */
1400 if (!drv_found){
1401 drv_index = cciss_find_free_drive_index(ctlr);
1402 if (drv_index == -1)
1403 goto freeret;
1404
1405 }
1406 h->drv[drv_index].LunID = lunid;
1407 cciss_update_drive_info(ctlr, drv_index);
1408 } /* end for */
1409 } /* end else */
1410
1411freeret:
1412 kfree(ld_buff);
1413 h->busy_configuring = 0;
1414 /* We return -1 here to tell the ACU that we have registered/updated
1415 * all of the drives that we can and to keep it from calling us
1416 * additional times.
1417 */
1418 return -1;
1419mem_msg:
1420 printk(KERN_ERR "cciss: out of memory\n");
1421 goto freeret;
1422}
1423
1424/* This function will deregister the disk and it's queue from the
1425 * kernel. It must be called with the controller lock held and the
1426 * drv structures busy_configuring flag set. It's parameters are:
1427 *
1428 * disk = This is the disk to be deregistered
1429 * drv = This is the drive_info_struct associated with the disk to be
1430 * deregistered. It contains information about the disk used
1431 * by the driver.
1432 * clear_all = This flag determines whether or not the disk information
1433 * is going to be completely cleared out and the highest_lun
1434 * reset. Sometimes we want to clear out information about
1435 * the disk in preperation for re-adding it. In this case
1436 * the highest_lun should be left unchanged and the LunID
1437 * should not be cleared.
1438*/
1439static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
1440 int clear_all)
1441{
1149 ctlr_info_t *h = get_host(disk); 1442 ctlr_info_t *h = get_host(disk);
1150 drive_info_struct *drv = get_drv(disk);
1151 int ctlr = h->ctlr;
1152 1443
1153 if (!capable(CAP_SYS_RAWIO)) 1444 if (!capable(CAP_SYS_RAWIO))
1154 return -EPERM; 1445 return -EPERM;
1155 1446
1156 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1157 /* make sure logical volume is NOT is use */ 1447 /* make sure logical volume is NOT is use */
1158 if( drv->usage_count > 1) { 1448 if(clear_all || (h->gendisk[0] == disk)) {
1159 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); 1449 if (drv->usage_count > 1)
1160 return -EBUSY; 1450 return -EBUSY;
1161 } 1451 }
1162 drv->usage_count++; 1452 else
1163 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); 1453 if( drv->usage_count > 0 )
1454 return -EBUSY;
1164 1455
1165 /* invalidate the devices and deregister the disk */ 1456 /* invalidate the devices and deregister the disk. If it is disk
1166 if (disk->flags & GENHD_FL_UP) 1457 * zero do not deregister it but just zero out it's values. This
1458 * allows us to delete disk zero but keep the controller registered.
1459 */
1460 if (h->gendisk[0] != disk){
1461 if (disk->flags & GENHD_FL_UP){
1462 blk_cleanup_queue(disk->queue);
1167 del_gendisk(disk); 1463 del_gendisk(disk);
1464 drv->queue = NULL;
1465 }
1466 }
1467
1468 --h->num_luns;
1469 /* zero out the disk size info */
1470 drv->nr_blocks = 0;
1471 drv->block_size = 0;
1472 drv->heads = 0;
1473 drv->sectors = 0;
1474 drv->cylinders = 0;
1475 drv->raid_level = -1; /* This can be used as a flag variable to
1476 * indicate that this element of the drive
1477 * array is free.
1478 */
1479
1480 if (clear_all){
1168 /* check to see if it was the last disk */ 1481 /* check to see if it was the last disk */
1169 if (drv == h->drv + h->highest_lun) { 1482 if (drv == h->drv + h->highest_lun) {
1170 /* if so, find the new hightest lun */ 1483 /* if so, find the new hightest lun */
1171 int i, newhighest =-1; 1484 int i, newhighest =-1;
1172 for(i=0; i<h->highest_lun; i++) { 1485 for(i=0; i<h->highest_lun; i++) {
1173 /* if the disk has size > 0, it is available */ 1486 /* if the disk has size > 0, it is available */
1174 if (h->drv[i].nr_blocks) 1487 if (h->drv[i].heads)
1175 newhighest = i; 1488 newhighest = i;
1176 } 1489 }
1177 h->highest_lun = newhighest; 1490 h->highest_lun = newhighest;
1178
1179 } 1491 }
1180 --h->num_luns; 1492
1181 /* zero out the disk size info */
1182 drv->nr_blocks = 0;
1183 drv->block_size = 0;
1184 drv->cylinders = 0;
1185 drv->LunID = 0; 1493 drv->LunID = 0;
1494 }
1186 return(0); 1495 return(0);
1187} 1496}
1497
1188static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, 1498static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff,
1189 size_t size, 1499 size_t size,
1190 unsigned int use_unit_num, /* 0: address the controller, 1500 unsigned int use_unit_num, /* 0: address the controller,
@@ -1420,8 +1730,10 @@ case CMD_HARDWARE_ERR:
1420 } 1730 }
1421 } 1731 }
1422 /* unlock the buffers from DMA */ 1732 /* unlock the buffers from DMA */
1733 buff_dma_handle.val32.lower = c->SG[0].Addr.lower;
1734 buff_dma_handle.val32.upper = c->SG[0].Addr.upper;
1423 pci_unmap_single( h->pdev, (dma_addr_t) buff_dma_handle.val, 1735 pci_unmap_single( h->pdev, (dma_addr_t) buff_dma_handle.val,
1424 size, PCI_DMA_BIDIRECTIONAL); 1736 c->SG[0].Len, PCI_DMA_BIDIRECTIONAL);
1425 cmd_free(h, c, 0); 1737 cmd_free(h, c, 0);
1426 return(return_status); 1738 return(return_status);
1427 1739
@@ -1495,164 +1807,6 @@ cciss_read_capacity(int ctlr, int logvol, ReadCapdata_struct *buf,
1495 return; 1807 return;
1496} 1808}
1497 1809
1498static int register_new_disk(ctlr_info_t *h)
1499{
1500 struct gendisk *disk;
1501 int ctlr = h->ctlr;
1502 int i;
1503 int num_luns;
1504 int logvol;
1505 int new_lun_found = 0;
1506 int new_lun_index = 0;
1507 int free_index_found = 0;
1508 int free_index = 0;
1509 ReportLunData_struct *ld_buff = NULL;
1510 ReadCapdata_struct *size_buff = NULL;
1511 InquiryData_struct *inq_buff = NULL;
1512 int return_code;
1513 int listlength = 0;
1514 __u32 lunid = 0;
1515 unsigned int block_size;
1516 unsigned int total_size;
1517
1518 if (!capable(CAP_SYS_RAWIO))
1519 return -EPERM;
1520 /* if we have no space in our disk array left to add anything */
1521 if( h->num_luns >= CISS_MAX_LUN)
1522 return -EINVAL;
1523
1524 ld_buff = kmalloc(sizeof(ReportLunData_struct), GFP_KERNEL);
1525 if (ld_buff == NULL)
1526 goto mem_msg;
1527 memset(ld_buff, 0, sizeof(ReportLunData_struct));
1528 size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL);
1529 if (size_buff == NULL)
1530 goto mem_msg;
1531 inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL);
1532 if (inq_buff == NULL)
1533 goto mem_msg;
1534
1535 return_code = sendcmd_withirq(CISS_REPORT_LOG, ctlr, ld_buff,
1536 sizeof(ReportLunData_struct), 0, 0, 0, TYPE_CMD);
1537
1538 if( return_code == IO_OK)
1539 {
1540
1541 // printk("LUN Data\n--------------------------\n");
1542
1543 listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[0])) << 24;
1544 listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[1])) << 16;
1545 listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[2])) << 8;
1546 listlength |= 0xff & (unsigned int)(ld_buff->LUNListLength[3]);
1547 } else /* reading number of logical volumes failed */
1548 {
1549 printk(KERN_WARNING "cciss: report logical volume"
1550 " command failed\n");
1551 listlength = 0;
1552 goto free_err;
1553 }
1554 num_luns = listlength / 8; // 8 bytes pre entry
1555 if (num_luns > CISS_MAX_LUN)
1556 {
1557 num_luns = CISS_MAX_LUN;
1558 }
1559#ifdef CCISS_DEBUG
1560 printk(KERN_DEBUG "Length = %x %x %x %x = %d\n", ld_buff->LUNListLength[0],
1561 ld_buff->LUNListLength[1], ld_buff->LUNListLength[2],
1562 ld_buff->LUNListLength[3], num_luns);
1563#endif
1564 for(i=0; i< num_luns; i++)
1565 {
1566 int j;
1567 int lunID_found = 0;
1568
1569 lunid = (0xff & (unsigned int)(ld_buff->LUN[i][3])) << 24;
1570 lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][2])) << 16;
1571 lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][1])) << 8;
1572 lunid |= 0xff & (unsigned int)(ld_buff->LUN[i][0]);
1573
1574 /* check to see if this is a new lun */
1575 for(j=0; j <= h->highest_lun; j++)
1576 {
1577#ifdef CCISS_DEBUG
1578 printk("Checking %d %x against %x\n", j,h->drv[j].LunID,
1579 lunid);
1580#endif /* CCISS_DEBUG */
1581 if (h->drv[j].LunID == lunid)
1582 {
1583 lunID_found = 1;
1584 break;
1585 }
1586
1587 }
1588 if( lunID_found == 1)
1589 continue;
1590 else
1591 { /* It is the new lun we have been looking for */
1592#ifdef CCISS_DEBUG
1593 printk("new lun found at %d\n", i);
1594#endif /* CCISS_DEBUG */
1595 new_lun_index = i;
1596 new_lun_found = 1;
1597 break;
1598 }
1599 }
1600 if (!new_lun_found)
1601 {
1602 printk(KERN_WARNING "cciss: New Logical Volume not found\n");
1603 goto free_err;
1604 }
1605 /* Now find the free index */
1606 for(i=0; i <CISS_MAX_LUN; i++)
1607 {
1608#ifdef CCISS_DEBUG
1609 printk("Checking Index %d\n", i);
1610#endif /* CCISS_DEBUG */
1611 if(h->drv[i].LunID == 0)
1612 {
1613#ifdef CCISS_DEBUG
1614 printk("free index found at %d\n", i);
1615#endif /* CCISS_DEBUG */
1616 free_index_found = 1;
1617 free_index = i;
1618 break;
1619 }
1620 }
1621 if (!free_index_found)
1622 {
1623 printk(KERN_WARNING "cciss: unable to find free slot for disk\n");
1624 goto free_err;
1625 }
1626
1627 logvol = free_index;
1628 h->drv[logvol].LunID = lunid;
1629 /* there could be gaps in lun numbers, track hightest */
1630 if(h->highest_lun < lunid)
1631 h->highest_lun = logvol;
1632 cciss_read_capacity(ctlr, logvol, size_buff, 1,
1633 &total_size, &block_size);
1634 cciss_geometry_inquiry(ctlr, logvol, 1, total_size, block_size,
1635 inq_buff, &h->drv[logvol]);
1636 h->drv[logvol].usage_count = 0;
1637 ++h->num_luns;
1638 /* setup partitions per disk */
1639 disk = h->gendisk[logvol];
1640 set_capacity(disk, h->drv[logvol].nr_blocks);
1641 /* if it's the controller it's already added */
1642 if(logvol)
1643 add_disk(disk);
1644freeret:
1645 kfree(ld_buff);
1646 kfree(size_buff);
1647 kfree(inq_buff);
1648 return (logvol);
1649mem_msg:
1650 printk(KERN_ERR "cciss: out of memory\n");
1651free_err:
1652 logvol = -1;
1653 goto freeret;
1654}
1655
1656static int cciss_revalidate(struct gendisk *disk) 1810static int cciss_revalidate(struct gendisk *disk)
1657{ 1811{
1658 ctlr_info_t *h = get_host(disk); 1812 ctlr_info_t *h = get_host(disk);
@@ -1859,8 +2013,10 @@ resend_cmd1:
1859 2013
1860cleanup1: 2014cleanup1:
1861 /* unlock the data buffer from DMA */ 2015 /* unlock the data buffer from DMA */
2016 buff_dma_handle.val32.lower = c->SG[0].Addr.lower;
2017 buff_dma_handle.val32.upper = c->SG[0].Addr.upper;
1862 pci_unmap_single(info_p->pdev, (dma_addr_t) buff_dma_handle.val, 2018 pci_unmap_single(info_p->pdev, (dma_addr_t) buff_dma_handle.val,
1863 size, PCI_DMA_BIDIRECTIONAL); 2019 c->SG[0].Len, PCI_DMA_BIDIRECTIONAL);
1864 cmd_free(info_p, c, 1); 2020 cmd_free(info_p, c, 1);
1865 return (status); 2021 return (status);
1866} 2022}
@@ -2111,7 +2267,11 @@ queue:
2111 /* fill in the request */ 2267 /* fill in the request */
2112 drv = creq->rq_disk->private_data; 2268 drv = creq->rq_disk->private_data;
2113 c->Header.ReplyQueue = 0; // unused in simple mode 2269 c->Header.ReplyQueue = 0; // unused in simple mode
2114 c->Header.Tag.lower = c->busaddr; // use the physical address the cmd block for tag 2270 /* got command from pool, so use the command block index instead */
2271 /* for direct lookups. */
2272 /* The first 2 bits are reserved for controller error reporting. */
2273 c->Header.Tag.lower = (c->cmdindex << 3);
2274 c->Header.Tag.lower |= 0x04; /* flag for direct lookup. */
2115 c->Header.LUN.LogDev.VolId= drv->LunID; 2275 c->Header.LUN.LogDev.VolId= drv->LunID;
2116 c->Header.LUN.LogDev.Mode = 1; 2276 c->Header.LUN.LogDev.Mode = 1;
2117 c->Request.CDBLen = 10; // 12 byte commands not in FW yet; 2277 c->Request.CDBLen = 10; // 12 byte commands not in FW yet;
@@ -2186,7 +2346,7 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
2186 ctlr_info_t *h = dev_id; 2346 ctlr_info_t *h = dev_id;
2187 CommandList_struct *c; 2347 CommandList_struct *c;
2188 unsigned long flags; 2348 unsigned long flags;
2189 __u32 a, a1; 2349 __u32 a, a1, a2;
2190 int j; 2350 int j;
2191 int start_queue = h->next_to_run; 2351 int start_queue = h->next_to_run;
2192 2352
@@ -2204,10 +2364,21 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
2204 while((a = h->access.command_completed(h)) != FIFO_EMPTY) 2364 while((a = h->access.command_completed(h)) != FIFO_EMPTY)
2205 { 2365 {
2206 a1 = a; 2366 a1 = a;
2367 if ((a & 0x04)) {
2368 a2 = (a >> 3);
2369 if (a2 >= NR_CMDS) {
2370 printk(KERN_WARNING "cciss: controller cciss%d failed, stopping.\n", h->ctlr);
2371 fail_all_cmds(h->ctlr);
2372 return IRQ_HANDLED;
2373 }
2374
2375 c = h->cmd_pool + a2;
2376 a = c->busaddr;
2377
2378 } else {
2207 a &= ~3; 2379 a &= ~3;
2208 if ((c = h->cmpQ) == NULL) 2380 if ((c = h->cmpQ) == NULL) {
2209 { 2381 printk(KERN_WARNING "cciss: Completion of %08x ignored\n", a1);
2210 printk(KERN_WARNING "cciss: Completion of %08lx ignored\n", (unsigned long)a1);
2211 continue; 2382 continue;
2212 } 2383 }
2213 while(c->busaddr != a) { 2384 while(c->busaddr != a) {
@@ -2215,6 +2386,7 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
2215 if (c == h->cmpQ) 2386 if (c == h->cmpQ)
2216 break; 2387 break;
2217 } 2388 }
2389 }
2218 /* 2390 /*
2219 * If we've found the command, take it off the 2391 * If we've found the command, take it off the
2220 * completion Q and free it 2392 * completion Q and free it
@@ -2634,12 +2806,16 @@ static void cciss_getgeometry(int cntl_num)
2634#endif /* CCISS_DEBUG */ 2806#endif /* CCISS_DEBUG */
2635 2807
2636 hba[cntl_num]->highest_lun = hba[cntl_num]->num_luns-1; 2808 hba[cntl_num]->highest_lun = hba[cntl_num]->num_luns-1;
2637 for(i=0; i< hba[cntl_num]->num_luns; i++) 2809// for(i=0; i< hba[cntl_num]->num_luns; i++)
2810 for(i=0; i < CISS_MAX_LUN; i++)
2638 { 2811 {
2639 2812 if (i < hba[cntl_num]->num_luns){
2640 lunid = (0xff & (unsigned int)(ld_buff->LUN[i][3])) << 24; 2813 lunid = (0xff & (unsigned int)(ld_buff->LUN[i][3]))
2641 lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][2])) << 16; 2814 << 24;
2642 lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][1])) << 8; 2815 lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][2]))
2816 << 16;
2817 lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][1]))
2818 << 8;
2643 lunid |= 0xff & (unsigned int)(ld_buff->LUN[i][0]); 2819 lunid |= 0xff & (unsigned int)(ld_buff->LUN[i][0]);
2644 2820
2645 hba[cntl_num]->drv[i].LunID = lunid; 2821 hba[cntl_num]->drv[i].LunID = lunid;
@@ -2647,13 +2823,18 @@ static void cciss_getgeometry(int cntl_num)
2647 2823
2648#ifdef CCISS_DEBUG 2824#ifdef CCISS_DEBUG
2649 printk(KERN_DEBUG "LUN[%d]: %x %x %x %x = %x\n", i, 2825 printk(KERN_DEBUG "LUN[%d]: %x %x %x %x = %x\n", i,
2650 ld_buff->LUN[i][0], ld_buff->LUN[i][1],ld_buff->LUN[i][2], 2826 ld_buff->LUN[i][0], ld_buff->LUN[i][1],
2651 ld_buff->LUN[i][3], hba[cntl_num]->drv[i].LunID); 2827 ld_buff->LUN[i][2], ld_buff->LUN[i][3],
2828 hba[cntl_num]->drv[i].LunID);
2652#endif /* CCISS_DEBUG */ 2829#endif /* CCISS_DEBUG */
2653 cciss_read_capacity(cntl_num, i, size_buff, 0, 2830 cciss_read_capacity(cntl_num, i, size_buff, 0,
2654 &total_size, &block_size); 2831 &total_size, &block_size);
2655 cciss_geometry_inquiry(cntl_num, i, 0, total_size, block_size, 2832 cciss_geometry_inquiry(cntl_num, i, 0, total_size,
2656 inq_buff, &hba[cntl_num]->drv[i]); 2833 block_size, inq_buff, &hba[cntl_num]->drv[i]);
2834 } else {
2835 /* initialize raid_level to indicate a free space */
2836 hba[cntl_num]->drv[i].raid_level = -1;
2837 }
2657 } 2838 }
2658 kfree(ld_buff); 2839 kfree(ld_buff);
2659 kfree(size_buff); 2840 kfree(size_buff);
@@ -2727,6 +2908,9 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
2727 i = alloc_cciss_hba(); 2908 i = alloc_cciss_hba();
2728 if(i < 0) 2909 if(i < 0)
2729 return (-1); 2910 return (-1);
2911
2912 hba[i]->busy_initializing = 1;
2913
2730 if (cciss_pci_init(hba[i], pdev) != 0) 2914 if (cciss_pci_init(hba[i], pdev) != 0)
2731 goto clean1; 2915 goto clean1;
2732 2916
@@ -2849,6 +3033,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
2849 add_disk(disk); 3033 add_disk(disk);
2850 } 3034 }
2851 3035
3036 hba[i]->busy_initializing = 0;
2852 return(1); 3037 return(1);
2853 3038
2854clean4: 3039clean4:
@@ -2869,6 +3054,7 @@ clean2:
2869clean1: 3054clean1:
2870 release_io_mem(hba[i]); 3055 release_io_mem(hba[i]);
2871 free_hba(i); 3056 free_hba(i);
3057 hba[i]->busy_initializing = 0;
2872 return(-1); 3058 return(-1);
2873} 3059}
2874 3060
@@ -2913,9 +3099,10 @@ static void __devexit cciss_remove_one (struct pci_dev *pdev)
2913 /* remove it from the disk list */ 3099 /* remove it from the disk list */
2914 for (j = 0; j < NWD; j++) { 3100 for (j = 0; j < NWD; j++) {
2915 struct gendisk *disk = hba[i]->gendisk[j]; 3101 struct gendisk *disk = hba[i]->gendisk[j];
2916 if (disk->flags & GENHD_FL_UP) 3102 if (disk->flags & GENHD_FL_UP) {
2917 blk_cleanup_queue(disk->queue);
2918 del_gendisk(disk); 3103 del_gendisk(disk);
3104 blk_cleanup_queue(disk->queue);
3105 }
2919 } 3106 }
2920 3107
2921 pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), 3108 pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct),
@@ -2964,5 +3151,43 @@ static void __exit cciss_cleanup(void)
2964 remove_proc_entry("cciss", proc_root_driver); 3151 remove_proc_entry("cciss", proc_root_driver);
2965} 3152}
2966 3153
3154static void fail_all_cmds(unsigned long ctlr)
3155{
3156 /* If we get here, the board is apparently dead. */
3157 ctlr_info_t *h = hba[ctlr];
3158 CommandList_struct *c;
3159 unsigned long flags;
3160
3161 printk(KERN_WARNING "cciss%d: controller not responding.\n", h->ctlr);
3162 h->alive = 0; /* the controller apparently died... */
3163
3164 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
3165
3166 pci_disable_device(h->pdev); /* Make sure it is really dead. */
3167
3168 /* move everything off the request queue onto the completed queue */
3169 while( (c = h->reqQ) != NULL ) {
3170 removeQ(&(h->reqQ), c);
3171 h->Qdepth--;
3172 addQ (&(h->cmpQ), c);
3173 }
3174
3175 /* Now, fail everything on the completed queue with a HW error */
3176 while( (c = h->cmpQ) != NULL ) {
3177 removeQ(&h->cmpQ, c);
3178 c->err_info->CommandStatus = CMD_HARDWARE_ERR;
3179 if (c->cmd_type == CMD_RWREQ) {
3180 complete_command(h, c, 0);
3181 } else if (c->cmd_type == CMD_IOCTL_PEND)
3182 complete(c->waiting);
3183#ifdef CONFIG_CISS_SCSI_TAPE
3184 else if (c->cmd_type == CMD_SCSI)
3185 complete_scsi_command(c, 0, 0);
3186#endif
3187 }
3188 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
3189 return;
3190}
3191
2967module_init(cciss_init); 3192module_init(cciss_init);
2968module_exit(cciss_cleanup); 3193module_exit(cciss_cleanup);
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index 566587d0a500..ef277baee9fd 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -35,7 +35,13 @@ typedef struct _drive_info_struct
35 int heads; 35 int heads;
36 int sectors; 36 int sectors;
37 int cylinders; 37 int cylinders;
38 int raid_level; 38 int raid_level; /* set to -1 to indicate that
39 * the drive is not in use/configured
40 */
41 int busy_configuring; /*This is set when the drive is being removed
42 *to prevent it from being opened or it's queue
43 *from being started.
44 */
39} drive_info_struct; 45} drive_info_struct;
40 46
41struct ctlr_info 47struct ctlr_info
@@ -83,6 +89,7 @@ struct ctlr_info
83 int nr_allocs; 89 int nr_allocs;
84 int nr_frees; 90 int nr_frees;
85 int busy_configuring; 91 int busy_configuring;
92 int busy_initializing;
86 93
87 /* This element holds the zero based queue number of the last 94 /* This element holds the zero based queue number of the last
88 * queue to be started. It is used for fairness. 95 * queue to be started. It is used for fairness.
@@ -94,6 +101,7 @@ struct ctlr_info
94#ifdef CONFIG_CISS_SCSI_TAPE 101#ifdef CONFIG_CISS_SCSI_TAPE
95 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ 102 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */
96#endif 103#endif
104 unsigned char alive;
97}; 105};
98 106
99/* Defining the diffent access_menthods */ 107/* Defining the diffent access_menthods */
diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h
index a88a88817623..53fea549ba8b 100644
--- a/drivers/block/cciss_cmd.h
+++ b/drivers/block/cciss_cmd.h
@@ -226,6 +226,10 @@ typedef struct _ErrorInfo_struct {
226#define CMD_MSG_DONE 0x04 226#define CMD_MSG_DONE 0x04
227#define CMD_MSG_TIMEOUT 0x05 227#define CMD_MSG_TIMEOUT 0x05
228 228
229/* This structure needs to be divisible by 8 for new
230 * indexing method.
231 */
232#define PADSIZE (sizeof(long) - 4)
229typedef struct _CommandList_struct { 233typedef struct _CommandList_struct {
230 CommandListHeader_struct Header; 234 CommandListHeader_struct Header;
231 RequestBlock_struct Request; 235 RequestBlock_struct Request;
@@ -236,14 +240,14 @@ typedef struct _CommandList_struct {
236 ErrorInfo_struct * err_info; /* pointer to the allocated mem */ 240 ErrorInfo_struct * err_info; /* pointer to the allocated mem */
237 int ctlr; 241 int ctlr;
238 int cmd_type; 242 int cmd_type;
243 long cmdindex;
239 struct _CommandList_struct *prev; 244 struct _CommandList_struct *prev;
240 struct _CommandList_struct *next; 245 struct _CommandList_struct *next;
241 struct request * rq; 246 struct request * rq;
242 struct completion *waiting; 247 struct completion *waiting;
243 int retry_count; 248 int retry_count;
244#ifdef CONFIG_CISS_SCSI_TAPE
245 void * scsi_cmd; 249 void * scsi_cmd;
246#endif 250 char pad[PADSIZE];
247} CommandList_struct; 251} CommandList_struct;
248 252
249//Configuration Table Structure 253//Configuration Table Structure
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index f16e3caed58a..e183a3ef7839 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -93,6 +93,7 @@ struct cciss_scsi_cmd_stack_elem_t {
93 CommandList_struct cmd; 93 CommandList_struct cmd;
94 ErrorInfo_struct Err; 94 ErrorInfo_struct Err;
95 __u32 busaddr; 95 __u32 busaddr;
96 __u32 pad;
96}; 97};
97 98
98#pragma pack() 99#pragma pack()
@@ -877,7 +878,7 @@ cciss_scsi_interpret_error(CommandList_struct *cp)
877 878
878static int 879static int
879cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr, 880cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr,
880 InquiryData_struct *buf) 881 unsigned char *buf, unsigned char bufsize)
881{ 882{
882 int rc; 883 int rc;
883 CommandList_struct *cp; 884 CommandList_struct *cp;
@@ -900,11 +901,10 @@ cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr,
900 cdb[1] = 0; 901 cdb[1] = 0;
901 cdb[2] = 0; 902 cdb[2] = 0;
902 cdb[3] = 0; 903 cdb[3] = 0;
903 cdb[4] = sizeof(*buf) & 0xff; 904 cdb[4] = bufsize;
904 cdb[5] = 0; 905 cdb[5] = 0;
905 rc = cciss_scsi_do_simple_cmd(c, cp, scsi3addr, cdb, 906 rc = cciss_scsi_do_simple_cmd(c, cp, scsi3addr, cdb,
906 6, (unsigned char *) buf, 907 6, buf, bufsize, XFER_READ);
907 sizeof(*buf), XFER_READ);
908 908
909 if (rc != 0) return rc; /* something went wrong */ 909 if (rc != 0) return rc; /* something went wrong */
910 910
@@ -1000,9 +1000,10 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
1000 that though. 1000 that though.
1001 1001
1002 */ 1002 */
1003 1003#define OBDR_TAPE_INQ_SIZE 49
1004#define OBDR_TAPE_SIG "$DR-10"
1004 ReportLunData_struct *ld_buff; 1005 ReportLunData_struct *ld_buff;
1005 InquiryData_struct *inq_buff; 1006 unsigned char *inq_buff;
1006 unsigned char scsi3addr[8]; 1007 unsigned char scsi3addr[8];
1007 ctlr_info_t *c; 1008 ctlr_info_t *c;
1008 __u32 num_luns=0; 1009 __u32 num_luns=0;
@@ -1020,7 +1021,7 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
1020 return; 1021 return;
1021 } 1022 }
1022 memset(ld_buff, 0, reportlunsize); 1023 memset(ld_buff, 0, reportlunsize);
1023 inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL); 1024 inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
1024 if (inq_buff == NULL) { 1025 if (inq_buff == NULL) {
1025 printk(KERN_ERR "cciss: out of memory\n"); 1026 printk(KERN_ERR "cciss: out of memory\n");
1026 kfree(ld_buff); 1027 kfree(ld_buff);
@@ -1051,19 +1052,36 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
1051 1052
1052 /* for each physical lun, do an inquiry */ 1053 /* for each physical lun, do an inquiry */
1053 if (ld_buff->LUN[i][3] & 0xC0) continue; 1054 if (ld_buff->LUN[i][3] & 0xC0) continue;
1054 memset(inq_buff, 0, sizeof(InquiryData_struct)); 1055 memset(inq_buff, 0, OBDR_TAPE_INQ_SIZE);
1055 memcpy(&scsi3addr[0], &ld_buff->LUN[i][0], 8); 1056 memcpy(&scsi3addr[0], &ld_buff->LUN[i][0], 8);
1056 1057
1057 if (cciss_scsi_do_inquiry(hba[cntl_num], 1058 if (cciss_scsi_do_inquiry(hba[cntl_num], scsi3addr, inq_buff,
1058 scsi3addr, inq_buff) != 0) 1059 (unsigned char) OBDR_TAPE_INQ_SIZE) != 0) {
1059 {
1060 /* Inquiry failed (msg printed already) */ 1060 /* Inquiry failed (msg printed already) */
1061 devtype = 0; /* so we will skip this device. */ 1061 devtype = 0; /* so we will skip this device. */
1062 } else /* what kind of device is this? */ 1062 } else /* what kind of device is this? */
1063 devtype = (inq_buff->data_byte[0] & 0x1f); 1063 devtype = (inq_buff[0] & 0x1f);
1064 1064
1065 switch (devtype) 1065 switch (devtype)
1066 { 1066 {
1067 case 0x05: /* CD-ROM */ {
1068
1069 /* We don't *really* support actual CD-ROM devices,
1070 * just this "One Button Disaster Recovery" tape drive
1071 * which temporarily pretends to be a CD-ROM drive.
1072 * So we check that the device is really an OBDR tape
1073 * device by checking for "$DR-10" in bytes 43-48 of
1074 * the inquiry data.
1075 */
1076 char obdr_sig[7];
1077
1078 strncpy(obdr_sig, &inq_buff[43], 6);
1079 obdr_sig[6] = '\0';
1080 if (strncmp(obdr_sig, OBDR_TAPE_SIG, 6) != 0)
1081 /* Not OBDR device, ignore it. */
1082 break;
1083 }
1084 /* fall through . . . */
1067 case 0x01: /* sequential access, (tape) */ 1085 case 0x01: /* sequential access, (tape) */
1068 case 0x08: /* medium changer */ 1086 case 0x08: /* medium changer */
1069 if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) { 1087 if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) {
@@ -1126,6 +1144,7 @@ cciss_scsi_proc_info(struct Scsi_Host *sh,
1126 1144
1127 int buflen, datalen; 1145 int buflen, datalen;
1128 ctlr_info_t *ci; 1146 ctlr_info_t *ci;
1147 int i;
1129 int cntl_num; 1148 int cntl_num;
1130 1149
1131 1150
@@ -1136,8 +1155,28 @@ cciss_scsi_proc_info(struct Scsi_Host *sh,
1136 cntl_num = ci->ctlr; /* Get our index into the hba[] array */ 1155 cntl_num = ci->ctlr; /* Get our index into the hba[] array */
1137 1156
1138 if (func == 0) { /* User is reading from /proc/scsi/ciss*?/?* */ 1157 if (func == 0) { /* User is reading from /proc/scsi/ciss*?/?* */
1139 buflen = sprintf(buffer, "hostnum=%d\n", sh->host_no); 1158 buflen = sprintf(buffer, "cciss%d: SCSI host: %d\n",
1140 1159 cntl_num, sh->host_no);
1160
1161 /* this information is needed by apps to know which cciss
1162 device corresponds to which scsi host number without
1163 having to open a scsi target device node. The device
1164 information is not a duplicate of /proc/scsi/scsi because
1165 the two may be out of sync due to scsi hotplug, rather
1166 this info is for an app to be able to use to know how to
1167 get them back in sync. */
1168
1169 for (i=0;i<ccissscsi[cntl_num].ndevices;i++) {
1170 struct cciss_scsi_dev_t *sd = &ccissscsi[cntl_num].dev[i];
1171 buflen += sprintf(&buffer[buflen], "c%db%dt%dl%d %02d "
1172 "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
1173 sh->host_no, sd->bus, sd->target, sd->lun,
1174 sd->devtype,
1175 sd->scsi3addr[0], sd->scsi3addr[1],
1176 sd->scsi3addr[2], sd->scsi3addr[3],
1177 sd->scsi3addr[4], sd->scsi3addr[5],
1178 sd->scsi3addr[6], sd->scsi3addr[7]);
1179 }
1141 datalen = buflen - offset; 1180 datalen = buflen - offset;
1142 if (datalen < 0) { /* they're reading past EOF. */ 1181 if (datalen < 0) { /* they're reading past EOF. */
1143 datalen = 0; 1182 datalen = 0;
@@ -1399,7 +1438,7 @@ cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len)
1399 1438
1400 CPQ_TAPE_LOCK(ctlr, flags); 1439 CPQ_TAPE_LOCK(ctlr, flags);
1401 size = sprintf(buffer + *len, 1440 size = sprintf(buffer + *len,
1402 " Sequential access devices: %d\n\n", 1441 "Sequential access devices: %d\n\n",
1403 ccissscsi[ctlr].ndevices); 1442 ccissscsi[ctlr].ndevices);
1404 CPQ_TAPE_UNLOCK(ctlr, flags); 1443 CPQ_TAPE_UNLOCK(ctlr, flags);
1405 *pos += size; *len += size; 1444 *pos += size; *len += size;
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 7b838342f0a3..7e22a58926b8 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -5,29 +5,41 @@
5 * May be copied or modified under the terms of the GNU General Public 5 * May be copied or modified under the terms of the GNU General Public
6 * License. See linux/COPYING for more information. 6 * License. See linux/COPYING for more information.
7 * 7 *
8 * Packet writing layer for ATAPI and SCSI CD-R, CD-RW, DVD-R, and 8 * Packet writing layer for ATAPI and SCSI CD-RW, DVD+RW, DVD-RW and
9 * DVD-RW devices (aka an exercise in block layer masturbation) 9 * DVD-RAM devices.
10 * 10 *
11 * Theory of operation:
11 * 12 *
12 * TODO: (circa order of when I will fix it) 13 * At the lowest level, there is the standard driver for the CD/DVD device,
13 * - Only able to write on CD-RW media right now. 14 * typically ide-cd.c or sr.c. This driver can handle read and write requests,
14 * - check host application code on media and set it in write page 15 * but it doesn't know anything about the special restrictions that apply to
15 * - interface for UDF <-> packet to negotiate a new location when a write 16 * packet writing. One restriction is that write requests must be aligned to
16 * fails. 17 * packet boundaries on the physical media, and the size of a write request
17 * - handle OPC, especially for -RW media 18 * must be equal to the packet size. Another restriction is that a
19 * GPCMD_FLUSH_CACHE command has to be issued to the drive before a read
20 * command, if the previous command was a write.
18 * 21 *
19 * Theory of operation: 22 * The purpose of the packet writing driver is to hide these restrictions from
23 * higher layers, such as file systems, and present a block device that can be
24 * randomly read and written using 2kB-sized blocks.
25 *
26 * The lowest layer in the packet writing driver is the packet I/O scheduler.
27 * Its data is defined by the struct packet_iosched and includes two bio
28 * queues with pending read and write requests. These queues are processed
29 * by the pkt_iosched_process_queue() function. The write requests in this
30 * queue are already properly aligned and sized. This layer is responsible for
31 * issuing the flush cache commands and scheduling the I/O in a good order.
20 * 32 *
21 * We use a custom make_request_fn function that forwards reads directly to 33 * The next layer transforms unaligned write requests to aligned writes. This
22 * the underlying CD device. Write requests are either attached directly to 34 * transformation requires reading missing pieces of data from the underlying
23 * a live packet_data object, or simply stored sequentially in a list for 35 * block device, assembling the pieces to full packets and queuing them to the
24 * later processing by the kcdrwd kernel thread. This driver doesn't use 36 * packet I/O scheduler.
25 * any elevator functionally as defined by the elevator_s struct, but the
26 * underlying CD device uses a standard elevator.
27 * 37 *
28 * This strategy makes it possible to do very late merging of IO requests. 38 * At the top layer there is a custom make_request_fn function that forwards
29 * A new bio sent to pkt_make_request can be merged with a live packet_data 39 * read requests directly to the iosched queue and puts write requests in the
30 * object even if the object is in the data gathering state. 40 * unaligned write queue. A kernel thread performs the necessary read
41 * gathering to convert the unaligned writes to aligned writes and then feeds
42 * them to the packet I/O scheduler.
31 * 43 *
32 *************************************************************************/ 44 *************************************************************************/
33 45
@@ -100,10 +112,9 @@ static struct bio *pkt_bio_alloc(int nr_iovecs)
100 goto no_bio; 112 goto no_bio;
101 bio_init(bio); 113 bio_init(bio);
102 114
103 bvl = kmalloc(nr_iovecs * sizeof(struct bio_vec), GFP_KERNEL); 115 bvl = kcalloc(nr_iovecs, sizeof(struct bio_vec), GFP_KERNEL);
104 if (!bvl) 116 if (!bvl)
105 goto no_bvl; 117 goto no_bvl;
106 memset(bvl, 0, nr_iovecs * sizeof(struct bio_vec));
107 118
108 bio->bi_max_vecs = nr_iovecs; 119 bio->bi_max_vecs = nr_iovecs;
109 bio->bi_io_vec = bvl; 120 bio->bi_io_vec = bvl;
@@ -125,10 +136,9 @@ static struct packet_data *pkt_alloc_packet_data(void)
125 int i; 136 int i;
126 struct packet_data *pkt; 137 struct packet_data *pkt;
127 138
128 pkt = kmalloc(sizeof(struct packet_data), GFP_KERNEL); 139 pkt = kzalloc(sizeof(struct packet_data), GFP_KERNEL);
129 if (!pkt) 140 if (!pkt)
130 goto no_pkt; 141 goto no_pkt;
131 memset(pkt, 0, sizeof(struct packet_data));
132 142
133 pkt->w_bio = pkt_bio_alloc(PACKET_MAX_SIZE); 143 pkt->w_bio = pkt_bio_alloc(PACKET_MAX_SIZE);
134 if (!pkt->w_bio) 144 if (!pkt->w_bio)
@@ -659,7 +669,6 @@ static void pkt_make_local_copy(struct packet_data *pkt, struct page **pages, in
659 } 669 }
660 offs += CD_FRAMESIZE; 670 offs += CD_FRAMESIZE;
661 if (offs >= PAGE_SIZE) { 671 if (offs >= PAGE_SIZE) {
662 BUG_ON(offs > PAGE_SIZE);
663 offs = 0; 672 offs = 0;
664 p++; 673 p++;
665 } 674 }
@@ -724,12 +733,6 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
724 atomic_set(&pkt->io_wait, 0); 733 atomic_set(&pkt->io_wait, 0);
725 atomic_set(&pkt->io_errors, 0); 734 atomic_set(&pkt->io_errors, 0);
726 735
727 if (pkt->cache_valid) {
728 VPRINTK("pkt_gather_data: zone %llx cached\n",
729 (unsigned long long)pkt->sector);
730 goto out_account;
731 }
732
733 /* 736 /*
734 * Figure out which frames we need to read before we can write. 737 * Figure out which frames we need to read before we can write.
735 */ 738 */
@@ -738,6 +741,7 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
738 for (bio = pkt->orig_bios; bio; bio = bio->bi_next) { 741 for (bio = pkt->orig_bios; bio; bio = bio->bi_next) {
739 int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9); 742 int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9);
740 int num_frames = bio->bi_size / CD_FRAMESIZE; 743 int num_frames = bio->bi_size / CD_FRAMESIZE;
744 pd->stats.secs_w += num_frames * (CD_FRAMESIZE >> 9);
741 BUG_ON(first_frame < 0); 745 BUG_ON(first_frame < 0);
742 BUG_ON(first_frame + num_frames > pkt->frames); 746 BUG_ON(first_frame + num_frames > pkt->frames);
743 for (f = first_frame; f < first_frame + num_frames; f++) 747 for (f = first_frame; f < first_frame + num_frames; f++)
@@ -745,6 +749,12 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
745 } 749 }
746 spin_unlock(&pkt->lock); 750 spin_unlock(&pkt->lock);
747 751
752 if (pkt->cache_valid) {
753 VPRINTK("pkt_gather_data: zone %llx cached\n",
754 (unsigned long long)pkt->sector);
755 goto out_account;
756 }
757
748 /* 758 /*
749 * Schedule reads for missing parts of the packet. 759 * Schedule reads for missing parts of the packet.
750 */ 760 */
@@ -778,7 +788,6 @@ out_account:
778 frames_read, (unsigned long long)pkt->sector); 788 frames_read, (unsigned long long)pkt->sector);
779 pd->stats.pkt_started++; 789 pd->stats.pkt_started++;
780 pd->stats.secs_rg += frames_read * (CD_FRAMESIZE >> 9); 790 pd->stats.secs_rg += frames_read * (CD_FRAMESIZE >> 9);
781 pd->stats.secs_w += pd->settings.size;
782} 791}
783 792
784/* 793/*
@@ -794,10 +803,11 @@ static struct packet_data *pkt_get_packet_data(struct pktcdvd_device *pd, int zo
794 list_del_init(&pkt->list); 803 list_del_init(&pkt->list);
795 if (pkt->sector != zone) 804 if (pkt->sector != zone)
796 pkt->cache_valid = 0; 805 pkt->cache_valid = 0;
797 break; 806 return pkt;
798 } 807 }
799 } 808 }
800 return pkt; 809 BUG();
810 return NULL;
801} 811}
802 812
803static void pkt_put_packet_data(struct pktcdvd_device *pd, struct packet_data *pkt) 813static void pkt_put_packet_data(struct pktcdvd_device *pd, struct packet_data *pkt)
@@ -941,12 +951,10 @@ try_next_bio:
941 } 951 }
942 952
943 pkt = pkt_get_packet_data(pd, zone); 953 pkt = pkt_get_packet_data(pd, zone);
944 BUG_ON(!pkt);
945 954
946 pd->current_sector = zone + pd->settings.size; 955 pd->current_sector = zone + pd->settings.size;
947 pkt->sector = zone; 956 pkt->sector = zone;
948 pkt->frames = pd->settings.size >> 2; 957 pkt->frames = pd->settings.size >> 2;
949 BUG_ON(pkt->frames > PACKET_MAX_SIZE);
950 pkt->write_size = 0; 958 pkt->write_size = 0;
951 959
952 /* 960 /*
@@ -1636,6 +1644,10 @@ static int pkt_probe_settings(struct pktcdvd_device *pd)
1636 printk("pktcdvd: detected zero packet size!\n"); 1644 printk("pktcdvd: detected zero packet size!\n");
1637 pd->settings.size = 128; 1645 pd->settings.size = 128;
1638 } 1646 }
1647 if (pd->settings.size > PACKET_MAX_SECTORS) {
1648 printk("pktcdvd: packet size is too big\n");
1649 return -ENXIO;
1650 }
1639 pd->settings.fp = ti.fp; 1651 pd->settings.fp = ti.fp;
1640 pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1); 1652 pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
1641 1653
@@ -2198,7 +2210,6 @@ static int pkt_make_request(request_queue_t *q, struct bio *bio)
2198 * No matching packet found. Store the bio in the work queue. 2210 * No matching packet found. Store the bio in the work queue.
2199 */ 2211 */
2200 node = mempool_alloc(pd->rb_pool, GFP_NOIO); 2212 node = mempool_alloc(pd->rb_pool, GFP_NOIO);
2201 BUG_ON(!node);
2202 node->bio = bio; 2213 node->bio = bio;
2203 spin_lock(&pd->lock); 2214 spin_lock(&pd->lock);
2204 BUG_ON(pd->bio_queue_size < 0); 2215 BUG_ON(pd->bio_queue_size < 0);
@@ -2406,7 +2417,6 @@ static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
2406 struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; 2417 struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data;
2407 2418
2408 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode)); 2419 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode));
2409 BUG_ON(!pd);
2410 2420
2411 switch (cmd) { 2421 switch (cmd) {
2412 /* 2422 /*
@@ -2477,10 +2487,9 @@ static int pkt_setup_dev(struct pkt_ctrl_command *ctrl_cmd)
2477 return -EBUSY; 2487 return -EBUSY;
2478 } 2488 }
2479 2489
2480 pd = kmalloc(sizeof(struct pktcdvd_device), GFP_KERNEL); 2490 pd = kzalloc(sizeof(struct pktcdvd_device), GFP_KERNEL);
2481 if (!pd) 2491 if (!pd)
2482 return ret; 2492 return ret;
2483 memset(pd, 0, sizeof(struct pktcdvd_device));
2484 2493
2485 pd->rb_pool = mempool_create(PKT_RB_POOL_SIZE, pkt_rb_alloc, pkt_rb_free, NULL); 2494 pd->rb_pool = mempool_create(PKT_RB_POOL_SIZE, pkt_rb_alloc, pkt_rb_free, NULL);
2486 if (!pd->rb_pool) 2495 if (!pd->rb_pool)
diff --git a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c
index abb2df249fd3..856c2278e9d0 100644
--- a/drivers/block/scsi_ioctl.c
+++ b/drivers/block/scsi_ioctl.c
@@ -123,6 +123,7 @@ static int verify_command(struct file *file, unsigned char *cmd)
123 safe_for_read(READ_12), 123 safe_for_read(READ_12),
124 safe_for_read(READ_16), 124 safe_for_read(READ_16),
125 safe_for_read(READ_BUFFER), 125 safe_for_read(READ_BUFFER),
126 safe_for_read(READ_DEFECT_DATA),
126 safe_for_read(READ_LONG), 127 safe_for_read(READ_LONG),
127 safe_for_read(INQUIRY), 128 safe_for_read(INQUIRY),
128 safe_for_read(MODE_SENSE), 129 safe_for_read(MODE_SENSE),
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 2a36561eec68..a124f8c5d062 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -2053,10 +2053,6 @@ static int __init rs_init(void)
2053 state->icount.rx = state->icount.tx = 0; 2053 state->icount.rx = state->icount.tx = 0;
2054 state->icount.frame = state->icount.parity = 0; 2054 state->icount.frame = state->icount.parity = 0;
2055 state->icount.overrun = state->icount.brk = 0; 2055 state->icount.overrun = state->icount.brk = 0;
2056 /*
2057 if(state->port && check_region(state->port,REGION_LENGTH(state)))
2058 continue;
2059 */
2060 2056
2061 printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n", 2057 printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n",
2062 state->line); 2058 state->line);
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index c3898afce3ae..344001b45af9 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -84,6 +84,17 @@ config 977_WATCHDOG
84 84
85 Not sure? It's safe to say N. 85 Not sure? It's safe to say N.
86 86
87config IXP2000_WATCHDOG
88 tristate "IXP2000 Watchdog"
89 depends on WATCHDOG && ARCH_IXP2000
90 help
91 Say Y here if to include support for the watchdog timer
92 in the Intel IXP2000(2400, 2800, 2850) network processors.
93 This driver can be built as a module by choosing M. The module
94 will be called ixp2000_wdt.
95
96 Say N if you are unsure.
97
87config IXP4XX_WATCHDOG 98config IXP4XX_WATCHDOG
88 tristate "IXP4xx Watchdog" 99 tristate "IXP4xx Watchdog"
89 depends on WATCHDOG && ARCH_IXP4XX 100 depends on WATCHDOG && ARCH_IXP4XX
@@ -100,17 +111,6 @@ config IXP4XX_WATCHDOG
100 111
101 Say N if you are unsure. 112 Say N if you are unsure.
102 113
103config IXP2000_WATCHDOG
104 tristate "IXP2000 Watchdog"
105 depends on WATCHDOG && ARCH_IXP2000
106 help
107 Say Y here if to include support for the watchdog timer
108 in the Intel IXP2000(2400, 2800, 2850) network processors.
109 This driver can be built as a module by choosing M. The module
110 will be called ixp2000_wdt.
111
112 Say N if you are unsure.
113
114config S3C2410_WATCHDOG 114config S3C2410_WATCHDOG
115 tristate "S3C2410 Watchdog" 115 tristate "S3C2410 Watchdog"
116 depends on WATCHDOG && ARCH_S3C2410 116 depends on WATCHDOG && ARCH_S3C2410
@@ -139,6 +139,15 @@ config SA1100_WATCHDOG
139 To compile this driver as a module, choose M here: the 139 To compile this driver as a module, choose M here: the
140 module will be called sa1100_wdt. 140 module will be called sa1100_wdt.
141 141
142config MPCORE_WATCHDOG
143 tristate "MPcore watchdog"
144 depends on WATCHDOG && ARM_MPCORE_PLATFORM && LOCAL_TIMERS
145 help
146 Watchdog timer embedded into the MPcore system.
147
148 To compile this driver as a module, choose M here: the
149 module will be called mpcore_wdt.
150
142# X86 (i386 + ia64 + x86_64) Architecture 151# X86 (i386 + ia64 + x86_64) Architecture
143 152
144config ACQUIRE_WDT 153config ACQUIRE_WDT
@@ -224,6 +233,16 @@ config IB700_WDT
224 233
225 Most people will say N. 234 Most people will say N.
226 235
236config IBMASR
237 tristate "IBM Automatic Server Restart"
238 depends on WATCHDOG && X86
239 help
240 This is the driver for the IBM Automatic Server Restart watchdog
241 timer builtin into some eServer xSeries machines.
242
243 To compile this driver as a module, choose M here: the
244 module will be called ibmasr.
245
227config WAFER_WDT 246config WAFER_WDT
228 tristate "ICP Wafer 5823 Single Board Computer Watchdog" 247 tristate "ICP Wafer 5823 Single Board Computer Watchdog"
229 depends on WATCHDOG && X86 248 depends on WATCHDOG && X86
@@ -234,6 +253,16 @@ config WAFER_WDT
234 To compile this driver as a module, choose M here: the 253 To compile this driver as a module, choose M here: the
235 module will be called wafer5823wdt. 254 module will be called wafer5823wdt.
236 255
256config I6300ESB_WDT
257 tristate "Intel 6300ESB Timer/Watchdog"
258 depends on WATCHDOG && X86 && PCI
259 ---help---
260 Hardware driver for the watchdog timer built into the Intel
261 6300ESB controller hub.
262
263 To compile this driver as a module, choose M here: the
264 module will be called i6300esb.
265
237config I8XX_TCO 266config I8XX_TCO
238 tristate "Intel i8xx TCO Timer/Watchdog" 267 tristate "Intel i8xx TCO Timer/Watchdog"
239 depends on WATCHDOG && (X86 || IA64) && PCI 268 depends on WATCHDOG && (X86 || IA64) && PCI
@@ -289,6 +318,19 @@ config 60XX_WDT
289 You can compile this driver directly into the kernel, or use 318 You can compile this driver directly into the kernel, or use
290 it as a module. The module will be called sbc60xxwdt. 319 it as a module. The module will be called sbc60xxwdt.
291 320
321config SBC8360_WDT
322 tristate "SBC8360 Watchdog Timer"
323 depends on WATCHDOG && X86
324 ---help---
325
326 This is the driver for the hardware watchdog on the SBC8360 Single
327 Board Computer produced by Axiomtek Co., Ltd. (www.axiomtek.com).
328
329 To compile this driver as a module, choose M here: the
330 module will be called sbc8360.ko.
331
332 Most people will say N.
333
292config CPU5_WDT 334config CPU5_WDT
293 tristate "SMA CPU5 Watchdog" 335 tristate "SMA CPU5 Watchdog"
294 depends on WATCHDOG && X86 336 depends on WATCHDOG && X86
@@ -327,6 +369,19 @@ config W83877F_WDT
327 369
328 Most people will say N. 370 Most people will say N.
329 371
372config W83977F_WDT
373 tristate "W83977F (PCM-5335) Watchdog Timer"
374 depends on WATCHDOG && X86
375 ---help---
376 This is the driver for the hardware watchdog on the W83977F I/O chip
377 as used in AAEON's PCM-5335 SBC (and likely others). This
378 watchdog simply watches your kernel to make sure it doesn't freeze,
379 and if it does, it reboots your computer after a certain amount of
380 time.
381
382 To compile this driver as a module, choose M here: the
383 module will be called w83977f_wdt.
384
330config MACHZ_WDT 385config MACHZ_WDT
331 tristate "ZF MachZ Watchdog" 386 tristate "ZF MachZ Watchdog"
332 depends on WATCHDOG && X86 387 depends on WATCHDOG && X86
@@ -346,6 +401,10 @@ config 8xx_WDT
346 tristate "MPC8xx Watchdog Timer" 401 tristate "MPC8xx Watchdog Timer"
347 depends on WATCHDOG && 8xx 402 depends on WATCHDOG && 8xx
348 403
404config MV64X60_WDT
405 tristate "MV64X60 (Marvell Discovery) Watchdog Timer"
406 depends on WATCHDOG && MV64X60
407
349config BOOKE_WDT 408config BOOKE_WDT
350 tristate "PowerPC Book-E Watchdog Timer" 409 tristate "PowerPC Book-E Watchdog Timer"
351 depends on WATCHDOG && (BOOKE || 4xx) 410 depends on WATCHDOG && (BOOKE || 4xx)
@@ -353,6 +412,17 @@ config BOOKE_WDT
353 Please see Documentation/watchdog/watchdog-api.txt for 412 Please see Documentation/watchdog/watchdog-api.txt for
354 more information. 413 more information.
355 414
415# PPC64 Architecture
416
417config WATCHDOG_RTAS
418 tristate "RTAS watchdog"
419 depends on WATCHDOG && PPC_RTAS
420 help
421 This driver adds watchdog support for the RTAS watchdog.
422
423 To compile this driver as a module, choose M here. The module
424 will be called wdrtas.
425
356# MIPS Architecture 426# MIPS Architecture
357 427
358config INDYDOG 428config INDYDOG
@@ -421,16 +491,6 @@ config WATCHDOG_RIO
421 machines. The watchdog timeout period is normally one minute but 491 machines. The watchdog timeout period is normally one minute but
422 can be changed with a boot-time parameter. 492 can be changed with a boot-time parameter.
423 493
424# ppc64 RTAS watchdog
425config WATCHDOG_RTAS
426 tristate "RTAS watchdog"
427 depends on WATCHDOG && PPC_RTAS
428 help
429 This driver adds watchdog support for the RTAS watchdog.
430
431 To compile this driver as a module, choose M here. The module
432 will be called wdrtas.
433
434# 494#
435# ISA-based Watchdog Cards 495# ISA-based Watchdog Cards
436# 496#
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index cfeac6f10137..cfd0a3987710 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o
29obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o 29obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
30obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o 30obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
31obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o 31obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
32obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o
32 33
33# X86 (i386 + ia64 + x86_64) Architecture 34# X86 (i386 + ia64 + x86_64) Architecture
34obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o 35obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
@@ -38,22 +39,27 @@ obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o
38obj-$(CONFIG_SC520_WDT) += sc520_wdt.o 39obj-$(CONFIG_SC520_WDT) += sc520_wdt.o
39obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o 40obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o
40obj-$(CONFIG_IB700_WDT) += ib700wdt.o 41obj-$(CONFIG_IB700_WDT) += ib700wdt.o
42obj-$(CONFIG_IBMASR) += ibmasr.o
41obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o 43obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
44obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o
42obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o 45obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o
43obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o 46obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
44obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o 47obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
45obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o 48obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
49obj-$(CONFIG_SBC8360_WDT) += sbc8360.o
46obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o 50obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
47obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o 51obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o
48obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o 52obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
53obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o
49obj-$(CONFIG_MACHZ_WDT) += machzwd.o 54obj-$(CONFIG_MACHZ_WDT) += machzwd.o
50 55
51# PowerPC Architecture 56# PowerPC Architecture
52obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o 57obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o
58obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
59obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
53 60
54# PPC64 Architecture 61# PPC64 Architecture
55obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o 62obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
56obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
57 63
58# MIPS Architecture 64# MIPS Architecture
59obj-$(CONFIG_INDYDOG) += indydog.o 65obj-$(CONFIG_INDYDOG) += indydog.o
diff --git a/drivers/char/watchdog/i6300esb.c b/drivers/char/watchdog/i6300esb.c
new file mode 100644
index 000000000000..93785f13242e
--- /dev/null
+++ b/drivers/char/watchdog/i6300esb.c
@@ -0,0 +1,527 @@
1/*
2 * i6300esb: Watchdog timer driver for Intel 6300ESB chipset
3 *
4 * (c) Copyright 2004 Google Inc.
5 * (c) Copyright 2005 David Härdeman <david@2gen.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * based on i810-tco.c which is in turn based on softdog.c
13 *
14 * The timer is implemented in the following I/O controller hubs:
15 * (See the intel documentation on http://developer.intel.com.)
16 * 6300ESB chip : document number 300641-003
17 *
18 * 2004YYZZ Ross Biro
19 * Initial version 0.01
20 * 2004YYZZ Ross Biro
21 * Version 0.02
22 * 20050210 David Härdeman <david@2gen.com>
23 * Ported driver to kernel 2.6
24 */
25
26/*
27 * Includes, defines, variables, module parameters, ...
28 */
29
30#include <linux/module.h>
31#include <linux/types.h>
32#include <linux/kernel.h>
33#include <linux/fs.h>
34#include <linux/mm.h>
35#include <linux/miscdevice.h>
36#include <linux/watchdog.h>
37#include <linux/reboot.h>
38#include <linux/init.h>
39#include <linux/pci.h>
40#include <linux/ioport.h>
41
42#include <asm/uaccess.h>
43#include <asm/io.h>
44
45/* Module and version information */
46#define ESB_VERSION "0.03"
47#define ESB_MODULE_NAME "i6300ESB timer"
48#define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION
49#define PFX ESB_MODULE_NAME ": "
50
51/* PCI configuration registers */
52#define ESB_CONFIG_REG 0x60 /* Config register */
53#define ESB_LOCK_REG 0x68 /* WDT lock register */
54
55/* Memory mapped registers */
56#define ESB_TIMER1_REG BASEADDR + 0x00 /* Timer1 value after each reset */
57#define ESB_TIMER2_REG BASEADDR + 0x04 /* Timer2 value after each reset */
58#define ESB_GINTSR_REG BASEADDR + 0x08 /* General Interrupt Status Register */
59#define ESB_RELOAD_REG BASEADDR + 0x0c /* Reload register */
60
61/* Lock register bits */
62#define ESB_WDT_FUNC ( 0x01 << 2 ) /* Watchdog functionality */
63#define ESB_WDT_ENABLE ( 0x01 << 1 ) /* Enable WDT */
64#define ESB_WDT_LOCK ( 0x01 << 0 ) /* Lock (nowayout) */
65
66/* Config register bits */
67#define ESB_WDT_REBOOT ( 0x01 << 5 ) /* Enable reboot on timeout */
68#define ESB_WDT_FREQ ( 0x01 << 2 ) /* Decrement frequency */
69#define ESB_WDT_INTTYPE ( 0x11 << 0 ) /* Interrupt type on timer1 timeout */
70
71/* Reload register bits */
72#define ESB_WDT_RELOAD ( 0x01 << 8 ) /* prevent timeout */
73
74/* Magic constants */
75#define ESB_UNLOCK1 0x80 /* Step 1 to unlock reset registers */
76#define ESB_UNLOCK2 0x86 /* Step 2 to unlock reset registers */
77
78/* internal variables */
79static void __iomem *BASEADDR;
80static spinlock_t esb_lock; /* Guards the hardware */
81static unsigned long timer_alive;
82static struct pci_dev *esb_pci;
83static unsigned short triggered; /* The status of the watchdog upon boot */
84static char esb_expect_close;
85
86/* module parameters */
87#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat (1<heartbeat<2*1023) */
88static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */
89module_param(heartbeat, int, 0);
90MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
91
92static int nowayout = WATCHDOG_NOWAYOUT;
93module_param(nowayout, int, 0);
94MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
95
96/*
97 * Some i6300ESB specific functions
98 */
99
100/*
101 * Prepare for reloading the timer by unlocking the proper registers.
102 * This is performed by first writing 0x80 followed by 0x86 to the
103 * reload register. After this the appropriate registers can be written
104 * to once before they need to be unlocked again.
105 */
106static inline void esb_unlock_registers(void) {
107 writeb(ESB_UNLOCK1, ESB_RELOAD_REG);
108 writeb(ESB_UNLOCK2, ESB_RELOAD_REG);
109}
110
111static void esb_timer_start(void)
112{
113 u8 val;
114
115 /* Enable or Enable + Lock? */
116 val = 0x02 | (nowayout ? 0x01 : 0x00);
117
118 pci_write_config_byte(esb_pci, ESB_LOCK_REG, val);
119}
120
121static int esb_timer_stop(void)
122{
123 u8 val;
124
125 spin_lock(&esb_lock);
126 /* First, reset timers as suggested by the docs */
127 esb_unlock_registers();
128 writew(ESB_WDT_RELOAD, ESB_RELOAD_REG);
129 /* Then disable the WDT */
130 pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x0);
131 pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val);
132 spin_unlock(&esb_lock);
133
134 /* Returns 0 if the timer was disabled, non-zero otherwise */
135 return (val & 0x01);
136}
137
138static void esb_timer_keepalive(void)
139{
140 spin_lock(&esb_lock);
141 esb_unlock_registers();
142 writew(ESB_WDT_RELOAD, ESB_RELOAD_REG);
143 /* FIXME: Do we need to flush anything here? */
144 spin_unlock(&esb_lock);
145}
146
147static int esb_timer_set_heartbeat(int time)
148{
149 u32 val;
150
151 if (time < 0x1 || time > (2 * 0x03ff))
152 return -EINVAL;
153
154 spin_lock(&esb_lock);
155
156 /* We shift by 9, so if we are passed a value of 1 sec,
157 * val will be 1 << 9 = 512, then write that to two
158 * timers => 2 * 512 = 1024 (which is decremented at 1KHz)
159 */
160 val = time << 9;
161
162 /* Write timer 1 */
163 esb_unlock_registers();
164 writel(val, ESB_TIMER1_REG);
165
166 /* Write timer 2 */
167 esb_unlock_registers();
168 writel(val, ESB_TIMER2_REG);
169
170 /* Reload */
171 esb_unlock_registers();
172 writew(ESB_WDT_RELOAD, ESB_RELOAD_REG);
173
174 /* FIXME: Do we need to flush everything out? */
175
176 /* Done */
177 heartbeat = time;
178 spin_unlock(&esb_lock);
179 return 0;
180}
181
182static int esb_timer_read (void)
183{
184 u32 count;
185
186 /* This isn't documented, and doesn't take into
187 * acount which stage is running, but it looks
188 * like a 20 bit count down, so we might as well report it.
189 */
190 pci_read_config_dword(esb_pci, 0x64, &count);
191 return (int)count;
192}
193
194/*
195 * /dev/watchdog handling
196 */
197
198static int esb_open (struct inode *inode, struct file *file)
199{
200 /* /dev/watchdog can only be opened once */
201 if (test_and_set_bit(0, &timer_alive))
202 return -EBUSY;
203
204 /* Reload and activate timer */
205 esb_timer_keepalive ();
206 esb_timer_start ();
207
208 return nonseekable_open(inode, file);
209}
210
211static int esb_release (struct inode *inode, struct file *file)
212{
213 /* Shut off the timer. */
214 if (esb_expect_close == 42) {
215 esb_timer_stop ();
216 } else {
217 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
218 esb_timer_keepalive ();
219 }
220 clear_bit(0, &timer_alive);
221 esb_expect_close = 0;
222 return 0;
223}
224
225static ssize_t esb_write (struct file *file, const char __user *data,
226 size_t len, loff_t * ppos)
227{
228 /* See if we got the magic character 'V' and reload the timer */
229 if (len) {
230 if (!nowayout) {
231 size_t i;
232
233 /* note: just in case someone wrote the magic character
234 * five months ago... */
235 esb_expect_close = 0;
236
237 /* scan to see whether or not we got the magic character */
238 for (i = 0; i != len; i++) {
239 char c;
240 if(get_user(c, data+i))
241 return -EFAULT;
242 if (c == 'V')
243 esb_expect_close = 42;
244 }
245 }
246
247 /* someone wrote to us, we should reload the timer */
248 esb_timer_keepalive ();
249 }
250 return len;
251}
252
253static int esb_ioctl (struct inode *inode, struct file *file,
254 unsigned int cmd, unsigned long arg)
255{
256 int new_options, retval = -EINVAL;
257 int new_heartbeat;
258 void __user *argp = (void __user *)arg;
259 int __user *p = argp;
260 static struct watchdog_info ident = {
261 .options = WDIOF_SETTIMEOUT |
262 WDIOF_KEEPALIVEPING |
263 WDIOF_MAGICCLOSE,
264 .firmware_version = 0,
265 .identity = ESB_MODULE_NAME,
266 };
267
268 switch (cmd) {
269 case WDIOC_GETSUPPORT:
270 return copy_to_user(argp, &ident,
271 sizeof (ident)) ? -EFAULT : 0;
272
273 case WDIOC_GETSTATUS:
274 return put_user (esb_timer_read(), p);
275
276 case WDIOC_GETBOOTSTATUS:
277 return put_user (triggered, p);
278
279 case WDIOC_KEEPALIVE:
280 esb_timer_keepalive ();
281 return 0;
282
283 case WDIOC_SETOPTIONS:
284 {
285 if (get_user (new_options, p))
286 return -EFAULT;
287
288 if (new_options & WDIOS_DISABLECARD) {
289 esb_timer_stop ();
290 retval = 0;
291 }
292
293 if (new_options & WDIOS_ENABLECARD) {
294 esb_timer_keepalive ();
295 esb_timer_start ();
296 retval = 0;
297 }
298
299 return retval;
300 }
301
302 case WDIOC_SETTIMEOUT:
303 {
304 if (get_user(new_heartbeat, p))
305 return -EFAULT;
306
307 if (esb_timer_set_heartbeat(new_heartbeat))
308 return -EINVAL;
309
310 esb_timer_keepalive ();
311 /* Fall */
312 }
313
314 case WDIOC_GETTIMEOUT:
315 return put_user(heartbeat, p);
316
317 default:
318 return -ENOIOCTLCMD;
319 }
320}
321
322/*
323 * Notify system
324 */
325
326static int esb_notify_sys (struct notifier_block *this, unsigned long code, void *unused)
327{
328 if (code==SYS_DOWN || code==SYS_HALT) {
329 /* Turn the WDT off */
330 esb_timer_stop ();
331 }
332
333 return NOTIFY_DONE;
334}
335
336/*
337 * Kernel Interfaces
338 */
339
340static struct file_operations esb_fops = {
341 .owner = THIS_MODULE,
342 .llseek = no_llseek,
343 .write = esb_write,
344 .ioctl = esb_ioctl,
345 .open = esb_open,
346 .release = esb_release,
347};
348
349static struct miscdevice esb_miscdev = {
350 .minor = WATCHDOG_MINOR,
351 .name = "watchdog",
352 .fops = &esb_fops,
353};
354
355static struct notifier_block esb_notifier = {
356 .notifier_call = esb_notify_sys,
357};
358
359/*
360 * Data for PCI driver interface
361 *
362 * This data only exists for exporting the supported
363 * PCI ids via MODULE_DEVICE_TABLE. We do not actually
364 * register a pci_driver, because someone else might one day
365 * want to register another driver on the same PCI id.
366 */
367static struct pci_device_id esb_pci_tbl[] = {
368 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9), },
369 { 0, }, /* End of list */
370};
371MODULE_DEVICE_TABLE (pci, esb_pci_tbl);
372
373/*
374 * Init & exit routines
375 */
376
377static unsigned char __init esb_getdevice (void)
378{
379 u8 val1;
380 unsigned short val2;
381
382 struct pci_dev *dev = NULL;
383 /*
384 * Find the PCI device
385 */
386
387 for_each_pci_dev(dev) {
388 if (pci_match_id(esb_pci_tbl, dev)) {
389 esb_pci = dev;
390 break;
391 }
392 }
393
394 if (esb_pci) {
395 if (pci_enable_device(esb_pci)) {
396 printk (KERN_ERR PFX "failed to enable device\n");
397 goto err_devput;
398 }
399
400 if (pci_request_region(esb_pci, 0, ESB_MODULE_NAME)) {
401 printk (KERN_ERR PFX "failed to request region\n");
402 goto err_disable;
403 }
404
405 BASEADDR = ioremap(pci_resource_start(esb_pci, 0),
406 pci_resource_len(esb_pci, 0));
407 if (BASEADDR == NULL) {
408 /* Something's wrong here, BASEADDR has to be set */
409 printk (KERN_ERR PFX "failed to get BASEADDR\n");
410 goto err_release;
411 }
412
413 /*
414 * The watchdog has two timers, it can be setup so that the
415 * expiry of timer1 results in an interrupt and the expiry of
416 * timer2 results in a reboot. We set it to not generate
417 * any interrupts as there is not much we can do with it
418 * right now.
419 *
420 * We also enable reboots and set the timer frequency to
421 * the PCI clock divided by 2^15 (approx 1KHz).
422 */
423 pci_write_config_word(esb_pci, ESB_CONFIG_REG, 0x0003);
424
425 /* Check that the WDT isn't already locked */
426 pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val1);
427 if (val1 & ESB_WDT_LOCK)
428 printk (KERN_WARNING PFX "nowayout already set\n");
429
430 /* Set the timer to watchdog mode and disable it for now */
431 pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x00);
432
433 /* Check if the watchdog was previously triggered */
434 esb_unlock_registers();
435 val2 = readw(ESB_RELOAD_REG);
436 triggered = (val2 & (0x01 << 9) >> 9);
437
438 /* Reset trigger flag and timers */
439 esb_unlock_registers();
440 writew((0x11 << 8), ESB_RELOAD_REG);
441
442 /* Done */
443 return 1;
444
445err_release:
446 pci_release_region(esb_pci, 0);
447err_disable:
448 pci_disable_device(esb_pci);
449err_devput:
450 pci_dev_put(esb_pci);
451 }
452 return 0;
453}
454
455static int __init watchdog_init (void)
456{
457 int ret;
458
459 spin_lock_init(&esb_lock);
460
461 /* Check whether or not the hardware watchdog is there */
462 if (!esb_getdevice () || esb_pci == NULL)
463 return -ENODEV;
464
465 /* Check that the heartbeat value is within it's range ; if not reset to the default */
466 if (esb_timer_set_heartbeat (heartbeat)) {
467 esb_timer_set_heartbeat (WATCHDOG_HEARTBEAT);
468 printk(KERN_INFO PFX "heartbeat value must be 1<heartbeat<2046, using %d\n",
469 heartbeat);
470 }
471
472 ret = register_reboot_notifier(&esb_notifier);
473 if (ret != 0) {
474 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
475 ret);
476 goto err_unmap;
477 }
478
479 ret = misc_register(&esb_miscdev);
480 if (ret != 0) {
481 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
482 WATCHDOG_MINOR, ret);
483 goto err_notifier;
484 }
485
486 esb_timer_stop ();
487
488 printk (KERN_INFO PFX "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n",
489 BASEADDR, heartbeat, nowayout);
490
491 return 0;
492
493err_notifier:
494 unregister_reboot_notifier(&esb_notifier);
495err_unmap:
496 iounmap(BASEADDR);
497/* err_release: */
498 pci_release_region(esb_pci, 0);
499/* err_disable: */
500 pci_disable_device(esb_pci);
501/* err_devput: */
502 pci_dev_put(esb_pci);
503 return ret;
504}
505
506static void __exit watchdog_cleanup (void)
507{
508 /* Stop the timer before we leave */
509 if (!nowayout)
510 esb_timer_stop ();
511
512 /* Deregister */
513 misc_deregister(&esb_miscdev);
514 unregister_reboot_notifier(&esb_notifier);
515 iounmap(BASEADDR);
516 pci_release_region(esb_pci, 0);
517 pci_disable_device(esb_pci);
518 pci_dev_put(esb_pci);
519}
520
521module_init(watchdog_init);
522module_exit(watchdog_cleanup);
523
524MODULE_AUTHOR("Ross Biro and David Härdeman");
525MODULE_DESCRIPTION("Watchdog driver for Intel 6300ESB chipsets");
526MODULE_LICENSE("GPL");
527MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/char/watchdog/ibmasr.c b/drivers/char/watchdog/ibmasr.c
new file mode 100644
index 000000000000..294c474ae485
--- /dev/null
+++ b/drivers/char/watchdog/ibmasr.c
@@ -0,0 +1,405 @@
1/*
2 * IBM Automatic Server Restart driver.
3 *
4 * Copyright (c) 2005 Andrey Panin <pazke@donpac.ru>
5 *
6 * Based on driver written by Pete Reynolds.
7 * Copyright (c) IBM Corporation, 1998-2004.
8 *
9 * This software may be used and distributed according to the terms
10 * of the GNU Public License, incorporated herein by reference.
11 */
12
13#include <linux/config.h>
14#include <linux/fs.h>
15#include <linux/kernel.h>
16#include <linux/slab.h>
17#include <linux/module.h>
18#include <linux/pci.h>
19#include <linux/timer.h>
20#include <linux/miscdevice.h>
21#include <linux/watchdog.h>
22#include <linux/dmi.h>
23
24#include <asm/io.h>
25#include <asm/uaccess.h>
26
27
28enum {
29 ASMTYPE_UNKNOWN,
30 ASMTYPE_TOPAZ,
31 ASMTYPE_JASPER,
32 ASMTYPE_PEARL,
33 ASMTYPE_JUNIPER,
34 ASMTYPE_SPRUCE,
35};
36
37#define PFX "ibmasr: "
38
39#define TOPAZ_ASR_REG_OFFSET 4
40#define TOPAZ_ASR_TOGGLE 0x40
41#define TOPAZ_ASR_DISABLE 0x80
42
43/* PEARL ASR S/W REGISTER SUPERIO PORT ADDRESSES */
44#define PEARL_BASE 0xe04
45#define PEARL_WRITE 0xe06
46#define PEARL_READ 0xe07
47
48#define PEARL_ASR_DISABLE_MASK 0x80 /* bit 7: disable = 1, enable = 0 */
49#define PEARL_ASR_TOGGLE_MASK 0x40 /* bit 6: 0, then 1, then 0 */
50
51/* JASPER OFFSET FROM SIO BASE ADDR TO ASR S/W REGISTERS. */
52#define JASPER_ASR_REG_OFFSET 0x38
53
54#define JASPER_ASR_DISABLE_MASK 0x01 /* bit 0: disable = 1, enable = 0 */
55#define JASPER_ASR_TOGGLE_MASK 0x02 /* bit 1: 0, then 1, then 0 */
56
57#define JUNIPER_BASE_ADDRESS 0x54b /* Base address of Juniper ASR */
58#define JUNIPER_ASR_DISABLE_MASK 0x01 /* bit 0: disable = 1 enable = 0 */
59#define JUNIPER_ASR_TOGGLE_MASK 0x02 /* bit 1: 0, then 1, then 0 */
60
61#define SPRUCE_BASE_ADDRESS 0x118e /* Base address of Spruce ASR */
62#define SPRUCE_ASR_DISABLE_MASK 0x01 /* bit 1: disable = 1 enable = 0 */
63#define SPRUCE_ASR_TOGGLE_MASK 0x02 /* bit 0: 0, then 1, then 0 */
64
65
66static int nowayout = WATCHDOG_NOWAYOUT;
67
68static unsigned long asr_is_open;
69static char asr_expect_close;
70
71static unsigned int asr_type, asr_base, asr_length;
72static unsigned int asr_read_addr, asr_write_addr;
73static unsigned char asr_toggle_mask, asr_disable_mask;
74
75static void asr_toggle(void)
76{
77 unsigned char reg = inb(asr_read_addr);
78
79 outb(reg & ~asr_toggle_mask, asr_write_addr);
80 reg = inb(asr_read_addr);
81
82 outb(reg | asr_toggle_mask, asr_write_addr);
83 reg = inb(asr_read_addr);
84
85 outb(reg & ~asr_toggle_mask, asr_write_addr);
86 reg = inb(asr_read_addr);
87}
88
89static void asr_enable(void)
90{
91 unsigned char reg;
92
93 if (asr_type == ASMTYPE_TOPAZ) {
94 /* asr_write_addr == asr_read_addr */
95 reg = inb(asr_read_addr);
96 outb(reg & ~(TOPAZ_ASR_TOGGLE | TOPAZ_ASR_DISABLE),
97 asr_read_addr);
98 } else {
99 /*
100 * First make sure the hardware timer is reset by toggling
101 * ASR hardware timer line.
102 */
103 asr_toggle();
104
105 reg = inb(asr_read_addr);
106 outb(reg & ~asr_disable_mask, asr_write_addr);
107 }
108 reg = inb(asr_read_addr);
109}
110
111static void asr_disable(void)
112{
113 unsigned char reg = inb(asr_read_addr);
114
115 if (asr_type == ASMTYPE_TOPAZ)
116 /* asr_write_addr == asr_read_addr */
117 outb(reg | TOPAZ_ASR_TOGGLE | TOPAZ_ASR_DISABLE,
118 asr_read_addr);
119 else {
120 outb(reg | asr_toggle_mask, asr_write_addr);
121 reg = inb(asr_read_addr);
122
123 outb(reg | asr_disable_mask, asr_write_addr);
124 }
125 reg = inb(asr_read_addr);
126}
127
128static int __init asr_get_base_address(void)
129{
130 unsigned char low, high;
131 const char *type = "";
132
133 asr_length = 1;
134
135 switch (asr_type) {
136 case ASMTYPE_TOPAZ:
137 /* SELECT SuperIO CHIP FOR QUERYING (WRITE 0x07 TO BOTH 0x2E and 0x2F) */
138 outb(0x07, 0x2e);
139 outb(0x07, 0x2f);
140
141 /* SELECT AND READ THE HIGH-NIBBLE OF THE GPIO BASE ADDRESS */
142 outb(0x60, 0x2e);
143 high = inb(0x2f);
144
145 /* SELECT AND READ THE LOW-NIBBLE OF THE GPIO BASE ADDRESS */
146 outb(0x61, 0x2e);
147 low = inb(0x2f);
148
149 asr_base = (high << 16) | low;
150 asr_read_addr = asr_write_addr =
151 asr_base + TOPAZ_ASR_REG_OFFSET;
152 asr_length = 5;
153
154 break;
155
156 case ASMTYPE_JASPER:
157 type = "Jaspers ";
158
159 /* FIXME: need to use pci_config_lock here, but it's not exported */
160
161/* spin_lock_irqsave(&pci_config_lock, flags);*/
162
163 /* Select the SuperIO chip in the PCI I/O port register */
164 outl(0x8000f858, 0xcf8);
165
166 /*
167 * Read the base address for the SuperIO chip.
168 * Only the lower 16 bits are valid, but the address is word
169 * aligned so the last bit must be masked off.
170 */
171 asr_base = inl(0xcfc) & 0xfffe;
172
173/* spin_unlock_irqrestore(&pci_config_lock, flags);*/
174
175 asr_read_addr = asr_write_addr =
176 asr_base + JASPER_ASR_REG_OFFSET;
177 asr_toggle_mask = JASPER_ASR_TOGGLE_MASK;
178 asr_disable_mask = JASPER_ASR_DISABLE_MASK;
179 asr_length = JASPER_ASR_REG_OFFSET + 1;
180
181 break;
182
183 case ASMTYPE_PEARL:
184 type = "Pearls ";
185 asr_base = PEARL_BASE;
186 asr_read_addr = PEARL_READ;
187 asr_write_addr = PEARL_WRITE;
188 asr_toggle_mask = PEARL_ASR_TOGGLE_MASK;
189 asr_disable_mask = PEARL_ASR_DISABLE_MASK;
190 asr_length = 4;
191 break;
192
193 case ASMTYPE_JUNIPER:
194 type = "Junipers ";
195 asr_base = JUNIPER_BASE_ADDRESS;
196 asr_read_addr = asr_write_addr = asr_base;
197 asr_toggle_mask = JUNIPER_ASR_TOGGLE_MASK;
198 asr_disable_mask = JUNIPER_ASR_DISABLE_MASK;
199 break;
200
201 case ASMTYPE_SPRUCE:
202 type = "Spruce's ";
203 asr_base = SPRUCE_BASE_ADDRESS;
204 asr_read_addr = asr_write_addr = asr_base;
205 asr_toggle_mask = SPRUCE_ASR_TOGGLE_MASK;
206 asr_disable_mask = SPRUCE_ASR_DISABLE_MASK;
207 break;
208 }
209
210 if (!request_region(asr_base, asr_length, "ibmasr")) {
211 printk(KERN_ERR PFX "address %#x already in use\n",
212 asr_base);
213 return -EBUSY;
214 }
215
216 printk(KERN_INFO PFX "found %sASR @ addr %#x\n", type, asr_base);
217
218 return 0;
219}
220
221
222static ssize_t asr_write(struct file *file, const char __user *buf,
223 size_t count, loff_t *ppos)
224{
225 if (count) {
226 if (!nowayout) {
227 size_t i;
228
229 /* In case it was set long ago */
230 asr_expect_close = 0;
231
232 for (i = 0; i != count; i++) {
233 char c;
234 if (get_user(c, buf + i))
235 return -EFAULT;
236 if (c == 'V')
237 asr_expect_close = 42;
238 }
239 }
240 asr_toggle();
241 }
242 return count;
243}
244
245static int asr_ioctl(struct inode *inode, struct file *file,
246 unsigned int cmd, unsigned long arg)
247{
248 static const struct watchdog_info ident = {
249 .options = WDIOF_KEEPALIVEPING |
250 WDIOF_MAGICCLOSE,
251 .identity = "IBM ASR"
252 };
253 void __user *argp = (void __user *)arg;
254 int __user *p = argp;
255 int heartbeat;
256
257 switch (cmd) {
258 case WDIOC_GETSUPPORT:
259 return copy_to_user(argp, &ident, sizeof(ident)) ?
260 -EFAULT : 0;
261
262 case WDIOC_GETSTATUS:
263 case WDIOC_GETBOOTSTATUS:
264 return put_user(0, p);
265
266 case WDIOC_KEEPALIVE:
267 asr_toggle();
268 return 0;
269
270 /*
271 * The hardware has a fixed timeout value, so no WDIOC_SETTIMEOUT
272 * and WDIOC_GETTIMEOUT always returns 256.
273 */
274 case WDIOC_GETTIMEOUT:
275 heartbeat = 256;
276 return put_user(heartbeat, p);
277
278 case WDIOC_SETOPTIONS: {
279 int new_options, retval = -EINVAL;
280
281 if (get_user(new_options, p))
282 return -EFAULT;
283
284 if (new_options & WDIOS_DISABLECARD) {
285 asr_disable();
286 retval = 0;
287 }
288
289 if (new_options & WDIOS_ENABLECARD) {
290 asr_enable();
291 asr_toggle();
292 retval = 0;
293 }
294
295 return retval;
296 }
297 }
298
299 return -ENOIOCTLCMD;
300}
301
302static int asr_open(struct inode *inode, struct file *file)
303{
304 if(test_and_set_bit(0, &asr_is_open))
305 return -EBUSY;
306
307 asr_toggle();
308 asr_enable();
309
310 return nonseekable_open(inode, file);
311}
312
313static int asr_release(struct inode *inode, struct file *file)
314{
315 if (asr_expect_close == 42)
316 asr_disable();
317 else {
318 printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n");
319 asr_toggle();
320 }
321 clear_bit(0, &asr_is_open);
322 asr_expect_close = 0;
323 return 0;
324}
325
326static struct file_operations asr_fops = {
327 .owner = THIS_MODULE,
328 .llseek = no_llseek,
329 .write = asr_write,
330 .ioctl = asr_ioctl,
331 .open = asr_open,
332 .release = asr_release,
333};
334
335static struct miscdevice asr_miscdev = {
336 .minor = WATCHDOG_MINOR,
337 .name = "watchdog",
338 .fops = &asr_fops,
339};
340
341
342struct ibmasr_id {
343 const char *desc;
344 int type;
345};
346
347static struct ibmasr_id __initdata ibmasr_id_table[] = {
348 { "IBM Automatic Server Restart - eserver xSeries 220", ASMTYPE_TOPAZ },
349 { "IBM Automatic Server Restart - Machine Type 8673", ASMTYPE_PEARL },
350 { "IBM Automatic Server Restart - Machine Type 8480", ASMTYPE_JASPER },
351 { "IBM Automatic Server Restart - Machine Type 8482", ASMTYPE_JUNIPER },
352 { "IBM Automatic Server Restart - Machine Type 8648", ASMTYPE_SPRUCE },
353 { NULL }
354};
355
356static int __init ibmasr_init(void)
357{
358 struct ibmasr_id *id;
359 int rc;
360
361 for (id = ibmasr_id_table; id->desc; id++) {
362 if (dmi_find_device(DMI_DEV_TYPE_OTHER, id->desc, NULL)) {
363 asr_type = id->type;
364 break;
365 }
366 }
367
368 if (!asr_type)
369 return -ENODEV;
370
371 rc = misc_register(&asr_miscdev);
372 if (rc < 0) {
373 printk(KERN_ERR PFX "failed to register misc device\n");
374 return rc;
375 }
376
377 rc = asr_get_base_address();
378 if (rc) {
379 misc_deregister(&asr_miscdev);
380 return rc;
381 }
382
383 return 0;
384}
385
386static void __exit ibmasr_exit(void)
387{
388 if (!nowayout)
389 asr_disable();
390
391 misc_deregister(&asr_miscdev);
392
393 release_region(asr_base, asr_length);
394}
395
396module_init(ibmasr_init);
397module_exit(ibmasr_exit);
398
399module_param(nowayout, int, 0);
400MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
401
402MODULE_DESCRIPTION("IBM Automatic Server Restart driver");
403MODULE_AUTHOR("Andrey Panin");
404MODULE_LICENSE("GPL");
405MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/char/watchdog/mpcore_wdt.c b/drivers/char/watchdog/mpcore_wdt.c
new file mode 100644
index 000000000000..c694eee1fb24
--- /dev/null
+++ b/drivers/char/watchdog/mpcore_wdt.c
@@ -0,0 +1,434 @@
1/*
2 * Watchdog driver for the mpcore watchdog timer
3 *
4 * (c) Copyright 2004 ARM Limited
5 *
6 * Based on the SoftDog driver:
7 * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved.
8 * http://www.redhat.com
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 *
15 * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
16 * warranty for any of this software. This material is provided
17 * "AS-IS" and at no charge.
18 *
19 * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>
20 *
21 */
22#include <linux/module.h>
23#include <linux/moduleparam.h>
24#include <linux/config.h>
25#include <linux/types.h>
26#include <linux/miscdevice.h>
27#include <linux/watchdog.h>
28#include <linux/fs.h>
29#include <linux/reboot.h>
30#include <linux/init.h>
31#include <linux/interrupt.h>
32#include <linux/device.h>
33#include <asm/uaccess.h>
34
35struct mpcore_wdt {
36 unsigned long timer_alive;
37 struct device *dev;
38 void __iomem *base;
39 int irq;
40 unsigned int perturb;
41 char expect_close;
42};
43
44static struct platform_device *mpcore_wdt_dev;
45
46extern unsigned int mpcore_timer_rate;
47
48#define TIMER_MARGIN 60
49static int mpcore_margin = TIMER_MARGIN;
50module_param(mpcore_margin, int, 0);
51MODULE_PARM_DESC(mpcore_margin, "MPcore timer margin in seconds. (0<mpcore_margin<65536, default=" __MODULE_STRING(TIMER_MARGIN) ")");
52
53static int nowayout = WATCHDOG_NOWAYOUT;
54module_param(nowayout, int, 0);
55MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
56
57#define ONLY_TESTING 0
58static int mpcore_noboot = ONLY_TESTING;
59module_param(mpcore_noboot, int, 0);
60MODULE_PARM_DESC(mpcore_noboot, "MPcore watchdog action, set to 1 to ignore reboots, 0 to reboot (default=" __MODULE_STRING(ONLY_TESTING) ")");
61
62/*
63 * This is the interrupt handler. Note that we only use this
64 * in testing mode, so don't actually do a reboot here.
65 */
66static irqreturn_t mpcore_wdt_fire(int irq, void *arg, struct pt_regs *regs)
67{
68 struct mpcore_wdt *wdt = arg;
69
70 /* Check it really was our interrupt */
71 if (readl(wdt->base + TWD_WDOG_INTSTAT)) {
72 dev_printk(KERN_CRIT, wdt->dev, "Triggered - Reboot ignored.\n");
73
74 /* Clear the interrupt on the watchdog */
75 writel(1, wdt->base + TWD_WDOG_INTSTAT);
76
77 return IRQ_HANDLED;
78 }
79
80 return IRQ_NONE;
81}
82
83/*
84 * mpcore_wdt_keepalive - reload the timer
85 *
86 * Note that the spec says a DIFFERENT value must be written to the reload
87 * register each time. The "perturb" variable deals with this by adding 1
88 * to the count every other time the function is called.
89 */
90static void mpcore_wdt_keepalive(struct mpcore_wdt *wdt)
91{
92 unsigned int count;
93
94 /* Assume prescale is set to 256 */
95 count = (mpcore_timer_rate / 256) * mpcore_margin;
96
97 /* Reload the counter */
98 writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);
99
100 wdt->perturb = wdt->perturb ? 0 : 1;
101}
102
103static void mpcore_wdt_stop(struct mpcore_wdt *wdt)
104{
105 writel(0x12345678, wdt->base + TWD_WDOG_DISABLE);
106 writel(0x87654321, wdt->base + TWD_WDOG_DISABLE);
107 writel(0x0, wdt->base + TWD_WDOG_CONTROL);
108}
109
110static void mpcore_wdt_start(struct mpcore_wdt *wdt)
111{
112 dev_printk(KERN_INFO, wdt->dev, "enabling watchdog.\n");
113
114 /* This loads the count register but does NOT start the count yet */
115 mpcore_wdt_keepalive(wdt);
116
117 if (mpcore_noboot) {
118 /* Enable watchdog - prescale=256, watchdog mode=0, enable=1 */
119 writel(0x0000FF01, wdt->base + TWD_WDOG_CONTROL);
120 } else {
121 /* Enable watchdog - prescale=256, watchdog mode=1, enable=1 */
122 writel(0x0000FF09, wdt->base + TWD_WDOG_CONTROL);
123 }
124}
125
126static int mpcore_wdt_set_heartbeat(int t)
127{
128 if (t < 0x0001 || t > 0xFFFF)
129 return -EINVAL;
130
131 mpcore_margin = t;
132 return 0;
133}
134
135/*
136 * /dev/watchdog handling
137 */
138static int mpcore_wdt_open(struct inode *inode, struct file *file)
139{
140 struct mpcore_wdt *wdt = dev_get_drvdata(&mpcore_wdt_dev->dev);
141
142 if (test_and_set_bit(0, &wdt->timer_alive))
143 return -EBUSY;
144
145 if (nowayout)
146 __module_get(THIS_MODULE);
147
148 file->private_data = wdt;
149
150 /*
151 * Activate timer
152 */
153 mpcore_wdt_start(wdt);
154
155 return nonseekable_open(inode, file);
156}
157
158static int mpcore_wdt_release(struct inode *inode, struct file *file)
159{
160 struct mpcore_wdt *wdt = file->private_data;
161
162 /*
163 * Shut off the timer.
164 * Lock it in if it's a module and we set nowayout
165 */
166 if (wdt->expect_close == 42) {
167 mpcore_wdt_stop(wdt);
168 } else {
169 dev_printk(KERN_CRIT, wdt->dev, "unexpected close, not stopping watchdog!\n");
170 mpcore_wdt_keepalive(wdt);
171 }
172 clear_bit(0, &wdt->timer_alive);
173 wdt->expect_close = 0;
174 return 0;
175}
176
177static ssize_t mpcore_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
178{
179 struct mpcore_wdt *wdt = file->private_data;
180
181 /* Can't seek (pwrite) on this device */
182 if (ppos != &file->f_pos)
183 return -ESPIPE;
184
185 /*
186 * Refresh the timer.
187 */
188 if (len) {
189 if (!nowayout) {
190 size_t i;
191
192 /* In case it was set long ago */
193 wdt->expect_close = 0;
194
195 for (i = 0; i != len; i++) {
196 char c;
197
198 if (get_user(c, data + i))
199 return -EFAULT;
200 if (c == 'V')
201 wdt->expect_close = 42;
202 }
203 }
204 mpcore_wdt_keepalive(wdt);
205 }
206 return len;
207}
208
209static struct watchdog_info ident = {
210 .options = WDIOF_SETTIMEOUT |
211 WDIOF_KEEPALIVEPING |
212 WDIOF_MAGICCLOSE,
213 .identity = "MPcore Watchdog",
214};
215
216static int mpcore_wdt_ioctl(struct inode *inode, struct file *file,
217 unsigned int cmd, unsigned long arg)
218{
219 struct mpcore_wdt *wdt = file->private_data;
220 int ret;
221 union {
222 struct watchdog_info ident;
223 int i;
224 } uarg;
225
226 if (_IOC_DIR(cmd) && _IOC_SIZE(cmd) > sizeof(uarg))
227 return -ENOIOCTLCMD;
228
229 if (_IOC_DIR(cmd) & _IOC_WRITE) {
230 ret = copy_from_user(&uarg, (void __user *)arg, _IOC_SIZE(cmd));
231 if (ret)
232 return -EFAULT;
233 }
234
235 switch (cmd) {
236 case WDIOC_GETSUPPORT:
237 uarg.ident = ident;
238 ret = 0;
239 break;
240
241 case WDIOC_SETOPTIONS:
242 ret = -EINVAL;
243 if (uarg.i & WDIOS_DISABLECARD) {
244 mpcore_wdt_stop(wdt);
245 ret = 0;
246 }
247 if (uarg.i & WDIOS_ENABLECARD) {
248 mpcore_wdt_start(wdt);
249 ret = 0;
250 }
251 break;
252
253 case WDIOC_GETSTATUS:
254 case WDIOC_GETBOOTSTATUS:
255 uarg.i = 0;
256 ret = 0;
257 break;
258
259 case WDIOC_KEEPALIVE:
260 mpcore_wdt_keepalive(wdt);
261 ret = 0;
262 break;
263
264 case WDIOC_SETTIMEOUT:
265 ret = mpcore_wdt_set_heartbeat(uarg.i);
266 if (ret)
267 break;
268
269 mpcore_wdt_keepalive(wdt);
270 /* Fall */
271 case WDIOC_GETTIMEOUT:
272 uarg.i = mpcore_margin;
273 ret = 0;
274 break;
275
276 default:
277 return -ENOIOCTLCMD;
278 }
279
280 if (ret == 0 && _IOC_DIR(cmd) & _IOC_READ) {
281 ret = copy_to_user((void __user *)arg, &uarg, _IOC_SIZE(cmd));
282 if (ret)
283 ret = -EFAULT;
284 }
285 return ret;
286}
287
288/*
289 * System shutdown handler. Turn off the watchdog if we're
290 * restarting or halting the system.
291 */
292static void mpcore_wdt_shutdown(struct device *_dev)
293{
294 struct mpcore_wdt *wdt = dev_get_drvdata(_dev);
295
296 if (system_state == SYSTEM_RESTART || system_state == SYSTEM_HALT)
297 mpcore_wdt_stop(wdt);
298}
299
300/*
301 * Kernel Interfaces
302 */
303static struct file_operations mpcore_wdt_fops = {
304 .owner = THIS_MODULE,
305 .llseek = no_llseek,
306 .write = mpcore_wdt_write,
307 .ioctl = mpcore_wdt_ioctl,
308 .open = mpcore_wdt_open,
309 .release = mpcore_wdt_release,
310};
311
312static struct miscdevice mpcore_wdt_miscdev = {
313 .minor = WATCHDOG_MINOR,
314 .name = "watchdog",
315 .fops = &mpcore_wdt_fops,
316};
317
318static int __devinit mpcore_wdt_probe(struct device *_dev)
319{
320 struct platform_device *dev = to_platform_device(_dev);
321 struct mpcore_wdt *wdt;
322 struct resource *res;
323 int ret;
324
325 /* We only accept one device, and it must have an id of -1 */
326 if (dev->id != -1)
327 return -ENODEV;
328
329 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
330 if (!res) {
331 ret = -ENODEV;
332 goto err_out;
333 }
334
335 wdt = kmalloc(sizeof(struct mpcore_wdt), GFP_KERNEL);
336 if (!wdt) {
337 ret = -ENOMEM;
338 goto err_out;
339 }
340 memset(wdt, 0, sizeof(struct mpcore_wdt));
341
342 wdt->dev = &dev->dev;
343 wdt->irq = platform_get_irq(dev, 0);
344 wdt->base = ioremap(res->start, res->end - res->start + 1);
345 if (!wdt->base) {
346 ret = -ENOMEM;
347 goto err_free;
348 }
349
350 mpcore_wdt_miscdev.dev = &dev->dev;
351 ret = misc_register(&mpcore_wdt_miscdev);
352 if (ret) {
353 dev_printk(KERN_ERR, _dev, "cannot register miscdev on minor=%d (err=%d)\n",
354 WATCHDOG_MINOR, ret);
355 goto err_misc;
356 }
357
358 ret = request_irq(wdt->irq, mpcore_wdt_fire, SA_INTERRUPT, "mpcore_wdt", wdt);
359 if (ret) {
360 dev_printk(KERN_ERR, _dev, "cannot register IRQ%d for watchdog\n", wdt->irq);
361 goto err_irq;
362 }
363
364 mpcore_wdt_stop(wdt);
365 dev_set_drvdata(&dev->dev, wdt);
366 mpcore_wdt_dev = dev;
367
368 return 0;
369
370 err_irq:
371 misc_deregister(&mpcore_wdt_miscdev);
372 err_misc:
373 iounmap(wdt->base);
374 err_free:
375 kfree(wdt);
376 err_out:
377 return ret;
378}
379
380static int __devexit mpcore_wdt_remove(struct device *dev)
381{
382 struct mpcore_wdt *wdt = dev_get_drvdata(dev);
383
384 dev_set_drvdata(dev, NULL);
385
386 misc_deregister(&mpcore_wdt_miscdev);
387
388 mpcore_wdt_dev = NULL;
389
390 free_irq(wdt->irq, wdt);
391 iounmap(wdt->base);
392 kfree(wdt);
393 return 0;
394}
395
396static struct device_driver mpcore_wdt_driver = {
397 .name = "mpcore_wdt",
398 .bus = &platform_bus_type,
399 .probe = mpcore_wdt_probe,
400 .remove = __devexit_p(mpcore_wdt_remove),
401 .shutdown = mpcore_wdt_shutdown,
402};
403
404static char banner[] __initdata = KERN_INFO "MPcore Watchdog Timer: 0.1. mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n";
405
406static int __init mpcore_wdt_init(void)
407{
408 /*
409 * Check that the margin value is within it's range;
410 * if not reset to the default
411 */
412 if (mpcore_wdt_set_heartbeat(mpcore_margin)) {
413 mpcore_wdt_set_heartbeat(TIMER_MARGIN);
414 printk(KERN_INFO "mpcore_margin value must be 0<mpcore_margin<65536, using %d\n",
415 TIMER_MARGIN);
416 }
417
418 printk(banner, mpcore_noboot, mpcore_margin, nowayout);
419
420 return driver_register(&mpcore_wdt_driver);
421}
422
423static void __exit mpcore_wdt_exit(void)
424{
425 driver_unregister(&mpcore_wdt_driver);
426}
427
428module_init(mpcore_wdt_init);
429module_exit(mpcore_wdt_exit);
430
431MODULE_AUTHOR("ARM Limited");
432MODULE_DESCRIPTION("MPcore Watchdog Device Driver");
433MODULE_LICENSE("GPL");
434MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/char/watchdog/mv64x60_wdt.c b/drivers/char/watchdog/mv64x60_wdt.c
new file mode 100644
index 000000000000..1436aea3b28f
--- /dev/null
+++ b/drivers/char/watchdog/mv64x60_wdt.c
@@ -0,0 +1,252 @@
1/*
2 * mv64x60_wdt.c - MV64X60 (Marvell Discovery) watchdog userspace interface
3 *
4 * Author: James Chapman <jchapman@katalix.com>
5 *
6 * Platform-specific setup code should configure the dog to generate
7 * interrupt or reset as required. This code only enables/disables
8 * and services the watchdog.
9 *
10 * Derived from mpc8xx_wdt.c, with the following copyright.
11 *
12 * 2002 (c) Florian Schirmer <jolt@tuxbox.org> This file is licensed under
13 * the terms of the GNU General Public License version 2. This program
14 * is licensed "as is" without any warranty of any kind, whether express
15 * or implied.
16 */
17
18#include <linux/config.h>
19#include <linux/fs.h>
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <linux/miscdevice.h>
23#include <linux/module.h>
24#include <linux/watchdog.h>
25#include <asm/mv64x60.h>
26#include <asm/uaccess.h>
27#include <asm/io.h>
28
29/* MV64x60 WDC (config) register access definitions */
30#define MV64x60_WDC_CTL1_MASK (3 << 24)
31#define MV64x60_WDC_CTL1(val) ((val & 3) << 24)
32#define MV64x60_WDC_CTL2_MASK (3 << 26)
33#define MV64x60_WDC_CTL2(val) ((val & 3) << 26)
34
35/* Flags bits */
36#define MV64x60_WDOG_FLAG_OPENED 0
37#define MV64x60_WDOG_FLAG_ENABLED 1
38
39static unsigned long wdt_flags;
40static int wdt_status;
41static void __iomem *mv64x60_regs;
42static int mv64x60_wdt_timeout;
43
44static void mv64x60_wdt_reg_write(u32 val)
45{
46 /* Allow write only to CTL1 / CTL2 fields, retaining values in
47 * other fields.
48 */
49 u32 data = readl(mv64x60_regs + MV64x60_WDT_WDC);
50 data &= ~(MV64x60_WDC_CTL1_MASK | MV64x60_WDC_CTL2_MASK);
51 data |= val;
52 writel(data, mv64x60_regs + MV64x60_WDT_WDC);
53}
54
55static void mv64x60_wdt_service(void)
56{
57 /* Write 01 followed by 10 to CTL2 */
58 mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x01));
59 mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x02));
60}
61
62static void mv64x60_wdt_handler_disable(void)
63{
64 if (test_and_clear_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) {
65 /* Write 01 followed by 10 to CTL1 */
66 mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01));
67 mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02));
68 printk(KERN_NOTICE "mv64x60_wdt: watchdog deactivated\n");
69 }
70}
71
72static void mv64x60_wdt_handler_enable(void)
73{
74 if (!test_and_set_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) {
75 /* Write 01 followed by 10 to CTL1 */
76 mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01));
77 mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02));
78 printk(KERN_NOTICE "mv64x60_wdt: watchdog activated\n");
79 }
80}
81
82static int mv64x60_wdt_open(struct inode *inode, struct file *file)
83{
84 if (test_and_set_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags))
85 return -EBUSY;
86
87 mv64x60_wdt_service();
88 mv64x60_wdt_handler_enable();
89
90 return 0;
91}
92
93static int mv64x60_wdt_release(struct inode *inode, struct file *file)
94{
95 mv64x60_wdt_service();
96
97#if !defined(CONFIG_WATCHDOG_NOWAYOUT)
98 mv64x60_wdt_handler_disable();
99#endif
100
101 clear_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags);
102
103 return 0;
104}
105
106static ssize_t mv64x60_wdt_write(struct file *file, const char *data,
107 size_t len, loff_t * ppos)
108{
109 if (*ppos != file->f_pos)
110 return -ESPIPE;
111
112 if (len)
113 mv64x60_wdt_service();
114
115 return len;
116}
117
118static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
119 unsigned int cmd, unsigned long arg)
120{
121 int timeout;
122 static struct watchdog_info info = {
123 .options = WDIOF_KEEPALIVEPING,
124 .firmware_version = 0,
125 .identity = "MV64x60 watchdog",
126 };
127
128 switch (cmd) {
129 case WDIOC_GETSUPPORT:
130 if (copy_to_user((void *)arg, &info, sizeof(info)))
131 return -EFAULT;
132 break;
133
134 case WDIOC_GETSTATUS:
135 case WDIOC_GETBOOTSTATUS:
136 if (put_user(wdt_status, (int *)arg))
137 return -EFAULT;
138 wdt_status &= ~WDIOF_KEEPALIVEPING;
139 break;
140
141 case WDIOC_GETTEMP:
142 return -EOPNOTSUPP;
143
144 case WDIOC_SETOPTIONS:
145 return -EOPNOTSUPP;
146
147 case WDIOC_KEEPALIVE:
148 mv64x60_wdt_service();
149 wdt_status |= WDIOF_KEEPALIVEPING;
150 break;
151
152 case WDIOC_SETTIMEOUT:
153 return -EOPNOTSUPP;
154
155 case WDIOC_GETTIMEOUT:
156 timeout = mv64x60_wdt_timeout * HZ;
157 if (put_user(timeout, (int *)arg))
158 return -EFAULT;
159 break;
160
161 default:
162 return -ENOIOCTLCMD;
163 }
164
165 return 0;
166}
167
168static struct file_operations mv64x60_wdt_fops = {
169 .owner = THIS_MODULE,
170 .llseek = no_llseek,
171 .write = mv64x60_wdt_write,
172 .ioctl = mv64x60_wdt_ioctl,
173 .open = mv64x60_wdt_open,
174 .release = mv64x60_wdt_release,
175};
176
177static struct miscdevice mv64x60_wdt_miscdev = {
178 .minor = WATCHDOG_MINOR,
179 .name = "watchdog",
180 .fops = &mv64x60_wdt_fops,
181};
182
183static int __devinit mv64x60_wdt_probe(struct device *dev)
184{
185 struct platform_device *pd = to_platform_device(dev);
186 struct mv64x60_wdt_pdata *pdata = pd->dev.platform_data;
187 int bus_clk = 133;
188
189 mv64x60_wdt_timeout = 10;
190 if (pdata) {
191 mv64x60_wdt_timeout = pdata->timeout;
192 bus_clk = pdata->bus_clk;
193 }
194
195 mv64x60_regs = mv64x60_get_bridge_vbase();
196
197 writel((mv64x60_wdt_timeout * (bus_clk * 1000000)) >> 8,
198 mv64x60_regs + MV64x60_WDT_WDC);
199
200 return misc_register(&mv64x60_wdt_miscdev);
201}
202
203static int __devexit mv64x60_wdt_remove(struct device *dev)
204{
205 misc_deregister(&mv64x60_wdt_miscdev);
206
207 mv64x60_wdt_service();
208 mv64x60_wdt_handler_disable();
209
210 return 0;
211}
212
213static struct device_driver mv64x60_wdt_driver = {
214 .name = MV64x60_WDT_NAME,
215 .bus = &platform_bus_type,
216 .probe = mv64x60_wdt_probe,
217 .remove = __devexit_p(mv64x60_wdt_remove),
218};
219
220static struct platform_device *mv64x60_wdt_dev;
221
222static int __init mv64x60_wdt_init(void)
223{
224 int ret;
225
226 printk(KERN_INFO "MV64x60 watchdog driver\n");
227
228 mv64x60_wdt_dev = platform_device_register_simple(MV64x60_WDT_NAME,
229 -1, NULL, 0);
230 if (IS_ERR(mv64x60_wdt_dev)) {
231 ret = PTR_ERR(mv64x60_wdt_dev);
232 goto out;
233 }
234
235 ret = driver_register(&mv64x60_wdt_driver);
236 out:
237 return ret;
238}
239
240static void __exit mv64x60_wdt_exit(void)
241{
242 driver_unregister(&mv64x60_wdt_driver);
243 platform_device_unregister(mv64x60_wdt_dev);
244}
245
246module_init(mv64x60_wdt_init);
247module_exit(mv64x60_wdt_exit);
248
249MODULE_AUTHOR("James Chapman <jchapman@katalix.com>");
250MODULE_DESCRIPTION("MV64x60 watchdog driver");
251MODULE_LICENSE("GPL");
252MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c
index 2b13afb09c5d..5a80adbf8032 100644
--- a/drivers/char/watchdog/pcwd_pci.c
+++ b/drivers/char/watchdog/pcwd_pci.c
@@ -29,27 +29,29 @@
29 * Includes, defines, variables, module parameters, ... 29 * Includes, defines, variables, module parameters, ...
30 */ 30 */
31 31
32#include <linux/config.h> 32#include <linux/config.h> /* For CONFIG_WATCHDOG_NOWAYOUT/... */
33#include <linux/module.h> 33#include <linux/module.h> /* For module specific items */
34#include <linux/moduleparam.h> 34#include <linux/moduleparam.h> /* For new moduleparam's */
35#include <linux/types.h> 35#include <linux/types.h> /* For standard types (like size_t) */
36#include <linux/delay.h> 36#include <linux/errno.h> /* For the -ENODEV/... values */
37#include <linux/miscdevice.h> 37#include <linux/kernel.h> /* For printk/panic/... */
38#include <linux/watchdog.h> 38#include <linux/delay.h> /* For mdelay function */
39#include <linux/notifier.h> 39#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */
40#include <linux/reboot.h> 40#include <linux/watchdog.h> /* For the watchdog specific items */
41#include <linux/init.h> 41#include <linux/notifier.h> /* For notifier support */
42#include <linux/fs.h> 42#include <linux/reboot.h> /* For reboot_notifier stuff */
43#include <linux/pci.h> 43#include <linux/init.h> /* For __init/__exit/... */
44#include <linux/ioport.h> 44#include <linux/fs.h> /* For file operations */
45#include <linux/spinlock.h> 45#include <linux/pci.h> /* For pci functions */
46 46#include <linux/ioport.h> /* For io-port access */
47#include <asm/uaccess.h> 47#include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */
48#include <asm/io.h> 48
49#include <asm/uaccess.h> /* For copy_to_user/put_user/... */
50#include <asm/io.h> /* For inb/outb/... */
49 51
50/* Module and version information */ 52/* Module and version information */
51#define WATCHDOG_VERSION "1.01" 53#define WATCHDOG_VERSION "1.01"
52#define WATCHDOG_DATE "15 Mar 2005" 54#define WATCHDOG_DATE "02 Sep 2005"
53#define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" 55#define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog"
54#define WATCHDOG_NAME "pcwd_pci" 56#define WATCHDOG_NAME "pcwd_pci"
55#define PFX WATCHDOG_NAME ": " 57#define PFX WATCHDOG_NAME ": "
@@ -335,12 +337,14 @@ static int pcipcwd_ioctl(struct inode *inode, struct file *file,
335 return -EFAULT; 337 return -EFAULT;
336 338
337 if (new_options & WDIOS_DISABLECARD) { 339 if (new_options & WDIOS_DISABLECARD) {
338 pcipcwd_stop(); 340 if (pcipcwd_stop())
341 return -EIO;
339 retval = 0; 342 retval = 0;
340 } 343 }
341 344
342 if (new_options & WDIOS_ENABLECARD) { 345 if (new_options & WDIOS_ENABLECARD) {
343 pcipcwd_start(); 346 if (pcipcwd_start())
347 return -EIO;
344 retval = 0; 348 retval = 0;
345 } 349 }
346 350
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
index 8b292bf343c4..3625b2601b42 100644
--- a/drivers/char/watchdog/s3c2410_wdt.c
+++ b/drivers/char/watchdog/s3c2410_wdt.c
@@ -464,7 +464,7 @@ static void s3c2410wdt_shutdown(struct device *dev)
464static unsigned long wtcon_save; 464static unsigned long wtcon_save;
465static unsigned long wtdat_save; 465static unsigned long wtdat_save;
466 466
467static int s3c2410wdt_suspend(struct device *dev, u32 state, u32 level) 467static int s3c2410wdt_suspend(struct device *dev, pm_message_t state, u32 level)
468{ 468{
469 if (level == SUSPEND_POWER_DOWN) { 469 if (level == SUSPEND_POWER_DOWN) {
470 /* Save watchdog state, and turn it off. */ 470 /* Save watchdog state, and turn it off. */
diff --git a/drivers/char/watchdog/sbc8360.c b/drivers/char/watchdog/sbc8360.c
new file mode 100644
index 000000000000..c6cbf808d8c2
--- /dev/null
+++ b/drivers/char/watchdog/sbc8360.c
@@ -0,0 +1,414 @@
1/*
2 * SBC8360 Watchdog driver
3 *
4 * (c) Copyright 2005 Webcon, Inc.
5 *
6 * Based on ib700wdt.c, which is based on advantechwdt.c which is based
7 * on acquirewdt.c which is based on wdt.c.
8 *
9 * (c) Copyright 2001 Charles Howes <chowes@vsol.net>
10 *
11 * Based on advantechwdt.c which is based on acquirewdt.c which
12 * is based on wdt.c.
13 *
14 * (c) Copyright 2000-2001 Marek Michalkiewicz <marekm@linux.org.pl>
15 *
16 * Based on acquirewdt.c which is based on wdt.c.
17 * Original copyright messages:
18 *
19 * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved.
20 * http://www.redhat.com
21 *
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * as published by the Free Software Foundation; either version
25 * 2 of the License, or (at your option) any later version.
26 *
27 * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
28 * warranty for any of this software. This material is provided
29 * "AS-IS" and at no charge.
30 *
31 * (c) Copyright 1995 Alan Cox <alan@redhat.com>
32 *
33 * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
34 * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
35 * Added timeout module option to override default
36 *
37 */
38
39#include <linux/config.h>
40#include <linux/module.h>
41#include <linux/types.h>
42#include <linux/miscdevice.h>
43#include <linux/watchdog.h>
44#include <linux/ioport.h>
45#include <linux/delay.h>
46#include <linux/notifier.h>
47#include <linux/fs.h>
48#include <linux/reboot.h>
49#include <linux/init.h>
50#include <linux/spinlock.h>
51#include <linux/moduleparam.h>
52
53#include <asm/io.h>
54#include <asm/uaccess.h>
55#include <asm/system.h>
56
57static unsigned long sbc8360_is_open;
58static spinlock_t sbc8360_lock;
59static char expect_close;
60
61#define PFX "sbc8360: "
62
63/*
64 *
65 * Watchdog Timer Configuration
66 *
67 * The function of the watchdog timer is to reset the system automatically
68 * and is defined at I/O port 0120H and 0121H. To enable the watchdog timer
69 * and allow the system to reset, write appropriate values from the table
70 * below to I/O port 0120H and 0121H. To disable the timer, write a zero
71 * value to I/O port 0121H for the system to stop the watchdog function.
72 *
73 * The following describes how the timer should be programmed (according to
74 * the vendor documentation)
75 *
76 * Enabling Watchdog:
77 * MOV AX,000AH (enable, phase I)
78 * MOV DX,0120H
79 * OUT DX,AX
80 * MOV AX,000BH (enable, phase II)
81 * MOV DX,0120H
82 * OUT DX,AX
83 * MOV AX,000nH (set multiplier n, from 1-4)
84 * MOV DX,0120H
85 * OUT DX,AX
86 * MOV AX,000mH (set base timer m, from 0-F)
87 * MOV DX,0121H
88 * OUT DX,AX
89 *
90 * Reset timer:
91 * MOV AX,000mH (same as set base timer, above)
92 * MOV DX,0121H
93 * OUT DX,AX
94 *
95 * Disabling Watchdog:
96 * MOV AX,0000H (a zero value)
97 * MOV DX,0120H
98 * OUT DX,AX
99 *
100 * Watchdog timeout configuration values:
101 * N
102 * M | 1 2 3 4
103 * --|----------------------------------
104 * 0 | 0.5s 5s 50s 100s
105 * 1 | 1s 10s 100s 200s
106 * 2 | 1.5s 15s 150s 300s
107 * 3 | 2s 20s 200s 400s
108 * 4 | 2.5s 25s 250s 500s
109 * 5 | 3s 30s 300s 600s
110 * 6 | 3.5s 35s 350s 700s
111 * 7 | 4s 40s 400s 800s
112 * 8 | 4.5s 45s 450s 900s
113 * 9 | 5s 50s 500s 1000s
114 * A | 5.5s 55s 550s 1100s
115 * B | 6s 60s 600s 1200s
116 * C | 6.5s 65s 650s 1300s
117 * D | 7s 70s 700s 1400s
118 * E | 7.5s 75s 750s 1500s
119 * F | 8s 80s 800s 1600s
120 *
121 * Another way to say the same things is:
122 * For N=1, Timeout = (M+1) * 0.5s
123 * For N=2, Timeout = (M+1) * 5s
124 * For N=3, Timeout = (M+1) * 50s
125 * For N=4, Timeout = (M+1) * 100s
126 *
127 */
128
129static int wd_times[64][2] = {
130 {0, 1}, /* 0 = 0.5s */
131 {1, 1}, /* 1 = 1s */
132 {2, 1}, /* 2 = 1.5s */
133 {3, 1}, /* 3 = 2s */
134 {4, 1}, /* 4 = 2.5s */
135 {5, 1}, /* 5 = 3s */
136 {6, 1}, /* 6 = 3.5s */
137 {7, 1}, /* 7 = 4s */
138 {8, 1}, /* 8 = 4.5s */
139 {9, 1}, /* 9 = 5s */
140 {0xA, 1}, /* 10 = 5.5s */
141 {0xB, 1}, /* 11 = 6s */
142 {0xC, 1}, /* 12 = 6.5s */
143 {0xD, 1}, /* 13 = 7s */
144 {0xE, 1}, /* 14 = 7.5s */
145 {0xF, 1}, /* 15 = 8s */
146 {0, 2}, /* 16 = 5s */
147 {1, 2}, /* 17 = 10s */
148 {2, 2}, /* 18 = 15s */
149 {3, 2}, /* 19 = 20s */
150 {4, 2}, /* 20 = 25s */
151 {5, 2}, /* 21 = 30s */
152 {6, 2}, /* 22 = 35s */
153 {7, 2}, /* 23 = 40s */
154 {8, 2}, /* 24 = 45s */
155 {9, 2}, /* 25 = 50s */
156 {0xA, 2}, /* 26 = 55s */
157 {0xB, 2}, /* 27 = 60s */
158 {0xC, 2}, /* 28 = 65s */
159 {0xD, 2}, /* 29 = 70s */
160 {0xE, 2}, /* 30 = 75s */
161 {0xF, 2}, /* 31 = 80s */
162 {0, 3}, /* 32 = 50s */
163 {1, 3}, /* 33 = 100s */
164 {2, 3}, /* 34 = 150s */
165 {3, 3}, /* 35 = 200s */
166 {4, 3}, /* 36 = 250s */
167 {5, 3}, /* 37 = 300s */
168 {6, 3}, /* 38 = 350s */
169 {7, 3}, /* 39 = 400s */
170 {8, 3}, /* 40 = 450s */
171 {9, 3}, /* 41 = 500s */
172 {0xA, 3}, /* 42 = 550s */
173 {0xB, 3}, /* 43 = 600s */
174 {0xC, 3}, /* 44 = 650s */
175 {0xD, 3}, /* 45 = 700s */
176 {0xE, 3}, /* 46 = 750s */
177 {0xF, 3}, /* 47 = 800s */
178 {0, 4}, /* 48 = 100s */
179 {1, 4}, /* 49 = 200s */
180 {2, 4}, /* 50 = 300s */
181 {3, 4}, /* 51 = 400s */
182 {4, 4}, /* 52 = 500s */
183 {5, 4}, /* 53 = 600s */
184 {6, 4}, /* 54 = 700s */
185 {7, 4}, /* 55 = 800s */
186 {8, 4}, /* 56 = 900s */
187 {9, 4}, /* 57 = 1000s */
188 {0xA, 4}, /* 58 = 1100s */
189 {0xB, 4}, /* 59 = 1200s */
190 {0xC, 4}, /* 60 = 1300s */
191 {0xD, 4}, /* 61 = 1400s */
192 {0xE, 4}, /* 62 = 1500s */
193 {0xF, 4} /* 63 = 1600s */
194};
195
196#define SBC8360_ENABLE 0x120
197#define SBC8360_BASETIME 0x121
198
199static int timeout = 27;
200static int wd_margin = 0xB;
201static int wd_multiplier = 2;
202static int nowayout = WATCHDOG_NOWAYOUT;
203
204module_param(timeout, int, 27);
205MODULE_PARM_DESC(timeout, "Index into timeout table (0-63) (default=27 (60s))");
206module_param(nowayout, int, 0);
207MODULE_PARM_DESC(nowayout,
208 "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
209
210/*
211 * Kernel methods.
212 */
213
214/* Activate and pre-configure watchdog */
215static void sbc8360_activate(void)
216{
217 /* Enable the watchdog */
218 outb(0x0A, SBC8360_ENABLE);
219 msleep_interruptible(100);
220 outb(0x0B, SBC8360_ENABLE);
221 msleep_interruptible(100);
222 /* Set timeout multiplier */
223 outb(wd_multiplier, SBC8360_ENABLE);
224 msleep_interruptible(100);
225 /* Nothing happens until first sbc8360_ping() */
226}
227
228/* Kernel pings watchdog */
229static void sbc8360_ping(void)
230{
231 /* Write the base timer register */
232 outb(wd_margin, SBC8360_BASETIME);
233}
234
235/* Userspace pings kernel driver, or requests clean close */
236static ssize_t sbc8360_write(struct file *file, const char __user * buf,
237 size_t count, loff_t * ppos)
238{
239 if (count) {
240 if (!nowayout) {
241 size_t i;
242
243 /* In case it was set long ago */
244 expect_close = 0;
245
246 for (i = 0; i != count; i++) {
247 char c;
248 if (get_user(c, buf + i))
249 return -EFAULT;
250 if (c == 'V')
251 expect_close = 42;
252 }
253 }
254 sbc8360_ping();
255 }
256 return count;
257}
258
259static int sbc8360_open(struct inode *inode, struct file *file)
260{
261 spin_lock(&sbc8360_lock);
262 if (test_and_set_bit(0, &sbc8360_is_open)) {
263 spin_unlock(&sbc8360_lock);
264 return -EBUSY;
265 }
266 if (nowayout)
267 __module_get(THIS_MODULE);
268
269 /* Activate and ping once to start the countdown */
270 spin_unlock(&sbc8360_lock);
271 sbc8360_activate();
272 sbc8360_ping();
273 return nonseekable_open(inode, file);
274}
275
276static int sbc8360_close(struct inode *inode, struct file *file)
277{
278 spin_lock(&sbc8360_lock);
279 if (expect_close == 42)
280 outb(0, SBC8360_ENABLE);
281 else
282 printk(KERN_CRIT PFX
283 "SBC8360 device closed unexpectedly. SBC8360 will not stop!\n");
284
285 clear_bit(0, &sbc8360_is_open);
286 expect_close = 0;
287 spin_unlock(&sbc8360_lock);
288 return 0;
289}
290
291/*
292 * Notifier for system down
293 */
294
295static int sbc8360_notify_sys(struct notifier_block *this, unsigned long code,
296 void *unused)
297{
298 if (code == SYS_DOWN || code == SYS_HALT) {
299 /* Disable the SBC8360 Watchdog */
300 outb(0, SBC8360_ENABLE);
301 }
302 return NOTIFY_DONE;
303}
304
305/*
306 * Kernel Interfaces
307 */
308
309static struct file_operations sbc8360_fops = {
310 .owner = THIS_MODULE,
311 .llseek = no_llseek,
312 .write = sbc8360_write,
313 .open = sbc8360_open,
314 .release = sbc8360_close,
315};
316
317static struct miscdevice sbc8360_miscdev = {
318 .minor = WATCHDOG_MINOR,
319 .name = "watchdog",
320 .fops = &sbc8360_fops,
321};
322
323/*
324 * The SBC8360 needs to learn about soft shutdowns in order to
325 * turn the timebomb registers off.
326 */
327
328static struct notifier_block sbc8360_notifier = {
329 .notifier_call = sbc8360_notify_sys,
330};
331
332static int __init sbc8360_init(void)
333{
334 int res;
335 unsigned long int mseconds = 60000;
336
337 spin_lock_init(&sbc8360_lock);
338 res = misc_register(&sbc8360_miscdev);
339 if (res) {
340 printk(KERN_ERR PFX "failed to register misc device\n");
341 goto out_nomisc;
342 }
343
344 if (!request_region(SBC8360_ENABLE, 1, "SBC8360")) {
345 printk(KERN_ERR PFX "ENABLE method I/O %X is not available.\n",
346 SBC8360_ENABLE);
347 res = -EIO;
348 goto out_noenablereg;
349 }
350 if (!request_region(SBC8360_BASETIME, 1, "SBC8360")) {
351 printk(KERN_ERR PFX
352 "BASETIME method I/O %X is not available.\n",
353 SBC8360_BASETIME);
354 res = -EIO;
355 goto out_nobasetimereg;
356 }
357
358 res = register_reboot_notifier(&sbc8360_notifier);
359 if (res) {
360 printk(KERN_ERR PFX "Failed to register reboot notifier.\n");
361 goto out_noreboot;
362 }
363
364 if (timeout < 0 || timeout > 63) {
365 printk(KERN_ERR PFX "Invalid timeout index (must be 0-63).\n");
366 res = -EINVAL;
367 goto out_noreboot;
368 }
369
370 wd_margin = wd_times[timeout][0];
371 wd_multiplier = wd_times[timeout][1];
372
373 if (wd_multiplier == 1)
374 mseconds = (wd_margin + 1) * 500;
375 else if (wd_multiplier == 2)
376 mseconds = (wd_margin + 1) * 5000;
377 else if (wd_multiplier == 3)
378 mseconds = (wd_margin + 1) * 50000;
379 else if (wd_multiplier == 4)
380 mseconds = (wd_margin + 1) * 100000;
381
382 /* My kingdom for the ability to print "0.5 seconds" in the kernel! */
383 printk(KERN_INFO PFX "Timeout set at %ld ms.\n", mseconds);
384
385 return 0;
386
387 out_noreboot:
388 release_region(SBC8360_ENABLE, 1);
389 release_region(SBC8360_BASETIME, 1);
390 out_noenablereg:
391 out_nobasetimereg:
392 misc_deregister(&sbc8360_miscdev);
393 out_nomisc:
394 return res;
395}
396
397static void __exit sbc8360_exit(void)
398{
399 misc_deregister(&sbc8360_miscdev);
400 unregister_reboot_notifier(&sbc8360_notifier);
401 release_region(SBC8360_ENABLE, 1);
402 release_region(SBC8360_BASETIME, 1);
403}
404
405module_init(sbc8360_init);
406module_exit(sbc8360_exit);
407
408MODULE_AUTHOR("Ian E. Morgan <imorgan@webcon.ca>");
409MODULE_DESCRIPTION("SBC8360 watchdog driver");
410MODULE_LICENSE("GPL");
411MODULE_VERSION("1.0");
412MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
413
414/* end of sbc8360.c */
diff --git a/drivers/char/watchdog/w83977f_wdt.c b/drivers/char/watchdog/w83977f_wdt.c
new file mode 100644
index 000000000000..a7ff64c8921f
--- /dev/null
+++ b/drivers/char/watchdog/w83977f_wdt.c
@@ -0,0 +1,543 @@
1/*
2 * W83977F Watchdog Timer Driver for Winbond W83977F I/O Chip
3 *
4 * (c) Copyright 2005 Jose Goncalves <jose.goncalves@inov.pt>
5 *
6 * Based on w83877f_wdt.c by Scott Jennings,
7 * and wdt977.c by Woody Suwalski
8 *
9 * -----------------------
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 *
16 */
17
18#include <linux/module.h>
19#include <linux/moduleparam.h>
20#include <linux/config.h>
21#include <linux/types.h>
22#include <linux/kernel.h>
23#include <linux/fs.h>
24#include <linux/miscdevice.h>
25#include <linux/init.h>
26#include <linux/ioport.h>
27#include <linux/watchdog.h>
28#include <linux/notifier.h>
29#include <linux/reboot.h>
30
31#include <asm/io.h>
32#include <asm/system.h>
33#include <asm/uaccess.h>
34
35#define WATCHDOG_VERSION "1.00"
36#define WATCHDOG_NAME "W83977F WDT"
37#define PFX WATCHDOG_NAME ": "
38#define DRIVER_VERSION WATCHDOG_NAME " driver, v" WATCHDOG_VERSION "\n"
39
40#define IO_INDEX_PORT 0x3F0
41#define IO_DATA_PORT (IO_INDEX_PORT+1)
42
43#define UNLOCK_DATA 0x87
44#define LOCK_DATA 0xAA
45#define DEVICE_REGISTER 0x07
46
47#define DEFAULT_TIMEOUT 45 /* default timeout in seconds */
48
49static int timeout = DEFAULT_TIMEOUT;
50static int timeoutW; /* timeout in watchdog counter units */
51static unsigned long timer_alive;
52static int testmode;
53static char expect_close;
54static spinlock_t spinlock;
55
56module_param(timeout, int, 0);
57MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (15..7635), default=" __MODULE_STRING(DEFAULT_TIMEOUT) ")");
58module_param(testmode, int, 0);
59MODULE_PARM_DESC(testmode,"Watchdog testmode (1 = no reboot), default=0");
60
61static int nowayout = WATCHDOG_NOWAYOUT;
62module_param(nowayout, int, 0);
63MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
64
65/*
66 * Start the watchdog
67 */
68
69static int wdt_start(void)
70{
71 unsigned long flags;
72
73 spin_lock_irqsave(&spinlock, flags);
74
75 /* Unlock the SuperIO chip */
76 outb_p(UNLOCK_DATA,IO_INDEX_PORT);
77 outb_p(UNLOCK_DATA,IO_INDEX_PORT);
78
79 /*
80 * Select device Aux2 (device=8) to set watchdog regs F2, F3 and F4.
81 * F2 has the timeout in watchdog counter units.
82 * F3 is set to enable watchdog LED blink at timeout.
83 * F4 is used to just clear the TIMEOUT'ed state (bit 0).
84 */
85 outb_p(DEVICE_REGISTER,IO_INDEX_PORT);
86 outb_p(0x08,IO_DATA_PORT);
87 outb_p(0xF2,IO_INDEX_PORT);
88 outb_p(timeoutW,IO_DATA_PORT);
89 outb_p(0xF3,IO_INDEX_PORT);
90 outb_p(0x08,IO_DATA_PORT);
91 outb_p(0xF4,IO_INDEX_PORT);
92 outb_p(0x00,IO_DATA_PORT);
93
94 /* Set device Aux2 active */
95 outb_p(0x30,IO_INDEX_PORT);
96 outb_p(0x01,IO_DATA_PORT);
97
98 /*
99 * Select device Aux1 (dev=7) to set GP16 as the watchdog output
100 * (in reg E6) and GP13 as the watchdog LED output (in reg E3).
101 * Map GP16 at pin 119.
102 * In test mode watch the bit 0 on F4 to indicate "triggered" or
103 * check watchdog LED on SBC.
104 */
105 outb_p(DEVICE_REGISTER,IO_INDEX_PORT);
106 outb_p(0x07,IO_DATA_PORT);
107 if (!testmode)
108 {
109 unsigned pin_map;
110
111 outb_p(0xE6,IO_INDEX_PORT);
112 outb_p(0x0A,IO_DATA_PORT);
113 outb_p(0x2C,IO_INDEX_PORT);
114 pin_map = inb_p(IO_DATA_PORT);
115 pin_map |= 0x10;
116 pin_map &= ~(0x20);
117 outb_p(0x2C,IO_INDEX_PORT);
118 outb_p(pin_map,IO_DATA_PORT);
119 }
120 outb_p(0xE3,IO_INDEX_PORT);
121 outb_p(0x08,IO_DATA_PORT);
122
123 /* Set device Aux1 active */
124 outb_p(0x30,IO_INDEX_PORT);
125 outb_p(0x01,IO_DATA_PORT);
126
127 /* Lock the SuperIO chip */
128 outb_p(LOCK_DATA,IO_INDEX_PORT);
129
130 spin_unlock_irqrestore(&spinlock, flags);
131
132 printk(KERN_INFO PFX "activated.\n");
133
134 return 0;
135}
136
137/*
138 * Stop the watchdog
139 */
140
141static int wdt_stop(void)
142{
143 unsigned long flags;
144
145 spin_lock_irqsave(&spinlock, flags);
146
147 /* Unlock the SuperIO chip */
148 outb_p(UNLOCK_DATA,IO_INDEX_PORT);
149 outb_p(UNLOCK_DATA,IO_INDEX_PORT);
150
151 /*
152 * Select device Aux2 (device=8) to set watchdog regs F2, F3 and F4.
153 * F2 is reset to its default value (watchdog timer disabled).
154 * F3 is reset to its default state.
155 * F4 clears the TIMEOUT'ed state (bit 0) - back to default.
156 */
157 outb_p(DEVICE_REGISTER,IO_INDEX_PORT);
158 outb_p(0x08,IO_DATA_PORT);
159 outb_p(0xF2,IO_INDEX_PORT);
160 outb_p(0xFF,IO_DATA_PORT);
161 outb_p(0xF3,IO_INDEX_PORT);
162 outb_p(0x00,IO_DATA_PORT);
163 outb_p(0xF4,IO_INDEX_PORT);
164 outb_p(0x00,IO_DATA_PORT);
165 outb_p(0xF2,IO_INDEX_PORT);
166 outb_p(0x00,IO_DATA_PORT);
167
168 /*
169 * Select device Aux1 (dev=7) to set GP16 (in reg E6) and
170 * Gp13 (in reg E3) as inputs.
171 */
172 outb_p(DEVICE_REGISTER,IO_INDEX_PORT);
173 outb_p(0x07,IO_DATA_PORT);
174 if (!testmode)
175 {
176 outb_p(0xE6,IO_INDEX_PORT);
177 outb_p(0x01,IO_DATA_PORT);
178 }
179 outb_p(0xE3,IO_INDEX_PORT);
180 outb_p(0x01,IO_DATA_PORT);
181
182 /* Lock the SuperIO chip */
183 outb_p(LOCK_DATA,IO_INDEX_PORT);
184
185 spin_unlock_irqrestore(&spinlock, flags);
186
187 printk(KERN_INFO PFX "shutdown.\n");
188
189 return 0;
190}
191
192/*
193 * Send a keepalive ping to the watchdog
194 * This is done by simply re-writing the timeout to reg. 0xF2
195 */
196
197static int wdt_keepalive(void)
198{
199 unsigned long flags;
200
201 spin_lock_irqsave(&spinlock, flags);
202
203 /* Unlock the SuperIO chip */
204 outb_p(UNLOCK_DATA,IO_INDEX_PORT);
205 outb_p(UNLOCK_DATA,IO_INDEX_PORT);
206
207 /* Select device Aux2 (device=8) to kick watchdog reg F2 */
208 outb_p(DEVICE_REGISTER,IO_INDEX_PORT);
209 outb_p(0x08,IO_DATA_PORT);
210 outb_p(0xF2,IO_INDEX_PORT);
211 outb_p(timeoutW,IO_DATA_PORT);
212
213 /* Lock the SuperIO chip */
214 outb_p(LOCK_DATA,IO_INDEX_PORT);
215
216 spin_unlock_irqrestore(&spinlock, flags);
217
218 return 0;
219}
220
221/*
222 * Set the watchdog timeout value
223 */
224
225static int wdt_set_timeout(int t)
226{
227 int tmrval;
228
229 /*
230 * Convert seconds to watchdog counter time units, rounding up.
231 * On PCM-5335 watchdog units are 30 seconds/step with 15 sec startup
232 * value. This information is supplied in the PCM-5335 manual and was
233 * checked by me on a real board. This is a bit strange because W83977f
234 * datasheet says counter unit is in minutes!
235 */
236 if (t < 15)
237 return -EINVAL;
238
239 tmrval = ((t + 15) + 29) / 30;
240
241 if (tmrval > 255)
242 return -EINVAL;
243
244 /*
245 * timeout is the timeout in seconds,
246 * timeoutW is the timeout in watchdog counter units.
247 */
248 timeoutW = tmrval;
249 timeout = (timeoutW * 30) - 15;
250 return 0;
251}
252
253/*
254 * Get the watchdog status
255 */
256
257static int wdt_get_status(int *status)
258{
259 int new_status;
260 unsigned long flags;
261
262 spin_lock_irqsave(&spinlock, flags);
263
264 /* Unlock the SuperIO chip */
265 outb_p(UNLOCK_DATA,IO_INDEX_PORT);
266 outb_p(UNLOCK_DATA,IO_INDEX_PORT);
267
268 /* Select device Aux2 (device=8) to read watchdog reg F4 */
269 outb_p(DEVICE_REGISTER,IO_INDEX_PORT);
270 outb_p(0x08,IO_DATA_PORT);
271 outb_p(0xF4,IO_INDEX_PORT);
272 new_status = inb_p(IO_DATA_PORT);
273
274 /* Lock the SuperIO chip */
275 outb_p(LOCK_DATA,IO_INDEX_PORT);
276
277 spin_unlock_irqrestore(&spinlock, flags);
278
279 *status = 0;
280 if (new_status & 1)
281 *status |= WDIOF_CARDRESET;
282
283 return 0;
284}
285
286
287/*
288 * /dev/watchdog handling
289 */
290
291static int wdt_open(struct inode *inode, struct file *file)
292{
293 /* If the watchdog is alive we don't need to start it again */
294 if( test_and_set_bit(0, &timer_alive) )
295 return -EBUSY;
296
297 if (nowayout)
298 __module_get(THIS_MODULE);
299
300 wdt_start();
301 return nonseekable_open(inode, file);
302}
303
304static int wdt_release(struct inode *inode, struct file *file)
305{
306 /*
307 * Shut off the timer.
308 * Lock it in if it's a module and we set nowayout
309 */
310 if (expect_close == 42)
311 {
312 wdt_stop();
313 clear_bit(0, &timer_alive);
314 } else {
315 wdt_keepalive();
316 printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n");
317 }
318 expect_close = 0;
319 return 0;
320}
321
322/*
323 * wdt_write:
324 * @file: file handle to the watchdog
325 * @buf: buffer to write (unused as data does not matter here
326 * @count: count of bytes
327 * @ppos: pointer to the position to write. No seeks allowed
328 *
329 * A write to a watchdog device is defined as a keepalive signal. Any
330 * write of data will do, as we we don't define content meaning.
331 */
332
333static ssize_t wdt_write(struct file *file, const char __user *buf,
334 size_t count, loff_t *ppos)
335{
336 /* See if we got the magic character 'V' and reload the timer */
337 if(count)
338 {
339 if (!nowayout)
340 {
341 size_t ofs;
342
343 /* note: just in case someone wrote the magic character long ago */
344 expect_close = 0;
345
346 /* scan to see whether or not we got the magic character */
347 for(ofs = 0; ofs != count; ofs++)
348 {
349 char c;
350 if (get_user(c, buf + ofs))
351 return -EFAULT;
352 if (c == 'V') {
353 expect_close = 42;
354 }
355 }
356 }
357
358 /* someone wrote to us, we should restart timer */
359 wdt_keepalive();
360 }
361 return count;
362}
363
364/*
365 * wdt_ioctl:
366 * @inode: inode of the device
367 * @file: file handle to the device
368 * @cmd: watchdog command
369 * @arg: argument pointer
370 *
371 * The watchdog API defines a common set of functions for all watchdogs
372 * according to their available features.
373 */
374
375static struct watchdog_info ident = {
376 .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
377 .firmware_version = 1,
378 .identity = WATCHDOG_NAME,
379};
380
381static int wdt_ioctl(struct inode *inode, struct file *file,
382 unsigned int cmd, unsigned long arg)
383{
384 int status;
385 int new_options, retval = -EINVAL;
386 int new_timeout;
387 union {
388 struct watchdog_info __user *ident;
389 int __user *i;
390 } uarg;
391
392 uarg.i = (int __user *)arg;
393
394 switch(cmd)
395 {
396 default:
397 return -ENOIOCTLCMD;
398
399 case WDIOC_GETSUPPORT:
400 return copy_to_user(uarg.ident, &ident, sizeof(ident)) ? -EFAULT : 0;
401
402 case WDIOC_GETSTATUS:
403 wdt_get_status(&status);
404 return put_user(status, uarg.i);
405
406 case WDIOC_GETBOOTSTATUS:
407 return put_user(0, uarg.i);
408
409 case WDIOC_KEEPALIVE:
410 wdt_keepalive();
411 return 0;
412
413 case WDIOC_SETOPTIONS:
414 if (get_user (new_options, uarg.i))
415 return -EFAULT;
416
417 if (new_options & WDIOS_DISABLECARD) {
418 wdt_stop();
419 retval = 0;
420 }
421
422 if (new_options & WDIOS_ENABLECARD) {
423 wdt_start();
424 retval = 0;
425 }
426
427 return retval;
428
429 case WDIOC_SETTIMEOUT:
430 if (get_user(new_timeout, uarg.i))
431 return -EFAULT;
432
433 if (wdt_set_timeout(new_timeout))
434 return -EINVAL;
435
436 wdt_keepalive();
437 /* Fall */
438
439 case WDIOC_GETTIMEOUT:
440 return put_user(timeout, uarg.i);
441
442 }
443}
444
445static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
446 void *unused)
447{
448 if (code==SYS_DOWN || code==SYS_HALT)
449 wdt_stop();
450 return NOTIFY_DONE;
451}
452
453static struct file_operations wdt_fops=
454{
455 .owner = THIS_MODULE,
456 .llseek = no_llseek,
457 .write = wdt_write,
458 .ioctl = wdt_ioctl,
459 .open = wdt_open,
460 .release = wdt_release,
461};
462
463static struct miscdevice wdt_miscdev=
464{
465 .minor = WATCHDOG_MINOR,
466 .name = "watchdog",
467 .fops = &wdt_fops,
468};
469
470static struct notifier_block wdt_notifier = {
471 .notifier_call = wdt_notify_sys,
472};
473
474static int __init w83977f_wdt_init(void)
475{
476 int rc;
477
478 printk(KERN_INFO PFX DRIVER_VERSION);
479
480 spin_lock_init(&spinlock);
481
482 /*
483 * Check that the timeout value is within it's range ;
484 * if not reset to the default
485 */
486 if (wdt_set_timeout(timeout)) {
487 wdt_set_timeout(DEFAULT_TIMEOUT);
488 printk(KERN_INFO PFX "timeout value must be 15<=timeout<=7635, using %d\n",
489 DEFAULT_TIMEOUT);
490 }
491
492 if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME))
493 {
494 printk(KERN_ERR PFX "I/O address 0x%04x already in use\n",
495 IO_INDEX_PORT);
496 rc = -EIO;
497 goto err_out;
498 }
499
500 rc = misc_register(&wdt_miscdev);
501 if (rc)
502 {
503 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
504 wdt_miscdev.minor, rc);
505 goto err_out_region;
506 }
507
508 rc = register_reboot_notifier(&wdt_notifier);
509 if (rc)
510 {
511 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
512 rc);
513 goto err_out_miscdev;
514 }
515
516 printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n",
517 timeout, nowayout, testmode);
518
519 return 0;
520
521err_out_miscdev:
522 misc_deregister(&wdt_miscdev);
523err_out_region:
524 release_region(IO_INDEX_PORT,2);
525err_out:
526 return rc;
527}
528
529static void __exit w83977f_wdt_exit(void)
530{
531 wdt_stop();
532 misc_deregister(&wdt_miscdev);
533 unregister_reboot_notifier(&wdt_notifier);
534 release_region(IO_INDEX_PORT,2);
535}
536
537module_init(w83977f_wdt_init);
538module_exit(w83977f_wdt_exit);
539
540MODULE_AUTHOR("Jose Goncalves <jose.goncalves@inov.pt>");
541MODULE_DESCRIPTION("Driver for watchdog timer in W83977F I/O chip");
542MODULE_LICENSE("GPL");
543MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/connector/Kconfig b/drivers/connector/Kconfig
new file mode 100644
index 000000000000..0bc2059c1e08
--- /dev/null
+++ b/drivers/connector/Kconfig
@@ -0,0 +1,13 @@
1menu "Connector - unified userspace <-> kernelspace linker"
2
3config CONNECTOR
4 tristate "Connector - unified userspace <-> kernelspace linker"
5 depends on NET
6 ---help---
7 This is unified userspace <-> kernelspace connector working on top
8 of the netlink socket protocol.
9
10 Connector support can also be built as a module. If so, the module
11 will be called cn.ko.
12
13endmenu
diff --git a/drivers/connector/Makefile b/drivers/connector/Makefile
new file mode 100644
index 000000000000..12ca79e8234d
--- /dev/null
+++ b/drivers/connector/Makefile
@@ -0,0 +1,3 @@
1obj-$(CONFIG_CONNECTOR) += cn.o
2
3cn-y += cn_queue.o connector.o
diff --git a/drivers/connector/cn_queue.c b/drivers/connector/cn_queue.c
new file mode 100644
index 000000000000..966632182e2d
--- /dev/null
+++ b/drivers/connector/cn_queue.c
@@ -0,0 +1,173 @@
1/*
2 * cn_queue.c
3 *
4 * 2004-2005 Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/list.h>
26#include <linux/workqueue.h>
27#include <linux/spinlock.h>
28#include <linux/slab.h>
29#include <linux/skbuff.h>
30#include <linux/suspend.h>
31#include <linux/connector.h>
32#include <linux/delay.h>
33
34static void cn_queue_wrapper(void *data)
35{
36 struct cn_callback_entry *cbq = data;
37
38 cbq->cb->callback(cbq->cb->priv);
39 cbq->destruct_data(cbq->ddata);
40 cbq->ddata = NULL;
41}
42
43static struct cn_callback_entry *cn_queue_alloc_callback_entry(struct cn_callback *cb)
44{
45 struct cn_callback_entry *cbq;
46
47 cbq = kzalloc(sizeof(*cbq), GFP_KERNEL);
48 if (!cbq) {
49 printk(KERN_ERR "Failed to create new callback queue.\n");
50 return NULL;
51 }
52
53 cbq->cb = cb;
54 INIT_WORK(&cbq->work, &cn_queue_wrapper, cbq);
55 return cbq;
56}
57
58static void cn_queue_free_callback(struct cn_callback_entry *cbq)
59{
60 cancel_delayed_work(&cbq->work);
61 flush_workqueue(cbq->pdev->cn_queue);
62
63 kfree(cbq);
64}
65
66int cn_cb_equal(struct cb_id *i1, struct cb_id *i2)
67{
68 return ((i1->idx == i2->idx) && (i1->val == i2->val));
69}
70
71int cn_queue_add_callback(struct cn_queue_dev *dev, struct cn_callback *cb)
72{
73 struct cn_callback_entry *cbq, *__cbq;
74 int found = 0;
75
76 cbq = cn_queue_alloc_callback_entry(cb);
77 if (!cbq)
78 return -ENOMEM;
79
80 atomic_inc(&dev->refcnt);
81 cbq->pdev = dev;
82
83 spin_lock_bh(&dev->queue_lock);
84 list_for_each_entry(__cbq, &dev->queue_list, callback_entry) {
85 if (cn_cb_equal(&__cbq->cb->id, &cb->id)) {
86 found = 1;
87 break;
88 }
89 }
90 if (!found)
91 list_add_tail(&cbq->callback_entry, &dev->queue_list);
92 spin_unlock_bh(&dev->queue_lock);
93
94 if (found) {
95 atomic_dec(&dev->refcnt);
96 cn_queue_free_callback(cbq);
97 return -EINVAL;
98 }
99
100 cbq->nls = dev->nls;
101 cbq->seq = 0;
102 cbq->group = cbq->cb->id.idx;
103
104 return 0;
105}
106
107void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id)
108{
109 struct cn_callback_entry *cbq, *n;
110 int found = 0;
111
112 spin_lock_bh(&dev->queue_lock);
113 list_for_each_entry_safe(cbq, n, &dev->queue_list, callback_entry) {
114 if (cn_cb_equal(&cbq->cb->id, id)) {
115 list_del(&cbq->callback_entry);
116 found = 1;
117 break;
118 }
119 }
120 spin_unlock_bh(&dev->queue_lock);
121
122 if (found) {
123 cn_queue_free_callback(cbq);
124 atomic_dec_and_test(&dev->refcnt);
125 }
126}
127
128struct cn_queue_dev *cn_queue_alloc_dev(char *name, struct sock *nls)
129{
130 struct cn_queue_dev *dev;
131
132 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
133 if (!dev)
134 return NULL;
135
136 snprintf(dev->name, sizeof(dev->name), "%s", name);
137 atomic_set(&dev->refcnt, 0);
138 INIT_LIST_HEAD(&dev->queue_list);
139 spin_lock_init(&dev->queue_lock);
140
141 dev->nls = nls;
142 dev->netlink_groups = 0;
143
144 dev->cn_queue = create_workqueue(dev->name);
145 if (!dev->cn_queue) {
146 kfree(dev);
147 return NULL;
148 }
149
150 return dev;
151}
152
153void cn_queue_free_dev(struct cn_queue_dev *dev)
154{
155 struct cn_callback_entry *cbq, *n;
156
157 flush_workqueue(dev->cn_queue);
158 destroy_workqueue(dev->cn_queue);
159
160 spin_lock_bh(&dev->queue_lock);
161 list_for_each_entry_safe(cbq, n, &dev->queue_list, callback_entry)
162 list_del(&cbq->callback_entry);
163 spin_unlock_bh(&dev->queue_lock);
164
165 while (atomic_read(&dev->refcnt)) {
166 printk(KERN_INFO "Waiting for %s to become free: refcnt=%d.\n",
167 dev->name, atomic_read(&dev->refcnt));
168 msleep(1000);
169 }
170
171 kfree(dev);
172 dev = NULL;
173}
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
new file mode 100644
index 000000000000..aaf6d468a8b9
--- /dev/null
+++ b/drivers/connector/connector.c
@@ -0,0 +1,486 @@
1/*
2 * connector.c
3 *
4 * 2004-2005 Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/list.h>
25#include <linux/skbuff.h>
26#include <linux/netlink.h>
27#include <linux/moduleparam.h>
28#include <linux/connector.h>
29
30#include <net/sock.h>
31
32MODULE_LICENSE("GPL");
33MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
34MODULE_DESCRIPTION("Generic userspace <-> kernelspace connector.");
35
36static u32 cn_idx = CN_IDX_CONNECTOR;
37static u32 cn_val = CN_VAL_CONNECTOR;
38
39module_param(cn_idx, uint, 0);
40module_param(cn_val, uint, 0);
41MODULE_PARM_DESC(cn_idx, "Connector's main device idx.");
42MODULE_PARM_DESC(cn_val, "Connector's main device val.");
43
44static DECLARE_MUTEX(notify_lock);
45static LIST_HEAD(notify_list);
46
47static struct cn_dev cdev;
48
49int cn_already_initialized = 0;
50
51/*
52 * msg->seq and msg->ack are used to determine message genealogy.
53 * When someone sends message it puts there locally unique sequence
54 * and random acknowledge numbers. Sequence number may be copied into
55 * nlmsghdr->nlmsg_seq too.
56 *
57 * Sequence number is incremented with each message to be sent.
58 *
59 * If we expect reply to our message then the sequence number in
60 * received message MUST be the same as in original message, and
61 * acknowledge number MUST be the same + 1.
62 *
63 * If we receive a message and its sequence number is not equal to the
64 * one we are expecting then it is a new message.
65 *
66 * If we receive a message and its sequence number is the same as one
67 * we are expecting but it's acknowledgement number is not equal to
68 * the acknowledgement number in the original message + 1, then it is
69 * a new message.
70 *
71 */
72int cn_netlink_send(struct cn_msg *msg, u32 __group, int gfp_mask)
73{
74 struct cn_callback_entry *__cbq;
75 unsigned int size;
76 struct sk_buff *skb;
77 struct nlmsghdr *nlh;
78 struct cn_msg *data;
79 struct cn_dev *dev = &cdev;
80 u32 group = 0;
81 int found = 0;
82
83 if (!__group) {
84 spin_lock_bh(&dev->cbdev->queue_lock);
85 list_for_each_entry(__cbq, &dev->cbdev->queue_list,
86 callback_entry) {
87 if (cn_cb_equal(&__cbq->cb->id, &msg->id)) {
88 found = 1;
89 group = __cbq->group;
90 }
91 }
92 spin_unlock_bh(&dev->cbdev->queue_lock);
93
94 if (!found)
95 return -ENODEV;
96 } else {
97 group = __group;
98 }
99
100 size = NLMSG_SPACE(sizeof(*msg) + msg->len);
101
102 skb = alloc_skb(size, gfp_mask);
103 if (!skb)
104 return -ENOMEM;
105
106 nlh = NLMSG_PUT(skb, 0, msg->seq, NLMSG_DONE, size - sizeof(*nlh));
107
108 data = NLMSG_DATA(nlh);
109
110 memcpy(data, msg, sizeof(*data) + msg->len);
111
112 NETLINK_CB(skb).dst_group = group;
113
114 netlink_broadcast(dev->nls, skb, 0, group, gfp_mask);
115
116 return 0;
117
118nlmsg_failure:
119 kfree_skb(skb);
120 return -EINVAL;
121}
122
123/*
124 * Callback helper - queues work and setup destructor for given data.
125 */
126static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), void *data)
127{
128 struct cn_callback_entry *__cbq;
129 struct cn_dev *dev = &cdev;
130 int found = 0;
131
132 spin_lock_bh(&dev->cbdev->queue_lock);
133 list_for_each_entry(__cbq, &dev->cbdev->queue_list, callback_entry) {
134 if (cn_cb_equal(&__cbq->cb->id, &msg->id)) {
135 /*
136 * Let's scream if there is some magic and the
137 * data will arrive asynchronously here.
138 * [i.e. netlink messages will be queued].
139 * After the first warning I will fix it
140 * quickly, but now I think it is
141 * impossible. --zbr (2004_04_27).
142 */
143 if (likely(!test_bit(0, &__cbq->work.pending) &&
144 __cbq->ddata == NULL)) {
145 __cbq->cb->priv = msg;
146
147 __cbq->ddata = data;
148 __cbq->destruct_data = destruct_data;
149
150 if (queue_work(dev->cbdev->cn_queue,
151 &__cbq->work))
152 found = 1;
153 } else {
154 printk("%s: cbq->data=%p, "
155 "work->pending=%08lx.\n",
156 __func__, __cbq->ddata,
157 __cbq->work.pending);
158 WARN_ON(1);
159 }
160 break;
161 }
162 }
163 spin_unlock_bh(&dev->cbdev->queue_lock);
164
165 return found ? 0 : -ENODEV;
166}
167
168/*
169 * Skb receive helper - checks skb and msg size and calls callback
170 * helper.
171 */
172static int __cn_rx_skb(struct sk_buff *skb, struct nlmsghdr *nlh)
173{
174 u32 pid, uid, seq, group;
175 struct cn_msg *msg;
176
177 pid = NETLINK_CREDS(skb)->pid;
178 uid = NETLINK_CREDS(skb)->uid;
179 seq = nlh->nlmsg_seq;
180 group = NETLINK_CB((skb)).dst_group;
181 msg = NLMSG_DATA(nlh);
182
183 return cn_call_callback(msg, (void (*)(void *))kfree_skb, skb);
184}
185
186/*
187 * Main netlink receiving function.
188 *
189 * It checks skb and netlink header sizes and calls the skb receive
190 * helper with a shared skb.
191 */
192static void cn_rx_skb(struct sk_buff *__skb)
193{
194 struct nlmsghdr *nlh;
195 u32 len;
196 int err;
197 struct sk_buff *skb;
198
199 skb = skb_get(__skb);
200
201 if (skb->len >= NLMSG_SPACE(0)) {
202 nlh = (struct nlmsghdr *)skb->data;
203
204 if (nlh->nlmsg_len < sizeof(struct cn_msg) ||
205 skb->len < nlh->nlmsg_len ||
206 nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) {
207 kfree_skb(skb);
208 goto out;
209 }
210
211 len = NLMSG_ALIGN(nlh->nlmsg_len);
212 if (len > skb->len)
213 len = skb->len;
214
215 err = __cn_rx_skb(skb, nlh);
216 if (err < 0)
217 kfree_skb(skb);
218 }
219
220out:
221 kfree_skb(__skb);
222}
223
224/*
225 * Netlink socket input callback - dequeues the skbs and calls the
226 * main netlink receiving function.
227 */
228static void cn_input(struct sock *sk, int len)
229{
230 struct sk_buff *skb;
231
232 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL)
233 cn_rx_skb(skb);
234}
235
236/*
237 * Notification routing.
238 *
239 * Gets id and checks if there are notification request for it's idx
240 * and val. If there are such requests notify the listeners with the
241 * given notify event.
242 *
243 */
244static void cn_notify(struct cb_id *id, u32 notify_event)
245{
246 struct cn_ctl_entry *ent;
247
248 down(&notify_lock);
249 list_for_each_entry(ent, &notify_list, notify_entry) {
250 int i;
251 struct cn_notify_req *req;
252 struct cn_ctl_msg *ctl = ent->msg;
253 int idx_found, val_found;
254
255 idx_found = val_found = 0;
256
257 req = (struct cn_notify_req *)ctl->data;
258 for (i = 0; i < ctl->idx_notify_num; ++i, ++req) {
259 if (id->idx >= req->first &&
260 id->idx < req->first + req->range) {
261 idx_found = 1;
262 break;
263 }
264 }
265
266 for (i = 0; i < ctl->val_notify_num; ++i, ++req) {
267 if (id->val >= req->first &&
268 id->val < req->first + req->range) {
269 val_found = 1;
270 break;
271 }
272 }
273
274 if (idx_found && val_found) {
275 struct cn_msg m = { .ack = notify_event, };
276
277 memcpy(&m.id, id, sizeof(m.id));
278 cn_netlink_send(&m, ctl->group, GFP_KERNEL);
279 }
280 }
281 up(&notify_lock);
282}
283
284/*
285 * Callback add routing - adds callback with given ID and name.
286 * If there is registered callback with the same ID it will not be added.
287 *
288 * May sleep.
289 */
290int cn_add_callback(struct cb_id *id, char *name, void (*callback)(void *))
291{
292 int err;
293 struct cn_dev *dev = &cdev;
294 struct cn_callback *cb;
295
296 cb = kzalloc(sizeof(*cb), GFP_KERNEL);
297 if (!cb)
298 return -ENOMEM;
299
300 scnprintf(cb->name, sizeof(cb->name), "%s", name);
301
302 memcpy(&cb->id, id, sizeof(cb->id));
303 cb->callback = callback;
304
305 err = cn_queue_add_callback(dev->cbdev, cb);
306 if (err) {
307 kfree(cb);
308 return err;
309 }
310
311 cn_notify(id, 0);
312
313 return 0;
314}
315
316/*
317 * Callback remove routing - removes callback
318 * with given ID.
319 * If there is no registered callback with given
320 * ID nothing happens.
321 *
322 * May sleep while waiting for reference counter to become zero.
323 */
324void cn_del_callback(struct cb_id *id)
325{
326 struct cn_dev *dev = &cdev;
327
328 cn_queue_del_callback(dev->cbdev, id);
329 cn_notify(id, 1);
330}
331
332/*
333 * Checks two connector's control messages to be the same.
334 * Returns 1 if they are the same or if the first one is corrupted.
335 */
336static int cn_ctl_msg_equals(struct cn_ctl_msg *m1, struct cn_ctl_msg *m2)
337{
338 int i;
339 struct cn_notify_req *req1, *req2;
340
341 if (m1->idx_notify_num != m2->idx_notify_num)
342 return 0;
343
344 if (m1->val_notify_num != m2->val_notify_num)
345 return 0;
346
347 if (m1->len != m2->len)
348 return 0;
349
350 if ((m1->idx_notify_num + m1->val_notify_num) * sizeof(*req1) !=
351 m1->len)
352 return 1;
353
354 req1 = (struct cn_notify_req *)m1->data;
355 req2 = (struct cn_notify_req *)m2->data;
356
357 for (i = 0; i < m1->idx_notify_num; ++i) {
358 if (req1->first != req2->first || req1->range != req2->range)
359 return 0;
360 req1++;
361 req2++;
362 }
363
364 for (i = 0; i < m1->val_notify_num; ++i) {
365 if (req1->first != req2->first || req1->range != req2->range)
366 return 0;
367 req1++;
368 req2++;
369 }
370
371 return 1;
372}
373
374/*
375 * Main connector device's callback.
376 *
377 * Used for notification of a request's processing.
378 */
379static void cn_callback(void *data)
380{
381 struct cn_msg *msg = data;
382 struct cn_ctl_msg *ctl;
383 struct cn_ctl_entry *ent;
384 u32 size;
385
386 if (msg->len < sizeof(*ctl))
387 return;
388
389 ctl = (struct cn_ctl_msg *)msg->data;
390
391 size = (sizeof(*ctl) + ((ctl->idx_notify_num +
392 ctl->val_notify_num) *
393 sizeof(struct cn_notify_req)));
394
395 if (msg->len != size)
396 return;
397
398 if (ctl->len + sizeof(*ctl) != msg->len)
399 return;
400
401 /*
402 * Remove notification.
403 */
404 if (ctl->group == 0) {
405 struct cn_ctl_entry *n;
406
407 down(&notify_lock);
408 list_for_each_entry_safe(ent, n, &notify_list, notify_entry) {
409 if (cn_ctl_msg_equals(ent->msg, ctl)) {
410 list_del(&ent->notify_entry);
411 kfree(ent);
412 }
413 }
414 up(&notify_lock);
415
416 return;
417 }
418
419 size += sizeof(*ent);
420
421 ent = kzalloc(size, GFP_KERNEL);
422 if (!ent)
423 return;
424
425 ent->msg = (struct cn_ctl_msg *)(ent + 1);
426
427 memcpy(ent->msg, ctl, size - sizeof(*ent));
428
429 down(&notify_lock);
430 list_add(&ent->notify_entry, &notify_list);
431 up(&notify_lock);
432}
433
434static int __init cn_init(void)
435{
436 struct cn_dev *dev = &cdev;
437 int err;
438
439 dev->input = cn_input;
440 dev->id.idx = cn_idx;
441 dev->id.val = cn_val;
442
443 dev->nls = netlink_kernel_create(NETLINK_CONNECTOR,
444 CN_NETLINK_USERS + 0xf,
445 dev->input, THIS_MODULE);
446 if (!dev->nls)
447 return -EIO;
448
449 dev->cbdev = cn_queue_alloc_dev("cqueue", dev->nls);
450 if (!dev->cbdev) {
451 if (dev->nls->sk_socket)
452 sock_release(dev->nls->sk_socket);
453 return -EINVAL;
454 }
455
456 err = cn_add_callback(&dev->id, "connector", &cn_callback);
457 if (err) {
458 cn_queue_free_dev(dev->cbdev);
459 if (dev->nls->sk_socket)
460 sock_release(dev->nls->sk_socket);
461 return -EINVAL;
462 }
463
464 cn_already_initialized = 1;
465
466 return 0;
467}
468
469static void __exit cn_fini(void)
470{
471 struct cn_dev *dev = &cdev;
472
473 cn_already_initialized = 0;
474
475 cn_del_callback(&dev->id);
476 cn_queue_free_dev(dev->cbdev);
477 if (dev->nls->sk_socket)
478 sock_release(dev->nls->sk_socket);
479}
480
481module_init(cn_init);
482module_exit(cn_fini);
483
484EXPORT_SYMBOL_GPL(cn_add_callback);
485EXPORT_SYMBOL_GPL(cn_del_callback);
486EXPORT_SYMBOL_GPL(cn_netlink_send);
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c
index 37b49c2daf5f..eff5896ce865 100644
--- a/drivers/i2c/busses/i2c-keywest.c
+++ b/drivers/i2c/busses/i2c-keywest.c
@@ -611,7 +611,6 @@ create_iface(struct device_node *np, struct device *dev)
611 611
612 for (i=0; i<nchan; i++) { 612 for (i=0; i<nchan; i++) {
613 struct keywest_chan* chan = &iface->channels[i]; 613 struct keywest_chan* chan = &iface->channels[i];
614 u8 addr;
615 614
616 sprintf(chan->adapter.name, "%s %d", np->parent->name, i); 615 sprintf(chan->adapter.name, "%s %d", np->parent->name, i);
617 chan->iface = iface; 616 chan->iface = iface;
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index b443b04a4c5a..0b0aa4f51628 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -601,44 +601,15 @@ EXPORT_SYMBOL(ide_wait_stat);
601 */ 601 */
602u8 eighty_ninty_three (ide_drive_t *drive) 602u8 eighty_ninty_three (ide_drive_t *drive)
603{ 603{
604#if 0 604 if(HWIF(drive)->udma_four == 0)
605 if (!HWIF(drive)->udma_four) 605 return 0;
606 if (!(drive->id->hw_config & 0x6000))
606 return 0; 607 return 0;
607
608 if (drive->id->major_rev_num) {
609 int hssbd = 0;
610 int i;
611 /*
612 * Determine highest Supported SPEC
613 */
614 for (i=1; i<=15; i++)
615 if (drive->id->major_rev_num & (1<<i))
616 hssbd++;
617
618 switch (hssbd) {
619 case 7:
620 case 6:
621 case 5:
622 /* ATA-4 and older do not support above Ultra 33 */
623 default:
624 return 0;
625 }
626 }
627
628 return ((u8) (
629#ifndef CONFIG_IDEDMA_IVB
630 (drive->id->hw_config & 0x4000) &&
631#endif /* CONFIG_IDEDMA_IVB */
632 (drive->id->hw_config & 0x6000)) ? 1 : 0);
633
634#else
635
636 return ((u8) ((HWIF(drive)->udma_four) &&
637#ifndef CONFIG_IDEDMA_IVB 608#ifndef CONFIG_IDEDMA_IVB
638 (drive->id->hw_config & 0x4000) && 609 if(!(drive->id->hw_config & 0x4000))
610 return 0;
639#endif /* CONFIG_IDEDMA_IVB */ 611#endif /* CONFIG_IDEDMA_IVB */
640 (drive->id->hw_config & 0x6000)) ? 1 : 0); 612 return 1;
641#endif
642} 613}
643 614
644EXPORT_SYMBOL(eighty_ninty_three); 615EXPORT_SYMBOL(eighty_ninty_three);
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 3de9ab897e42..3d9c7afc8695 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -608,7 +608,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha
608 608
609#ifdef __i386__ 609#ifdef __i386__
610 if (dev->resource[PCI_ROM_RESOURCE].start) { 610 if (dev->resource[PCI_ROM_RESOURCE].start) {
611 pci_write_config_byte(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); 611 pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
612 printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start); 612 printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start);
613 } 613 }
614#endif 614#endif
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
index bbde46279984..be334da7a754 100644
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -173,7 +173,7 @@ static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev, const cha
173 173
174 if (cmd & PCI_COMMAND_MEMORY) { 174 if (cmd & PCI_COMMAND_MEMORY) {
175 if (pci_resource_start(dev, PCI_ROM_RESOURCE)) { 175 if (pci_resource_start(dev, PCI_ROM_RESOURCE)) {
176 pci_write_config_byte(dev, PCI_ROM_ADDRESS, 176 pci_write_config_dword(dev, PCI_ROM_ADDRESS,
177 dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); 177 dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
178 printk(KERN_INFO "HPT345: ROM enabled at 0x%08lx\n", 178 printk(KERN_INFO "HPT345: ROM enabled at 0x%08lx\n",
179 dev->resource[PCI_ROM_RESOURCE].start); 179 dev->resource[PCI_ROM_RESOURCE].start);
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 627af507643a..de88218ef7cc 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -790,7 +790,7 @@ static void sbp2_host_reset(struct hpsb_host *host)
790static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) 790static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
791{ 791{
792 struct sbp2scsi_host_info *hi = scsi_id->hi; 792 struct sbp2scsi_host_info *hi = scsi_id->hi;
793 struct scsi_device *sdev; 793 int error;
794 794
795 SBP2_DEBUG("sbp2_start_device"); 795 SBP2_DEBUG("sbp2_start_device");
796 796
@@ -939,10 +939,10 @@ alloc_fail:
939 sbp2_max_speed_and_size(scsi_id); 939 sbp2_max_speed_and_size(scsi_id);
940 940
941 /* Add this device to the scsi layer now */ 941 /* Add this device to the scsi layer now */
942 sdev = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0); 942 error = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0);
943 if (IS_ERR(sdev)) { 943 if (error) {
944 SBP2_ERR("scsi_add_device failed"); 944 SBP2_ERR("scsi_add_device failed");
945 return PTR_ERR(sdev); 945 return error;
946 } 946 }
947 947
948 return 0; 948 return 0;
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index e55dee390775..444f7756fee6 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -132,6 +132,17 @@ config KEYBOARD_CORGI
132 To compile this driver as a module, choose M here: the 132 To compile this driver as a module, choose M here: the
133 module will be called corgikbd. 133 module will be called corgikbd.
134 134
135config KEYBOARD_SPITZ
136 tristate "Spitz keyboard"
137 depends on PXA_SHARPSL
138 default y
139 help
140 Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000,
141 SL-C3000 and Sl-C3100 series of PDAs.
142
143 To compile this driver as a module, choose M here: the
144 module will be called spitzkbd.
145
135config KEYBOARD_MAPLE 146config KEYBOARD_MAPLE
136 tristate "Maple bus keyboard" 147 tristate "Maple bus keyboard"
137 depends on SH_DREAMCAST && MAPLE 148 depends on SH_DREAMCAST && MAPLE
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index b02eeceea3c3..9ce0b87f2fac 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o
14obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o 14obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o
15obj-$(CONFIG_KEYBOARD_98KBD) += 98kbd.o 15obj-$(CONFIG_KEYBOARD_98KBD) += 98kbd.o
16obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o 16obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
17obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
17obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 18obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
18obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o 19obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
19 20
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
new file mode 100644
index 000000000000..1714045a182b
--- /dev/null
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -0,0 +1,478 @@
1/*
2 * Keyboard driver for Sharp Spitz, Borzoi and Akita (SL-Cxx00 series)
3 *
4 * Copyright (c) 2005 Richard Purdie
5 *
6 * Based on corgikbd.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14#include <linux/delay.h>
15#include <linux/device.h>
16#include <linux/init.h>
17#include <linux/input.h>
18#include <linux/interrupt.h>
19#include <linux/jiffies.h>
20#include <linux/module.h>
21#include <linux/slab.h>
22#include <asm/irq.h>
23
24#include <asm/arch/spitz.h>
25#include <asm/arch/hardware.h>
26#include <asm/arch/pxa-regs.h>
27
28#define KB_ROWS 7
29#define KB_COLS 11
30#define KB_ROWMASK(r) (1 << (r))
31#define SCANCODE(r,c) (((r)<<4) + (c) + 1)
32#define NR_SCANCODES ((KB_ROWS<<4) + 1)
33
34#define HINGE_SCAN_INTERVAL (150) /* ms */
35
36#define SPITZ_KEY_CALENDER KEY_F1
37#define SPITZ_KEY_ADDRESS KEY_F2
38#define SPITZ_KEY_FN KEY_F3
39#define SPITZ_KEY_CANCEL KEY_F4
40#define SPITZ_KEY_EXOK KEY_F5
41#define SPITZ_KEY_EXCANCEL KEY_F6
42#define SPITZ_KEY_EXJOGDOWN KEY_F7
43#define SPITZ_KEY_EXJOGUP KEY_F8
44#define SPITZ_KEY_JAP1 KEY_LEFTALT
45#define SPITZ_KEY_JAP2 KEY_RIGHTCTRL
46#define SPITZ_KEY_SYNC KEY_F9
47#define SPITZ_KEY_MAIL KEY_F10
48#define SPITZ_KEY_OK KEY_F11
49#define SPITZ_KEY_MENU KEY_F12
50
51static unsigned char spitzkbd_keycode[NR_SCANCODES] = {
52 0, /* 0 */
53 KEY_LEFTCTRL, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, SPITZ_KEY_EXOK, SPITZ_KEY_EXCANCEL, 0, 0, 0, 0, 0, /* 1-16 */
54 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, SPITZ_KEY_EXJOGDOWN, SPITZ_KEY_EXJOGUP, 0, 0, 0, 0, 0, /* 17-32 */
55 KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */
56 SPITZ_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, /* 49-64 */
57 SPITZ_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, /* 65-80 */
58 SPITZ_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, SPITZ_KEY_FN, 0, 0, 0, 0, 0, /* 81-96 */
59 KEY_SYSRQ, SPITZ_KEY_JAP1, SPITZ_KEY_JAP2, SPITZ_KEY_CANCEL, SPITZ_KEY_OK, SPITZ_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0 /* 97-112 */
60};
61
62static int spitz_strobes[] = {
63 SPITZ_GPIO_KEY_STROBE0,
64 SPITZ_GPIO_KEY_STROBE1,
65 SPITZ_GPIO_KEY_STROBE2,
66 SPITZ_GPIO_KEY_STROBE3,
67 SPITZ_GPIO_KEY_STROBE4,
68 SPITZ_GPIO_KEY_STROBE5,
69 SPITZ_GPIO_KEY_STROBE6,
70 SPITZ_GPIO_KEY_STROBE7,
71 SPITZ_GPIO_KEY_STROBE8,
72 SPITZ_GPIO_KEY_STROBE9,
73 SPITZ_GPIO_KEY_STROBE10,
74};
75
76static int spitz_senses[] = {
77 SPITZ_GPIO_KEY_SENSE0,
78 SPITZ_GPIO_KEY_SENSE1,
79 SPITZ_GPIO_KEY_SENSE2,
80 SPITZ_GPIO_KEY_SENSE3,
81 SPITZ_GPIO_KEY_SENSE4,
82 SPITZ_GPIO_KEY_SENSE5,
83 SPITZ_GPIO_KEY_SENSE6,
84};
85
86struct spitzkbd {
87 unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)];
88 struct input_dev input;
89 char phys[32];
90
91 spinlock_t lock;
92 struct timer_list timer;
93 struct timer_list htimer;
94
95 unsigned int suspended;
96 unsigned long suspend_jiffies;
97};
98
99#define KB_DISCHARGE_DELAY 10
100#define KB_ACTIVATE_DELAY 10
101
102/* Helper functions for reading the keyboard matrix
103 * Note: We should really be using pxa_gpio_mode to alter GPDR but it
104 * requires a function call per GPIO bit which is excessive
105 * when we need to access 11 bits at once, multiple times.
106 * These functions must be called within local_irq_save()/local_irq_restore()
107 * or similar.
108 */
109static inline void spitzkbd_discharge_all(void)
110{
111 /* STROBE All HiZ */
112 GPCR0 = SPITZ_GPIO_G0_STROBE_BIT;
113 GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
114 GPCR1 = SPITZ_GPIO_G1_STROBE_BIT;
115 GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
116 GPCR2 = SPITZ_GPIO_G2_STROBE_BIT;
117 GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
118 GPCR3 = SPITZ_GPIO_G3_STROBE_BIT;
119 GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
120}
121
122static inline void spitzkbd_activate_all(void)
123{
124 /* STROBE ALL -> High */
125 GPSR0 = SPITZ_GPIO_G0_STROBE_BIT;
126 GPDR0 |= SPITZ_GPIO_G0_STROBE_BIT;
127 GPSR1 = SPITZ_GPIO_G1_STROBE_BIT;
128 GPDR1 |= SPITZ_GPIO_G1_STROBE_BIT;
129 GPSR2 = SPITZ_GPIO_G2_STROBE_BIT;
130 GPDR2 |= SPITZ_GPIO_G2_STROBE_BIT;
131 GPSR3 = SPITZ_GPIO_G3_STROBE_BIT;
132 GPDR3 |= SPITZ_GPIO_G3_STROBE_BIT;
133
134 udelay(KB_DISCHARGE_DELAY);
135
136 /* Clear any interrupts we may have triggered when altering the GPIO lines */
137 GEDR0 = SPITZ_GPIO_G0_SENSE_BIT;
138 GEDR1 = SPITZ_GPIO_G1_SENSE_BIT;
139 GEDR2 = SPITZ_GPIO_G2_SENSE_BIT;
140 GEDR3 = SPITZ_GPIO_G3_SENSE_BIT;
141}
142
143static inline void spitzkbd_activate_col(int col)
144{
145 int gpio = spitz_strobes[col];
146 GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
147 GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
148 GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
149 GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
150 GPSR(gpio) = GPIO_bit(gpio);
151 GPDR(gpio) |= GPIO_bit(gpio);
152}
153
154static inline void spitzkbd_reset_col(int col)
155{
156 int gpio = spitz_strobes[col];
157 GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
158 GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
159 GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
160 GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
161 GPCR(gpio) = GPIO_bit(gpio);
162 GPDR(gpio) |= GPIO_bit(gpio);
163}
164
165static inline int spitzkbd_get_row_status(int col)
166{
167 return ((GPLR0 >> 12) & 0x01) | ((GPLR0 >> 16) & 0x02)
168 | ((GPLR2 >> 25) & 0x04) | ((GPLR1 << 1) & 0x08)
169 | ((GPLR1 >> 0) & 0x10) | ((GPLR1 >> 1) & 0x60);
170}
171
172/*
173 * The spitz keyboard only generates interrupts when a key is pressed.
174 * When a key is pressed, we enable a timer which then scans the
175 * keyboard to detect when the key is released.
176 */
177
178/* Scan the hardware keyboard and push any changes up through the input layer */
179static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs *regs)
180{
181 unsigned int row, col, rowd;
182 unsigned long flags;
183 unsigned int num_pressed, pwrkey = ((GPLR(SPITZ_GPIO_ON_KEY) & GPIO_bit(SPITZ_GPIO_ON_KEY)) != 0);
184
185 if (spitzkbd_data->suspended)
186 return;
187
188 spin_lock_irqsave(&spitzkbd_data->lock, flags);
189
190 if (regs)
191 input_regs(&spitzkbd_data->input, regs);
192
193 num_pressed = 0;
194 for (col = 0; col < KB_COLS; col++) {
195 /*
196 * Discharge the output driver capacitatance
197 * in the keyboard matrix. (Yes it is significant..)
198 */
199
200 spitzkbd_discharge_all();
201 udelay(KB_DISCHARGE_DELAY);
202
203 spitzkbd_activate_col(col);
204 udelay(KB_ACTIVATE_DELAY);
205
206 rowd = spitzkbd_get_row_status(col);
207 for (row = 0; row < KB_ROWS; row++) {
208 unsigned int scancode, pressed;
209
210 scancode = SCANCODE(row, col);
211 pressed = rowd & KB_ROWMASK(row);
212
213 input_report_key(&spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed);
214
215 if (pressed)
216 num_pressed++;
217 }
218 spitzkbd_reset_col(col);
219 }
220
221 spitzkbd_activate_all();
222
223 input_report_key(&spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 );
224 input_report_key(&spitzkbd_data->input, KEY_SUSPEND, pwrkey);
225
226 if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) {
227 input_event(&spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1);
228 spitzkbd_data->suspend_jiffies = jiffies;
229 }
230
231 input_sync(&spitzkbd_data->input);
232
233 /* if any keys are pressed, enable the timer */
234 if (num_pressed)
235 mod_timer(&spitzkbd_data->timer, jiffies + msecs_to_jiffies(100));
236
237 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
238}
239
240/*
241 * spitz keyboard interrupt handler.
242 */
243static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
244{
245 struct spitzkbd *spitzkbd_data = dev_id;
246
247 if (!timer_pending(&spitzkbd_data->timer)) {
248 /** wait chattering delay **/
249 udelay(20);
250 spitzkbd_scankeyboard(spitzkbd_data, regs);
251 }
252
253 return IRQ_HANDLED;
254}
255
256/*
257 * spitz timer checking for released keys
258 */
259static void spitzkbd_timer_callback(unsigned long data)
260{
261 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
262 spitzkbd_scankeyboard(spitzkbd_data, NULL);
263}
264
265/*
266 * The hinge switches generate an interrupt.
267 * We debounce the switches and pass them to the input system.
268 */
269
270static irqreturn_t spitzkbd_hinge_isr(int irq, void *dev_id, struct pt_regs *regs)
271{
272 struct spitzkbd *spitzkbd_data = dev_id;
273
274 if (!timer_pending(&spitzkbd_data->htimer))
275 mod_timer(&spitzkbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
276
277 return IRQ_HANDLED;
278}
279
280#define HINGE_STABLE_COUNT 2
281static int sharpsl_hinge_state;
282static int hinge_count;
283
284static void spitzkbd_hinge_timer(unsigned long data)
285{
286 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
287 unsigned long state;
288 unsigned long flags;
289
290 state = GPLR(SPITZ_GPIO_SWA) & (GPIO_bit(SPITZ_GPIO_SWA)|GPIO_bit(SPITZ_GPIO_SWB));
291 if (state != sharpsl_hinge_state) {
292 hinge_count = 0;
293 sharpsl_hinge_state = state;
294 } else if (hinge_count < HINGE_STABLE_COUNT) {
295 hinge_count++;
296 }
297
298 if (hinge_count >= HINGE_STABLE_COUNT) {
299 spin_lock_irqsave(&spitzkbd_data->lock, flags);
300
301 input_report_switch(&spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0));
302 input_report_switch(&spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0));
303 input_sync(&spitzkbd_data->input);
304
305 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
306 } else {
307 mod_timer(&spitzkbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
308 }
309}
310
311#ifdef CONFIG_PM
312static int spitzkbd_suspend(struct device *dev, pm_message_t state, uint32_t level)
313{
314 if (level == SUSPEND_POWER_DOWN) {
315 int i;
316 struct spitzkbd *spitzkbd = dev_get_drvdata(dev);
317 spitzkbd->suspended = 1;
318
319 /* Set Strobe lines as inputs - *except* strobe line 0 leave this
320 enabled so we can detect a power button press for resume */
321 for (i = 1; i < SPITZ_KEY_STROBE_NUM; i++)
322 pxa_gpio_mode(spitz_strobes[i] | GPIO_IN);
323 }
324 return 0;
325}
326
327static int spitzkbd_resume(struct device *dev, uint32_t level)
328{
329 if (level == RESUME_POWER_ON) {
330 int i;
331 struct spitzkbd *spitzkbd = dev_get_drvdata(dev);
332
333 for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++)
334 pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH);
335
336 /* Upon resume, ignore the suspend key for a short while */
337 spitzkbd->suspend_jiffies = jiffies;
338 spitzkbd->suspended = 0;
339 }
340 return 0;
341}
342#else
343#define spitzkbd_suspend NULL
344#define spitzkbd_resume NULL
345#endif
346
347static int __init spitzkbd_probe(struct device *dev)
348{
349 int i;
350 struct spitzkbd *spitzkbd;
351
352 spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL);
353 if (!spitzkbd)
354 return -ENOMEM;
355
356 dev_set_drvdata(dev,spitzkbd);
357 strcpy(spitzkbd->phys, "spitzkbd/input0");
358
359 spin_lock_init(&spitzkbd->lock);
360
361 /* Init Keyboard rescan timer */
362 init_timer(&spitzkbd->timer);
363 spitzkbd->timer.function = spitzkbd_timer_callback;
364 spitzkbd->timer.data = (unsigned long) spitzkbd;
365
366 /* Init Hinge Timer */
367 init_timer(&spitzkbd->htimer);
368 spitzkbd->htimer.function = spitzkbd_hinge_timer;
369 spitzkbd->htimer.data = (unsigned long) spitzkbd;
370
371 spitzkbd->suspend_jiffies=jiffies;
372
373 init_input_dev(&spitzkbd->input);
374 spitzkbd->input.private = spitzkbd;
375 spitzkbd->input.name = "Spitz Keyboard";
376 spitzkbd->input.dev = dev;
377 spitzkbd->input.phys = spitzkbd->phys;
378 spitzkbd->input.id.bustype = BUS_HOST;
379 spitzkbd->input.id.vendor = 0x0001;
380 spitzkbd->input.id.product = 0x0001;
381 spitzkbd->input.id.version = 0x0100;
382 spitzkbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
383 spitzkbd->input.keycode = spitzkbd->keycode;
384 spitzkbd->input.keycodesize = sizeof(unsigned char);
385 spitzkbd->input.keycodemax = ARRAY_SIZE(spitzkbd_keycode);
386
387 memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode));
388 for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++)
389 set_bit(spitzkbd->keycode[i], spitzkbd->input.keybit);
390 clear_bit(0, spitzkbd->input.keybit);
391 set_bit(SW_0, spitzkbd->input.swbit);
392 set_bit(SW_1, spitzkbd->input.swbit);
393
394 input_register_device(&spitzkbd->input);
395 mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
396
397 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
398 for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++) {
399 pxa_gpio_mode(spitz_senses[i] | GPIO_IN);
400 if (request_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd_interrupt,
401 SA_INTERRUPT, "Spitzkbd Sense", spitzkbd))
402 printk(KERN_WARNING "spitzkbd: Can't get Sense IRQ: %d!\n", i);
403 else
404 set_irq_type(IRQ_GPIO(spitz_senses[i]),IRQT_RISING);
405 }
406
407 /* Set Strobe lines as outputs - set high */
408 for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++)
409 pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH);
410
411 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN);
412 pxa_gpio_mode(SPITZ_GPIO_ON_KEY | GPIO_IN);
413 pxa_gpio_mode(SPITZ_GPIO_SWA | GPIO_IN);
414 pxa_gpio_mode(SPITZ_GPIO_SWB | GPIO_IN);
415
416 request_irq(SPITZ_IRQ_GPIO_SYNC, spitzkbd_interrupt, SA_INTERRUPT, "Spitzkbd Sync", spitzkbd);
417 request_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd_interrupt, SA_INTERRUPT, "Spitzkbd PwrOn", spitzkbd);
418 request_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd_hinge_isr, SA_INTERRUPT, "Spitzkbd SWA", spitzkbd);
419 request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr, SA_INTERRUPT, "Spitzkbd SWB", spitzkbd);
420
421 set_irq_type(SPITZ_IRQ_GPIO_SYNC, IRQT_BOTHEDGE);
422 set_irq_type(SPITZ_IRQ_GPIO_ON_KEY, IRQT_BOTHEDGE);
423 set_irq_type(SPITZ_IRQ_GPIO_SWA, IRQT_BOTHEDGE);
424 set_irq_type(SPITZ_IRQ_GPIO_SWB, IRQT_BOTHEDGE);
425
426 printk(KERN_INFO "input: Spitz Keyboard Registered\n");
427
428 return 0;
429}
430
431static int spitzkbd_remove(struct device *dev)
432{
433 int i;
434 struct spitzkbd *spitzkbd = dev_get_drvdata(dev);
435
436 for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++)
437 free_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd);
438
439 free_irq(SPITZ_IRQ_GPIO_SYNC, spitzkbd);
440 free_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd);
441 free_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd);
442 free_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd);
443
444 del_timer_sync(&spitzkbd->htimer);
445 del_timer_sync(&spitzkbd->timer);
446
447 input_unregister_device(&spitzkbd->input);
448
449 kfree(spitzkbd);
450
451 return 0;
452}
453
454static struct device_driver spitzkbd_driver = {
455 .name = "spitz-keyboard",
456 .bus = &platform_bus_type,
457 .probe = spitzkbd_probe,
458 .remove = spitzkbd_remove,
459 .suspend = spitzkbd_suspend,
460 .resume = spitzkbd_resume,
461};
462
463static int __devinit spitzkbd_init(void)
464{
465 return driver_register(&spitzkbd_driver);
466}
467
468static void __exit spitzkbd_exit(void)
469{
470 driver_unregister(&spitzkbd_driver);
471}
472
473module_init(spitzkbd_init);
474module_exit(spitzkbd_exit);
475
476MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
477MODULE_DESCRIPTION("Spitz Keyboard Driver");
478MODULE_LICENSE("GPLv2");
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 0489af5a80c9..21d55ed4b88a 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -24,17 +24,17 @@ config TOUCHSCREEN_BITSY
24 module will be called h3600_ts_input. 24 module will be called h3600_ts_input.
25 25
26config TOUCHSCREEN_CORGI 26config TOUCHSCREEN_CORGI
27 tristate "Corgi touchscreen (for Sharp SL-C7xx)" 27 tristate "SharpSL (Corgi and Spitz series) touchscreen driver"
28 depends on PXA_SHARPSL 28 depends on PXA_SHARPSL
29 default y 29 default y
30 help 30 help
31 Say Y here to enable the driver for the touchscreen on the 31 Say Y here to enable the driver for the touchscreen on the
32 Sharp SL-C7xx series of PDAs. 32 Sharp SL-C7xx and SL-Cxx00 series of PDAs.
33 33
34 If unsure, say N. 34 If unsure, say N.
35 35
36 To compile this driver as a module, choose M here: the 36 To compile this driver as a module, choose M here: the
37 module will be called ads7846_ts. 37 module will be called corgi_ts.
38 38
39config TOUCHSCREEN_GUNZE 39config TOUCHSCREEN_GUNZE
40 tristate "Gunze AHL-51S touchscreen" 40 tristate "Gunze AHL-51S touchscreen"
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index 5d19261b884f..4c7fbe550365 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Touchscreen driver for Sharp Corgi models (SL-C7xx) 2 * Touchscreen driver for Sharp SL-C7xx and SL-Cxx00 models
3 * 3 *
4 * Copyright (c) 2004-2005 Richard Purdie 4 * Copyright (c) 2004-2005 Richard Purdie
5 * 5 *
@@ -19,7 +19,7 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <asm/irq.h> 20#include <asm/irq.h>
21 21
22#include <asm/arch/corgi.h> 22#include <asm/arch/sharpsl.h>
23#include <asm/arch/hardware.h> 23#include <asm/arch/hardware.h>
24#include <asm/arch/pxa-regs.h> 24#include <asm/arch/pxa-regs.h>
25 25
@@ -47,15 +47,20 @@ struct corgi_ts {
47 struct ts_event tc; 47 struct ts_event tc;
48 int pendown; 48 int pendown;
49 int power_mode; 49 int power_mode;
50 int irq_gpio;
51 struct corgits_machinfo *machinfo;
50}; 52};
51 53
52#define STATUS_HSYNC (GPLR(CORGI_GPIO_HSYNC) & GPIO_bit(CORGI_GPIO_HSYNC)) 54#ifdef CONFIG_PXA25x
53
54#define SyncHS() while((STATUS_HSYNC) == 0); while((STATUS_HSYNC) != 0);
55#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a)) 55#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a))
56#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x)) 56#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x))
57#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x)) 57#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x))
58 58#endif
59#ifdef CONFIG_PXA27x
60#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a))
61#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C1, 0" : "=r"(x))
62#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C1, 0" : : "r"(x))
63#endif
59 64
60/* ADS7846 Touch Screen Controller bit definitions */ 65/* ADS7846 Touch Screen Controller bit definitions */
61#define ADSCTRL_PD0 (1u << 0) /* PD0 */ 66#define ADSCTRL_PD0 (1u << 0) /* PD0 */
@@ -66,12 +71,11 @@ struct corgi_ts {
66#define ADSCTRL_STS (1u << 7) /* Start Bit */ 71#define ADSCTRL_STS (1u << 7) /* Start Bit */
67 72
68/* External Functions */ 73/* External Functions */
69extern unsigned long w100fb_get_hsynclen(struct device *dev);
70extern unsigned int get_clk_frequency_khz(int info); 74extern unsigned int get_clk_frequency_khz(int info);
71 75
72static unsigned long calc_waittime(void) 76static unsigned long calc_waittime(struct corgi_ts *corgi_ts)
73{ 77{
74 unsigned long hsync_len = w100fb_get_hsynclen(&corgifb_device.dev); 78 unsigned long hsync_len = corgi_ts->machinfo->get_hsync_len();
75 79
76 if (hsync_len) 80 if (hsync_len)
77 return get_clk_frequency_khz(0)*1000/hsync_len; 81 return get_clk_frequency_khz(0)*1000/hsync_len;
@@ -79,7 +83,8 @@ static unsigned long calc_waittime(void)
79 return 0; 83 return 0;
80} 84}
81 85
82static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int address, unsigned long wait_time) 86static int sync_receive_data_send_cmd(struct corgi_ts *corgi_ts, int doRecive, int doSend,
87 unsigned int address, unsigned long wait_time)
83{ 88{
84 unsigned long timer1 = 0, timer2, pmnc = 0; 89 unsigned long timer1 = 0, timer2, pmnc = 0;
85 int pos = 0; 90 int pos = 0;
@@ -90,7 +95,7 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add
90 PMNC_SET(0x01); 95 PMNC_SET(0x01);
91 96
92 /* polling HSync */ 97 /* polling HSync */
93 SyncHS(); 98 corgi_ts->machinfo->wait_hsync();
94 /* get CCNT */ 99 /* get CCNT */
95 CCNT(timer1); 100 CCNT(timer1);
96 } 101 }
@@ -109,7 +114,7 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add
109 CCNT(timer2); 114 CCNT(timer2);
110 if (timer2-timer1 > wait_time) { 115 if (timer2-timer1 > wait_time) {
111 /* too slow - timeout, try again */ 116 /* too slow - timeout, try again */
112 SyncHS(); 117 corgi_ts->machinfo->wait_hsync();
113 /* get OSCR */ 118 /* get OSCR */
114 CCNT(timer1); 119 CCNT(timer1);
115 /* Wait after HSync */ 120 /* Wait after HSync */
@@ -133,23 +138,23 @@ static int read_xydata(struct corgi_ts *corgi_ts)
133 /* critical section */ 138 /* critical section */
134 local_irq_save(flags); 139 local_irq_save(flags);
135 corgi_ssp_ads7846_lock(); 140 corgi_ssp_ads7846_lock();
136 wait_time=calc_waittime(); 141 wait_time = calc_waittime(corgi_ts);
137 142
138 /* Y-axis */ 143 /* Y-axis */
139 sync_receive_data_send_cmd(0, 1, 1u, wait_time); 144 sync_receive_data_send_cmd(corgi_ts, 0, 1, 1u, wait_time);
140 145
141 /* Y-axis */ 146 /* Y-axis */
142 sync_receive_data_send_cmd(1, 1, 1u, wait_time); 147 sync_receive_data_send_cmd(corgi_ts, 1, 1, 1u, wait_time);
143 148
144 /* X-axis */ 149 /* X-axis */
145 y = sync_receive_data_send_cmd(1, 1, 5u, wait_time); 150 y = sync_receive_data_send_cmd(corgi_ts, 1, 1, 5u, wait_time);
146 151
147 /* Z1 */ 152 /* Z1 */
148 x = sync_receive_data_send_cmd(1, 1, 3u, wait_time); 153 x = sync_receive_data_send_cmd(corgi_ts, 1, 1, 3u, wait_time);
149 154
150 /* Z2 */ 155 /* Z2 */
151 z1 = sync_receive_data_send_cmd(1, 1, 4u, wait_time); 156 z1 = sync_receive_data_send_cmd(corgi_ts, 1, 1, 4u, wait_time);
152 z2 = sync_receive_data_send_cmd(1, 0, 4u, wait_time); 157 z2 = sync_receive_data_send_cmd(corgi_ts, 1, 0, 4u, wait_time);
153 158
154 /* Power-Down Enable */ 159 /* Power-Down Enable */
155 corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 160 corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
@@ -189,9 +194,9 @@ static void new_data(struct corgi_ts *corgi_ts, struct pt_regs *regs)
189 194
190static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs) 195static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs)
191{ 196{
192 if ((GPLR(CORGI_GPIO_TP_INT) & GPIO_bit(CORGI_GPIO_TP_INT)) == 0) { 197 if ((GPLR(IRQ_TO_GPIO(corgi_ts->irq_gpio)) & GPIO_bit(IRQ_TO_GPIO(corgi_ts->irq_gpio))) == 0) {
193 /* Disable Interrupt */ 198 /* Disable Interrupt */
194 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_NOEDGE); 199 set_irq_type(corgi_ts->irq_gpio, IRQT_NOEDGE);
195 if (read_xydata(corgi_ts)) { 200 if (read_xydata(corgi_ts)) {
196 corgi_ts->pendown = 1; 201 corgi_ts->pendown = 1;
197 new_data(corgi_ts, regs); 202 new_data(corgi_ts, regs);
@@ -210,7 +215,7 @@ static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_
210 } 215 }
211 216
212 /* Enable Falling Edge */ 217 /* Enable Falling Edge */
213 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 218 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
214 corgi_ts->pendown = 0; 219 corgi_ts->pendown = 0;
215 } 220 }
216} 221}
@@ -254,7 +259,7 @@ static int corgits_resume(struct device *dev, uint32_t level)
254 259
255 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 260 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
256 /* Enable Falling Edge */ 261 /* Enable Falling Edge */
257 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 262 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
258 corgi_ts->power_mode = PWR_MODE_ACTIVE; 263 corgi_ts->power_mode = PWR_MODE_ACTIVE;
259 } 264 }
260 return 0; 265 return 0;
@@ -267,6 +272,7 @@ static int corgits_resume(struct device *dev, uint32_t level)
267static int __init corgits_probe(struct device *dev) 272static int __init corgits_probe(struct device *dev)
268{ 273{
269 struct corgi_ts *corgi_ts; 274 struct corgi_ts *corgi_ts;
275 struct platform_device *pdev = to_platform_device(dev);
270 276
271 if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL))) 277 if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL)))
272 return -ENOMEM; 278 return -ENOMEM;
@@ -275,6 +281,14 @@ static int __init corgits_probe(struct device *dev)
275 281
276 memset(corgi_ts, 0, sizeof(struct corgi_ts)); 282 memset(corgi_ts, 0, sizeof(struct corgi_ts));
277 283
284 corgi_ts->machinfo = dev->platform_data;
285 corgi_ts->irq_gpio = platform_get_irq(pdev, 0);
286
287 if (corgi_ts->irq_gpio < 0) {
288 kfree(corgi_ts);
289 return -ENODEV;
290 }
291
278 init_input_dev(&corgi_ts->input); 292 init_input_dev(&corgi_ts->input);
279 corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 293 corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
280 corgi_ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 294 corgi_ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
@@ -293,8 +307,7 @@ static int __init corgits_probe(struct device *dev)
293 corgi_ts->input.id.product = 0x0002; 307 corgi_ts->input.id.product = 0x0002;
294 corgi_ts->input.id.version = 0x0100; 308 corgi_ts->input.id.version = 0x0100;
295 309
296 pxa_gpio_mode(CORGI_GPIO_TP_INT | GPIO_IN); 310 pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN);
297 pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN);
298 311
299 /* Initiaize ADS7846 Difference Reference mode */ 312 /* Initiaize ADS7846 Difference Reference mode */
300 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 313 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
@@ -313,14 +326,14 @@ static int __init corgits_probe(struct device *dev)
313 input_register_device(&corgi_ts->input); 326 input_register_device(&corgi_ts->input);
314 corgi_ts->power_mode = PWR_MODE_ACTIVE; 327 corgi_ts->power_mode = PWR_MODE_ACTIVE;
315 328
316 if (request_irq(CORGI_IRQ_GPIO_TP_INT, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) { 329 if (request_irq(corgi_ts->irq_gpio, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) {
317 input_unregister_device(&corgi_ts->input); 330 input_unregister_device(&corgi_ts->input);
318 kfree(corgi_ts); 331 kfree(corgi_ts);
319 return -EBUSY; 332 return -EBUSY;
320 } 333 }
321 334
322 /* Enable Falling Edge */ 335 /* Enable Falling Edge */
323 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 336 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
324 337
325 printk(KERN_INFO "input: Corgi Touchscreen Registered\n"); 338 printk(KERN_INFO "input: Corgi Touchscreen Registered\n");
326 339
@@ -331,8 +344,9 @@ static int corgits_remove(struct device *dev)
331{ 344{
332 struct corgi_ts *corgi_ts = dev_get_drvdata(dev); 345 struct corgi_ts *corgi_ts = dev_get_drvdata(dev);
333 346
334 free_irq(CORGI_IRQ_GPIO_TP_INT, NULL); 347 free_irq(corgi_ts->irq_gpio, NULL);
335 del_timer_sync(&corgi_ts->timer); 348 del_timer_sync(&corgi_ts->timer);
349 corgi_ts->machinfo->put_hsync();
336 input_unregister_device(&corgi_ts->input); 350 input_unregister_device(&corgi_ts->input);
337 kfree(corgi_ts); 351 kfree(corgi_ts);
338 return 0; 352 return 0;
diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c
index 40b0df04ed9f..1ebed041672d 100644
--- a/drivers/isdn/sc/init.c
+++ b/drivers/isdn/sc/init.c
@@ -87,7 +87,7 @@ static int __init sc_init(void)
87 */ 87 */
88 for (i = 0 ; i < MAX_IO_REGS - 1 ; i++) { 88 for (i = 0 ; i < MAX_IO_REGS - 1 ; i++) {
89 if(!request_region(io[b] + i * 0x400, 1, "sc test")) { 89 if(!request_region(io[b] + i * 0x400, 1, "sc test")) {
90 pr_debug("check_region for 0x%x failed\n", io[b] + i * 0x400); 90 pr_debug("request_region for 0x%x failed\n", io[b] + i * 0x400);
91 io[b] = 0; 91 io[b] = 0;
92 break; 92 break;
93 } else 93 } else
@@ -181,7 +181,7 @@ static int __init sc_init(void)
181 for (i = SRAM_MIN ; i < SRAM_MAX ; i += SRAM_PAGESIZE) { 181 for (i = SRAM_MIN ; i < SRAM_MAX ; i += SRAM_PAGESIZE) {
182 pr_debug("Checking RAM address 0x%x...\n", i); 182 pr_debug("Checking RAM address 0x%x...\n", i);
183 if(request_region(i, SRAM_PAGESIZE, "sc test")) { 183 if(request_region(i, SRAM_PAGESIZE, "sc test")) {
184 pr_debug(" check_region succeeded\n"); 184 pr_debug(" request_region succeeded\n");
185 model = identify_board(i, io[b]); 185 model = identify_board(i, io[b]);
186 release_region(i, SRAM_PAGESIZE); 186 release_region(i, SRAM_PAGESIZE);
187 if (model >= 0) { 187 if (model >= 0) {
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 8b4ad70dd1b2..877c770558e9 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -29,7 +29,7 @@
29 29
30#include <linux/module.h> /* Modules */ 30#include <linux/module.h> /* Modules */
31#include <linux/init.h> /* Initdata */ 31#include <linux/init.h> /* Initdata */
32#include <linux/ioport.h> /* check_region, request_region */ 32#include <linux/ioport.h> /* request_region */
33#include <linux/delay.h> /* udelay */ 33#include <linux/delay.h> /* udelay */
34#include <asm/io.h> /* outb, outb_p */ 34#include <asm/io.h> /* outb, outb_p */
35#include <asm/uaccess.h> /* copy to/from user */ 35#include <asm/uaccess.h> /* copy to/from user */
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 013c835ed910..5319a9c9a979 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -26,7 +26,7 @@
26 26
27#include <linux/module.h> /* Modules */ 27#include <linux/module.h> /* Modules */
28#include <linux/init.h> /* Initdata */ 28#include <linux/init.h> /* Initdata */
29#include <linux/ioport.h> /* check_region, request_region */ 29#include <linux/ioport.h> /* request_region */
30#include <linux/delay.h> /* udelay */ 30#include <linux/delay.h> /* udelay */
31#include <asm/io.h> /* outb, outb_p */ 31#include <asm/io.h> /* outb, outb_p */
32#include <asm/uaccess.h> /* copy to/from user */ 32#include <asm/uaccess.h> /* copy to/from user */
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 53d399b6652b..022913da8c59 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -29,7 +29,7 @@
29 29
30#include <linux/module.h> /* Modules */ 30#include <linux/module.h> /* Modules */
31#include <linux/init.h> /* Initdata */ 31#include <linux/init.h> /* Initdata */
32#include <linux/ioport.h> /* check_region, request_region */ 32#include <linux/ioport.h> /* request_region */
33#include <linux/delay.h> /* udelay */ 33#include <linux/delay.h> /* udelay */
34#include <asm/io.h> /* outb, outb_p */ 34#include <asm/io.h> /* outb, outb_p */
35#include <asm/uaccess.h> /* copy to/from user */ 35#include <asm/uaccess.h> /* copy to/from user */
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 202bfe6819b8..6418f03b9ce4 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -17,7 +17,7 @@
17 17
18#include <linux/module.h> /* Modules */ 18#include <linux/module.h> /* Modules */
19#include <linux/init.h> /* Initdata */ 19#include <linux/init.h> /* Initdata */
20#include <linux/ioport.h> /* check_region, request_region */ 20#include <linux/ioport.h> /* request_region */
21#include <linux/delay.h> /* udelay */ 21#include <linux/delay.h> /* udelay */
22#include <asm/io.h> /* outb, outb_p */ 22#include <asm/io.h> /* outb, outb_p */
23#include <asm/uaccess.h> /* copy to/from user */ 23#include <asm/uaccess.h> /* copy to/from user */
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index c00245d4d249..b2256d675b44 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -10,7 +10,7 @@
10 10
11#include <linux/module.h> /* Modules */ 11#include <linux/module.h> /* Modules */
12#include <linux/init.h> /* Initdata */ 12#include <linux/init.h> /* Initdata */
13#include <linux/ioport.h> /* check_region, request_region */ 13#include <linux/ioport.h> /* request_region */
14#include <linux/delay.h> /* udelay */ 14#include <linux/delay.h> /* udelay */
15#include <asm/io.h> /* outb, outb_p */ 15#include <asm/io.h> /* outb, outb_p */
16#include <asm/uaccess.h> /* copy to/from user */ 16#include <asm/uaccess.h> /* copy to/from user */
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 3a464a09221f..6f03ce4dd7b0 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -18,7 +18,7 @@
18#include <linux/kernel.h> /* __setup */ 18#include <linux/kernel.h> /* __setup */
19#include <linux/module.h> /* Modules */ 19#include <linux/module.h> /* Modules */
20#include <linux/init.h> /* Initdata */ 20#include <linux/init.h> /* Initdata */
21#include <linux/ioport.h> /* check_region, request_region */ 21#include <linux/ioport.h> /* request_region */
22#include <linux/delay.h> /* udelay */ 22#include <linux/delay.h> /* udelay */
23#include <linux/videodev.h> /* kernel radio structs */ 23#include <linux/videodev.h> /* kernel radio structs */
24#include <linux/isapnp.h> 24#include <linux/isapnp.h>
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index 0732efda6a98..71971e9bb342 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -14,7 +14,7 @@
14 14
15#include <linux/module.h> /* Modules */ 15#include <linux/module.h> /* Modules */
16#include <linux/init.h> /* Initdata */ 16#include <linux/init.h> /* Initdata */
17#include <linux/ioport.h> /* check_region, request_region */ 17#include <linux/ioport.h> /* request_region */
18#include <linux/delay.h> /* udelay */ 18#include <linux/delay.h> /* udelay */
19#include <asm/io.h> /* outb, outb_p */ 19#include <asm/io.h> /* outb, outb_p */
20#include <asm/uaccess.h> /* copy to/from user */ 20#include <asm/uaccess.h> /* copy to/from user */
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index 248d67fde037..b03573c6840e 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -25,7 +25,7 @@
25 25
26#include <linux/module.h> /* Modules */ 26#include <linux/module.h> /* Modules */
27#include <linux/init.h> /* Initdata */ 27#include <linux/init.h> /* Initdata */
28#include <linux/ioport.h> /* check_region, request_region */ 28#include <linux/ioport.h> /* request_region */
29#include <linux/delay.h> /* udelay */ 29#include <linux/delay.h> /* udelay */
30#include <asm/io.h> /* outb, outb_p */ 30#include <asm/io.h> /* outb, outb_p */
31#include <asm/uaccess.h> /* copy to/from user */ 31#include <asm/uaccess.h> /* copy to/from user */
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index d7da901ebe90..f304f3c14763 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -31,7 +31,7 @@
31 31
32#include <linux/module.h> /* Modules */ 32#include <linux/module.h> /* Modules */
33#include <linux/init.h> /* Initdata */ 33#include <linux/init.h> /* Initdata */
34#include <linux/ioport.h> /* check_region, request_region */ 34#include <linux/ioport.h> /* request_region */
35#include <linux/proc_fs.h> /* radio card status report */ 35#include <linux/proc_fs.h> /* radio card status report */
36#include <asm/io.h> /* outb, outb_p */ 36#include <asm/io.h> /* outb, outb_p */
37#include <asm/uaccess.h> /* copy to/from user */ 37#include <asm/uaccess.h> /* copy to/from user */
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index 342f92df4aba..4c6d6fb49034 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -28,7 +28,7 @@
28 28
29#include <linux/module.h> /* Modules */ 29#include <linux/module.h> /* Modules */
30#include <linux/init.h> /* Initdata */ 30#include <linux/init.h> /* Initdata */
31#include <linux/ioport.h> /* check_region, request_region */ 31#include <linux/ioport.h> /* request_region */
32#include <linux/delay.h> /* udelay, msleep */ 32#include <linux/delay.h> /* udelay, msleep */
33#include <asm/io.h> /* outb, outb_p */ 33#include <asm/io.h> /* outb, outb_p */
34#include <asm/uaccess.h> /* copy to/from user */ 34#include <asm/uaccess.h> /* copy to/from user */
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index c9106b1d79df..4334744652de 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -221,9 +221,7 @@ static int lgdt330x_pll_set(struct dvb_frontend* fe,
221 int err; 221 int err;
222 222
223 /* Put the analog decoder in standby to keep it quiet */ 223 /* Put the analog decoder in standby to keep it quiet */
224 if (core->tda9887_conf) { 224 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
225 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
226 }
227 225
228 dvb_pll_configure(core->pll_desc, buf, params->frequency, 0); 226 dvb_pll_configure(core->pll_desc, buf, params->frequency, 0);
229 dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n", 227 dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n",
@@ -402,6 +400,9 @@ static int dvb_register(struct cx8802_dev *dev)
402 dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max; 400 dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max;
403 } 401 }
404 402
403 /* Put the analog decoder in standby to keep it quiet */
404 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
405
405 /* register everything */ 406 /* register everything */
406 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev); 407 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev);
407} 408}
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index e11e55dc8924..3cbca7cbea80 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -93,7 +93,7 @@ static int dma = 2;
93static inline void wbsd_unlock_config(struct wbsd_host* host) 93static inline void wbsd_unlock_config(struct wbsd_host* host)
94{ 94{
95 BUG_ON(host->config == 0); 95 BUG_ON(host->config == 0);
96 96
97 outb(host->unlock_code, host->config); 97 outb(host->unlock_code, host->config);
98 outb(host->unlock_code, host->config); 98 outb(host->unlock_code, host->config);
99} 99}
@@ -101,14 +101,14 @@ static inline void wbsd_unlock_config(struct wbsd_host* host)
101static inline void wbsd_lock_config(struct wbsd_host* host) 101static inline void wbsd_lock_config(struct wbsd_host* host)
102{ 102{
103 BUG_ON(host->config == 0); 103 BUG_ON(host->config == 0);
104 104
105 outb(LOCK_CODE, host->config); 105 outb(LOCK_CODE, host->config);
106} 106}
107 107
108static inline void wbsd_write_config(struct wbsd_host* host, u8 reg, u8 value) 108static inline void wbsd_write_config(struct wbsd_host* host, u8 reg, u8 value)
109{ 109{
110 BUG_ON(host->config == 0); 110 BUG_ON(host->config == 0);
111 111
112 outb(reg, host->config); 112 outb(reg, host->config);
113 outb(value, host->config + 1); 113 outb(value, host->config + 1);
114} 114}
@@ -116,7 +116,7 @@ static inline void wbsd_write_config(struct wbsd_host* host, u8 reg, u8 value)
116static inline u8 wbsd_read_config(struct wbsd_host* host, u8 reg) 116static inline u8 wbsd_read_config(struct wbsd_host* host, u8 reg)
117{ 117{
118 BUG_ON(host->config == 0); 118 BUG_ON(host->config == 0);
119 119
120 outb(reg, host->config); 120 outb(reg, host->config);
121 return inb(host->config + 1); 121 return inb(host->config + 1);
122} 122}
@@ -140,21 +140,21 @@ static inline u8 wbsd_read_index(struct wbsd_host* host, u8 index)
140static void wbsd_init_device(struct wbsd_host* host) 140static void wbsd_init_device(struct wbsd_host* host)
141{ 141{
142 u8 setup, ier; 142 u8 setup, ier;
143 143
144 /* 144 /*
145 * Reset chip (SD/MMC part) and fifo. 145 * Reset chip (SD/MMC part) and fifo.
146 */ 146 */
147 setup = wbsd_read_index(host, WBSD_IDX_SETUP); 147 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
148 setup |= WBSD_FIFO_RESET | WBSD_SOFT_RESET; 148 setup |= WBSD_FIFO_RESET | WBSD_SOFT_RESET;
149 wbsd_write_index(host, WBSD_IDX_SETUP, setup); 149 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
150 150
151 /* 151 /*
152 * Set DAT3 to input 152 * Set DAT3 to input
153 */ 153 */
154 setup &= ~WBSD_DAT3_H; 154 setup &= ~WBSD_DAT3_H;
155 wbsd_write_index(host, WBSD_IDX_SETUP, setup); 155 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
156 host->flags &= ~WBSD_FIGNORE_DETECT; 156 host->flags &= ~WBSD_FIGNORE_DETECT;
157 157
158 /* 158 /*
159 * Read back default clock. 159 * Read back default clock.
160 */ 160 */
@@ -164,12 +164,12 @@ static void wbsd_init_device(struct wbsd_host* host)
164 * Power down port. 164 * Power down port.
165 */ 165 */
166 outb(WBSD_POWER_N, host->base + WBSD_CSR); 166 outb(WBSD_POWER_N, host->base + WBSD_CSR);
167 167
168 /* 168 /*
169 * Set maximum timeout. 169 * Set maximum timeout.
170 */ 170 */
171 wbsd_write_index(host, WBSD_IDX_TAAC, 0x7F); 171 wbsd_write_index(host, WBSD_IDX_TAAC, 0x7F);
172 172
173 /* 173 /*
174 * Test for card presence 174 * Test for card presence
175 */ 175 */
@@ -177,7 +177,7 @@ static void wbsd_init_device(struct wbsd_host* host)
177 host->flags |= WBSD_FCARD_PRESENT; 177 host->flags |= WBSD_FCARD_PRESENT;
178 else 178 else
179 host->flags &= ~WBSD_FCARD_PRESENT; 179 host->flags &= ~WBSD_FCARD_PRESENT;
180 180
181 /* 181 /*
182 * Enable interesting interrupts. 182 * Enable interesting interrupts.
183 */ 183 */
@@ -200,9 +200,9 @@ static void wbsd_init_device(struct wbsd_host* host)
200static void wbsd_reset(struct wbsd_host* host) 200static void wbsd_reset(struct wbsd_host* host)
201{ 201{
202 u8 setup; 202 u8 setup;
203 203
204 printk(KERN_ERR DRIVER_NAME ": Resetting chip\n"); 204 printk(KERN_ERR DRIVER_NAME ": Resetting chip\n");
205 205
206 /* 206 /*
207 * Soft reset of chip (SD/MMC part). 207 * Soft reset of chip (SD/MMC part).
208 */ 208 */
@@ -214,9 +214,9 @@ static void wbsd_reset(struct wbsd_host* host)
214static void wbsd_request_end(struct wbsd_host* host, struct mmc_request* mrq) 214static void wbsd_request_end(struct wbsd_host* host, struct mmc_request* mrq)
215{ 215{
216 unsigned long dmaflags; 216 unsigned long dmaflags;
217 217
218 DBGF("Ending request, cmd (%x)\n", mrq->cmd->opcode); 218 DBGF("Ending request, cmd (%x)\n", mrq->cmd->opcode);
219 219
220 if (host->dma >= 0) 220 if (host->dma >= 0)
221 { 221 {
222 /* 222 /*
@@ -232,7 +232,7 @@ static void wbsd_request_end(struct wbsd_host* host, struct mmc_request* mrq)
232 */ 232 */
233 wbsd_write_index(host, WBSD_IDX_DMA, 0); 233 wbsd_write_index(host, WBSD_IDX_DMA, 0);
234 } 234 }
235 235
236 host->mrq = NULL; 236 host->mrq = NULL;
237 237
238 /* 238 /*
@@ -275,7 +275,7 @@ static inline int wbsd_next_sg(struct wbsd_host* host)
275 host->offset = 0; 275 host->offset = 0;
276 host->remain = host->cur_sg->length; 276 host->remain = host->cur_sg->length;
277 } 277 }
278 278
279 return host->num_sg; 279 return host->num_sg;
280} 280}
281 281
@@ -297,12 +297,12 @@ static inline void wbsd_sg_to_dma(struct wbsd_host* host, struct mmc_data* data)
297 struct scatterlist* sg; 297 struct scatterlist* sg;
298 char* dmabuf = host->dma_buffer; 298 char* dmabuf = host->dma_buffer;
299 char* sgbuf; 299 char* sgbuf;
300 300
301 size = host->size; 301 size = host->size;
302 302
303 sg = data->sg; 303 sg = data->sg;
304 len = data->sg_len; 304 len = data->sg_len;
305 305
306 /* 306 /*
307 * Just loop through all entries. Size might not 307 * Just loop through all entries. Size might not
308 * be the entire list though so make sure that 308 * be the entire list though so make sure that
@@ -317,23 +317,23 @@ static inline void wbsd_sg_to_dma(struct wbsd_host* host, struct mmc_data* data)
317 memcpy(dmabuf, sgbuf, sg[i].length); 317 memcpy(dmabuf, sgbuf, sg[i].length);
318 kunmap_atomic(sgbuf, KM_BIO_SRC_IRQ); 318 kunmap_atomic(sgbuf, KM_BIO_SRC_IRQ);
319 dmabuf += sg[i].length; 319 dmabuf += sg[i].length;
320 320
321 if (size < sg[i].length) 321 if (size < sg[i].length)
322 size = 0; 322 size = 0;
323 else 323 else
324 size -= sg[i].length; 324 size -= sg[i].length;
325 325
326 if (size == 0) 326 if (size == 0)
327 break; 327 break;
328 } 328 }
329 329
330 /* 330 /*
331 * Check that we didn't get a request to transfer 331 * Check that we didn't get a request to transfer
332 * more data than can fit into the SG list. 332 * more data than can fit into the SG list.
333 */ 333 */
334 334
335 BUG_ON(size != 0); 335 BUG_ON(size != 0);
336 336
337 host->size -= size; 337 host->size -= size;
338} 338}
339 339
@@ -343,12 +343,12 @@ static inline void wbsd_dma_to_sg(struct wbsd_host* host, struct mmc_data* data)
343 struct scatterlist* sg; 343 struct scatterlist* sg;
344 char* dmabuf = host->dma_buffer; 344 char* dmabuf = host->dma_buffer;
345 char* sgbuf; 345 char* sgbuf;
346 346
347 size = host->size; 347 size = host->size;
348 348
349 sg = data->sg; 349 sg = data->sg;
350 len = data->sg_len; 350 len = data->sg_len;
351 351
352 /* 352 /*
353 * Just loop through all entries. Size might not 353 * Just loop through all entries. Size might not
354 * be the entire list though so make sure that 354 * be the entire list though so make sure that
@@ -363,30 +363,30 @@ static inline void wbsd_dma_to_sg(struct wbsd_host* host, struct mmc_data* data)
363 memcpy(sgbuf, dmabuf, sg[i].length); 363 memcpy(sgbuf, dmabuf, sg[i].length);
364 kunmap_atomic(sgbuf, KM_BIO_SRC_IRQ); 364 kunmap_atomic(sgbuf, KM_BIO_SRC_IRQ);
365 dmabuf += sg[i].length; 365 dmabuf += sg[i].length;
366 366
367 if (size < sg[i].length) 367 if (size < sg[i].length)
368 size = 0; 368 size = 0;
369 else 369 else
370 size -= sg[i].length; 370 size -= sg[i].length;
371 371
372 if (size == 0) 372 if (size == 0)
373 break; 373 break;
374 } 374 }
375 375
376 /* 376 /*
377 * Check that we didn't get a request to transfer 377 * Check that we didn't get a request to transfer
378 * more data than can fit into the SG list. 378 * more data than can fit into the SG list.
379 */ 379 */
380 380
381 BUG_ON(size != 0); 381 BUG_ON(size != 0);
382 382
383 host->size -= size; 383 host->size -= size;
384} 384}
385 385
386/* 386/*
387 * Command handling 387 * Command handling
388 */ 388 */
389 389
390static inline void wbsd_get_short_reply(struct wbsd_host* host, 390static inline void wbsd_get_short_reply(struct wbsd_host* host,
391 struct mmc_command* cmd) 391 struct mmc_command* cmd)
392{ 392{
@@ -398,7 +398,7 @@ static inline void wbsd_get_short_reply(struct wbsd_host* host,
398 cmd->error = MMC_ERR_INVALID; 398 cmd->error = MMC_ERR_INVALID;
399 return; 399 return;
400 } 400 }
401 401
402 cmd->resp[0] = 402 cmd->resp[0] =
403 wbsd_read_index(host, WBSD_IDX_RESP12) << 24; 403 wbsd_read_index(host, WBSD_IDX_RESP12) << 24;
404 cmd->resp[0] |= 404 cmd->resp[0] |=
@@ -415,7 +415,7 @@ static inline void wbsd_get_long_reply(struct wbsd_host* host,
415 struct mmc_command* cmd) 415 struct mmc_command* cmd)
416{ 416{
417 int i; 417 int i;
418 418
419 /* 419 /*
420 * Correct response type? 420 * Correct response type?
421 */ 421 */
@@ -424,7 +424,7 @@ static inline void wbsd_get_long_reply(struct wbsd_host* host,
424 cmd->error = MMC_ERR_INVALID; 424 cmd->error = MMC_ERR_INVALID;
425 return; 425 return;
426 } 426 }
427 427
428 for (i = 0;i < 4;i++) 428 for (i = 0;i < 4;i++)
429 { 429 {
430 cmd->resp[i] = 430 cmd->resp[i] =
@@ -442,7 +442,7 @@ static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd)
442{ 442{
443 int i; 443 int i;
444 u8 status, isr; 444 u8 status, isr;
445 445
446 DBGF("Sending cmd (%x)\n", cmd->opcode); 446 DBGF("Sending cmd (%x)\n", cmd->opcode);
447 447
448 /* 448 /*
@@ -451,16 +451,16 @@ static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd)
451 * transfer. 451 * transfer.
452 */ 452 */
453 host->isr = 0; 453 host->isr = 0;
454 454
455 /* 455 /*
456 * Send the command (CRC calculated by host). 456 * Send the command (CRC calculated by host).
457 */ 457 */
458 outb(cmd->opcode, host->base + WBSD_CMDR); 458 outb(cmd->opcode, host->base + WBSD_CMDR);
459 for (i = 3;i >= 0;i--) 459 for (i = 3;i >= 0;i--)
460 outb((cmd->arg >> (i * 8)) & 0xff, host->base + WBSD_CMDR); 460 outb((cmd->arg >> (i * 8)) & 0xff, host->base + WBSD_CMDR);
461 461
462 cmd->error = MMC_ERR_NONE; 462 cmd->error = MMC_ERR_NONE;
463 463
464 /* 464 /*
465 * Wait for the request to complete. 465 * Wait for the request to complete.
466 */ 466 */
@@ -477,7 +477,7 @@ static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd)
477 * Read back status. 477 * Read back status.
478 */ 478 */
479 isr = host->isr; 479 isr = host->isr;
480 480
481 /* Card removed? */ 481 /* Card removed? */
482 if (isr & WBSD_INT_CARD) 482 if (isr & WBSD_INT_CARD)
483 cmd->error = MMC_ERR_TIMEOUT; 483 cmd->error = MMC_ERR_TIMEOUT;
@@ -509,13 +509,13 @@ static void wbsd_empty_fifo(struct wbsd_host* host)
509 struct mmc_data* data = host->mrq->cmd->data; 509 struct mmc_data* data = host->mrq->cmd->data;
510 char* buffer; 510 char* buffer;
511 int i, fsr, fifo; 511 int i, fsr, fifo;
512 512
513 /* 513 /*
514 * Handle excessive data. 514 * Handle excessive data.
515 */ 515 */
516 if (data->bytes_xfered == host->size) 516 if (data->bytes_xfered == host->size)
517 return; 517 return;
518 518
519 buffer = wbsd_kmap_sg(host) + host->offset; 519 buffer = wbsd_kmap_sg(host) + host->offset;
520 520
521 /* 521 /*
@@ -527,14 +527,14 @@ static void wbsd_empty_fifo(struct wbsd_host* host)
527 /* 527 /*
528 * The size field in the FSR is broken so we have to 528 * The size field in the FSR is broken so we have to
529 * do some guessing. 529 * do some guessing.
530 */ 530 */
531 if (fsr & WBSD_FIFO_FULL) 531 if (fsr & WBSD_FIFO_FULL)
532 fifo = 16; 532 fifo = 16;
533 else if (fsr & WBSD_FIFO_FUTHRE) 533 else if (fsr & WBSD_FIFO_FUTHRE)
534 fifo = 8; 534 fifo = 8;
535 else 535 else
536 fifo = 1; 536 fifo = 1;
537 537
538 for (i = 0;i < fifo;i++) 538 for (i = 0;i < fifo;i++)
539 { 539 {
540 *buffer = inb(host->base + WBSD_DFR); 540 *buffer = inb(host->base + WBSD_DFR);
@@ -543,23 +543,23 @@ static void wbsd_empty_fifo(struct wbsd_host* host)
543 host->remain--; 543 host->remain--;
544 544
545 data->bytes_xfered++; 545 data->bytes_xfered++;
546 546
547 /* 547 /*
548 * Transfer done? 548 * Transfer done?
549 */ 549 */
550 if (data->bytes_xfered == host->size) 550 if (data->bytes_xfered == host->size)
551 { 551 {
552 wbsd_kunmap_sg(host); 552 wbsd_kunmap_sg(host);
553 return; 553 return;
554 } 554 }
555 555
556 /* 556 /*
557 * End of scatter list entry? 557 * End of scatter list entry?
558 */ 558 */
559 if (host->remain == 0) 559 if (host->remain == 0)
560 { 560 {
561 wbsd_kunmap_sg(host); 561 wbsd_kunmap_sg(host);
562 562
563 /* 563 /*
564 * Get next entry. Check if last. 564 * Get next entry. Check if last.
565 */ 565 */
@@ -572,17 +572,17 @@ static void wbsd_empty_fifo(struct wbsd_host* host)
572 * into the scatter list. 572 * into the scatter list.
573 */ 573 */
574 BUG_ON(1); 574 BUG_ON(1);
575 575
576 host->size = data->bytes_xfered; 576 host->size = data->bytes_xfered;
577 577
578 return; 578 return;
579 } 579 }
580 580
581 buffer = wbsd_kmap_sg(host); 581 buffer = wbsd_kmap_sg(host);
582 } 582 }
583 } 583 }
584 } 584 }
585 585
586 wbsd_kunmap_sg(host); 586 wbsd_kunmap_sg(host);
587 587
588 /* 588 /*
@@ -599,7 +599,7 @@ static void wbsd_fill_fifo(struct wbsd_host* host)
599 struct mmc_data* data = host->mrq->cmd->data; 599 struct mmc_data* data = host->mrq->cmd->data;
600 char* buffer; 600 char* buffer;
601 int i, fsr, fifo; 601 int i, fsr, fifo;
602 602
603 /* 603 /*
604 * Check that we aren't being called after the 604 * Check that we aren't being called after the
605 * entire buffer has been transfered. 605 * entire buffer has been transfered.
@@ -618,7 +618,7 @@ static void wbsd_fill_fifo(struct wbsd_host* host)
618 /* 618 /*
619 * The size field in the FSR is broken so we have to 619 * The size field in the FSR is broken so we have to
620 * do some guessing. 620 * do some guessing.
621 */ 621 */
622 if (fsr & WBSD_FIFO_EMPTY) 622 if (fsr & WBSD_FIFO_EMPTY)
623 fifo = 0; 623 fifo = 0;
624 else if (fsr & WBSD_FIFO_EMTHRE) 624 else if (fsr & WBSD_FIFO_EMTHRE)
@@ -632,9 +632,9 @@ static void wbsd_fill_fifo(struct wbsd_host* host)
632 buffer++; 632 buffer++;
633 host->offset++; 633 host->offset++;
634 host->remain--; 634 host->remain--;
635 635
636 data->bytes_xfered++; 636 data->bytes_xfered++;
637 637
638 /* 638 /*
639 * Transfer done? 639 * Transfer done?
640 */ 640 */
@@ -650,7 +650,7 @@ static void wbsd_fill_fifo(struct wbsd_host* host)
650 if (host->remain == 0) 650 if (host->remain == 0)
651 { 651 {
652 wbsd_kunmap_sg(host); 652 wbsd_kunmap_sg(host);
653 653
654 /* 654 /*
655 * Get next entry. Check if last. 655 * Get next entry. Check if last.
656 */ 656 */
@@ -663,19 +663,19 @@ static void wbsd_fill_fifo(struct wbsd_host* host)
663 * into the scatter list. 663 * into the scatter list.
664 */ 664 */
665 BUG_ON(1); 665 BUG_ON(1);
666 666
667 host->size = data->bytes_xfered; 667 host->size = data->bytes_xfered;
668 668
669 return; 669 return;
670 } 670 }
671 671
672 buffer = wbsd_kmap_sg(host); 672 buffer = wbsd_kmap_sg(host);
673 } 673 }
674 } 674 }
675 } 675 }
676 676
677 wbsd_kunmap_sg(host); 677 wbsd_kunmap_sg(host);
678 678
679 /* 679 /*
680 * The controller stops sending interrupts for 680 * The controller stops sending interrupts for
681 * 'FIFO empty' under certain conditions. So we 681 * 'FIFO empty' under certain conditions. So we
@@ -694,7 +694,7 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data)
694 1 << data->blksz_bits, data->blocks, data->flags); 694 1 << data->blksz_bits, data->blocks, data->flags);
695 DBGF("tsac %d ms nsac %d clk\n", 695 DBGF("tsac %d ms nsac %d clk\n",
696 data->timeout_ns / 1000000, data->timeout_clks); 696 data->timeout_ns / 1000000, data->timeout_clks);
697 697
698 /* 698 /*
699 * Calculate size. 699 * Calculate size.
700 */ 700 */
@@ -708,12 +708,12 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data)
708 wbsd_write_index(host, WBSD_IDX_TAAC, 127); 708 wbsd_write_index(host, WBSD_IDX_TAAC, 127);
709 else 709 else
710 wbsd_write_index(host, WBSD_IDX_TAAC, data->timeout_ns/1000000); 710 wbsd_write_index(host, WBSD_IDX_TAAC, data->timeout_ns/1000000);
711 711
712 if (data->timeout_clks > 255) 712 if (data->timeout_clks > 255)
713 wbsd_write_index(host, WBSD_IDX_NSAC, 255); 713 wbsd_write_index(host, WBSD_IDX_NSAC, 255);
714 else 714 else
715 wbsd_write_index(host, WBSD_IDX_NSAC, data->timeout_clks); 715 wbsd_write_index(host, WBSD_IDX_NSAC, data->timeout_clks);
716 716
717 /* 717 /*
718 * Inform the chip of how large blocks will be 718 * Inform the chip of how large blocks will be
719 * sent. It needs this to determine when to 719 * sent. It needs this to determine when to
@@ -732,7 +732,7 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data)
732 else if (host->bus_width == MMC_BUS_WIDTH_4) 732 else if (host->bus_width == MMC_BUS_WIDTH_4)
733 { 733 {
734 blksize = (1 << data->blksz_bits) + 2 * 4; 734 blksize = (1 << data->blksz_bits) + 2 * 4;
735 735
736 wbsd_write_index(host, WBSD_IDX_PBSMSB, ((blksize >> 4) & 0xF0) 736 wbsd_write_index(host, WBSD_IDX_PBSMSB, ((blksize >> 4) & 0xF0)
737 | WBSD_DATA_WIDTH); 737 | WBSD_DATA_WIDTH);
738 wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF); 738 wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF);
@@ -751,12 +751,12 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data)
751 setup = wbsd_read_index(host, WBSD_IDX_SETUP); 751 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
752 setup |= WBSD_FIFO_RESET; 752 setup |= WBSD_FIFO_RESET;
753 wbsd_write_index(host, WBSD_IDX_SETUP, setup); 753 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
754 754
755 /* 755 /*
756 * DMA transfer? 756 * DMA transfer?
757 */ 757 */
758 if (host->dma >= 0) 758 if (host->dma >= 0)
759 { 759 {
760 /* 760 /*
761 * The buffer for DMA is only 64 kB. 761 * The buffer for DMA is only 64 kB.
762 */ 762 */
@@ -766,17 +766,17 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data)
766 data->error = MMC_ERR_INVALID; 766 data->error = MMC_ERR_INVALID;
767 return; 767 return;
768 } 768 }
769 769
770 /* 770 /*
771 * Transfer data from the SG list to 771 * Transfer data from the SG list to
772 * the DMA buffer. 772 * the DMA buffer.
773 */ 773 */
774 if (data->flags & MMC_DATA_WRITE) 774 if (data->flags & MMC_DATA_WRITE)
775 wbsd_sg_to_dma(host, data); 775 wbsd_sg_to_dma(host, data);
776 776
777 /* 777 /*
778 * Initialise the ISA DMA controller. 778 * Initialise the ISA DMA controller.
779 */ 779 */
780 dmaflags = claim_dma_lock(); 780 dmaflags = claim_dma_lock();
781 disable_dma(host->dma); 781 disable_dma(host->dma);
782 clear_dma_ff(host->dma); 782 clear_dma_ff(host->dma);
@@ -802,17 +802,17 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data)
802 * output to a minimum. 802 * output to a minimum.
803 */ 803 */
804 host->firsterr = 1; 804 host->firsterr = 1;
805 805
806 /* 806 /*
807 * Initialise the SG list. 807 * Initialise the SG list.
808 */ 808 */
809 wbsd_init_sg(host, data); 809 wbsd_init_sg(host, data);
810 810
811 /* 811 /*
812 * Turn off DMA. 812 * Turn off DMA.
813 */ 813 */
814 wbsd_write_index(host, WBSD_IDX_DMA, 0); 814 wbsd_write_index(host, WBSD_IDX_DMA, 0);
815 815
816 /* 816 /*
817 * Set up FIFO threshold levels (and fill 817 * Set up FIFO threshold levels (and fill
818 * buffer if doing a write). 818 * buffer if doing a write).
@@ -828,8 +828,8 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data)
828 WBSD_FIFOEN_EMPTY | 8); 828 WBSD_FIFOEN_EMPTY | 8);
829 wbsd_fill_fifo(host); 829 wbsd_fill_fifo(host);
830 } 830 }
831 } 831 }
832 832
833 data->error = MMC_ERR_NONE; 833 data->error = MMC_ERR_NONE;
834} 834}
835 835
@@ -838,7 +838,7 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data)
838 unsigned long dmaflags; 838 unsigned long dmaflags;
839 int count; 839 int count;
840 u8 status; 840 u8 status;
841 841
842 WARN_ON(host->mrq == NULL); 842 WARN_ON(host->mrq == NULL);
843 843
844 /* 844 /*
@@ -855,7 +855,7 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data)
855 { 855 {
856 status = wbsd_read_index(host, WBSD_IDX_STATUS); 856 status = wbsd_read_index(host, WBSD_IDX_STATUS);
857 } while (status & (WBSD_BLOCK_READ | WBSD_BLOCK_WRITE)); 857 } while (status & (WBSD_BLOCK_READ | WBSD_BLOCK_WRITE));
858 858
859 /* 859 /*
860 * DMA transfer? 860 * DMA transfer?
861 */ 861 */
@@ -865,7 +865,7 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data)
865 * Disable DMA on the host. 865 * Disable DMA on the host.
866 */ 866 */
867 wbsd_write_index(host, WBSD_IDX_DMA, 0); 867 wbsd_write_index(host, WBSD_IDX_DMA, 0);
868 868
869 /* 869 /*
870 * Turn of ISA DMA controller. 870 * Turn of ISA DMA controller.
871 */ 871 */
@@ -874,7 +874,7 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data)
874 clear_dma_ff(host->dma); 874 clear_dma_ff(host->dma);
875 count = get_dma_residue(host->dma); 875 count = get_dma_residue(host->dma);
876 release_dma_lock(dmaflags); 876 release_dma_lock(dmaflags);
877 877
878 /* 878 /*
879 * Any leftover data? 879 * Any leftover data?
880 */ 880 */
@@ -882,7 +882,7 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data)
882 { 882 {
883 printk(KERN_ERR DRIVER_NAME ": Incomplete DMA " 883 printk(KERN_ERR DRIVER_NAME ": Incomplete DMA "
884 "transfer. %d bytes left.\n", count); 884 "transfer. %d bytes left.\n", count);
885 885
886 data->error = MMC_ERR_FAILED; 886 data->error = MMC_ERR_FAILED;
887 } 887 }
888 else 888 else
@@ -893,13 +893,13 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data)
893 */ 893 */
894 if (data->flags & MMC_DATA_READ) 894 if (data->flags & MMC_DATA_READ)
895 wbsd_dma_to_sg(host, data); 895 wbsd_dma_to_sg(host, data);
896 896
897 data->bytes_xfered = host->size; 897 data->bytes_xfered = host->size;
898 } 898 }
899 } 899 }
900 900
901 DBGF("Ending data transfer (%d bytes)\n", data->bytes_xfered); 901 DBGF("Ending data transfer (%d bytes)\n", data->bytes_xfered);
902 902
903 wbsd_request_end(host, host->mrq); 903 wbsd_request_end(host, host->mrq);
904} 904}
905 905
@@ -924,7 +924,7 @@ static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq)
924 cmd = mrq->cmd; 924 cmd = mrq->cmd;
925 925
926 host->mrq = mrq; 926 host->mrq = mrq;
927 927
928 /* 928 /*
929 * If there is no card in the slot then 929 * If there is no card in the slot then
930 * timeout immediatly. 930 * timeout immediatly.
@@ -941,18 +941,18 @@ static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq)
941 if (cmd->data) 941 if (cmd->data)
942 { 942 {
943 wbsd_prepare_data(host, cmd->data); 943 wbsd_prepare_data(host, cmd->data);
944 944
945 if (cmd->data->error != MMC_ERR_NONE) 945 if (cmd->data->error != MMC_ERR_NONE)
946 goto done; 946 goto done;
947 } 947 }
948 948
949 wbsd_send_command(host, cmd); 949 wbsd_send_command(host, cmd);
950 950
951 /* 951 /*
952 * If this is a data transfer the request 952 * If this is a data transfer the request
953 * will be finished after the data has 953 * will be finished after the data has
954 * transfered. 954 * transfered.
955 */ 955 */
956 if (cmd->data && (cmd->error == MMC_ERR_NONE)) 956 if (cmd->data && (cmd->error == MMC_ERR_NONE))
957 { 957 {
958 /* 958 /*
@@ -965,7 +965,7 @@ static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq)
965 965
966 return; 966 return;
967 } 967 }
968 968
969done: 969done:
970 wbsd_request_end(host, mrq); 970 wbsd_request_end(host, mrq);
971 971
@@ -976,7 +976,7 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
976{ 976{
977 struct wbsd_host* host = mmc_priv(mmc); 977 struct wbsd_host* host = mmc_priv(mmc);
978 u8 clk, setup, pwr; 978 u8 clk, setup, pwr;
979 979
980 DBGF("clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", 980 DBGF("clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n",
981 ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select, 981 ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select,
982 ios->vdd, ios->bus_width); 982 ios->vdd, ios->bus_width);
@@ -989,7 +989,7 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
989 */ 989 */
990 if (ios->power_mode == MMC_POWER_OFF) 990 if (ios->power_mode == MMC_POWER_OFF)
991 wbsd_init_device(host); 991 wbsd_init_device(host);
992 992
993 if (ios->clock >= 24000000) 993 if (ios->clock >= 24000000)
994 clk = WBSD_CLK_24M; 994 clk = WBSD_CLK_24M;
995 else if (ios->clock >= 16000000) 995 else if (ios->clock >= 16000000)
@@ -1042,7 +1042,7 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
1042 mod_timer(&host->ignore_timer, jiffies + HZ/100); 1042 mod_timer(&host->ignore_timer, jiffies + HZ/100);
1043 } 1043 }
1044 wbsd_write_index(host, WBSD_IDX_SETUP, setup); 1044 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
1045 1045
1046 /* 1046 /*
1047 * Store bus width for later. Will be used when 1047 * Store bus width for later. Will be used when
1048 * setting up the data transfer. 1048 * setting up the data transfer.
@@ -1128,7 +1128,7 @@ static inline struct mmc_data* wbsd_get_data(struct wbsd_host* host)
1128 WARN_ON(!host->mrq->cmd->data); 1128 WARN_ON(!host->mrq->cmd->data);
1129 if (!host->mrq->cmd->data) 1129 if (!host->mrq->cmd->data)
1130 return NULL; 1130 return NULL;
1131 1131
1132 return host->mrq->cmd->data; 1132 return host->mrq->cmd->data;
1133} 1133}
1134 1134
@@ -1136,72 +1136,67 @@ static void wbsd_tasklet_card(unsigned long param)
1136{ 1136{
1137 struct wbsd_host* host = (struct wbsd_host*)param; 1137 struct wbsd_host* host = (struct wbsd_host*)param;
1138 u8 csr; 1138 u8 csr;
1139 1139 int delay = -1;
1140
1140 spin_lock(&host->lock); 1141 spin_lock(&host->lock);
1141 1142
1142 if (host->flags & WBSD_FIGNORE_DETECT) 1143 if (host->flags & WBSD_FIGNORE_DETECT)
1143 { 1144 {
1144 spin_unlock(&host->lock); 1145 spin_unlock(&host->lock);
1145 return; 1146 return;
1146 } 1147 }
1147 1148
1148 csr = inb(host->base + WBSD_CSR); 1149 csr = inb(host->base + WBSD_CSR);
1149 WARN_ON(csr == 0xff); 1150 WARN_ON(csr == 0xff);
1150 1151
1151 if (csr & WBSD_CARDPRESENT) 1152 if (csr & WBSD_CARDPRESENT)
1152 { 1153 {
1153 if (!(host->flags & WBSD_FCARD_PRESENT)) 1154 if (!(host->flags & WBSD_FCARD_PRESENT))
1154 { 1155 {
1155 DBG("Card inserted\n"); 1156 DBG("Card inserted\n");
1156 host->flags |= WBSD_FCARD_PRESENT; 1157 host->flags |= WBSD_FCARD_PRESENT;
1157
1158 spin_unlock(&host->lock);
1159 1158
1160 /* 1159 delay = 500;
1161 * Delay card detection to allow electrical connections
1162 * to stabilise.
1163 */
1164 mmc_detect_change(host->mmc, msecs_to_jiffies(500));
1165 } 1160 }
1166 else
1167 spin_unlock(&host->lock);
1168 } 1161 }
1169 else if (host->flags & WBSD_FCARD_PRESENT) 1162 else if (host->flags & WBSD_FCARD_PRESENT)
1170 { 1163 {
1171 DBG("Card removed\n"); 1164 DBG("Card removed\n");
1172 host->flags &= ~WBSD_FCARD_PRESENT; 1165 host->flags &= ~WBSD_FCARD_PRESENT;
1173 1166
1174 if (host->mrq) 1167 if (host->mrq)
1175 { 1168 {
1176 printk(KERN_ERR DRIVER_NAME 1169 printk(KERN_ERR DRIVER_NAME
1177 ": Card removed during transfer!\n"); 1170 ": Card removed during transfer!\n");
1178 wbsd_reset(host); 1171 wbsd_reset(host);
1179 1172
1180 host->mrq->cmd->error = MMC_ERR_FAILED; 1173 host->mrq->cmd->error = MMC_ERR_FAILED;
1181 tasklet_schedule(&host->finish_tasklet); 1174 tasklet_schedule(&host->finish_tasklet);
1182 } 1175 }
1183
1184 /*
1185 * Unlock first since we might get a call back.
1186 */
1187 spin_unlock(&host->lock);
1188 1176
1189 mmc_detect_change(host->mmc, 0); 1177 delay = 0;
1190 } 1178 }
1191 else 1179
1192 spin_unlock(&host->lock); 1180 /*
1181 * Unlock first since we might get a call back.
1182 */
1183
1184 spin_unlock(&host->lock);
1185
1186 if (delay != -1)
1187 mmc_detect_change(host->mmc, msecs_to_jiffies(delay));
1193} 1188}
1194 1189
1195static void wbsd_tasklet_fifo(unsigned long param) 1190static void wbsd_tasklet_fifo(unsigned long param)
1196{ 1191{
1197 struct wbsd_host* host = (struct wbsd_host*)param; 1192 struct wbsd_host* host = (struct wbsd_host*)param;
1198 struct mmc_data* data; 1193 struct mmc_data* data;
1199 1194
1200 spin_lock(&host->lock); 1195 spin_lock(&host->lock);
1201 1196
1202 if (!host->mrq) 1197 if (!host->mrq)
1203 goto end; 1198 goto end;
1204 1199
1205 data = wbsd_get_data(host); 1200 data = wbsd_get_data(host);
1206 if (!data) 1201 if (!data)
1207 goto end; 1202 goto end;
@@ -1220,7 +1215,7 @@ static void wbsd_tasklet_fifo(unsigned long param)
1220 tasklet_schedule(&host->finish_tasklet); 1215 tasklet_schedule(&host->finish_tasklet);
1221 } 1216 }
1222 1217
1223end: 1218end:
1224 spin_unlock(&host->lock); 1219 spin_unlock(&host->lock);
1225} 1220}
1226 1221
@@ -1228,23 +1223,23 @@ static void wbsd_tasklet_crc(unsigned long param)
1228{ 1223{
1229 struct wbsd_host* host = (struct wbsd_host*)param; 1224 struct wbsd_host* host = (struct wbsd_host*)param;
1230 struct mmc_data* data; 1225 struct mmc_data* data;
1231 1226
1232 spin_lock(&host->lock); 1227 spin_lock(&host->lock);
1233 1228
1234 if (!host->mrq) 1229 if (!host->mrq)
1235 goto end; 1230 goto end;
1236 1231
1237 data = wbsd_get_data(host); 1232 data = wbsd_get_data(host);
1238 if (!data) 1233 if (!data)
1239 goto end; 1234 goto end;
1240 1235
1241 DBGF("CRC error\n"); 1236 DBGF("CRC error\n");
1242 1237
1243 data->error = MMC_ERR_BADCRC; 1238 data->error = MMC_ERR_BADCRC;
1244 1239
1245 tasklet_schedule(&host->finish_tasklet); 1240 tasklet_schedule(&host->finish_tasklet);
1246 1241
1247end: 1242end:
1248 spin_unlock(&host->lock); 1243 spin_unlock(&host->lock);
1249} 1244}
1250 1245
@@ -1252,23 +1247,23 @@ static void wbsd_tasklet_timeout(unsigned long param)
1252{ 1247{
1253 struct wbsd_host* host = (struct wbsd_host*)param; 1248 struct wbsd_host* host = (struct wbsd_host*)param;
1254 struct mmc_data* data; 1249 struct mmc_data* data;
1255 1250
1256 spin_lock(&host->lock); 1251 spin_lock(&host->lock);
1257 1252
1258 if (!host->mrq) 1253 if (!host->mrq)
1259 goto end; 1254 goto end;
1260 1255
1261 data = wbsd_get_data(host); 1256 data = wbsd_get_data(host);
1262 if (!data) 1257 if (!data)
1263 goto end; 1258 goto end;
1264 1259
1265 DBGF("Timeout\n"); 1260 DBGF("Timeout\n");
1266 1261
1267 data->error = MMC_ERR_TIMEOUT; 1262 data->error = MMC_ERR_TIMEOUT;
1268 1263
1269 tasklet_schedule(&host->finish_tasklet); 1264 tasklet_schedule(&host->finish_tasklet);
1270 1265
1271end: 1266end:
1272 spin_unlock(&host->lock); 1267 spin_unlock(&host->lock);
1273} 1268}
1274 1269
@@ -1276,20 +1271,20 @@ static void wbsd_tasklet_finish(unsigned long param)
1276{ 1271{
1277 struct wbsd_host* host = (struct wbsd_host*)param; 1272 struct wbsd_host* host = (struct wbsd_host*)param;
1278 struct mmc_data* data; 1273 struct mmc_data* data;
1279 1274
1280 spin_lock(&host->lock); 1275 spin_lock(&host->lock);
1281 1276
1282 WARN_ON(!host->mrq); 1277 WARN_ON(!host->mrq);
1283 if (!host->mrq) 1278 if (!host->mrq)
1284 goto end; 1279 goto end;
1285 1280
1286 data = wbsd_get_data(host); 1281 data = wbsd_get_data(host);
1287 if (!data) 1282 if (!data)
1288 goto end; 1283 goto end;
1289 1284
1290 wbsd_finish_data(host, data); 1285 wbsd_finish_data(host, data);
1291 1286
1292end: 1287end:
1293 spin_unlock(&host->lock); 1288 spin_unlock(&host->lock);
1294} 1289}
1295 1290
@@ -1297,7 +1292,7 @@ static void wbsd_tasklet_block(unsigned long param)
1297{ 1292{
1298 struct wbsd_host* host = (struct wbsd_host*)param; 1293 struct wbsd_host* host = (struct wbsd_host*)param;
1299 struct mmc_data* data; 1294 struct mmc_data* data;
1300 1295
1301 spin_lock(&host->lock); 1296 spin_lock(&host->lock);
1302 1297
1303 if ((wbsd_read_index(host, WBSD_IDX_CRCSTATUS) & WBSD_CRC_MASK) != 1298 if ((wbsd_read_index(host, WBSD_IDX_CRCSTATUS) & WBSD_CRC_MASK) !=
@@ -1306,15 +1301,15 @@ static void wbsd_tasklet_block(unsigned long param)
1306 data = wbsd_get_data(host); 1301 data = wbsd_get_data(host);
1307 if (!data) 1302 if (!data)
1308 goto end; 1303 goto end;
1309 1304
1310 DBGF("CRC error\n"); 1305 DBGF("CRC error\n");
1311 1306
1312 data->error = MMC_ERR_BADCRC; 1307 data->error = MMC_ERR_BADCRC;
1313 1308
1314 tasklet_schedule(&host->finish_tasklet); 1309 tasklet_schedule(&host->finish_tasklet);
1315 } 1310 }
1316 1311
1317end: 1312end:
1318 spin_unlock(&host->lock); 1313 spin_unlock(&host->lock);
1319} 1314}
1320 1315
@@ -1326,7 +1321,7 @@ static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs)
1326{ 1321{
1327 struct wbsd_host* host = dev_id; 1322 struct wbsd_host* host = dev_id;
1328 int isr; 1323 int isr;
1329 1324
1330 isr = inb(host->base + WBSD_ISR); 1325 isr = inb(host->base + WBSD_ISR);
1331 1326
1332 /* 1327 /*
@@ -1334,7 +1329,7 @@ static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs)
1334 */ 1329 */
1335 if (isr == 0xff || isr == 0x00) 1330 if (isr == 0xff || isr == 0x00)
1336 return IRQ_NONE; 1331 return IRQ_NONE;
1337 1332
1338 host->isr |= isr; 1333 host->isr |= isr;
1339 1334
1340 /* 1335 /*
@@ -1352,7 +1347,7 @@ static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs)
1352 tasklet_hi_schedule(&host->block_tasklet); 1347 tasklet_hi_schedule(&host->block_tasklet);
1353 if (isr & WBSD_INT_TC) 1348 if (isr & WBSD_INT_TC)
1354 tasklet_schedule(&host->finish_tasklet); 1349 tasklet_schedule(&host->finish_tasklet);
1355 1350
1356 return IRQ_HANDLED; 1351 return IRQ_HANDLED;
1357} 1352}
1358 1353
@@ -1370,14 +1365,14 @@ static int __devinit wbsd_alloc_mmc(struct device* dev)
1370{ 1365{
1371 struct mmc_host* mmc; 1366 struct mmc_host* mmc;
1372 struct wbsd_host* host; 1367 struct wbsd_host* host;
1373 1368
1374 /* 1369 /*
1375 * Allocate MMC structure. 1370 * Allocate MMC structure.
1376 */ 1371 */
1377 mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev); 1372 mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev);
1378 if (!mmc) 1373 if (!mmc)
1379 return -ENOMEM; 1374 return -ENOMEM;
1380 1375
1381 host = mmc_priv(mmc); 1376 host = mmc_priv(mmc);
1382 host->mmc = mmc; 1377 host->mmc = mmc;
1383 1378
@@ -1391,37 +1386,37 @@ static int __devinit wbsd_alloc_mmc(struct device* dev)
1391 mmc->f_max = 24000000; 1386 mmc->f_max = 24000000;
1392 mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34; 1387 mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34;
1393 mmc->caps = MMC_CAP_4_BIT_DATA; 1388 mmc->caps = MMC_CAP_4_BIT_DATA;
1394 1389
1395 spin_lock_init(&host->lock); 1390 spin_lock_init(&host->lock);
1396 1391
1397 /* 1392 /*
1398 * Set up timers 1393 * Set up timers
1399 */ 1394 */
1400 init_timer(&host->ignore_timer); 1395 init_timer(&host->ignore_timer);
1401 host->ignore_timer.data = (unsigned long)host; 1396 host->ignore_timer.data = (unsigned long)host;
1402 host->ignore_timer.function = wbsd_reset_ignore; 1397 host->ignore_timer.function = wbsd_reset_ignore;
1403 1398
1404 /* 1399 /*
1405 * Maximum number of segments. Worst case is one sector per segment 1400 * Maximum number of segments. Worst case is one sector per segment
1406 * so this will be 64kB/512. 1401 * so this will be 64kB/512.
1407 */ 1402 */
1408 mmc->max_hw_segs = 128; 1403 mmc->max_hw_segs = 128;
1409 mmc->max_phys_segs = 128; 1404 mmc->max_phys_segs = 128;
1410 1405
1411 /* 1406 /*
1412 * Maximum number of sectors in one transfer. Also limited by 64kB 1407 * Maximum number of sectors in one transfer. Also limited by 64kB
1413 * buffer. 1408 * buffer.
1414 */ 1409 */
1415 mmc->max_sectors = 128; 1410 mmc->max_sectors = 128;
1416 1411
1417 /* 1412 /*
1418 * Maximum segment size. Could be one segment with the maximum number 1413 * Maximum segment size. Could be one segment with the maximum number
1419 * of segments. 1414 * of segments.
1420 */ 1415 */
1421 mmc->max_seg_size = mmc->max_sectors * 512; 1416 mmc->max_seg_size = mmc->max_sectors * 512;
1422 1417
1423 dev_set_drvdata(dev, mmc); 1418 dev_set_drvdata(dev, mmc);
1424 1419
1425 return 0; 1420 return 0;
1426} 1421}
1427 1422
@@ -1429,18 +1424,18 @@ static void __devexit wbsd_free_mmc(struct device* dev)
1429{ 1424{
1430 struct mmc_host* mmc; 1425 struct mmc_host* mmc;
1431 struct wbsd_host* host; 1426 struct wbsd_host* host;
1432 1427
1433 mmc = dev_get_drvdata(dev); 1428 mmc = dev_get_drvdata(dev);
1434 if (!mmc) 1429 if (!mmc)
1435 return; 1430 return;
1436 1431
1437 host = mmc_priv(mmc); 1432 host = mmc_priv(mmc);
1438 BUG_ON(host == NULL); 1433 BUG_ON(host == NULL);
1439 1434
1440 del_timer_sync(&host->ignore_timer); 1435 del_timer_sync(&host->ignore_timer);
1441 1436
1442 mmc_free_host(mmc); 1437 mmc_free_host(mmc);
1443 1438
1444 dev_set_drvdata(dev, NULL); 1439 dev_set_drvdata(dev, NULL);
1445} 1440}
1446 1441
@@ -1452,7 +1447,7 @@ static int __devinit wbsd_scan(struct wbsd_host* host)
1452{ 1447{
1453 int i, j, k; 1448 int i, j, k;
1454 int id; 1449 int id;
1455 1450
1456 /* 1451 /*
1457 * Iterate through all ports, all codes to 1452 * Iterate through all ports, all codes to
1458 * find hardware that is in our known list. 1453 * find hardware that is in our known list.
@@ -1461,32 +1456,32 @@ static int __devinit wbsd_scan(struct wbsd_host* host)
1461 { 1456 {
1462 if (!request_region(config_ports[i], 2, DRIVER_NAME)) 1457 if (!request_region(config_ports[i], 2, DRIVER_NAME))
1463 continue; 1458 continue;
1464 1459
1465 for (j = 0;j < sizeof(unlock_codes)/sizeof(int);j++) 1460 for (j = 0;j < sizeof(unlock_codes)/sizeof(int);j++)
1466 { 1461 {
1467 id = 0xFFFF; 1462 id = 0xFFFF;
1468 1463
1469 outb(unlock_codes[j], config_ports[i]); 1464 outb(unlock_codes[j], config_ports[i]);
1470 outb(unlock_codes[j], config_ports[i]); 1465 outb(unlock_codes[j], config_ports[i]);
1471 1466
1472 outb(WBSD_CONF_ID_HI, config_ports[i]); 1467 outb(WBSD_CONF_ID_HI, config_ports[i]);
1473 id = inb(config_ports[i] + 1) << 8; 1468 id = inb(config_ports[i] + 1) << 8;
1474 1469
1475 outb(WBSD_CONF_ID_LO, config_ports[i]); 1470 outb(WBSD_CONF_ID_LO, config_ports[i]);
1476 id |= inb(config_ports[i] + 1); 1471 id |= inb(config_ports[i] + 1);
1477 1472
1478 for (k = 0;k < sizeof(valid_ids)/sizeof(int);k++) 1473 for (k = 0;k < sizeof(valid_ids)/sizeof(int);k++)
1479 { 1474 {
1480 if (id == valid_ids[k]) 1475 if (id == valid_ids[k])
1481 { 1476 {
1482 host->chip_id = id; 1477 host->chip_id = id;
1483 host->config = config_ports[i]; 1478 host->config = config_ports[i];
1484 host->unlock_code = unlock_codes[i]; 1479 host->unlock_code = unlock_codes[i];
1485 1480
1486 return 0; 1481 return 0;
1487 } 1482 }
1488 } 1483 }
1489 1484
1490 if (id != 0xFFFF) 1485 if (id != 0xFFFF)
1491 { 1486 {
1492 DBG("Unknown hardware (id %x) found at %x\n", 1487 DBG("Unknown hardware (id %x) found at %x\n",
@@ -1495,10 +1490,10 @@ static int __devinit wbsd_scan(struct wbsd_host* host)
1495 1490
1496 outb(LOCK_CODE, config_ports[i]); 1491 outb(LOCK_CODE, config_ports[i]);
1497 } 1492 }
1498 1493
1499 release_region(config_ports[i], 2); 1494 release_region(config_ports[i], 2);
1500 } 1495 }
1501 1496
1502 return -ENODEV; 1497 return -ENODEV;
1503} 1498}
1504 1499
@@ -1510,12 +1505,12 @@ static int __devinit wbsd_request_region(struct wbsd_host* host, int base)
1510{ 1505{
1511 if (io & 0x7) 1506 if (io & 0x7)
1512 return -EINVAL; 1507 return -EINVAL;
1513 1508
1514 if (!request_region(base, 8, DRIVER_NAME)) 1509 if (!request_region(base, 8, DRIVER_NAME))
1515 return -EIO; 1510 return -EIO;
1516 1511
1517 host->base = io; 1512 host->base = io;
1518 1513
1519 return 0; 1514 return 0;
1520} 1515}
1521 1516
@@ -1523,12 +1518,12 @@ static void __devexit wbsd_release_regions(struct wbsd_host* host)
1523{ 1518{
1524 if (host->base) 1519 if (host->base)
1525 release_region(host->base, 8); 1520 release_region(host->base, 8);
1526 1521
1527 host->base = 0; 1522 host->base = 0;
1528 1523
1529 if (host->config) 1524 if (host->config)
1530 release_region(host->config, 2); 1525 release_region(host->config, 2);
1531 1526
1532 host->config = 0; 1527 host->config = 0;
1533} 1528}
1534 1529
@@ -1540,10 +1535,10 @@ static void __devinit wbsd_request_dma(struct wbsd_host* host, int dma)
1540{ 1535{
1541 if (dma < 0) 1536 if (dma < 0)
1542 return; 1537 return;
1543 1538
1544 if (request_dma(dma, DRIVER_NAME)) 1539 if (request_dma(dma, DRIVER_NAME))
1545 goto err; 1540 goto err;
1546 1541
1547 /* 1542 /*
1548 * We need to allocate a special buffer in 1543 * We need to allocate a special buffer in
1549 * order for ISA to be able to DMA to it. 1544 * order for ISA to be able to DMA to it.
@@ -1558,7 +1553,7 @@ static void __devinit wbsd_request_dma(struct wbsd_host* host, int dma)
1558 */ 1553 */
1559 host->dma_addr = dma_map_single(host->mmc->dev, host->dma_buffer, 1554 host->dma_addr = dma_map_single(host->mmc->dev, host->dma_buffer,
1560 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL); 1555 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1561 1556
1562 /* 1557 /*
1563 * ISA DMA must be aligned on a 64k basis. 1558 * ISA DMA must be aligned on a 64k basis.
1564 */ 1559 */
@@ -1571,19 +1566,19 @@ static void __devinit wbsd_request_dma(struct wbsd_host* host, int dma)
1571 goto kfree; 1566 goto kfree;
1572 1567
1573 host->dma = dma; 1568 host->dma = dma;
1574 1569
1575 return; 1570 return;
1576 1571
1577kfree: 1572kfree:
1578 /* 1573 /*
1579 * If we've gotten here then there is some kind of alignment bug 1574 * If we've gotten here then there is some kind of alignment bug
1580 */ 1575 */
1581 BUG_ON(1); 1576 BUG_ON(1);
1582 1577
1583 dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE, 1578 dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE,
1584 DMA_BIDIRECTIONAL); 1579 DMA_BIDIRECTIONAL);
1585 host->dma_addr = (dma_addr_t)NULL; 1580 host->dma_addr = (dma_addr_t)NULL;
1586 1581
1587 kfree(host->dma_buffer); 1582 kfree(host->dma_buffer);
1588 host->dma_buffer = NULL; 1583 host->dma_buffer = NULL;
1589 1584
@@ -1604,7 +1599,7 @@ static void __devexit wbsd_release_dma(struct wbsd_host* host)
1604 kfree(host->dma_buffer); 1599 kfree(host->dma_buffer);
1605 if (host->dma >= 0) 1600 if (host->dma >= 0)
1606 free_dma(host->dma); 1601 free_dma(host->dma);
1607 1602
1608 host->dma = -1; 1603 host->dma = -1;
1609 host->dma_buffer = NULL; 1604 host->dma_buffer = NULL;
1610 host->dma_addr = (dma_addr_t)NULL; 1605 host->dma_addr = (dma_addr_t)NULL;
@@ -1617,7 +1612,7 @@ static void __devexit wbsd_release_dma(struct wbsd_host* host)
1617static int __devinit wbsd_request_irq(struct wbsd_host* host, int irq) 1612static int __devinit wbsd_request_irq(struct wbsd_host* host, int irq)
1618{ 1613{
1619 int ret; 1614 int ret;
1620 1615
1621 /* 1616 /*
1622 * Allocate interrupt. 1617 * Allocate interrupt.
1623 */ 1618 */
@@ -1625,7 +1620,7 @@ static int __devinit wbsd_request_irq(struct wbsd_host* host, int irq)
1625 ret = request_irq(irq, wbsd_irq, SA_SHIRQ, DRIVER_NAME, host); 1620 ret = request_irq(irq, wbsd_irq, SA_SHIRQ, DRIVER_NAME, host);
1626 if (ret) 1621 if (ret)
1627 return ret; 1622 return ret;
1628 1623
1629 host->irq = irq; 1624 host->irq = irq;
1630 1625
1631 /* 1626 /*
@@ -1637,7 +1632,7 @@ static int __devinit wbsd_request_irq(struct wbsd_host* host, int irq)
1637 tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, (unsigned long)host); 1632 tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, (unsigned long)host);
1638 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, (unsigned long)host); 1633 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, (unsigned long)host);
1639 tasklet_init(&host->block_tasklet, wbsd_tasklet_block, (unsigned long)host); 1634 tasklet_init(&host->block_tasklet, wbsd_tasklet_block, (unsigned long)host);
1640 1635
1641 return 0; 1636 return 0;
1642} 1637}
1643 1638
@@ -1647,9 +1642,9 @@ static void __devexit wbsd_release_irq(struct wbsd_host* host)
1647 return; 1642 return;
1648 1643
1649 free_irq(host->irq, host); 1644 free_irq(host->irq, host);
1650 1645
1651 host->irq = 0; 1646 host->irq = 0;
1652 1647
1653 tasklet_kill(&host->card_tasklet); 1648 tasklet_kill(&host->card_tasklet);
1654 tasklet_kill(&host->fifo_tasklet); 1649 tasklet_kill(&host->fifo_tasklet);
1655 tasklet_kill(&host->crc_tasklet); 1650 tasklet_kill(&host->crc_tasklet);
@@ -1666,7 +1661,7 @@ static int __devinit wbsd_request_resources(struct wbsd_host* host,
1666 int base, int irq, int dma) 1661 int base, int irq, int dma)
1667{ 1662{
1668 int ret; 1663 int ret;
1669 1664
1670 /* 1665 /*
1671 * Allocate I/O ports. 1666 * Allocate I/O ports.
1672 */ 1667 */
@@ -1685,7 +1680,7 @@ static int __devinit wbsd_request_resources(struct wbsd_host* host,
1685 * Allocate DMA. 1680 * Allocate DMA.
1686 */ 1681 */
1687 wbsd_request_dma(host, dma); 1682 wbsd_request_dma(host, dma);
1688 1683
1689 return 0; 1684 return 0;
1690} 1685}
1691 1686
@@ -1708,7 +1703,7 @@ static void __devinit wbsd_chip_config(struct wbsd_host* host)
1708{ 1703{
1709 /* 1704 /*
1710 * Reset the chip. 1705 * Reset the chip.
1711 */ 1706 */
1712 wbsd_write_config(host, WBSD_CONF_SWRST, 1); 1707 wbsd_write_config(host, WBSD_CONF_SWRST, 1);
1713 wbsd_write_config(host, WBSD_CONF_SWRST, 0); 1708 wbsd_write_config(host, WBSD_CONF_SWRST, 0);
1714 1709
@@ -1716,23 +1711,23 @@ static void __devinit wbsd_chip_config(struct wbsd_host* host)
1716 * Select SD/MMC function. 1711 * Select SD/MMC function.
1717 */ 1712 */
1718 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD); 1713 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1719 1714
1720 /* 1715 /*
1721 * Set up card detection. 1716 * Set up card detection.
1722 */ 1717 */
1723 wbsd_write_config(host, WBSD_CONF_PINS, WBSD_PINS_DETECT_GP11); 1718 wbsd_write_config(host, WBSD_CONF_PINS, WBSD_PINS_DETECT_GP11);
1724 1719
1725 /* 1720 /*
1726 * Configure chip 1721 * Configure chip
1727 */ 1722 */
1728 wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8); 1723 wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8);
1729 wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff); 1724 wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff);
1730 1725
1731 wbsd_write_config(host, WBSD_CONF_IRQ, host->irq); 1726 wbsd_write_config(host, WBSD_CONF_IRQ, host->irq);
1732 1727
1733 if (host->dma >= 0) 1728 if (host->dma >= 0)
1734 wbsd_write_config(host, WBSD_CONF_DRQ, host->dma); 1729 wbsd_write_config(host, WBSD_CONF_DRQ, host->dma);
1735 1730
1736 /* 1731 /*
1737 * Enable and power up chip. 1732 * Enable and power up chip.
1738 */ 1733 */
@@ -1743,26 +1738,26 @@ static void __devinit wbsd_chip_config(struct wbsd_host* host)
1743/* 1738/*
1744 * Check that configured resources are correct. 1739 * Check that configured resources are correct.
1745 */ 1740 */
1746 1741
1747static int __devinit wbsd_chip_validate(struct wbsd_host* host) 1742static int __devinit wbsd_chip_validate(struct wbsd_host* host)
1748{ 1743{
1749 int base, irq, dma; 1744 int base, irq, dma;
1750 1745
1751 /* 1746 /*
1752 * Select SD/MMC function. 1747 * Select SD/MMC function.
1753 */ 1748 */
1754 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD); 1749 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1755 1750
1756 /* 1751 /*
1757 * Read configuration. 1752 * Read configuration.
1758 */ 1753 */
1759 base = wbsd_read_config(host, WBSD_CONF_PORT_HI) << 8; 1754 base = wbsd_read_config(host, WBSD_CONF_PORT_HI) << 8;
1760 base |= wbsd_read_config(host, WBSD_CONF_PORT_LO); 1755 base |= wbsd_read_config(host, WBSD_CONF_PORT_LO);
1761 1756
1762 irq = wbsd_read_config(host, WBSD_CONF_IRQ); 1757 irq = wbsd_read_config(host, WBSD_CONF_IRQ);
1763 1758
1764 dma = wbsd_read_config(host, WBSD_CONF_DRQ); 1759 dma = wbsd_read_config(host, WBSD_CONF_DRQ);
1765 1760
1766 /* 1761 /*
1767 * Validate against given configuration. 1762 * Validate against given configuration.
1768 */ 1763 */
@@ -1772,7 +1767,7 @@ static int __devinit wbsd_chip_validate(struct wbsd_host* host)
1772 return 0; 1767 return 0;
1773 if ((dma != host->dma) && (host->dma != -1)) 1768 if ((dma != host->dma) && (host->dma != -1))
1774 return 0; 1769 return 0;
1775 1770
1776 return 1; 1771 return 1;
1777} 1772}
1778 1773
@@ -1788,14 +1783,14 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma,
1788 struct wbsd_host* host = NULL; 1783 struct wbsd_host* host = NULL;
1789 struct mmc_host* mmc = NULL; 1784 struct mmc_host* mmc = NULL;
1790 int ret; 1785 int ret;
1791 1786
1792 ret = wbsd_alloc_mmc(dev); 1787 ret = wbsd_alloc_mmc(dev);
1793 if (ret) 1788 if (ret)
1794 return ret; 1789 return ret;
1795 1790
1796 mmc = dev_get_drvdata(dev); 1791 mmc = dev_get_drvdata(dev);
1797 host = mmc_priv(mmc); 1792 host = mmc_priv(mmc);
1798 1793
1799 /* 1794 /*
1800 * Scan for hardware. 1795 * Scan for hardware.
1801 */ 1796 */
@@ -1814,7 +1809,7 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma,
1814 return ret; 1809 return ret;
1815 } 1810 }
1816 } 1811 }
1817 1812
1818 /* 1813 /*
1819 * Request resources. 1814 * Request resources.
1820 */ 1815 */
@@ -1825,7 +1820,7 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma,
1825 wbsd_free_mmc(dev); 1820 wbsd_free_mmc(dev);
1826 return ret; 1821 return ret;
1827 } 1822 }
1828 1823
1829 /* 1824 /*
1830 * See if chip needs to be configured. 1825 * See if chip needs to be configured.
1831 */ 1826 */
@@ -1842,7 +1837,7 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma,
1842 } 1837 }
1843 else 1838 else
1844 wbsd_chip_config(host); 1839 wbsd_chip_config(host);
1845 1840
1846 /* 1841 /*
1847 * Power Management stuff. No idea how this works. 1842 * Power Management stuff. No idea how this works.
1848 * Not tested. 1843 * Not tested.
@@ -1860,7 +1855,7 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma,
1860 * Reset the chip into a known state. 1855 * Reset the chip into a known state.
1861 */ 1856 */
1862 wbsd_init_device(host); 1857 wbsd_init_device(host);
1863 1858
1864 mmc_add_host(mmc); 1859 mmc_add_host(mmc);
1865 1860
1866 printk(KERN_INFO "%s: W83L51xD", mmc_hostname(mmc)); 1861 printk(KERN_INFO "%s: W83L51xD", mmc_hostname(mmc));
@@ -1882,12 +1877,12 @@ static void __devexit wbsd_shutdown(struct device* dev, int pnp)
1882{ 1877{
1883 struct mmc_host* mmc = dev_get_drvdata(dev); 1878 struct mmc_host* mmc = dev_get_drvdata(dev);
1884 struct wbsd_host* host; 1879 struct wbsd_host* host;
1885 1880
1886 if (!mmc) 1881 if (!mmc)
1887 return; 1882 return;
1888 1883
1889 host = mmc_priv(mmc); 1884 host = mmc_priv(mmc);
1890 1885
1891 mmc_remove_host(mmc); 1886 mmc_remove_host(mmc);
1892 1887
1893 if (!pnp) 1888 if (!pnp)
@@ -1900,9 +1895,9 @@ static void __devexit wbsd_shutdown(struct device* dev, int pnp)
1900 wbsd_write_config(host, WBSD_CONF_ENABLE, 0); 1895 wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
1901 wbsd_lock_config(host); 1896 wbsd_lock_config(host);
1902 } 1897 }
1903 1898
1904 wbsd_release_resources(host); 1899 wbsd_release_resources(host);
1905 1900
1906 wbsd_free_mmc(dev); 1901 wbsd_free_mmc(dev);
1907} 1902}
1908 1903
@@ -1932,7 +1927,7 @@ static int __devinit
1932wbsd_pnp_probe(struct pnp_dev * pnpdev, const struct pnp_device_id *dev_id) 1927wbsd_pnp_probe(struct pnp_dev * pnpdev, const struct pnp_device_id *dev_id)
1933{ 1928{
1934 int io, irq, dma; 1929 int io, irq, dma;
1935 1930
1936 /* 1931 /*
1937 * Get resources from PnP layer. 1932 * Get resources from PnP layer.
1938 */ 1933 */
@@ -1942,9 +1937,9 @@ wbsd_pnp_probe(struct pnp_dev * pnpdev, const struct pnp_device_id *dev_id)
1942 dma = pnp_dma(pnpdev, 0); 1937 dma = pnp_dma(pnpdev, 0);
1943 else 1938 else
1944 dma = -1; 1939 dma = -1;
1945 1940
1946 DBGF("PnP resources: port %3x irq %d dma %d\n", io, irq, dma); 1941 DBGF("PnP resources: port %3x irq %d dma %d\n", io, irq, dma);
1947 1942
1948 return wbsd_init(&pnpdev->dev, io, irq, dma, 1); 1943 return wbsd_init(&pnpdev->dev, io, irq, dma, 1);
1949} 1944}
1950 1945
@@ -1985,7 +1980,7 @@ static struct device_driver wbsd_driver = {
1985 .bus = &platform_bus_type, 1980 .bus = &platform_bus_type,
1986 .probe = wbsd_probe, 1981 .probe = wbsd_probe,
1987 .remove = wbsd_remove, 1982 .remove = wbsd_remove,
1988 1983
1989 .suspend = wbsd_suspend, 1984 .suspend = wbsd_suspend,
1990 .resume = wbsd_resume, 1985 .resume = wbsd_resume,
1991}; 1986};
@@ -2008,7 +2003,7 @@ static struct pnp_driver wbsd_pnp_driver = {
2008static int __init wbsd_drv_init(void) 2003static int __init wbsd_drv_init(void)
2009{ 2004{
2010 int result; 2005 int result;
2011 2006
2012 printk(KERN_INFO DRIVER_NAME 2007 printk(KERN_INFO DRIVER_NAME
2013 ": Winbond W83L51xD SD/MMC card interface driver, " 2008 ": Winbond W83L51xD SD/MMC card interface driver, "
2014 DRIVER_VERSION "\n"); 2009 DRIVER_VERSION "\n");
@@ -2023,8 +2018,8 @@ static int __init wbsd_drv_init(void)
2023 return result; 2018 return result;
2024 } 2019 }
2025 2020
2026#endif /* CONFIG_PNP */ 2021#endif /* CONFIG_PNP */
2027 2022
2028 if (nopnp) 2023 if (nopnp)
2029 { 2024 {
2030 result = driver_register(&wbsd_driver); 2025 result = driver_register(&wbsd_driver);
@@ -2046,13 +2041,13 @@ static void __exit wbsd_drv_exit(void)
2046 2041
2047 if (!nopnp) 2042 if (!nopnp)
2048 pnp_unregister_driver(&wbsd_pnp_driver); 2043 pnp_unregister_driver(&wbsd_pnp_driver);
2049 2044
2050#endif /* CONFIG_PNP */ 2045#endif /* CONFIG_PNP */
2051 2046
2052 if (nopnp) 2047 if (nopnp)
2053 { 2048 {
2054 platform_device_unregister(wbsd_device); 2049 platform_device_unregister(wbsd_device);
2055 2050
2056 driver_unregister(&wbsd_driver); 2051 driver_unregister(&wbsd_driver);
2057 } 2052 }
2058 2053
diff --git a/drivers/mmc/wbsd.h b/drivers/mmc/wbsd.h
index 9005b5241b3c..249baa701cb0 100644
--- a/drivers/mmc/wbsd.h
+++ b/drivers/mmc/wbsd.h
@@ -139,51 +139,50 @@
139struct wbsd_host 139struct wbsd_host
140{ 140{
141 struct mmc_host* mmc; /* MMC structure */ 141 struct mmc_host* mmc; /* MMC structure */
142 142
143 spinlock_t lock; /* Mutex */ 143 spinlock_t lock; /* Mutex */
144 144
145 int flags; /* Driver states */ 145 int flags; /* Driver states */
146 146
147#define WBSD_FCARD_PRESENT (1<<0) /* Card is present */ 147#define WBSD_FCARD_PRESENT (1<<0) /* Card is present */
148#define WBSD_FIGNORE_DETECT (1<<1) /* Ignore card detection */ 148#define WBSD_FIGNORE_DETECT (1<<1) /* Ignore card detection */
149 149
150 struct mmc_request* mrq; /* Current request */ 150 struct mmc_request* mrq; /* Current request */
151 151
152 u8 isr; /* Accumulated ISR */ 152 u8 isr; /* Accumulated ISR */
153 153
154 struct scatterlist* cur_sg; /* Current SG entry */ 154 struct scatterlist* cur_sg; /* Current SG entry */
155 unsigned int num_sg; /* Number of entries left */ 155 unsigned int num_sg; /* Number of entries left */
156 void* mapped_sg; /* vaddr of mapped sg */ 156 void* mapped_sg; /* vaddr of mapped sg */
157 157
158 unsigned int offset; /* Offset into current entry */ 158 unsigned int offset; /* Offset into current entry */
159 unsigned int remain; /* Data left in curren entry */ 159 unsigned int remain; /* Data left in curren entry */
160 160
161 int size; /* Total size of transfer */ 161 int size; /* Total size of transfer */
162 162
163 char* dma_buffer; /* ISA DMA buffer */ 163 char* dma_buffer; /* ISA DMA buffer */
164 dma_addr_t dma_addr; /* Physical address for same */ 164 dma_addr_t dma_addr; /* Physical address for same */
165 165
166 int firsterr; /* See fifo functions */ 166 int firsterr; /* See fifo functions */
167 167
168 u8 clk; /* Current clock speed */ 168 u8 clk; /* Current clock speed */
169 unsigned char bus_width; /* Current bus width */ 169 unsigned char bus_width; /* Current bus width */
170 170
171 int config; /* Config port */ 171 int config; /* Config port */
172 u8 unlock_code; /* Code to unlock config */ 172 u8 unlock_code; /* Code to unlock config */
173 173
174 int chip_id; /* ID of controller */ 174 int chip_id; /* ID of controller */
175 175
176 int base; /* I/O port base */ 176 int base; /* I/O port base */
177 int irq; /* Interrupt */ 177 int irq; /* Interrupt */
178 int dma; /* DMA channel */ 178 int dma; /* DMA channel */
179 179
180 struct tasklet_struct card_tasklet; /* Tasklet structures */ 180 struct tasklet_struct card_tasklet; /* Tasklet structures */
181 struct tasklet_struct fifo_tasklet; 181 struct tasklet_struct fifo_tasklet;
182 struct tasklet_struct crc_tasklet; 182 struct tasklet_struct crc_tasklet;
183 struct tasklet_struct timeout_tasklet; 183 struct tasklet_struct timeout_tasklet;
184 struct tasklet_struct finish_tasklet; 184 struct tasklet_struct finish_tasklet;
185 struct tasklet_struct block_tasklet; 185 struct tasklet_struct block_tasklet;
186 186
187 struct timer_list detect_timer; /* Card detection timer */
188 struct timer_list ignore_timer; /* Ignore detection timer */ 187 struct timer_list ignore_timer; /* Ignore detection timer */
189}; 188};
diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index 52c77cbe8c62..1f0302735416 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -160,7 +160,7 @@ static int __init com90io_probe(struct net_device *dev)
160 return -ENODEV; 160 return -ENODEV;
161 } 161 }
162 if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com90io probe")) { 162 if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com90io probe")) {
163 BUGMSG(D_INIT_REASONS, "IO check_region %x-%x failed.\n", 163 BUGMSG(D_INIT_REASONS, "IO request_region %x-%x failed.\n",
164 ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1); 164 ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
165 return -ENXIO; 165 return -ENXIO;
166 } 166 }
@@ -242,7 +242,7 @@ static int __init com90io_found(struct net_device *dev)
242 BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq); 242 BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq);
243 return -ENODEV; 243 return -ENODEV;
244 } 244 }
245 /* Reserve the I/O region - guaranteed to work by check_region */ 245 /* Reserve the I/O region */
246 if (!request_region(dev->base_addr, ARCNET_TOTAL_SIZE, "arcnet (COM90xx-IO)")) { 246 if (!request_region(dev->base_addr, ARCNET_TOTAL_SIZE, "arcnet (COM90xx-IO)")) {
247 free_irq(dev->irq, dev); 247 free_irq(dev->irq, dev);
248 return -EBUSY; 248 return -EBUSY;
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 83598e32179c..3a2ace01e444 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -5015,6 +5015,7 @@ static struct ethtool_ops bnx2_ethtool_ops = {
5015 .phys_id = bnx2_phys_id, 5015 .phys_id = bnx2_phys_id,
5016 .get_stats_count = bnx2_get_stats_count, 5016 .get_stats_count = bnx2_get_stats_count,
5017 .get_ethtool_stats = bnx2_get_ethtool_stats, 5017 .get_ethtool_stats = bnx2_get_ethtool_stats,
5018 .get_perm_addr = ethtool_op_get_perm_addr,
5018}; 5019};
5019 5020
5020/* Called with rtnl_lock */ 5021/* Called with rtnl_lock */
@@ -5442,6 +5443,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
5442 pci_set_drvdata(pdev, dev); 5443 pci_set_drvdata(pdev, dev);
5443 5444
5444 memcpy(dev->dev_addr, bp->mac_addr, 6); 5445 memcpy(dev->dev_addr, bp->mac_addr, 6);
5446 memcpy(dev->perm_addr, bp->mac_addr, 6);
5445 bp->name = board_info[ent->driver_data].name, 5447 bp->name = board_info[ent->driver_data].name,
5446 printk(KERN_INFO "%s: %s (%c%d) PCI%s %s %dMHz found at mem %lx, " 5448 printk(KERN_INFO "%s: %s (%c%d) PCI%s %s %dMHz found at mem %lx, "
5447 "IRQ %d, ", 5449 "IRQ %d, ",
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 0b230222bfea..90999867a32c 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -293,7 +293,7 @@ static int sp_header(struct sk_buff *skb, struct net_device *dev,
293{ 293{
294#ifdef CONFIG_INET 294#ifdef CONFIG_INET
295 if (type != htons(ETH_P_AX25)) 295 if (type != htons(ETH_P_AX25))
296 return ax25_encapsulate(skb, dev, type, daddr, saddr, len); 296 return ax25_hard_header(skb, dev, type, daddr, saddr, len);
297#endif 297#endif
298 return 0; 298 return 0;
299} 299}
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 5298096afbdb..e4188d082f01 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -40,7 +40,7 @@
40 40
41/*****************************************************************************/ 41/*****************************************************************************/
42 42
43#include <linux/config.h> 43#include <linux/crc-ccitt.h>
44#include <linux/module.h> 44#include <linux/module.h>
45#include <linux/kernel.h> 45#include <linux/kernel.h>
46#include <linux/init.h> 46#include <linux/init.h>
@@ -48,18 +48,12 @@
48#include <linux/workqueue.h> 48#include <linux/workqueue.h>
49#include <linux/fs.h> 49#include <linux/fs.h>
50#include <linux/parport.h> 50#include <linux/parport.h>
51#include <linux/smp_lock.h>
52#include <asm/uaccess.h>
53#include <linux/if_arp.h> 51#include <linux/if_arp.h>
54#include <linux/kmod.h>
55#include <linux/hdlcdrv.h> 52#include <linux/hdlcdrv.h>
56#include <linux/baycom.h> 53#include <linux/baycom.h>
57#include <linux/jiffies.h> 54#include <linux/jiffies.h>
58#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
59/* prototypes for ax25_encapsulate and ax25_rebuild_header */
60#include <net/ax25.h> 55#include <net/ax25.h>
61#endif /* CONFIG_AX25 || CONFIG_AX25_MODULE */ 56#include <asm/uaccess.h>
62#include <linux/crc-ccitt.h>
63 57
64/* --------------------------------------------------------------------- */ 58/* --------------------------------------------------------------------- */
65 59
@@ -1177,13 +1171,8 @@ static void baycom_probe(struct net_device *dev)
1177 /* Fill in the fields of the device structure */ 1171 /* Fill in the fields of the device structure */
1178 bc->skb = NULL; 1172 bc->skb = NULL;
1179 1173
1180#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 1174 dev->hard_header = ax25_hard_header;
1181 dev->hard_header = ax25_encapsulate;
1182 dev->rebuild_header = ax25_rebuild_header; 1175 dev->rebuild_header = ax25_rebuild_header;
1183#else /* CONFIG_AX25 || CONFIG_AX25_MODULE */
1184 dev->hard_header = NULL;
1185 dev->rebuild_header = NULL;
1186#endif /* CONFIG_AX25 || CONFIG_AX25_MODULE */
1187 dev->set_mac_address = baycom_set_mac_address; 1176 dev->set_mac_address = baycom_set_mac_address;
1188 1177
1189 dev->type = ARPHRD_AX25; /* AF_AX25 device */ 1178 dev->type = ARPHRD_AX25; /* AF_AX25 device */
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index 2946e037a9b1..1756f0ed54cc 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -488,7 +488,7 @@ static void bpq_setup(struct net_device *dev)
488 dev->flags = 0; 488 dev->flags = 0;
489 489
490#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 490#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
491 dev->hard_header = ax25_encapsulate; 491 dev->hard_header = ax25_hard_header;
492 dev->rebuild_header = ax25_rebuild_header; 492 dev->rebuild_header = ax25_rebuild_header;
493#endif 493#endif
494 494
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index f515245a3fd0..3be3f916643a 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -449,12 +449,12 @@ module_exit(dmascc_exit);
449static void dev_setup(struct net_device *dev) 449static void dev_setup(struct net_device *dev)
450{ 450{
451 dev->type = ARPHRD_AX25; 451 dev->type = ARPHRD_AX25;
452 dev->hard_header_len = 73; 452 dev->hard_header_len = AX25_MAX_HEADER_LEN;
453 dev->mtu = 1500; 453 dev->mtu = 1500;
454 dev->addr_len = 7; 454 dev->addr_len = AX25_ADDR_LEN;
455 dev->tx_queue_len = 64; 455 dev->tx_queue_len = 64;
456 memcpy(dev->broadcast, ax25_broadcast, 7); 456 memcpy(dev->broadcast, ax25_broadcast, AX25_ADDR_LEN);
457 memcpy(dev->dev_addr, ax25_test, 7); 457 memcpy(dev->dev_addr, ax25_test, AX25_ADDR_LEN);
458} 458}
459 459
460static int __init setup_adapter(int card_base, int type, int n) 460static int __init setup_adapter(int card_base, int type, int n)
@@ -600,7 +600,7 @@ static int __init setup_adapter(int card_base, int type, int n)
600 dev->do_ioctl = scc_ioctl; 600 dev->do_ioctl = scc_ioctl;
601 dev->hard_start_xmit = scc_send_packet; 601 dev->hard_start_xmit = scc_send_packet;
602 dev->get_stats = scc_get_stats; 602 dev->get_stats = scc_get_stats;
603 dev->hard_header = ax25_encapsulate; 603 dev->hard_header = ax25_hard_header;
604 dev->rebuild_header = ax25_rebuild_header; 604 dev->rebuild_header = ax25_rebuild_header;
605 dev->set_mac_address = scc_set_mac_address; 605 dev->set_mac_address = scc_set_mac_address;
606 } 606 }
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index b4c836e4fe86..dacc7687b97f 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -42,7 +42,6 @@
42 42
43/*****************************************************************************/ 43/*****************************************************************************/
44 44
45#include <linux/config.h>
46#include <linux/module.h> 45#include <linux/module.h>
47#include <linux/types.h> 46#include <linux/types.h>
48#include <linux/net.h> 47#include <linux/net.h>
@@ -52,20 +51,14 @@
52#include <linux/errno.h> 51#include <linux/errno.h>
53#include <linux/init.h> 52#include <linux/init.h>
54#include <linux/bitops.h> 53#include <linux/bitops.h>
55#include <asm/uaccess.h>
56 54
57#include <linux/netdevice.h> 55#include <linux/netdevice.h>
58#include <linux/if_arp.h> 56#include <linux/if_arp.h>
59#include <linux/etherdevice.h>
60#include <linux/skbuff.h> 57#include <linux/skbuff.h>
61#include <linux/hdlcdrv.h> 58#include <linux/hdlcdrv.h>
62/* prototypes for ax25_encapsulate and ax25_rebuild_header */
63#include <net/ax25.h> 59#include <net/ax25.h>
60#include <asm/uaccess.h>
64 61
65/* make genksyms happy */
66#include <linux/ip.h>
67#include <linux/udp.h>
68#include <linux/tcp.h>
69#include <linux/crc-ccitt.h> 62#include <linux/crc-ccitt.h>
70 63
71/* --------------------------------------------------------------------- */ 64/* --------------------------------------------------------------------- */
@@ -708,13 +701,8 @@ static void hdlcdrv_setup(struct net_device *dev)
708 701
709 s->skb = NULL; 702 s->skb = NULL;
710 703
711#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 704 dev->hard_header = ax25_hard_header;
712 dev->hard_header = ax25_encapsulate;
713 dev->rebuild_header = ax25_rebuild_header; 705 dev->rebuild_header = ax25_rebuild_header;
714#else /* CONFIG_AX25 || CONFIG_AX25_MODULE */
715 dev->hard_header = NULL;
716 dev->rebuild_header = NULL;
717#endif /* CONFIG_AX25 || CONFIG_AX25_MODULE */
718 dev->set_mac_address = hdlcdrv_set_mac_address; 706 dev->set_mac_address = hdlcdrv_set_mac_address;
719 707
720 dev->type = ARPHRD_AX25; /* AF_AX25 device */ 708 dev->type = ARPHRD_AX25; /* AF_AX25 device */
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 63b1a2b86acb..d9fe64b46f4b 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -500,7 +500,7 @@ static int ax_header(struct sk_buff *skb, struct net_device *dev, unsigned short
500{ 500{
501#ifdef CONFIG_INET 501#ifdef CONFIG_INET
502 if (type != htons(ETH_P_AX25)) 502 if (type != htons(ETH_P_AX25))
503 return ax25_encapsulate(skb, dev, type, daddr, saddr, len); 503 return ax25_hard_header(skb, dev, type, daddr, saddr, len);
504#endif 504#endif
505 return 0; 505 return 0;
506} 506}
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index c27e417f32bf..6ace0e914fd1 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -1557,7 +1557,7 @@ static void scc_net_setup(struct net_device *dev)
1557 dev->stop = scc_net_close; 1557 dev->stop = scc_net_close;
1558 1558
1559 dev->hard_start_xmit = scc_net_tx; 1559 dev->hard_start_xmit = scc_net_tx;
1560 dev->hard_header = ax25_encapsulate; 1560 dev->hard_header = ax25_hard_header;
1561 dev->rebuild_header = ax25_rebuild_header; 1561 dev->rebuild_header = ax25_rebuild_header;
1562 dev->set_mac_address = scc_net_set_mac_address; 1562 dev->set_mac_address = scc_net_set_mac_address;
1563 dev->get_stats = scc_net_get_stats; 1563 dev->get_stats = scc_net_get_stats;
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index f52ee3162c51..fe22479eb202 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -60,15 +60,7 @@
60#include <linux/if_arp.h> 60#include <linux/if_arp.h>
61#include <linux/etherdevice.h> 61#include <linux/etherdevice.h>
62#include <linux/skbuff.h> 62#include <linux/skbuff.h>
63#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
64/* prototypes for ax25_encapsulate and ax25_rebuild_header */
65#include <net/ax25.h> 63#include <net/ax25.h>
66#endif /* CONFIG_AX25 || CONFIG_AX25_MODULE */
67
68/* make genksyms happy */
69#include <linux/ip.h>
70#include <linux/udp.h>
71#include <linux/tcp.h>
72 64
73#include <linux/kernel.h> 65#include <linux/kernel.h>
74#include <linux/proc_fs.h> 66#include <linux/proc_fs.h>
@@ -1116,23 +1108,17 @@ static void yam_setup(struct net_device *dev)
1116 1108
1117 skb_queue_head_init(&yp->send_queue); 1109 skb_queue_head_init(&yp->send_queue);
1118 1110
1119#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 1111 dev->hard_header = ax25_hard_header;
1120 dev->hard_header = ax25_encapsulate;
1121 dev->rebuild_header = ax25_rebuild_header; 1112 dev->rebuild_header = ax25_rebuild_header;
1122#else /* CONFIG_AX25 || CONFIG_AX25_MODULE */
1123 dev->hard_header = NULL;
1124 dev->rebuild_header = NULL;
1125#endif /* CONFIG_AX25 || CONFIG_AX25_MODULE */
1126 1113
1127 dev->set_mac_address = yam_set_mac_address; 1114 dev->set_mac_address = yam_set_mac_address;
1128 1115
1129 dev->type = ARPHRD_AX25; /* AF_AX25 device */ 1116 dev->type = ARPHRD_AX25;
1130 dev->hard_header_len = 73; /* We do digipeaters now */ 1117 dev->hard_header_len = AX25_MAX_HEADER_LEN;
1131 dev->mtu = 256; /* AX25 is the default */ 1118 dev->mtu = AX25_MTU;
1132 dev->addr_len = 7; /* sizeof an ax.25 address */ 1119 dev->addr_len = AX25_ADDR_LEN;
1133 memcpy(dev->broadcast, ax25_bcast, 7); 1120 memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
1134 memcpy(dev->dev_addr, ax25_test, 7); 1121 memcpy(dev->dev_addr, ax25_test, AX25_ADDR_LEN);
1135
1136} 1122}
1137 1123
1138static int __init yam_init_driver(void) 1124static int __init yam_init_driver(void)
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index dc57352e5a97..7599f52e15b3 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -6893,8 +6893,7 @@ static struct net_device_stats *tg3_get_stats(struct net_device *dev)
6893 get_stat64(&hw_stats->tx_octets); 6893 get_stat64(&hw_stats->tx_octets);
6894 6894
6895 stats->rx_errors = old_stats->rx_errors + 6895 stats->rx_errors = old_stats->rx_errors +
6896 get_stat64(&hw_stats->rx_errors) + 6896 get_stat64(&hw_stats->rx_errors);
6897 get_stat64(&hw_stats->rx_discards);
6898 stats->tx_errors = old_stats->tx_errors + 6897 stats->tx_errors = old_stats->tx_errors +
6899 get_stat64(&hw_stats->tx_errors) + 6898 get_stat64(&hw_stats->tx_errors) +
6900 get_stat64(&hw_stats->tx_mac_errors) + 6899 get_stat64(&hw_stats->tx_mac_errors) +
@@ -6922,6 +6921,9 @@ static struct net_device_stats *tg3_get_stats(struct net_device *dev)
6922 stats->rx_crc_errors = old_stats->rx_crc_errors + 6921 stats->rx_crc_errors = old_stats->rx_crc_errors +
6923 calc_crc_errors(tp); 6922 calc_crc_errors(tp);
6924 6923
6924 stats->rx_missed_errors = old_stats->rx_missed_errors +
6925 get_stat64(&hw_stats->rx_discards);
6926
6925 return stats; 6927 return stats;
6926} 6928}
6927 6929
@@ -8303,6 +8305,7 @@ static struct ethtool_ops tg3_ethtool_ops = {
8303 .get_ethtool_stats = tg3_get_ethtool_stats, 8305 .get_ethtool_stats = tg3_get_ethtool_stats,
8304 .get_coalesce = tg3_get_coalesce, 8306 .get_coalesce = tg3_get_coalesce,
8305 .set_coalesce = tg3_set_coalesce, 8307 .set_coalesce = tg3_set_coalesce,
8308 .get_perm_addr = ethtool_op_get_perm_addr,
8306}; 8309};
8307 8310
8308static void __devinit tg3_get_eeprom_size(struct tg3 *tp) 8311static void __devinit tg3_get_eeprom_size(struct tg3 *tp)
@@ -9781,6 +9784,7 @@ static int __devinit tg3_get_macaddr_sparc(struct tg3 *tp)
9781 if (prom_getproplen(node, "local-mac-address") == 6) { 9784 if (prom_getproplen(node, "local-mac-address") == 6) {
9782 prom_getproperty(node, "local-mac-address", 9785 prom_getproperty(node, "local-mac-address",
9783 dev->dev_addr, 6); 9786 dev->dev_addr, 6);
9787 memcpy(dev->perm_addr, dev->dev_addr, 6);
9784 return 0; 9788 return 0;
9785 } 9789 }
9786 } 9790 }
@@ -9792,6 +9796,7 @@ static int __devinit tg3_get_default_macaddr_sparc(struct tg3 *tp)
9792 struct net_device *dev = tp->dev; 9796 struct net_device *dev = tp->dev;
9793 9797
9794 memcpy(dev->dev_addr, idprom->id_ethaddr, 6); 9798 memcpy(dev->dev_addr, idprom->id_ethaddr, 6);
9799 memcpy(dev->perm_addr, idprom->id_ethaddr, 6);
9795 return 0; 9800 return 0;
9796} 9801}
9797#endif 9802#endif
@@ -9861,6 +9866,7 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
9861#endif 9866#endif
9862 return -EINVAL; 9867 return -EINVAL;
9863 } 9868 }
9869 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
9864 return 0; 9870 return 0;
9865} 9871}
9866 9872
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index d1fb1bab8aa8..bedd7f9f23e4 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -629,6 +629,7 @@ static struct pcmcia_device_id orinoco_cs_ids[] = {
629 PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90), 629 PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90),
630 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584), 630 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584),
631 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9), 631 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9),
632 PCMCIA_DEVICE_PROD_ID12("corega_K.K.", "Wireless_LAN_PCCB-11", 0x29e33311, 0xee7a27ae),
632 PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac), 633 PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac),
633 PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab), 634 PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab),
634 PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3), 635 PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3),
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 39ba6406fd54..80969f7e7a0b 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -376,6 +376,7 @@ static int ds_open(struct inode *inode, struct file *file)
376 socket_t i = iminor(inode); 376 socket_t i = iminor(inode);
377 struct pcmcia_socket *s; 377 struct pcmcia_socket *s;
378 user_info_t *user; 378 user_info_t *user;
379 static int warning_printed = 0;
379 380
380 ds_dbg(0, "ds_open(socket %d)\n", i); 381 ds_dbg(0, "ds_open(socket %d)\n", i);
381 382
@@ -407,6 +408,17 @@ static int ds_open(struct inode *inode, struct file *file)
407 s->user = user; 408 s->user = user;
408 file->private_data = user; 409 file->private_data = user;
409 410
411 if (!warning_printed) {
412 printk(KERN_INFO "pcmcia: Detected deprecated PCMCIA ioctl "
413 "usage.\n");
414 printk(KERN_INFO "pcmcia: This interface will soon be removed from "
415 "the kernel; please expect breakage unless you upgrade "
416 "to new tools.\n");
417 printk(KERN_INFO "pcmcia: see http://www.kernel.org/pub/linux/"
418 "utils/kernel/pcmcia/pcmcia.html for details.\n");
419 warning_printed = 1;
420 }
421
410 if (s->pcmcia_state.present) 422 if (s->pcmcia_state.present)
411 queue_event(user, CS_EVENT_CARD_INSERTION); 423 queue_event(user, CS_EVENT_CARD_INSERTION);
412 return 0; 424 return 0;
diff --git a/drivers/sbus/char/bpp.c b/drivers/sbus/char/bpp.c
index 87302fb14885..ccb20a6f5f36 100644
--- a/drivers/sbus/char/bpp.c
+++ b/drivers/sbus/char/bpp.c
@@ -295,8 +295,7 @@ static unsigned short get_pins(unsigned minor)
295 295
296static void snooze(unsigned long snooze_time, unsigned minor) 296static void snooze(unsigned long snooze_time, unsigned minor)
297{ 297{
298 set_current_state(TASK_UNINTERRUPTIBLE); 298 schedule_timeout_uninterruptible(snooze_time + 1);
299 schedule_timeout(snooze_time + 1);
300} 299}
301 300
302static int wait_for(unsigned short set, unsigned short clr, 301static int wait_for(unsigned short set, unsigned short clr,
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
index dbad7f35eb0a..24ed5893b4f0 100644
--- a/drivers/sbus/char/display7seg.c
+++ b/drivers/sbus/char/display7seg.c
@@ -14,7 +14,7 @@
14#include <linux/major.h> 14#include <linux/major.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/miscdevice.h> 16#include <linux/miscdevice.h>
17#include <linux/ioport.h> /* request_region, check_region */ 17#include <linux/ioport.h> /* request_region */
18#include <asm/atomic.h> 18#include <asm/atomic.h>
19#include <asm/ebus.h> /* EBus device */ 19#include <asm/ebus.h> /* EBus device */
20#include <asm/oplib.h> /* OpenProm Library */ 20#include <asm/oplib.h> /* OpenProm Library */
diff --git a/drivers/sbus/char/vfc_i2c.c b/drivers/sbus/char/vfc_i2c.c
index 739cad9b19a1..ceec30648f4f 100644
--- a/drivers/sbus/char/vfc_i2c.c
+++ b/drivers/sbus/char/vfc_i2c.c
@@ -81,8 +81,7 @@ int vfc_pcf8584_init(struct vfc_dev *dev)
81 81
82void vfc_i2c_delay_no_busy(struct vfc_dev *dev, unsigned long usecs) 82void vfc_i2c_delay_no_busy(struct vfc_dev *dev, unsigned long usecs)
83{ 83{
84 set_current_state(TASK_UNINTERRUPTIBLE); 84 schedule_timeout_uninterruptible(usecs_to_jiffies(usecs));
85 schedule_timeout(usecs_to_jiffies(usecs));
86} 85}
87 86
88void inline vfc_i2c_delay(struct vfc_dev *dev) 87void inline vfc_i2c_delay(struct vfc_dev *dev)
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index bc6e4627c7a1..a6ac61611f35 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -59,6 +59,7 @@
59 Fix 'handled=1' ISR usage, remove bogus IRQ check. 59 Fix 'handled=1' ISR usage, remove bogus IRQ check.
60 Remove un-needed eh_abort handler. 60 Remove un-needed eh_abort handler.
61 Add support for embedded firmware error strings. 61 Add support for embedded firmware error strings.
62 2.26.02.003 - Correctly handle single sgl's with use_sg=1.
62*/ 63*/
63 64
64#include <linux/module.h> 65#include <linux/module.h>
@@ -81,7 +82,7 @@
81#include "3w-9xxx.h" 82#include "3w-9xxx.h"
82 83
83/* Globals */ 84/* Globals */
84#define TW_DRIVER_VERSION "2.26.02.002" 85#define TW_DRIVER_VERSION "2.26.02.003"
85static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; 86static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
86static unsigned int twa_device_extension_count; 87static unsigned int twa_device_extension_count;
87static int twa_major = -1; 88static int twa_major = -1;
@@ -1805,6 +1806,8 @@ static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
1805 if (tw_dev->srb[request_id]->request_bufflen < TW_MIN_SGL_LENGTH) { 1806 if (tw_dev->srb[request_id]->request_bufflen < TW_MIN_SGL_LENGTH) {
1806 command_packet->sg_list[0].address = tw_dev->generic_buffer_phys[request_id]; 1807 command_packet->sg_list[0].address = tw_dev->generic_buffer_phys[request_id];
1807 command_packet->sg_list[0].length = TW_MIN_SGL_LENGTH; 1808 command_packet->sg_list[0].length = TW_MIN_SGL_LENGTH;
1809 if (tw_dev->srb[request_id]->sc_data_direction == DMA_TO_DEVICE || tw_dev->srb[request_id]->sc_data_direction == DMA_BIDIRECTIONAL)
1810 memcpy(tw_dev->generic_buffer_virt[request_id], tw_dev->srb[request_id]->request_buffer, tw_dev->srb[request_id]->request_bufflen);
1808 } else { 1811 } else {
1809 buffaddr = twa_map_scsi_single_data(tw_dev, request_id); 1812 buffaddr = twa_map_scsi_single_data(tw_dev, request_id);
1810 if (buffaddr == 0) 1813 if (buffaddr == 0)
@@ -1823,6 +1826,12 @@ static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
1823 1826
1824 if (tw_dev->srb[request_id]->use_sg > 0) { 1827 if (tw_dev->srb[request_id]->use_sg > 0) {
1825 if ((tw_dev->srb[request_id]->use_sg == 1) && (tw_dev->srb[request_id]->request_bufflen < TW_MIN_SGL_LENGTH)) { 1828 if ((tw_dev->srb[request_id]->use_sg == 1) && (tw_dev->srb[request_id]->request_bufflen < TW_MIN_SGL_LENGTH)) {
1829 if (tw_dev->srb[request_id]->sc_data_direction == DMA_TO_DEVICE || tw_dev->srb[request_id]->sc_data_direction == DMA_BIDIRECTIONAL) {
1830 struct scatterlist *sg = (struct scatterlist *)tw_dev->srb[request_id]->request_buffer;
1831 char *buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
1832 memcpy(tw_dev->generic_buffer_virt[request_id], buf, sg->length);
1833 kunmap_atomic(buf - sg->offset, KM_IRQ0);
1834 }
1826 command_packet->sg_list[0].address = tw_dev->generic_buffer_phys[request_id]; 1835 command_packet->sg_list[0].address = tw_dev->generic_buffer_phys[request_id];
1827 command_packet->sg_list[0].length = TW_MIN_SGL_LENGTH; 1836 command_packet->sg_list[0].length = TW_MIN_SGL_LENGTH;
1828 } else { 1837 } else {
@@ -1888,11 +1897,20 @@ out:
1888/* This function completes an execute scsi operation */ 1897/* This function completes an execute scsi operation */
1889static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id) 1898static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id)
1890{ 1899{
1891 /* Copy the response if too small */ 1900 if (tw_dev->srb[request_id]->request_bufflen < TW_MIN_SGL_LENGTH &&
1892 if ((tw_dev->srb[request_id]->request_buffer) && (tw_dev->srb[request_id]->request_bufflen < TW_MIN_SGL_LENGTH)) { 1901 (tw_dev->srb[request_id]->sc_data_direction == DMA_FROM_DEVICE ||
1893 memcpy(tw_dev->srb[request_id]->request_buffer, 1902 tw_dev->srb[request_id]->sc_data_direction == DMA_BIDIRECTIONAL)) {
1894 tw_dev->generic_buffer_virt[request_id], 1903 if (tw_dev->srb[request_id]->use_sg == 0) {
1895 tw_dev->srb[request_id]->request_bufflen); 1904 memcpy(tw_dev->srb[request_id]->request_buffer,
1905 tw_dev->generic_buffer_virt[request_id],
1906 tw_dev->srb[request_id]->request_bufflen);
1907 }
1908 if (tw_dev->srb[request_id]->use_sg == 1) {
1909 struct scatterlist *sg = (struct scatterlist *)tw_dev->srb[request_id]->request_buffer;
1910 char *buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
1911 memcpy(buf, tw_dev->generic_buffer_virt[request_id], sg->length);
1912 kunmap_atomic(buf - sg->offset, KM_IRQ0);
1913 }
1896 } 1914 }
1897} /* End twa_scsiop_execute_scsi_complete() */ 1915} /* End twa_scsiop_execute_scsi_complete() */
1898 1916
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 2d21265e650b..20019b82b4a8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -235,6 +235,13 @@ config SCSI_ISCSI_ATTRS
235 each attached iSCSI device to sysfs, say Y. 235 each attached iSCSI device to sysfs, say Y.
236 Otherwise, say N. 236 Otherwise, say N.
237 237
238config SCSI_SAS_ATTRS
239 tristate "SAS Transport Attributes"
240 depends on SCSI
241 help
242 If you wish to export transport-specific information about
243 each attached SAS device to sysfs, say Y.
244
238endmenu 245endmenu
239 246
240menu "SCSI low-level drivers" 247menu "SCSI low-level drivers"
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 4b4fd94c2674..1e4edbdf2730 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_RAID_ATTRS) += raid_class.o
31obj-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o 31obj-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o
32obj-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o 32obj-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o
33obj-$(CONFIG_SCSI_ISCSI_ATTRS) += scsi_transport_iscsi.o 33obj-$(CONFIG_SCSI_ISCSI_ATTRS) += scsi_transport_iscsi.o
34obj-$(CONFIG_SCSI_SAS_ATTRS) += scsi_transport_sas.o
34 35
35obj-$(CONFIG_SCSI_AMIGA7XX) += amiga7xx.o 53c7xx.o 36obj-$(CONFIG_SCSI_AMIGA7XX) += amiga7xx.o 53c7xx.o
36obj-$(CONFIG_A3000_SCSI) += a3000.o wd33c93.o 37obj-$(CONFIG_A3000_SCSI) += a3000.o wd33c93.o
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 0e089a42c03a..86eaf6d408d5 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -966,21 +966,21 @@ static void
966lpfc_get_host_fabric_name (struct Scsi_Host *shost) 966lpfc_get_host_fabric_name (struct Scsi_Host *shost)
967{ 967{
968 struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata[0]; 968 struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata[0];
969 u64 nodename; 969 u64 node_name;
970 970
971 spin_lock_irq(shost->host_lock); 971 spin_lock_irq(shost->host_lock);
972 972
973 if ((phba->fc_flag & FC_FABRIC) || 973 if ((phba->fc_flag & FC_FABRIC) ||
974 ((phba->fc_topology == TOPOLOGY_LOOP) && 974 ((phba->fc_topology == TOPOLOGY_LOOP) &&
975 (phba->fc_flag & FC_PUBLIC_LOOP))) 975 (phba->fc_flag & FC_PUBLIC_LOOP)))
976 memcpy(&nodename, &phba->fc_fabparam.nodeName, sizeof(u64)); 976 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.wwn);
977 else 977 else
978 /* fabric is local port if there is no F/FL_Port */ 978 /* fabric is local port if there is no F/FL_Port */
979 memcpy(&nodename, &phba->fc_nodename, sizeof(u64)); 979 node_name = wwn_to_u64(phba->fc_nodename.wwn);
980 980
981 spin_unlock_irq(shost->host_lock); 981 spin_unlock_irq(shost->host_lock);
982 982
983 fc_host_fabric_name(shost) = be64_to_cpu(nodename); 983 fc_host_fabric_name(shost) = node_name;
984} 984}
985 985
986 986
@@ -1103,21 +1103,20 @@ lpfc_get_starget_node_name(struct scsi_target *starget)
1103{ 1103{
1104 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 1104 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
1105 struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata[0]; 1105 struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata[0];
1106 uint64_t node_name = 0; 1106 u64 node_name = 0;
1107 struct lpfc_nodelist *ndlp = NULL; 1107 struct lpfc_nodelist *ndlp = NULL;
1108 1108
1109 spin_lock_irq(shost->host_lock); 1109 spin_lock_irq(shost->host_lock);
1110 /* Search the mapped list for this target ID */ 1110 /* Search the mapped list for this target ID */
1111 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) { 1111 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
1112 if (starget->id == ndlp->nlp_sid) { 1112 if (starget->id == ndlp->nlp_sid) {
1113 memcpy(&node_name, &ndlp->nlp_nodename, 1113 node_name = wwn_to_u64(ndlp->nlp_nodename.wwn);
1114 sizeof(struct lpfc_name));
1115 break; 1114 break;
1116 } 1115 }
1117 } 1116 }
1118 spin_unlock_irq(shost->host_lock); 1117 spin_unlock_irq(shost->host_lock);
1119 1118
1120 fc_starget_node_name(starget) = be64_to_cpu(node_name); 1119 fc_starget_node_name(starget) = node_name;
1121} 1120}
1122 1121
1123static void 1122static void
@@ -1125,21 +1124,20 @@ lpfc_get_starget_port_name(struct scsi_target *starget)
1125{ 1124{
1126 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 1125 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
1127 struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata[0]; 1126 struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata[0];
1128 uint64_t port_name = 0; 1127 u64 port_name = 0;
1129 struct lpfc_nodelist *ndlp = NULL; 1128 struct lpfc_nodelist *ndlp = NULL;
1130 1129
1131 spin_lock_irq(shost->host_lock); 1130 spin_lock_irq(shost->host_lock);
1132 /* Search the mapped list for this target ID */ 1131 /* Search the mapped list for this target ID */
1133 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) { 1132 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
1134 if (starget->id == ndlp->nlp_sid) { 1133 if (starget->id == ndlp->nlp_sid) {
1135 memcpy(&port_name, &ndlp->nlp_portname, 1134 port_name = wwn_to_u64(ndlp->nlp_portname.wwn);
1136 sizeof(struct lpfc_name));
1137 break; 1135 break;
1138 } 1136 }
1139 } 1137 }
1140 spin_unlock_irq(shost->host_lock); 1138 spin_unlock_irq(shost->host_lock);
1141 1139
1142 fc_starget_port_name(starget) = be64_to_cpu(port_name); 1140 fc_starget_port_name(starget) = port_name;
1143} 1141}
1144 1142
1145static void 1143static void
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 0a8269d6b130..4fb8eb0c84cf 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -1017,13 +1017,10 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
1017 struct fc_rport *rport; 1017 struct fc_rport *rport;
1018 struct lpfc_rport_data *rdata; 1018 struct lpfc_rport_data *rdata;
1019 struct fc_rport_identifiers rport_ids; 1019 struct fc_rport_identifiers rport_ids;
1020 uint64_t wwn;
1021 1020
1022 /* Remote port has reappeared. Re-register w/ FC transport */ 1021 /* Remote port has reappeared. Re-register w/ FC transport */
1023 memcpy(&wwn, &ndlp->nlp_nodename, sizeof(uint64_t)); 1022 rport_ids.node_name = wwn_to_u64(ndlp->nlp_nodename.wwn);
1024 rport_ids.node_name = be64_to_cpu(wwn); 1023 rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.wwn);
1025 memcpy(&wwn, &ndlp->nlp_portname, sizeof(uint64_t));
1026 rport_ids.port_name = be64_to_cpu(wwn);
1027 rport_ids.port_id = ndlp->nlp_DID; 1024 rport_ids.port_id = ndlp->nlp_DID;
1028 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; 1025 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
1029 if (ndlp->nlp_type & NLP_FCP_TARGET) 1026 if (ndlp->nlp_type & NLP_FCP_TARGET)
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index 21591cb9f551..047a87c26cc0 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -262,12 +262,14 @@ struct lpfc_sli_ct_request {
262#define FF_FRAME_SIZE 2048 262#define FF_FRAME_SIZE 2048
263 263
264struct lpfc_name { 264struct lpfc_name {
265 union {
266 struct {
265#ifdef __BIG_ENDIAN_BITFIELD 267#ifdef __BIG_ENDIAN_BITFIELD
266 uint8_t nameType:4; /* FC Word 0, bit 28:31 */ 268 uint8_t nameType:4; /* FC Word 0, bit 28:31 */
267 uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit 8:11 of IEEE ext */ 269 uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit 8:11 of IEEE ext */
268#else /* __LITTLE_ENDIAN_BITFIELD */ 270#else /* __LITTLE_ENDIAN_BITFIELD */
269 uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit 8:11 of IEEE ext */ 271 uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit 8:11 of IEEE ext */
270 uint8_t nameType:4; /* FC Word 0, bit 28:31 */ 272 uint8_t nameType:4; /* FC Word 0, bit 28:31 */
271#endif 273#endif
272 274
273#define NAME_IEEE 0x1 /* IEEE name - nameType */ 275#define NAME_IEEE 0x1 /* IEEE name - nameType */
@@ -276,8 +278,11 @@ struct lpfc_name {
276#define NAME_IP_TYPE 0x4 /* IP address */ 278#define NAME_IP_TYPE 0x4 /* IP address */
277#define NAME_CCITT_TYPE 0xC 279#define NAME_CCITT_TYPE 0xC
278#define NAME_CCITT_GR_TYPE 0xE 280#define NAME_CCITT_GR_TYPE 0xE
279 uint8_t IEEEextLsb; /* FC Word 0, bit 16:23, IEEE extended Lsb */ 281 uint8_t IEEEextLsb; /* FC Word 0, bit 16:23, IEEE extended Lsb */
280 uint8_t IEEE[6]; /* FC IEEE address */ 282 uint8_t IEEE[6]; /* FC IEEE address */
283 };
284 uint8_t wwn[8];
285 };
281}; 286};
282 287
283struct csp { 288struct csp {
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 6f3cb59bf9e0..454058f655db 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -1333,7 +1333,6 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1333 unsigned long bar0map_len, bar2map_len; 1333 unsigned long bar0map_len, bar2map_len;
1334 int error = -ENODEV, retval; 1334 int error = -ENODEV, retval;
1335 int i; 1335 int i;
1336 u64 wwname;
1337 1336
1338 if (pci_enable_device(pdev)) 1337 if (pci_enable_device(pdev))
1339 goto out; 1338 goto out;
@@ -1524,10 +1523,8 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1524 * Must done after lpfc_sli_hba_setup() 1523 * Must done after lpfc_sli_hba_setup()
1525 */ 1524 */
1526 1525
1527 memcpy(&wwname, &phba->fc_nodename, sizeof(u64)); 1526 fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.wwn);
1528 fc_host_node_name(host) = be64_to_cpu(wwname); 1527 fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.wwn);
1529 memcpy(&wwname, &phba->fc_portname, sizeof(u64));
1530 fc_host_port_name(host) = be64_to_cpu(wwname);
1531 fc_host_supported_classes(host) = FC_COS_CLASS3; 1528 fc_host_supported_classes(host) = FC_COS_CLASS3;
1532 1529
1533 memset(fc_host_supported_fc4s(host), 0, 1530 memset(fc_host_supported_fc4s(host), 0,
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index fe0fce71adc7..fc25cd834668 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -360,16 +360,16 @@ qla2x00_get_starget_node_name(struct scsi_target *starget)
360 struct Scsi_Host *host = dev_to_shost(starget->dev.parent); 360 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
361 scsi_qla_host_t *ha = to_qla_host(host); 361 scsi_qla_host_t *ha = to_qla_host(host);
362 fc_port_t *fcport; 362 fc_port_t *fcport;
363 uint64_t node_name = 0; 363 u64 node_name = 0;
364 364
365 list_for_each_entry(fcport, &ha->fcports, list) { 365 list_for_each_entry(fcport, &ha->fcports, list) {
366 if (starget->id == fcport->os_target_id) { 366 if (starget->id == fcport->os_target_id) {
367 node_name = *(uint64_t *)fcport->node_name; 367 node_name = wwn_to_u64(fcport->node_name);
368 break; 368 break;
369 } 369 }
370 } 370 }
371 371
372 fc_starget_node_name(starget) = be64_to_cpu(node_name); 372 fc_starget_node_name(starget) = node_name;
373} 373}
374 374
375static void 375static void
@@ -378,16 +378,16 @@ qla2x00_get_starget_port_name(struct scsi_target *starget)
378 struct Scsi_Host *host = dev_to_shost(starget->dev.parent); 378 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
379 scsi_qla_host_t *ha = to_qla_host(host); 379 scsi_qla_host_t *ha = to_qla_host(host);
380 fc_port_t *fcport; 380 fc_port_t *fcport;
381 uint64_t port_name = 0; 381 u64 port_name = 0;
382 382
383 list_for_each_entry(fcport, &ha->fcports, list) { 383 list_for_each_entry(fcport, &ha->fcports, list) {
384 if (starget->id == fcport->os_target_id) { 384 if (starget->id == fcport->os_target_id) {
385 port_name = *(uint64_t *)fcport->port_name; 385 port_name = wwn_to_u64(fcport->port_name);
386 break; 386 break;
387 } 387 }
388 } 388 }
389 389
390 fc_starget_port_name(starget) = be64_to_cpu(port_name); 390 fc_starget_port_name(starget) = port_name;
391} 391}
392 392
393static void 393static void
@@ -460,9 +460,7 @@ struct fc_function_template qla2xxx_transport_functions = {
460void 460void
461qla2x00_init_host_attr(scsi_qla_host_t *ha) 461qla2x00_init_host_attr(scsi_qla_host_t *ha)
462{ 462{
463 fc_host_node_name(ha->host) = 463 fc_host_node_name(ha->host) = wwn_to_u64(ha->init_cb->node_name);
464 be64_to_cpu(*(uint64_t *)ha->init_cb->node_name); 464 fc_host_port_name(ha->host) = wwn_to_u64(ha->init_cb->port_name);
465 fc_host_port_name(ha->host) =
466 be64_to_cpu(*(uint64_t *)ha->init_cb->port_name);
467 fc_host_supported_classes(ha->host) = FC_COS_CLASS3; 465 fc_host_supported_classes(ha->host) = FC_COS_CLASS3;
468} 466}
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index c619583e646b..3e9b64137873 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -2066,8 +2066,8 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport)
2066 return; 2066 return;
2067 } 2067 }
2068 2068
2069 rport_ids.node_name = be64_to_cpu(*(uint64_t *)fcport->node_name); 2069 rport_ids.node_name = wwn_to_u64(fcport->node_name);
2070 rport_ids.port_name = be64_to_cpu(*(uint64_t *)fcport->port_name); 2070 rport_ids.port_name = wwn_to_u64(fcport->port_name);
2071 rport_ids.port_id = fcport->d_id.b.domain << 16 | 2071 rport_ids.port_id = fcport->d_id.b.domain << 16 |
2072 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; 2072 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
2073 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; 2073 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 77f2d444f7e0..863bb6495daa 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -97,6 +97,30 @@ int scsi_insert_special_req(struct scsi_request *sreq, int at_head)
97} 97}
98 98
99static void scsi_run_queue(struct request_queue *q); 99static void scsi_run_queue(struct request_queue *q);
100static void scsi_release_buffers(struct scsi_cmnd *cmd);
101
102/*
103 * Function: scsi_unprep_request()
104 *
105 * Purpose: Remove all preparation done for a request, including its
106 * associated scsi_cmnd, so that it can be requeued.
107 *
108 * Arguments: req - request to unprepare
109 *
110 * Lock status: Assumed that no locks are held upon entry.
111 *
112 * Returns: Nothing.
113 */
114static void scsi_unprep_request(struct request *req)
115{
116 struct scsi_cmnd *cmd = req->special;
117
118 req->flags &= ~REQ_DONTPREP;
119 req->special = (req->flags & REQ_SPECIAL) ? cmd->sc_request : NULL;
120
121 scsi_release_buffers(cmd);
122 scsi_put_command(cmd);
123}
100 124
101/* 125/*
102 * Function: scsi_queue_insert() 126 * Function: scsi_queue_insert()
@@ -116,12 +140,14 @@ static void scsi_run_queue(struct request_queue *q);
116 * commands. 140 * commands.
117 * Notes: This could be called either from an interrupt context or a 141 * Notes: This could be called either from an interrupt context or a
118 * normal process context. 142 * normal process context.
143 * Notes: Upon return, cmd is a stale pointer.
119 */ 144 */
120int scsi_queue_insert(struct scsi_cmnd *cmd, int reason) 145int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
121{ 146{
122 struct Scsi_Host *host = cmd->device->host; 147 struct Scsi_Host *host = cmd->device->host;
123 struct scsi_device *device = cmd->device; 148 struct scsi_device *device = cmd->device;
124 struct request_queue *q = device->request_queue; 149 struct request_queue *q = device->request_queue;
150 struct request *req = cmd->request;
125 unsigned long flags; 151 unsigned long flags;
126 152
127 SCSI_LOG_MLQUEUE(1, 153 SCSI_LOG_MLQUEUE(1,
@@ -162,8 +188,9 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
162 * function. The SCSI request function detects the blocked condition 188 * function. The SCSI request function detects the blocked condition
163 * and plugs the queue appropriately. 189 * and plugs the queue appropriately.
164 */ 190 */
191 scsi_unprep_request(req);
165 spin_lock_irqsave(q->queue_lock, flags); 192 spin_lock_irqsave(q->queue_lock, flags);
166 blk_requeue_request(q, cmd->request); 193 blk_requeue_request(q, req);
167 spin_unlock_irqrestore(q->queue_lock, flags); 194 spin_unlock_irqrestore(q->queue_lock, flags);
168 195
169 scsi_run_queue(q); 196 scsi_run_queue(q);
@@ -339,7 +366,7 @@ int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
339 int result; 366 int result;
340 367
341 if (sshdr) { 368 if (sshdr) {
342 sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); 369 sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO);
343 if (!sense) 370 if (!sense)
344 return DRIVER_ERROR << 24; 371 return DRIVER_ERROR << 24;
345 memset(sense, 0, SCSI_SENSE_BUFFERSIZE); 372 memset(sense, 0, SCSI_SENSE_BUFFERSIZE);
@@ -552,15 +579,16 @@ static void scsi_run_queue(struct request_queue *q)
552 * I/O errors in the middle of the request, in which case 579 * I/O errors in the middle of the request, in which case
553 * we need to request the blocks that come after the bad 580 * we need to request the blocks that come after the bad
554 * sector. 581 * sector.
582 * Notes: Upon return, cmd is a stale pointer.
555 */ 583 */
556static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd) 584static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
557{ 585{
586 struct request *req = cmd->request;
558 unsigned long flags; 587 unsigned long flags;
559 588
560 cmd->request->flags &= ~REQ_DONTPREP; 589 scsi_unprep_request(req);
561
562 spin_lock_irqsave(q->queue_lock, flags); 590 spin_lock_irqsave(q->queue_lock, flags);
563 blk_requeue_request(q, cmd->request); 591 blk_requeue_request(q, req);
564 spin_unlock_irqrestore(q->queue_lock, flags); 592 spin_unlock_irqrestore(q->queue_lock, flags);
565 593
566 scsi_run_queue(q); 594 scsi_run_queue(q);
@@ -595,13 +623,14 @@ void scsi_run_host_queues(struct Scsi_Host *shost)
595 * 623 *
596 * Lock status: Assumed that lock is not held upon entry. 624 * Lock status: Assumed that lock is not held upon entry.
597 * 625 *
598 * Returns: cmd if requeue done or required, NULL otherwise 626 * Returns: cmd if requeue required, NULL otherwise.
599 * 627 *
600 * Notes: This is called for block device requests in order to 628 * Notes: This is called for block device requests in order to
601 * mark some number of sectors as complete. 629 * mark some number of sectors as complete.
602 * 630 *
603 * We are guaranteeing that the request queue will be goosed 631 * We are guaranteeing that the request queue will be goosed
604 * at some point during this call. 632 * at some point during this call.
633 * Notes: If cmd was requeued, upon return it will be a stale pointer.
605 */ 634 */
606static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate, 635static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate,
607 int bytes, int requeue) 636 int bytes, int requeue)
@@ -624,14 +653,15 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate,
624 if (!uptodate && blk_noretry_request(req)) 653 if (!uptodate && blk_noretry_request(req))
625 end_that_request_chunk(req, 0, leftover); 654 end_that_request_chunk(req, 0, leftover);
626 else { 655 else {
627 if (requeue) 656 if (requeue) {
628 /* 657 /*
629 * Bleah. Leftovers again. Stick the 658 * Bleah. Leftovers again. Stick the
630 * leftovers in the front of the 659 * leftovers in the front of the
631 * queue, and goose the queue again. 660 * queue, and goose the queue again.
632 */ 661 */
633 scsi_requeue_command(q, cmd); 662 scsi_requeue_command(q, cmd);
634 663 cmd = NULL;
664 }
635 return cmd; 665 return cmd;
636 } 666 }
637 } 667 }
@@ -857,15 +887,13 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,
857 * requeueing right here - we will requeue down below 887 * requeueing right here - we will requeue down below
858 * when we handle the bad sectors. 888 * when we handle the bad sectors.
859 */ 889 */
860 cmd = scsi_end_request(cmd, 1, good_bytes, result == 0);
861 890
862 /* 891 /*
863 * If the command completed without error, then either finish off the 892 * If the command completed without error, then either
864 * rest of the command, or start a new one. 893 * finish off the rest of the command, or start a new one.
865 */ 894 */
866 if (result == 0 || cmd == NULL ) { 895 if (scsi_end_request(cmd, 1, good_bytes, result == 0) == NULL)
867 return; 896 return;
868 }
869 } 897 }
870 /* 898 /*
871 * Now, if we were good little boys and girls, Santa left us a request 899 * Now, if we were good little boys and girls, Santa left us a request
@@ -880,7 +908,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,
880 * and quietly refuse further access. 908 * and quietly refuse further access.
881 */ 909 */
882 cmd->device->changed = 1; 910 cmd->device->changed = 1;
883 cmd = scsi_end_request(cmd, 0, 911 scsi_end_request(cmd, 0,
884 this_count, 1); 912 this_count, 1);
885 return; 913 return;
886 } else { 914 } else {
@@ -914,7 +942,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,
914 scsi_requeue_command(q, cmd); 942 scsi_requeue_command(q, cmd);
915 result = 0; 943 result = 0;
916 } else { 944 } else {
917 cmd = scsi_end_request(cmd, 0, this_count, 1); 945 scsi_end_request(cmd, 0, this_count, 1);
918 return; 946 return;
919 } 947 }
920 break; 948 break;
@@ -931,7 +959,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,
931 dev_printk(KERN_INFO, 959 dev_printk(KERN_INFO,
932 &cmd->device->sdev_gendev, 960 &cmd->device->sdev_gendev,
933 "Device not ready.\n"); 961 "Device not ready.\n");
934 cmd = scsi_end_request(cmd, 0, this_count, 1); 962 scsi_end_request(cmd, 0, this_count, 1);
935 return; 963 return;
936 case VOLUME_OVERFLOW: 964 case VOLUME_OVERFLOW:
937 if (!(req->flags & REQ_QUIET)) { 965 if (!(req->flags & REQ_QUIET)) {
@@ -941,7 +969,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,
941 __scsi_print_command(cmd->data_cmnd); 969 __scsi_print_command(cmd->data_cmnd);
942 scsi_print_sense("", cmd); 970 scsi_print_sense("", cmd);
943 } 971 }
944 cmd = scsi_end_request(cmd, 0, block_bytes, 1); 972 scsi_end_request(cmd, 0, block_bytes, 1);
945 return; 973 return;
946 default: 974 default:
947 break; 975 break;
@@ -972,7 +1000,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,
972 block_bytes = req->hard_cur_sectors << 9; 1000 block_bytes = req->hard_cur_sectors << 9;
973 if (!block_bytes) 1001 if (!block_bytes)
974 block_bytes = req->data_len; 1002 block_bytes = req->data_len;
975 cmd = scsi_end_request(cmd, 0, block_bytes, 1); 1003 scsi_end_request(cmd, 0, block_bytes, 1);
976 } 1004 }
977} 1005}
978EXPORT_SYMBOL(scsi_io_completion); 1006EXPORT_SYMBOL(scsi_io_completion);
@@ -1118,7 +1146,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1118 if (unlikely(!scsi_device_online(sdev))) { 1146 if (unlikely(!scsi_device_online(sdev))) {
1119 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n", 1147 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n",
1120 sdev->host->host_no, sdev->id, sdev->lun); 1148 sdev->host->host_no, sdev->id, sdev->lun);
1121 return BLKPREP_KILL; 1149 goto kill;
1122 } 1150 }
1123 if (unlikely(sdev->sdev_state != SDEV_RUNNING)) { 1151 if (unlikely(sdev->sdev_state != SDEV_RUNNING)) {
1124 /* OK, we're not in a running state don't prep 1152 /* OK, we're not in a running state don't prep
@@ -1128,7 +1156,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1128 * at all allowed down */ 1156 * at all allowed down */
1129 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to dead device\n", 1157 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to dead device\n",
1130 sdev->host->host_no, sdev->id, sdev->lun); 1158 sdev->host->host_no, sdev->id, sdev->lun);
1131 return BLKPREP_KILL; 1159 goto kill;
1132 } 1160 }
1133 /* OK, we only allow special commands (i.e. not 1161 /* OK, we only allow special commands (i.e. not
1134 * user initiated ones */ 1162 * user initiated ones */
@@ -1160,11 +1188,11 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1160 if(unlikely(specials_only) && !(req->flags & REQ_SPECIAL)) { 1188 if(unlikely(specials_only) && !(req->flags & REQ_SPECIAL)) {
1161 if(specials_only == SDEV_QUIESCE || 1189 if(specials_only == SDEV_QUIESCE ||
1162 specials_only == SDEV_BLOCK) 1190 specials_only == SDEV_BLOCK)
1163 return BLKPREP_DEFER; 1191 goto defer;
1164 1192
1165 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to device being removed\n", 1193 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to device being removed\n",
1166 sdev->host->host_no, sdev->id, sdev->lun); 1194 sdev->host->host_no, sdev->id, sdev->lun);
1167 return BLKPREP_KILL; 1195 goto kill;
1168 } 1196 }
1169 1197
1170 1198
@@ -1182,7 +1210,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1182 cmd->tag = req->tag; 1210 cmd->tag = req->tag;
1183 } else { 1211 } else {
1184 blk_dump_rq_flags(req, "SCSI bad req"); 1212 blk_dump_rq_flags(req, "SCSI bad req");
1185 return BLKPREP_KILL; 1213 goto kill;
1186 } 1214 }
1187 1215
1188 /* note the overloading of req->special. When the tag 1216 /* note the overloading of req->special. When the tag
@@ -1220,8 +1248,13 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1220 * required). 1248 * required).
1221 */ 1249 */
1222 ret = scsi_init_io(cmd); 1250 ret = scsi_init_io(cmd);
1223 if (ret) /* BLKPREP_KILL return also releases the command */ 1251 switch(ret) {
1224 return ret; 1252 case BLKPREP_KILL:
1253 /* BLKPREP_KILL return also releases the command */
1254 goto kill;
1255 case BLKPREP_DEFER:
1256 goto defer;
1257 }
1225 1258
1226 /* 1259 /*
1227 * Initialize the actual SCSI command for this request. 1260 * Initialize the actual SCSI command for this request.
@@ -1231,7 +1264,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1231 if (unlikely(!drv->init_command(cmd))) { 1264 if (unlikely(!drv->init_command(cmd))) {
1232 scsi_release_buffers(cmd); 1265 scsi_release_buffers(cmd);
1233 scsi_put_command(cmd); 1266 scsi_put_command(cmd);
1234 return BLKPREP_KILL; 1267 goto kill;
1235 } 1268 }
1236 } else { 1269 } else {
1237 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1270 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
@@ -1262,6 +1295,9 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1262 if (sdev->device_busy == 0) 1295 if (sdev->device_busy == 0)
1263 blk_plug_device(q); 1296 blk_plug_device(q);
1264 return BLKPREP_DEFER; 1297 return BLKPREP_DEFER;
1298 kill:
1299 req->errors = DID_NO_CONNECT << 16;
1300 return BLKPREP_KILL;
1265} 1301}
1266 1302
1267/* 1303/*
@@ -1336,19 +1372,24 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
1336} 1372}
1337 1373
1338/* 1374/*
1339 * Kill requests for a dead device 1375 * Kill a request for a dead device
1340 */ 1376 */
1341static void scsi_kill_requests(request_queue_t *q) 1377static void scsi_kill_request(struct request *req, request_queue_t *q)
1342{ 1378{
1343 struct request *req; 1379 struct scsi_cmnd *cmd = req->special;
1380
1381 blkdev_dequeue_request(req);
1344 1382
1345 while ((req = elv_next_request(q)) != NULL) { 1383 if (unlikely(cmd == NULL)) {
1346 blkdev_dequeue_request(req); 1384 printk(KERN_CRIT "impossible request in %s.\n",
1347 req->flags |= REQ_QUIET; 1385 __FUNCTION__);
1348 while (end_that_request_first(req, 0, req->nr_sectors)) 1386 BUG();
1349 ;
1350 end_that_request_last(req);
1351 } 1387 }
1388
1389 scsi_init_cmd_errh(cmd);
1390 cmd->result = DID_NO_CONNECT << 16;
1391 atomic_inc(&cmd->device->iorequest_cnt);
1392 __scsi_done(cmd);
1352} 1393}
1353 1394
1354/* 1395/*
@@ -1371,7 +1412,8 @@ static void scsi_request_fn(struct request_queue *q)
1371 1412
1372 if (!sdev) { 1413 if (!sdev) {
1373 printk("scsi: killing requests for dead queue\n"); 1414 printk("scsi: killing requests for dead queue\n");
1374 scsi_kill_requests(q); 1415 while ((req = elv_next_request(q)) != NULL)
1416 scsi_kill_request(req, q);
1375 return; 1417 return;
1376 } 1418 }
1377 1419
@@ -1398,11 +1440,7 @@ static void scsi_request_fn(struct request_queue *q)
1398 if (unlikely(!scsi_device_online(sdev))) { 1440 if (unlikely(!scsi_device_online(sdev))) {
1399 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n", 1441 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n",
1400 sdev->host->host_no, sdev->id, sdev->lun); 1442 sdev->host->host_no, sdev->id, sdev->lun);
1401 blkdev_dequeue_request(req); 1443 scsi_kill_request(req, q);
1402 req->flags |= REQ_QUIET;
1403 while (end_that_request_first(req, 0, req->nr_sectors))
1404 ;
1405 end_that_request_last(req);
1406 continue; 1444 continue;
1407 } 1445 }
1408 1446
@@ -1415,6 +1453,14 @@ static void scsi_request_fn(struct request_queue *q)
1415 sdev->device_busy++; 1453 sdev->device_busy++;
1416 1454
1417 spin_unlock(q->queue_lock); 1455 spin_unlock(q->queue_lock);
1456 cmd = req->special;
1457 if (unlikely(cmd == NULL)) {
1458 printk(KERN_CRIT "impossible request in %s.\n"
1459 "please mail a stack trace to "
1460 "linux-scsi@vger.kernel.org",
1461 __FUNCTION__);
1462 BUG();
1463 }
1418 spin_lock(shost->host_lock); 1464 spin_lock(shost->host_lock);
1419 1465
1420 if (!scsi_host_queue_ready(q, shost, sdev)) 1466 if (!scsi_host_queue_ready(q, shost, sdev))
@@ -1433,15 +1479,6 @@ static void scsi_request_fn(struct request_queue *q)
1433 */ 1479 */
1434 spin_unlock_irq(shost->host_lock); 1480 spin_unlock_irq(shost->host_lock);
1435 1481
1436 cmd = req->special;
1437 if (unlikely(cmd == NULL)) {
1438 printk(KERN_CRIT "impossible request in %s.\n"
1439 "please mail a stack trace to "
1440 "linux-scsi@vger.kernel.org",
1441 __FUNCTION__);
1442 BUG();
1443 }
1444
1445 /* 1482 /*
1446 * Finally, initialize any error handling parameters, and set up 1483 * Finally, initialize any error handling parameters, and set up
1447 * the timers for timeouts. 1484 * the timers for timeouts.
@@ -1477,6 +1514,7 @@ static void scsi_request_fn(struct request_queue *q)
1477 * cases (host limits or settings) should run the queue at some 1514 * cases (host limits or settings) should run the queue at some
1478 * later time. 1515 * later time.
1479 */ 1516 */
1517 scsi_unprep_request(req);
1480 spin_lock_irq(q->queue_lock); 1518 spin_lock_irq(q->queue_lock);
1481 blk_requeue_request(q, req); 1519 blk_requeue_request(q, req);
1482 sdev->device_busy--; 1520 sdev->device_busy--;
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index ee6de1768e53..d05f778d31a8 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -124,6 +124,7 @@ extern void scsi_sysfs_unregister(void);
124extern void scsi_sysfs_device_initialize(struct scsi_device *); 124extern void scsi_sysfs_device_initialize(struct scsi_device *);
125extern int scsi_sysfs_target_initialize(struct scsi_device *); 125extern int scsi_sysfs_target_initialize(struct scsi_device *);
126extern struct scsi_transport_template blank_transport_template; 126extern struct scsi_transport_template blank_transport_template;
127extern void __scsi_remove_device(struct scsi_device *);
127 128
128extern struct bus_type scsi_bus_type; 129extern struct bus_type scsi_bus_type;
129 130
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 19c9a232a754..b86f170fa8ed 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -870,8 +870,12 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
870 out_free_sdev: 870 out_free_sdev:
871 if (res == SCSI_SCAN_LUN_PRESENT) { 871 if (res == SCSI_SCAN_LUN_PRESENT) {
872 if (sdevp) { 872 if (sdevp) {
873 scsi_device_get(sdev); 873 if (scsi_device_get(sdev) == 0) {
874 *sdevp = sdev; 874 *sdevp = sdev;
875 } else {
876 __scsi_remove_device(sdev);
877 res = SCSI_SCAN_NO_RESPONSE;
878 }
875 } 879 }
876 } else { 880 } else {
877 if (sdev->host->hostt->slave_destroy) 881 if (sdev->host->hostt->slave_destroy)
@@ -1260,6 +1264,19 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
1260} 1264}
1261EXPORT_SYMBOL(__scsi_add_device); 1265EXPORT_SYMBOL(__scsi_add_device);
1262 1266
1267int scsi_add_device(struct Scsi_Host *host, uint channel,
1268 uint target, uint lun)
1269{
1270 struct scsi_device *sdev =
1271 __scsi_add_device(host, channel, target, lun, NULL);
1272 if (IS_ERR(sdev))
1273 return PTR_ERR(sdev);
1274
1275 scsi_device_put(sdev);
1276 return 0;
1277}
1278EXPORT_SYMBOL(scsi_add_device);
1279
1263void scsi_rescan_device(struct device *dev) 1280void scsi_rescan_device(struct device *dev)
1264{ 1281{
1265 struct scsi_driver *drv; 1282 struct scsi_driver *drv;
@@ -1276,27 +1293,8 @@ void scsi_rescan_device(struct device *dev)
1276} 1293}
1277EXPORT_SYMBOL(scsi_rescan_device); 1294EXPORT_SYMBOL(scsi_rescan_device);
1278 1295
1279/** 1296static void __scsi_scan_target(struct device *parent, unsigned int channel,
1280 * scsi_scan_target - scan a target id, possibly including all LUNs on the 1297 unsigned int id, unsigned int lun, int rescan)
1281 * target.
1282 * @sdevsca: Scsi_Device handle for scanning
1283 * @shost: host to scan
1284 * @channel: channel to scan
1285 * @id: target id to scan
1286 *
1287 * Description:
1288 * Scan the target id on @shost, @channel, and @id. Scan at least LUN
1289 * 0, and possibly all LUNs on the target id.
1290 *
1291 * Use the pre-allocated @sdevscan as a handle for the scanning. This
1292 * function sets sdevscan->host, sdevscan->id and sdevscan->lun; the
1293 * scanning functions modify sdevscan->lun.
1294 *
1295 * First try a REPORT LUN scan, if that does not scan the target, do a
1296 * sequential scan of LUNs on the target id.
1297 **/
1298void scsi_scan_target(struct device *parent, unsigned int channel,
1299 unsigned int id, unsigned int lun, int rescan)
1300{ 1298{
1301 struct Scsi_Host *shost = dev_to_shost(parent); 1299 struct Scsi_Host *shost = dev_to_shost(parent);
1302 int bflags = 0; 1300 int bflags = 0;
@@ -1310,9 +1308,7 @@ void scsi_scan_target(struct device *parent, unsigned int channel,
1310 */ 1308 */
1311 return; 1309 return;
1312 1310
1313
1314 starget = scsi_alloc_target(parent, channel, id); 1311 starget = scsi_alloc_target(parent, channel, id);
1315
1316 if (!starget) 1312 if (!starget)
1317 return; 1313 return;
1318 1314
@@ -1358,6 +1354,33 @@ void scsi_scan_target(struct device *parent, unsigned int channel,
1358 1354
1359 put_device(&starget->dev); 1355 put_device(&starget->dev);
1360} 1356}
1357
1358/**
1359 * scsi_scan_target - scan a target id, possibly including all LUNs on the
1360 * target.
1361 * @parent: host to scan
1362 * @channel: channel to scan
1363 * @id: target id to scan
1364 * @lun: Specific LUN to scan or SCAN_WILD_CARD
1365 * @rescan: passed to LUN scanning routines
1366 *
1367 * Description:
1368 * Scan the target id on @parent, @channel, and @id. Scan at least LUN 0,
1369 * and possibly all LUNs on the target id.
1370 *
1371 * First try a REPORT LUN scan, if that does not scan the target, do a
1372 * sequential scan of LUNs on the target id.
1373 **/
1374void scsi_scan_target(struct device *parent, unsigned int channel,
1375 unsigned int id, unsigned int lun, int rescan)
1376{
1377 struct Scsi_Host *shost = dev_to_shost(parent);
1378
1379 down(&shost->scan_mutex);
1380 if (scsi_host_scan_allowed(shost))
1381 __scsi_scan_target(parent, channel, id, lun, rescan);
1382 up(&shost->scan_mutex);
1383}
1361EXPORT_SYMBOL(scsi_scan_target); 1384EXPORT_SYMBOL(scsi_scan_target);
1362 1385
1363static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel, 1386static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
@@ -1383,10 +1406,12 @@ static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
1383 order_id = shost->max_id - id - 1; 1406 order_id = shost->max_id - id - 1;
1384 else 1407 else
1385 order_id = id; 1408 order_id = id;
1386 scsi_scan_target(&shost->shost_gendev, channel, order_id, lun, rescan); 1409 __scsi_scan_target(&shost->shost_gendev, channel,
1410 order_id, lun, rescan);
1387 } 1411 }
1388 else 1412 else
1389 scsi_scan_target(&shost->shost_gendev, channel, id, lun, rescan); 1413 __scsi_scan_target(&shost->shost_gendev, channel,
1414 id, lun, rescan);
1390} 1415}
1391 1416
1392int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, 1417int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
@@ -1484,12 +1509,15 @@ void scsi_forget_host(struct Scsi_Host *shost)
1484 */ 1509 */
1485struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost) 1510struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost)
1486{ 1511{
1487 struct scsi_device *sdev; 1512 struct scsi_device *sdev = NULL;
1488 struct scsi_target *starget; 1513 struct scsi_target *starget;
1489 1514
1515 down(&shost->scan_mutex);
1516 if (!scsi_host_scan_allowed(shost))
1517 goto out;
1490 starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); 1518 starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id);
1491 if (!starget) 1519 if (!starget)
1492 return NULL; 1520 goto out;
1493 1521
1494 sdev = scsi_alloc_sdev(starget, 0, NULL); 1522 sdev = scsi_alloc_sdev(starget, 0, NULL);
1495 if (sdev) { 1523 if (sdev) {
@@ -1497,6 +1525,8 @@ struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost)
1497 sdev->borken = 0; 1525 sdev->borken = 0;
1498 } 1526 }
1499 put_device(&starget->dev); 1527 put_device(&starget->dev);
1528 out:
1529 up(&shost->scan_mutex);
1500 return sdev; 1530 return sdev;
1501} 1531}
1502EXPORT_SYMBOL(scsi_get_host_dev); 1532EXPORT_SYMBOL(scsi_get_host_dev);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index dae59d1da07a..b8052d5206cc 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -653,7 +653,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
653 error = attr_add(&sdev->sdev_gendev, 653 error = attr_add(&sdev->sdev_gendev,
654 sdev->host->hostt->sdev_attrs[i]); 654 sdev->host->hostt->sdev_attrs[i]);
655 if (error) { 655 if (error) {
656 scsi_remove_device(sdev); 656 __scsi_remove_device(sdev);
657 goto out; 657 goto out;
658 } 658 }
659 } 659 }
@@ -667,7 +667,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
667 scsi_sysfs_sdev_attrs[i]); 667 scsi_sysfs_sdev_attrs[i]);
668 error = device_create_file(&sdev->sdev_gendev, attr); 668 error = device_create_file(&sdev->sdev_gendev, attr);
669 if (error) { 669 if (error) {
670 scsi_remove_device(sdev); 670 __scsi_remove_device(sdev);
671 goto out; 671 goto out;
672 } 672 }
673 } 673 }
@@ -687,17 +687,10 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
687 return error; 687 return error;
688} 688}
689 689
690/** 690void __scsi_remove_device(struct scsi_device *sdev)
691 * scsi_remove_device - unregister a device from the scsi bus
692 * @sdev: scsi_device to unregister
693 **/
694void scsi_remove_device(struct scsi_device *sdev)
695{ 691{
696 struct Scsi_Host *shost = sdev->host;
697
698 down(&shost->scan_mutex);
699 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) 692 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
700 goto out; 693 return;
701 694
702 class_device_unregister(&sdev->sdev_classdev); 695 class_device_unregister(&sdev->sdev_classdev);
703 device_del(&sdev->sdev_gendev); 696 device_del(&sdev->sdev_gendev);
@@ -706,8 +699,17 @@ void scsi_remove_device(struct scsi_device *sdev)
706 sdev->host->hostt->slave_destroy(sdev); 699 sdev->host->hostt->slave_destroy(sdev);
707 transport_unregister_device(&sdev->sdev_gendev); 700 transport_unregister_device(&sdev->sdev_gendev);
708 put_device(&sdev->sdev_gendev); 701 put_device(&sdev->sdev_gendev);
709out: 702}
710 up(&shost->scan_mutex); 703
704/**
705 * scsi_remove_device - unregister a device from the scsi bus
706 * @sdev: scsi_device to unregister
707 **/
708void scsi_remove_device(struct scsi_device *sdev)
709{
710 down(&sdev->host->scan_mutex);
711 __scsi_remove_device(sdev);
712 up(&sdev->host->scan_mutex);
711} 713}
712EXPORT_SYMBOL(scsi_remove_device); 714EXPORT_SYMBOL(scsi_remove_device);
713 715
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
new file mode 100644
index 000000000000..ff724bbe6611
--- /dev/null
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -0,0 +1,820 @@
1/*
2 * Copyright (C) 2005 Dell Inc.
3 * Released under GPL v2.
4 *
5 * Serial Attached SCSI (SAS) transport class.
6 *
7 * The SAS transport class contains common code to deal with SAS HBAs,
8 * an aproximated representation of SAS topologies in the driver model,
9 * and various sysfs attributes to expose these topologies and managment
10 * interfaces to userspace.
11 *
12 * In addition to the basic SCSI core objects this transport class
13 * introduces two additional intermediate objects: The SAS PHY
14 * as represented by struct sas_phy defines an "outgoing" PHY on
15 * a SAS HBA or Expander, and the SAS remote PHY represented by
16 * struct sas_rphy defines an "incoming" PHY on a SAS Expander or
17 * end device. Note that this is purely a software concept, the
18 * underlying hardware for a PHY and a remote PHY is the exactly
19 * the same.
20 *
21 * There is no concept of a SAS port in this code, users can see
22 * what PHYs form a wide port based on the port_identifier attribute,
23 * which is the same for all PHYs in a port.
24 */
25
26#include <linux/init.h>
27#include <linux/module.h>
28#include <linux/err.h>
29
30#include <scsi/scsi_device.h>
31#include <scsi/scsi_host.h>
32#include <scsi/scsi_transport.h>
33#include <scsi/scsi_transport_sas.h>
34
35
36#define SAS_HOST_ATTRS 0
37#define SAS_PORT_ATTRS 11
38#define SAS_RPORT_ATTRS 5
39
40struct sas_internal {
41 struct scsi_transport_template t;
42 struct sas_function_template *f;
43
44 struct class_device_attribute private_host_attrs[SAS_HOST_ATTRS];
45 struct class_device_attribute private_phy_attrs[SAS_PORT_ATTRS];
46 struct class_device_attribute private_rphy_attrs[SAS_RPORT_ATTRS];
47
48 struct transport_container phy_attr_cont;
49 struct transport_container rphy_attr_cont;
50
51 /*
52 * The array of null terminated pointers to attributes
53 * needed by scsi_sysfs.c
54 */
55 struct class_device_attribute *host_attrs[SAS_HOST_ATTRS + 1];
56 struct class_device_attribute *phy_attrs[SAS_PORT_ATTRS + 1];
57 struct class_device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1];
58};
59#define to_sas_internal(tmpl) container_of(tmpl, struct sas_internal, t)
60
61struct sas_host_attrs {
62 struct list_head rphy_list;
63 spinlock_t lock;
64 u32 next_target_id;
65};
66#define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data)
67
68
69/*
70 * Hack to allow attributes of the same name in different objects.
71 */
72#define SAS_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
73 struct class_device_attribute class_device_attr_##_prefix##_##_name = \
74 __ATTR(_name,_mode,_show,_store)
75
76
77/*
78 * Pretty printing helpers
79 */
80
81#define sas_bitfield_name_match(title, table) \
82static ssize_t \
83get_sas_##title##_names(u32 table_key, char *buf) \
84{ \
85 char *prefix = ""; \
86 ssize_t len = 0; \
87 int i; \
88 \
89 for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) { \
90 if (table[i].value & table_key) { \
91 len += sprintf(buf + len, "%s%s", \
92 prefix, table[i].name); \
93 prefix = ", "; \
94 } \
95 } \
96 len += sprintf(buf + len, "\n"); \
97 return len; \
98}
99
100#define sas_bitfield_name_search(title, table) \
101static ssize_t \
102get_sas_##title##_names(u32 table_key, char *buf) \
103{ \
104 ssize_t len = 0; \
105 int i; \
106 \
107 for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) { \
108 if (table[i].value == table_key) { \
109 len += sprintf(buf + len, "%s", \
110 table[i].name); \
111 break; \
112 } \
113 } \
114 len += sprintf(buf + len, "\n"); \
115 return len; \
116}
117
118static struct {
119 u32 value;
120 char *name;
121} sas_device_type_names[] = {
122 { SAS_PHY_UNUSED, "unused" },
123 { SAS_END_DEVICE, "end device" },
124 { SAS_EDGE_EXPANDER_DEVICE, "edge expander" },
125 { SAS_FANOUT_EXPANDER_DEVICE, "fanout expander" },
126};
127sas_bitfield_name_search(device_type, sas_device_type_names)
128
129
130static struct {
131 u32 value;
132 char *name;
133} sas_protocol_names[] = {
134 { SAS_PROTOCOL_SATA, "sata" },
135 { SAS_PROTOCOL_SMP, "smp" },
136 { SAS_PROTOCOL_STP, "stp" },
137 { SAS_PROTOCOL_SSP, "ssp" },
138};
139sas_bitfield_name_match(protocol, sas_protocol_names)
140
141static struct {
142 u32 value;
143 char *name;
144} sas_linkspeed_names[] = {
145 { SAS_LINK_RATE_UNKNOWN, "Unknown" },
146 { SAS_PHY_DISABLED, "Phy disabled" },
147 { SAS_LINK_RATE_FAILED, "Link Rate failed" },
148 { SAS_SATA_SPINUP_HOLD, "Spin-up hold" },
149 { SAS_LINK_RATE_1_5_GBPS, "1.5 Gbit" },
150 { SAS_LINK_RATE_3_0_GBPS, "3.0 Gbit" },
151};
152sas_bitfield_name_search(linkspeed, sas_linkspeed_names)
153
154
155/*
156 * SAS host attributes
157 */
158
159static int sas_host_setup(struct transport_container *tc, struct device *dev,
160 struct class_device *cdev)
161{
162 struct Scsi_Host *shost = dev_to_shost(dev);
163 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
164
165 INIT_LIST_HEAD(&sas_host->rphy_list);
166 spin_lock_init(&sas_host->lock);
167 sas_host->next_target_id = 0;
168 return 0;
169}
170
171static DECLARE_TRANSPORT_CLASS(sas_host_class,
172 "sas_host", sas_host_setup, NULL, NULL);
173
174static int sas_host_match(struct attribute_container *cont,
175 struct device *dev)
176{
177 struct Scsi_Host *shost;
178 struct sas_internal *i;
179
180 if (!scsi_is_host_device(dev))
181 return 0;
182 shost = dev_to_shost(dev);
183
184 if (!shost->transportt)
185 return 0;
186 if (shost->transportt->host_attrs.ac.class !=
187 &sas_host_class.class)
188 return 0;
189
190 i = to_sas_internal(shost->transportt);
191 return &i->t.host_attrs.ac == cont;
192}
193
194static int do_sas_phy_delete(struct device *dev, void *data)
195{
196 if (scsi_is_sas_phy(dev))
197 sas_phy_delete(dev_to_phy(dev));
198 return 0;
199}
200
201/**
202 * sas_remove_host -- tear down a Scsi_Host's SAS data structures
203 * @shost: Scsi Host that is torn down
204 *
205 * Removes all SAS PHYs and remote PHYs for a given Scsi_Host.
206 * Must be called just before scsi_remove_host for SAS HBAs.
207 */
208void sas_remove_host(struct Scsi_Host *shost)
209{
210 device_for_each_child(&shost->shost_gendev, NULL, do_sas_phy_delete);
211}
212EXPORT_SYMBOL(sas_remove_host);
213
214
215/*
216 * SAS Port attributes
217 */
218
219#define sas_phy_show_simple(field, name, format_string, cast) \
220static ssize_t \
221show_sas_phy_##name(struct class_device *cdev, char *buf) \
222{ \
223 struct sas_phy *phy = transport_class_to_phy(cdev); \
224 \
225 return snprintf(buf, 20, format_string, cast phy->field); \
226}
227
228#define sas_phy_simple_attr(field, name, format_string, type) \
229 sas_phy_show_simple(field, name, format_string, (type)) \
230static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL)
231
232#define sas_phy_show_protocol(field, name) \
233static ssize_t \
234show_sas_phy_##name(struct class_device *cdev, char *buf) \
235{ \
236 struct sas_phy *phy = transport_class_to_phy(cdev); \
237 \
238 if (!phy->field) \
239 return snprintf(buf, 20, "none\n"); \
240 return get_sas_protocol_names(phy->field, buf); \
241}
242
243#define sas_phy_protocol_attr(field, name) \
244 sas_phy_show_protocol(field, name) \
245static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL)
246
247#define sas_phy_show_linkspeed(field) \
248static ssize_t \
249show_sas_phy_##field(struct class_device *cdev, char *buf) \
250{ \
251 struct sas_phy *phy = transport_class_to_phy(cdev); \
252 \
253 return get_sas_linkspeed_names(phy->field, buf); \
254}
255
256#define sas_phy_linkspeed_attr(field) \
257 sas_phy_show_linkspeed(field) \
258static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL)
259
260static ssize_t
261show_sas_device_type(struct class_device *cdev, char *buf)
262{
263 struct sas_phy *phy = transport_class_to_phy(cdev);
264
265 if (!phy->identify.device_type)
266 return snprintf(buf, 20, "none\n");
267 return get_sas_device_type_names(phy->identify.device_type, buf);
268}
269
270static CLASS_DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL);
271
272sas_phy_protocol_attr(identify.initiator_port_protocols,
273 initiator_port_protocols);
274sas_phy_protocol_attr(identify.target_port_protocols,
275 target_port_protocols);
276sas_phy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n",
277 unsigned long long);
278sas_phy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8);
279sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", u8);
280sas_phy_linkspeed_attr(negotiated_linkrate);
281sas_phy_linkspeed_attr(minimum_linkrate_hw);
282sas_phy_linkspeed_attr(minimum_linkrate);
283sas_phy_linkspeed_attr(maximum_linkrate_hw);
284sas_phy_linkspeed_attr(maximum_linkrate);
285
286
287static DECLARE_TRANSPORT_CLASS(sas_phy_class,
288 "sas_phy", NULL, NULL, NULL);
289
290static int sas_phy_match(struct attribute_container *cont, struct device *dev)
291{
292 struct Scsi_Host *shost;
293 struct sas_internal *i;
294
295 if (!scsi_is_sas_phy(dev))
296 return 0;
297 shost = dev_to_shost(dev->parent);
298
299 if (!shost->transportt)
300 return 0;
301 if (shost->transportt->host_attrs.ac.class !=
302 &sas_host_class.class)
303 return 0;
304
305 i = to_sas_internal(shost->transportt);
306 return &i->phy_attr_cont.ac == cont;
307}
308
309static void sas_phy_release(struct device *dev)
310{
311 struct sas_phy *phy = dev_to_phy(dev);
312
313 put_device(dev->parent);
314 kfree(phy);
315}
316
317/**
318 * sas_phy_alloc -- allocates and initialize a SAS PHY structure
319 * @parent: Parent device
320 * @number: Port number
321 *
322 * Allocates an SAS PHY structure. It will be added in the device tree
323 * below the device specified by @parent, which has to be either a Scsi_Host
324 * or sas_rphy.
325 *
326 * Returns:
327 * SAS PHY allocated or %NULL if the allocation failed.
328 */
329struct sas_phy *sas_phy_alloc(struct device *parent, int number)
330{
331 struct Scsi_Host *shost = dev_to_shost(parent);
332 struct sas_phy *phy;
333
334 phy = kmalloc(sizeof(*phy), GFP_KERNEL);
335 if (!phy)
336 return NULL;
337 memset(phy, 0, sizeof(*phy));
338
339 get_device(parent);
340
341 phy->number = number;
342
343 device_initialize(&phy->dev);
344 phy->dev.parent = get_device(parent);
345 phy->dev.release = sas_phy_release;
346 sprintf(phy->dev.bus_id, "phy-%d:%d", shost->host_no, number);
347
348 transport_setup_device(&phy->dev);
349
350 return phy;
351}
352EXPORT_SYMBOL(sas_phy_alloc);
353
354/**
355 * sas_phy_add -- add a SAS PHY to the device hierachy
356 * @phy: The PHY to be added
357 *
358 * Publishes a SAS PHY to the rest of the system.
359 */
360int sas_phy_add(struct sas_phy *phy)
361{
362 int error;
363
364 error = device_add(&phy->dev);
365 if (!error) {
366 transport_add_device(&phy->dev);
367 transport_configure_device(&phy->dev);
368 }
369
370 return error;
371}
372EXPORT_SYMBOL(sas_phy_add);
373
374/**
375 * sas_phy_free -- free a SAS PHY
376 * @phy: SAS PHY to free
377 *
378 * Frees the specified SAS PHY.
379 *
380 * Note:
381 * This function must only be called on a PHY that has not
382 * sucessfully been added using sas_phy_add().
383 */
384void sas_phy_free(struct sas_phy *phy)
385{
386 transport_destroy_device(&phy->dev);
387 put_device(phy->dev.parent);
388 put_device(phy->dev.parent);
389 put_device(phy->dev.parent);
390 kfree(phy);
391}
392EXPORT_SYMBOL(sas_phy_free);
393
394/**
395 * sas_phy_delete -- remove SAS PHY
396 * @phy: SAS PHY to remove
397 *
398 * Removes the specified SAS PHY. If the SAS PHY has an
399 * associated remote PHY it is removed before.
400 */
401void
402sas_phy_delete(struct sas_phy *phy)
403{
404 struct device *dev = &phy->dev;
405
406 if (phy->rphy)
407 sas_rphy_delete(phy->rphy);
408
409 transport_remove_device(dev);
410 device_del(dev);
411 transport_destroy_device(dev);
412 put_device(dev->parent);
413}
414EXPORT_SYMBOL(sas_phy_delete);
415
416/**
417 * scsi_is_sas_phy -- check if a struct device represents a SAS PHY
418 * @dev: device to check
419 *
420 * Returns:
421 * %1 if the device represents a SAS PHY, %0 else
422 */
423int scsi_is_sas_phy(const struct device *dev)
424{
425 return dev->release == sas_phy_release;
426}
427EXPORT_SYMBOL(scsi_is_sas_phy);
428
429/*
430 * SAS remote PHY attributes.
431 */
432
433#define sas_rphy_show_simple(field, name, format_string, cast) \
434static ssize_t \
435show_sas_rphy_##name(struct class_device *cdev, char *buf) \
436{ \
437 struct sas_rphy *rphy = transport_class_to_rphy(cdev); \
438 \
439 return snprintf(buf, 20, format_string, cast rphy->field); \
440}
441
442#define sas_rphy_simple_attr(field, name, format_string, type) \
443 sas_rphy_show_simple(field, name, format_string, (type)) \
444static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \
445 show_sas_rphy_##name, NULL)
446
447#define sas_rphy_show_protocol(field, name) \
448static ssize_t \
449show_sas_rphy_##name(struct class_device *cdev, char *buf) \
450{ \
451 struct sas_rphy *rphy = transport_class_to_rphy(cdev); \
452 \
453 if (!rphy->field) \
454 return snprintf(buf, 20, "none\n"); \
455 return get_sas_protocol_names(rphy->field, buf); \
456}
457
458#define sas_rphy_protocol_attr(field, name) \
459 sas_rphy_show_protocol(field, name) \
460static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \
461 show_sas_rphy_##name, NULL)
462
463static ssize_t
464show_sas_rphy_device_type(struct class_device *cdev, char *buf)
465{
466 struct sas_rphy *rphy = transport_class_to_rphy(cdev);
467
468 if (!rphy->identify.device_type)
469 return snprintf(buf, 20, "none\n");
470 return get_sas_device_type_names(
471 rphy->identify.device_type, buf);
472}
473
474static SAS_CLASS_DEVICE_ATTR(rphy, device_type, S_IRUGO,
475 show_sas_rphy_device_type, NULL);
476
477sas_rphy_protocol_attr(identify.initiator_port_protocols,
478 initiator_port_protocols);
479sas_rphy_protocol_attr(identify.target_port_protocols, target_port_protocols);
480sas_rphy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n",
481 unsigned long long);
482sas_rphy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8);
483
484static DECLARE_TRANSPORT_CLASS(sas_rphy_class,
485 "sas_rphy", NULL, NULL, NULL);
486
487static int sas_rphy_match(struct attribute_container *cont, struct device *dev)
488{
489 struct Scsi_Host *shost;
490 struct sas_internal *i;
491
492 if (!scsi_is_sas_rphy(dev))
493 return 0;
494 shost = dev_to_shost(dev->parent->parent);
495
496 if (!shost->transportt)
497 return 0;
498 if (shost->transportt->host_attrs.ac.class !=
499 &sas_host_class.class)
500 return 0;
501
502 i = to_sas_internal(shost->transportt);
503 return &i->rphy_attr_cont.ac == cont;
504}
505
506static void sas_rphy_release(struct device *dev)
507{
508 struct sas_rphy *rphy = dev_to_rphy(dev);
509
510 put_device(dev->parent);
511 kfree(rphy);
512}
513
514/**
515 * sas_rphy_alloc -- allocates and initialize a SAS remote PHY structure
516 * @parent: SAS PHY this remote PHY is conneted to
517 *
518 * Allocates an SAS remote PHY structure, connected to @parent.
519 *
520 * Returns:
521 * SAS PHY allocated or %NULL if the allocation failed.
522 */
523struct sas_rphy *sas_rphy_alloc(struct sas_phy *parent)
524{
525 struct Scsi_Host *shost = dev_to_shost(&parent->dev);
526 struct sas_rphy *rphy;
527
528 rphy = kmalloc(sizeof(*rphy), GFP_KERNEL);
529 if (!rphy) {
530 put_device(&parent->dev);
531 return NULL;
532 }
533 memset(rphy, 0, sizeof(*rphy));
534
535 device_initialize(&rphy->dev);
536 rphy->dev.parent = get_device(&parent->dev);
537 rphy->dev.release = sas_rphy_release;
538 sprintf(rphy->dev.bus_id, "rphy-%d:%d",
539 shost->host_no, parent->number);
540 transport_setup_device(&rphy->dev);
541
542 return rphy;
543}
544EXPORT_SYMBOL(sas_rphy_alloc);
545
546/**
547 * sas_rphy_add -- add a SAS remote PHY to the device hierachy
548 * @rphy: The remote PHY to be added
549 *
550 * Publishes a SAS remote PHY to the rest of the system.
551 */
552int sas_rphy_add(struct sas_rphy *rphy)
553{
554 struct sas_phy *parent = dev_to_phy(rphy->dev.parent);
555 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
556 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
557 struct sas_identify *identify = &rphy->identify;
558 int error;
559
560 if (parent->rphy)
561 return -ENXIO;
562 parent->rphy = rphy;
563
564 error = device_add(&rphy->dev);
565 if (error)
566 return error;
567 transport_add_device(&rphy->dev);
568 transport_configure_device(&rphy->dev);
569
570 spin_lock(&sas_host->lock);
571 list_add_tail(&rphy->list, &sas_host->rphy_list);
572 if (identify->device_type == SAS_END_DEVICE &&
573 (identify->target_port_protocols &
574 (SAS_PROTOCOL_SSP|SAS_PROTOCOL_STP|SAS_PROTOCOL_SATA)))
575 rphy->scsi_target_id = sas_host->next_target_id++;
576 else
577 rphy->scsi_target_id = -1;
578 spin_unlock(&sas_host->lock);
579
580 if (rphy->scsi_target_id != -1) {
581 scsi_scan_target(&rphy->dev, parent->number,
582 rphy->scsi_target_id, ~0, 0);
583 }
584
585 return 0;
586}
587EXPORT_SYMBOL(sas_rphy_add);
588
589/**
590 * sas_rphy_free -- free a SAS remote PHY
591 * @rphy SAS remote PHY to free
592 *
593 * Frees the specified SAS remote PHY.
594 *
595 * Note:
596 * This function must only be called on a remote
597 * PHY that has not sucessfully been added using
598 * sas_rphy_add().
599 */
600void sas_rphy_free(struct sas_rphy *rphy)
601{
602 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent);
603 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
604
605 spin_lock(&sas_host->lock);
606 list_del(&rphy->list);
607 spin_unlock(&sas_host->lock);
608
609 transport_destroy_device(&rphy->dev);
610 put_device(rphy->dev.parent);
611 put_device(rphy->dev.parent);
612 put_device(rphy->dev.parent);
613 kfree(rphy);
614}
615EXPORT_SYMBOL(sas_rphy_free);
616
617/**
618 * sas_rphy_delete -- remove SAS remote PHY
619 * @rphy: SAS remote PHY to remove
620 *
621 * Removes the specified SAS remote PHY.
622 */
623void
624sas_rphy_delete(struct sas_rphy *rphy)
625{
626 struct device *dev = &rphy->dev;
627 struct sas_phy *parent = dev_to_phy(dev->parent);
628 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
629 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
630
631 transport_destroy_device(&rphy->dev);
632
633 scsi_remove_target(&rphy->dev);
634
635 spin_lock(&sas_host->lock);
636 list_del(&rphy->list);
637 spin_unlock(&sas_host->lock);
638
639 transport_remove_device(dev);
640 device_del(dev);
641 transport_destroy_device(dev);
642 put_device(&parent->dev);
643}
644EXPORT_SYMBOL(sas_rphy_delete);
645
646/**
647 * scsi_is_sas_rphy -- check if a struct device represents a SAS remote PHY
648 * @dev: device to check
649 *
650 * Returns:
651 * %1 if the device represents a SAS remote PHY, %0 else
652 */
653int scsi_is_sas_rphy(const struct device *dev)
654{
655 return dev->release == sas_rphy_release;
656}
657EXPORT_SYMBOL(scsi_is_sas_rphy);
658
659
660/*
661 * SCSI scan helper
662 */
663
664static struct device *sas_target_parent(struct Scsi_Host *shost,
665 int channel, uint id)
666{
667 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
668 struct sas_rphy *rphy;
669 struct device *dev = NULL;
670
671 spin_lock(&sas_host->lock);
672 list_for_each_entry(rphy, &sas_host->rphy_list, list) {
673 struct sas_phy *parent = dev_to_phy(rphy->dev.parent);
674 if (parent->number == channel &&
675 rphy->scsi_target_id == id)
676 dev = &rphy->dev;
677 }
678 spin_unlock(&sas_host->lock);
679
680 return dev;
681}
682
683
684/*
685 * Setup / Teardown code
686 */
687
688#define SETUP_RPORT_ATTRIBUTE(field) \
689 i->private_rphy_attrs[count] = class_device_attr_##field; \
690 i->private_rphy_attrs[count].attr.mode = S_IRUGO; \
691 i->private_rphy_attrs[count].store = NULL; \
692 i->rphy_attrs[count] = &i->private_rphy_attrs[count]; \
693 count++
694
695#define SETUP_PORT_ATTRIBUTE(field) \
696 i->private_phy_attrs[count] = class_device_attr_##field; \
697 i->private_phy_attrs[count].attr.mode = S_IRUGO; \
698 i->private_phy_attrs[count].store = NULL; \
699 i->phy_attrs[count] = &i->private_phy_attrs[count]; \
700 count++
701
702
703/**
704 * sas_attach_transport -- instantiate SAS transport template
705 * @ft: SAS transport class function template
706 */
707struct scsi_transport_template *
708sas_attach_transport(struct sas_function_template *ft)
709{
710 struct sas_internal *i;
711 int count;
712
713 i = kmalloc(sizeof(struct sas_internal), GFP_KERNEL);
714 if (!i)
715 return NULL;
716 memset(i, 0, sizeof(struct sas_internal));
717
718 i->t.target_parent = sas_target_parent;
719
720 i->t.host_attrs.ac.attrs = &i->host_attrs[0];
721 i->t.host_attrs.ac.class = &sas_host_class.class;
722 i->t.host_attrs.ac.match = sas_host_match;
723 transport_container_register(&i->t.host_attrs);
724 i->t.host_size = sizeof(struct sas_host_attrs);
725
726 i->phy_attr_cont.ac.class = &sas_phy_class.class;
727 i->phy_attr_cont.ac.attrs = &i->phy_attrs[0];
728 i->phy_attr_cont.ac.match = sas_phy_match;
729 transport_container_register(&i->phy_attr_cont);
730
731 i->rphy_attr_cont.ac.class = &sas_rphy_class.class;
732 i->rphy_attr_cont.ac.attrs = &i->rphy_attrs[0];
733 i->rphy_attr_cont.ac.match = sas_rphy_match;
734 transport_container_register(&i->rphy_attr_cont);
735
736 i->f = ft;
737
738 count = 0;
739 i->host_attrs[count] = NULL;
740
741 count = 0;
742 SETUP_PORT_ATTRIBUTE(initiator_port_protocols);
743 SETUP_PORT_ATTRIBUTE(target_port_protocols);
744 SETUP_PORT_ATTRIBUTE(device_type);
745 SETUP_PORT_ATTRIBUTE(sas_address);
746 SETUP_PORT_ATTRIBUTE(phy_identifier);
747 SETUP_PORT_ATTRIBUTE(port_identifier);
748 SETUP_PORT_ATTRIBUTE(negotiated_linkrate);
749 SETUP_PORT_ATTRIBUTE(minimum_linkrate_hw);
750 SETUP_PORT_ATTRIBUTE(minimum_linkrate);
751 SETUP_PORT_ATTRIBUTE(maximum_linkrate_hw);
752 SETUP_PORT_ATTRIBUTE(maximum_linkrate);
753 i->phy_attrs[count] = NULL;
754
755 count = 0;
756 SETUP_RPORT_ATTRIBUTE(rphy_initiator_port_protocols);
757 SETUP_RPORT_ATTRIBUTE(rphy_target_port_protocols);
758 SETUP_RPORT_ATTRIBUTE(rphy_device_type);
759 SETUP_RPORT_ATTRIBUTE(rphy_sas_address);
760 SETUP_RPORT_ATTRIBUTE(rphy_phy_identifier);
761 i->rphy_attrs[count] = NULL;
762
763 return &i->t;
764}
765EXPORT_SYMBOL(sas_attach_transport);
766
767/**
768 * sas_release_transport -- release SAS transport template instance
769 * @t: transport template instance
770 */
771void sas_release_transport(struct scsi_transport_template *t)
772{
773 struct sas_internal *i = to_sas_internal(t);
774
775 transport_container_unregister(&i->t.host_attrs);
776 transport_container_unregister(&i->phy_attr_cont);
777 transport_container_unregister(&i->rphy_attr_cont);
778
779 kfree(i);
780}
781EXPORT_SYMBOL(sas_release_transport);
782
783static __init int sas_transport_init(void)
784{
785 int error;
786
787 error = transport_class_register(&sas_host_class);
788 if (error)
789 goto out;
790 error = transport_class_register(&sas_phy_class);
791 if (error)
792 goto out_unregister_transport;
793 error = transport_class_register(&sas_rphy_class);
794 if (error)
795 goto out_unregister_phy;
796
797 return 0;
798
799 out_unregister_phy:
800 transport_class_unregister(&sas_phy_class);
801 out_unregister_transport:
802 transport_class_unregister(&sas_host_class);
803 out:
804 return error;
805
806}
807
808static void __exit sas_transport_exit(void)
809{
810 transport_class_unregister(&sas_host_class);
811 transport_class_unregister(&sas_phy_class);
812 transport_class_unregister(&sas_rphy_class);
813}
814
815MODULE_AUTHOR("Christoph Hellwig");
816MODULE_DESCRIPTION("SAS Transphy Attributes");
817MODULE_LICENSE("GPL");
818
819module_init(sas_transport_init);
820module_exit(sas_transport_exit);
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index b1b69d738d08..9ea4765d1d12 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -61,7 +61,7 @@ static int sg_version_num = 30533; /* 2 digits for each component */
61 61
62#ifdef CONFIG_SCSI_PROC_FS 62#ifdef CONFIG_SCSI_PROC_FS
63#include <linux/proc_fs.h> 63#include <linux/proc_fs.h>
64static char *sg_version_date = "20050901"; 64static char *sg_version_date = "20050908";
65 65
66static int sg_proc_init(void); 66static int sg_proc_init(void);
67static void sg_proc_cleanup(void); 67static void sg_proc_cleanup(void);
@@ -1299,7 +1299,7 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma)
1299 sg_rb_correct4mmap(rsv_schp, 1); /* do only once per fd lifetime */ 1299 sg_rb_correct4mmap(rsv_schp, 1); /* do only once per fd lifetime */
1300 sfp->mmap_called = 1; 1300 sfp->mmap_called = 1;
1301 } 1301 }
1302 vma->vm_flags |= (VM_RESERVED | VM_IO); 1302 vma->vm_flags |= VM_RESERVED;
1303 vma->vm_private_data = sfp; 1303 vma->vm_private_data = sfp;
1304 vma->vm_ops = &sg_mmap_vm_ops; 1304 vma->vm_ops = &sg_mmap_vm_ops;
1305 return 0; 1305 return 0;
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c
index 4382ee60b6a8..6bed8713897e 100644
--- a/drivers/tc/zs.c
+++ b/drivers/tc/zs.c
@@ -1683,7 +1683,7 @@ static void __init probe_sccs(void)
1683#ifndef CONFIG_SERIAL_DEC_CONSOLE 1683#ifndef CONFIG_SERIAL_DEC_CONSOLE
1684 /* 1684 /*
1685 * We're called early and memory managment isn't up, yet. 1685 * We're called early and memory managment isn't up, yet.
1686 * Thus check_region would fail. 1686 * Thus request_region would fail.
1687 */ 1687 */
1688 if (!request_region((unsigned long) 1688 if (!request_region((unsigned long)
1689 zs_channels[n_channels].control, 1689 zs_channels[n_channels].control,
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 615874e03ce8..31ee13eef7af 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -753,7 +753,8 @@ config FB_I810_GTF
753 753
754config FB_I810_I2C 754config FB_I810_I2C
755 bool "Enable DDC Support" 755 bool "Enable DDC Support"
756 depends on FB_I810 && I2C && FB_I810_GTF 756 depends on FB_I810 && FB_I810_GTF
757 select I2C
757 select I2C_ALGOBIT 758 select I2C_ALGOBIT
758 help 759 help
759 760
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
index 353cb3f73cf2..a32817678552 100644
--- a/drivers/video/backlight/corgi_bl.c
+++ b/drivers/video/backlight/corgi_bl.c
@@ -43,18 +43,10 @@ static void corgibl_send_intensity(int intensity)
43 intensity &= CORGI_LIMIT_MASK; 43 intensity &= CORGI_LIMIT_MASK;
44 } 44 }
45 45
46 /* Skip 0x20 as it will blank the display */
47 if (intensity >= 0x20)
48 intensity++;
49
50 spin_lock_irqsave(&bl_lock, flags); 46 spin_lock_irqsave(&bl_lock, flags);
51 /* Bits 0-4 are accessed via the SSP interface */ 47
52 corgi_ssp_blduty_set(intensity & 0x1f); 48 corgibl_mach_set_intensity(intensity);
53 /* Bit 5 is via SCOOP */ 49
54 if (intensity & 0x0020)
55 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
56 else
57 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
58 spin_unlock_irqrestore(&bl_lock, flags); 50 spin_unlock_irqrestore(&bl_lock, flags);
59} 51}
60 52
@@ -113,8 +105,8 @@ static int corgibl_get_power(struct backlight_device *bd)
113 105
114static int corgibl_set_intensity(struct backlight_device *bd, int intensity) 106static int corgibl_set_intensity(struct backlight_device *bd, int intensity)
115{ 107{
116 if (intensity > CORGI_MAX_INTENSITY) 108 if (intensity > corgibl_data.max_brightness)
117 intensity = CORGI_MAX_INTENSITY; 109 intensity = corgibl_data.max_brightness;
118 corgibl_send_intensity(intensity); 110 corgibl_send_intensity(intensity);
119 current_intensity=intensity; 111 current_intensity=intensity;
120 return 0; 112 return 0;
@@ -141,7 +133,6 @@ static struct backlight_properties corgibl_data = {
141 .owner = THIS_MODULE, 133 .owner = THIS_MODULE,
142 .get_power = corgibl_get_power, 134 .get_power = corgibl_get_power,
143 .set_power = corgibl_set_power, 135 .set_power = corgibl_set_power,
144 .max_brightness = CORGI_MAX_INTENSITY,
145 .get_brightness = corgibl_get_intensity, 136 .get_brightness = corgibl_get_intensity,
146 .set_brightness = corgibl_set_intensity, 137 .set_brightness = corgibl_set_intensity,
147}; 138};
@@ -150,12 +141,18 @@ static struct backlight_device *corgi_backlight_device;
150 141
151static int __init corgibl_probe(struct device *dev) 142static int __init corgibl_probe(struct device *dev)
152{ 143{
144 struct corgibl_machinfo *machinfo = dev->platform_data;
145
146 corgibl_data.max_brightness = machinfo->max_intensity;
147 corgibl_mach_set_intensity = machinfo->set_bl_intensity;
148
153 corgi_backlight_device = backlight_device_register ("corgi-bl", 149 corgi_backlight_device = backlight_device_register ("corgi-bl",
154 NULL, &corgibl_data); 150 NULL, &corgibl_data);
155 if (IS_ERR (corgi_backlight_device)) 151 if (IS_ERR (corgi_backlight_device))
156 return PTR_ERR (corgi_backlight_device); 152 return PTR_ERR (corgi_backlight_device);
157 153
158 corgibl_set_intensity(NULL, CORGI_DEFAULT_INTENSITY); 154 corgibl_set_intensity(NULL, CORGI_DEFAULT_INTENSITY);
155 corgibl_limit_intensity(0);
159 156
160 printk("Corgi Backlight Driver Initialized.\n"); 157 printk("Corgi Backlight Driver Initialized.\n");
161 return 0; 158 return 0;
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 2e93224d2d55..0fc8bb499c3f 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -767,7 +767,7 @@ static const char *fbcon_startup(void)
767 const char *display_desc = "frame buffer device"; 767 const char *display_desc = "frame buffer device";
768 struct display *p = &fb_display[fg_console]; 768 struct display *p = &fb_display[fg_console];
769 struct vc_data *vc = vc_cons[fg_console].d; 769 struct vc_data *vc = vc_cons[fg_console].d;
770 struct font_desc *font = NULL; 770 const struct font_desc *font = NULL;
771 struct module *owner; 771 struct module *owner;
772 struct fb_info *info = NULL; 772 struct fb_info *info = NULL;
773 struct fbcon_ops *ops; 773 struct fbcon_ops *ops;
@@ -841,7 +841,7 @@ static const char *fbcon_startup(void)
841 info->var.yres); 841 info->var.yres);
842 vc->vc_font.width = font->width; 842 vc->vc_font.width = font->width;
843 vc->vc_font.height = font->height; 843 vc->vc_font.height = font->height;
844 vc->vc_font.data = p->fontdata = font->data; 844 vc->vc_font.data = (void *)(p->fontdata = font->data);
845 vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */ 845 vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */
846 } 846 }
847 847
@@ -941,7 +941,7 @@ static void fbcon_init(struct vc_data *vc, int init)
941 fb, copy the font from that console */ 941 fb, copy the font from that console */
942 t = &fb_display[svc->vc_num]; 942 t = &fb_display[svc->vc_num];
943 if (!vc->vc_font.data) { 943 if (!vc->vc_font.data) {
944 vc->vc_font.data = p->fontdata = t->fontdata; 944 vc->vc_font.data = (void *)(p->fontdata = t->fontdata);
945 vc->vc_font.width = (*default_mode)->vc_font.width; 945 vc->vc_font.width = (*default_mode)->vc_font.width;
946 vc->vc_font.height = (*default_mode)->vc_font.height; 946 vc->vc_font.height = (*default_mode)->vc_font.height;
947 p->userfont = t->userfont; 947 p->userfont = t->userfont;
@@ -1188,7 +1188,7 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
1188 return; 1188 return;
1189 t = &fb_display[svc->vc_num]; 1189 t = &fb_display[svc->vc_num];
1190 if (!vc->vc_font.data) { 1190 if (!vc->vc_font.data) {
1191 vc->vc_font.data = p->fontdata = t->fontdata; 1191 vc->vc_font.data = (void *)(p->fontdata = t->fontdata);
1192 vc->vc_font.width = (*default_mode)->vc_font.width; 1192 vc->vc_font.width = (*default_mode)->vc_font.width;
1193 vc->vc_font.height = (*default_mode)->vc_font.height; 1193 vc->vc_font.height = (*default_mode)->vc_font.height;
1194 p->userfont = t->userfont; 1194 p->userfont = t->userfont;
@@ -1687,6 +1687,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1687 case SM_DOWN: 1687 case SM_DOWN:
1688 if (count > vc->vc_rows) /* Maximum realistic size */ 1688 if (count > vc->vc_rows) /* Maximum realistic size */
1689 count = vc->vc_rows; 1689 count = vc->vc_rows;
1690 if (logo_shown >= 0)
1691 goto redraw_down;
1690 switch (p->scrollmode) { 1692 switch (p->scrollmode) {
1691 case SCROLL_MOVE: 1693 case SCROLL_MOVE:
1692 ops->bmove(vc, info, t, 0, t + count, 0, 1694 ops->bmove(vc, info, t, 0, t + count, 0,
@@ -2148,7 +2150,7 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font)
2148} 2150}
2149 2151
2150static int fbcon_do_set_font(struct vc_data *vc, int w, int h, 2152static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2151 u8 * data, int userfont) 2153 const u8 * data, int userfont)
2152{ 2154{
2153 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; 2155 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2154 struct display *p = &fb_display[vc->vc_num]; 2156 struct display *p = &fb_display[vc->vc_num];
@@ -2166,7 +2168,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2166 cnt = FNTCHARCNT(data); 2168 cnt = FNTCHARCNT(data);
2167 else 2169 else
2168 cnt = 256; 2170 cnt = 256;
2169 vc->vc_font.data = p->fontdata = data; 2171 vc->vc_font.data = (void *)(p->fontdata = data);
2170 if ((p->userfont = userfont)) 2172 if ((p->userfont = userfont))
2171 REFCOUNT(data)++; 2173 REFCOUNT(data)++;
2172 vc->vc_font.width = w; 2174 vc->vc_font.width = w;
@@ -2323,7 +2325,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigne
2323 tmp->vc_font.width == w && 2325 tmp->vc_font.width == w &&
2324 !memcmp(fb_display[i].fontdata, new_data, size)) { 2326 !memcmp(fb_display[i].fontdata, new_data, size)) {
2325 kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); 2327 kfree(new_data - FONT_EXTRA_WORDS * sizeof(int));
2326 new_data = fb_display[i].fontdata; 2328 new_data = (u8 *)fb_display[i].fontdata;
2327 break; 2329 break;
2328 } 2330 }
2329 } 2331 }
@@ -2333,7 +2335,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigne
2333static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name) 2335static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name)
2334{ 2336{
2335 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; 2337 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2336 struct font_desc *f; 2338 const struct font_desc *f;
2337 2339
2338 if (!name) 2340 if (!name)
2339 f = get_default_font(info->var.xres, info->var.yres); 2341 f = get_default_font(info->var.xres, info->var.yres);
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
index 08befafe11d1..0738cd62def2 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/console/fbcon.h
@@ -30,7 +30,7 @@ struct display {
30 /* Filled in by the frame buffer device */ 30 /* Filled in by the frame buffer device */
31 u_short inverse; /* != 0 text black on white as default */ 31 u_short inverse; /* != 0 text black on white as default */
32 /* Filled in by the low-level console driver */ 32 /* Filled in by the low-level console driver */
33 u_char *fontdata; 33 const u_char *fontdata;
34 int userfont; /* != 0 if fontdata kmalloc()ed */ 34 int userfont; /* != 0 if fontdata kmalloc()ed */
35 u_short scrollmode; /* Scroll Method */ 35 u_short scrollmode; /* Scroll Method */
36 short yscroll; /* Hardware scrolling */ 36 short yscroll; /* Hardware scrolling */
diff --git a/drivers/video/console/font_10x18.c b/drivers/video/console/font_10x18.c
index ff0af96e4dfc..e6aa0eab5bb6 100644
--- a/drivers/video/console/font_10x18.c
+++ b/drivers/video/console/font_10x18.c
@@ -7,7 +7,7 @@
7 7
8#define FONTDATAMAX 9216 8#define FONTDATAMAX 9216
9 9
10static unsigned char fontdata_10x18[FONTDATAMAX] = { 10static const unsigned char fontdata_10x18[FONTDATAMAX] = {
11 11
12 /* 0 0x00 '^@' */ 12 /* 0 0x00 '^@' */
13 0x00, 0x00, /* 0000000000 */ 13 0x00, 0x00, /* 0000000000 */
@@ -5132,7 +5132,7 @@ static unsigned char fontdata_10x18[FONTDATAMAX] = {
5132}; 5132};
5133 5133
5134 5134
5135struct font_desc font_10x18 = { 5135const struct font_desc font_10x18 = {
5136 FONT10x18_IDX, 5136 FONT10x18_IDX,
5137 "10x18", 5137 "10x18",
5138 10, 5138 10,
diff --git a/drivers/video/console/font_6x11.c b/drivers/video/console/font_6x11.c
index c52f1294044a..89976cd97494 100644
--- a/drivers/video/console/font_6x11.c
+++ b/drivers/video/console/font_6x11.c
@@ -8,7 +8,7 @@
8 8
9#define FONTDATAMAX (11*256) 9#define FONTDATAMAX (11*256)
10 10
11static unsigned char fontdata_6x11[FONTDATAMAX] = { 11static const unsigned char fontdata_6x11[FONTDATAMAX] = {
12 12
13 /* 0 0x00 '^@' */ 13 /* 0 0x00 '^@' */
14 0x00, /* 00000000 */ 14 0x00, /* 00000000 */
@@ -3341,7 +3341,7 @@ static unsigned char fontdata_6x11[FONTDATAMAX] = {
3341}; 3341};
3342 3342
3343 3343
3344struct font_desc font_vga_6x11 = { 3344const struct font_desc font_vga_6x11 = {
3345 VGA6x11_IDX, 3345 VGA6x11_IDX,
3346 "ProFont6x11", 3346 "ProFont6x11",
3347 6, 3347 6,
diff --git a/drivers/video/console/font_7x14.c b/drivers/video/console/font_7x14.c
index 1fa7fcf2ff72..bbf116647397 100644
--- a/drivers/video/console/font_7x14.c
+++ b/drivers/video/console/font_7x14.c
@@ -7,7 +7,7 @@
7 7
8#define FONTDATAMAX 3584 8#define FONTDATAMAX 3584
9 9
10static unsigned char fontdata_7x14[FONTDATAMAX] = { 10static const unsigned char fontdata_7x14[FONTDATAMAX] = {
11 11
12 /* 0 0x00 '^@' */ 12 /* 0 0x00 '^@' */
13 0x00, /* 0000000 */ 13 0x00, /* 0000000 */
@@ -4108,7 +4108,7 @@ static unsigned char fontdata_7x14[FONTDATAMAX] = {
4108}; 4108};
4109 4109
4110 4110
4111struct font_desc font_7x14 = { 4111const struct font_desc font_7x14 = {
4112 FONT7x14_IDX, 4112 FONT7x14_IDX,
4113 "7x14", 4113 "7x14",
4114 7, 4114 7,
diff --git a/drivers/video/console/font_8x16.c b/drivers/video/console/font_8x16.c
index e6f8dbaa122b..74fe86f28ff4 100644
--- a/drivers/video/console/font_8x16.c
+++ b/drivers/video/console/font_8x16.c
@@ -8,7 +8,7 @@
8 8
9#define FONTDATAMAX 4096 9#define FONTDATAMAX 4096
10 10
11static unsigned char fontdata_8x16[FONTDATAMAX] = { 11static const unsigned char fontdata_8x16[FONTDATAMAX] = {
12 12
13 /* 0 0x00 '^@' */ 13 /* 0 0x00 '^@' */
14 0x00, /* 00000000 */ 14 0x00, /* 00000000 */
@@ -4621,7 +4621,7 @@ static unsigned char fontdata_8x16[FONTDATAMAX] = {
4621}; 4621};
4622 4622
4623 4623
4624struct font_desc font_vga_8x16 = { 4624const struct font_desc font_vga_8x16 = {
4625 VGA8x16_IDX, 4625 VGA8x16_IDX,
4626 "VGA8x16", 4626 "VGA8x16",
4627 8, 4627 8,
diff --git a/drivers/video/console/font_8x8.c b/drivers/video/console/font_8x8.c
index 57fbe266a6b9..26199f8ee908 100644
--- a/drivers/video/console/font_8x8.c
+++ b/drivers/video/console/font_8x8.c
@@ -8,7 +8,7 @@
8 8
9#define FONTDATAMAX 2048 9#define FONTDATAMAX 2048
10 10
11static unsigned char fontdata_8x8[FONTDATAMAX] = { 11static const unsigned char fontdata_8x8[FONTDATAMAX] = {
12 12
13 /* 0 0x00 '^@' */ 13 /* 0 0x00 '^@' */
14 0x00, /* 00000000 */ 14 0x00, /* 00000000 */
@@ -2573,7 +2573,7 @@ static unsigned char fontdata_8x8[FONTDATAMAX] = {
2573}; 2573};
2574 2574
2575 2575
2576struct font_desc font_vga_8x8 = { 2576const struct font_desc font_vga_8x8 = {
2577 VGA8x8_IDX, 2577 VGA8x8_IDX,
2578 "VGA8x8", 2578 "VGA8x8",
2579 8, 2579 8,
diff --git a/drivers/video/console/font_acorn_8x8.c b/drivers/video/console/font_acorn_8x8.c
index d565505e3069..2d2e39632e2d 100644
--- a/drivers/video/console/font_acorn_8x8.c
+++ b/drivers/video/console/font_acorn_8x8.c
@@ -3,7 +3,7 @@
3#include <linux/config.h> 3#include <linux/config.h>
4#include <linux/font.h> 4#include <linux/font.h>
5 5
6static unsigned char acorndata_8x8[] = { 6static const unsigned char acorndata_8x8[] = {
7/* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */ 7/* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */
8/* 01 */ 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */ 8/* 01 */ 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */
9/* 02 */ 0x7e, 0xff, 0xbd, 0xff, 0xc3, 0xe7, 0xff, 0x7e, /* ^B */ 9/* 02 */ 0x7e, 0xff, 0xbd, 0xff, 0xc3, 0xe7, 0xff, 0x7e, /* ^B */
@@ -262,7 +262,7 @@ static unsigned char acorndata_8x8[] = {
262/* FF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 262/* FF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
263}; 263};
264 264
265struct font_desc font_acorn_8x8 = { 265const struct font_desc font_acorn_8x8 = {
266 ACORN8x8_IDX, 266 ACORN8x8_IDX,
267 "Acorn8x8", 267 "Acorn8x8",
268 8, 268 8,
diff --git a/drivers/video/console/font_mini_4x6.c b/drivers/video/console/font_mini_4x6.c
index 593b95500a0c..d818234fdf11 100644
--- a/drivers/video/console/font_mini_4x6.c
+++ b/drivers/video/console/font_mini_4x6.c
@@ -43,7 +43,7 @@ __END__;
43 43
44#define FONTDATAMAX 1536 44#define FONTDATAMAX 1536
45 45
46static unsigned char fontdata_mini_4x6[FONTDATAMAX] = { 46static const unsigned char fontdata_mini_4x6[FONTDATAMAX] = {
47 47
48 /*{*/ 48 /*{*/
49 /* Char 0: ' ' */ 49 /* Char 0: ' ' */
@@ -2147,7 +2147,7 @@ static unsigned char fontdata_mini_4x6[FONTDATAMAX] = {
2147 /*}*/ 2147 /*}*/
2148}; 2148};
2149 2149
2150struct font_desc font_mini_4x6 = { 2150const struct font_desc font_mini_4x6 = {
2151 MINI4x6_IDX, 2151 MINI4x6_IDX,
2152 "MINI4x6", 2152 "MINI4x6",
2153 4, 2153 4,
diff --git a/drivers/video/console/font_pearl_8x8.c b/drivers/video/console/font_pearl_8x8.c
index 5fa95f118818..e646c88f55c7 100644
--- a/drivers/video/console/font_pearl_8x8.c
+++ b/drivers/video/console/font_pearl_8x8.c
@@ -13,7 +13,7 @@
13 13
14#define FONTDATAMAX 2048 14#define FONTDATAMAX 2048
15 15
16static unsigned char fontdata_pearl8x8[FONTDATAMAX] = { 16static const unsigned char fontdata_pearl8x8[FONTDATAMAX] = {
17 17
18 /* 0 0x00 '^@' */ 18 /* 0 0x00 '^@' */
19 0x00, /* 00000000 */ 19 0x00, /* 00000000 */
@@ -2577,7 +2577,7 @@ static unsigned char fontdata_pearl8x8[FONTDATAMAX] = {
2577 2577
2578}; 2578};
2579 2579
2580struct font_desc font_pearl_8x8 = { 2580const struct font_desc font_pearl_8x8 = {
2581 PEARL8x8_IDX, 2581 PEARL8x8_IDX,
2582 "PEARL8x8", 2582 "PEARL8x8",
2583 8, 2583 8,
diff --git a/drivers/video/console/font_sun12x22.c b/drivers/video/console/font_sun12x22.c
index c7bd967ea100..ab5eb93407b4 100644
--- a/drivers/video/console/font_sun12x22.c
+++ b/drivers/video/console/font_sun12x22.c
@@ -2,7 +2,7 @@
2 2
3#define FONTDATAMAX 11264 3#define FONTDATAMAX 11264
4 4
5static unsigned char fontdata_sun12x22[FONTDATAMAX] = { 5static const unsigned char fontdata_sun12x22[FONTDATAMAX] = {
6 6
7 /* 0 0x00 '^@' */ 7 /* 0 0x00 '^@' */
8 0x00, 0x00, /* 000000000000 */ 8 0x00, 0x00, /* 000000000000 */
@@ -6151,7 +6151,7 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
6151}; 6151};
6152 6152
6153 6153
6154struct font_desc font_sun_12x22 = { 6154const struct font_desc font_sun_12x22 = {
6155 SUN12x22_IDX, 6155 SUN12x22_IDX,
6156 "SUN12x22", 6156 "SUN12x22",
6157 12, 6157 12,
diff --git a/drivers/video/console/font_sun8x16.c b/drivers/video/console/font_sun8x16.c
index 2af3ab354652..41f910f5529c 100644
--- a/drivers/video/console/font_sun8x16.c
+++ b/drivers/video/console/font_sun8x16.c
@@ -2,7 +2,7 @@
2 2
3#define FONTDATAMAX 4096 3#define FONTDATAMAX 4096
4 4
5static unsigned char fontdata_sun8x16[FONTDATAMAX] = { 5static const unsigned char fontdata_sun8x16[FONTDATAMAX] = {
6/* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6/* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
7/* */ 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00, 7/* */ 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,
8/* */ 0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00, 8/* */ 0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00,
@@ -261,7 +261,7 @@ static unsigned char fontdata_sun8x16[FONTDATAMAX] = {
261/* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 261/* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
262}; 262};
263 263
264struct font_desc font_sun_8x16 = { 264const struct font_desc font_sun_8x16 = {
265 SUN8x16_IDX, 265 SUN8x16_IDX,
266 "SUN8x16", 266 "SUN8x16",
267 8, 267 8,
diff --git a/drivers/video/console/fonts.c b/drivers/video/console/fonts.c
index e79b29702649..4fd07d9eca03 100644
--- a/drivers/video/console/fonts.c
+++ b/drivers/video/console/fonts.c
@@ -23,7 +23,7 @@
23 23
24#define NO_FONTS 24#define NO_FONTS
25 25
26static struct font_desc *fonts[] = { 26static const struct font_desc *fonts[] = {
27#ifdef CONFIG_FONT_8x8 27#ifdef CONFIG_FONT_8x8
28#undef NO_FONTS 28#undef NO_FONTS
29 &font_vga_8x8, 29 &font_vga_8x8,
@@ -84,7 +84,7 @@ static struct font_desc *fonts[] = {
84 * 84 *
85 */ 85 */
86 86
87struct font_desc *find_font(char *name) 87const struct font_desc *find_font(const char *name)
88{ 88{
89 unsigned int i; 89 unsigned int i;
90 90
@@ -108,10 +108,10 @@ struct font_desc *find_font(char *name)
108 * 108 *
109 */ 109 */
110 110
111struct font_desc *get_default_font(int xres, int yres) 111const struct font_desc *get_default_font(int xres, int yres)
112{ 112{
113 int i, c, cc; 113 int i, c, cc;
114 struct font_desc *f, *g; 114 const struct font_desc *f, *g;
115 115
116 g = NULL; 116 g = NULL;
117 cc = -10000; 117 cc = -10000;
@@ -138,7 +138,6 @@ struct font_desc *get_default_font(int xres, int yres)
138 return g; 138 return g;
139} 139}
140 140
141EXPORT_SYMBOL(fonts);
142EXPORT_SYMBOL(find_font); 141EXPORT_SYMBOL(find_font);
143EXPORT_SYMBOL(get_default_font); 142EXPORT_SYMBOL(get_default_font);
144 143
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index 98e00d8601e5..e02da41f1b26 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -1285,7 +1285,7 @@ static int matroxfb_getmemory(WPMINFO unsigned int maxSize, unsigned int *realSi
1285 vaddr_t vm; 1285 vaddr_t vm;
1286 unsigned int offs; 1286 unsigned int offs;
1287 unsigned int offs2; 1287 unsigned int offs2;
1288 unsigned char store; 1288 unsigned char store, orig;
1289 unsigned char bytes[32]; 1289 unsigned char bytes[32];
1290 unsigned char* tmp; 1290 unsigned char* tmp;
1291 1291
@@ -1298,7 +1298,8 @@ static int matroxfb_getmemory(WPMINFO unsigned int maxSize, unsigned int *realSi
1298 if (maxSize > 0x2000000) maxSize = 0x2000000; 1298 if (maxSize > 0x2000000) maxSize = 0x2000000;
1299 1299
1300 mga_outb(M_EXTVGA_INDEX, 0x03); 1300 mga_outb(M_EXTVGA_INDEX, 0x03);
1301 mga_outb(M_EXTVGA_DATA, mga_inb(M_EXTVGA_DATA) | 0x80); 1301 orig = mga_inb(M_EXTVGA_DATA);
1302 mga_outb(M_EXTVGA_DATA, orig | 0x80);
1302 1303
1303 store = mga_readb(vm, 0x1234); 1304 store = mga_readb(vm, 0x1234);
1304 tmp = bytes; 1305 tmp = bytes;
@@ -1323,7 +1324,7 @@ static int matroxfb_getmemory(WPMINFO unsigned int maxSize, unsigned int *realSi
1323 mga_writeb(vm, 0x1234, store); 1324 mga_writeb(vm, 0x1234, store);
1324 1325
1325 mga_outb(M_EXTVGA_INDEX, 0x03); 1326 mga_outb(M_EXTVGA_INDEX, 0x03);
1326 mga_outb(M_EXTVGA_DATA, mga_inb(M_EXTVGA_DATA) & ~0x80); 1327 mga_outb(M_EXTVGA_DATA, orig);
1327 1328
1328 *realSize = offs - 0x100000; 1329 *realSize = offs - 0x100000;
1329#ifdef CONFIG_FB_MATROX_MILLENIUM 1330#ifdef CONFIG_FB_MATROX_MILLENIUM
@@ -1858,6 +1859,8 @@ static int initMatrox2(WPMINFO struct board* b){
1858 to yres_virtual * xres_virtual < 2^32 */ 1859 to yres_virtual * xres_virtual < 2^32 */
1859 } 1860 }
1860 matroxfb_init_fix(PMINFO2); 1861 matroxfb_init_fix(PMINFO2);
1862 ACCESS_FBINFO(fbcon.screen_base) = vaddr_va(ACCESS_FBINFO(video.vbase));
1863 matroxfb_update_fix(PMINFO2);
1861 /* Normalize values (namely yres_virtual) */ 1864 /* Normalize values (namely yres_virtual) */
1862 matroxfb_check_var(&vesafb_defined, &ACCESS_FBINFO(fbcon)); 1865 matroxfb_check_var(&vesafb_defined, &ACCESS_FBINFO(fbcon));
1863 /* And put it into "current" var. Do NOT program hardware yet, or we'll not take over 1866 /* And put it into "current" var. Do NOT program hardware yet, or we'll not take over
@@ -2010,11 +2013,11 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm
2010 } 2013 }
2011 /* not match... */ 2014 /* not match... */
2012 if (!b->vendor) 2015 if (!b->vendor)
2013 return -1; 2016 return -ENODEV;
2014 if (dev > 0) { 2017 if (dev > 0) {
2015 /* not requested one... */ 2018 /* not requested one... */
2016 dev--; 2019 dev--;
2017 return -1; 2020 return -ENODEV;
2018 } 2021 }
2019 pci_read_config_dword(pdev, PCI_COMMAND, &cmd); 2022 pci_read_config_dword(pdev, PCI_COMMAND, &cmd);
2020 if (pci_enable_device(pdev)) { 2023 if (pci_enable_device(pdev)) {
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index e0dad948467b..2e11b601c488 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -67,6 +67,7 @@
67#include <linux/init.h> 67#include <linux/init.h>
68#include <linux/pci.h> 68#include <linux/pci.h>
69#include <linux/ioport.h> 69#include <linux/ioport.h>
70#include <linux/ctype.h>
70 71
71#include <video/fbcon.h> 72#include <video/fbcon.h>
72#include <video/fbcon-mfb.h> 73#include <video/fbcon-mfb.h>
@@ -2594,7 +2595,7 @@ static char *pm3fb_boardnum_setup(char *options, unsigned long *bn)
2594{ 2595{
2595 char *next; 2596 char *next;
2596 2597
2597 if (!(CHAR_IS_NUM(options[0]))) { 2598 if (!(isdigit(options[0]))) {
2598 (*bn) = 0; 2599 (*bn) = 0;
2599 return (options); 2600 return (options);
2600 } 2601 }
diff --git a/fs/namei.c b/fs/namei.c
index 21d85f1ac839..043d587216b5 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1048,7 +1048,7 @@ int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata
1048out: 1048out:
1049 if (unlikely(current->audit_context 1049 if (unlikely(current->audit_context
1050 && nd && nd->dentry && nd->dentry->d_inode)) 1050 && nd && nd->dentry && nd->dentry->d_inode))
1051 audit_inode(name, nd->dentry->d_inode); 1051 audit_inode(name, nd->dentry->d_inode, flags);
1052 return retval; 1052 return retval;
1053} 1053}
1054 1054
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index e08edc17c6a0..361b4007d4a0 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -162,7 +162,7 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_
162 162
163 163
164static inline int 164static inline int
165nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open) 165nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open, struct nfs4_stateowner **replay_owner)
166{ 166{
167 int status; 167 int status;
168 dprintk("NFSD: nfsd4_open filename %.*s op_stateowner %p\n", 168 dprintk("NFSD: nfsd4_open filename %.*s op_stateowner %p\n",
@@ -238,8 +238,10 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open
238 */ 238 */
239 status = nfsd4_process_open2(rqstp, current_fh, open); 239 status = nfsd4_process_open2(rqstp, current_fh, open);
240out: 240out:
241 if (open->op_stateowner) 241 if (open->op_stateowner) {
242 nfs4_get_stateowner(open->op_stateowner); 242 nfs4_get_stateowner(open->op_stateowner);
243 *replay_owner = open->op_stateowner;
244 }
243 nfs4_unlock_state(); 245 nfs4_unlock_state();
244 return status; 246 return status;
245} 247}
@@ -809,8 +811,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
809 op->status = nfsd4_access(rqstp, current_fh, &op->u.access); 811 op->status = nfsd4_access(rqstp, current_fh, &op->u.access);
810 break; 812 break;
811 case OP_CLOSE: 813 case OP_CLOSE:
812 op->status = nfsd4_close(rqstp, current_fh, &op->u.close); 814 op->status = nfsd4_close(rqstp, current_fh, &op->u.close, &replay_owner);
813 replay_owner = op->u.close.cl_stateowner;
814 break; 815 break;
815 case OP_COMMIT: 816 case OP_COMMIT:
816 op->status = nfsd4_commit(rqstp, current_fh, &op->u.commit); 817 op->status = nfsd4_commit(rqstp, current_fh, &op->u.commit);
@@ -831,15 +832,13 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
831 op->status = nfsd4_link(rqstp, current_fh, save_fh, &op->u.link); 832 op->status = nfsd4_link(rqstp, current_fh, save_fh, &op->u.link);
832 break; 833 break;
833 case OP_LOCK: 834 case OP_LOCK:
834 op->status = nfsd4_lock(rqstp, current_fh, &op->u.lock); 835 op->status = nfsd4_lock(rqstp, current_fh, &op->u.lock, &replay_owner);
835 replay_owner = op->u.lock.lk_stateowner;
836 break; 836 break;
837 case OP_LOCKT: 837 case OP_LOCKT:
838 op->status = nfsd4_lockt(rqstp, current_fh, &op->u.lockt); 838 op->status = nfsd4_lockt(rqstp, current_fh, &op->u.lockt);
839 break; 839 break;
840 case OP_LOCKU: 840 case OP_LOCKU:
841 op->status = nfsd4_locku(rqstp, current_fh, &op->u.locku); 841 op->status = nfsd4_locku(rqstp, current_fh, &op->u.locku, &replay_owner);
842 replay_owner = op->u.locku.lu_stateowner;
843 break; 842 break;
844 case OP_LOOKUP: 843 case OP_LOOKUP:
845 op->status = nfsd4_lookup(rqstp, current_fh, &op->u.lookup); 844 op->status = nfsd4_lookup(rqstp, current_fh, &op->u.lookup);
@@ -853,16 +852,13 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
853 op->status = nfs_ok; 852 op->status = nfs_ok;
854 break; 853 break;
855 case OP_OPEN: 854 case OP_OPEN:
856 op->status = nfsd4_open(rqstp, current_fh, &op->u.open); 855 op->status = nfsd4_open(rqstp, current_fh, &op->u.open, &replay_owner);
857 replay_owner = op->u.open.op_stateowner;
858 break; 856 break;
859 case OP_OPEN_CONFIRM: 857 case OP_OPEN_CONFIRM:
860 op->status = nfsd4_open_confirm(rqstp, current_fh, &op->u.open_confirm); 858 op->status = nfsd4_open_confirm(rqstp, current_fh, &op->u.open_confirm, &replay_owner);
861 replay_owner = op->u.open_confirm.oc_stateowner;
862 break; 859 break;
863 case OP_OPEN_DOWNGRADE: 860 case OP_OPEN_DOWNGRADE:
864 op->status = nfsd4_open_downgrade(rqstp, current_fh, &op->u.open_downgrade); 861 op->status = nfsd4_open_downgrade(rqstp, current_fh, &op->u.open_downgrade, &replay_owner);
865 replay_owner = op->u.open_downgrade.od_stateowner;
866 break; 862 break;
867 case OP_PUTFH: 863 case OP_PUTFH:
868 op->status = nfsd4_putfh(rqstp, current_fh, &op->u.putfh); 864 op->status = nfsd4_putfh(rqstp, current_fh, &op->u.putfh);
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index b83f8fb441e1..6bbefd06f10d 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -624,7 +624,7 @@ gen_callback(struct nfs4_client *clp, struct nfsd4_setclientid *se)
624 cb->cb_ident = se->se_callback_ident; 624 cb->cb_ident = se->se_callback_ident;
625 return; 625 return;
626out_err: 626out_err:
627 printk(KERN_INFO "NFSD: this client (clientid %08x/%08x) " 627 dprintk(KERN_INFO "NFSD: this client (clientid %08x/%08x) "
628 "will not receive delegations\n", 628 "will not receive delegations\n",
629 clp->cl_clientid.cl_boot, clp->cl_clientid.cl_id); 629 clp->cl_clientid.cl_boot, clp->cl_clientid.cl_id);
630 630
@@ -678,13 +678,12 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_setclientid *setclid)
678 int status; 678 int status;
679 char dname[HEXDIR_LEN]; 679 char dname[HEXDIR_LEN];
680 680
681 status = nfserr_inval;
682 if (!check_name(clname)) 681 if (!check_name(clname))
683 goto out; 682 return nfserr_inval;
684 683
685 status = nfs4_make_rec_clidname(dname, &clname); 684 status = nfs4_make_rec_clidname(dname, &clname);
686 if (status) 685 if (status)
687 goto out; 686 return status;
688 687
689 /* 688 /*
690 * XXX The Duplicate Request Cache (DRC) has been checked (??) 689 * XXX The Duplicate Request Cache (DRC) has been checked (??)
@@ -2014,7 +2013,7 @@ STALE_STATEID(stateid_t *stateid)
2014{ 2013{
2015 if (stateid->si_boot == boot_time) 2014 if (stateid->si_boot == boot_time)
2016 return 0; 2015 return 0;
2017 printk("NFSD: stale stateid (%08x/%08x/%08x/%08x)!\n", 2016 dprintk("NFSD: stale stateid (%08x/%08x/%08x/%08x)!\n",
2018 stateid->si_boot, stateid->si_stateownerid, stateid->si_fileid, 2017 stateid->si_boot, stateid->si_stateownerid, stateid->si_fileid,
2019 stateid->si_generation); 2018 stateid->si_generation);
2020 return 1; 2019 return 1;
@@ -2275,7 +2274,7 @@ nfs4_preprocess_seqid_op(struct svc_fh *current_fh, u32 seqid, stateid_t *statei
2275 2274
2276check_replay: 2275check_replay:
2277 if (seqid == sop->so_seqid - 1) { 2276 if (seqid == sop->so_seqid - 1) {
2278 printk("NFSD: preprocess_seqid_op: retransmission?\n"); 2277 dprintk("NFSD: preprocess_seqid_op: retransmission?\n");
2279 /* indicate replay to calling function */ 2278 /* indicate replay to calling function */
2280 return NFSERR_REPLAY_ME; 2279 return NFSERR_REPLAY_ME;
2281 } 2280 }
@@ -2286,7 +2285,7 @@ check_replay:
2286} 2285}
2287 2286
2288int 2287int
2289nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_confirm *oc) 2288nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_confirm *oc, struct nfs4_stateowner **replay_owner)
2290{ 2289{
2291 int status; 2290 int status;
2292 struct nfs4_stateowner *sop; 2291 struct nfs4_stateowner *sop;
@@ -2320,8 +2319,10 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs
2320 2319
2321 nfsd4_create_clid_dir(sop->so_client); 2320 nfsd4_create_clid_dir(sop->so_client);
2322out: 2321out:
2323 if (oc->oc_stateowner) 2322 if (oc->oc_stateowner) {
2324 nfs4_get_stateowner(oc->oc_stateowner); 2323 nfs4_get_stateowner(oc->oc_stateowner);
2324 *replay_owner = oc->oc_stateowner;
2325 }
2325 nfs4_unlock_state(); 2326 nfs4_unlock_state();
2326 return status; 2327 return status;
2327} 2328}
@@ -2352,7 +2353,7 @@ reset_union_bmap_deny(unsigned long deny, unsigned long *bmap)
2352} 2353}
2353 2354
2354int 2355int
2355nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_downgrade *od) 2356nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_downgrade *od, struct nfs4_stateowner **replay_owner)
2356{ 2357{
2357 int status; 2358 int status;
2358 struct nfs4_stateid *stp; 2359 struct nfs4_stateid *stp;
@@ -2394,8 +2395,10 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct n
2394 memcpy(&od->od_stateid, &stp->st_stateid, sizeof(stateid_t)); 2395 memcpy(&od->od_stateid, &stp->st_stateid, sizeof(stateid_t));
2395 status = nfs_ok; 2396 status = nfs_ok;
2396out: 2397out:
2397 if (od->od_stateowner) 2398 if (od->od_stateowner) {
2398 nfs4_get_stateowner(od->od_stateowner); 2399 nfs4_get_stateowner(od->od_stateowner);
2400 *replay_owner = od->od_stateowner;
2401 }
2399 nfs4_unlock_state(); 2402 nfs4_unlock_state();
2400 return status; 2403 return status;
2401} 2404}
@@ -2404,7 +2407,7 @@ out:
2404 * nfs4_unlock_state() called after encode 2407 * nfs4_unlock_state() called after encode
2405 */ 2408 */
2406int 2409int
2407nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_close *close) 2410nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_close *close, struct nfs4_stateowner **replay_owner)
2408{ 2411{
2409 int status; 2412 int status;
2410 struct nfs4_stateid *stp; 2413 struct nfs4_stateid *stp;
@@ -2430,8 +2433,10 @@ nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_clos
2430 /* release_state_owner() calls nfsd_close() if needed */ 2433 /* release_state_owner() calls nfsd_close() if needed */
2431 release_state_owner(stp, OPEN_STATE); 2434 release_state_owner(stp, OPEN_STATE);
2432out: 2435out:
2433 if (close->cl_stateowner) 2436 if (close->cl_stateowner) {
2434 nfs4_get_stateowner(close->cl_stateowner); 2437 nfs4_get_stateowner(close->cl_stateowner);
2438 *replay_owner = close->cl_stateowner;
2439 }
2435 nfs4_unlock_state(); 2440 nfs4_unlock_state();
2436 return status; 2441 return status;
2437} 2442}
@@ -2500,8 +2505,7 @@ find_stateid(stateid_t *stid, int flags)
2500 (local->st_stateid.si_fileid == f_id)) 2505 (local->st_stateid.si_fileid == f_id))
2501 return local; 2506 return local;
2502 } 2507 }
2503 } else 2508 }
2504 printk("NFSD: find_stateid: ERROR: no state flag\n");
2505 return NULL; 2509 return NULL;
2506} 2510}
2507 2511
@@ -2624,7 +2628,9 @@ alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp, str
2624 sop->so_is_open_owner = 0; 2628 sop->so_is_open_owner = 0;
2625 sop->so_id = current_ownerid++; 2629 sop->so_id = current_ownerid++;
2626 sop->so_client = clp; 2630 sop->so_client = clp;
2627 sop->so_seqid = lock->lk_new_lock_seqid; 2631 /* It is the openowner seqid that will be incremented in encode in the
2632 * case of new lockowners; so increment the lock seqid manually: */
2633 sop->so_seqid = lock->lk_new_lock_seqid + 1;
2628 sop->so_confirmed = 1; 2634 sop->so_confirmed = 1;
2629 rp = &sop->so_replay; 2635 rp = &sop->so_replay;
2630 rp->rp_status = NFSERR_SERVERFAULT; 2636 rp->rp_status = NFSERR_SERVERFAULT;
@@ -2676,9 +2682,10 @@ check_lock_length(u64 offset, u64 length)
2676 * LOCK operation 2682 * LOCK operation
2677 */ 2683 */
2678int 2684int
2679nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock *lock) 2685nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock *lock, struct nfs4_stateowner **replay_owner)
2680{ 2686{
2681 struct nfs4_stateowner *open_sop = NULL; 2687 struct nfs4_stateowner *open_sop = NULL;
2688 struct nfs4_stateowner *lock_sop = NULL;
2682 struct nfs4_stateid *lock_stp; 2689 struct nfs4_stateid *lock_stp;
2683 struct file *filp; 2690 struct file *filp;
2684 struct file_lock file_lock; 2691 struct file_lock file_lock;
@@ -2705,19 +2712,19 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2705 struct nfs4_file *fp; 2712 struct nfs4_file *fp;
2706 2713
2707 status = nfserr_stale_clientid; 2714 status = nfserr_stale_clientid;
2708 if (STALE_CLIENTID(&lock->lk_new_clientid)) { 2715 if (STALE_CLIENTID(&lock->lk_new_clientid))
2709 printk("NFSD: nfsd4_lock: clientid is stale!\n");
2710 goto out; 2716 goto out;
2711 }
2712 2717
2713 /* validate and update open stateid and open seqid */ 2718 /* validate and update open stateid and open seqid */
2714 status = nfs4_preprocess_seqid_op(current_fh, 2719 status = nfs4_preprocess_seqid_op(current_fh,
2715 lock->lk_new_open_seqid, 2720 lock->lk_new_open_seqid,
2716 &lock->lk_new_open_stateid, 2721 &lock->lk_new_open_stateid,
2717 CHECK_FH | OPEN_STATE, 2722 CHECK_FH | OPEN_STATE,
2718 &open_sop, &open_stp, lock); 2723 &lock->lk_stateowner, &open_stp,
2724 lock);
2719 if (status) 2725 if (status)
2720 goto out; 2726 goto out;
2727 open_sop = lock->lk_stateowner;
2721 /* create lockowner and lock stateid */ 2728 /* create lockowner and lock stateid */
2722 fp = open_stp->st_file; 2729 fp = open_stp->st_file;
2723 strhashval = lock_ownerstr_hashval(fp->fi_inode, 2730 strhashval = lock_ownerstr_hashval(fp->fi_inode,
@@ -2727,16 +2734,15 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2727 * the same file, or should they just be allowed (and 2734 * the same file, or should they just be allowed (and
2728 * create new stateids)? */ 2735 * create new stateids)? */
2729 status = nfserr_resource; 2736 status = nfserr_resource;
2730 if (!(lock->lk_stateowner = alloc_init_lock_stateowner(strhashval, open_sop->so_client, open_stp, lock))) 2737 lock_sop = alloc_init_lock_stateowner(strhashval,
2738 open_sop->so_client, open_stp, lock);
2739 if (lock_sop == NULL)
2731 goto out; 2740 goto out;
2732 if ((lock_stp = alloc_init_lock_stateid(lock->lk_stateowner, 2741 lock_stp = alloc_init_lock_stateid(lock_sop, fp, open_stp);
2733 fp, open_stp)) == NULL) { 2742 if (lock_stp == NULL) {
2734 release_stateowner(lock->lk_stateowner); 2743 release_stateowner(lock_sop);
2735 lock->lk_stateowner = NULL;
2736 goto out; 2744 goto out;
2737 } 2745 }
2738 /* bump the open seqid used to create the lock */
2739 open_sop->so_seqid++;
2740 } else { 2746 } else {
2741 /* lock (lock owner + lock stateid) already exists */ 2747 /* lock (lock owner + lock stateid) already exists */
2742 status = nfs4_preprocess_seqid_op(current_fh, 2748 status = nfs4_preprocess_seqid_op(current_fh,
@@ -2746,12 +2752,13 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2746 &lock->lk_stateowner, &lock_stp, lock); 2752 &lock->lk_stateowner, &lock_stp, lock);
2747 if (status) 2753 if (status)
2748 goto out; 2754 goto out;
2755 lock_sop = lock->lk_stateowner;
2749 } 2756 }
2750 /* lock->lk_stateowner and lock_stp have been created or found */ 2757 /* lock->lk_stateowner and lock_stp have been created or found */
2751 filp = lock_stp->st_vfs_file; 2758 filp = lock_stp->st_vfs_file;
2752 2759
2753 if ((status = fh_verify(rqstp, current_fh, S_IFREG, MAY_LOCK))) { 2760 if ((status = fh_verify(rqstp, current_fh, S_IFREG, MAY_LOCK))) {
2754 printk("NFSD: nfsd4_lock: permission denied!\n"); 2761 dprintk("NFSD: nfsd4_lock: permission denied!\n");
2755 goto out; 2762 goto out;
2756 } 2763 }
2757 2764
@@ -2776,7 +2783,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2776 status = nfserr_inval; 2783 status = nfserr_inval;
2777 goto out; 2784 goto out;
2778 } 2785 }
2779 file_lock.fl_owner = (fl_owner_t) lock->lk_stateowner; 2786 file_lock.fl_owner = (fl_owner_t)lock_sop;
2780 file_lock.fl_pid = current->tgid; 2787 file_lock.fl_pid = current->tgid;
2781 file_lock.fl_file = filp; 2788 file_lock.fl_file = filp;
2782 file_lock.fl_flags = FL_POSIX; 2789 file_lock.fl_flags = FL_POSIX;
@@ -2832,14 +2839,13 @@ out_destroy_new_stateid:
2832 * An error encountered after instantiation of the new 2839 * An error encountered after instantiation of the new
2833 * stateid has forced us to destroy it. 2840 * stateid has forced us to destroy it.
2834 */ 2841 */
2835 if (!seqid_mutating_err(status))
2836 open_sop->so_seqid--;
2837
2838 release_state_owner(lock_stp, LOCK_STATE); 2842 release_state_owner(lock_stp, LOCK_STATE);
2839 } 2843 }
2840out: 2844out:
2841 if (lock->lk_stateowner) 2845 if (lock->lk_stateowner) {
2842 nfs4_get_stateowner(lock->lk_stateowner); 2846 nfs4_get_stateowner(lock->lk_stateowner);
2847 *replay_owner = lock->lk_stateowner;
2848 }
2843 nfs4_unlock_state(); 2849 nfs4_unlock_state();
2844 return status; 2850 return status;
2845} 2851}
@@ -2866,13 +2872,11 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2866 nfs4_lock_state(); 2872 nfs4_lock_state();
2867 2873
2868 status = nfserr_stale_clientid; 2874 status = nfserr_stale_clientid;
2869 if (STALE_CLIENTID(&lockt->lt_clientid)) { 2875 if (STALE_CLIENTID(&lockt->lt_clientid))
2870 printk("NFSD: nfsd4_lockt: clientid is stale!\n");
2871 goto out; 2876 goto out;
2872 }
2873 2877
2874 if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0))) { 2878 if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0))) {
2875 printk("NFSD: nfsd4_lockt: fh_verify() failed!\n"); 2879 dprintk("NFSD: nfsd4_lockt: fh_verify() failed!\n");
2876 if (status == nfserr_symlink) 2880 if (status == nfserr_symlink)
2877 status = nfserr_inval; 2881 status = nfserr_inval;
2878 goto out; 2882 goto out;
@@ -2930,7 +2934,7 @@ out:
2930} 2934}
2931 2935
2932int 2936int
2933nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_locku *locku) 2937nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_locku *locku, struct nfs4_stateowner **replay_owner)
2934{ 2938{
2935 struct nfs4_stateid *stp; 2939 struct nfs4_stateid *stp;
2936 struct file *filp = NULL; 2940 struct file *filp = NULL;
@@ -2976,7 +2980,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2976 if (file_lock.fl_ops && file_lock.fl_ops->fl_release_private) 2980 if (file_lock.fl_ops && file_lock.fl_ops->fl_release_private)
2977 file_lock.fl_ops->fl_release_private(&file_lock); 2981 file_lock.fl_ops->fl_release_private(&file_lock);
2978 if (status) { 2982 if (status) {
2979 printk("NFSD: nfs4_locku: posix_lock_file failed!\n"); 2983 dprintk("NFSD: nfs4_locku: posix_lock_file failed!\n");
2980 goto out_nfserr; 2984 goto out_nfserr;
2981 } 2985 }
2982 /* 2986 /*
@@ -2986,8 +2990,10 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2986 memcpy(&locku->lu_stateid, &stp->st_stateid, sizeof(stateid_t)); 2990 memcpy(&locku->lu_stateid, &stp->st_stateid, sizeof(stateid_t));
2987 2991
2988out: 2992out:
2989 if (locku->lu_stateowner) 2993 if (locku->lu_stateowner) {
2990 nfs4_get_stateowner(locku->lu_stateowner); 2994 nfs4_get_stateowner(locku->lu_stateowner);
2995 *replay_owner = locku->lu_stateowner;
2996 }
2991 nfs4_unlock_state(); 2997 nfs4_unlock_state();
2992 return status; 2998 return status;
2993 2999
@@ -3036,10 +3042,8 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner *
3036 /* XXX check for lease expiration */ 3042 /* XXX check for lease expiration */
3037 3043
3038 status = nfserr_stale_clientid; 3044 status = nfserr_stale_clientid;
3039 if (STALE_CLIENTID(clid)) { 3045 if (STALE_CLIENTID(clid))
3040 printk("NFSD: nfsd4_release_lockowner: clientid is stale!\n");
3041 return status; 3046 return status;
3042 }
3043 3047
3044 nfs4_lock_state(); 3048 nfs4_lock_state();
3045 3049
diff --git a/fs/open.c b/fs/open.c
index 2fac58c51910..f0d90cf0495c 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -738,52 +738,15 @@ asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group)
738 return error; 738 return error;
739} 739}
740 740
741/* 741static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
742 * Note that while the flag value (low two bits) for sys_open means: 742 int flags, struct file *f)
743 * 00 - read-only
744 * 01 - write-only
745 * 10 - read-write
746 * 11 - special
747 * it is changed into
748 * 00 - no permissions needed
749 * 01 - read-permission
750 * 10 - write-permission
751 * 11 - read-write
752 * for the internal routines (ie open_namei()/follow_link() etc). 00 is
753 * used by symlinks.
754 */
755struct file *filp_open(const char * filename, int flags, int mode)
756{
757 int namei_flags, error;
758 struct nameidata nd;
759
760 namei_flags = flags;
761 if ((namei_flags+1) & O_ACCMODE)
762 namei_flags++;
763 if (namei_flags & O_TRUNC)
764 namei_flags |= 2;
765
766 error = open_namei(filename, namei_flags, mode, &nd);
767 if (!error)
768 return dentry_open(nd.dentry, nd.mnt, flags);
769
770 return ERR_PTR(error);
771}
772
773EXPORT_SYMBOL(filp_open);
774
775struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
776{ 743{
777 struct file * f;
778 struct inode *inode; 744 struct inode *inode;
779 int error; 745 int error;
780 746
781 error = -ENFILE;
782 f = get_empty_filp();
783 if (!f)
784 goto cleanup_dentry;
785 f->f_flags = flags; 747 f->f_flags = flags;
786 f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE; 748 f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK |
749 FMODE_PREAD | FMODE_PWRITE;
787 inode = dentry->d_inode; 750 inode = dentry->d_inode;
788 if (f->f_mode & FMODE_WRITE) { 751 if (f->f_mode & FMODE_WRITE) {
789 error = get_write_access(inode); 752 error = get_write_access(inode);
@@ -828,12 +791,63 @@ cleanup_all:
828 f->f_vfsmnt = NULL; 791 f->f_vfsmnt = NULL;
829cleanup_file: 792cleanup_file:
830 put_filp(f); 793 put_filp(f);
831cleanup_dentry:
832 dput(dentry); 794 dput(dentry);
833 mntput(mnt); 795 mntput(mnt);
834 return ERR_PTR(error); 796 return ERR_PTR(error);
835} 797}
836 798
799/*
800 * Note that while the flag value (low two bits) for sys_open means:
801 * 00 - read-only
802 * 01 - write-only
803 * 10 - read-write
804 * 11 - special
805 * it is changed into
806 * 00 - no permissions needed
807 * 01 - read-permission
808 * 10 - write-permission
809 * 11 - read-write
810 * for the internal routines (ie open_namei()/follow_link() etc). 00 is
811 * used by symlinks.
812 */
813struct file *filp_open(const char * filename, int flags, int mode)
814{
815 int namei_flags, error;
816 struct nameidata nd;
817 struct file *f;
818
819 namei_flags = flags;
820 if ((namei_flags+1) & O_ACCMODE)
821 namei_flags++;
822 if (namei_flags & O_TRUNC)
823 namei_flags |= 2;
824
825 error = -ENFILE;
826 f = get_empty_filp();
827 if (f == NULL)
828 return ERR_PTR(error);
829
830 error = open_namei(filename, namei_flags, mode, &nd);
831 if (!error)
832 return __dentry_open(nd.dentry, nd.mnt, flags, f);
833
834 put_filp(f);
835 return ERR_PTR(error);
836}
837EXPORT_SYMBOL(filp_open);
838
839struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
840{
841 int error;
842 struct file *f;
843
844 error = -ENFILE;
845 f = get_empty_filp();
846 if (f == NULL)
847 return ERR_PTR(error);
848
849 return __dentry_open(dentry, mnt, flags, f);
850}
837EXPORT_SYMBOL(dentry_open); 851EXPORT_SYMBOL(dentry_open);
838 852
839/* 853/*
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index c9f178fb494f..c20babd6216d 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -667,7 +667,7 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
667 if (th->t_trans_id) { 667 if (th->t_trans_id) {
668 int err; 668 int err;
669 // update any changes we made to blk count 669 // update any changes we made to blk count
670 reiserfs_update_sd(th, inode); 670 mark_inode_dirty(inode);
671 err = 671 err =
672 journal_end(th, inode->i_sb, 672 journal_end(th, inode->i_sb,
673 JOURNAL_PER_BALANCE_CNT * 3 + 1 + 673 JOURNAL_PER_BALANCE_CNT * 3 + 1 +
@@ -855,17 +855,18 @@ static int reiserfs_submit_file_region_for_write(struct reiserfs_transaction_han
855 855
856 if (th->t_trans_id) { 856 if (th->t_trans_id) {
857 reiserfs_write_lock(inode->i_sb); 857 reiserfs_write_lock(inode->i_sb);
858 reiserfs_update_sd(th, inode); // And update on-disk metadata 858 // this sets the proper flags for O_SYNC to trigger a commit
859 mark_inode_dirty(inode);
859 reiserfs_write_unlock(inode->i_sb); 860 reiserfs_write_unlock(inode->i_sb);
860 } else 861 } else
861 inode->i_sb->s_op->dirty_inode(inode); 862 mark_inode_dirty(inode);
862 863
863 sd_update = 1; 864 sd_update = 1;
864 } 865 }
865 if (th->t_trans_id) { 866 if (th->t_trans_id) {
866 reiserfs_write_lock(inode->i_sb); 867 reiserfs_write_lock(inode->i_sb);
867 if (!sd_update) 868 if (!sd_update)
868 reiserfs_update_sd(th, inode); 869 mark_inode_dirty(inode);
869 status = journal_end(th, th->t_super, th->t_blocks_allocated); 870 status = journal_end(th, th->t_super, th->t_blocks_allocated);
870 if (status) 871 if (status)
871 retval = status; 872 retval = status;
@@ -1320,7 +1321,7 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1320 return err; 1321 return err;
1321 } 1322 }
1322 reiserfs_update_inode_transaction(inode); 1323 reiserfs_update_inode_transaction(inode);
1323 reiserfs_update_sd(&th, inode); 1324 mark_inode_dirty(inode);
1324 err = journal_end(&th, inode->i_sb, 1); 1325 err = journal_end(&th, inode->i_sb, 1);
1325 if (err) { 1326 if (err) {
1326 reiserfs_write_unlock(inode->i_sb); 1327 reiserfs_write_unlock(inode->i_sb);
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 1a8a1bf2154d..d76ee6c4f9b8 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -2639,6 +2639,12 @@ static int reiserfs_commit_write(struct file *f, struct page *page,
2639 } 2639 }
2640 reiserfs_update_inode_transaction(inode); 2640 reiserfs_update_inode_transaction(inode);
2641 inode->i_size = pos; 2641 inode->i_size = pos;
2642 /*
2643 * this will just nest into our transaction. It's important
2644 * to use mark_inode_dirty so the inode gets pushed around on the
2645 * dirty lists, and so that O_SYNC works as expected
2646 */
2647 mark_inode_dirty(inode);
2642 reiserfs_update_sd(&myth, inode); 2648 reiserfs_update_sd(&myth, inode);
2643 update_sd = 1; 2649 update_sd = 1;
2644 ret = journal_end(&myth, inode->i_sb, 1); 2650 ret = journal_end(&myth, inode->i_sb, 1);
@@ -2649,21 +2655,13 @@ static int reiserfs_commit_write(struct file *f, struct page *page,
2649 if (th) { 2655 if (th) {
2650 reiserfs_write_lock(inode->i_sb); 2656 reiserfs_write_lock(inode->i_sb);
2651 if (!update_sd) 2657 if (!update_sd)
2652 reiserfs_update_sd(th, inode); 2658 mark_inode_dirty(inode);
2653 ret = reiserfs_end_persistent_transaction(th); 2659 ret = reiserfs_end_persistent_transaction(th);
2654 reiserfs_write_unlock(inode->i_sb); 2660 reiserfs_write_unlock(inode->i_sb);
2655 if (ret) 2661 if (ret)
2656 goto out; 2662 goto out;
2657 } 2663 }
2658 2664
2659 /* we test for O_SYNC here so we can commit the transaction
2660 ** for any packed tails the file might have had
2661 */
2662 if (f && (f->f_flags & O_SYNC)) {
2663 reiserfs_write_lock(inode->i_sb);
2664 ret = reiserfs_commit_for_inode(inode);
2665 reiserfs_write_unlock(inode->i_sb);
2666 }
2667 out: 2665 out:
2668 return ret; 2666 return ret;
2669 2667
diff --git a/include/asm-alpha/pgtable.h b/include/asm-alpha/pgtable.h
index 22b53e369f59..8393bf374b2b 100644
--- a/include/asm-alpha/pgtable.h
+++ b/include/asm-alpha/pgtable.h
@@ -339,13 +339,6 @@ extern inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
339#define kern_addr_valid(addr) (1) 339#define kern_addr_valid(addr) (1)
340#endif 340#endif
341 341
342#define io_remap_page_range(vma, start, busaddr, size, prot) \
343({ \
344 void *va = (void __force *)ioremap(busaddr, size); \
345 unsigned long pfn = virt_to_phys(va) >> PAGE_SHIFT; \
346 remap_pfn_range(vma, start, pfn, size, prot); \
347})
348
349#define io_remap_pfn_range(vma, start, pfn, size, prot) \ 342#define io_remap_pfn_range(vma, start, pfn, size, prot) \
350 remap_pfn_range(vma, start, pfn, size, prot) 343 remap_pfn_range(vma, start, pfn, size, prot)
351 344
diff --git a/include/asm-arm/arch-pxa/akita.h b/include/asm-arm/arch-pxa/akita.h
new file mode 100644
index 000000000000..4a1fbcfccc39
--- /dev/null
+++ b/include/asm-arm/arch-pxa/akita.h
@@ -0,0 +1,30 @@
1/*
2 * Hardware specific definitions for SL-C1000 (Akita)
3 *
4 * Copyright (c) 2005 Richard Purdie
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 version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12/* Akita IO Expander GPIOs */
13
14#define AKITA_IOEXP_RESERVED_7 (1 << 7)
15#define AKITA_IOEXP_IR_ON (1 << 6)
16#define AKITA_IOEXP_AKIN_PULLUP (1 << 5)
17#define AKITA_IOEXP_BACKLIGHT_CONT (1 << 4)
18#define AKITA_IOEXP_BACKLIGHT_ON (1 << 3)
19#define AKITA_IOEXP_MIC_BIAS (1 << 2)
20#define AKITA_IOEXP_RESERVED_1 (1 << 1)
21#define AKITA_IOEXP_RESERVED_0 (1 << 0)
22
23/* Direction Bitfield 0=output 1=input */
24#define AKITA_IOEXP_IO_DIR 0
25/* Default Values */
26#define AKITA_IOEXP_IO_OUT (AKITA_IOEXP_IR_ON | AKITA_IOEXP_AKIN_PULLUP)
27
28void akita_set_ioexp(struct device *dev, unsigned char bitmask);
29void akita_reset_ioexp(struct device *dev, unsigned char bitmask);
30
diff --git a/include/asm-arm/arch-pxa/corgi.h b/include/asm-arm/arch-pxa/corgi.h
index 4b7aa0b8391e..e554caa0d18b 100644
--- a/include/asm-arm/arch-pxa/corgi.h
+++ b/include/asm-arm/arch-pxa/corgi.h
@@ -106,17 +106,5 @@ extern struct platform_device corgiscoop_device;
106extern struct platform_device corgissp_device; 106extern struct platform_device corgissp_device;
107extern struct platform_device corgifb_device; 107extern struct platform_device corgifb_device;
108 108
109/*
110 * External Functions
111 */
112extern unsigned long corgi_ssp_ads7846_putget(unsigned long);
113extern unsigned long corgi_ssp_ads7846_get(void);
114extern void corgi_ssp_ads7846_put(unsigned long data);
115extern void corgi_ssp_ads7846_lock(void);
116extern void corgi_ssp_ads7846_unlock(void);
117extern void corgi_ssp_lcdtg_send (unsigned char adrs, unsigned char data);
118extern void corgi_ssp_blduty_set(int duty);
119extern int corgi_ssp_max1111_get(unsigned long data);
120
121#endif /* __ASM_ARCH_CORGI_H */ 109#endif /* __ASM_ARCH_CORGI_H */
122 110
diff --git a/include/asm-arm/arch-pxa/sharpsl.h b/include/asm-arm/arch-pxa/sharpsl.h
new file mode 100644
index 000000000000..311f2bb5386a
--- /dev/null
+++ b/include/asm-arm/arch-pxa/sharpsl.h
@@ -0,0 +1,32 @@
1/*
2 * SharpSL SSP Driver
3 */
4
5unsigned long corgi_ssp_ads7846_putget(unsigned long);
6unsigned long corgi_ssp_ads7846_get(void);
7void corgi_ssp_ads7846_put(unsigned long data);
8void corgi_ssp_ads7846_lock(void);
9void corgi_ssp_ads7846_unlock(void);
10void corgi_ssp_lcdtg_send (unsigned char adrs, unsigned char data);
11void corgi_ssp_blduty_set(int duty);
12int corgi_ssp_max1111_get(unsigned long data);
13
14/*
15 * SharpSL Touchscreen Driver
16 */
17
18struct corgits_machinfo {
19 unsigned long (*get_hsync_len)(void);
20 void (*put_hsync)(void);
21 void (*wait_hsync)(void);
22};
23
24/*
25 * SharpSL Backlight
26 */
27
28struct corgibl_machinfo {
29 int max_intensity;
30 void (*set_bl_intensity)(int intensity);
31};
32
diff --git a/include/asm-arm/arch-pxa/spitz.h b/include/asm-arm/arch-pxa/spitz.h
new file mode 100644
index 000000000000..62e1fe4d025f
--- /dev/null
+++ b/include/asm-arm/arch-pxa/spitz.h
@@ -0,0 +1,158 @@
1/*
2 * Hardware specific definitions for SL-Cx000 series of PDAs
3 *
4 * Copyright (c) 2005 Alexander Wykes
5 * Copyright (c) 2005 Richard Purdie
6 *
7 * Based on Sharp's 2.4 kernel patches
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14#ifndef __ASM_ARCH_SPITZ_H
15#define __ASM_ARCH_SPITZ_H 1
16#endif
17
18/* Spitz/Akita GPIOs */
19
20#define SPITZ_GPIO_KEY_INT (0) /* Key Interrupt */
21#define SPITZ_GPIO_RESET (1)
22#define SPITZ_GPIO_nSD_DETECT (9)
23#define SPITZ_GPIO_TP_INT (11) /* Touch Panel interrupt */
24#define SPITZ_GPIO_AK_INT (13) /* Remote Control */
25#define SPITZ_GPIO_ADS7846_CS (14)
26#define SPITZ_GPIO_SYNC (16)
27#define SPITZ_GPIO_MAX1111_CS (20)
28#define SPITZ_GPIO_FATAL_BAT (21)
29#define SPITZ_GPIO_HSYNC (22)
30#define SPITZ_GPIO_nSD_CLK (32)
31#define SPITZ_GPIO_USB_DEVICE (35)
32#define SPITZ_GPIO_USB_HOST (37)
33#define SPITZ_GPIO_USB_CONNECT (41)
34#define SPITZ_GPIO_LCDCON_CS (53)
35#define SPITZ_GPIO_nPCE (54)
36#define SPITZ_GPIO_nSD_WP (81)
37#define SPITZ_GPIO_ON_RESET (89)
38#define SPITZ_GPIO_BAT_COVER (90)
39#define SPITZ_GPIO_CF_CD (94)
40#define SPITZ_GPIO_ON_KEY (95)
41#define SPITZ_GPIO_SWA (97)
42#define SPITZ_GPIO_SWB (96)
43#define SPITZ_GPIO_CHRG_FULL (101)
44#define SPITZ_GPIO_CO (101)
45#define SPITZ_GPIO_CF_IRQ (105)
46#define SPITZ_GPIO_AC_IN (115)
47#define SPITZ_GPIO_HP_IN (116)
48
49/* Spitz Only GPIOs */
50
51#define SPITZ_GPIO_CF2_IRQ (106) /* CF slot1 Ready */
52#define SPITZ_GPIO_CF2_CD (93)
53
54
55/* Spitz/Akita Keyboard Definitions */
56
57#define SPITZ_KEY_STROBE_NUM (11)
58#define SPITZ_KEY_SENSE_NUM (7)
59#define SPITZ_GPIO_G0_STROBE_BIT 0x0f800000
60#define SPITZ_GPIO_G1_STROBE_BIT 0x00100000
61#define SPITZ_GPIO_G2_STROBE_BIT 0x01000000
62#define SPITZ_GPIO_G3_STROBE_BIT 0x00041880
63#define SPITZ_GPIO_G0_SENSE_BIT 0x00021000
64#define SPITZ_GPIO_G1_SENSE_BIT 0x000000d4
65#define SPITZ_GPIO_G2_SENSE_BIT 0x08000000
66#define SPITZ_GPIO_G3_SENSE_BIT 0x00000000
67
68#define SPITZ_GPIO_KEY_STROBE0 88
69#define SPITZ_GPIO_KEY_STROBE1 23
70#define SPITZ_GPIO_KEY_STROBE2 24
71#define SPITZ_GPIO_KEY_STROBE3 25
72#define SPITZ_GPIO_KEY_STROBE4 26
73#define SPITZ_GPIO_KEY_STROBE5 27
74#define SPITZ_GPIO_KEY_STROBE6 52
75#define SPITZ_GPIO_KEY_STROBE7 103
76#define SPITZ_GPIO_KEY_STROBE8 107
77#define SPITZ_GPIO_KEY_STROBE9 108
78#define SPITZ_GPIO_KEY_STROBE10 114
79
80#define SPITZ_GPIO_KEY_SENSE0 12
81#define SPITZ_GPIO_KEY_SENSE1 17
82#define SPITZ_GPIO_KEY_SENSE2 91
83#define SPITZ_GPIO_KEY_SENSE3 34
84#define SPITZ_GPIO_KEY_SENSE4 36
85#define SPITZ_GPIO_KEY_SENSE5 38
86#define SPITZ_GPIO_KEY_SENSE6 39
87
88
89/* Spitz Scoop Device (No. 1) GPIOs */
90/* Suspend States in comments */
91#define SPITZ_SCP_LED_GREEN SCOOP_GPCR_PA11 /* Keep */
92#define SPITZ_SCP_JK_B SCOOP_GPCR_PA12 /* Keep */
93#define SPITZ_SCP_CHRG_ON SCOOP_GPCR_PA13 /* Keep */
94#define SPITZ_SCP_MUTE_L SCOOP_GPCR_PA14 /* Low */
95#define SPITZ_SCP_MUTE_R SCOOP_GPCR_PA15 /* Low */
96#define SPITZ_SCP_CF_POWER SCOOP_GPCR_PA16 /* Keep */
97#define SPITZ_SCP_LED_ORANGE SCOOP_GPCR_PA17 /* Keep */
98#define SPITZ_SCP_JK_A SCOOP_GPCR_PA18 /* Low */
99#define SPITZ_SCP_ADC_TEMP_ON SCOOP_GPCR_PA19 /* Low */
100
101#define SPITZ_SCP_IO_DIR (SPITZ_SCP_LED_GREEN | SPITZ_SCP_JK_B | SPITZ_SCP_CHRG_ON | \
102 SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R | SPITZ_SCP_LED_ORANGE | \
103 SPITZ_SCP_CF_POWER | SPITZ_SCP_JK_A | SPITZ_SCP_ADC_TEMP_ON)
104#define SPITZ_SCP_IO_OUT (SPITZ_SCP_CHRG_ON | SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R)
105#define SPITZ_SCP_SUS_CLR (SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R | SPITZ_SCP_JK_A | SPITZ_SCP_ADC_TEMP_ON)
106#define SPITZ_SCP_SUS_SET 0
107
108/* Spitz Scoop Device (No. 2) GPIOs */
109/* Suspend States in comments */
110#define SPITZ_SCP2_IR_ON SCOOP_GPCR_PA11 /* High */
111#define SPITZ_SCP2_AKIN_PULLUP SCOOP_GPCR_PA12 /* Keep */
112#define SPITZ_SCP2_RESERVED_1 SCOOP_GPCR_PA13 /* High */
113#define SPITZ_SCP2_RESERVED_2 SCOOP_GPCR_PA14 /* Low */
114#define SPITZ_SCP2_RESERVED_3 SCOOP_GPCR_PA15 /* Low */
115#define SPITZ_SCP2_RESERVED_4 SCOOP_GPCR_PA16 /* Low */
116#define SPITZ_SCP2_BACKLIGHT_CONT SCOOP_GPCR_PA17 /* Low */
117#define SPITZ_SCP2_BACKLIGHT_ON SCOOP_GPCR_PA18 /* Low */
118#define SPITZ_SCP2_MIC_BIAS SCOOP_GPCR_PA19 /* Low */
119
120#define SPITZ_SCP2_IO_DIR (SPITZ_SCP2_IR_ON | SPITZ_SCP2_AKIN_PULLUP | SPITZ_SCP2_RESERVED_1 | \
121 SPITZ_SCP2_RESERVED_2 | SPITZ_SCP2_RESERVED_3 | SPITZ_SCP2_RESERVED_4 | \
122 SPITZ_SCP2_BACKLIGHT_CONT | SPITZ_SCP2_BACKLIGHT_ON | SPITZ_SCP2_MIC_BIAS)
123
124#define SPITZ_SCP2_IO_OUT (SPITZ_SCP2_IR_ON | SPITZ_SCP2_AKIN_PULLUP | SPITZ_SCP2_RESERVED_1)
125#define SPITZ_SCP2_SUS_CLR (SPITZ_SCP2_RESERVED_2 | SPITZ_SCP2_RESERVED_3 | SPITZ_SCP2_RESERVED_4 | \
126 SPITZ_SCP2_BACKLIGHT_CONT | SPITZ_SCP2_BACKLIGHT_ON | SPITZ_SCP2_MIC_BIAS)
127#define SPITZ_SCP2_SUS_SET (SPITZ_SCP2_IR_ON | SPITZ_SCP2_RESERVED_1)
128
129
130/* Spitz IRQ Definitions */
131
132#define SPITZ_IRQ_GPIO_KEY_INT IRQ_GPIO(SPITZ_GPIO_KEY_INT)
133#define SPITZ_IRQ_GPIO_AC_IN IRQ_GPIO(SPITZ_GPIO_AC_IN)
134#define SPITZ_IRQ_GPIO_AK_INT IRQ_GPIO(SPITZ_GPIO_AK_INT)
135#define SPITZ_IRQ_GPIO_HP_IN IRQ_GPIO(SPITZ_GPIO_HP_IN)
136#define SPITZ_IRQ_GPIO_TP_INT IRQ_GPIO(SPITZ_GPIO_TP_INT)
137#define SPITZ_IRQ_GPIO_SYNC IRQ_GPIO(SPITZ_GPIO_SYNC)
138#define SPITZ_IRQ_GPIO_ON_KEY IRQ_GPIO(SPITZ_GPIO_ON_KEY)
139#define SPITZ_IRQ_GPIO_SWA IRQ_GPIO(SPITZ_GPIO_SWA)
140#define SPITZ_IRQ_GPIO_SWB IRQ_GPIO(SPITZ_GPIO_SWB)
141#define SPITZ_IRQ_GPIO_BAT_COVER IRQ_GPIO(SPITZ_GPIO_BAT_COVER)
142#define SPITZ_IRQ_GPIO_FATAL_BAT IRQ_GPIO(SPITZ_GPIO_FATAL_BAT)
143#define SPITZ_IRQ_GPIO_CO IRQ_GPIO(SPITZ_GPIO_CO)
144#define SPITZ_IRQ_GPIO_CF_IRQ IRQ_GPIO(SPITZ_GPIO_CF_IRQ)
145#define SPITZ_IRQ_GPIO_CF_CD IRQ_GPIO(SPITZ_GPIO_CF_CD)
146#define SPITZ_IRQ_GPIO_CF2_IRQ IRQ_GPIO(SPITZ_GPIO_CF2_IRQ)
147#define SPITZ_IRQ_GPIO_nSD_INT IRQ_GPIO(SPITZ_GPIO_nSD_INT)
148#define SPITZ_IRQ_GPIO_nSD_DETECT IRQ_GPIO(SPITZ_GPIO_nSD_DETECT)
149
150/*
151 * Shared data structures
152 */
153extern struct platform_device spitzscoop_device;
154extern struct platform_device spitzscoop2_device;
155extern struct platform_device spitzssp_device;
156extern struct sharpsl_charger_machinfo spitz_pm_machinfo;
157
158extern void spitz_lcd_power(int on);
diff --git a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
index 478c49b56e18..366bafbdfbb1 100644
--- a/include/asm-arm/pgtable.h
+++ b/include/asm-arm/pgtable.h
@@ -445,12 +445,9 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
445#define HAVE_ARCH_UNMAPPED_AREA 445#define HAVE_ARCH_UNMAPPED_AREA
446 446
447/* 447/*
448 * remap a physical address `phys' of size `size' with page protection `prot' 448 * remap a physical page `pfn' of size `size' with page protection `prot'
449 * into virtual address `from' 449 * into virtual address `from'
450 */ 450 */
451#define io_remap_page_range(vma,from,phys,size,prot) \
452 remap_pfn_range(vma, from, (phys) >> PAGE_SHIFT, size, prot)
453
454#define io_remap_pfn_range(vma,from,pfn,size,prot) \ 451#define io_remap_pfn_range(vma,from,pfn,size,prot) \
455 remap_pfn_range(vma, from, pfn, size, prot) 452 remap_pfn_range(vma, from, pfn, size, prot)
456 453
diff --git a/include/asm-arm26/pgtable.h b/include/asm-arm26/pgtable.h
index 4a0a00da425f..f602cf572411 100644
--- a/include/asm-arm26/pgtable.h
+++ b/include/asm-arm26/pgtable.h
@@ -294,12 +294,9 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
294#include <asm-generic/pgtable.h> 294#include <asm-generic/pgtable.h>
295 295
296/* 296/*
297 * remap a physical address `phys' of size `size' with page protection `prot' 297 * remap a physical page `pfn' of size `size' with page protection `prot'
298 * into virtual address `from' 298 * into virtual address `from'
299 */ 299 */
300#define io_remap_page_range(vma,from,phys,size,prot) \
301 remap_pfn_range(vma, from, (phys) >> PAGE_SHIFT, size, prot)
302
303#define io_remap_pfn_range(vma,from,pfn,size,prot) \ 300#define io_remap_pfn_range(vma,from,pfn,size,prot) \
304 remap_pfn_range(vma, from, pfn, size, prot) 301 remap_pfn_range(vma, from, pfn, size, prot)
305 302
diff --git a/include/asm-frv/pgtable.h b/include/asm-frv/pgtable.h
index d0a9c2f9c13e..473fb4bb6329 100644
--- a/include/asm-frv/pgtable.h
+++ b/include/asm-frv/pgtable.h
@@ -500,9 +500,6 @@ static inline int pte_file(pte_t pte)
500#define PageSkip(page) (0) 500#define PageSkip(page) (0)
501#define kern_addr_valid(addr) (1) 501#define kern_addr_valid(addr) (1)
502 502
503#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
504 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
505
506#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 503#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
507 remap_pfn_range(vma, vaddr, pfn, size, prot) 504 remap_pfn_range(vma, vaddr, pfn, size, prot)
508 505
diff --git a/include/asm-h8300/pgtable.h b/include/asm-h8300/pgtable.h
index 69076eb31476..f6e296fc1297 100644
--- a/include/asm-h8300/pgtable.h
+++ b/include/asm-h8300/pgtable.h
@@ -52,8 +52,6 @@ extern int is_in_rom(unsigned long);
52 * No page table caches to initialise 52 * No page table caches to initialise
53 */ 53 */
54#define pgtable_cache_init() do { } while (0) 54#define pgtable_cache_init() do { } while (0)
55#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
56 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
57 55
58#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 56#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
59 remap_pfn_range(vma, vaddr, pfn, size, prot) 57 remap_pfn_range(vma, vaddr, pfn, size, prot)
diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h
index 47bc1ffa3d4c..d101ac414f07 100644
--- a/include/asm-i386/pgtable.h
+++ b/include/asm-i386/pgtable.h
@@ -431,9 +431,6 @@ extern void noexec_setup(const char *str);
431#define kern_addr_valid(addr) (1) 431#define kern_addr_valid(addr) (1)
432#endif /* CONFIG_FLATMEM */ 432#endif /* CONFIG_FLATMEM */
433 433
434#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
435 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
436
437#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 434#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
438 remap_pfn_range(vma, vaddr, pfn, size, prot) 435 remap_pfn_range(vma, vaddr, pfn, size, prot)
439 436
diff --git a/include/asm-ia64/pgtable.h b/include/asm-ia64/pgtable.h
index 2e34c06e6777..3339c7b55a6f 100644
--- a/include/asm-ia64/pgtable.h
+++ b/include/asm-ia64/pgtable.h
@@ -443,10 +443,6 @@ extern void paging_init (void);
443#define pte_to_pgoff(pte) ((pte_val(pte) << 1) >> 3) 443#define pte_to_pgoff(pte) ((pte_val(pte) << 1) >> 3)
444#define pgoff_to_pte(off) ((pte_t) { ((off) << 2) | _PAGE_FILE }) 444#define pgoff_to_pte(off) ((pte_t) { ((off) << 2) | _PAGE_FILE })
445 445
446/* XXX is this right? */
447#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
448 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
449
450#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 446#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
451 remap_pfn_range(vma, vaddr, pfn, size, prot) 447 remap_pfn_range(vma, vaddr, pfn, size, prot)
452 448
diff --git a/include/asm-m32r/pgtable.h b/include/asm-m32r/pgtable.h
index da805e970844..388e5ee9fa27 100644
--- a/include/asm-m32r/pgtable.h
+++ b/include/asm-m32r/pgtable.h
@@ -378,9 +378,6 @@ static inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
378/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */ 378/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
379#define kern_addr_valid(addr) (1) 379#define kern_addr_valid(addr) (1)
380 380
381#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
382 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
383
384#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 381#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
385 remap_pfn_range(vma, vaddr, pfn, size, prot) 382 remap_pfn_range(vma, vaddr, pfn, size, prot)
386 383
diff --git a/include/asm-m68k/pgtable.h b/include/asm-m68k/pgtable.h
index 0c87fc84f7a4..add129e93fd7 100644
--- a/include/asm-m68k/pgtable.h
+++ b/include/asm-m68k/pgtable.h
@@ -141,9 +141,6 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
141 141
142#define kern_addr_valid(addr) (1) 142#define kern_addr_valid(addr) (1)
143 143
144#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
145 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
146
147#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 144#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
148 remap_pfn_range(vma, vaddr, pfn, size, prot) 145 remap_pfn_range(vma, vaddr, pfn, size, prot)
149 146
diff --git a/include/asm-m68knommu/cacheflush.h b/include/asm-m68knommu/cacheflush.h
index aa7a2ffa41af..026bbc9565b4 100644
--- a/include/asm-m68knommu/cacheflush.h
+++ b/include/asm-m68knommu/cacheflush.h
@@ -2,23 +2,23 @@
2#define _M68KNOMMU_CACHEFLUSH_H 2#define _M68KNOMMU_CACHEFLUSH_H
3 3
4/* 4/*
5 * (C) Copyright 2000-2002, Greg Ungerer <gerg@snapgear.com> 5 * (C) Copyright 2000-2004, Greg Ungerer <gerg@snapgear.com>
6 */ 6 */
7#include <linux/mm.h> 7#include <linux/mm.h>
8 8
9#define flush_cache_all() __flush_cache_all() 9#define flush_cache_all() __flush_cache_all()
10#define flush_cache_mm(mm) do { } while (0) 10#define flush_cache_mm(mm) do { } while (0)
11#define flush_cache_range(vma, start, end) do { } while (0) 11#define flush_cache_range(vma, start, end) __flush_cache_all()
12#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 12#define flush_cache_page(vma, vmaddr) do { } while (0)
13#define flush_dcache_range(start,len) do { } while (0) 13#define flush_dcache_range(start,len) __flush_cache_all()
14#define flush_dcache_page(page) do { } while (0) 14#define flush_dcache_page(page) do { } while (0)
15#define flush_dcache_mmap_lock(mapping) do { } while (0) 15#define flush_dcache_mmap_lock(mapping) do { } while (0)
16#define flush_dcache_mmap_unlock(mapping) do { } while (0) 16#define flush_dcache_mmap_unlock(mapping) do { } while (0)
17#define flush_icache_range(start,len) __flush_cache_all() 17#define flush_icache_range(start,len) __flush_cache_all()
18#define flush_icache_page(vma,pg) do { } while (0) 18#define flush_icache_page(vma,pg) do { } while (0)
19#define flush_icache_user_range(vma,pg,adr,len) do { } while (0) 19#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
20#define flush_cache_vmap(start, end) flush_cache_all() 20#define flush_cache_vmap(start, end) do { } while (0)
21#define flush_cache_vunmap(start, end) flush_cache_all() 21#define flush_cache_vunmap(start, end) do { } while (0)
22 22
23#define copy_to_user_page(vma, page, vaddr, dst, src, len) \ 23#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
24 memcpy(dst, src, len) 24 memcpy(dst, src, len)
@@ -50,22 +50,23 @@ extern inline void __flush_cache_all(void)
50 "movec %%d0,%%CACR\n\t" 50 "movec %%d0,%%CACR\n\t"
51 : : : "d0", "a0" ); 51 : : : "d0", "a0" );
52#endif /* CONFIG_M5407 */ 52#endif /* CONFIG_M5407 */
53#ifdef CONFIG_M5272 53#if defined(CONFIG_M527x) || defined(CONFIG_M528x)
54 __asm__ __volatile__ ( 54 __asm__ __volatile__ (
55 "movel #0x01000000, %%d0\n\t" 55 "movel #0x81400100, %%d0\n\t"
56 "movec %%d0, %%CACR\n\t"
57 "nop\n\t"
58 "movel #0x80000100, %%d0\n\t"
59 "movec %%d0, %%CACR\n\t" 56 "movec %%d0, %%CACR\n\t"
60 "nop\n\t" 57 "nop\n\t"
61 : : : "d0" ); 58 : : : "d0" );
62#endif /* CONFIG_M5272 */ 59#endif /* CONFIG_M527x || CONFIG_M528x */
63#if 0 /* CONFIG_M5249 */ 60#ifdef CONFIG_M5272
64 __asm__ __volatile__ ( 61 __asm__ __volatile__ (
65 "movel #0x01000000, %%d0\n\t" 62 "movel #0x01000000, %%d0\n\t"
66 "movec %%d0, %%CACR\n\t" 63 "movec %%d0, %%CACR\n\t"
67 "nop\n\t" 64 "nop\n\t"
68 "movel #0xa0000200, %%d0\n\t" 65 : : : "d0" );
66#endif /* CONFIG_M5272 */
67#if CONFIG_M5249
68 __asm__ __volatile__ (
69 "movel #0xa1000200, %%d0\n\t"
69 "movec %%d0, %%CACR\n\t" 70 "movec %%d0, %%CACR\n\t"
70 "nop\n\t" 71 "nop\n\t"
71 : : : "d0" ); 72 : : : "d0" );
diff --git a/include/asm-m68knommu/pgtable.h b/include/asm-m68knommu/pgtable.h
index e2a69fffa370..00893055e6c2 100644
--- a/include/asm-m68knommu/pgtable.h
+++ b/include/asm-m68knommu/pgtable.h
@@ -56,8 +56,6 @@ extern int is_in_rom(unsigned long);
56 * No page table caches to initialise. 56 * No page table caches to initialise.
57 */ 57 */
58#define pgtable_cache_init() do { } while (0) 58#define pgtable_cache_init() do { } while (0)
59#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
60 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
61 59
62#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 60#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
63 remap_pfn_range(vma, vaddr, pfn, size, prot) 61 remap_pfn_range(vma, vaddr, pfn, size, prot)
diff --git a/include/asm-m68knommu/scatterlist.h b/include/asm-m68knommu/scatterlist.h
index 230b8d56d17f..12309b181d29 100644
--- a/include/asm-m68knommu/scatterlist.h
+++ b/include/asm-m68knommu/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _M68KNOMMU_SCATTERLIST_H 1#ifndef _M68KNOMMU_SCATTERLIST_H
2#define _M68KNOMMU_SCATTERLIST_H 2#define _M68KNOMMU_SCATTERLIST_H
3 3
4#include <linux/mm.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page *page; 7 struct page *page;
6 unsigned int offset; 8 unsigned int offset;
@@ -8,6 +10,10 @@ struct scatterlist {
8 unsigned int length; 10 unsigned int length;
9}; 11};
10 12
13#define sg_address(sg) (page_address((sg)->page) + (sg)->offset
14#define sg_dma_address(sg) ((sg)->dma_address)
15#define sg_dma_len(sg) ((sg)->length)
16
11#define ISA_DMA_THRESHOLD (0xffffffff) 17#define ISA_DMA_THRESHOLD (0xffffffff)
12 18
13#endif /* !(_M68KNOMMU_SCATTERLIST_H) */ 19#endif /* !(_M68KNOMMU_SCATTERLIST_H) */
diff --git a/include/asm-m68knommu/system.h b/include/asm-m68knommu/system.h
index c341b66c147b..53cbbad0f130 100644
--- a/include/asm-m68knommu/system.h
+++ b/include/asm-m68knommu/system.h
@@ -57,9 +57,18 @@ asmlinkage void resume(void);
57 : "cc", "%d0", "memory") 57 : "cc", "%d0", "memory")
58#define local_irq_disable() __asm__ __volatile__ ( \ 58#define local_irq_disable() __asm__ __volatile__ ( \
59 "move %/sr,%%d0\n\t" \ 59 "move %/sr,%%d0\n\t" \
60 "ori.l #0x0700,%%d0\n\t" \ 60 "ori.l #0x0700,%%d0\n\t" \
61 "move %%d0,%/sr\n" \ 61 "move %%d0,%/sr\n" \
62 : /* no inputs */ \ 62 : /* no outputs */ \
63 : \
64 : "cc", "%d0", "memory")
65/* For spinlocks etc */
66#define local_irq_save(x) __asm__ __volatile__ ( \
67 "movew %%sr,%0\n\t" \
68 "movew #0x0700,%%d0\n\t" \
69 "or.l %0,%%d0\n\t" \
70 "movew %%d0,%/sr" \
71 : "=d" (x) \
63 : \ 72 : \
64 : "cc", "%d0", "memory") 73 : "cc", "%d0", "memory")
65#else 74#else
@@ -75,7 +84,9 @@ asmlinkage void resume(void);
75#define local_irq_restore(x) asm volatile ("movew %0,%%sr": :"d" (x) : "memory") 84#define local_irq_restore(x) asm volatile ("movew %0,%%sr": :"d" (x) : "memory")
76 85
77/* For spinlocks etc */ 86/* For spinlocks etc */
87#ifndef local_irq_save
78#define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } while (0) 88#define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } while (0)
89#endif
79 90
80#define irqs_disabled() \ 91#define irqs_disabled() \
81({ \ 92({ \
@@ -234,9 +245,9 @@ cmpxchg(volatile int *p, int old, int new)
234#ifdef CONFIG_COLDFIRE 245#ifdef CONFIG_COLDFIRE
235#if defined(CONFIG_M5272) && defined(CONFIG_NETtel) 246#if defined(CONFIG_M5272) && defined(CONFIG_NETtel)
236/* 247/*
237 * Need to account for broken early mask of 5272 silicon. So don't 248 * Need to account for broken early mask of 5272 silicon. So don't
238 * jump through the original start address. Jump strait into the 249 * jump through the original start address. Jump strait into the
239 * known start of the FLASH code. 250 * known start of the FLASH code.
240 */ 251 */
241#define HARD_RESET_NOW() ({ \ 252#define HARD_RESET_NOW() ({ \
242 asm(" \ 253 asm(" \
@@ -244,7 +255,9 @@ cmpxchg(volatile int *p, int old, int new)
244 jmp 0xf0000400; \ 255 jmp 0xf0000400; \
245 "); \ 256 "); \
246}) 257})
247#elif defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || defined(CONFIG_CLEOPATRA) 258#elif defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \
259 defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || \
260 defined(CONFIG_CLEOPATRA)
248#define HARD_RESET_NOW() ({ \ 261#define HARD_RESET_NOW() ({ \
249 asm(" \ 262 asm(" \
250 movew #0x2700, %sr; \ 263 movew #0x2700, %sr; \
@@ -257,6 +270,26 @@ cmpxchg(volatile int *p, int old, int new)
257 jmp (%a0); \ 270 jmp (%a0); \
258 "); \ 271 "); \
259}) 272})
273#elif defined(CONFIG_M5272)
274/*
275 * Retrieve the boot address in flash using CSBR0 and CSOR0
276 * find the reset vector at flash_address + 4 (e.g. 0x400)
277 * remap it in the flash's current location (e.g. 0xf0000400)
278 * and jump there.
279 */
280#define HARD_RESET_NOW() ({ \
281 asm(" \
282 movew #0x2700, %%sr; \
283 move.l %0+0x40,%%d0; \
284 and.l %0+0x44,%%d0; \
285 andi.l #0xfffff000,%%d0; \
286 mov.l %%d0,%%a0; \
287 or.l 4(%%a0),%%d0; \
288 mov.l %%d0,%%a0; \
289 jmp (%%a0);" \
290 : /* No output */ \
291 : "o" (*(char *)MCF_MBAR) ); \
292})
260#elif defined(CONFIG_M528x) 293#elif defined(CONFIG_M528x)
261/* 294/*
262 * The MCF528x has a bit (SOFTRST) in memory (Reset Control Register RCR), 295 * The MCF528x has a bit (SOFTRST) in memory (Reset Control Register RCR),
@@ -270,6 +303,15 @@ cmpxchg(volatile int *p, int old, int new)
270 while(1) \ 303 while(1) \
271 *reset |= (0x01 << 7);\ 304 *reset |= (0x01 << 7);\
272}) 305})
306#elif defined(CONFIG_M523x)
307#define HARD_RESET_NOW() ({ \
308 asm(" \
309 movew #0x2700, %sr; \
310 movel #0x01000000, %sp; \
311 moveal #0x40110000, %a0; \
312 moveb #0x80, (%a0); \
313 "); \
314})
273#else 315#else
274#define HARD_RESET_NOW() ({ \ 316#define HARD_RESET_NOW() ({ \
275 asm(" \ 317 asm(" \
diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h
index dbe13da0bdad..cbd1672c94cb 100644
--- a/include/asm-mips/pgtable.h
+++ b/include/asm-mips/pgtable.h
@@ -358,16 +358,6 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
358extern phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size); 358extern phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size);
359extern int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long pfn, unsigned long size, pgprot_t prot); 359extern int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long pfn, unsigned long size, pgprot_t prot);
360 360
361static inline int io_remap_page_range(struct vm_area_struct *vma,
362 unsigned long vaddr,
363 unsigned long paddr,
364 unsigned long size,
365 pgprot_t prot)
366{
367 phys_t phys_addr_high = fixup_bigphys_addr(paddr, size);
368 return remap_pfn_range(vma, vaddr, phys_addr_high >> PAGE_SHIFT, size, prot);
369}
370
371static inline int io_remap_pfn_range(struct vm_area_struct *vma, 361static inline int io_remap_pfn_range(struct vm_area_struct *vma,
372 unsigned long vaddr, 362 unsigned long vaddr,
373 unsigned long pfn, 363 unsigned long pfn,
@@ -378,8 +368,6 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma,
378 return remap_pfn_range(vma, vaddr, pfn, size, prot); 368 return remap_pfn_range(vma, vaddr, pfn, size, prot);
379} 369}
380#else 370#else
381#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
382 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
383#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 371#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
384 remap_pfn_range(vma, vaddr, pfn, size, prot) 372 remap_pfn_range(vma, vaddr, pfn, size, prot)
385#endif 373#endif
diff --git a/include/asm-parisc/pgtable.h b/include/asm-parisc/pgtable.h
index f001bb01e38f..820c6e712cd7 100644
--- a/include/asm-parisc/pgtable.h
+++ b/include/asm-parisc/pgtable.h
@@ -498,9 +498,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
498 498
499#endif /* !__ASSEMBLY__ */ 499#endif /* !__ASSEMBLY__ */
500 500
501#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
502 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
503
504#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 501#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
505 remap_pfn_range(vma, vaddr, pfn, size, prot) 502 remap_pfn_range(vma, vaddr, pfn, size, prot)
506 503
diff --git a/include/asm-ppc/mv64x60.h b/include/asm-ppc/mv64x60.h
index 835930d6faa1..75c2ffa26b26 100644
--- a/include/asm-ppc/mv64x60.h
+++ b/include/asm-ppc/mv64x60.h
@@ -119,6 +119,14 @@ extern spinlock_t mv64x60_lock;
119 119
120#define MV64x60_64BIT_WIN_COUNT 24 120#define MV64x60_64BIT_WIN_COUNT 24
121 121
122/* Watchdog Platform Device, Driver Data */
123#define MV64x60_WDT_NAME "wdt"
124
125struct mv64x60_wdt_pdata {
126 int timeout; /* watchdog expiry in seconds, default 10 */
127 int bus_clk; /* bus clock in MHz, default 133 */
128};
129
122/* 130/*
123 * Define a structure that's used to pass in config information to the 131 * Define a structure that's used to pass in config information to the
124 * core routines. 132 * core routines.
diff --git a/include/asm-ppc/pgtable.h b/include/asm-ppc/pgtable.h
index 92f30b28b252..eee601bb9ada 100644
--- a/include/asm-ppc/pgtable.h
+++ b/include/asm-ppc/pgtable.h
@@ -812,15 +812,6 @@ extern void kernel_set_cachemode (unsigned long address, unsigned long size,
812#ifdef CONFIG_PHYS_64BIT 812#ifdef CONFIG_PHYS_64BIT
813extern int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, 813extern int remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
814 unsigned long paddr, unsigned long size, pgprot_t prot); 814 unsigned long paddr, unsigned long size, pgprot_t prot);
815static inline int io_remap_page_range(struct vm_area_struct *vma,
816 unsigned long vaddr,
817 unsigned long paddr,
818 unsigned long size,
819 pgprot_t prot)
820{
821 phys_addr_t paddr64 = fixup_bigphys_addr(paddr, size);
822 return remap_pfn_range(vma, vaddr, paddr64 >> PAGE_SHIFT, size, prot);
823}
824 815
825static inline int io_remap_pfn_range(struct vm_area_struct *vma, 816static inline int io_remap_pfn_range(struct vm_area_struct *vma,
826 unsigned long vaddr, 817 unsigned long vaddr,
@@ -832,8 +823,6 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma,
832 return remap_pfn_range(vma, vaddr, paddr64 >> PAGE_SHIFT, size, prot); 823 return remap_pfn_range(vma, vaddr, paddr64 >> PAGE_SHIFT, size, prot);
833} 824}
834#else 825#else
835#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
836 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
837#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 826#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
838 remap_pfn_range(vma, vaddr, pfn, size, prot) 827 remap_pfn_range(vma, vaddr, pfn, size, prot)
839#endif 828#endif
diff --git a/include/asm-ppc/segment.h b/include/asm-ppc/segment.h
deleted file mode 100644
index 0f2f7428d437..000000000000
--- a/include/asm-ppc/segment.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm/uaccess.h>
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h
index ecb909572d3f..0f4bcaae61bd 100644
--- a/include/asm-sh/pgtable.h
+++ b/include/asm-sh/pgtable.h
@@ -277,9 +277,6 @@ typedef pte_t *pte_addr_t;
277 277
278#define kern_addr_valid(addr) (1) 278#define kern_addr_valid(addr) (1)
279 279
280#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
281 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
282
283#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 280#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
284 remap_pfn_range(vma, vaddr, pfn, size, prot) 281 remap_pfn_range(vma, vaddr, pfn, size, prot)
285 282
diff --git a/include/asm-sh64/pgtable.h b/include/asm-sh64/pgtable.h
index 78ac6be2d9ef..51db4307bfaf 100644
--- a/include/asm-sh64/pgtable.h
+++ b/include/asm-sh64/pgtable.h
@@ -482,9 +482,6 @@ extern void update_mmu_cache(struct vm_area_struct * vma,
482#define PageSkip(page) (0) 482#define PageSkip(page) (0)
483#define kern_addr_valid(addr) (1) 483#define kern_addr_valid(addr) (1)
484 484
485#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
486 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
487
488#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 485#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
489 remap_pfn_range(vma, vaddr, pfn, size, prot) 486 remap_pfn_range(vma, vaddr, pfn, size, prot)
490 487
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
index 1dc110ba82d6..2cb483516459 100644
--- a/include/asm-x86_64/pgtable.h
+++ b/include/asm-x86_64/pgtable.h
@@ -421,9 +421,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
421 421
422extern int kern_addr_valid(unsigned long addr); 422extern int kern_addr_valid(unsigned long addr);
423 423
424#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
425 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
426
427#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 424#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
428 remap_pfn_range(vma, vaddr, pfn, size, prot) 425 remap_pfn_range(vma, vaddr, pfn, size, prot)
429 426
diff --git a/include/asm-xtensa/pgtable.h b/include/asm-xtensa/pgtable.h
index 883ebc2d75d6..987e3b802313 100644
--- a/include/asm-xtensa/pgtable.h
+++ b/include/asm-xtensa/pgtable.h
@@ -441,11 +441,11 @@ extern void update_mmu_cache(struct vm_area_struct * vma,
441 unsigned long address, pte_t pte); 441 unsigned long address, pte_t pte);
442 442
443/* 443/*
444 * remap a physical address `phys' of size `size' with page protection `prot' 444 * remap a physical page `pfn' of size `size' with page protection `prot'
445 * into virtual address `from' 445 * into virtual address `from'
446 */ 446 */
447#define io_remap_page_range(vma,from,phys,size,prot) \ 447#define io_remap_pfn_range(vma,from,pfn,size,prot) \
448 remap_pfn_range(vma, from, (phys) >> PAGE_SHIFT, size, prot) 448 remap_pfn_range(vma, from, pfn, size, prot)
449 449
450 450
451/* No page table caches to init */ 451/* No page table caches to init */
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 68aba0c02e49..b2a2509bd7ea 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -51,7 +51,8 @@
51#define AUDIT_WATCH_LIST 1009 /* List all file/dir watches */ 51#define AUDIT_WATCH_LIST 1009 /* List all file/dir watches */
52#define AUDIT_SIGNAL_INFO 1010 /* Get info about sender of signal to auditd */ 52#define AUDIT_SIGNAL_INFO 1010 /* Get info about sender of signal to auditd */
53 53
54#define AUDIT_FIRST_USER_MSG 1100 /* Userspace messages uninteresting to kernel */ 54#define AUDIT_FIRST_USER_MSG 1100 /* Userspace messages mostly uninteresting to kernel */
55#define AUDIT_USER_AVC 1107 /* We filter this differently */
55#define AUDIT_LAST_USER_MSG 1199 56#define AUDIT_LAST_USER_MSG 1199
56 57
57#define AUDIT_DAEMON_START 1200 /* Daemon startup record */ 58#define AUDIT_DAEMON_START 1200 /* Daemon startup record */
@@ -75,10 +76,15 @@
75#define AUDIT_KERNEL 2000 /* Asynchronous audit record. NOT A REQUEST. */ 76#define AUDIT_KERNEL 2000 /* Asynchronous audit record. NOT A REQUEST. */
76 77
77/* Rule flags */ 78/* Rule flags */
78#define AUDIT_PER_TASK 0x01 /* Apply rule at task creation (not syscall) */ 79#define AUDIT_FILTER_USER 0x00 /* Apply rule to user-generated messages */
79#define AUDIT_AT_ENTRY 0x02 /* Apply rule at syscall entry */ 80#define AUDIT_FILTER_TASK 0x01 /* Apply rule at task creation (not syscall) */
80#define AUDIT_AT_EXIT 0x04 /* Apply rule at syscall exit */ 81#define AUDIT_FILTER_ENTRY 0x02 /* Apply rule at syscall entry */
81#define AUDIT_PREPEND 0x10 /* Prepend to front of list */ 82#define AUDIT_FILTER_WATCH 0x03 /* Apply rule to file system watches */
83#define AUDIT_FILTER_EXIT 0x04 /* Apply rule at syscall exit */
84
85#define AUDIT_NR_FILTERS 5
86
87#define AUDIT_FILTER_PREPEND 0x10 /* Prepend to front of list */
82 88
83/* Rule actions */ 89/* Rule actions */
84#define AUDIT_NEVER 0 /* Do not build context if rule matches */ 90#define AUDIT_NEVER 0 /* Do not build context if rule matches */
@@ -199,6 +205,7 @@ struct audit_sig_info {
199struct audit_buffer; 205struct audit_buffer;
200struct audit_context; 206struct audit_context;
201struct inode; 207struct inode;
208struct netlink_skb_parms;
202 209
203#define AUDITSC_INVALID 0 210#define AUDITSC_INVALID 0
204#define AUDITSC_SUCCESS 1 211#define AUDITSC_SUCCESS 1
@@ -215,7 +222,7 @@ extern void audit_syscall_entry(struct task_struct *task, int arch,
215extern void audit_syscall_exit(struct task_struct *task, int failed, long return_code); 222extern void audit_syscall_exit(struct task_struct *task, int failed, long return_code);
216extern void audit_getname(const char *name); 223extern void audit_getname(const char *name);
217extern void audit_putname(const char *name); 224extern void audit_putname(const char *name);
218extern void audit_inode(const char *name, const struct inode *inode); 225extern void audit_inode(const char *name, const struct inode *inode, unsigned flags);
219 226
220 /* Private API (for audit.c only) */ 227 /* Private API (for audit.c only) */
221extern int audit_receive_filter(int type, int pid, int uid, int seq, 228extern int audit_receive_filter(int type, int pid, int uid, int seq,
@@ -230,6 +237,7 @@ extern int audit_socketcall(int nargs, unsigned long *args);
230extern int audit_sockaddr(int len, void *addr); 237extern int audit_sockaddr(int len, void *addr);
231extern int audit_avc_path(struct dentry *dentry, struct vfsmount *mnt); 238extern int audit_avc_path(struct dentry *dentry, struct vfsmount *mnt);
232extern void audit_signal_info(int sig, struct task_struct *t); 239extern void audit_signal_info(int sig, struct task_struct *t);
240extern int audit_filter_user(struct netlink_skb_parms *cb, int type);
233#else 241#else
234#define audit_alloc(t) ({ 0; }) 242#define audit_alloc(t) ({ 0; })
235#define audit_free(t) do { ; } while (0) 243#define audit_free(t) do { ; } while (0)
@@ -237,7 +245,7 @@ extern void audit_signal_info(int sig, struct task_struct *t);
237#define audit_syscall_exit(t,f,r) do { ; } while (0) 245#define audit_syscall_exit(t,f,r) do { ; } while (0)
238#define audit_getname(n) do { ; } while (0) 246#define audit_getname(n) do { ; } while (0)
239#define audit_putname(n) do { ; } while (0) 247#define audit_putname(n) do { ; } while (0)
240#define audit_inode(n,i) do { ; } while (0) 248#define audit_inode(n,i,f) do { ; } while (0)
241#define audit_receive_filter(t,p,u,s,d,l) ({ -EOPNOTSUPP; }) 249#define audit_receive_filter(t,p,u,s,d,l) ({ -EOPNOTSUPP; })
242#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) 250#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0)
243#define audit_get_loginuid(c) ({ -1; }) 251#define audit_get_loginuid(c) ({ -1; })
@@ -246,16 +254,17 @@ extern void audit_signal_info(int sig, struct task_struct *t);
246#define audit_sockaddr(len, addr) ({ 0; }) 254#define audit_sockaddr(len, addr) ({ 0; })
247#define audit_avc_path(dentry, mnt) ({ 0; }) 255#define audit_avc_path(dentry, mnt) ({ 0; })
248#define audit_signal_info(s,t) do { ; } while (0) 256#define audit_signal_info(s,t) do { ; } while (0)
257#define audit_filter_user(cb,t) ({ 1; })
249#endif 258#endif
250 259
251#ifdef CONFIG_AUDIT 260#ifdef CONFIG_AUDIT
252/* These are defined in audit.c */ 261/* These are defined in audit.c */
253 /* Public API */ 262 /* Public API */
254extern void audit_log(struct audit_context *ctx, int type, 263extern void audit_log(struct audit_context *ctx, int gfp_mask,
255 const char *fmt, ...) 264 int type, const char *fmt, ...)
256 __attribute__((format(printf,3,4))); 265 __attribute__((format(printf,4,5)));
257 266
258extern struct audit_buffer *audit_log_start(struct audit_context *ctx,int type); 267extern struct audit_buffer *audit_log_start(struct audit_context *ctx, int gfp_mask, int type);
259extern void audit_log_format(struct audit_buffer *ab, 268extern void audit_log_format(struct audit_buffer *ab,
260 const char *fmt, ...) 269 const char *fmt, ...)
261 __attribute__((format(printf,2,3))); 270 __attribute__((format(printf,2,3)));
@@ -274,9 +283,10 @@ extern void audit_send_reply(int pid, int seq, int type,
274 int done, int multi, 283 int done, int multi,
275 void *payload, int size); 284 void *payload, int size);
276extern void audit_log_lost(const char *message); 285extern void audit_log_lost(const char *message);
286extern struct semaphore audit_netlink_sem;
277#else 287#else
278#define audit_log(c,t,f,...) do { ; } while (0) 288#define audit_log(c,g,t,f,...) do { ; } while (0)
279#define audit_log_start(c,t) ({ NULL; }) 289#define audit_log_start(c,g,t) ({ NULL; })
280#define audit_log_vformat(b,f,a) do { ; } while (0) 290#define audit_log_vformat(b,f,a) do { ; } while (0)
281#define audit_log_format(b,f,...) do { ; } while (0) 291#define audit_log_format(b,f,...) do { ; } while (0)
282#define audit_log_end(b) do { ; } while (0) 292#define audit_log_end(b) do { ; } while (0)
diff --git a/include/linux/connector.h b/include/linux/connector.h
new file mode 100644
index 000000000000..96de26301f84
--- /dev/null
+++ b/include/linux/connector.h
@@ -0,0 +1,158 @@
1/*
2 * connector.h
3 *
4 * 2004-2005 Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef __CONNECTOR_H
23#define __CONNECTOR_H
24
25#include <asm/types.h>
26
27#define CN_IDX_CONNECTOR 0xffffffff
28#define CN_VAL_CONNECTOR 0xffffffff
29
30#define CN_NETLINK_USERS 1
31
32/*
33 * Maximum connector's message size.
34 */
35#define CONNECTOR_MAX_MSG_SIZE 1024
36
37/*
38 * idx and val are unique identifiers which
39 * are used for message routing and
40 * must be registered in connector.h for in-kernel usage.
41 */
42
43struct cb_id {
44 __u32 idx;
45 __u32 val;
46};
47
48struct cn_msg {
49 struct cb_id id;
50
51 __u32 seq;
52 __u32 ack;
53
54 __u16 len; /* Length of the following data */
55 __u16 flags;
56 __u8 data[0];
57};
58
59/*
60 * Notify structure - requests notification about
61 * registering/unregistering idx/val in range [first, first+range].
62 */
63struct cn_notify_req {
64 __u32 first;
65 __u32 range;
66};
67
68/*
69 * Main notification control message
70 * *_notify_num - number of appropriate cn_notify_req structures after
71 * this struct.
72 * group - notification receiver's idx.
73 * len - total length of the attached data.
74 */
75struct cn_ctl_msg {
76 __u32 idx_notify_num;
77 __u32 val_notify_num;
78 __u32 group;
79 __u32 len;
80 __u8 data[0];
81};
82
83#ifdef __KERNEL__
84
85#include <asm/atomic.h>
86
87#include <linux/list.h>
88#include <linux/workqueue.h>
89
90#include <net/sock.h>
91
92#define CN_CBQ_NAMELEN 32
93
94struct cn_queue_dev {
95 atomic_t refcnt;
96 unsigned char name[CN_CBQ_NAMELEN];
97
98 struct workqueue_struct *cn_queue;
99
100 struct list_head queue_list;
101 spinlock_t queue_lock;
102
103 int netlink_groups;
104 struct sock *nls;
105};
106
107struct cn_callback {
108 unsigned char name[CN_CBQ_NAMELEN];
109
110 struct cb_id id;
111 void (*callback) (void *);
112 void *priv;
113};
114
115struct cn_callback_entry {
116 struct list_head callback_entry;
117 struct cn_callback *cb;
118 struct work_struct work;
119 struct cn_queue_dev *pdev;
120
121 void (*destruct_data) (void *);
122 void *ddata;
123
124 int seq, group;
125 struct sock *nls;
126};
127
128struct cn_ctl_entry {
129 struct list_head notify_entry;
130 struct cn_ctl_msg *msg;
131};
132
133struct cn_dev {
134 struct cb_id id;
135
136 u32 seq, groups;
137 struct sock *nls;
138 void (*input) (struct sock * sk, int len);
139
140 struct cn_queue_dev *cbdev;
141};
142
143int cn_add_callback(struct cb_id *, char *, void (*callback) (void *));
144void cn_del_callback(struct cb_id *);
145int cn_netlink_send(struct cn_msg *, u32, int);
146
147int cn_queue_add_callback(struct cn_queue_dev *dev, struct cn_callback *cb);
148void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id);
149
150struct cn_queue_dev *cn_queue_alloc_dev(char *name, struct sock *);
151void cn_queue_free_dev(struct cn_queue_dev *dev);
152
153int cn_cb_equal(struct cb_id *, struct cb_id *);
154
155extern int cn_already_initialized;
156
157#endif /* __KERNEL__ */
158#endif /* __CONNECTOR_H */
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 82e39cd0c4fb..c698055266d0 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -619,7 +619,7 @@ struct fb_tilemap {
619 __u32 height; /* height of each tile in scanlines */ 619 __u32 height; /* height of each tile in scanlines */
620 __u32 depth; /* color depth of each tile */ 620 __u32 depth; /* color depth of each tile */
621 __u32 length; /* number of tiles in the map */ 621 __u32 length; /* number of tiles in the map */
622 __u8 *data; /* actual tile map: a bitmap array, packed 622 const __u8 *data; /* actual tile map: a bitmap array, packed
623 to the nearest byte */ 623 to the nearest byte */
624}; 624};
625 625
diff --git a/include/linux/font.h b/include/linux/font.h
index 8fc80a7d78ac..53b129f07f6f 100644
--- a/include/linux/font.h
+++ b/include/linux/font.h
@@ -15,9 +15,9 @@
15 15
16struct font_desc { 16struct font_desc {
17 int idx; 17 int idx;
18 char *name; 18 const char *name;
19 int width, height; 19 int width, height;
20 void *data; 20 const void *data;
21 int pref; 21 int pref;
22}; 22};
23 23
@@ -32,7 +32,7 @@ struct font_desc {
32#define ACORN8x8_IDX 8 32#define ACORN8x8_IDX 8
33#define MINI4x6_IDX 9 33#define MINI4x6_IDX 9
34 34
35extern struct font_desc font_vga_8x8, 35extern const struct font_desc font_vga_8x8,
36 font_vga_8x16, 36 font_vga_8x16,
37 font_pearl_8x8, 37 font_pearl_8x8,
38 font_vga_6x11, 38 font_vga_6x11,
@@ -45,11 +45,11 @@ extern struct font_desc font_vga_8x8,
45 45
46/* Find a font with a specific name */ 46/* Find a font with a specific name */
47 47
48extern struct font_desc *find_font(char *name); 48extern const struct font_desc *find_font(const char *name);
49 49
50/* Get the default font for a specific screen size */ 50/* Get the default font for a specific screen size */
51 51
52extern struct font_desc *get_default_font(int xres, int yres); 52extern const struct font_desc *get_default_font(int xres, int yres);
53 53
54/* Max. length for the name of a predefined font */ 54/* Max. length for the name of a predefined font */
55#define MAX_FONT_NAME 32 55#define MAX_FONT_NAME 32
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 687ba8c9973d..4367ce4db52a 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -307,8 +307,8 @@ struct sysinfo {
307 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ 307 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
308}; 308};
309 309
310extern void BUILD_BUG(void); 310/* Force a compilation error if condition is false */
311#define BUILD_BUG_ON(condition) do { if (condition) BUILD_BUG(); } while(0) 311#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
312 312
313#ifdef CONFIG_SYSCTL 313#ifdef CONFIG_SYSCTL
314extern int randomize_va_space; 314extern int randomize_va_space;
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 167518668936..7bbd25970c9e 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -15,6 +15,7 @@
15#define NETLINK_ISCSI 8 /* Open-iSCSI */ 15#define NETLINK_ISCSI 8 /* Open-iSCSI */
16#define NETLINK_AUDIT 9 /* auditing */ 16#define NETLINK_AUDIT 9 /* auditing */
17#define NETLINK_FIB_LOOKUP 10 17#define NETLINK_FIB_LOOKUP 10
18#define NETLINK_CONNECTOR 11
18#define NETLINK_NETFILTER 12 /* netfilter subsystem */ 19#define NETLINK_NETFILTER 12 /* netfilter subsystem */
19#define NETLINK_IP6_FW 13 20#define NETLINK_IP6_FW 13
20#define NETLINK_DNRTMSG 14 /* DECnet routing messages */ 21#define NETLINK_DNRTMSG 14 /* DECnet routing messages */
diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
index 4d24d65c0e88..8903688890ce 100644
--- a/include/linux/nfsd/xdr4.h
+++ b/include/linux/nfsd/xdr4.h
@@ -438,17 +438,22 @@ extern int nfsd4_process_open1(struct nfsd4_open *open);
438extern int nfsd4_process_open2(struct svc_rqst *rqstp, 438extern int nfsd4_process_open2(struct svc_rqst *rqstp,
439 struct svc_fh *current_fh, struct nfsd4_open *open); 439 struct svc_fh *current_fh, struct nfsd4_open *open);
440extern int nfsd4_open_confirm(struct svc_rqst *rqstp, 440extern int nfsd4_open_confirm(struct svc_rqst *rqstp,
441 struct svc_fh *current_fh, struct nfsd4_open_confirm *oc); 441 struct svc_fh *current_fh, struct nfsd4_open_confirm *oc,
442 struct nfs4_stateowner **);
442extern int nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, 443extern int nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh,
443 struct nfsd4_close *close); 444 struct nfsd4_close *close,
445 struct nfs4_stateowner **replay_owner);
444extern int nfsd4_open_downgrade(struct svc_rqst *rqstp, 446extern int nfsd4_open_downgrade(struct svc_rqst *rqstp,
445 struct svc_fh *current_fh, struct nfsd4_open_downgrade *od); 447 struct svc_fh *current_fh, struct nfsd4_open_downgrade *od,
448 struct nfs4_stateowner **replay_owner);
446extern int nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, 449extern int nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh,
447 struct nfsd4_lock *lock); 450 struct nfsd4_lock *lock,
451 struct nfs4_stateowner **replay_owner);
448extern int nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, 452extern int nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh,
449 struct nfsd4_lockt *lockt); 453 struct nfsd4_lockt *lockt);
450extern int nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, 454extern int nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh,
451 struct nfsd4_locku *locku); 455 struct nfsd4_locku *locku,
456 struct nfs4_stateowner **replay_owner);
452extern int 457extern int
453nfsd4_release_lockowner(struct svc_rqst *rqstp, 458nfsd4_release_lockowner(struct svc_rqst *rqstp,
454 struct nfsd4_release_lockowner *rlockowner); 459 struct nfsd4_release_lockowner *rlockowner);
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index ee0ab7a5f91b..f6c1a142286a 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -447,6 +447,10 @@
447#define PCI_DEVICE_ID_CIRRUS_7542 0x1200 447#define PCI_DEVICE_ID_CIRRUS_7542 0x1200
448#define PCI_DEVICE_ID_CIRRUS_7543 0x1202 448#define PCI_DEVICE_ID_CIRRUS_7543 0x1202
449#define PCI_DEVICE_ID_CIRRUS_7541 0x1204 449#define PCI_DEVICE_ID_CIRRUS_7541 0x1204
450#define PCI_DEVICE_ID_CIRRUS_4610 0x6001
451#define PCI_DEVICE_ID_CIRRUS_4612 0x6003
452#define PCI_DEVICE_ID_CIRRUS_4615 0x6004
453#define PCI_DEVICE_ID_CIRRUS_4281 0x6005
450 454
451#define PCI_VENDOR_ID_IBM 0x1014 455#define PCI_VENDOR_ID_IBM 0x1014
452#define PCI_DEVICE_ID_IBM_FIRE_CORAL 0x000a 456#define PCI_DEVICE_ID_IBM_FIRE_CORAL 0x000a
@@ -682,7 +686,9 @@
682#define PCI_DEVICE_ID_SI_6326 0x6326 686#define PCI_DEVICE_ID_SI_6326 0x6326
683#define PCI_DEVICE_ID_SI_7001 0x7001 687#define PCI_DEVICE_ID_SI_7001 0x7001
684#define PCI_DEVICE_ID_SI_7012 0x7012 688#define PCI_DEVICE_ID_SI_7012 0x7012
689#define PCI_DEVICE_ID_SI_7013 0x7013
685#define PCI_DEVICE_ID_SI_7016 0x7016 690#define PCI_DEVICE_ID_SI_7016 0x7016
691#define PCI_DEVICE_ID_SI_7018 0x7018
686 692
687#define PCI_VENDOR_ID_HP 0x103c 693#define PCI_VENDOR_ID_HP 0x103c
688#define PCI_DEVICE_ID_HP_VISUALIZE_EG 0x1005 694#define PCI_DEVICE_ID_HP_VISUALIZE_EG 0x1005
@@ -713,10 +719,12 @@
713#define PCI_DEVICE_ID_HP_DIVA_EVEREST 0x1282 719#define PCI_DEVICE_ID_HP_DIVA_EVEREST 0x1282
714#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290 720#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290
715#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301 721#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301
722#define PCI_DEVICE_ID_HP_CISS 0x3210
716#define PCI_DEVICE_ID_HP_CISSA 0x3220 723#define PCI_DEVICE_ID_HP_CISSA 0x3220
717#define PCI_DEVICE_ID_HP_CISSB 0x3222 724#define PCI_DEVICE_ID_HP_CISSB 0x3222
718#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031
719#define PCI_DEVICE_ID_HP_CISSC 0x3230 725#define PCI_DEVICE_ID_HP_CISSC 0x3230
726#define PCI_DEVICE_ID_HP_CISSD 0x3238
727#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031
720 728
721#define PCI_VENDOR_ID_PCTECH 0x1042 729#define PCI_VENDOR_ID_PCTECH 0x1042
722#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000 730#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000
@@ -991,6 +999,7 @@
991#define PCI_DEVICE_ID_BROOKTREE_849A 0x0351 999#define PCI_DEVICE_ID_BROOKTREE_849A 0x0351
992#define PCI_DEVICE_ID_BROOKTREE_878_1 0x036e 1000#define PCI_DEVICE_ID_BROOKTREE_878_1 0x036e
993#define PCI_DEVICE_ID_BROOKTREE_878 0x0878 1001#define PCI_DEVICE_ID_BROOKTREE_878 0x0878
1002#define PCI_DEVICE_ID_BROOKTREE_879 0x0879
994#define PCI_DEVICE_ID_BROOKTREE_8474 0x8474 1003#define PCI_DEVICE_ID_BROOKTREE_8474 0x8474
995 1004
996#define PCI_VENDOR_ID_SIERRA 0x10a8 1005#define PCI_VENDOR_ID_SIERRA 0x10a8
@@ -1109,6 +1118,9 @@
1109#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2160 0x0004 1118#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2160 0x0004
1110#define PCI_DEVICE_ID_NEOMAGIC_MAGICMEDIA_256AV 0x0005 1119#define PCI_DEVICE_ID_NEOMAGIC_MAGICMEDIA_256AV 0x0005
1111#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZVPLUS 0x0083 1120#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZVPLUS 0x0083
1121#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005
1122#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006
1123#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016
1112 1124
1113#define PCI_VENDOR_ID_ASP 0x10cd 1125#define PCI_VENDOR_ID_ASP 0x10cd
1114#define PCI_DEVICE_ID_ASP_ABP940 0x1200 1126#define PCI_DEVICE_ID_ASP_ABP940 0x1200
@@ -1155,10 +1167,13 @@
1155#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064 1167#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064
1156#define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE 0x0065 1168#define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE 0x0065
1157#define PCI_DEVICE_ID_NVIDIA_NVENET_2 0x0066 1169#define PCI_DEVICE_ID_NVIDIA_NVENET_2 0x0066
1170#define PCI_DEVICE_ID_NVIDIA_MCP2_MODEM 0x0069
1158#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a 1171#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a
1159#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS 0x0084 1172#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS 0x0084
1160#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE 0x0085 1173#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE 0x0085
1161#define PCI_DEVICE_ID_NVIDIA_NVENET_4 0x0086 1174#define PCI_DEVICE_ID_NVIDIA_NVENET_4 0x0086
1175#define PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM 0x0089
1176#define PCI_DEVICE_ID_NVIDIA_CK8_AUDIO 0x008a
1162#define PCI_DEVICE_ID_NVIDIA_NVENET_5 0x008c 1177#define PCI_DEVICE_ID_NVIDIA_NVENET_5 0x008c
1163#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA 0x008e 1178#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA 0x008e
1164#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0 1179#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0
@@ -1173,6 +1188,7 @@
1173#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4 1188#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4
1174#define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5 1189#define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5
1175#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6 1190#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6
1191#define PCI_DEVICE_ID_NVIDIA_MCP3_MODEM 0x00d9
1176#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da 1192#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da
1177#define PCI_DEVICE_ID_NVIDIA_NVENET_7 0x00df 1193#define PCI_DEVICE_ID_NVIDIA_NVENET_7 0x00df
1178#define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1 1194#define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1
@@ -1180,6 +1196,7 @@
1180#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS 0x00e4 1196#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS 0x00e4
1181#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE 0x00e5 1197#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE 0x00e5
1182#define PCI_DEVICE_ID_NVIDIA_NVENET_6 0x00e6 1198#define PCI_DEVICE_ID_NVIDIA_NVENET_6 0x00e6
1199#define PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO 0x00ea
1183#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2 0x00ee 1200#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2 0x00ee
1184#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100 1201#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100
1185#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101 1202#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101
@@ -1230,6 +1247,7 @@
1230#define PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO 0x01b1 1247#define PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO 0x01b1
1231#define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01b4 1248#define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01b4
1232#define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE 0x01bc 1249#define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE 0x01bc
1250#define PCI_DEVICE_ID_NVIDIA_MCP1_MODEM 0x01c1
1233#define PCI_DEVICE_ID_NVIDIA_NVENET_1 0x01c3 1251#define PCI_DEVICE_ID_NVIDIA_NVENET_1 0x01c3
1234#define PCI_DEVICE_ID_NVIDIA_NFORCE2 0x01e0 1252#define PCI_DEVICE_ID_NVIDIA_NFORCE2 0x01e0
1235#define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200 1253#define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200
@@ -1334,6 +1352,13 @@
1334#define PCI_DEVICE_ID_REALTEK_8169 0x8169 1352#define PCI_DEVICE_ID_REALTEK_8169 0x8169
1335 1353
1336#define PCI_VENDOR_ID_XILINX 0x10ee 1354#define PCI_VENDOR_ID_XILINX 0x10ee
1355#define PCI_DEVICE_ID_RME_DIGI96 0x3fc0
1356#define PCI_DEVICE_ID_RME_DIGI96_8 0x3fc1
1357#define PCI_DEVICE_ID_RME_DIGI96_8_PRO 0x3fc2
1358#define PCI_DEVICE_IDRME__DIGI96_8_PAD_OR_PST 0x3fc3
1359#define PCI_DEVICE_ID_XILINX_HAMMERFALL 0x3fc4
1360#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5
1361#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6
1337#define PCI_DEVICE_ID_TURBOPAM 0x4020 1362#define PCI_DEVICE_ID_TURBOPAM 0x4020
1338 1363
1339#define PCI_VENDOR_ID_TRUEVISION 0x10fa 1364#define PCI_VENDOR_ID_TRUEVISION 0x10fa
@@ -1809,6 +1834,14 @@
1809#define PCI_DEVICE_ID_ESS_ESS1968 0x1968 1834#define PCI_DEVICE_ID_ESS_ESS1968 0x1968
1810#define PCI_DEVICE_ID_ESS_AUDIOPCI 0x1969 1835#define PCI_DEVICE_ID_ESS_AUDIOPCI 0x1969
1811#define PCI_DEVICE_ID_ESS_ESS1978 0x1978 1836#define PCI_DEVICE_ID_ESS_ESS1978 0x1978
1837#define PCI_DEVICE_ID_ESS_ALLEGRO_1 0x1988
1838#define PCI_DEVICE_ID_ESS_ALLEGRO 0x1989
1839#define PCI_DEVICE_ID_ESS_CANYON3D_2LE 0x1990
1840#define PCI_DEVICE_ID_ESS_CANYON3D_2 0x1992
1841#define PCI_DEVICE_ID_ESS_MAESTRO3 0x1998
1842#define PCI_DEVICE_ID_ESS_MAESTRO3_1 0x1999
1843#define PCI_DEVICE_ID_ESS_MAESTRO3_HW 0x199a
1844#define PCI_DEVICE_ID_ESS_MAESTRO3_2 0x199b
1812 1845
1813#define PCI_VENDOR_ID_SATSAGEM 0x1267 1846#define PCI_VENDOR_ID_SATSAGEM 0x1267
1814#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016 1847#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016
@@ -1968,6 +2001,9 @@
1968#define PCI_DEVICE_ID_LMC_SSI 0x0005 2001#define PCI_DEVICE_ID_LMC_SSI 0x0005
1969#define PCI_DEVICE_ID_LMC_T1 0x0006 2002#define PCI_DEVICE_ID_LMC_T1 0x0006
1970 2003
2004#define PCI_VENDOR_ID_MARIAN 0x1382
2005#define PCI_DEVICE_ID_MARIAN_PRODIF_PLUS 0x2048
2006
1971#define PCI_VENDOR_ID_NETGEAR 0x1385 2007#define PCI_VENDOR_ID_NETGEAR 0x1385
1972#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a 2008#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a
1973#define PCI_DEVICE_ID_NETGEAR_GA622 0x622a 2009#define PCI_DEVICE_ID_NETGEAR_GA622 0x622a
@@ -2056,6 +2092,10 @@
2056#define PCI_VENDOR_ID_TIMEDIA 0x1409 2092#define PCI_VENDOR_ID_TIMEDIA 0x1409
2057#define PCI_DEVICE_ID_TIMEDIA_1889 0x7168 2093#define PCI_DEVICE_ID_TIMEDIA_1889 0x7168
2058 2094
2095#define PCI_VENDOR_ID_ICE 0x1412
2096#define PCI_DEVICE_ID_ICE_1712 0x1712
2097#define PCI_DEVICE_ID_VT1724 0x1724
2098
2059#define PCI_VENDOR_ID_OXSEMI 0x1415 2099#define PCI_VENDOR_ID_OXSEMI 0x1415
2060#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403 2100#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403
2061#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501 2101#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501
@@ -2536,6 +2576,7 @@
2536#define PCI_DEVICE_ID_INTEL_82443BX_1 0x7191 2576#define PCI_DEVICE_ID_INTEL_82443BX_1 0x7191
2537#define PCI_DEVICE_ID_INTEL_82443BX_2 0x7192 2577#define PCI_DEVICE_ID_INTEL_82443BX_2 0x7192
2538#define PCI_DEVICE_ID_INTEL_440MX 0x7195 2578#define PCI_DEVICE_ID_INTEL_440MX 0x7195
2579#define PCI_DEVICE_ID_INTEL_440MX_6 0x7196
2539#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198 2580#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198
2540#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199 2581#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199
2541#define PCI_DEVICE_ID_INTEL_82443MX_2 0x719a 2582#define PCI_DEVICE_ID_INTEL_82443MX_2 0x719a
@@ -2642,6 +2683,11 @@
2642#define PCI_VENDOR_ID_TTTECH 0x0357 2683#define PCI_VENDOR_ID_TTTECH 0x0357
2643#define PCI_DEVICE_ID_TTTECH_MC322 0x000A 2684#define PCI_DEVICE_ID_TTTECH_MC322 0x000A
2644 2685
2686#define PCI_VENDOR_ID_XILINX_RME 0xea60
2687#define PCI_DEVICE_ID_RME_DIGI32 0x9896
2688#define PCI_DEVICE_ID_RME_DIGI32_PRO 0x9897
2689#define PCI_DEVICE_ID_RME_DIGI32_8 0x9898
2690
2645#define PCI_VENDOR_ID_ARK 0xedd8 2691#define PCI_VENDOR_ID_ARK 0xedd8
2646#define PCI_DEVICE_ID_ARK_STING 0xa091 2692#define PCI_DEVICE_ID_ARK_STING 0xa091
2647#define PCI_DEVICE_ID_ARK_STINGARK 0xa099 2693#define PCI_DEVICE_ID_ARK_STINGARK 0xa099
diff --git a/include/linux/pktcdvd.h b/include/linux/pktcdvd.h
index 4b32bce9a289..2c177e4c8f22 100644
--- a/include/linux/pktcdvd.h
+++ b/include/linux/pktcdvd.h
@@ -166,6 +166,9 @@ struct packet_iosched
166/* 166/*
167 * 32 buffers of 2048 bytes 167 * 32 buffers of 2048 bytes
168 */ 168 */
169#if (PAGE_SIZE % CD_FRAMESIZE) != 0
170#error "PAGE_SIZE must be a multiple of CD_FRAMESIZE"
171#endif
169#define PACKET_MAX_SIZE 32 172#define PACKET_MAX_SIZE 32
170#define PAGES_PER_PACKET (PACKET_MAX_SIZE * CD_FRAMESIZE / PAGE_SIZE) 173#define PAGES_PER_PACKET (PACKET_MAX_SIZE * CD_FRAMESIZE / PAGE_SIZE)
171#define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9) 174#define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 38c8654aaa96..49e617fa0f66 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -121,6 +121,17 @@ extern unsigned long nr_iowait(void);
121#define set_task_state(tsk, state_value) \ 121#define set_task_state(tsk, state_value) \
122 set_mb((tsk)->state, (state_value)) 122 set_mb((tsk)->state, (state_value))
123 123
124/*
125 * set_current_state() includes a barrier so that the write of current->state
126 * is correctly serialised wrt the caller's subsequent test of whether to
127 * actually sleep:
128 *
129 * set_current_state(TASK_UNINTERRUPTIBLE);
130 * if (do_i_need_to_sleep())
131 * schedule();
132 *
133 * If the caller does not need such serialisation then use __set_current_state()
134 */
124#define __set_current_state(state_value) \ 135#define __set_current_state(state_value) \
125 do { current->state = (state_value); } while (0) 136 do { current->state = (state_value); } while (0)
126#define set_current_state(state_value) \ 137#define set_current_state(state_value) \
diff --git a/include/linux/security.h b/include/linux/security.h
index 55b02e1c73f4..0e43460d374e 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1907,6 +1907,11 @@ extern int register_security (struct security_operations *ops);
1907extern int unregister_security (struct security_operations *ops); 1907extern int unregister_security (struct security_operations *ops);
1908extern int mod_reg_security (const char *name, struct security_operations *ops); 1908extern int mod_reg_security (const char *name, struct security_operations *ops);
1909extern int mod_unreg_security (const char *name, struct security_operations *ops); 1909extern int mod_unreg_security (const char *name, struct security_operations *ops);
1910extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1911 struct dentry *parent, void *data,
1912 struct file_operations *fops);
1913extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1914extern void securityfs_remove(struct dentry *dentry);
1910 1915
1911 1916
1912#else /* CONFIG_SECURITY */ 1917#else /* CONFIG_SECURITY */
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 532a6c5c24e9..3a29a9f9b451 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -544,7 +544,8 @@ enum {
544 NET_NETROM_TRANSPORT_REQUESTED_WINDOW_SIZE=8, 544 NET_NETROM_TRANSPORT_REQUESTED_WINDOW_SIZE=8,
545 NET_NETROM_TRANSPORT_NO_ACTIVITY_TIMEOUT=9, 545 NET_NETROM_TRANSPORT_NO_ACTIVITY_TIMEOUT=9,
546 NET_NETROM_ROUTING_CONTROL=10, 546 NET_NETROM_ROUTING_CONTROL=10,
547 NET_NETROM_LINK_FAILS_COUNT=11 547 NET_NETROM_LINK_FAILS_COUNT=11,
548 NET_NETROM_RESET=12
548}; 549};
549 550
550/* /proc/sys/net/ax25 */ 551/* /proc/sys/net/ax25 */
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index f623a33b9abe..89a055761bed 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -60,12 +60,17 @@ enum v4l2_field {
60 (field) == V4L2_FIELD_SEQ_BT) 60 (field) == V4L2_FIELD_SEQ_BT)
61 61
62enum v4l2_buf_type { 62enum v4l2_buf_type {
63 V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, 63 V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
64 V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, 64 V4L2_BUF_TYPE_VIDEO_OUTPUT = 2,
65 V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, 65 V4L2_BUF_TYPE_VIDEO_OVERLAY = 3,
66 V4L2_BUF_TYPE_VBI_CAPTURE = 4, 66 V4L2_BUF_TYPE_VBI_CAPTURE = 4,
67 V4L2_BUF_TYPE_VBI_OUTPUT = 5, 67 V4L2_BUF_TYPE_VBI_OUTPUT = 5,
68 V4L2_BUF_TYPE_PRIVATE = 0x80, 68#if 1
69 /* Experimental Sliced VBI */
70 V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6,
71 V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7,
72#endif
73 V4L2_BUF_TYPE_PRIVATE = 0x80,
69}; 74};
70 75
71enum v4l2_ctrl_type { 76enum v4l2_ctrl_type {
@@ -149,20 +154,24 @@ struct v4l2_capability
149}; 154};
150 155
151/* Values for 'capabilities' field */ 156/* Values for 'capabilities' field */
152#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */ 157#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */
153#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */ 158#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */
154#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ 159#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */
155#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a VBI capture device */ 160#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */
156#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a VBI output device */ 161#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */
157#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ 162#if 1
163#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */
164#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */
165#endif
166#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */
158 167
159#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ 168#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
160#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ 169#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
161#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ 170#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */
162 171
163#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ 172#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
164#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ 173#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
165#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */ 174#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */
166 175
167/* 176/*
168 * V I D E O I M A G E F O R M A T 177 * V I D E O I M A G E F O R M A T
@@ -809,6 +818,8 @@ struct v4l2_audioout
809 * Data services API by Michael Schimek 818 * Data services API by Michael Schimek
810 */ 819 */
811 820
821/* Raw VBI */
822
812struct v4l2_vbi_format 823struct v4l2_vbi_format
813{ 824{
814 __u32 sampling_rate; /* in 1 Hz */ 825 __u32 sampling_rate; /* in 1 Hz */
@@ -825,6 +836,54 @@ struct v4l2_vbi_format
825#define V4L2_VBI_UNSYNC (1<< 0) 836#define V4L2_VBI_UNSYNC (1<< 0)
826#define V4L2_VBI_INTERLACED (1<< 1) 837#define V4L2_VBI_INTERLACED (1<< 1)
827 838
839#if 1
840/* Sliced VBI
841 *
842 * This implements is a proposal V4L2 API to allow SLICED VBI
843 * required for some hardware encoders. It should change without
844 * notice in the definitive implementation.
845 */
846
847struct v4l2_sliced_vbi_format
848{
849 __u16 service_set;
850 /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
851 service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
852 (equals frame lines 313-336 for 625 line video
853 standards, 263-286 for 525 line standards) */
854 __u16 service_lines[2][24];
855 __u32 io_size;
856 __u32 reserved[2]; /* must be zero */
857};
858
859#define V4L2_SLICED_TELETEXT_B (0x0001)
860#define V4L2_SLICED_VPS (0x0400)
861#define V4L2_SLICED_CAPTION_525 (0x1000)
862#define V4L2_SLICED_WSS_625 (0x4000)
863
864#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525)
865#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625)
866
867struct v4l2_sliced_vbi_cap
868{
869 __u16 service_set;
870 /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
871 service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
872 (equals frame lines 313-336 for 625 line video
873 standards, 263-286 for 525 line standards) */
874 __u16 service_lines[2][24];
875 __u32 reserved[4]; /* must be 0 */
876};
877
878struct v4l2_sliced_vbi_data
879{
880 __u32 id;
881 __u32 field; /* 0: first field, 1: second field */
882 __u32 line; /* 1-23 */
883 __u32 reserved; /* must be 0 */
884 __u8 data[48];
885};
886#endif
828 887
829/* 888/*
830 * A G G R E G A T E S T R U C T U R E S 889 * A G G R E G A T E S T R U C T U R E S
@@ -837,10 +896,13 @@ struct v4l2_format
837 enum v4l2_buf_type type; 896 enum v4l2_buf_type type;
838 union 897 union
839 { 898 {
840 struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE 899 struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE
841 struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY 900 struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY
842 struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE 901 struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE
843 __u8 raw_data[200]; // user-defined 902#if 1
903 struct v4l2_sliced_vbi_format sliced; // V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
904#endif
905 __u8 raw_data[200]; // user-defined
844 } fmt; 906 } fmt;
845}; 907};
846 908
@@ -916,6 +978,9 @@ struct v4l2_streamparm
916#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout) 978#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout)
917#define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority) 979#define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority)
918#define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority) 980#define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority)
981#if 1
982#define VIDIOC_G_SLICED_VBI_CAP _IOR ('V', 69, struct v4l2_sliced_vbi_cap)
983#endif
919 984
920/* for compatibility, will go away some day */ 985/* for compatibility, will go away some day */
921#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) 986#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int)
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 227d3378decd..9dbcd9e51c00 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -26,11 +26,20 @@
26 26
27/* AX.25 Protocol IDs */ 27/* AX.25 Protocol IDs */
28#define AX25_P_ROSE 0x01 28#define AX25_P_ROSE 0x01
29#define AX25_P_IP 0xCC 29#define AX25_P_VJCOMP 0x06 /* Compressed TCP/IP packet */
30#define AX25_P_ARP 0xCD 30 /* Van Jacobsen (RFC 1144) */
31#define AX25_P_TEXT 0xF0 31#define AX25_P_VJUNCOMP 0x07 /* Uncompressed TCP/IP packet */
32#define AX25_P_NETROM 0xCF 32 /* Van Jacobsen (RFC 1144) */
33#define AX25_P_SEGMENT 0x08 33#define AX25_P_SEGMENT 0x08 /* Segmentation fragment */
34#define AX25_P_TEXNET 0xc3 /* TEXTNET datagram protocol */
35#define AX25_P_LQ 0xc4 /* Link Quality Protocol */
36#define AX25_P_ATALK 0xca /* Appletalk */
37#define AX25_P_ATALK_ARP 0xcb /* Appletalk ARP */
38#define AX25_P_IP 0xcc /* ARPA Internet Protocol */
39#define AX25_P_ARP 0xcd /* ARPA Adress Resolution */
40#define AX25_P_FLEXNET 0xce /* FlexNet */
41#define AX25_P_NETROM 0xcf /* NET/ROM */
42#define AX25_P_TEXT 0xF0 /* No layer 3 protocol impl. */
34 43
35/* AX.25 Segment control values */ 44/* AX.25 Segment control values */
36#define AX25_SEG_REM 0x7F 45#define AX25_SEG_REM 0x7F
@@ -88,11 +97,11 @@
88/* Define Link State constants. */ 97/* Define Link State constants. */
89 98
90enum { 99enum {
91 AX25_STATE_0, 100 AX25_STATE_0, /* Listening */
92 AX25_STATE_1, 101 AX25_STATE_1, /* SABM sent */
93 AX25_STATE_2, 102 AX25_STATE_2, /* DISC sent */
94 AX25_STATE_3, 103 AX25_STATE_3, /* Established */
95 AX25_STATE_4 104 AX25_STATE_4 /* Recovery */
96}; 105};
97 106
98#define AX25_MODULUS 8 /* Standard AX.25 modulus */ 107#define AX25_MODULUS 8 /* Standard AX.25 modulus */
@@ -319,7 +328,7 @@ extern int ax25_rx_iframe(ax25_cb *, struct sk_buff *);
319extern int ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); 328extern int ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
320 329
321/* ax25_ip.c */ 330/* ax25_ip.c */
322extern int ax25_encapsulate(struct sk_buff *, struct net_device *, unsigned short, void *, void *, unsigned int); 331extern int ax25_hard_header(struct sk_buff *, struct net_device *, unsigned short, void *, void *, unsigned int);
323extern int ax25_rebuild_header(struct sk_buff *); 332extern int ax25_rebuild_header(struct sk_buff *);
324 333
325/* ax25_out.c */ 334/* ax25_out.c */
diff --git a/include/net/netrom.h b/include/net/netrom.h
index 45f2c7616d8b..a6bf6e0f606a 100644
--- a/include/net/netrom.h
+++ b/include/net/netrom.h
@@ -6,6 +6,7 @@
6 6
7#ifndef _NETROM_H 7#ifndef _NETROM_H
8#define _NETROM_H 8#define _NETROM_H
9
9#include <linux/netrom.h> 10#include <linux/netrom.h>
10#include <linux/list.h> 11#include <linux/list.h>
11#include <net/sock.h> 12#include <net/sock.h>
@@ -22,6 +23,7 @@
22#define NR_DISCACK 0x04 23#define NR_DISCACK 0x04
23#define NR_INFO 0x05 24#define NR_INFO 0x05
24#define NR_INFOACK 0x06 25#define NR_INFOACK 0x06
26#define NR_RESET 0x07
25 27
26#define NR_CHOKE_FLAG 0x80 28#define NR_CHOKE_FLAG 0x80
27#define NR_NAK_FLAG 0x40 29#define NR_NAK_FLAG 0x40
@@ -51,11 +53,16 @@ enum {
51#define NR_DEFAULT_TTL 16 /* Default Time To Live - 16 */ 53#define NR_DEFAULT_TTL 16 /* Default Time To Live - 16 */
52#define NR_DEFAULT_ROUTING 1 /* Is routing enabled ? */ 54#define NR_DEFAULT_ROUTING 1 /* Is routing enabled ? */
53#define NR_DEFAULT_FAILS 2 /* Link fails until route fails */ 55#define NR_DEFAULT_FAILS 2 /* Link fails until route fails */
56#define NR_DEFAULT_RESET 0 /* Sent / accept reset cmds? */
54 57
55#define NR_MODULUS 256 58#define NR_MODULUS 256
56#define NR_MAX_WINDOW_SIZE 127 /* Maximum Window Allowable - 127 */ 59#define NR_MAX_WINDOW_SIZE 127 /* Maximum Window Allowable - 127 */
57#define NR_MAX_PACKET_SIZE 236 /* Maximum Packet Length - 236 */ 60#define NR_MAX_PACKET_SIZE 236 /* Maximum Packet Length - 236 */
58 61
62struct nr_private {
63 struct net_device_stats stats;
64};
65
59struct nr_sock { 66struct nr_sock {
60 struct sock sock; 67 struct sock sock;
61 ax25_address user_addr, source_addr, dest_addr; 68 ax25_address user_addr, source_addr, dest_addr;
@@ -176,6 +183,8 @@ extern int sysctl_netrom_transport_requested_window_size;
176extern int sysctl_netrom_transport_no_activity_timeout; 183extern int sysctl_netrom_transport_no_activity_timeout;
177extern int sysctl_netrom_routing_control; 184extern int sysctl_netrom_routing_control;
178extern int sysctl_netrom_link_fails_count; 185extern int sysctl_netrom_link_fails_count;
186extern int sysctl_netrom_reset_circuit;
187
179extern int nr_rx_frame(struct sk_buff *, struct net_device *); 188extern int nr_rx_frame(struct sk_buff *, struct net_device *);
180extern void nr_destroy_socket(struct sock *); 189extern void nr_destroy_socket(struct sock *);
181 190
@@ -218,7 +227,28 @@ extern void nr_requeue_frames(struct sock *);
218extern int nr_validate_nr(struct sock *, unsigned short); 227extern int nr_validate_nr(struct sock *, unsigned short);
219extern int nr_in_rx_window(struct sock *, unsigned short); 228extern int nr_in_rx_window(struct sock *, unsigned short);
220extern void nr_write_internal(struct sock *, int); 229extern void nr_write_internal(struct sock *, int);
221extern void nr_transmit_refusal(struct sk_buff *, int); 230
231extern void __nr_transmit_reply(struct sk_buff *skb, int mine,
232 unsigned char cmdflags);
233
234/*
235 * This routine is called when a Connect Acknowledge with the Choke Flag
236 * set is needed to refuse a connection.
237 */
238#define nr_transmit_refusal(skb, mine) \
239do { \
240 __nr_transmit_reply((skb), (mine), NR_CONNACK | NR_CHOKE_FLAG); \
241} while (0)
242
243/*
244 * This routine is called when we don't have a circuit matching an incoming
245 * NET/ROM packet. This is an G8PZT Xrouter extension.
246 */
247#define nr_transmit_reset(skb, mine) \
248do { \
249 __nr_transmit_reply((skb), (mine), NR_RESET); \
250} while (0)
251
222extern void nr_disconnect(struct sock *, int); 252extern void nr_disconnect(struct sock *, int);
223 253
224/* nr_timer.c */ 254/* nr_timer.c */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index da63722c0123..c0e4c67d836f 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -178,8 +178,8 @@ static inline struct scsi_target *scsi_target(struct scsi_device *sdev)
178 178
179extern struct scsi_device *__scsi_add_device(struct Scsi_Host *, 179extern struct scsi_device *__scsi_add_device(struct Scsi_Host *,
180 uint, uint, uint, void *hostdata); 180 uint, uint, uint, void *hostdata);
181#define scsi_add_device(host, channel, target, lun) \ 181extern int scsi_add_device(struct Scsi_Host *host, uint channel,
182 __scsi_add_device(host, channel, target, lun, NULL) 182 uint target, uint lun);
183extern void scsi_remove_device(struct scsi_device *); 183extern void scsi_remove_device(struct scsi_device *);
184extern int scsi_device_cancel(struct scsi_device *, int); 184extern int scsi_device_cancel(struct scsi_device *, int);
185 185
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 70ad16315a16..115db056dc6b 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -439,4 +439,12 @@ int fc_remote_port_block(struct fc_rport *rport);
439void fc_remote_port_unblock(struct fc_rport *rport); 439void fc_remote_port_unblock(struct fc_rport *rport);
440int scsi_is_fc_rport(const struct device *); 440int scsi_is_fc_rport(const struct device *);
441 441
442static inline u64 wwn_to_u64(u8 *wwn)
443{
444 return (u64)wwn[0] << 56 | (u64)wwn[1] << 48 |
445 (u64)wwn[2] << 40 | (u64)wwn[3] << 32 |
446 (u64)wwn[4] << 24 | (u64)wwn[5] << 16 |
447 (u64)wwn[6] << 8 | (u64)wwn[7];
448}
449
442#endif /* SCSI_TRANSPORT_FC_H */ 450#endif /* SCSI_TRANSPORT_FC_H */
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
new file mode 100644
index 000000000000..bc4aeb660dd3
--- /dev/null
+++ b/include/scsi/scsi_transport_sas.h
@@ -0,0 +1,100 @@
1#ifndef SCSI_TRANSPORT_SAS_H
2#define SCSI_TRANSPORT_SAS_H
3
4#include <linux/transport_class.h>
5#include <linux/types.h>
6
7struct scsi_transport_template;
8struct sas_rphy;
9
10
11enum sas_device_type {
12 SAS_PHY_UNUSED,
13 SAS_END_DEVICE,
14 SAS_EDGE_EXPANDER_DEVICE,
15 SAS_FANOUT_EXPANDER_DEVICE,
16};
17
18enum sas_protocol {
19 SAS_PROTOCOL_SATA = 0x01,
20 SAS_PROTOCOL_SMP = 0x02,
21 SAS_PROTOCOL_STP = 0x04,
22 SAS_PROTOCOL_SSP = 0x08,
23};
24
25enum sas_linkrate {
26 SAS_LINK_RATE_UNKNOWN,
27 SAS_PHY_DISABLED,
28 SAS_LINK_RATE_FAILED,
29 SAS_SATA_SPINUP_HOLD,
30 SAS_SATA_PORT_SELECTOR,
31 SAS_LINK_RATE_1_5_GBPS,
32 SAS_LINK_RATE_3_0_GBPS,
33 SAS_LINK_VIRTUAL,
34};
35
36struct sas_identify {
37 enum sas_device_type device_type;
38 enum sas_protocol initiator_port_protocols;
39 enum sas_protocol target_port_protocols;
40 u64 sas_address;
41 u8 phy_identifier;
42};
43
44/* The functions by which the transport class and the driver communicate */
45struct sas_function_template {
46};
47
48struct sas_phy {
49 struct device dev;
50 int number;
51 struct sas_identify identify;
52 enum sas_linkrate negotiated_linkrate;
53 enum sas_linkrate minimum_linkrate_hw;
54 enum sas_linkrate minimum_linkrate;
55 enum sas_linkrate maximum_linkrate_hw;
56 enum sas_linkrate maximum_linkrate;
57 u8 port_identifier;
58 struct sas_rphy *rphy;
59};
60
61#define dev_to_phy(d) \
62 container_of((d), struct sas_phy, dev)
63#define transport_class_to_phy(cdev) \
64 dev_to_phy((cdev)->dev)
65#define phy_to_shost(phy) \
66 dev_to_shost((phy)->dev.parent)
67
68struct sas_rphy {
69 struct device dev;
70 struct sas_identify identify;
71 struct list_head list;
72 u32 scsi_target_id;
73};
74
75#define dev_to_rphy(d) \
76 container_of((d), struct sas_rphy, dev)
77#define transport_class_to_rphy(cdev) \
78 dev_to_rphy((cdev)->dev)
79#define rphy_to_shost(rphy) \
80 dev_to_shost((rphy)->dev.parent)
81
82extern void sas_remove_host(struct Scsi_Host *);
83
84extern struct sas_phy *sas_phy_alloc(struct device *, int);
85extern void sas_phy_free(struct sas_phy *);
86extern int sas_phy_add(struct sas_phy *);
87extern void sas_phy_delete(struct sas_phy *);
88extern int scsi_is_sas_phy(const struct device *);
89
90extern struct sas_rphy *sas_rphy_alloc(struct sas_phy *);
91void sas_rphy_free(struct sas_rphy *);
92extern int sas_rphy_add(struct sas_rphy *);
93extern void sas_rphy_delete(struct sas_rphy *);
94extern int scsi_is_sas_rphy(const struct device *);
95
96extern struct scsi_transport_template *
97sas_attach_transport(struct sas_function_template *);
98extern void sas_release_transport(struct scsi_transport_template *);
99
100#endif /* SCSI_TRANSPORT_SAS_H */
diff --git a/include/sound/core.h b/include/sound/core.h
index 3dc41fd5c54d..26160adcdffc 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -168,6 +168,9 @@ struct _snd_card {
168 wait_queue_head_t shutdown_sleep; 168 wait_queue_head_t shutdown_sleep;
169 struct work_struct free_workq; /* for free in workqueue */ 169 struct work_struct free_workq; /* for free in workqueue */
170 struct device *dev; 170 struct device *dev;
171#ifdef CONFIG_SND_GENERIC_DRIVER
172 struct snd_generic_device *generic_dev;
173#endif
171 174
172#ifdef CONFIG_PM 175#ifdef CONFIG_PM
173 int (*pm_suspend)(snd_card_t *card, pm_message_t state); 176 int (*pm_suspend)(snd_card_t *card, pm_message_t state);
@@ -176,9 +179,6 @@ struct _snd_card {
176 unsigned int power_state; /* power state */ 179 unsigned int power_state; /* power state */
177 struct semaphore power_lock; /* power lock */ 180 struct semaphore power_lock; /* power lock */
178 wait_queue_head_t power_sleep; 181 wait_queue_head_t power_sleep;
179#ifdef CONFIG_SND_GENERIC_PM
180 struct snd_generic_device *pm_dev; /* for ISA */
181#endif
182#endif 182#endif
183 183
184#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 184#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
@@ -348,6 +348,8 @@ int snd_card_file_remove(snd_card_t *card, struct file *file);
348#ifndef snd_card_set_dev 348#ifndef snd_card_set_dev
349#define snd_card_set_dev(card,devptr) ((card)->dev = (devptr)) 349#define snd_card_set_dev(card,devptr) ((card)->dev = (devptr))
350#endif 350#endif
351/* register a generic device (for ISA, etc) */
352int snd_card_set_generic_dev(snd_card_t *card);
351 353
352/* device.c */ 354/* device.c */
353 355
diff --git a/include/sound/cs46xx.h b/include/sound/cs46xx.h
index 9b94510eda60..b0c0e192eb56 100644
--- a/include/sound/cs46xx.h
+++ b/include/sound/cs46xx.h
@@ -29,19 +29,6 @@
29#include "ac97_codec.h" 29#include "ac97_codec.h"
30#include "cs46xx_dsp_spos.h" 30#include "cs46xx_dsp_spos.h"
31 31
32#ifndef PCI_VENDOR_ID_CIRRUS
33#define PCI_VENDOR_ID_CIRRUS 0x1013
34#endif
35#ifndef PCI_DEVICE_ID_CIRRUS_4610
36#define PCI_DEVICE_ID_CIRRUS_4610 0x6001
37#endif
38#ifndef PCI_DEVICE_ID_CIRRUS_4612
39#define PCI_DEVICE_ID_CIRRUS_4612 0x6003
40#endif
41#ifndef PCI_DEVICE_ID_CIRRUS_4615
42#define PCI_DEVICE_ID_CIRRUS_4615 0x6004
43#endif
44
45/* 32/*
46 * Direct registers 33 * Direct registers
47 */ 34 */
@@ -1715,7 +1702,6 @@ struct _snd_cs46xx {
1715 void (*active_ctrl)(cs46xx_t *, int); 1702 void (*active_ctrl)(cs46xx_t *, int);
1716 void (*mixer_init)(cs46xx_t *); 1703 void (*mixer_init)(cs46xx_t *);
1717 1704
1718 struct pci_dev *acpi_dev;
1719 int acpi_port; 1705 int acpi_port;
1720 snd_kcontrol_t *eapd_switch; /* for amplifier hack */ 1706 snd_kcontrol_t *eapd_switch; /* for amplifier hack */
1721 int accept_valid; /* accept mmap valid (for OSS) */ 1707 int accept_valid; /* accept mmap valid (for OSS) */
diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
index 4e3993dfcefe..67bf3f18e96a 100644
--- a/include/sound/emu10k1.h
+++ b/include/sound/emu10k1.h
@@ -35,13 +35,6 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <asm/io.h> 36#include <asm/io.h>
37 37
38#ifndef PCI_VENDOR_ID_CREATIVE
39#define PCI_VENDOR_ID_CREATIVE 0x1102
40#endif
41#ifndef PCI_DEVICE_ID_CREATIVE_EMU10K1
42#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002
43#endif
44
45/* ------------------- DEFINES -------------------- */ 38/* ------------------- DEFINES -------------------- */
46 39
47#define EMUPAGESIZE 4096 40#define EMUPAGESIZE 4096
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index d6361dab0370..2b23a5967071 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -903,13 +903,16 @@ int snd_pcm_format_unsigned(snd_pcm_format_t format);
903int snd_pcm_format_linear(snd_pcm_format_t format); 903int snd_pcm_format_linear(snd_pcm_format_t format);
904int snd_pcm_format_little_endian(snd_pcm_format_t format); 904int snd_pcm_format_little_endian(snd_pcm_format_t format);
905int snd_pcm_format_big_endian(snd_pcm_format_t format); 905int snd_pcm_format_big_endian(snd_pcm_format_t format);
906/* 906#if 0 /* just for DocBook */
907/**
907 * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian 908 * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian
908 * @format: the format to check 909 * @format: the format to check
909 * 910 *
910 * Returns 1 if the given PCM format is CPU-endian, 0 if 911 * Returns 1 if the given PCM format is CPU-endian, 0 if
911 * opposite, or a negative error code if endian not specified. 912 * opposite, or a negative error code if endian not specified.
912 */ 913 */
914int snd_pcm_format_cpu_endian(snd_pcm_format_t format);
915#endif /* DocBook */
913#ifdef SNDRV_LITTLE_ENDIAN 916#ifdef SNDRV_LITTLE_ENDIAN
914#define snd_pcm_format_cpu_endian(format) snd_pcm_format_little_endian(format) 917#define snd_pcm_format_cpu_endian(format) snd_pcm_format_little_endian(format)
915#else 918#else
diff --git a/include/sound/pcm_oss.h b/include/sound/pcm_oss.h
index 518728536bc6..0b67c9d105af 100644
--- a/include/sound/pcm_oss.h
+++ b/include/sound/pcm_oss.h
@@ -32,7 +32,8 @@ struct _snd_pcm_oss_setup {
32 block:1, 32 block:1,
33 nonblock:1, 33 nonblock:1,
34 partialfrag:1, 34 partialfrag:1,
35 nosilence:1; 35 nosilence:1,
36 buggyptr:1;
36 unsigned int periods; 37 unsigned int periods;
37 unsigned int period_size; 38 unsigned int period_size;
38 snd_pcm_oss_setup_t *next; 39 snd_pcm_oss_setup_t *next;
diff --git a/include/sound/trident.h b/include/sound/trident.h
index f5254ec36e6a..a408d3925050 100644
--- a/include/sound/trident.h
+++ b/include/sound/trident.h
@@ -33,23 +33,6 @@
33//#include "ainstr_gf1.h" 33//#include "ainstr_gf1.h"
34#include "ainstr_simple.h" 34#include "ainstr_simple.h"
35 35
36#ifndef PCI_VENDOR_ID_TRIDENT
37#define PCI_VENDOR_ID_TRIDENT 0x1023
38#endif
39#ifndef PCI_DEVICE_ID_TRIDENT_4DWAVE_DX
40#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000
41#endif
42#ifndef PCI_DEVICE_ID_TRIDENT_4DWAVE_NX
43#define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001
44#endif
45
46#ifndef PCI_VENDOR_ID_SI
47#define PCI_VENDOR_ID_SI 0x1039
48#endif
49#ifndef PCI_DEVICE_ID_SI_7018
50#define PCI_DEVICE_ID_SI_7018 0x7018
51#endif
52
53#define TRIDENT_DEVICE_ID_DX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_DX) 36#define TRIDENT_DEVICE_ID_DX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_DX)
54#define TRIDENT_DEVICE_ID_NX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_NX) 37#define TRIDENT_DEVICE_ID_NX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_NX)
55#define TRIDENT_DEVICE_ID_SI7018 ((PCI_VENDOR_ID_SI<<16)|PCI_DEVICE_ID_SI_7018) 38#define TRIDENT_DEVICE_ID_SI7018 ((PCI_VENDOR_ID_SI<<16)|PCI_DEVICE_ID_SI_7018)
diff --git a/include/sound/version.h b/include/sound/version.h
index 8d19bfabb7e0..ee32af20dba9 100644
--- a/include/sound/version.h
+++ b/include/sound/version.h
@@ -1,3 +1,3 @@
1/* include/version.h. Generated by configure. */ 1/* include/version.h. Generated by configure. */
2#define CONFIG_SND_VERSION "1.0.10rc1" 2#define CONFIG_SND_VERSION "1.0.10rc1"
3#define CONFIG_SND_DATE " (Tue Aug 30 05:31:08 2005 UTC)" 3#define CONFIG_SND_DATE " (Mon Sep 12 08:13:09 2005 UTC)"
diff --git a/include/sound/ymfpci.h b/include/sound/ymfpci.h
index 9a3c1e6c820a..c3bccbfd8d4c 100644
--- a/include/sound/ymfpci.h
+++ b/include/sound/ymfpci.h
@@ -28,28 +28,6 @@
28#include "timer.h" 28#include "timer.h"
29#include <linux/gameport.h> 29#include <linux/gameport.h>
30 30
31#ifndef PCI_VENDOR_ID_YAMAHA
32#define PCI_VENDOR_ID_YAMAHA 0x1073
33#endif
34#ifndef PCI_DEVICE_ID_YAMAHA_724
35#define PCI_DEVICE_ID_YAMAHA_724 0x0004
36#endif
37#ifndef PCI_DEVICE_ID_YAMAHA_724F
38#define PCI_DEVICE_ID_YAMAHA_724F 0x000d
39#endif
40#ifndef PCI_DEVICE_ID_YAMAHA_740
41#define PCI_DEVICE_ID_YAMAHA_740 0x000a
42#endif
43#ifndef PCI_DEVICE_ID_YAMAHA_740C
44#define PCI_DEVICE_ID_YAMAHA_740C 0x000c
45#endif
46#ifndef PCI_DEVICE_ID_YAMAHA_744
47#define PCI_DEVICE_ID_YAMAHA_744 0x0010
48#endif
49#ifndef PCI_DEVICE_ID_YAMAHA_754
50#define PCI_DEVICE_ID_YAMAHA_754 0x0012
51#endif
52
53/* 31/*
54 * Direct registers 32 * Direct registers
55 */ 33 */
diff --git a/include/video/pm3fb.h b/include/video/pm3fb.h
index 8d3cef5d87a2..6f4ea808cf74 100644
--- a/include/video/pm3fb.h
+++ b/include/video/pm3fb.h
@@ -1142,9 +1142,6 @@
1142/* do we want accelerated console */ 1142/* do we want accelerated console */
1143#define PM3FB_USE_ACCEL 1 1143#define PM3FB_USE_ACCEL 1
1144 1144
1145/* useful ? */
1146#define CHAR_IS_NUM(a) ((((a) >= '0') && ((a) <= '9')) ? 1 : 0)
1147
1148/* for driver debugging ONLY */ 1145/* for driver debugging ONLY */
1149/* 0 = assert only, 1 = error, 2 = info, 3+ = verbose */ 1146/* 0 = assert only, 1 = error, 2 = info, 3+ = verbose */
1150/* define PM3FB_MASTER_DEBUG 1 */ 1147/* define PM3FB_MASTER_DEBUG 1 */
diff --git a/include/video/w100fb.h b/include/video/w100fb.h
index e6da2d7ded8c..677d40326796 100644
--- a/include/video/w100fb.h
+++ b/include/video/w100fb.h
@@ -19,6 +19,7 @@ struct w100fb_par;
19 19
20unsigned long w100fb_gpio_read(int port); 20unsigned long w100fb_gpio_read(int port);
21void w100fb_gpio_write(int port, unsigned long value); 21void w100fb_gpio_write(int port, unsigned long value);
22unsigned long w100fb_get_hsynclen(struct device *dev);
22 23
23/* LCD Specific Routines and Config */ 24/* LCD Specific Routines and Config */
24struct w100_tg_info { 25struct w100_tg_info {
diff --git a/init/initramfs.c b/init/initramfs.c
index 02c5ce64990d..0c5d9a3f951b 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -466,6 +466,14 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
466extern char __initramfs_start[], __initramfs_end[]; 466extern char __initramfs_start[], __initramfs_end[];
467#ifdef CONFIG_BLK_DEV_INITRD 467#ifdef CONFIG_BLK_DEV_INITRD
468#include <linux/initrd.h> 468#include <linux/initrd.h>
469
470static void __init free_initrd(void)
471{
472 free_initrd_mem(initrd_start, initrd_end);
473 initrd_start = 0;
474 initrd_end = 0;
475}
476
469#endif 477#endif
470 478
471void __init populate_rootfs(void) 479void __init populate_rootfs(void)
@@ -484,7 +492,7 @@ void __init populate_rootfs(void)
484 printk(" it is\n"); 492 printk(" it is\n");
485 unpack_to_rootfs((char *)initrd_start, 493 unpack_to_rootfs((char *)initrd_start,
486 initrd_end - initrd_start, 0); 494 initrd_end - initrd_start, 0);
487 free_initrd_mem(initrd_start, initrd_end); 495 free_initrd();
488 return; 496 return;
489 } 497 }
490 printk("it isn't (%s); looks like an initrd\n", err); 498 printk("it isn't (%s); looks like an initrd\n", err);
@@ -493,7 +501,7 @@ void __init populate_rootfs(void)
493 sys_write(fd, (char *)initrd_start, 501 sys_write(fd, (char *)initrd_start,
494 initrd_end - initrd_start); 502 initrd_end - initrd_start);
495 sys_close(fd); 503 sys_close(fd);
496 free_initrd_mem(initrd_start, initrd_end); 504 free_initrd();
497 } 505 }
498 } 506 }
499#endif 507#endif
diff --git a/kernel/audit.c b/kernel/audit.c
index 7f0699790d46..83096b67510a 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -79,6 +79,8 @@ static int audit_rate_limit;
79 79
80/* Number of outstanding audit_buffers allowed. */ 80/* Number of outstanding audit_buffers allowed. */
81static int audit_backlog_limit = 64; 81static int audit_backlog_limit = 64;
82static int audit_backlog_wait_time = 60 * HZ;
83static int audit_backlog_wait_overflow = 0;
82 84
83/* The identity of the user shutting down the audit system. */ 85/* The identity of the user shutting down the audit system. */
84uid_t audit_sig_uid = -1; 86uid_t audit_sig_uid = -1;
@@ -106,18 +108,12 @@ static LIST_HEAD(audit_freelist);
106static struct sk_buff_head audit_skb_queue; 108static struct sk_buff_head audit_skb_queue;
107static struct task_struct *kauditd_task; 109static struct task_struct *kauditd_task;
108static DECLARE_WAIT_QUEUE_HEAD(kauditd_wait); 110static DECLARE_WAIT_QUEUE_HEAD(kauditd_wait);
109 111static DECLARE_WAIT_QUEUE_HEAD(audit_backlog_wait);
110/* There are three lists of rules -- one to search at task creation
111 * time, one to search at syscall entry time, and another to search at
112 * syscall exit time. */
113static LIST_HEAD(audit_tsklist);
114static LIST_HEAD(audit_entlist);
115static LIST_HEAD(audit_extlist);
116 112
117/* The netlink socket is only to be read by 1 CPU, which lets us assume 113/* The netlink socket is only to be read by 1 CPU, which lets us assume
118 * that list additions and deletions never happen simultaneously in 114 * that list additions and deletions never happen simultaneously in
119 * auditsc.c */ 115 * auditsc.c */
120static DECLARE_MUTEX(audit_netlink_sem); 116DECLARE_MUTEX(audit_netlink_sem);
121 117
122/* AUDIT_BUFSIZ is the size of the temporary buffer used for formatting 118/* AUDIT_BUFSIZ is the size of the temporary buffer used for formatting
123 * audit records. Since printk uses a 1024 byte buffer, this buffer 119 * audit records. Since printk uses a 1024 byte buffer, this buffer
@@ -137,6 +133,7 @@ struct audit_buffer {
137 struct list_head list; 133 struct list_head list;
138 struct sk_buff *skb; /* formatted skb ready to send */ 134 struct sk_buff *skb; /* formatted skb ready to send */
139 struct audit_context *ctx; /* NULL or associated context */ 135 struct audit_context *ctx; /* NULL or associated context */
136 int gfp_mask;
140}; 137};
141 138
142static void audit_set_pid(struct audit_buffer *ab, pid_t pid) 139static void audit_set_pid(struct audit_buffer *ab, pid_t pid)
@@ -145,11 +142,6 @@ static void audit_set_pid(struct audit_buffer *ab, pid_t pid)
145 nlh->nlmsg_pid = pid; 142 nlh->nlmsg_pid = pid;
146} 143}
147 144
148struct audit_entry {
149 struct list_head list;
150 struct audit_rule rule;
151};
152
153static void audit_panic(const char *message) 145static void audit_panic(const char *message)
154{ 146{
155 switch (audit_failure) 147 switch (audit_failure)
@@ -233,7 +225,7 @@ static int audit_set_rate_limit(int limit, uid_t loginuid)
233{ 225{
234 int old = audit_rate_limit; 226 int old = audit_rate_limit;
235 audit_rate_limit = limit; 227 audit_rate_limit = limit;
236 audit_log(NULL, AUDIT_CONFIG_CHANGE, 228 audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE,
237 "audit_rate_limit=%d old=%d by auid=%u", 229 "audit_rate_limit=%d old=%d by auid=%u",
238 audit_rate_limit, old, loginuid); 230 audit_rate_limit, old, loginuid);
239 return old; 231 return old;
@@ -243,7 +235,7 @@ static int audit_set_backlog_limit(int limit, uid_t loginuid)
243{ 235{
244 int old = audit_backlog_limit; 236 int old = audit_backlog_limit;
245 audit_backlog_limit = limit; 237 audit_backlog_limit = limit;
246 audit_log(NULL, AUDIT_CONFIG_CHANGE, 238 audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE,
247 "audit_backlog_limit=%d old=%d by auid=%u", 239 "audit_backlog_limit=%d old=%d by auid=%u",
248 audit_backlog_limit, old, loginuid); 240 audit_backlog_limit, old, loginuid);
249 return old; 241 return old;
@@ -255,7 +247,7 @@ static int audit_set_enabled(int state, uid_t loginuid)
255 if (state != 0 && state != 1) 247 if (state != 0 && state != 1)
256 return -EINVAL; 248 return -EINVAL;
257 audit_enabled = state; 249 audit_enabled = state;
258 audit_log(NULL, AUDIT_CONFIG_CHANGE, 250 audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE,
259 "audit_enabled=%d old=%d by auid=%u", 251 "audit_enabled=%d old=%d by auid=%u",
260 audit_enabled, old, loginuid); 252 audit_enabled, old, loginuid);
261 return old; 253 return old;
@@ -269,7 +261,7 @@ static int audit_set_failure(int state, uid_t loginuid)
269 && state != AUDIT_FAIL_PANIC) 261 && state != AUDIT_FAIL_PANIC)
270 return -EINVAL; 262 return -EINVAL;
271 audit_failure = state; 263 audit_failure = state;
272 audit_log(NULL, AUDIT_CONFIG_CHANGE, 264 audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE,
273 "audit_failure=%d old=%d by auid=%u", 265 "audit_failure=%d old=%d by auid=%u",
274 audit_failure, old, loginuid); 266 audit_failure, old, loginuid);
275 return old; 267 return old;
@@ -281,6 +273,7 @@ int kauditd_thread(void *dummy)
281 273
282 while (1) { 274 while (1) {
283 skb = skb_dequeue(&audit_skb_queue); 275 skb = skb_dequeue(&audit_skb_queue);
276 wake_up(&audit_backlog_wait);
284 if (skb) { 277 if (skb) {
285 if (audit_pid) { 278 if (audit_pid) {
286 int err = netlink_unicast(audit_sock, skb, audit_pid, 0); 279 int err = netlink_unicast(audit_sock, skb, audit_pid, 0);
@@ -290,7 +283,7 @@ int kauditd_thread(void *dummy)
290 audit_pid = 0; 283 audit_pid = 0;
291 } 284 }
292 } else { 285 } else {
293 printk(KERN_ERR "%s\n", skb->data + NLMSG_SPACE(0)); 286 printk(KERN_NOTICE "%s\n", skb->data + NLMSG_SPACE(0));
294 kfree_skb(skb); 287 kfree_skb(skb);
295 } 288 }
296 } else { 289 } else {
@@ -423,7 +416,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
423 if (status_get->mask & AUDIT_STATUS_PID) { 416 if (status_get->mask & AUDIT_STATUS_PID) {
424 int old = audit_pid; 417 int old = audit_pid;
425 audit_pid = status_get->pid; 418 audit_pid = status_get->pid;
426 audit_log(NULL, AUDIT_CONFIG_CHANGE, 419 audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE,
427 "audit_pid=%d old=%d by auid=%u", 420 "audit_pid=%d old=%d by auid=%u",
428 audit_pid, old, loginuid); 421 audit_pid, old, loginuid);
429 } 422 }
@@ -435,15 +428,21 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
435 break; 428 break;
436 case AUDIT_USER: 429 case AUDIT_USER:
437 case AUDIT_FIRST_USER_MSG...AUDIT_LAST_USER_MSG: 430 case AUDIT_FIRST_USER_MSG...AUDIT_LAST_USER_MSG:
438 ab = audit_log_start(NULL, msg_type); 431 if (!audit_enabled && msg_type != AUDIT_USER_AVC)
439 if (!ab) 432 return 0;
440 break; /* audit_panic has been called */ 433
441 audit_log_format(ab, 434 err = audit_filter_user(&NETLINK_CB(skb), msg_type);
442 "user pid=%d uid=%u auid=%u" 435 if (err == 1) {
443 " msg='%.1024s'", 436 err = 0;
444 pid, uid, loginuid, (char *)data); 437 ab = audit_log_start(NULL, GFP_KERNEL, msg_type);
445 audit_set_pid(ab, pid); 438 if (ab) {
446 audit_log_end(ab); 439 audit_log_format(ab,
440 "user pid=%d uid=%u auid=%u msg='%.1024s'",
441 pid, uid, loginuid, (char *)data);
442 audit_set_pid(ab, pid);
443 audit_log_end(ab);
444 }
445 }
447 break; 446 break;
448 case AUDIT_ADD: 447 case AUDIT_ADD:
449 case AUDIT_DEL: 448 case AUDIT_DEL:
@@ -523,7 +522,7 @@ static int __init audit_init(void)
523 skb_queue_head_init(&audit_skb_queue); 522 skb_queue_head_init(&audit_skb_queue);
524 audit_initialized = 1; 523 audit_initialized = 1;
525 audit_enabled = audit_default; 524 audit_enabled = audit_default;
526 audit_log(NULL, AUDIT_KERNEL, "initialized"); 525 audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL, "initialized");
527 return 0; 526 return 0;
528} 527}
529__initcall(audit_init); 528__initcall(audit_init);
@@ -561,7 +560,7 @@ static void audit_buffer_free(struct audit_buffer *ab)
561} 560}
562 561
563static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx, 562static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx,
564 int gfp_mask, int type) 563 unsigned int __nocast gfp_mask, int type)
565{ 564{
566 unsigned long flags; 565 unsigned long flags;
567 struct audit_buffer *ab = NULL; 566 struct audit_buffer *ab = NULL;
@@ -587,6 +586,7 @@ static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx,
587 goto err; 586 goto err;
588 587
589 ab->ctx = ctx; 588 ab->ctx = ctx;
589 ab->gfp_mask = gfp_mask;
590 nlh = (struct nlmsghdr *)skb_put(ab->skb, NLMSG_SPACE(0)); 590 nlh = (struct nlmsghdr *)skb_put(ab->skb, NLMSG_SPACE(0));
591 nlh->nlmsg_type = type; 591 nlh->nlmsg_type = type;
592 nlh->nlmsg_flags = 0; 592 nlh->nlmsg_flags = 0;
@@ -606,26 +606,27 @@ err:
606 * (timestamp,serial) tuple is unique for each syscall and is live from 606 * (timestamp,serial) tuple is unique for each syscall and is live from
607 * syscall entry to syscall exit. 607 * syscall entry to syscall exit.
608 * 608 *
609 * Atomic values are only guaranteed to be 24-bit, so we count down.
610 *
611 * NOTE: Another possibility is to store the formatted records off the 609 * NOTE: Another possibility is to store the formatted records off the
612 * audit context (for those records that have a context), and emit them 610 * audit context (for those records that have a context), and emit them
613 * all at syscall exit. However, this could delay the reporting of 611 * all at syscall exit. However, this could delay the reporting of
614 * significant errors until syscall exit (or never, if the system 612 * significant errors until syscall exit (or never, if the system
615 * halts). */ 613 * halts). */
614
616unsigned int audit_serial(void) 615unsigned int audit_serial(void)
617{ 616{
618 static atomic_t serial = ATOMIC_INIT(0xffffff); 617 static spinlock_t serial_lock = SPIN_LOCK_UNLOCKED;
619 unsigned int a, b; 618 static unsigned int serial = 0;
619
620 unsigned long flags;
621 unsigned int ret;
620 622
623 spin_lock_irqsave(&serial_lock, flags);
621 do { 624 do {
622 a = atomic_read(&serial); 625 ret = ++serial;
623 if (atomic_dec_and_test(&serial)) 626 } while (unlikely(!ret));
624 atomic_set(&serial, 0xffffff); 627 spin_unlock_irqrestore(&serial_lock, flags);
625 b = atomic_read(&serial);
626 } while (b != a - 1);
627 628
628 return 0xffffff - b; 629 return ret;
629} 630}
630 631
631static inline void audit_get_stamp(struct audit_context *ctx, 632static inline void audit_get_stamp(struct audit_context *ctx,
@@ -645,17 +646,43 @@ static inline void audit_get_stamp(struct audit_context *ctx,
645 * syscall, then the syscall is marked as auditable and an audit record 646 * syscall, then the syscall is marked as auditable and an audit record
646 * will be written at syscall exit. If there is no associated task, tsk 647 * will be written at syscall exit. If there is no associated task, tsk
647 * should be NULL. */ 648 * should be NULL. */
648struct audit_buffer *audit_log_start(struct audit_context *ctx, int type) 649
650struct audit_buffer *audit_log_start(struct audit_context *ctx, int gfp_mask,
651 int type)
649{ 652{
650 struct audit_buffer *ab = NULL; 653 struct audit_buffer *ab = NULL;
651 struct timespec t; 654 struct timespec t;
652 unsigned int serial; 655 unsigned int serial;
656 int reserve;
657 unsigned long timeout_start = jiffies;
653 658
654 if (!audit_initialized) 659 if (!audit_initialized)
655 return NULL; 660 return NULL;
656 661
657 if (audit_backlog_limit 662 if (gfp_mask & __GFP_WAIT)
658 && skb_queue_len(&audit_skb_queue) > audit_backlog_limit) { 663 reserve = 0;
664 else
665 reserve = 5; /* Allow atomic callers to go up to five
666 entries over the normal backlog limit */
667
668 while (audit_backlog_limit
669 && skb_queue_len(&audit_skb_queue) > audit_backlog_limit + reserve) {
670 if (gfp_mask & __GFP_WAIT && audit_backlog_wait_time
671 && time_before(jiffies, timeout_start + audit_backlog_wait_time)) {
672
673 /* Wait for auditd to drain the queue a little */
674 DECLARE_WAITQUEUE(wait, current);
675 set_current_state(TASK_INTERRUPTIBLE);
676 add_wait_queue(&audit_backlog_wait, &wait);
677
678 if (audit_backlog_limit &&
679 skb_queue_len(&audit_skb_queue) > audit_backlog_limit)
680 schedule_timeout(timeout_start + audit_backlog_wait_time - jiffies);
681
682 __set_current_state(TASK_RUNNING);
683 remove_wait_queue(&audit_backlog_wait, &wait);
684 continue;
685 }
659 if (audit_rate_check()) 686 if (audit_rate_check())
660 printk(KERN_WARNING 687 printk(KERN_WARNING
661 "audit: audit_backlog=%d > " 688 "audit: audit_backlog=%d > "
@@ -663,10 +690,12 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, int type)
663 skb_queue_len(&audit_skb_queue), 690 skb_queue_len(&audit_skb_queue),
664 audit_backlog_limit); 691 audit_backlog_limit);
665 audit_log_lost("backlog limit exceeded"); 692 audit_log_lost("backlog limit exceeded");
693 audit_backlog_wait_time = audit_backlog_wait_overflow;
694 wake_up(&audit_backlog_wait);
666 return NULL; 695 return NULL;
667 } 696 }
668 697
669 ab = audit_buffer_alloc(ctx, GFP_ATOMIC, type); 698 ab = audit_buffer_alloc(ctx, gfp_mask, type);
670 if (!ab) { 699 if (!ab) {
671 audit_log_lost("out of memory in audit_log_start"); 700 audit_log_lost("out of memory in audit_log_start");
672 return NULL; 701 return NULL;
@@ -690,7 +719,7 @@ static inline int audit_expand(struct audit_buffer *ab, int extra)
690{ 719{
691 struct sk_buff *skb = ab->skb; 720 struct sk_buff *skb = ab->skb;
692 int ret = pskb_expand_head(skb, skb_headroom(skb), extra, 721 int ret = pskb_expand_head(skb, skb_headroom(skb), extra,
693 GFP_ATOMIC); 722 ab->gfp_mask);
694 if (ret < 0) { 723 if (ret < 0) {
695 audit_log_lost("out of memory in audit_expand"); 724 audit_log_lost("out of memory in audit_expand");
696 return 0; 725 return 0;
@@ -809,7 +838,7 @@ void audit_log_d_path(struct audit_buffer *ab, const char *prefix,
809 audit_log_format(ab, " %s", prefix); 838 audit_log_format(ab, " %s", prefix);
810 839
811 /* We will allow 11 spaces for ' (deleted)' to be appended */ 840 /* We will allow 11 spaces for ' (deleted)' to be appended */
812 path = kmalloc(PATH_MAX+11, GFP_KERNEL); 841 path = kmalloc(PATH_MAX+11, ab->gfp_mask);
813 if (!path) { 842 if (!path) {
814 audit_log_format(ab, "<no memory>"); 843 audit_log_format(ab, "<no memory>");
815 return; 844 return;
@@ -841,7 +870,7 @@ void audit_log_end(struct audit_buffer *ab)
841 ab->skb = NULL; 870 ab->skb = NULL;
842 wake_up_interruptible(&kauditd_wait); 871 wake_up_interruptible(&kauditd_wait);
843 } else { 872 } else {
844 printk("%s\n", ab->skb->data + NLMSG_SPACE(0)); 873 printk(KERN_NOTICE "%s\n", ab->skb->data + NLMSG_SPACE(0));
845 } 874 }
846 } 875 }
847 audit_buffer_free(ab); 876 audit_buffer_free(ab);
@@ -850,12 +879,13 @@ void audit_log_end(struct audit_buffer *ab)
850/* Log an audit record. This is a convenience function that calls 879/* Log an audit record. This is a convenience function that calls
851 * audit_log_start, audit_log_vformat, and audit_log_end. It may be 880 * audit_log_start, audit_log_vformat, and audit_log_end. It may be
852 * called in any context. */ 881 * called in any context. */
853void audit_log(struct audit_context *ctx, int type, const char *fmt, ...) 882void audit_log(struct audit_context *ctx, int gfp_mask, int type,
883 const char *fmt, ...)
854{ 884{
855 struct audit_buffer *ab; 885 struct audit_buffer *ab;
856 va_list args; 886 va_list args;
857 887
858 ab = audit_log_start(ctx, type); 888 ab = audit_log_start(ctx, gfp_mask, type);
859 if (ab) { 889 if (ab) {
860 va_start(args, fmt); 890 va_start(args, fmt);
861 audit_log_vformat(ab, fmt, args); 891 audit_log_vformat(ab, fmt, args);
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index e75f84e1a1a0..88696f639aab 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -39,6 +39,9 @@
39#include <linux/audit.h> 39#include <linux/audit.h>
40#include <linux/personality.h> 40#include <linux/personality.h>
41#include <linux/time.h> 41#include <linux/time.h>
42#include <linux/kthread.h>
43#include <linux/netlink.h>
44#include <linux/compiler.h>
42#include <asm/unistd.h> 45#include <asm/unistd.h>
43 46
44/* 0 = no checking 47/* 0 = no checking
@@ -95,6 +98,7 @@ struct audit_names {
95 uid_t uid; 98 uid_t uid;
96 gid_t gid; 99 gid_t gid;
97 dev_t rdev; 100 dev_t rdev;
101 unsigned flags;
98}; 102};
99 103
100struct audit_aux_data { 104struct audit_aux_data {
@@ -167,9 +171,16 @@ struct audit_context {
167/* There are three lists of rules -- one to search at task creation 171/* There are three lists of rules -- one to search at task creation
168 * time, one to search at syscall entry time, and another to search at 172 * time, one to search at syscall entry time, and another to search at
169 * syscall exit time. */ 173 * syscall exit time. */
170static LIST_HEAD(audit_tsklist); 174static struct list_head audit_filter_list[AUDIT_NR_FILTERS] = {
171static LIST_HEAD(audit_entlist); 175 LIST_HEAD_INIT(audit_filter_list[0]),
172static LIST_HEAD(audit_extlist); 176 LIST_HEAD_INIT(audit_filter_list[1]),
177 LIST_HEAD_INIT(audit_filter_list[2]),
178 LIST_HEAD_INIT(audit_filter_list[3]),
179 LIST_HEAD_INIT(audit_filter_list[4]),
180#if AUDIT_NR_FILTERS != 5
181#error Fix audit_filter_list initialiser
182#endif
183};
173 184
174struct audit_entry { 185struct audit_entry {
175 struct list_head list; 186 struct list_head list;
@@ -179,9 +190,36 @@ struct audit_entry {
179 190
180extern int audit_pid; 191extern int audit_pid;
181 192
193/* Copy rule from user-space to kernel-space. Called from
194 * audit_add_rule during AUDIT_ADD. */
195static inline int audit_copy_rule(struct audit_rule *d, struct audit_rule *s)
196{
197 int i;
198
199 if (s->action != AUDIT_NEVER
200 && s->action != AUDIT_POSSIBLE
201 && s->action != AUDIT_ALWAYS)
202 return -1;
203 if (s->field_count < 0 || s->field_count > AUDIT_MAX_FIELDS)
204 return -1;
205 if ((s->flags & ~AUDIT_FILTER_PREPEND) >= AUDIT_NR_FILTERS)
206 return -1;
207
208 d->flags = s->flags;
209 d->action = s->action;
210 d->field_count = s->field_count;
211 for (i = 0; i < d->field_count; i++) {
212 d->fields[i] = s->fields[i];
213 d->values[i] = s->values[i];
214 }
215 for (i = 0; i < AUDIT_BITMASK_SIZE; i++) d->mask[i] = s->mask[i];
216 return 0;
217}
218
182/* Check to see if two rules are identical. It is called from 219/* Check to see if two rules are identical. It is called from
220 * audit_add_rule during AUDIT_ADD and
183 * audit_del_rule during AUDIT_DEL. */ 221 * audit_del_rule during AUDIT_DEL. */
184static int audit_compare_rule(struct audit_rule *a, struct audit_rule *b) 222static inline int audit_compare_rule(struct audit_rule *a, struct audit_rule *b)
185{ 223{
186 int i; 224 int i;
187 225
@@ -210,19 +248,37 @@ static int audit_compare_rule(struct audit_rule *a, struct audit_rule *b)
210/* Note that audit_add_rule and audit_del_rule are called via 248/* Note that audit_add_rule and audit_del_rule are called via
211 * audit_receive() in audit.c, and are protected by 249 * audit_receive() in audit.c, and are protected by
212 * audit_netlink_sem. */ 250 * audit_netlink_sem. */
213static inline int audit_add_rule(struct audit_entry *entry, 251static inline int audit_add_rule(struct audit_rule *rule,
214 struct list_head *list) 252 struct list_head *list)
215{ 253{
216 if (entry->rule.flags & AUDIT_PREPEND) { 254 struct audit_entry *entry;
217 entry->rule.flags &= ~AUDIT_PREPEND; 255
256 /* Do not use the _rcu iterator here, since this is the only
257 * addition routine. */
258 list_for_each_entry(entry, list, list) {
259 if (!audit_compare_rule(rule, &entry->rule)) {
260 return -EEXIST;
261 }
262 }
263
264 if (!(entry = kmalloc(sizeof(*entry), GFP_KERNEL)))
265 return -ENOMEM;
266 if (audit_copy_rule(&entry->rule, rule)) {
267 kfree(entry);
268 return -EINVAL;
269 }
270
271 if (entry->rule.flags & AUDIT_FILTER_PREPEND) {
272 entry->rule.flags &= ~AUDIT_FILTER_PREPEND;
218 list_add_rcu(&entry->list, list); 273 list_add_rcu(&entry->list, list);
219 } else { 274 } else {
220 list_add_tail_rcu(&entry->list, list); 275 list_add_tail_rcu(&entry->list, list);
221 } 276 }
277
222 return 0; 278 return 0;
223} 279}
224 280
225static void audit_free_rule(struct rcu_head *head) 281static inline void audit_free_rule(struct rcu_head *head)
226{ 282{
227 struct audit_entry *e = container_of(head, struct audit_entry, rcu); 283 struct audit_entry *e = container_of(head, struct audit_entry, rcu);
228 kfree(e); 284 kfree(e);
@@ -245,82 +301,82 @@ static inline int audit_del_rule(struct audit_rule *rule,
245 return 0; 301 return 0;
246 } 302 }
247 } 303 }
248 return -EFAULT; /* No matching rule */ 304 return -ENOENT; /* No matching rule */
249} 305}
250 306
251/* Copy rule from user-space to kernel-space. Called during 307static int audit_list_rules(void *_dest)
252 * AUDIT_ADD. */
253static int audit_copy_rule(struct audit_rule *d, struct audit_rule *s)
254{ 308{
309 int pid, seq;
310 int *dest = _dest;
311 struct audit_entry *entry;
255 int i; 312 int i;
256 313
257 if (s->action != AUDIT_NEVER 314 pid = dest[0];
258 && s->action != AUDIT_POSSIBLE 315 seq = dest[1];
259 && s->action != AUDIT_ALWAYS) 316 kfree(dest);
260 return -1;
261 if (s->field_count < 0 || s->field_count > AUDIT_MAX_FIELDS)
262 return -1;
263 317
264 d->flags = s->flags; 318 down(&audit_netlink_sem);
265 d->action = s->action; 319
266 d->field_count = s->field_count; 320 /* The *_rcu iterators not needed here because we are
267 for (i = 0; i < d->field_count; i++) { 321 always called with audit_netlink_sem held. */
268 d->fields[i] = s->fields[i]; 322 for (i=0; i<AUDIT_NR_FILTERS; i++) {
269 d->values[i] = s->values[i]; 323 list_for_each_entry(entry, &audit_filter_list[i], list)
324 audit_send_reply(pid, seq, AUDIT_LIST, 0, 1,
325 &entry->rule, sizeof(entry->rule));
270 } 326 }
271 for (i = 0; i < AUDIT_BITMASK_SIZE; i++) d->mask[i] = s->mask[i]; 327 audit_send_reply(pid, seq, AUDIT_LIST, 1, 1, NULL, 0);
328
329 up(&audit_netlink_sem);
272 return 0; 330 return 0;
273} 331}
274 332
275int audit_receive_filter(int type, int pid, int uid, int seq, void *data, 333int audit_receive_filter(int type, int pid, int uid, int seq, void *data,
276 uid_t loginuid) 334 uid_t loginuid)
277{ 335{
278 u32 flags; 336 struct task_struct *tsk;
279 struct audit_entry *entry; 337 int *dest;
280 int err = 0; 338 int err = 0;
339 unsigned listnr;
281 340
282 switch (type) { 341 switch (type) {
283 case AUDIT_LIST: 342 case AUDIT_LIST:
284 /* The *_rcu iterators not needed here because we are 343 /* We can't just spew out the rules here because we might fill
285 always called with audit_netlink_sem held. */ 344 * the available socket buffer space and deadlock waiting for
286 list_for_each_entry(entry, &audit_tsklist, list) 345 * auditctl to read from it... which isn't ever going to
287 audit_send_reply(pid, seq, AUDIT_LIST, 0, 1, 346 * happen if we're actually running in the context of auditctl
288 &entry->rule, sizeof(entry->rule)); 347 * trying to _send_ the stuff */
289 list_for_each_entry(entry, &audit_entlist, list) 348
290 audit_send_reply(pid, seq, AUDIT_LIST, 0, 1, 349 dest = kmalloc(2 * sizeof(int), GFP_KERNEL);
291 &entry->rule, sizeof(entry->rule)); 350 if (!dest)
292 list_for_each_entry(entry, &audit_extlist, list) 351 return -ENOMEM;
293 audit_send_reply(pid, seq, AUDIT_LIST, 0, 1, 352 dest[0] = pid;
294 &entry->rule, sizeof(entry->rule)); 353 dest[1] = seq;
295 audit_send_reply(pid, seq, AUDIT_LIST, 1, 1, NULL, 0); 354
355 tsk = kthread_run(audit_list_rules, dest, "audit_list_rules");
356 if (IS_ERR(tsk)) {
357 kfree(dest);
358 err = PTR_ERR(tsk);
359 }
296 break; 360 break;
297 case AUDIT_ADD: 361 case AUDIT_ADD:
298 if (!(entry = kmalloc(sizeof(*entry), GFP_KERNEL))) 362 listnr =((struct audit_rule *)data)->flags & ~AUDIT_FILTER_PREPEND;
299 return -ENOMEM; 363 if (listnr >= AUDIT_NR_FILTERS)
300 if (audit_copy_rule(&entry->rule, data)) {
301 kfree(entry);
302 return -EINVAL; 364 return -EINVAL;
303 } 365
304 flags = entry->rule.flags; 366 err = audit_add_rule(data, &audit_filter_list[listnr]);
305 if (!err && (flags & AUDIT_PER_TASK)) 367 if (!err)
306 err = audit_add_rule(entry, &audit_tsklist); 368 audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE,
307 if (!err && (flags & AUDIT_AT_ENTRY)) 369 "auid=%u added an audit rule\n", loginuid);
308 err = audit_add_rule(entry, &audit_entlist);
309 if (!err && (flags & AUDIT_AT_EXIT))
310 err = audit_add_rule(entry, &audit_extlist);
311 audit_log(NULL, AUDIT_CONFIG_CHANGE,
312 "auid=%u added an audit rule\n", loginuid);
313 break; 370 break;
314 case AUDIT_DEL: 371 case AUDIT_DEL:
315 flags =((struct audit_rule *)data)->flags; 372 listnr =((struct audit_rule *)data)->flags & ~AUDIT_FILTER_PREPEND;
316 if (!err && (flags & AUDIT_PER_TASK)) 373 if (listnr >= AUDIT_NR_FILTERS)
317 err = audit_del_rule(data, &audit_tsklist); 374 return -EINVAL;
318 if (!err && (flags & AUDIT_AT_ENTRY)) 375
319 err = audit_del_rule(data, &audit_entlist); 376 err = audit_del_rule(data, &audit_filter_list[listnr]);
320 if (!err && (flags & AUDIT_AT_EXIT)) 377 if (!err)
321 err = audit_del_rule(data, &audit_extlist); 378 audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE,
322 audit_log(NULL, AUDIT_CONFIG_CHANGE, 379 "auid=%u removed an audit rule\n", loginuid);
323 "auid=%u removed an audit rule\n", loginuid);
324 break; 380 break;
325 default: 381 default:
326 return -EINVAL; 382 return -EINVAL;
@@ -384,8 +440,12 @@ static int audit_filter_rules(struct task_struct *tsk,
384 result = (ctx->return_code == value); 440 result = (ctx->return_code == value);
385 break; 441 break;
386 case AUDIT_SUCCESS: 442 case AUDIT_SUCCESS:
387 if (ctx && ctx->return_valid) 443 if (ctx && ctx->return_valid) {
388 result = (ctx->return_valid == AUDITSC_SUCCESS); 444 if (value)
445 result = (ctx->return_valid == AUDITSC_SUCCESS);
446 else
447 result = (ctx->return_valid == AUDITSC_FAILURE);
448 }
389 break; 449 break;
390 case AUDIT_DEVMAJOR: 450 case AUDIT_DEVMAJOR:
391 if (ctx) { 451 if (ctx) {
@@ -454,7 +514,7 @@ static enum audit_state audit_filter_task(struct task_struct *tsk)
454 enum audit_state state; 514 enum audit_state state;
455 515
456 rcu_read_lock(); 516 rcu_read_lock();
457 list_for_each_entry_rcu(e, &audit_tsklist, list) { 517 list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TASK], list) {
458 if (audit_filter_rules(tsk, &e->rule, NULL, &state)) { 518 if (audit_filter_rules(tsk, &e->rule, NULL, &state)) {
459 rcu_read_unlock(); 519 rcu_read_unlock();
460 return state; 520 return state;
@@ -474,20 +534,84 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk,
474 struct list_head *list) 534 struct list_head *list)
475{ 535{
476 struct audit_entry *e; 536 struct audit_entry *e;
537 enum audit_state state;
538
539 if (audit_pid && tsk->tgid == audit_pid)
540 return AUDIT_DISABLED;
541
542 rcu_read_lock();
543 if (!list_empty(list)) {
544 int word = AUDIT_WORD(ctx->major);
545 int bit = AUDIT_BIT(ctx->major);
546
547 list_for_each_entry_rcu(e, list, list) {
548 if ((e->rule.mask[word] & bit) == bit
549 && audit_filter_rules(tsk, &e->rule, ctx, &state)) {
550 rcu_read_unlock();
551 return state;
552 }
553 }
554 }
555 rcu_read_unlock();
556 return AUDIT_BUILD_CONTEXT;
557}
558
559static int audit_filter_user_rules(struct netlink_skb_parms *cb,
560 struct audit_rule *rule,
561 enum audit_state *state)
562{
563 int i;
564
565 for (i = 0; i < rule->field_count; i++) {
566 u32 field = rule->fields[i] & ~AUDIT_NEGATE;
567 u32 value = rule->values[i];
568 int result = 0;
569
570 switch (field) {
571 case AUDIT_PID:
572 result = (cb->creds.pid == value);
573 break;
574 case AUDIT_UID:
575 result = (cb->creds.uid == value);
576 break;
577 case AUDIT_GID:
578 result = (cb->creds.gid == value);
579 break;
580 case AUDIT_LOGINUID:
581 result = (cb->loginuid == value);
582 break;
583 }
584
585 if (rule->fields[i] & AUDIT_NEGATE)
586 result = !result;
587 if (!result)
588 return 0;
589 }
590 switch (rule->action) {
591 case AUDIT_NEVER: *state = AUDIT_DISABLED; break;
592 case AUDIT_POSSIBLE: *state = AUDIT_BUILD_CONTEXT; break;
593 case AUDIT_ALWAYS: *state = AUDIT_RECORD_CONTEXT; break;
594 }
595 return 1;
596}
597
598int audit_filter_user(struct netlink_skb_parms *cb, int type)
599{
600 struct audit_entry *e;
477 enum audit_state state; 601 enum audit_state state;
478 int word = AUDIT_WORD(ctx->major); 602 int ret = 1;
479 int bit = AUDIT_BIT(ctx->major);
480 603
481 rcu_read_lock(); 604 rcu_read_lock();
482 list_for_each_entry_rcu(e, list, list) { 605 list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_USER], list) {
483 if ((e->rule.mask[word] & bit) == bit 606 if (audit_filter_user_rules(cb, &e->rule, &state)) {
484 && audit_filter_rules(tsk, &e->rule, ctx, &state)) { 607 if (state == AUDIT_DISABLED)
485 rcu_read_unlock(); 608 ret = 0;
486 return state; 609 break;
487 } 610 }
488 } 611 }
489 rcu_read_unlock(); 612 rcu_read_unlock();
490 return AUDIT_BUILD_CONTEXT; 613
614 return ret; /* Audit by default */
491} 615}
492 616
493/* This should be called with task_lock() held. */ 617/* This should be called with task_lock() held. */
@@ -504,7 +628,7 @@ static inline struct audit_context *audit_get_context(struct task_struct *tsk,
504 628
505 if (context->in_syscall && !context->auditable) { 629 if (context->in_syscall && !context->auditable) {
506 enum audit_state state; 630 enum audit_state state;
507 state = audit_filter_syscall(tsk, context, &audit_extlist); 631 state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_EXIT]);
508 if (state == AUDIT_RECORD_CONTEXT) 632 if (state == AUDIT_RECORD_CONTEXT)
509 context->auditable = 1; 633 context->auditable = 1;
510 } 634 }
@@ -679,13 +803,13 @@ static void audit_log_task_info(struct audit_buffer *ab)
679 up_read(&mm->mmap_sem); 803 up_read(&mm->mmap_sem);
680} 804}
681 805
682static void audit_log_exit(struct audit_context *context) 806static void audit_log_exit(struct audit_context *context, unsigned int gfp_mask)
683{ 807{
684 int i; 808 int i;
685 struct audit_buffer *ab; 809 struct audit_buffer *ab;
686 struct audit_aux_data *aux; 810 struct audit_aux_data *aux;
687 811
688 ab = audit_log_start(context, AUDIT_SYSCALL); 812 ab = audit_log_start(context, gfp_mask, AUDIT_SYSCALL);
689 if (!ab) 813 if (!ab)
690 return; /* audit_panic has been called */ 814 return; /* audit_panic has been called */
691 audit_log_format(ab, "arch=%x syscall=%d", 815 audit_log_format(ab, "arch=%x syscall=%d",
@@ -717,7 +841,7 @@ static void audit_log_exit(struct audit_context *context)
717 841
718 for (aux = context->aux; aux; aux = aux->next) { 842 for (aux = context->aux; aux; aux = aux->next) {
719 843
720 ab = audit_log_start(context, aux->type); 844 ab = audit_log_start(context, GFP_KERNEL, aux->type);
721 if (!ab) 845 if (!ab)
722 continue; /* audit_panic has been called */ 846 continue; /* audit_panic has been called */
723 847
@@ -754,14 +878,14 @@ static void audit_log_exit(struct audit_context *context)
754 } 878 }
755 879
756 if (context->pwd && context->pwdmnt) { 880 if (context->pwd && context->pwdmnt) {
757 ab = audit_log_start(context, AUDIT_CWD); 881 ab = audit_log_start(context, GFP_KERNEL, AUDIT_CWD);
758 if (ab) { 882 if (ab) {
759 audit_log_d_path(ab, "cwd=", context->pwd, context->pwdmnt); 883 audit_log_d_path(ab, "cwd=", context->pwd, context->pwdmnt);
760 audit_log_end(ab); 884 audit_log_end(ab);
761 } 885 }
762 } 886 }
763 for (i = 0; i < context->name_count; i++) { 887 for (i = 0; i < context->name_count; i++) {
764 ab = audit_log_start(context, AUDIT_PATH); 888 ab = audit_log_start(context, GFP_KERNEL, AUDIT_PATH);
765 if (!ab) 889 if (!ab)
766 continue; /* audit_panic has been called */ 890 continue; /* audit_panic has been called */
767 891
@@ -770,6 +894,8 @@ static void audit_log_exit(struct audit_context *context)
770 audit_log_format(ab, " name="); 894 audit_log_format(ab, " name=");
771 audit_log_untrustedstring(ab, context->names[i].name); 895 audit_log_untrustedstring(ab, context->names[i].name);
772 } 896 }
897 audit_log_format(ab, " flags=%x\n", context->names[i].flags);
898
773 if (context->names[i].ino != (unsigned long)-1) 899 if (context->names[i].ino != (unsigned long)-1)
774 audit_log_format(ab, " inode=%lu dev=%02x:%02x mode=%#o" 900 audit_log_format(ab, " inode=%lu dev=%02x:%02x mode=%#o"
775 " ouid=%u ogid=%u rdev=%02x:%02x", 901 " ouid=%u ogid=%u rdev=%02x:%02x",
@@ -799,9 +925,11 @@ void audit_free(struct task_struct *tsk)
799 return; 925 return;
800 926
801 /* Check for system calls that do not go through the exit 927 /* Check for system calls that do not go through the exit
802 * function (e.g., exit_group), then free context block. */ 928 * function (e.g., exit_group), then free context block.
803 if (context->in_syscall && context->auditable && context->pid != audit_pid) 929 * We use GFP_ATOMIC here because we might be doing this
804 audit_log_exit(context); 930 * in the context of the idle thread */
931 if (context->in_syscall && context->auditable)
932 audit_log_exit(context, GFP_ATOMIC);
805 933
806 audit_free_context(context); 934 audit_free_context(context);
807} 935}
@@ -876,11 +1004,11 @@ void audit_syscall_entry(struct task_struct *tsk, int arch, int major,
876 1004
877 state = context->state; 1005 state = context->state;
878 if (state == AUDIT_SETUP_CONTEXT || state == AUDIT_BUILD_CONTEXT) 1006 if (state == AUDIT_SETUP_CONTEXT || state == AUDIT_BUILD_CONTEXT)
879 state = audit_filter_syscall(tsk, context, &audit_entlist); 1007 state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_ENTRY]);
880 if (likely(state == AUDIT_DISABLED)) 1008 if (likely(state == AUDIT_DISABLED))
881 return; 1009 return;
882 1010
883 context->serial = audit_serial(); 1011 context->serial = 0;
884 context->ctime = CURRENT_TIME; 1012 context->ctime = CURRENT_TIME;
885 context->in_syscall = 1; 1013 context->in_syscall = 1;
886 context->auditable = !!(state == AUDIT_RECORD_CONTEXT); 1014 context->auditable = !!(state == AUDIT_RECORD_CONTEXT);
@@ -903,10 +1031,10 @@ void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code)
903 /* Not having a context here is ok, since the parent may have 1031 /* Not having a context here is ok, since the parent may have
904 * called __put_task_struct. */ 1032 * called __put_task_struct. */
905 if (likely(!context)) 1033 if (likely(!context))
906 return; 1034 goto out;
907 1035
908 if (context->in_syscall && context->auditable && context->pid != audit_pid) 1036 if (context->in_syscall && context->auditable)
909 audit_log_exit(context); 1037 audit_log_exit(context, GFP_KERNEL);
910 1038
911 context->in_syscall = 0; 1039 context->in_syscall = 0;
912 context->auditable = 0; 1040 context->auditable = 0;
@@ -919,9 +1047,9 @@ void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code)
919 } else { 1047 } else {
920 audit_free_names(context); 1048 audit_free_names(context);
921 audit_free_aux(context); 1049 audit_free_aux(context);
922 audit_zero_context(context, context->state);
923 tsk->audit_context = context; 1050 tsk->audit_context = context;
924 } 1051 }
1052 out:
925 put_task_struct(tsk); 1053 put_task_struct(tsk);
926} 1054}
927 1055
@@ -996,7 +1124,7 @@ void audit_putname(const char *name)
996 1124
997/* Store the inode and device from a lookup. Called from 1125/* Store the inode and device from a lookup. Called from
998 * fs/namei.c:path_lookup(). */ 1126 * fs/namei.c:path_lookup(). */
999void audit_inode(const char *name, const struct inode *inode) 1127void audit_inode(const char *name, const struct inode *inode, unsigned flags)
1000{ 1128{
1001 int idx; 1129 int idx;
1002 struct audit_context *context = current->audit_context; 1130 struct audit_context *context = current->audit_context;
@@ -1022,17 +1150,20 @@ void audit_inode(const char *name, const struct inode *inode)
1022 ++context->ino_count; 1150 ++context->ino_count;
1023#endif 1151#endif
1024 } 1152 }
1025 context->names[idx].ino = inode->i_ino; 1153 context->names[idx].flags = flags;
1026 context->names[idx].dev = inode->i_sb->s_dev; 1154 context->names[idx].ino = inode->i_ino;
1027 context->names[idx].mode = inode->i_mode; 1155 context->names[idx].dev = inode->i_sb->s_dev;
1028 context->names[idx].uid = inode->i_uid; 1156 context->names[idx].mode = inode->i_mode;
1029 context->names[idx].gid = inode->i_gid; 1157 context->names[idx].uid = inode->i_uid;
1030 context->names[idx].rdev = inode->i_rdev; 1158 context->names[idx].gid = inode->i_gid;
1159 context->names[idx].rdev = inode->i_rdev;
1031} 1160}
1032 1161
1033void auditsc_get_stamp(struct audit_context *ctx, 1162void auditsc_get_stamp(struct audit_context *ctx,
1034 struct timespec *t, unsigned int *serial) 1163 struct timespec *t, unsigned int *serial)
1035{ 1164{
1165 if (!ctx->serial)
1166 ctx->serial = audit_serial();
1036 t->tv_sec = ctx->ctime.tv_sec; 1167 t->tv_sec = ctx->ctime.tv_sec;
1037 t->tv_nsec = ctx->ctime.tv_nsec; 1168 t->tv_nsec = ctx->ctime.tv_nsec;
1038 *serial = ctx->serial; 1169 *serial = ctx->serial;
@@ -1044,7 +1175,7 @@ int audit_set_loginuid(struct task_struct *task, uid_t loginuid)
1044 if (task->audit_context) { 1175 if (task->audit_context) {
1045 struct audit_buffer *ab; 1176 struct audit_buffer *ab;
1046 1177
1047 ab = audit_log_start(NULL, AUDIT_LOGIN); 1178 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN);
1048 if (ab) { 1179 if (ab) {
1049 audit_log_format(ab, "login pid=%d uid=%u " 1180 audit_log_format(ab, "login pid=%d uid=%u "
1050 "old auid=%u new auid=%u", 1181 "old auid=%u new auid=%u",
@@ -1153,7 +1284,7 @@ void audit_signal_info(int sig, struct task_struct *t)
1153 extern pid_t audit_sig_pid; 1284 extern pid_t audit_sig_pid;
1154 extern uid_t audit_sig_uid; 1285 extern uid_t audit_sig_uid;
1155 1286
1156 if (unlikely(audit_pid && t->pid == audit_pid)) { 1287 if (unlikely(audit_pid && t->tgid == audit_pid)) {
1157 if (sig == SIGTERM || sig == SIGHUP) { 1288 if (sig == SIGTERM || sig == SIGHUP) {
1158 struct audit_context *ctx = current->audit_context; 1289 struct audit_context *ctx = current->audit_context;
1159 audit_sig_pid = current->pid; 1290 audit_sig_pid = current->pid;
diff --git a/kernel/module.c b/kernel/module.c
index 4b39d3793c72..ff5c500ab625 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -20,6 +20,7 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/moduleloader.h> 21#include <linux/moduleloader.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/kernel.h>
23#include <linux/slab.h> 24#include <linux/slab.h>
24#include <linux/vmalloc.h> 25#include <linux/vmalloc.h>
25#include <linux/elf.h> 26#include <linux/elf.h>
@@ -498,7 +499,7 @@ static inline int try_force(unsigned int flags)
498{ 499{
499 int ret = (flags & O_TRUNC); 500 int ret = (flags & O_TRUNC);
500 if (ret) 501 if (ret)
501 tainted |= TAINT_FORCED_MODULE; 502 add_taint(TAINT_FORCED_MODULE);
502 return ret; 503 return ret;
503} 504}
504#else 505#else
@@ -897,7 +898,7 @@ static int check_version(Elf_Shdr *sechdrs,
897 if (!(tainted & TAINT_FORCED_MODULE)) { 898 if (!(tainted & TAINT_FORCED_MODULE)) {
898 printk("%s: no version for \"%s\" found: kernel tainted.\n", 899 printk("%s: no version for \"%s\" found: kernel tainted.\n",
899 mod->name, symname); 900 mod->name, symname);
900 tainted |= TAINT_FORCED_MODULE; 901 add_taint(TAINT_FORCED_MODULE);
901 } 902 }
902 return 1; 903 return 1;
903} 904}
@@ -1352,7 +1353,7 @@ static void set_license(struct module *mod, const char *license)
1352 if (!mod->license_gplok && !(tainted & TAINT_PROPRIETARY_MODULE)) { 1353 if (!mod->license_gplok && !(tainted & TAINT_PROPRIETARY_MODULE)) {
1353 printk(KERN_WARNING "%s: module license '%s' taints kernel.\n", 1354 printk(KERN_WARNING "%s: module license '%s' taints kernel.\n",
1354 mod->name, license); 1355 mod->name, license);
1355 tainted |= TAINT_PROPRIETARY_MODULE; 1356 add_taint(TAINT_PROPRIETARY_MODULE);
1356 } 1357 }
1357} 1358}
1358 1359
@@ -1610,7 +1611,7 @@ static struct module *load_module(void __user *umod,
1610 modmagic = get_modinfo(sechdrs, infoindex, "vermagic"); 1611 modmagic = get_modinfo(sechdrs, infoindex, "vermagic");
1611 /* This is allowed: modprobe --force will invalidate it. */ 1612 /* This is allowed: modprobe --force will invalidate it. */
1612 if (!modmagic) { 1613 if (!modmagic) {
1613 tainted |= TAINT_FORCED_MODULE; 1614 add_taint(TAINT_FORCED_MODULE);
1614 printk(KERN_WARNING "%s: no version magic, tainting kernel.\n", 1615 printk(KERN_WARNING "%s: no version magic, tainting kernel.\n",
1615 mod->name); 1616 mod->name);
1616 } else if (!same_magic(modmagic, vermagic)) { 1617 } else if (!same_magic(modmagic, vermagic)) {
@@ -1739,7 +1740,7 @@ static struct module *load_module(void __user *umod,
1739 (mod->num_gpl_syms && !gplcrcindex)) { 1740 (mod->num_gpl_syms && !gplcrcindex)) {
1740 printk(KERN_WARNING "%s: No versions for exported symbols." 1741 printk(KERN_WARNING "%s: No versions for exported symbols."
1741 " Tainting kernel.\n", mod->name); 1742 " Tainting kernel.\n", mod->name);
1742 tainted |= TAINT_FORCED_MODULE; 1743 add_taint(TAINT_FORCED_MODULE);
1743 } 1744 }
1744#endif 1745#endif
1745 1746
diff --git a/kernel/sched.c b/kernel/sched.c
index 81b3a96ed2d0..1f31a528fdba 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -294,6 +294,10 @@ static inline void prepare_lock_switch(runqueue_t *rq, task_t *next)
294 294
295static inline void finish_lock_switch(runqueue_t *rq, task_t *prev) 295static inline void finish_lock_switch(runqueue_t *rq, task_t *prev)
296{ 296{
297#ifdef CONFIG_DEBUG_SPINLOCK
298 /* this is a valid case when another task releases the spinlock */
299 rq->lock.owner = current;
300#endif
297 spin_unlock_irq(&rq->lock); 301 spin_unlock_irq(&rq->lock);
298} 302}
299 303
@@ -1529,10 +1533,6 @@ static inline void finish_task_switch(runqueue_t *rq, task_t *prev)
1529 * Manfred Spraul <manfred@colorfullife.com> 1533 * Manfred Spraul <manfred@colorfullife.com>
1530 */ 1534 */
1531 prev_task_flags = prev->flags; 1535 prev_task_flags = prev->flags;
1532#ifdef CONFIG_DEBUG_SPINLOCK
1533 /* this is a valid case when another task releases the spinlock */
1534 rq->lock.owner = current;
1535#endif
1536 finish_arch_switch(prev); 1536 finish_arch_switch(prev);
1537 finish_lock_switch(rq, prev); 1537 finish_lock_switch(rq, prev);
1538 if (mm) 1538 if (mm)
diff --git a/kernel/timer.c b/kernel/timer.c
index f4152fcd9f8e..3ba10fa35b60 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1151,19 +1151,22 @@ fastcall signed long __sched schedule_timeout(signed long timeout)
1151 out: 1151 out:
1152 return timeout < 0 ? 0 : timeout; 1152 return timeout < 0 ? 0 : timeout;
1153} 1153}
1154
1155EXPORT_SYMBOL(schedule_timeout); 1154EXPORT_SYMBOL(schedule_timeout);
1156 1155
1156/*
1157 * We can use __set_current_state() here because schedule_timeout() calls
1158 * schedule() unconditionally.
1159 */
1157signed long __sched schedule_timeout_interruptible(signed long timeout) 1160signed long __sched schedule_timeout_interruptible(signed long timeout)
1158{ 1161{
1159 set_current_state(TASK_INTERRUPTIBLE); 1162 __set_current_state(TASK_INTERRUPTIBLE);
1160 return schedule_timeout(timeout); 1163 return schedule_timeout(timeout);
1161} 1164}
1162EXPORT_SYMBOL(schedule_timeout_interruptible); 1165EXPORT_SYMBOL(schedule_timeout_interruptible);
1163 1166
1164signed long __sched schedule_timeout_uninterruptible(signed long timeout) 1167signed long __sched schedule_timeout_uninterruptible(signed long timeout)
1165{ 1168{
1166 set_current_state(TASK_UNINTERRUPTIBLE); 1169 __set_current_state(TASK_UNINTERRUPTIBLE);
1167 return schedule_timeout(timeout); 1170 return schedule_timeout(timeout);
1168} 1171}
1169EXPORT_SYMBOL(schedule_timeout_uninterruptible); 1172EXPORT_SYMBOL(schedule_timeout_uninterruptible);
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index afa06e184d88..9033f0859aa8 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -333,8 +333,13 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
333 if (prev && prev->vm_end < vma->vm_start) 333 if (prev && prev->vm_end < vma->vm_start)
334 return ERR_PTR(-EFAULT); 334 return ERR_PTR(-EFAULT);
335 if ((flags & MPOL_MF_STRICT) && !is_vm_hugetlb_page(vma)) { 335 if ((flags & MPOL_MF_STRICT) && !is_vm_hugetlb_page(vma)) {
336 unsigned long endvma = vma->vm_end;
337 if (endvma > end)
338 endvma = end;
339 if (vma->vm_start > start)
340 start = vma->vm_start;
336 err = check_pgd_range(vma->vm_mm, 341 err = check_pgd_range(vma->vm_mm,
337 vma->vm_start, vma->vm_end, nodes); 342 start, endvma, nodes);
338 if (err) { 343 if (err) {
339 first = ERR_PTR(err); 344 first = ERR_PTR(err);
340 break; 345 break;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c5823c395f71..ae2903339e71 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -22,6 +22,7 @@
22#include <linux/pagemap.h> 22#include <linux/pagemap.h>
23#include <linux/bootmem.h> 23#include <linux/bootmem.h>
24#include <linux/compiler.h> 24#include <linux/compiler.h>
25#include <linux/kernel.h>
25#include <linux/module.h> 26#include <linux/module.h>
26#include <linux/suspend.h> 27#include <linux/suspend.h>
27#include <linux/pagevec.h> 28#include <linux/pagevec.h>
@@ -117,7 +118,7 @@ static void bad_page(const char *function, struct page *page)
117 set_page_count(page, 0); 118 set_page_count(page, 0);
118 reset_page_mapcount(page); 119 reset_page_mapcount(page);
119 page->mapping = NULL; 120 page->mapping = NULL;
120 tainted |= TAINT_BAD_PAGE; 121 add_taint(TAINT_BAD_PAGE);
121} 122}
122 123
123#ifndef CONFIG_HUGETLB_PAGE 124#ifndef CONFIG_HUGETLB_PAGE
diff --git a/mm/vmscan.c b/mm/vmscan.c
index a740778f688d..0ea71e887bb6 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1258,9 +1258,9 @@ void wakeup_kswapd(struct zone *zone, int order)
1258 pgdat->kswapd_max_order = order; 1258 pgdat->kswapd_max_order = order;
1259 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) 1259 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
1260 return; 1260 return;
1261 if (!waitqueue_active(&zone->zone_pgdat->kswapd_wait)) 1261 if (!waitqueue_active(&pgdat->kswapd_wait))
1262 return; 1262 return;
1263 wake_up_interruptible(&zone->zone_pgdat->kswapd_wait); 1263 wake_up_interruptible(&pgdat->kswapd_wait);
1264} 1264}
1265 1265
1266#ifdef CONFIG_PM 1266#ifdef CONFIG_PM
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index ed705ddad56b..8e37e71e34ff 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -1695,16 +1695,12 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1695 /* These two are safe on a single CPU system as only user tasks fiddle here */ 1695 /* These two are safe on a single CPU system as only user tasks fiddle here */
1696 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) 1696 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL)
1697 amount = skb->len; 1697 amount = skb->len;
1698 res = put_user(amount, (int __user *)argp); 1698 res = put_user(amount, (int __user *) argp);
1699 break; 1699 break;
1700 } 1700 }
1701 1701
1702 case SIOCGSTAMP: 1702 case SIOCGSTAMP:
1703 if (sk != NULL) { 1703 res = sock_get_timestamp(sk, argp);
1704 res = sock_get_timestamp(sk, argp);
1705 break;
1706 }
1707 res = -EINVAL;
1708 break; 1704 break;
1709 1705
1710 case SIOCAX25ADDUID: /* Add a uid to the uid/call map table */ 1706 case SIOCAX25ADDUID: /* Add a uid to the uid/call map table */
@@ -1951,24 +1947,24 @@ static struct net_proto_family ax25_family_ops = {
1951}; 1947};
1952 1948
1953static struct proto_ops ax25_proto_ops = { 1949static struct proto_ops ax25_proto_ops = {
1954 .family = PF_AX25, 1950 .family = PF_AX25,
1955 .owner = THIS_MODULE, 1951 .owner = THIS_MODULE,
1956 .release = ax25_release, 1952 .release = ax25_release,
1957 .bind = ax25_bind, 1953 .bind = ax25_bind,
1958 .connect = ax25_connect, 1954 .connect = ax25_connect,
1959 .socketpair = sock_no_socketpair, 1955 .socketpair = sock_no_socketpair,
1960 .accept = ax25_accept, 1956 .accept = ax25_accept,
1961 .getname = ax25_getname, 1957 .getname = ax25_getname,
1962 .poll = datagram_poll, 1958 .poll = datagram_poll,
1963 .ioctl = ax25_ioctl, 1959 .ioctl = ax25_ioctl,
1964 .listen = ax25_listen, 1960 .listen = ax25_listen,
1965 .shutdown = ax25_shutdown, 1961 .shutdown = ax25_shutdown,
1966 .setsockopt = ax25_setsockopt, 1962 .setsockopt = ax25_setsockopt,
1967 .getsockopt = ax25_getsockopt, 1963 .getsockopt = ax25_getsockopt,
1968 .sendmsg = ax25_sendmsg, 1964 .sendmsg = ax25_sendmsg,
1969 .recvmsg = ax25_recvmsg, 1965 .recvmsg = ax25_recvmsg,
1970 .mmap = sock_no_mmap, 1966 .mmap = sock_no_mmap,
1971 .sendpage = sock_no_sendpage, 1967 .sendpage = sock_no_sendpage,
1972}; 1968};
1973 1969
1974/* 1970/*
@@ -1984,7 +1980,7 @@ static struct notifier_block ax25_dev_notifier = {
1984 .notifier_call =ax25_device_event, 1980 .notifier_call =ax25_device_event,
1985}; 1981};
1986 1982
1987EXPORT_SYMBOL(ax25_encapsulate); 1983EXPORT_SYMBOL(ax25_hard_header);
1988EXPORT_SYMBOL(ax25_rebuild_header); 1984EXPORT_SYMBOL(ax25_rebuild_header);
1989EXPORT_SYMBOL(ax25_findbyuid); 1985EXPORT_SYMBOL(ax25_findbyuid);
1990EXPORT_SYMBOL(ax25_find_cb); 1986EXPORT_SYMBOL(ax25_find_cb);
diff --git a/net/ax25/ax25_ip.c b/net/ax25/ax25_ip.c
index bba0173e2d65..d643dac3eccc 100644
--- a/net/ax25/ax25_ip.c
+++ b/net/ax25/ax25_ip.c
@@ -47,7 +47,7 @@
47 47
48#ifdef CONFIG_INET 48#ifdef CONFIG_INET
49 49
50int ax25_encapsulate(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) 50int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len)
51{ 51{
52 unsigned char *buff; 52 unsigned char *buff;
53 53
@@ -88,7 +88,7 @@ int ax25_encapsulate(struct sk_buff *skb, struct net_device *dev, unsigned short
88 *buff++ = AX25_P_ARP; 88 *buff++ = AX25_P_ARP;
89 break; 89 break;
90 default: 90 default:
91 printk(KERN_ERR "AX.25: ax25_encapsulate - wrong protocol type 0x%2.2x\n", type); 91 printk(KERN_ERR "AX.25: ax25_hard_header - wrong protocol type 0x%2.2x\n", type);
92 *buff++ = 0; 92 *buff++ = 0;
93 break; 93 break;
94 } 94 }
@@ -209,7 +209,7 @@ put:
209 209
210#else /* INET */ 210#else /* INET */
211 211
212int ax25_encapsulate(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) 212int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len)
213{ 213{
214 return -AX25_HEADER_LEN; 214 return -AX25_HEADER_LEN;
215} 215}
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index b3ad49fa7d78..ef430b1e8e42 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1452,8 +1452,7 @@ static int proc_thread_write(struct file *file, const char __user *user_buffer,
1452 thread_lock(); 1452 thread_lock();
1453 t->control |= T_REMDEV; 1453 t->control |= T_REMDEV;
1454 thread_unlock(); 1454 thread_unlock();
1455 current->state = TASK_INTERRUPTIBLE; 1455 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */
1456 schedule_timeout(HZ/8); /* Propagate thread->control */
1457 ret = count; 1456 ret = count;
1458 sprintf(pg_result, "OK: rem_device_all"); 1457 sprintf(pg_result, "OK: rem_device_all");
1459 goto out; 1458 goto out;
@@ -1716,10 +1715,9 @@ static void spin(struct pktgen_dev *pkt_dev, __u64 spin_until_us)
1716 printk(KERN_INFO "sleeping for %d\n", (int)(spin_until_us - now)); 1715 printk(KERN_INFO "sleeping for %d\n", (int)(spin_until_us - now));
1717 while (now < spin_until_us) { 1716 while (now < spin_until_us) {
1718 /* TODO: optimise sleeping behavior */ 1717 /* TODO: optimise sleeping behavior */
1719 if (spin_until_us - now > (1000000/HZ)+1) { 1718 if (spin_until_us - now > jiffies_to_usecs(1)+1)
1720 current->state = TASK_INTERRUPTIBLE; 1719 schedule_timeout_interruptible(1);
1721 schedule_timeout(1); 1720 else if (spin_until_us - now > 100) {
1722 } else if (spin_until_us - now > 100) {
1723 do_softirq(); 1721 do_softirq();
1724 if (!pkt_dev->running) 1722 if (!pkt_dev->running)
1725 return; 1723 return;
@@ -2449,8 +2447,7 @@ static void pktgen_run_all_threads(void)
2449 } 2447 }
2450 thread_unlock(); 2448 thread_unlock();
2451 2449
2452 current->state = TASK_INTERRUPTIBLE; 2450 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */
2453 schedule_timeout(HZ/8); /* Propagate thread->control */
2454 2451
2455 pktgen_wait_all_threads_run(); 2452 pktgen_wait_all_threads_run();
2456} 2453}
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index e05f4f955eee..38aa84986118 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -1095,6 +1095,10 @@ static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
1095{ 1095{
1096 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); 1096 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
1097 1097
1098 /* Listen socks doesn't have a private CCID block */
1099 if (sk->sk_state == DCCP_LISTEN)
1100 return;
1101
1098 BUG_ON(hcrx == NULL); 1102 BUG_ON(hcrx == NULL);
1099 1103
1100 info->tcpi_ca_state = hcrx->ccid3hcrx_state; 1104 info->tcpi_ca_state = hcrx->ccid3hcrx_state;
@@ -1106,6 +1110,10 @@ static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info)
1106{ 1110{
1107 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 1111 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
1108 1112
1113 /* Listen socks doesn't have a private CCID block */
1114 if (sk->sk_state == DCCP_LISTEN)
1115 return;
1116
1109 BUG_ON(hctx == NULL); 1117 BUG_ON(hctx == NULL);
1110 1118
1111 info->tcpi_rto = hctx->ccid3hctx_t_rto; 1119 info->tcpi_rto = hctx->ccid3hctx_t_rto;
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 953129d392d2..e8674baaa8d9 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -1103,10 +1103,8 @@ static int __init ic_dynamic(void)
1103#endif 1103#endif
1104 1104
1105 jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout); 1105 jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout);
1106 while (time_before(jiffies, jiff) && !ic_got_reply) { 1106 while (time_before(jiffies, jiff) && !ic_got_reply)
1107 set_current_state(TASK_UNINTERRUPTIBLE); 1107 schedule_timeout_uninterruptible(1);
1108 schedule_timeout(1);
1109 }
1110#ifdef IPCONFIG_DHCP 1108#ifdef IPCONFIG_DHCP
1111 /* DHCP isn't done until we get a DHCPACK. */ 1109 /* DHCP isn't done until we get a DHCPACK. */
1112 if ((ic_got_reply & IC_BOOTP) 1110 if ((ic_got_reply & IC_BOOTP)
diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
index 1b79ec36085f..d77d6b3f5f80 100644
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c
@@ -29,9 +29,9 @@ static char *ftp_buffer;
29static DEFINE_SPINLOCK(ip_ftp_lock); 29static DEFINE_SPINLOCK(ip_ftp_lock);
30 30
31#define MAX_PORTS 8 31#define MAX_PORTS 8
32static int ports[MAX_PORTS]; 32static short ports[MAX_PORTS];
33static int ports_c; 33static int ports_c;
34module_param_array(ports, int, &ports_c, 0400); 34module_param_array(ports, short, &ports_c, 0400);
35 35
36static int loose; 36static int loose;
37module_param(loose, int, 0600); 37module_param(loose, int, 0600);
@@ -450,7 +450,7 @@ out_update_nl:
450} 450}
451 451
452static struct ip_conntrack_helper ftp[MAX_PORTS]; 452static struct ip_conntrack_helper ftp[MAX_PORTS];
453static char ftp_names[MAX_PORTS][10]; 453static char ftp_names[MAX_PORTS][sizeof("ftp-65535")];
454 454
455/* Not __exit: called from init() */ 455/* Not __exit: called from init() */
456static void fini(void) 456static void fini(void)
diff --git a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
index d7a8a98c05e1..15457415a4f3 100644
--- a/net/ipv4/netfilter/ip_conntrack_irc.c
+++ b/net/ipv4/netfilter/ip_conntrack_irc.c
@@ -34,7 +34,7 @@
34#include <linux/moduleparam.h> 34#include <linux/moduleparam.h>
35 35
36#define MAX_PORTS 8 36#define MAX_PORTS 8
37static int ports[MAX_PORTS]; 37static short ports[MAX_PORTS];
38static int ports_c; 38static int ports_c;
39static int max_dcc_channels = 8; 39static int max_dcc_channels = 8;
40static unsigned int dcc_timeout = 300; 40static unsigned int dcc_timeout = 300;
@@ -52,7 +52,7 @@ EXPORT_SYMBOL_GPL(ip_nat_irc_hook);
52MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); 52MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
53MODULE_DESCRIPTION("IRC (DCC) connection tracking helper"); 53MODULE_DESCRIPTION("IRC (DCC) connection tracking helper");
54MODULE_LICENSE("GPL"); 54MODULE_LICENSE("GPL");
55module_param_array(ports, int, &ports_c, 0400); 55module_param_array(ports, short, &ports_c, 0400);
56MODULE_PARM_DESC(ports, "port numbers of IRC servers"); 56MODULE_PARM_DESC(ports, "port numbers of IRC servers");
57module_param(max_dcc_channels, int, 0400); 57module_param(max_dcc_channels, int, 0400);
58MODULE_PARM_DESC(max_dcc_channels, "max number of expected DCC channels per IRC session"); 58MODULE_PARM_DESC(max_dcc_channels, "max number of expected DCC channels per IRC session");
@@ -240,7 +240,7 @@ static int help(struct sk_buff **pskb,
240} 240}
241 241
242static struct ip_conntrack_helper irc_helpers[MAX_PORTS]; 242static struct ip_conntrack_helper irc_helpers[MAX_PORTS];
243static char irc_names[MAX_PORTS][10]; 243static char irc_names[MAX_PORTS][sizeof("irc-65535")];
244 244
245static void fini(void); 245static void fini(void);
246 246
diff --git a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c
index bb7246683b74..71ef19d126d0 100644
--- a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c
+++ b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c
@@ -23,7 +23,6 @@
23#include <linux/inetdevice.h> 23#include <linux/inetdevice.h>
24#include <linux/in.h> 24#include <linux/in.h>
25#include <linux/ip.h> 25#include <linux/ip.h>
26#include <linux/udp.h>
27#include <net/route.h> 26#include <net/route.h>
28 27
29#include <linux/netfilter.h> 28#include <linux/netfilter.h>
@@ -31,6 +30,8 @@
31#include <linux/netfilter_ipv4/ip_conntrack.h> 30#include <linux/netfilter_ipv4/ip_conntrack.h>
32#include <linux/netfilter_ipv4/ip_conntrack_helper.h> 31#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
33 32
33#define NMBD_PORT 137
34
34MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); 35MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
35MODULE_DESCRIPTION("NetBIOS name service broadcast connection tracking helper"); 36MODULE_DESCRIPTION("NetBIOS name service broadcast connection tracking helper");
36MODULE_LICENSE("GPL"); 37MODULE_LICENSE("GPL");
@@ -44,7 +45,6 @@ static int help(struct sk_buff **pskb,
44{ 45{
45 struct ip_conntrack_expect *exp; 46 struct ip_conntrack_expect *exp;
46 struct iphdr *iph = (*pskb)->nh.iph; 47 struct iphdr *iph = (*pskb)->nh.iph;
47 struct udphdr _uh, *uh;
48 struct rtable *rt = (struct rtable *)(*pskb)->dst; 48 struct rtable *rt = (struct rtable *)(*pskb)->dst;
49 struct in_device *in_dev; 49 struct in_device *in_dev;
50 u_int32_t mask = 0; 50 u_int32_t mask = 0;
@@ -72,20 +72,15 @@ static int help(struct sk_buff **pskb,
72 if (mask == 0) 72 if (mask == 0)
73 goto out; 73 goto out;
74 74
75 uh = skb_header_pointer(*pskb, iph->ihl * 4, sizeof(_uh), &_uh);
76 BUG_ON(uh == NULL);
77
78 exp = ip_conntrack_expect_alloc(ct); 75 exp = ip_conntrack_expect_alloc(ct);
79 if (exp == NULL) 76 if (exp == NULL)
80 goto out; 77 goto out;
81 memset(&exp->tuple, 0, sizeof(exp->tuple));
82 exp->tuple.src.ip = iph->daddr & mask;
83 exp->tuple.dst.ip = iph->saddr;
84 exp->tuple.dst.u.udp.port = uh->source;
85 exp->tuple.dst.protonum = IPPROTO_UDP;
86 78
87 memset(&exp->mask, 0, sizeof(exp->mask)); 79 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
80 exp->tuple.src.u.udp.port = ntohs(NMBD_PORT);
81
88 exp->mask.src.ip = mask; 82 exp->mask.src.ip = mask;
83 exp->mask.src.u.udp.port = 0xFFFF;
89 exp->mask.dst.ip = 0xFFFFFFFF; 84 exp->mask.dst.ip = 0xFFFFFFFF;
90 exp->mask.dst.u.udp.port = 0xFFFF; 85 exp->mask.dst.u.udp.port = 0xFFFF;
91 exp->mask.dst.protonum = 0xFF; 86 exp->mask.dst.protonum = 0xFF;
@@ -107,7 +102,7 @@ static struct ip_conntrack_helper helper = {
107 .src = { 102 .src = {
108 .u = { 103 .u = {
109 .udp = { 104 .udp = {
110 .port = __constant_htons(137), 105 .port = __constant_htons(NMBD_PORT),
111 } 106 }
112 } 107 }
113 }, 108 },
diff --git a/net/ipv4/netfilter/ip_conntrack_tftp.c b/net/ipv4/netfilter/ip_conntrack_tftp.c
index d2b590533452..a78736b8525d 100644
--- a/net/ipv4/netfilter/ip_conntrack_tftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_tftp.c
@@ -26,9 +26,9 @@ MODULE_DESCRIPTION("tftp connection tracking helper");
26MODULE_LICENSE("GPL"); 26MODULE_LICENSE("GPL");
27 27
28#define MAX_PORTS 8 28#define MAX_PORTS 8
29static int ports[MAX_PORTS]; 29static short ports[MAX_PORTS];
30static int ports_c; 30static int ports_c;
31module_param_array(ports, int, &ports_c, 0400); 31module_param_array(ports, short, &ports_c, 0400);
32MODULE_PARM_DESC(ports, "port numbers of tftp servers"); 32MODULE_PARM_DESC(ports, "port numbers of tftp servers");
33 33
34#if 0 34#if 0
@@ -100,7 +100,7 @@ static int tftp_help(struct sk_buff **pskb,
100} 100}
101 101
102static struct ip_conntrack_helper tftp[MAX_PORTS]; 102static struct ip_conntrack_helper tftp[MAX_PORTS];
103static char tftp_names[MAX_PORTS][10]; 103static char tftp_names[MAX_PORTS][sizeof("tftp-65535")];
104 104
105static void fini(void) 105static void fini(void)
106{ 106{
diff --git a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
index 2f3e181c8e97..275a174c6fe6 100644
--- a/net/ipv4/netfilter/ipt_MASQUERADE.c
+++ b/net/ipv4/netfilter/ipt_MASQUERADE.c
@@ -90,6 +90,12 @@ masquerade_target(struct sk_buff **pskb,
90 IP_NF_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED 90 IP_NF_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED
91 || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY)); 91 || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
92 92
93 /* Source address is 0.0.0.0 - locally generated packet that is
94 * probably not supposed to be masqueraded.
95 */
96 if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip == 0)
97 return NF_ACCEPT;
98
93 mr = targinfo; 99 mr = targinfo;
94 rt = (struct rtable *)(*pskb)->dst; 100 rt = (struct rtable *)(*pskb)->dst;
95 newsrc = inet_select_addr(out, rt->rt_gateway, RT_SCOPE_UNIVERSE); 101 newsrc = inet_select_addr(out, rt->rt_gateway, RT_SCOPE_UNIVERSE);
diff --git a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c
index d2e13447678e..715cb613405c 100644
--- a/net/ipv4/netfilter/ipt_REDIRECT.c
+++ b/net/ipv4/netfilter/ipt_REDIRECT.c
@@ -88,14 +88,18 @@ redirect_target(struct sk_buff **pskb,
88 newdst = htonl(0x7F000001); 88 newdst = htonl(0x7F000001);
89 else { 89 else {
90 struct in_device *indev; 90 struct in_device *indev;
91 struct in_ifaddr *ifa;
91 92
92 /* Device might not have an associated in_device. */ 93 newdst = 0;
93 indev = (struct in_device *)(*pskb)->dev->ip_ptr; 94
94 if (indev == NULL || indev->ifa_list == NULL) 95 rcu_read_lock();
95 return NF_DROP; 96 indev = __in_dev_get((*pskb)->dev);
97 if (indev && (ifa = indev->ifa_list))
98 newdst = ifa->ifa_local;
99 rcu_read_unlock();
96 100
97 /* Grab first address on interface. */ 101 if (!newdst)
98 newdst = indev->ifa_list->ifa_local; 102 return NF_DROP;
99 } 103 }
100 104
101 /* Transfer from original range. */ 105 /* Transfer from original range. */
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 5d1e61168eb7..6f20b4206e08 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -567,10 +567,8 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
567 self->tty = NULL; 567 self->tty = NULL;
568 568
569 if (self->blocked_open) { 569 if (self->blocked_open) {
570 if (self->close_delay) { 570 if (self->close_delay)
571 current->state = TASK_INTERRUPTIBLE; 571 schedule_timeout_interruptible(self->close_delay);
572 schedule_timeout(self->close_delay);
573 }
574 wake_up_interruptible(&self->open_wait); 572 wake_up_interruptible(&self->open_wait);
575 } 573 }
576 574
@@ -863,8 +861,7 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
863 spin_lock_irqsave(&self->spinlock, flags); 861 spin_lock_irqsave(&self->spinlock, flags);
864 while (self->tx_skb && self->tx_skb->len) { 862 while (self->tx_skb && self->tx_skb->len) {
865 spin_unlock_irqrestore(&self->spinlock, flags); 863 spin_unlock_irqrestore(&self->spinlock, flags);
866 current->state = TASK_INTERRUPTIBLE; 864 schedule_timeout_interruptible(poll_time);
867 schedule_timeout(poll_time);
868 spin_lock_irqsave(&self->spinlock, flags); 865 spin_lock_irqsave(&self->spinlock, flags);
869 if (signal_pending(current)) 866 if (signal_pending(current))
870 break; 867 break;
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index f4578c759ffc..e5d82d711cae 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -56,6 +56,7 @@ int sysctl_netrom_transport_requested_window_size = NR_DEFAULT_WINDOW;
56int sysctl_netrom_transport_no_activity_timeout = NR_DEFAULT_IDLE; 56int sysctl_netrom_transport_no_activity_timeout = NR_DEFAULT_IDLE;
57int sysctl_netrom_routing_control = NR_DEFAULT_ROUTING; 57int sysctl_netrom_routing_control = NR_DEFAULT_ROUTING;
58int sysctl_netrom_link_fails_count = NR_DEFAULT_FAILS; 58int sysctl_netrom_link_fails_count = NR_DEFAULT_FAILS;
59int sysctl_netrom_reset_circuit = NR_DEFAULT_RESET;
59 60
60static unsigned short circuit = 0x101; 61static unsigned short circuit = 0x101;
61 62
@@ -908,17 +909,17 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
908 if (frametype != NR_CONNREQ) { 909 if (frametype != NR_CONNREQ) {
909 /* 910 /*
910 * Here it would be nice to be able to send a reset but 911 * Here it would be nice to be able to send a reset but
911 * NET/ROM doesn't have one. The following hack would 912 * NET/ROM doesn't have one. We've tried to extend the protocol
912 * have been a way to extend the protocol but apparently 913 * by sending NR_CONNACK | NR_CHOKE_FLAGS replies but that
913 * it kills BPQ boxes... :-( 914 * apparently kills BPQ boxes... :-(
915 * So now we try to follow the established behaviour of
916 * G8PZT's Xrouter which is sending packets with command type 7
917 * as an extension of the protocol.
914 */ 918 */
915#if 0 919 if (sysctl_netrom_reset_circuit &&
916 /* 920 (frametype != NR_RESET || flags != 0))
917 * Never reply to a CONNACK/CHOKE. 921 nr_transmit_reset(skb, 1);
918 */ 922
919 if (frametype != NR_CONNACK || flags != NR_CHOKE_FLAG)
920 nr_transmit_refusal(skb, 1);
921#endif
922 return 0; 923 return 0;
923 } 924 }
924 925
@@ -1187,9 +1188,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1187 } 1188 }
1188 1189
1189 case SIOCGSTAMP: 1190 case SIOCGSTAMP:
1190 ret = -EINVAL; 1191 ret = sock_get_timestamp(sk, argp);
1191 if (sk != NULL)
1192 ret = sock_get_timestamp(sk, argp);
1193 release_sock(sk); 1192 release_sock(sk);
1194 return ret; 1193 return ret;
1195 1194
@@ -1393,8 +1392,7 @@ static int __init nr_proto_init(void)
1393 struct net_device *dev; 1392 struct net_device *dev;
1394 1393
1395 sprintf(name, "nr%d", i); 1394 sprintf(name, "nr%d", i);
1396 dev = alloc_netdev(sizeof(struct net_device_stats), name, 1395 dev = alloc_netdev(sizeof(struct nr_private), name, nr_setup);
1397 nr_setup);
1398 if (!dev) { 1396 if (!dev) {
1399 printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n"); 1397 printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n");
1400 goto fail; 1398 goto fail;
diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c
index 263da4c26494..4e66eef9a034 100644
--- a/net/netrom/nr_dev.c
+++ b/net/netrom/nr_dev.c
@@ -47,7 +47,7 @@ int nr_rx_ip(struct sk_buff *skb, struct net_device *dev)
47 struct net_device_stats *stats = netdev_priv(dev); 47 struct net_device_stats *stats = netdev_priv(dev);
48 48
49 if (!netif_running(dev)) { 49 if (!netif_running(dev)) {
50 stats->rx_errors++; 50 stats->rx_dropped++;
51 return 0; 51 return 0;
52 } 52 }
53 53
@@ -71,15 +71,10 @@ int nr_rx_ip(struct sk_buff *skb, struct net_device *dev)
71 71
72static int nr_rebuild_header(struct sk_buff *skb) 72static int nr_rebuild_header(struct sk_buff *skb)
73{ 73{
74 struct net_device *dev = skb->dev;
75 struct net_device_stats *stats = netdev_priv(dev);
76 struct sk_buff *skbn;
77 unsigned char *bp = skb->data; 74 unsigned char *bp = skb->data;
78 int len;
79 75
80 if (arp_find(bp + 7, skb)) { 76 if (arp_find(bp + 7, skb))
81 return 1; 77 return 1;
82 }
83 78
84 bp[6] &= ~AX25_CBIT; 79 bp[6] &= ~AX25_CBIT;
85 bp[6] &= ~AX25_EBIT; 80 bp[6] &= ~AX25_EBIT;
@@ -90,27 +85,7 @@ static int nr_rebuild_header(struct sk_buff *skb)
90 bp[6] |= AX25_EBIT; 85 bp[6] |= AX25_EBIT;
91 bp[6] |= AX25_SSSID_SPARE; 86 bp[6] |= AX25_SSSID_SPARE;
92 87
93 if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) { 88 return 0;
94 kfree_skb(skb);
95 return 1;
96 }
97
98 if (skb->sk != NULL)
99 skb_set_owner_w(skbn, skb->sk);
100
101 kfree_skb(skb);
102
103 len = skbn->len;
104
105 if (!nr_route_frame(skbn, NULL)) {
106 kfree_skb(skbn);
107 stats->tx_errors++;
108 }
109
110 stats->tx_packets++;
111 stats->tx_bytes += len;
112
113 return 1;
114} 89}
115 90
116#else 91#else
@@ -185,15 +160,27 @@ static int nr_close(struct net_device *dev)
185 160
186static int nr_xmit(struct sk_buff *skb, struct net_device *dev) 161static int nr_xmit(struct sk_buff *skb, struct net_device *dev)
187{ 162{
188 struct net_device_stats *stats = netdev_priv(dev); 163 struct nr_private *nr = netdev_priv(dev);
189 dev_kfree_skb(skb); 164 struct net_device_stats *stats = &nr->stats;
190 stats->tx_errors++; 165 unsigned int len = skb->len;
166
167 if (!nr_route_frame(skb, NULL)) {
168 kfree_skb(skb);
169 stats->tx_errors++;
170 return 0;
171 }
172
173 stats->tx_packets++;
174 stats->tx_bytes += len;
175
191 return 0; 176 return 0;
192} 177}
193 178
194static struct net_device_stats *nr_get_stats(struct net_device *dev) 179static struct net_device_stats *nr_get_stats(struct net_device *dev)
195{ 180{
196 return netdev_priv(dev); 181 struct nr_private *nr = netdev_priv(dev);
182
183 return &nr->stats;
197} 184}
198 185
199void nr_setup(struct net_device *dev) 186void nr_setup(struct net_device *dev)
@@ -208,12 +195,11 @@ void nr_setup(struct net_device *dev)
208 dev->hard_header_len = NR_NETWORK_LEN + NR_TRANSPORT_LEN; 195 dev->hard_header_len = NR_NETWORK_LEN + NR_TRANSPORT_LEN;
209 dev->addr_len = AX25_ADDR_LEN; 196 dev->addr_len = AX25_ADDR_LEN;
210 dev->type = ARPHRD_NETROM; 197 dev->type = ARPHRD_NETROM;
211 dev->tx_queue_len = 40;
212 dev->rebuild_header = nr_rebuild_header; 198 dev->rebuild_header = nr_rebuild_header;
213 dev->set_mac_address = nr_set_mac_address; 199 dev->set_mac_address = nr_set_mac_address;
214 200
215 /* New-style flags. */ 201 /* New-style flags. */
216 dev->flags = 0; 202 dev->flags = IFF_NOARP;
217 203
218 dev->get_stats = nr_get_stats; 204 dev->get_stats = nr_get_stats;
219} 205}
diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c
index 64b81a796907..004e8599b8fe 100644
--- a/net/netrom/nr_in.c
+++ b/net/netrom/nr_in.c
@@ -98,6 +98,11 @@ static int nr_state1_machine(struct sock *sk, struct sk_buff *skb,
98 nr_disconnect(sk, ECONNREFUSED); 98 nr_disconnect(sk, ECONNREFUSED);
99 break; 99 break;
100 100
101 case NR_RESET:
102 if (sysctl_netrom_reset_circuit);
103 nr_disconnect(sk, ECONNRESET);
104 break;
105
101 default: 106 default:
102 break; 107 break;
103 } 108 }
@@ -124,6 +129,11 @@ static int nr_state2_machine(struct sock *sk, struct sk_buff *skb,
124 nr_disconnect(sk, 0); 129 nr_disconnect(sk, 0);
125 break; 130 break;
126 131
132 case NR_RESET:
133 if (sysctl_netrom_reset_circuit);
134 nr_disconnect(sk, ECONNRESET);
135 break;
136
127 default: 137 default:
128 break; 138 break;
129 } 139 }
@@ -254,6 +264,11 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
254 } 264 }
255 break; 265 break;
256 266
267 case NR_RESET:
268 if (sysctl_netrom_reset_circuit);
269 nr_disconnect(sk, ECONNRESET);
270 break;
271
257 default: 272 default:
258 break; 273 break;
259 } 274 }
diff --git a/net/netrom/nr_subr.c b/net/netrom/nr_subr.c
index 587bed2674bf..bcb9946b4f56 100644
--- a/net/netrom/nr_subr.c
+++ b/net/netrom/nr_subr.c
@@ -210,10 +210,9 @@ void nr_write_internal(struct sock *sk, int frametype)
210} 210}
211 211
212/* 212/*
213 * This routine is called when a Connect Acknowledge with the Choke Flag 213 * This routine is called to send an error reply.
214 * set is needed to refuse a connection.
215 */ 214 */
216void nr_transmit_refusal(struct sk_buff *skb, int mine) 215void __nr_transmit_reply(struct sk_buff *skb, int mine, unsigned char cmdflags)
217{ 216{
218 struct sk_buff *skbn; 217 struct sk_buff *skbn;
219 unsigned char *dptr; 218 unsigned char *dptr;
@@ -254,7 +253,7 @@ void nr_transmit_refusal(struct sk_buff *skb, int mine)
254 *dptr++ = 0; 253 *dptr++ = 0;
255 } 254 }
256 255
257 *dptr++ = NR_CONNACK | NR_CHOKE_FLAG; 256 *dptr++ = cmdflags;
258 *dptr++ = 0; 257 *dptr++ = 0;
259 258
260 if (!nr_route_frame(skbn, NULL)) 259 if (!nr_route_frame(skbn, NULL))
diff --git a/net/netrom/sysctl_net_netrom.c b/net/netrom/sysctl_net_netrom.c
index c9ed50382ea7..6bb8dda849dc 100644
--- a/net/netrom/sysctl_net_netrom.c
+++ b/net/netrom/sysctl_net_netrom.c
@@ -30,6 +30,7 @@ static int min_idle[] = {0 * HZ};
30static int max_idle[] = {65535 * HZ}; 30static int max_idle[] = {65535 * HZ};
31static int min_route[] = {0}, max_route[] = {1}; 31static int min_route[] = {0}, max_route[] = {1};
32static int min_fails[] = {1}, max_fails[] = {10}; 32static int min_fails[] = {1}, max_fails[] = {10};
33static int min_reset[] = {0}, max_reset[] = {1};
33 34
34static struct ctl_table_header *nr_table_header; 35static struct ctl_table_header *nr_table_header;
35 36
@@ -155,6 +156,17 @@ static ctl_table nr_table[] = {
155 .extra1 = &min_fails, 156 .extra1 = &min_fails,
156 .extra2 = &max_fails 157 .extra2 = &max_fails
157 }, 158 },
159 {
160 .ctl_name = NET_NETROM_RESET,
161 .procname = "reset",
162 .data = &sysctl_netrom_reset_circuit,
163 .maxlen = sizeof(int),
164 .mode = 0644,
165 .proc_handler = &proc_dointvec_minmax,
166 .strategy = &sysctl_intvec,
167 .extra1 = &min_reset,
168 .extra2 = &max_reset
169 },
158 { .ctl_name = 0 } 170 { .ctl_name = 0 }
159}; 171};
160 172
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 3077878ed4f0..5acb1680524a 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1243,7 +1243,7 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1243 amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); 1243 amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
1244 if (amount < 0) 1244 if (amount < 0)
1245 amount = 0; 1245 amount = 0;
1246 return put_user(amount, (unsigned int __user *)argp); 1246 return put_user(amount, (unsigned int __user *) argp);
1247 } 1247 }
1248 1248
1249 case TIOCINQ: { 1249 case TIOCINQ: {
@@ -1252,13 +1252,11 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1252 /* These two are safe on a single CPU system as only user tasks fiddle here */ 1252 /* These two are safe on a single CPU system as only user tasks fiddle here */
1253 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) 1253 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL)
1254 amount = skb->len; 1254 amount = skb->len;
1255 return put_user(amount, (unsigned int __user *)argp); 1255 return put_user(amount, (unsigned int __user *) argp);
1256 } 1256 }
1257 1257
1258 case SIOCGSTAMP: 1258 case SIOCGSTAMP:
1259 if (sk != NULL) 1259 return sock_get_timestamp(sk, (struct timeval __user *) argp);
1260 return sock_get_timestamp(sk, (struct timeval __user *)argp);
1261 return -EINVAL;
1262 1260
1263 case SIOCGIFADDR: 1261 case SIOCGIFADDR:
1264 case SIOCSIFADDR: 1262 case SIOCSIFADDR:
diff --git a/net/rose/rose_dev.c b/net/rose/rose_dev.c
index a8ed9a1d09f9..d297af737d10 100644
--- a/net/rose/rose_dev.c
+++ b/net/rose/rose_dev.c
@@ -149,6 +149,6 @@ void rose_setup(struct net_device *dev)
149 dev->set_mac_address = rose_set_mac_address; 149 dev->set_mac_address = rose_set_mac_address;
150 150
151 /* New-style flags. */ 151 /* New-style flags. */
152 dev->flags = 0; 152 dev->flags = IFF_NOARP;
153 dev->get_stats = rose_get_stats; 153 dev->get_stats = rose_get_stats;
154} 154}
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 05fe2e735538..30ec3efc48a6 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -512,15 +512,14 @@ svc_sock_setbufsize(struct socket *sock, unsigned int snd, unsigned int rcv)
512static void 512static void
513svc_udp_data_ready(struct sock *sk, int count) 513svc_udp_data_ready(struct sock *sk, int count)
514{ 514{
515 struct svc_sock *svsk = (struct svc_sock *)(sk->sk_user_data); 515 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
516 516
517 if (!svsk) 517 if (svsk) {
518 goto out; 518 dprintk("svc: socket %p(inet %p), count=%d, busy=%d\n",
519 dprintk("svc: socket %p(inet %p), count=%d, busy=%d\n", 519 svsk, sk, count, test_bit(SK_BUSY, &svsk->sk_flags));
520 svsk, sk, count, test_bit(SK_BUSY, &svsk->sk_flags)); 520 set_bit(SK_DATA, &svsk->sk_flags);
521 set_bit(SK_DATA, &svsk->sk_flags); 521 svc_sock_enqueue(svsk);
522 svc_sock_enqueue(svsk); 522 }
523 out:
524 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 523 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
525 wake_up_interruptible(sk->sk_sleep); 524 wake_up_interruptible(sk->sk_sleep);
526} 525}
@@ -540,7 +539,7 @@ svc_write_space(struct sock *sk)
540 } 539 }
541 540
542 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) { 541 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) {
543 printk(KERN_WARNING "RPC svc_write_space: some sleeping on %p\n", 542 dprintk("RPC svc_write_space: someone sleeping on %p\n",
544 svsk); 543 svsk);
545 wake_up_interruptible(sk->sk_sleep); 544 wake_up_interruptible(sk->sk_sleep);
546 } 545 }
@@ -692,31 +691,29 @@ svc_udp_init(struct svc_sock *svsk)
692static void 691static void
693svc_tcp_listen_data_ready(struct sock *sk, int count_unused) 692svc_tcp_listen_data_ready(struct sock *sk, int count_unused)
694{ 693{
695 struct svc_sock *svsk; 694 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
696 695
697 dprintk("svc: socket %p TCP (listen) state change %d\n", 696 dprintk("svc: socket %p TCP (listen) state change %d\n",
698 sk, sk->sk_state); 697 sk, sk->sk_state);
699 698
700 if (sk->sk_state != TCP_LISTEN) { 699 /*
701 /* 700 * This callback may called twice when a new connection
702 * This callback may called twice when a new connection 701 * is established as a child socket inherits everything
703 * is established as a child socket inherits everything 702 * from a parent LISTEN socket.
704 * from a parent LISTEN socket. 703 * 1) data_ready method of the parent socket will be called
705 * 1) data_ready method of the parent socket will be called 704 * when one of child sockets become ESTABLISHED.
706 * when one of child sockets become ESTABLISHED. 705 * 2) data_ready method of the child socket may be called
707 * 2) data_ready method of the child socket may be called 706 * when it receives data before the socket is accepted.
708 * when it receives data before the socket is accepted. 707 * In case of 2, we should ignore it silently.
709 * In case of 2, we should ignore it silently. 708 */
710 */ 709 if (sk->sk_state == TCP_LISTEN) {
711 goto out; 710 if (svsk) {
712 } 711 set_bit(SK_CONN, &svsk->sk_flags);
713 if (!(svsk = (struct svc_sock *) sk->sk_user_data)) { 712 svc_sock_enqueue(svsk);
714 printk("svc: socket %p: no user data\n", sk); 713 } else
715 goto out; 714 printk("svc: socket %p: no user data\n", sk);
716 } 715 }
717 set_bit(SK_CONN, &svsk->sk_flags); 716
718 svc_sock_enqueue(svsk);
719 out:
720 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 717 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
721 wake_up_interruptible_all(sk->sk_sleep); 718 wake_up_interruptible_all(sk->sk_sleep);
722} 719}
@@ -727,18 +724,17 @@ svc_tcp_listen_data_ready(struct sock *sk, int count_unused)
727static void 724static void
728svc_tcp_state_change(struct sock *sk) 725svc_tcp_state_change(struct sock *sk)
729{ 726{
730 struct svc_sock *svsk; 727 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
731 728
732 dprintk("svc: socket %p TCP (connected) state change %d (svsk %p)\n", 729 dprintk("svc: socket %p TCP (connected) state change %d (svsk %p)\n",
733 sk, sk->sk_state, sk->sk_user_data); 730 sk, sk->sk_state, sk->sk_user_data);
734 731
735 if (!(svsk = (struct svc_sock *) sk->sk_user_data)) { 732 if (!svsk)
736 printk("svc: socket %p: no user data\n", sk); 733 printk("svc: socket %p: no user data\n", sk);
737 goto out; 734 else {
735 set_bit(SK_CLOSE, &svsk->sk_flags);
736 svc_sock_enqueue(svsk);
738 } 737 }
739 set_bit(SK_CLOSE, &svsk->sk_flags);
740 svc_sock_enqueue(svsk);
741 out:
742 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 738 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
743 wake_up_interruptible_all(sk->sk_sleep); 739 wake_up_interruptible_all(sk->sk_sleep);
744} 740}
@@ -746,15 +742,14 @@ svc_tcp_state_change(struct sock *sk)
746static void 742static void
747svc_tcp_data_ready(struct sock *sk, int count) 743svc_tcp_data_ready(struct sock *sk, int count)
748{ 744{
749 struct svc_sock * svsk; 745 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
750 746
751 dprintk("svc: socket %p TCP data ready (svsk %p)\n", 747 dprintk("svc: socket %p TCP data ready (svsk %p)\n",
752 sk, sk->sk_user_data); 748 sk, sk->sk_user_data);
753 if (!(svsk = (struct svc_sock *)(sk->sk_user_data))) 749 if (svsk) {
754 goto out; 750 set_bit(SK_DATA, &svsk->sk_flags);
755 set_bit(SK_DATA, &svsk->sk_flags); 751 svc_sock_enqueue(svsk);
756 svc_sock_enqueue(svsk); 752 }
757 out:
758 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 753 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
759 wake_up_interruptible(sk->sk_sleep); 754 wake_up_interruptible(sk->sk_sleep);
760} 755}
@@ -1170,8 +1165,7 @@ svc_recv(struct svc_serv *serv, struct svc_rqst *rqstp, long timeout)
1170 while (rqstp->rq_arghi < pages) { 1165 while (rqstp->rq_arghi < pages) {
1171 struct page *p = alloc_page(GFP_KERNEL); 1166 struct page *p = alloc_page(GFP_KERNEL);
1172 if (!p) { 1167 if (!p) {
1173 set_current_state(TASK_UNINTERRUPTIBLE); 1168 schedule_timeout_uninterruptible(msecs_to_jiffies(500));
1174 schedule_timeout(HZ/2);
1175 continue; 1169 continue;
1176 } 1170 }
1177 rqstp->rq_argpages[rqstp->rq_arghi++] = p; 1171 rqstp->rq_argpages[rqstp->rq_arghi++] = p;
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 09ffca54b373..3bed09e625c0 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -370,6 +370,12 @@ handle_modversions(struct module *mod, struct elf_info *info,
370 /* Ignore register directives. */ 370 /* Ignore register directives. */
371 if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER) 371 if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER)
372 break; 372 break;
373 if (symname[0] == '.') {
374 char *munged = strdup(symname);
375 munged[0] = '_';
376 munged[1] = toupper(munged[1]);
377 symname = munged;
378 }
373 } 379 }
374#endif 380#endif
375 381
diff --git a/security/Kconfig b/security/Kconfig
index dcf04a09185d..64d3f1e9ca85 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -35,6 +35,7 @@ config KEYS_DEBUG_PROC_KEYS
35 35
36config SECURITY 36config SECURITY
37 bool "Enable different security models" 37 bool "Enable different security models"
38 depends on SYSFS
38 help 39 help
39 This allows you to choose different security modules to be 40 This allows you to choose different security modules to be
40 configured into your kernel. 41 configured into your kernel.
diff --git a/security/Makefile b/security/Makefile
index 197cc2f3f1ec..8cbbf2f36709 100644
--- a/security/Makefile
+++ b/security/Makefile
@@ -11,7 +11,7 @@ obj-y += commoncap.o
11endif 11endif
12 12
13# Object file lists 13# Object file lists
14obj-$(CONFIG_SECURITY) += security.o dummy.o 14obj-$(CONFIG_SECURITY) += security.o dummy.o inode.o
15# Must precede capability.o in order to stack properly. 15# Must precede capability.o in order to stack properly.
16obj-$(CONFIG_SECURITY_SELINUX) += selinux/built-in.o 16obj-$(CONFIG_SECURITY_SELINUX) += selinux/built-in.o
17obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o 17obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o
diff --git a/security/inode.c b/security/inode.c
new file mode 100644
index 000000000000..a5964502ae30
--- /dev/null
+++ b/security/inode.c
@@ -0,0 +1,347 @@
1/*
2 * inode.c - securityfs
3 *
4 * Copyright (C) 2005 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * Based on fs/debugfs/inode.c which had the following copyright notice:
11 * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
12 * Copyright (C) 2004 IBM Inc.
13 */
14
15/* #define DEBUG */
16#include <linux/config.h>
17#include <linux/module.h>
18#include <linux/fs.h>
19#include <linux/mount.h>
20#include <linux/pagemap.h>
21#include <linux/init.h>
22#include <linux/namei.h>
23#include <linux/security.h>
24
25#define SECURITYFS_MAGIC 0x73636673
26
27static struct vfsmount *mount;
28static int mount_count;
29
30/*
31 * TODO:
32 * I think I can get rid of these default_file_ops, but not quite sure...
33 */
34static ssize_t default_read_file(struct file *file, char __user *buf,
35 size_t count, loff_t *ppos)
36{
37 return 0;
38}
39
40static ssize_t default_write_file(struct file *file, const char __user *buf,
41 size_t count, loff_t *ppos)
42{
43 return count;
44}
45
46static int default_open(struct inode *inode, struct file *file)
47{
48 if (inode->u.generic_ip)
49 file->private_data = inode->u.generic_ip;
50
51 return 0;
52}
53
54static struct file_operations default_file_ops = {
55 .read = default_read_file,
56 .write = default_write_file,
57 .open = default_open,
58};
59
60static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev)
61{
62 struct inode *inode = new_inode(sb);
63
64 if (inode) {
65 inode->i_mode = mode;
66 inode->i_uid = 0;
67 inode->i_gid = 0;
68 inode->i_blksize = PAGE_CACHE_SIZE;
69 inode->i_blocks = 0;
70 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
71 switch (mode & S_IFMT) {
72 default:
73 init_special_inode(inode, mode, dev);
74 break;
75 case S_IFREG:
76 inode->i_fop = &default_file_ops;
77 break;
78 case S_IFDIR:
79 inode->i_op = &simple_dir_inode_operations;
80 inode->i_fop = &simple_dir_operations;
81
82 /* directory inodes start off with i_nlink == 2 (for "." entry) */
83 inode->i_nlink++;
84 break;
85 }
86 }
87 return inode;
88}
89
90/* SMP-safe */
91static int mknod(struct inode *dir, struct dentry *dentry,
92 int mode, dev_t dev)
93{
94 struct inode *inode;
95 int error = -EPERM;
96
97 if (dentry->d_inode)
98 return -EEXIST;
99
100 inode = get_inode(dir->i_sb, mode, dev);
101 if (inode) {
102 d_instantiate(dentry, inode);
103 dget(dentry);
104 error = 0;
105 }
106 return error;
107}
108
109static int mkdir(struct inode *dir, struct dentry *dentry, int mode)
110{
111 int res;
112
113 mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
114 res = mknod(dir, dentry, mode, 0);
115 if (!res)
116 dir->i_nlink++;
117 return res;
118}
119
120static int create(struct inode *dir, struct dentry *dentry, int mode)
121{
122 mode = (mode & S_IALLUGO) | S_IFREG;
123 return mknod(dir, dentry, mode, 0);
124}
125
126static inline int positive(struct dentry *dentry)
127{
128 return dentry->d_inode && !d_unhashed(dentry);
129}
130
131static int fill_super(struct super_block *sb, void *data, int silent)
132{
133 static struct tree_descr files[] = {{""}};
134
135 return simple_fill_super(sb, SECURITYFS_MAGIC, files);
136}
137
138static struct super_block *get_sb(struct file_system_type *fs_type,
139 int flags, const char *dev_name,
140 void *data)
141{
142 return get_sb_single(fs_type, flags, data, fill_super);
143}
144
145static struct file_system_type fs_type = {
146 .owner = THIS_MODULE,
147 .name = "securityfs",
148 .get_sb = get_sb,
149 .kill_sb = kill_litter_super,
150};
151
152static int create_by_name(const char *name, mode_t mode,
153 struct dentry *parent,
154 struct dentry **dentry)
155{
156 int error = 0;
157
158 *dentry = NULL;
159
160 /* If the parent is not specified, we create it in the root.
161 * We need the root dentry to do this, which is in the super
162 * block. A pointer to that is in the struct vfsmount that we
163 * have around.
164 */
165 if (!parent ) {
166 if (mount && mount->mnt_sb) {
167 parent = mount->mnt_sb->s_root;
168 }
169 }
170 if (!parent) {
171 pr_debug("securityfs: Ah! can not find a parent!\n");
172 return -EFAULT;
173 }
174
175 down(&parent->d_inode->i_sem);
176 *dentry = lookup_one_len(name, parent, strlen(name));
177 if (!IS_ERR(dentry)) {
178 if ((mode & S_IFMT) == S_IFDIR)
179 error = mkdir(parent->d_inode, *dentry, mode);
180 else
181 error = create(parent->d_inode, *dentry, mode);
182 } else
183 error = PTR_ERR(dentry);
184 up(&parent->d_inode->i_sem);
185
186 return error;
187}
188
189/**
190 * securityfs_create_file - create a file in the securityfs filesystem
191 *
192 * @name: a pointer to a string containing the name of the file to create.
193 * @mode: the permission that the file should have
194 * @parent: a pointer to the parent dentry for this file. This should be a
195 * directory dentry if set. If this paramater is NULL, then the
196 * file will be created in the root of the securityfs filesystem.
197 * @data: a pointer to something that the caller will want to get to later
198 * on. The inode.u.generic_ip pointer will point to this value on
199 * the open() call.
200 * @fops: a pointer to a struct file_operations that should be used for
201 * this file.
202 *
203 * This is the basic "create a file" function for securityfs. It allows for a
204 * wide range of flexibility in createing a file, or a directory (if you
205 * want to create a directory, the securityfs_create_dir() function is
206 * recommended to be used instead.)
207 *
208 * This function will return a pointer to a dentry if it succeeds. This
209 * pointer must be passed to the securityfs_remove() function when the file is
210 * to be removed (no automatic cleanup happens if your module is unloaded,
211 * you are responsible here.) If an error occurs, NULL will be returned.
212 *
213 * If securityfs is not enabled in the kernel, the value -ENODEV will be
214 * returned. It is not wise to check for this value, but rather, check for
215 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling
216 * code.
217 */
218struct dentry *securityfs_create_file(const char *name, mode_t mode,
219 struct dentry *parent, void *data,
220 struct file_operations *fops)
221{
222 struct dentry *dentry = NULL;
223 int error;
224
225 pr_debug("securityfs: creating file '%s'\n",name);
226
227 error = simple_pin_fs("securityfs", &mount, &mount_count);
228 if (error) {
229 dentry = ERR_PTR(error);
230 goto exit;
231 }
232
233 error = create_by_name(name, mode, parent, &dentry);
234 if (error) {
235 dentry = ERR_PTR(error);
236 simple_release_fs(&mount, &mount_count);
237 goto exit;
238 }
239
240 if (dentry->d_inode) {
241 if (fops)
242 dentry->d_inode->i_fop = fops;
243 if (data)
244 dentry->d_inode->u.generic_ip = data;
245 }
246exit:
247 return dentry;
248}
249EXPORT_SYMBOL_GPL(securityfs_create_file);
250
251/**
252 * securityfs_create_dir - create a directory in the securityfs filesystem
253 *
254 * @name: a pointer to a string containing the name of the directory to
255 * create.
256 * @parent: a pointer to the parent dentry for this file. This should be a
257 * directory dentry if set. If this paramater is NULL, then the
258 * directory will be created in the root of the securityfs filesystem.
259 *
260 * This function creates a directory in securityfs with the given name.
261 *
262 * This function will return a pointer to a dentry if it succeeds. This
263 * pointer must be passed to the securityfs_remove() function when the file is
264 * to be removed (no automatic cleanup happens if your module is unloaded,
265 * you are responsible here.) If an error occurs, NULL will be returned.
266 *
267 * If securityfs is not enabled in the kernel, the value -ENODEV will be
268 * returned. It is not wise to check for this value, but rather, check for
269 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling
270 * code.
271 */
272struct dentry *securityfs_create_dir(const char *name, struct dentry *parent)
273{
274 return securityfs_create_file(name,
275 S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
276 parent, NULL, NULL);
277}
278EXPORT_SYMBOL_GPL(securityfs_create_dir);
279
280/**
281 * securityfs_remove - removes a file or directory from the securityfs filesystem
282 *
283 * @dentry: a pointer to a the dentry of the file or directory to be
284 * removed.
285 *
286 * This function removes a file or directory in securityfs that was previously
287 * created with a call to another securityfs function (like
288 * securityfs_create_file() or variants thereof.)
289 *
290 * This function is required to be called in order for the file to be
291 * removed, no automatic cleanup of files will happen when a module is
292 * removed, you are responsible here.
293 */
294void securityfs_remove(struct dentry *dentry)
295{
296 struct dentry *parent;
297
298 if (!dentry)
299 return;
300
301 parent = dentry->d_parent;
302 if (!parent || !parent->d_inode)
303 return;
304
305 down(&parent->d_inode->i_sem);
306 if (positive(dentry)) {
307 if (dentry->d_inode) {
308 if (S_ISDIR(dentry->d_inode->i_mode))
309 simple_rmdir(parent->d_inode, dentry);
310 else
311 simple_unlink(parent->d_inode, dentry);
312 dput(dentry);
313 }
314 }
315 up(&parent->d_inode->i_sem);
316 simple_release_fs(&mount, &mount_count);
317}
318EXPORT_SYMBOL_GPL(securityfs_remove);
319
320static decl_subsys(security, NULL, NULL);
321
322static int __init securityfs_init(void)
323{
324 int retval;
325
326 kset_set_kset_s(&security_subsys, kernel_subsys);
327 retval = subsystem_register(&security_subsys);
328 if (retval)
329 return retval;
330
331 retval = register_filesystem(&fs_type);
332 if (retval)
333 subsystem_unregister(&security_subsys);
334 return retval;
335}
336
337static void __exit securityfs_exit(void)
338{
339 simple_release_fs(&mount, &mount_count);
340 unregister_filesystem(&fs_type);
341 subsystem_unregister(&security_subsys);
342}
343
344core_initcall(securityfs_init);
345module_exit(securityfs_exit);
346MODULE_LICENSE("GPL");
347
diff --git a/security/seclvl.c b/security/seclvl.c
index 96b1f2122f67..dc4e17b6eaf6 100644
--- a/security/seclvl.c
+++ b/security/seclvl.c
@@ -119,69 +119,6 @@ MODULE_PARM_DESC(hideHash, "When set to 0, reading seclvl/passwd from sysfs "
119 } while (0) 119 } while (0)
120 120
121/** 121/**
122 * kobject stuff
123 */
124
125struct subsystem seclvl_subsys;
126
127struct seclvl_obj {
128 char *name;
129 struct list_head slot_list;
130 struct kobject kobj;
131};
132
133/**
134 * There is a seclvl_attribute struct for each file in sysfs.
135 *
136 * In our case, we have one of these structs for "passwd" and another
137 * for "seclvl".
138 */
139struct seclvl_attribute {
140 struct attribute attr;
141 ssize_t(*show) (struct seclvl_obj *, char *);
142 ssize_t(*store) (struct seclvl_obj *, const char *, size_t);
143};
144
145/**
146 * When this function is called, one of the files in sysfs is being
147 * written to. attribute->store is a function pointer to whatever the
148 * struct seclvl_attribute store function pointer points to. It is
149 * unique for "passwd" and "seclvl".
150 */
151static ssize_t
152seclvl_attr_store(struct kobject *kobj,
153 struct attribute *attr, const char *buf, size_t len)
154{
155 struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj);
156 struct seclvl_attribute *attribute =
157 container_of(attr, struct seclvl_attribute, attr);
158 return attribute->store ? attribute->store(obj, buf, len) : -EIO;
159}
160
161static ssize_t
162seclvl_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
163{
164 struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj);
165 struct seclvl_attribute *attribute =
166 container_of(attr, struct seclvl_attribute, attr);
167 return attribute->show ? attribute->show(obj, buf) : -EIO;
168}
169
170/**
171 * Callback function pointers for show and store
172 */
173static struct sysfs_ops seclvlfs_sysfs_ops = {
174 .show = seclvl_attr_show,
175 .store = seclvl_attr_store,
176};
177
178static struct kobj_type seclvl_ktype = {
179 .sysfs_ops = &seclvlfs_sysfs_ops
180};
181
182decl_subsys(seclvl, &seclvl_ktype, NULL);
183
184/**
185 * The actual security level. Ranges between -1 and 2 inclusive. 122 * The actual security level. Ranges between -1 and 2 inclusive.
186 */ 123 */
187static int seclvl; 124static int seclvl;
@@ -213,97 +150,44 @@ static int seclvl_sanity(int reqlvl)
213} 150}
214 151
215/** 152/**
216 * Called whenever the user reads the sysfs handle to this kernel
217 * object
218 */
219static ssize_t seclvl_read_file(struct seclvl_obj *obj, char *buff)
220{
221 return snprintf(buff, PAGE_SIZE, "%d\n", seclvl);
222}
223
224/**
225 * security level advancement rules: 153 * security level advancement rules:
226 * Valid levels are -1 through 2, inclusive. 154 * Valid levels are -1 through 2, inclusive.
227 * From -1, stuck. [ in case compiled into kernel ] 155 * From -1, stuck. [ in case compiled into kernel ]
228 * From 0 or above, can only increment. 156 * From 0 or above, can only increment.
229 */ 157 */
230static int do_seclvl_advance(int newlvl) 158static void do_seclvl_advance(void *data, u64 val)
231{ 159{
232 if (newlvl <= seclvl) { 160 int ret;
233 seclvl_printk(1, KERN_WARNING, "Cannot advance to seclvl " 161 int newlvl = (int)val;
234 "[%d]\n", newlvl); 162
235 return -EINVAL; 163 ret = seclvl_sanity(newlvl);
236 } 164 if (ret)
165 return;
166
237 if (newlvl > 2) { 167 if (newlvl > 2) {
238 seclvl_printk(1, KERN_WARNING, "Cannot advance to seclvl " 168 seclvl_printk(1, KERN_WARNING, "Cannot advance to seclvl "
239 "[%d]\n", newlvl); 169 "[%d]\n", newlvl);
240 return -EINVAL; 170 return;
241 } 171 }
242 if (seclvl == -1) { 172 if (seclvl == -1) {
243 seclvl_printk(1, KERN_WARNING, "Not allowed to advance to " 173 seclvl_printk(1, KERN_WARNING, "Not allowed to advance to "
244 "seclvl [%d]\n", seclvl); 174 "seclvl [%d]\n", seclvl);
245 return -EPERM; 175 return;
246 } 176 }
247 seclvl = newlvl; 177 seclvl = newlvl; /* would it be more "correct" to set *data? */
248 return 0; 178 return;
249} 179}
250 180
251/** 181static u64 seclvl_int_get(void *data)
252 * Called whenever the user writes to the sysfs handle to this kernel
253 * object (seclvl/seclvl). It expects a single-digit number.
254 */
255static ssize_t
256seclvl_write_file(struct seclvl_obj *obj, const char *buff, size_t count)
257{ 182{
258 unsigned long val; 183 return *(int *)data;
259 if (count > 2 || (count == 2 && buff[1] != '\n')) {
260 seclvl_printk(1, KERN_WARNING, "Invalid value passed to "
261 "seclvl: [%s]\n", buff);
262 return -EINVAL;
263 }
264 val = buff[0] - 48;
265 if (seclvl_sanity(val)) {
266 seclvl_printk(1, KERN_WARNING, "Illegal secure level "
267 "requested: [%d]\n", (int)val);
268 return -EPERM;
269 }
270 if (do_seclvl_advance(val)) {
271 seclvl_printk(0, KERN_ERR, "Failure advancing security level "
272 "to %lu\n", val);
273 }
274 return count;
275} 184}
276 185
277/* Generate sysfs_attr_seclvl */ 186DEFINE_SIMPLE_ATTRIBUTE(seclvl_file_ops, seclvl_int_get, do_seclvl_advance, "%lld\n");
278static struct seclvl_attribute sysfs_attr_seclvl =
279__ATTR(seclvl, (S_IFREG | S_IRUGO | S_IWUSR), seclvl_read_file,
280 seclvl_write_file);
281 187
282static unsigned char hashedPassword[SHA1_DIGEST_SIZE]; 188static unsigned char hashedPassword[SHA1_DIGEST_SIZE];
283 189
284/** 190/**
285 * Called whenever the user reads the sysfs passwd handle.
286 */
287static ssize_t seclvl_read_passwd(struct seclvl_obj *obj, char *buff)
288{
289 /* So just how good *is* your password? :-) */
290 char tmp[3];
291 int i = 0;
292 buff[0] = '\0';
293 if (hideHash) {
294 /* Security through obscurity */
295 return 0;
296 }
297 while (i < SHA1_DIGEST_SIZE) {
298 snprintf(tmp, 3, "%02x", hashedPassword[i]);
299 strncat(buff, tmp, 2);
300 i++;
301 }
302 strcat(buff, "\n");
303 return ((SHA1_DIGEST_SIZE * 2) + 1);
304}
305
306/**
307 * Converts a block of plaintext of into its SHA1 hashed value. 191 * Converts a block of plaintext of into its SHA1 hashed value.
308 * 192 *
309 * It would be nice if crypto had a wrapper to do this for us linear 193 * It would be nice if crypto had a wrapper to do this for us linear
@@ -347,12 +231,15 @@ plaintext_to_sha1(unsigned char *hash, const char *plaintext, int len)
347 * object. It hashes the password and compares the hashed results. 231 * object. It hashes the password and compares the hashed results.
348 */ 232 */
349static ssize_t 233static ssize_t
350seclvl_write_passwd(struct seclvl_obj *obj, const char *buff, size_t count) 234passwd_write_file(struct file * file, const char __user * buf,
235 size_t count, loff_t *ppos)
351{ 236{
352 int i; 237 int i;
353 unsigned char tmp[SHA1_DIGEST_SIZE]; 238 unsigned char tmp[SHA1_DIGEST_SIZE];
239 char *page;
354 int rc; 240 int rc;
355 int len; 241 int len;
242
356 if (!*passwd && !*sha1_passwd) { 243 if (!*passwd && !*sha1_passwd) {
357 seclvl_printk(0, KERN_ERR, "Attempt to password-unlock the " 244 seclvl_printk(0, KERN_ERR, "Attempt to password-unlock the "
358 "seclvl module, but neither a plain text " 245 "seclvl module, but neither a plain text "
@@ -363,13 +250,26 @@ seclvl_write_passwd(struct seclvl_obj *obj, const char *buff, size_t count)
363 "maintainer about this event.\n"); 250 "maintainer about this event.\n");
364 return -EINVAL; 251 return -EINVAL;
365 } 252 }
366 len = strlen(buff); 253
254 if (count < 0 || count >= PAGE_SIZE)
255 return -ENOMEM;
256 if (*ppos != 0) {
257 return -EINVAL;
258 }
259 page = (char *)get_zeroed_page(GFP_KERNEL);
260 if (!page)
261 return -ENOMEM;
262 len = -EFAULT;
263 if (copy_from_user(page, buf, count))
264 goto out;
265
266 len = strlen(page);
367 /* ``echo "secret" > seclvl/passwd'' includes a newline */ 267 /* ``echo "secret" > seclvl/passwd'' includes a newline */
368 if (buff[len - 1] == '\n') { 268 if (page[len - 1] == '\n') {
369 len--; 269 len--;
370 } 270 }
371 /* Hash the password, then compare the hashed values */ 271 /* Hash the password, then compare the hashed values */
372 if ((rc = plaintext_to_sha1(tmp, buff, len))) { 272 if ((rc = plaintext_to_sha1(tmp, page, len))) {
373 seclvl_printk(0, KERN_ERR, "Error hashing password: rc = " 273 seclvl_printk(0, KERN_ERR, "Error hashing password: rc = "
374 "[%d]\n", rc); 274 "[%d]\n", rc);
375 return rc; 275 return rc;
@@ -382,13 +282,16 @@ seclvl_write_passwd(struct seclvl_obj *obj, const char *buff, size_t count)
382 seclvl_printk(0, KERN_INFO, 282 seclvl_printk(0, KERN_INFO,
383 "Password accepted; seclvl reduced to 0.\n"); 283 "Password accepted; seclvl reduced to 0.\n");
384 seclvl = 0; 284 seclvl = 0;
385 return count; 285 len = count;
286
287out:
288 free_page((unsigned long)page);
289 return len;
386} 290}
387 291
388/* Generate sysfs_attr_passwd */ 292static struct file_operations passwd_file_ops = {
389static struct seclvl_attribute sysfs_attr_passwd = 293 .write = passwd_write_file,
390__ATTR(passwd, (S_IFREG | S_IRUGO | S_IWUSR), seclvl_read_passwd, 294};
391 seclvl_write_passwd);
392 295
393/** 296/**
394 * Explicitely disallow ptrace'ing the init process. 297 * Explicitely disallow ptrace'ing the init process.
@@ -647,22 +550,34 @@ static int processPassword(void)
647} 550}
648 551
649/** 552/**
650 * Sysfs registrations 553 * securityfs registrations
651 */ 554 */
652static int doSysfsRegistrations(void) 555struct dentry *dir_ino, *seclvl_ino, *passwd_ino;
556
557static int seclvlfs_register(void)
653{ 558{
654 int rc = 0; 559 dir_ino = securityfs_create_dir("seclvl", NULL);
655 if ((rc = subsystem_register(&seclvl_subsys))) { 560 if (!dir_ino)
656 seclvl_printk(0, KERN_WARNING, 561 return -EFAULT;
657 "Error [%d] registering seclvl subsystem\n", rc); 562
658 return rc; 563 seclvl_ino = securityfs_create_file("seclvl", S_IRUGO | S_IWUSR,
659 } 564 dir_ino, &seclvl, &seclvl_file_ops);
660 sysfs_create_file(&seclvl_subsys.kset.kobj, &sysfs_attr_seclvl.attr); 565 if (!seclvl_ino)
566 goto out_deldir;
661 if (*passwd || *sha1_passwd) { 567 if (*passwd || *sha1_passwd) {
662 sysfs_create_file(&seclvl_subsys.kset.kobj, 568 passwd_ino = securityfs_create_file("passwd", S_IRUGO | S_IWUSR,
663 &sysfs_attr_passwd.attr); 569 dir_ino, NULL, &passwd_file_ops);
570 if (!passwd_ino)
571 goto out_delf;
664 } 572 }
665 return 0; 573 return 0;
574
575out_deldir:
576 securityfs_remove(dir_ino);
577out_delf:
578 securityfs_remove(seclvl_ino);
579
580 return -EFAULT;
666} 581}
667 582
668/** 583/**
@@ -677,8 +592,6 @@ static int __init seclvl_init(void)
677 rc = -EINVAL; 592 rc = -EINVAL;
678 goto exit; 593 goto exit;
679 } 594 }
680 sysfs_attr_seclvl.attr.owner = THIS_MODULE;
681 sysfs_attr_passwd.attr.owner = THIS_MODULE;
682 if (initlvl < -1 || initlvl > 2) { 595 if (initlvl < -1 || initlvl > 2) {
683 seclvl_printk(0, KERN_ERR, "Error: bad initial securelevel " 596 seclvl_printk(0, KERN_ERR, "Error: bad initial securelevel "
684 "[%d].\n", initlvl); 597 "[%d].\n", initlvl);
@@ -706,7 +619,7 @@ static int __init seclvl_init(void)
706 } /* if primary module registered */ 619 } /* if primary module registered */
707 secondary = 1; 620 secondary = 1;
708 } /* if we registered ourselves with the security framework */ 621 } /* if we registered ourselves with the security framework */
709 if ((rc = doSysfsRegistrations())) { 622 if ((rc = seclvlfs_register())) {
710 seclvl_printk(0, KERN_ERR, "Error registering with sysfs\n"); 623 seclvl_printk(0, KERN_ERR, "Error registering with sysfs\n");
711 goto exit; 624 goto exit;
712 } 625 }
@@ -724,12 +637,11 @@ static int __init seclvl_init(void)
724 */ 637 */
725static void __exit seclvl_exit(void) 638static void __exit seclvl_exit(void)
726{ 639{
727 sysfs_remove_file(&seclvl_subsys.kset.kobj, &sysfs_attr_seclvl.attr); 640 securityfs_remove(seclvl_ino);
728 if (*passwd || *sha1_passwd) { 641 if (*passwd || *sha1_passwd) {
729 sysfs_remove_file(&seclvl_subsys.kset.kobj, 642 securityfs_remove(passwd_ino);
730 &sysfs_attr_passwd.attr);
731 } 643 }
732 subsystem_unregister(&seclvl_subsys); 644 securityfs_remove(dir_ino);
733 if (secondary == 1) { 645 if (secondary == 1) {
734 mod_unreg_security(MY_NAME, &seclvl_ops); 646 mod_unreg_security(MY_NAME, &seclvl_ops);
735 } else if (unregister_security(&seclvl_ops)) { 647 } else if (unregister_security(&seclvl_ops)) {
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index cf6020f85403..12e4fb72bf0f 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -242,7 +242,7 @@ void __init avc_init(void)
242 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node), 242 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
243 0, SLAB_PANIC, NULL, NULL); 243 0, SLAB_PANIC, NULL, NULL);
244 244
245 audit_log(current->audit_context, AUDIT_KERNEL, "AVC INITIALIZED\n"); 245 audit_log(current->audit_context, GFP_KERNEL, AUDIT_KERNEL, "AVC INITIALIZED\n");
246} 246}
247 247
248int avc_get_hash_stats(char *page) 248int avc_get_hash_stats(char *page)
@@ -550,7 +550,7 @@ void avc_audit(u32 ssid, u32 tsid,
550 return; 550 return;
551 } 551 }
552 552
553 ab = audit_log_start(current->audit_context, AUDIT_AVC); 553 ab = audit_log_start(current->audit_context, GFP_ATOMIC, AUDIT_AVC);
554 if (!ab) 554 if (!ab)
555 return; /* audit_panic has been called */ 555 return; /* audit_panic has been called */
556 audit_log_format(ab, "avc: %s ", denied ? "denied" : "granted"); 556 audit_log_format(ab, "avc: %s ", denied ? "denied" : "granted");
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index f40c8221ec1b..6e4937fe062b 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3389,7 +3389,7 @@ static int selinux_nlmsg_perm(struct sock *sk, struct sk_buff *skb)
3389 err = selinux_nlmsg_lookup(isec->sclass, nlh->nlmsg_type, &perm); 3389 err = selinux_nlmsg_lookup(isec->sclass, nlh->nlmsg_type, &perm);
3390 if (err) { 3390 if (err) {
3391 if (err == -EINVAL) { 3391 if (err == -EINVAL) {
3392 audit_log(current->audit_context, AUDIT_SELINUX_ERR, 3392 audit_log(current->audit_context, GFP_KERNEL, AUDIT_SELINUX_ERR,
3393 "SELinux: unrecognized netlink message" 3393 "SELinux: unrecognized netlink message"
3394 " type=%hu for sclass=%hu\n", 3394 " type=%hu for sclass=%hu\n",
3395 nlh->nlmsg_type, isec->sclass); 3395 nlh->nlmsg_type, isec->sclass);
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 92b89dc99bcd..aecdded55e74 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -381,7 +381,7 @@ static int security_validtrans_handle_fail(struct context *ocontext,
381 goto out; 381 goto out;
382 if (context_struct_to_string(tcontext, &t, &tlen) < 0) 382 if (context_struct_to_string(tcontext, &t, &tlen) < 0)
383 goto out; 383 goto out;
384 audit_log(current->audit_context, AUDIT_SELINUX_ERR, 384 audit_log(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR,
385 "security_validate_transition: denied for" 385 "security_validate_transition: denied for"
386 " oldcontext=%s newcontext=%s taskcontext=%s tclass=%s", 386 " oldcontext=%s newcontext=%s taskcontext=%s tclass=%s",
387 o, n, t, policydb.p_class_val_to_name[tclass-1]); 387 o, n, t, policydb.p_class_val_to_name[tclass-1]);
@@ -787,7 +787,7 @@ static int compute_sid_handle_invalid_context(
787 goto out; 787 goto out;
788 if (context_struct_to_string(newcontext, &n, &nlen) < 0) 788 if (context_struct_to_string(newcontext, &n, &nlen) < 0)
789 goto out; 789 goto out;
790 audit_log(current->audit_context, AUDIT_SELINUX_ERR, 790 audit_log(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR,
791 "security_compute_sid: invalid context %s" 791 "security_compute_sid: invalid context %s"
792 " for scontext=%s" 792 " for scontext=%s"
793 " tcontext=%s" 793 " tcontext=%s"
diff --git a/sound/arm/Kconfig b/sound/arm/Kconfig
index 2e4a5e0d16db..0864a7ce414d 100644
--- a/sound/arm/Kconfig
+++ b/sound/arm/Kconfig
@@ -7,6 +7,7 @@ config SND_SA11XX_UDA1341
7 tristate "SA11xx UDA1341TS driver (iPaq H3600)" 7 tristate "SA11xx UDA1341TS driver (iPaq H3600)"
8 depends on ARCH_SA1100 && SND && L3 8 depends on ARCH_SA1100 && SND && L3
9 select SND_PCM 9 select SND_PCM
10 select SND_GENERIC_DRIVER
10 help 11 help
11 Say Y here if you have a Compaq iPaq H3x00 handheld computer 12 Say Y here if you have a Compaq iPaq H3x00 handheld computer
12 and want to use its Philips UDA 1341 audio chip. 13 and want to use its Philips UDA 1341 audio chip.
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 98877030d579..34195b748608 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -900,6 +900,8 @@ static int __devinit aaci_probe(struct amba_device *dev, void *id)
900 if (ret) 900 if (ret)
901 goto out; 901 goto out;
902 902
903 snd_card_set_dev(aaci->card, &dev->dev);
904
903 ret = snd_card_register(aaci->card); 905 ret = snd_card_register(aaci->card);
904 if (ret == 0) { 906 if (ret == 0) {
905 dev_info(&dev->dev, "%s, fifo %d\n", aaci->card->longname, 907 dev_info(&dev->dev, "%s, fifo %d\n", aaci->card->longname,
diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
index 174bc032d1ad..6ee912259cc5 100644
--- a/sound/arm/sa11xx-uda1341.c
+++ b/sound/arm/sa11xx-uda1341.c
@@ -21,7 +21,7 @@
21 * merged HAL layer (patches from Brian) 21 * merged HAL layer (patches from Brian)
22 */ 22 */
23 23
24/* $Id: sa11xx-uda1341.c,v 1.21 2005/01/28 19:34:04 tiwai Exp $ */ 24/* $Id: sa11xx-uda1341.c,v 1.23 2005/09/09 13:22:34 tiwai Exp $ */
25 25
26/*************************************************************************************************** 26/***************************************************************************************************
27* 27*
@@ -918,7 +918,7 @@ static int __init sa11xx_uda1341_init(void)
918 if (card == NULL) 918 if (card == NULL)
919 return -ENOMEM; 919 return -ENOMEM;
920 920
921 sa11xx_uda1341 = kcalloc(1, sizeof(*sa11xx_uda1341), GFP_KERNEL); 921 sa11xx_uda1341 = kzalloc(sizeof(*sa11xx_uda1341), GFP_KERNEL);
922 if (sa11xx_uda1341 == NULL) 922 if (sa11xx_uda1341 == NULL)
923 return -ENOMEM; 923 return -ENOMEM;
924 spin_lock_init(&chip->s[0].dma_lock); 924 spin_lock_init(&chip->s[0].dma_lock);
@@ -946,6 +946,9 @@ static int __init sa11xx_uda1341_init(void)
946 strcpy(card->shortname, "H3600 UDA1341TS"); 946 strcpy(card->shortname, "H3600 UDA1341TS");
947 sprintf(card->longname, "Compaq iPAQ H3600 with Philips UDA1341TS"); 947 sprintf(card->longname, "Compaq iPAQ H3600 with Philips UDA1341TS");
948 948
949 if ((err = snd_card_set_generic_dev(card)) < 0)
950 goto nodev;
951
949 if ((err = snd_card_register(card)) == 0) { 952 if ((err = snd_card_register(card)) == 0) {
950 printk( KERN_INFO "iPAQ audio support initialized\n" ); 953 printk( KERN_INFO "iPAQ audio support initialized\n" );
951 return 0; 954 return 0;
diff --git a/sound/core/Kconfig b/sound/core/Kconfig
index d1e800b9866d..48cf45cfd0b7 100644
--- a/sound/core/Kconfig
+++ b/sound/core/Kconfig
@@ -99,6 +99,18 @@ config SND_RTCTIMER
99 To compile this driver as a module, choose M here: the module 99 To compile this driver as a module, choose M here: the module
100 will be called snd-rtctimer. 100 will be called snd-rtctimer.
101 101
102config SND_SEQ_RTCTIMER_DEFAULT
103 bool "Use RTC as default sequencer timer"
104 depends on SND_RTCTIMER && SND_SEQUENCER
105 default y
106 help
107 Say Y here to use the RTC timer as the default sequencer
108 timer. This is strongly recommended because it ensures
109 precise MIDI timing even when the system timer runs at less
110 than 1000 Hz.
111
112 If in doubt, say Y.
113
102config SND_VERBOSE_PRINTK 114config SND_VERBOSE_PRINTK
103 bool "Verbose printk" 115 bool "Verbose printk"
104 depends on SND 116 depends on SND
@@ -128,6 +140,6 @@ config SND_DEBUG_DETECT
128 Say Y here to enable extra-verbose log messages printed when 140 Say Y here to enable extra-verbose log messages printed when
129 detecting devices. 141 detecting devices.
130 142
131config SND_GENERIC_PM 143config SND_GENERIC_DRIVER
132 bool 144 bool
133 depends on SND 145 depends on SND
diff --git a/sound/core/control.c b/sound/core/control.c
index 227f3cf02771..736edf358e05 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -69,7 +69,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
69 err = -EFAULT; 69 err = -EFAULT;
70 goto __error2; 70 goto __error2;
71 } 71 }
72 ctl = kcalloc(1, sizeof(*ctl), GFP_KERNEL); 72 ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
73 if (ctl == NULL) { 73 if (ctl == NULL) {
74 err = -ENOMEM; 74 err = -ENOMEM;
75 goto __error; 75 goto __error;
@@ -162,7 +162,7 @@ void snd_ctl_notify(snd_card_t *card, unsigned int mask, snd_ctl_elem_id_t *id)
162 goto _found; 162 goto _found;
163 } 163 }
164 } 164 }
165 ev = kcalloc(1, sizeof(*ev), GFP_ATOMIC); 165 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
166 if (ev) { 166 if (ev) {
167 ev->id = *id; 167 ev->id = *id;
168 ev->mask = mask; 168 ev->mask = mask;
@@ -195,7 +195,7 @@ snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * control, unsigned int access)
195 195
196 snd_runtime_check(control != NULL, return NULL); 196 snd_runtime_check(control != NULL, return NULL);
197 snd_runtime_check(control->count > 0, return NULL); 197 snd_runtime_check(control->count > 0, return NULL);
198 kctl = kcalloc(1, sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL); 198 kctl = kzalloc(sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL);
199 if (kctl == NULL) 199 if (kctl == NULL)
200 return NULL; 200 return NULL;
201 *kctl = *control; 201 *kctl = *control;
@@ -521,7 +521,7 @@ static int snd_ctl_card_info(snd_card_t * card, snd_ctl_file_t * ctl,
521{ 521{
522 snd_ctl_card_info_t *info; 522 snd_ctl_card_info_t *info;
523 523
524 info = kcalloc(1, sizeof(*info), GFP_KERNEL); 524 info = kzalloc(sizeof(*info), GFP_KERNEL);
525 if (! info) 525 if (! info)
526 return -ENOMEM; 526 return -ENOMEM;
527 down_read(&snd_ioctl_rwsem); 527 down_read(&snd_ioctl_rwsem);
@@ -929,7 +929,7 @@ static int snd_ctl_elem_add(snd_ctl_file_t *file, snd_ctl_elem_info_t *info, int
929 return -EINVAL; 929 return -EINVAL;
930 } 930 }
931 private_size *= info->count; 931 private_size *= info->count;
932 ue = kcalloc(1, sizeof(struct user_element) + private_size, GFP_KERNEL); 932 ue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL);
933 if (ue == NULL) 933 if (ue == NULL)
934 return -ENOMEM; 934 return -ENOMEM;
935 ue->info = *info; 935 ue->info = *info;
@@ -1185,7 +1185,7 @@ static int _snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn, struct list_head *
1185{ 1185{
1186 snd_kctl_ioctl_t *pn; 1186 snd_kctl_ioctl_t *pn;
1187 1187
1188 pn = kcalloc(1, sizeof(snd_kctl_ioctl_t), GFP_KERNEL); 1188 pn = kzalloc(sizeof(snd_kctl_ioctl_t), GFP_KERNEL);
1189 if (pn == NULL) 1189 if (pn == NULL)
1190 return -ENOMEM; 1190 return -ENOMEM;
1191 pn->fioctl = fcn; 1191 pn->fioctl = fcn;
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 7fdabea4bfc8..207c7de5129c 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -92,7 +92,7 @@ static int snd_ctl_elem_info_compat(snd_ctl_file_t *ctl, struct sndrv_ctl_elem_i
92 struct sndrv_ctl_elem_info *data; 92 struct sndrv_ctl_elem_info *data;
93 int err; 93 int err;
94 94
95 data = kcalloc(1, sizeof(*data), GFP_KERNEL); 95 data = kzalloc(sizeof(*data), GFP_KERNEL);
96 if (! data) 96 if (! data)
97 return -ENOMEM; 97 return -ENOMEM;
98 98
@@ -271,7 +271,7 @@ static int snd_ctl_elem_read_user_compat(snd_card_t *card,
271 struct sndrv_ctl_elem_value *data; 271 struct sndrv_ctl_elem_value *data;
272 int err, type, count; 272 int err, type, count;
273 273
274 data = kcalloc(1, sizeof(*data), GFP_KERNEL); 274 data = kzalloc(sizeof(*data), GFP_KERNEL);
275 if (data == NULL) 275 if (data == NULL)
276 return -ENOMEM; 276 return -ENOMEM;
277 277
@@ -291,7 +291,7 @@ static int snd_ctl_elem_write_user_compat(snd_ctl_file_t *file,
291 struct sndrv_ctl_elem_value *data; 291 struct sndrv_ctl_elem_value *data;
292 int err, type, count; 292 int err, type, count;
293 293
294 data = kcalloc(1, sizeof(*data), GFP_KERNEL); 294 data = kzalloc(sizeof(*data), GFP_KERNEL);
295 if (data == NULL) 295 if (data == NULL)
296 return -ENOMEM; 296 return -ENOMEM;
297 297
@@ -313,7 +313,7 @@ static int snd_ctl_elem_add_compat(snd_ctl_file_t *file,
313 struct sndrv_ctl_elem_info *data; 313 struct sndrv_ctl_elem_info *data;
314 int err; 314 int err;
315 315
316 data = kcalloc(1, sizeof(*data), GFP_KERNEL); 316 data = kzalloc(sizeof(*data), GFP_KERNEL);
317 if (! data) 317 if (! data)
318 return -ENOMEM; 318 return -ENOMEM;
319 319
diff --git a/sound/core/device.c b/sound/core/device.c
index ca00ad7740c9..1f509f56e60c 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -49,7 +49,7 @@ int snd_device_new(snd_card_t *card, snd_device_type_t type,
49 snd_assert(card != NULL, return -ENXIO); 49 snd_assert(card != NULL, return -ENXIO);
50 snd_assert(device_data != NULL, return -ENXIO); 50 snd_assert(device_data != NULL, return -ENXIO);
51 snd_assert(ops != NULL, return -ENXIO); 51 snd_assert(ops != NULL, return -ENXIO);
52 dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); 52 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
53 if (dev == NULL) 53 if (dev == NULL)
54 return -ENOMEM; 54 return -ENOMEM;
55 dev->card = card; 55 dev->card = card;
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 997dd41c584e..9383f1294fb5 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -359,7 +359,7 @@ int snd_hwdep_new(snd_card_t * card, char *id, int device, snd_hwdep_t ** rhwdep
359 snd_assert(rhwdep != NULL, return -EINVAL); 359 snd_assert(rhwdep != NULL, return -EINVAL);
360 *rhwdep = NULL; 360 *rhwdep = NULL;
361 snd_assert(card != NULL, return -ENXIO); 361 snd_assert(card != NULL, return -ENXIO);
362 hwdep = kcalloc(1, sizeof(*hwdep), GFP_KERNEL); 362 hwdep = kzalloc(sizeof(*hwdep), GFP_KERNEL);
363 if (hwdep == NULL) 363 if (hwdep == NULL)
364 return -ENOMEM; 364 return -ENOMEM;
365 hwdep->card = card; 365 hwdep->card = card;
diff --git a/sound/core/info.c b/sound/core/info.c
index 7f8bdf7b0058..37024d68a26e 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -295,7 +295,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
295 goto __error; 295 goto __error;
296 } 296 }
297 } 297 }
298 data = kcalloc(1, sizeof(*data), GFP_KERNEL); 298 data = kzalloc(sizeof(*data), GFP_KERNEL);
299 if (data == NULL) { 299 if (data == NULL) {
300 err = -ENOMEM; 300 err = -ENOMEM;
301 goto __error; 301 goto __error;
@@ -304,7 +304,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
304 switch (entry->content) { 304 switch (entry->content) {
305 case SNDRV_INFO_CONTENT_TEXT: 305 case SNDRV_INFO_CONTENT_TEXT:
306 if (mode == O_RDONLY || mode == O_RDWR) { 306 if (mode == O_RDONLY || mode == O_RDWR) {
307 buffer = kcalloc(1, sizeof(*buffer), GFP_KERNEL); 307 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
308 if (buffer == NULL) { 308 if (buffer == NULL) {
309 kfree(data); 309 kfree(data);
310 err = -ENOMEM; 310 err = -ENOMEM;
@@ -323,7 +323,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
323 data->rbuffer = buffer; 323 data->rbuffer = buffer;
324 } 324 }
325 if (mode == O_WRONLY || mode == O_RDWR) { 325 if (mode == O_WRONLY || mode == O_RDWR) {
326 buffer = kcalloc(1, sizeof(*buffer), GFP_KERNEL); 326 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
327 if (buffer == NULL) { 327 if (buffer == NULL) {
328 if (mode == O_RDWR) { 328 if (mode == O_RDWR) {
329 vfree(data->rbuffer->buffer); 329 vfree(data->rbuffer->buffer);
@@ -752,7 +752,7 @@ char *snd_info_get_str(char *dest, char *src, int len)
752static snd_info_entry_t *snd_info_create_entry(const char *name) 752static snd_info_entry_t *snd_info_create_entry(const char *name)
753{ 753{
754 snd_info_entry_t *entry; 754 snd_info_entry_t *entry;
755 entry = kcalloc(1, sizeof(*entry), GFP_KERNEL); 755 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
756 if (entry == NULL) 756 if (entry == NULL)
757 return NULL; 757 return NULL;
758 entry->name = kstrdup(name, GFP_KERNEL); 758 entry->name = kstrdup(name, GFP_KERNEL);
diff --git a/sound/core/init.c b/sound/core/init.c
index d72f58f450ce..a5702014a704 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -72,7 +72,7 @@ snd_card_t *snd_card_new(int idx, const char *xid,
72 72
73 if (extra_size < 0) 73 if (extra_size < 0)
74 extra_size = 0; 74 extra_size = 0;
75 card = kcalloc(1, sizeof(*card) + extra_size, GFP_KERNEL); 75 card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL);
76 if (card == NULL) 76 if (card == NULL)
77 return NULL; 77 return NULL;
78 if (xid) { 78 if (xid) {
@@ -226,8 +226,10 @@ int snd_card_disconnect(snd_card_t * card)
226 return 0; 226 return 0;
227} 227}
228 228
229#if defined(CONFIG_PM) && defined(CONFIG_SND_GENERIC_PM) 229#ifdef CONFIG_SND_GENERIC_DRIVER
230static void snd_generic_device_unregister(struct snd_generic_device *dev); 230static void snd_generic_device_unregister(snd_card_t *card);
231#else
232#define snd_generic_device_unregister(x) /*NOP*/
231#endif 233#endif
232 234
233/** 235/**
@@ -253,14 +255,7 @@ int snd_card_free(snd_card_t * card)
253 255
254#ifdef CONFIG_PM 256#ifdef CONFIG_PM
255 wake_up(&card->power_sleep); 257 wake_up(&card->power_sleep);
256#ifdef CONFIG_SND_GENERIC_PM
257 if (card->pm_dev) {
258 snd_generic_device_unregister(card->pm_dev);
259 card->pm_dev = NULL;
260 }
261#endif
262#endif 258#endif
263
264 /* wait, until all devices are ready for the free operation */ 259 /* wait, until all devices are ready for the free operation */
265 wait_event(card->shutdown_sleep, card->files == NULL); 260 wait_event(card->shutdown_sleep, card->files == NULL);
266 261
@@ -288,6 +283,7 @@ int snd_card_free(snd_card_t * card)
288 snd_printk(KERN_WARNING "unable to free card info\n"); 283 snd_printk(KERN_WARNING "unable to free card info\n");
289 /* Not fatal error */ 284 /* Not fatal error */
290 } 285 }
286 snd_generic_device_unregister(card);
291 while (card->s_f_ops) { 287 while (card->s_f_ops) {
292 s_f_ops = card->s_f_ops; 288 s_f_ops = card->s_f_ops;
293 card->s_f_ops = s_f_ops->next; 289 card->s_f_ops = s_f_ops->next;
@@ -665,6 +661,96 @@ int snd_card_file_remove(snd_card_t *card, struct file *file)
665 return 0; 661 return 0;
666} 662}
667 663
664#ifdef CONFIG_SND_GENERIC_DRIVER
665/*
666 * generic device without a proper bus using platform_device
667 * (e.g. ISA)
668 */
669struct snd_generic_device {
670 struct platform_device pdev;
671 snd_card_t *card;
672};
673
674#define get_snd_generic_card(dev) container_of(to_platform_device(dev), struct snd_generic_device, pdev)->card
675
676#define SND_GENERIC_NAME "snd_generic"
677
678#ifdef CONFIG_PM
679static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level);
680static int snd_generic_resume(struct device *dev, u32 level);
681#endif
682
683/* initialized in sound.c */
684struct device_driver snd_generic_driver = {
685 .name = SND_GENERIC_NAME,
686 .bus = &platform_bus_type,
687#ifdef CONFIG_PM
688 .suspend = snd_generic_suspend,
689 .resume = snd_generic_resume,
690#endif
691};
692
693void snd_generic_device_release(struct device *dev)
694{
695}
696
697static int snd_generic_device_register(snd_card_t *card)
698{
699 struct snd_generic_device *dev;
700 int err;
701
702 if (card->generic_dev)
703 return 0; /* already registered */
704
705 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
706 if (! dev) {
707 snd_printk(KERN_ERR "can't allocate generic_device\n");
708 return -ENOMEM;
709 }
710
711 dev->pdev.name = SND_GENERIC_NAME;
712 dev->pdev.id = card->number;
713 dev->pdev.dev.release = snd_generic_device_release;
714 dev->card = card;
715 if ((err = platform_device_register(&dev->pdev)) < 0) {
716 kfree(dev);
717 return err;
718 }
719 card->generic_dev = dev;
720 return 0;
721}
722
723static void snd_generic_device_unregister(snd_card_t *card)
724{
725 struct snd_generic_device *dev = card->generic_dev;
726 if (dev) {
727 platform_device_unregister(&dev->pdev);
728 kfree(dev);
729 card->generic_dev = NULL;
730 }
731}
732
733/**
734 * snd_card_set_generic_dev - assign the generic device to the card
735 * @card: soundcard structure
736 *
737 * Assigns a generic device to the card. This function is provided as the
738 * last resort, for devices without any proper bus. Thus this won't override
739 * the device already assigned to the card.
740 *
741 * Returns zero if successful, or a negative error code.
742 */
743int snd_card_set_generic_dev(snd_card_t *card)
744{
745 int err;
746 if ((err = snd_generic_device_register(card)) < 0)
747 return err;
748 if (! card->dev)
749 snd_card_set_dev(card, &card->generic_dev->pdev.dev);
750 return 0;
751}
752#endif /* CONFIG_SND_GENERIC_DRIVER */
753
668#ifdef CONFIG_PM 754#ifdef CONFIG_PM
669/** 755/**
670 * snd_power_wait - wait until the power-state is changed. 756 * snd_power_wait - wait until the power-state is changed.
@@ -730,75 +816,7 @@ int snd_card_set_pm_callback(snd_card_t *card,
730 return 0; 816 return 0;
731} 817}
732 818
733#ifdef CONFIG_SND_GENERIC_PM 819#ifdef CONFIG_SND_GENERIC_DRIVER
734/*
735 * use platform_device for generic power-management without a proper bus
736 * (e.g. ISA)
737 */
738struct snd_generic_device {
739 struct platform_device pdev;
740 snd_card_t *card;
741};
742
743#define get_snd_generic_card(dev) container_of(to_platform_device(dev), struct snd_generic_device, pdev)->card
744
745#define SND_GENERIC_NAME "snd_generic_pm"
746
747static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level);
748static int snd_generic_resume(struct device *dev, u32 level);
749
750static struct device_driver snd_generic_driver = {
751 .name = SND_GENERIC_NAME,
752 .bus = &platform_bus_type,
753 .suspend = snd_generic_suspend,
754 .resume = snd_generic_resume,
755};
756
757static int generic_driver_registered;
758
759static void generic_driver_unregister(void)
760{
761 if (generic_driver_registered) {
762 generic_driver_registered--;
763 if (! generic_driver_registered)
764 driver_unregister(&snd_generic_driver);
765 }
766}
767
768static struct snd_generic_device *snd_generic_device_register(snd_card_t *card)
769{
770 struct snd_generic_device *dev;
771
772 if (! generic_driver_registered) {
773 if (driver_register(&snd_generic_driver) < 0)
774 return NULL;
775 }
776 generic_driver_registered++;
777
778 dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
779 if (! dev) {
780 generic_driver_unregister();
781 return NULL;
782 }
783
784 dev->pdev.name = SND_GENERIC_NAME;
785 dev->pdev.id = card->number;
786 dev->card = card;
787 if (platform_device_register(&dev->pdev) < 0) {
788 kfree(dev);
789 generic_driver_unregister();
790 return NULL;
791 }
792 return dev;
793}
794
795static void snd_generic_device_unregister(struct snd_generic_device *dev)
796{
797 platform_device_unregister(&dev->pdev);
798 kfree(dev);
799 generic_driver_unregister();
800}
801
802/* suspend/resume callbacks for snd_generic platform device */ 820/* suspend/resume callbacks for snd_generic platform device */
803static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level) 821static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level)
804{ 822{
@@ -846,13 +864,12 @@ int snd_card_set_generic_pm_callback(snd_card_t *card,
846 int (*resume)(snd_card_t *), 864 int (*resume)(snd_card_t *),
847 void *private_data) 865 void *private_data)
848{ 866{
849 card->pm_dev = snd_generic_device_register(card); 867 int err;
850 if (! card->pm_dev) 868 if ((err = snd_generic_device_register(card)) < 0)
851 return -ENOMEM; 869 return err;
852 snd_card_set_pm_callback(card, suspend, resume, private_data); 870 return snd_card_set_pm_callback(card, suspend, resume, private_data);
853 return 0;
854} 871}
855#endif /* CONFIG_SND_GENERIC_PM */ 872#endif /* CONFIG_SND_GENERIC_DRIVER */
856 873
857#ifdef CONFIG_PCI 874#ifdef CONFIG_PCI
858int snd_card_pci_suspend(struct pci_dev *dev, pm_message_t state) 875int snd_card_pci_suspend(struct pci_dev *dev, pm_message_t state)
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index 39a54a415528..91124ddbdda9 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -590,7 +590,7 @@ static int snd_mem_proc_write(struct file *file, const char __user *buffer,
590 590
591 alloced = 0; 591 alloced = 0;
592 pci = NULL; 592 pci = NULL;
593 while ((pci = pci_find_device(vendor, device, pci)) != NULL) { 593 while ((pci = pci_get_device(vendor, device, pci)) != NULL) {
594 if (mask > 0 && mask < 0xffffffff) { 594 if (mask > 0 && mask < 0xffffffff) {
595 if (pci_set_dma_mask(pci, mask) < 0 || 595 if (pci_set_dma_mask(pci, mask) < 0 ||
596 pci_set_consistent_dma_mask(pci, mask) < 0) { 596 pci_set_consistent_dma_mask(pci, mask) < 0) {
@@ -604,6 +604,7 @@ static int snd_mem_proc_write(struct file *file, const char __user *buffer,
604 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 604 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
605 size, &dmab) < 0) { 605 size, &dmab) < 0) {
606 printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size); 606 printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size);
607 pci_dev_put(pci);
607 return (int)count; 608 return (int)count;
608 } 609 }
609 snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci)); 610 snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci));
diff --git a/sound/core/memory.c b/sound/core/memory.c
index 291b4769bde3..8fa888fc53a0 100644
--- a/sound/core/memory.c
+++ b/sound/core/memory.c
@@ -249,7 +249,7 @@ int __exit snd_memory_info_done(void)
249int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count) 249int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count)
250{ 250{
251#if defined(__i386__) || defined(CONFIG_SPARC32) 251#if defined(__i386__) || defined(CONFIG_SPARC32)
252 return copy_to_user(dst, (const void*)src, count) ? -EFAULT : 0; 252 return copy_to_user(dst, (const void __force*)src, count) ? -EFAULT : 0;
253#else 253#else
254 char buf[256]; 254 char buf[256];
255 while (count) { 255 while (count) {
@@ -280,7 +280,7 @@ int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size
280int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count) 280int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count)
281{ 281{
282#if defined(__i386__) || defined(CONFIG_SPARC32) 282#if defined(__i386__) || defined(CONFIG_SPARC32)
283 return copy_from_user((void*)dst, src, count) ? -EFAULT : 0; 283 return copy_from_user((void __force *)dst, src, count) ? -EFAULT : 0;
284#else 284#else
285 char buf[256]; 285 char buf[256];
286 while (count) { 286 while (count) {
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index 98fc0766f885..69e1059112d1 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -53,7 +53,7 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
53 err = snd_card_file_add(card, file); 53 err = snd_card_file_add(card, file);
54 if (err < 0) 54 if (err < 0)
55 return err; 55 return err;
56 fmixer = kcalloc(1, sizeof(*fmixer), GFP_KERNEL); 56 fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL);
57 if (fmixer == NULL) { 57 if (fmixer == NULL) {
58 snd_card_file_remove(card, file); 58 snd_card_file_remove(card, file);
59 return -ENOMEM; 59 return -ENOMEM;
@@ -517,8 +517,8 @@ static void snd_mixer_oss_get_volume1_vol(snd_mixer_oss_file_t *fmixer,
517 up_read(&card->controls_rwsem); 517 up_read(&card->controls_rwsem);
518 return; 518 return;
519 } 519 }
520 uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); 520 uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
521 uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); 521 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
522 if (uinfo == NULL || uctl == NULL) 522 if (uinfo == NULL || uctl == NULL)
523 goto __unalloc; 523 goto __unalloc;
524 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); 524 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
@@ -551,8 +551,8 @@ static void snd_mixer_oss_get_volume1_sw(snd_mixer_oss_file_t *fmixer,
551 up_read(&card->controls_rwsem); 551 up_read(&card->controls_rwsem);
552 return; 552 return;
553 } 553 }
554 uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); 554 uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
555 uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); 555 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
556 if (uinfo == NULL || uctl == NULL) 556 if (uinfo == NULL || uctl == NULL)
557 goto __unalloc; 557 goto __unalloc;
558 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); 558 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
@@ -612,8 +612,8 @@ static void snd_mixer_oss_put_volume1_vol(snd_mixer_oss_file_t *fmixer,
612 down_read(&card->controls_rwsem); 612 down_read(&card->controls_rwsem);
613 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) 613 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL)
614 return; 614 return;
615 uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); 615 uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
616 uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); 616 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
617 if (uinfo == NULL || uctl == NULL) 617 if (uinfo == NULL || uctl == NULL)
618 goto __unalloc; 618 goto __unalloc;
619 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); 619 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
@@ -649,8 +649,8 @@ static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer,
649 up_read(&fmixer->card->controls_rwsem); 649 up_read(&fmixer->card->controls_rwsem);
650 return; 650 return;
651 } 651 }
652 uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); 652 uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
653 uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); 653 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
654 if (uinfo == NULL || uctl == NULL) 654 if (uinfo == NULL || uctl == NULL)
655 goto __unalloc; 655 goto __unalloc;
656 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); 656 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
@@ -768,8 +768,8 @@ static int snd_mixer_oss_get_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int
768 snd_ctl_elem_value_t *uctl; 768 snd_ctl_elem_value_t *uctl;
769 int err, idx; 769 int err, idx;
770 770
771 uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); 771 uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
772 uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); 772 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
773 if (uinfo == NULL || uctl == NULL) { 773 if (uinfo == NULL || uctl == NULL) {
774 err = -ENOMEM; 774 err = -ENOMEM;
775 goto __unlock; 775 goto __unlock;
@@ -813,8 +813,8 @@ static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int
813 int err; 813 int err;
814 unsigned int idx; 814 unsigned int idx;
815 815
816 uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); 816 uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
817 uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); 817 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
818 if (uinfo == NULL || uctl == NULL) { 818 if (uinfo == NULL || uctl == NULL) {
819 err = -ENOMEM; 819 err = -ENOMEM;
820 goto __unlock; 820 goto __unlock;
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index a13bd7bb4c9f..842c28b2ed55 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -850,7 +850,9 @@ static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char __u
850 return xfer > 0 ? xfer : -EAGAIN; 850 return xfer > 0 ? xfer : -EAGAIN;
851 } 851 }
852 } else { 852 } else {
853 tmp = snd_pcm_oss_write2(substream, (const char *)buf, runtime->oss.period_bytes, 0); 853 tmp = snd_pcm_oss_write2(substream,
854 (const char __force *)buf,
855 runtime->oss.period_bytes, 0);
854 if (tmp <= 0) 856 if (tmp <= 0)
855 return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; 857 return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
856 runtime->oss.bytes += tmp; 858 runtime->oss.bytes += tmp;
@@ -926,7 +928,8 @@ static ssize_t snd_pcm_oss_read1(snd_pcm_substream_t *substream, char __user *bu
926 xfer += tmp; 928 xfer += tmp;
927 runtime->oss.buffer_used -= tmp; 929 runtime->oss.buffer_used -= tmp;
928 } else { 930 } else {
929 tmp = snd_pcm_oss_read2(substream, (char *)buf, runtime->oss.period_bytes, 0); 931 tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
932 runtime->oss.period_bytes, 0);
930 if (tmp <= 0) 933 if (tmp <= 0)
931 return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; 934 return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
932 runtime->oss.bytes += tmp; 935 runtime->oss.bytes += tmp;
@@ -1540,7 +1543,11 @@ static int snd_pcm_oss_get_ptr(snd_pcm_oss_file_t *pcm_oss_file, int stream, str
1540 } else { 1543 } else {
1541 delay = snd_pcm_oss_bytes(substream, delay); 1544 delay = snd_pcm_oss_bytes(substream, delay);
1542 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 1545 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
1543 info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes; 1546 snd_pcm_oss_setup_t *setup = substream->oss.setup;
1547 if (setup && setup->buggyptr)
1548 info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes;
1549 else
1550 info.blocks = (delay + fixup) / runtime->oss.period_bytes;
1544 info.bytes = (runtime->oss.bytes - delay) & INT_MAX; 1551 info.bytes = (runtime->oss.bytes - delay) & INT_MAX;
1545 } else { 1552 } else {
1546 delay += fixup; 1553 delay += fixup;
@@ -1733,7 +1740,7 @@ static int snd_pcm_oss_open_file(struct file *file,
1733 snd_assert(rpcm_oss_file != NULL, return -EINVAL); 1740 snd_assert(rpcm_oss_file != NULL, return -EINVAL);
1734 *rpcm_oss_file = NULL; 1741 *rpcm_oss_file = NULL;
1735 1742
1736 pcm_oss_file = kcalloc(1, sizeof(*pcm_oss_file), GFP_KERNEL); 1743 pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL);
1737 if (pcm_oss_file == NULL) 1744 if (pcm_oss_file == NULL)
1738 return -ENOMEM; 1745 return -ENOMEM;
1739 1746
@@ -2347,6 +2354,8 @@ static void snd_pcm_oss_proc_write(snd_info_entry_t *entry,
2347 template.partialfrag = 1; 2354 template.partialfrag = 1;
2348 } else if (!strcmp(str, "no-silence")) { 2355 } else if (!strcmp(str, "no-silence")) {
2349 template.nosilence = 1; 2356 template.nosilence = 1;
2357 } else if (!strcmp(str, "buggy-ptr")) {
2358 template.buggyptr = 1;
2350 } 2359 }
2351 } while (*str); 2360 } while (*str);
2352 if (setup == NULL) { 2361 if (setup == NULL) {
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index 6430410c6c04..fc23373c000d 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -171,7 +171,7 @@ int snd_pcm_plugin_build(snd_pcm_plug_t *plug,
171 171
172 snd_assert(plug != NULL, return -ENXIO); 172 snd_assert(plug != NULL, return -ENXIO);
173 snd_assert(src_format != NULL && dst_format != NULL, return -ENXIO); 173 snd_assert(src_format != NULL && dst_format != NULL, return -ENXIO);
174 plugin = kcalloc(1, sizeof(*plugin) + extra, GFP_KERNEL); 174 plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL);
175 if (plugin == NULL) 175 if (plugin == NULL)
176 return -ENOMEM; 176 return -ENOMEM;
177 plugin->name = name; 177 plugin->name = name;
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 9f4c9209b271..1be470e942ef 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -597,7 +597,7 @@ int snd_pcm_new_stream(snd_pcm_t *pcm, int stream, int substream_count)
597 } 597 }
598 prev = NULL; 598 prev = NULL;
599 for (idx = 0, prev = NULL; idx < substream_count; idx++) { 599 for (idx = 0, prev = NULL; idx < substream_count; idx++) {
600 substream = kcalloc(1, sizeof(*substream), GFP_KERNEL); 600 substream = kzalloc(sizeof(*substream), GFP_KERNEL);
601 if (substream == NULL) 601 if (substream == NULL)
602 return -ENOMEM; 602 return -ENOMEM;
603 substream->pcm = pcm; 603 substream->pcm = pcm;
@@ -657,7 +657,7 @@ int snd_pcm_new(snd_card_t * card, char *id, int device,
657 snd_assert(rpcm != NULL, return -EINVAL); 657 snd_assert(rpcm != NULL, return -EINVAL);
658 *rpcm = NULL; 658 *rpcm = NULL;
659 snd_assert(card != NULL, return -ENXIO); 659 snd_assert(card != NULL, return -ENXIO);
660 pcm = kcalloc(1, sizeof(*pcm), GFP_KERNEL); 660 pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
661 if (pcm == NULL) 661 if (pcm == NULL)
662 return -ENOMEM; 662 return -ENOMEM;
663 pcm->card = card; 663 pcm->card = card;
@@ -795,7 +795,7 @@ int snd_pcm_open_substream(snd_pcm_t *pcm, int stream,
795 if (substream == NULL) 795 if (substream == NULL)
796 return -EAGAIN; 796 return -EAGAIN;
797 797
798 runtime = kcalloc(1, sizeof(*runtime), GFP_KERNEL); 798 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
799 if (runtime == NULL) 799 if (runtime == NULL)
800 return -ENOMEM; 800 return -ENOMEM;
801 801
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 0082914a7e33..0503980c23d9 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -524,6 +524,9 @@ void snd_interval_mul(const snd_interval_t *a, const snd_interval_t *b, snd_inte
524 524
525/** 525/**
526 * snd_interval_div - refine the interval value with division 526 * snd_interval_div - refine the interval value with division
527 * @a: dividend
528 * @b: divisor
529 * @c: quotient
527 * 530 *
528 * c = a / b 531 * c = a / b
529 * 532 *
@@ -555,7 +558,11 @@ void snd_interval_div(const snd_interval_t *a, const snd_interval_t *b, snd_inte
555 558
556/** 559/**
557 * snd_interval_muldivk - refine the interval value 560 * snd_interval_muldivk - refine the interval value
558 * 561 * @a: dividend 1
562 * @b: dividend 2
563 * @k: divisor (as integer)
564 * @c: result
565 *
559 * c = a * b / k 566 * c = a * b / k
560 * 567 *
561 * Returns non-zero if the value is changed, zero if not changed. 568 * Returns non-zero if the value is changed, zero if not changed.
@@ -582,6 +589,10 @@ void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b,
582 589
583/** 590/**
584 * snd_interval_mulkdiv - refine the interval value 591 * snd_interval_mulkdiv - refine the interval value
592 * @a: dividend 1
593 * @k: dividend 2 (as integer)
594 * @b: divisor
595 * @c: result
585 * 596 *
586 * c = a * k / b 597 * c = a * k / b
587 * 598 *
@@ -618,6 +629,11 @@ void snd_interval_mulkdiv(const snd_interval_t *a, unsigned int k,
618 629
619/** 630/**
620 * snd_interval_ratnum - refine the interval value 631 * snd_interval_ratnum - refine the interval value
632 * @i: interval to refine
633 * @rats_count: number of ratnum_t
634 * @rats: ratnum_t array
635 * @nump: pointer to store the resultant numerator
636 * @denp: pointer to store the resultant denominator
621 * 637 *
622 * Returns non-zero if the value is changed, zero if not changed. 638 * Returns non-zero if the value is changed, zero if not changed.
623 */ 639 */
@@ -715,6 +731,11 @@ int snd_interval_ratnum(snd_interval_t *i,
715 731
716/** 732/**
717 * snd_interval_ratden - refine the interval value 733 * snd_interval_ratden - refine the interval value
734 * @i: interval to refine
735 * @rats_count: number of ratden_t
736 * @rats: ratden_t array
737 * @nump: pointer to store the resultant numerator
738 * @denp: pointer to store the resultant denominator
718 * 739 *
719 * Returns non-zero if the value is changed, zero if not changed. 740 * Returns non-zero if the value is changed, zero if not changed.
720 */ 741 */
@@ -936,6 +957,11 @@ int snd_pcm_hw_rule_add(snd_pcm_runtime_t *runtime, unsigned int cond,
936 957
937/** 958/**
938 * snd_pcm_hw_constraint_mask 959 * snd_pcm_hw_constraint_mask
960 * @runtime: PCM runtime instance
961 * @var: hw_params variable to apply the mask
962 * @mask: the bitmap mask
963 *
964 * Apply the constraint of the given bitmap mask to a mask parameter.
939 */ 965 */
940int snd_pcm_hw_constraint_mask(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, 966int snd_pcm_hw_constraint_mask(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var,
941 u_int32_t mask) 967 u_int32_t mask)
@@ -951,6 +977,11 @@ int snd_pcm_hw_constraint_mask(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t va
951 977
952/** 978/**
953 * snd_pcm_hw_constraint_mask64 979 * snd_pcm_hw_constraint_mask64
980 * @runtime: PCM runtime instance
981 * @var: hw_params variable to apply the mask
982 * @mask: the 64bit bitmap mask
983 *
984 * Apply the constraint of the given bitmap mask to a mask parameter.
954 */ 985 */
955int snd_pcm_hw_constraint_mask64(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, 986int snd_pcm_hw_constraint_mask64(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var,
956 u_int64_t mask) 987 u_int64_t mask)
@@ -967,6 +998,10 @@ int snd_pcm_hw_constraint_mask64(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t
967 998
968/** 999/**
969 * snd_pcm_hw_constraint_integer 1000 * snd_pcm_hw_constraint_integer
1001 * @runtime: PCM runtime instance
1002 * @var: hw_params variable to apply the integer constraint
1003 *
1004 * Apply the constraint of integer to an interval parameter.
970 */ 1005 */
971int snd_pcm_hw_constraint_integer(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var) 1006int snd_pcm_hw_constraint_integer(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var)
972{ 1007{
@@ -976,6 +1011,12 @@ int snd_pcm_hw_constraint_integer(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t
976 1011
977/** 1012/**
978 * snd_pcm_hw_constraint_minmax 1013 * snd_pcm_hw_constraint_minmax
1014 * @runtime: PCM runtime instance
1015 * @var: hw_params variable to apply the range
1016 * @min: the minimal value
1017 * @max: the maximal value
1018 *
1019 * Apply the min/max range constraint to an interval parameter.
979 */ 1020 */
980int snd_pcm_hw_constraint_minmax(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, 1021int snd_pcm_hw_constraint_minmax(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var,
981 unsigned int min, unsigned int max) 1022 unsigned int min, unsigned int max)
@@ -999,6 +1040,12 @@ static int snd_pcm_hw_rule_list(snd_pcm_hw_params_t *params,
999 1040
1000/** 1041/**
1001 * snd_pcm_hw_constraint_list 1042 * snd_pcm_hw_constraint_list
1043 * @runtime: PCM runtime instance
1044 * @cond: condition bits
1045 * @var: hw_params variable to apply the list constraint
1046 * @l: list
1047 *
1048 * Apply the list of constraints to an interval parameter.
1002 */ 1049 */
1003int snd_pcm_hw_constraint_list(snd_pcm_runtime_t *runtime, 1050int snd_pcm_hw_constraint_list(snd_pcm_runtime_t *runtime,
1004 unsigned int cond, 1051 unsigned int cond,
@@ -1027,6 +1074,10 @@ static int snd_pcm_hw_rule_ratnums(snd_pcm_hw_params_t *params,
1027 1074
1028/** 1075/**
1029 * snd_pcm_hw_constraint_ratnums 1076 * snd_pcm_hw_constraint_ratnums
1077 * @runtime: PCM runtime instance
1078 * @cond: condition bits
1079 * @var: hw_params variable to apply the ratnums constraint
1080 * @r: ratnums_t constriants
1030 */ 1081 */
1031int snd_pcm_hw_constraint_ratnums(snd_pcm_runtime_t *runtime, 1082int snd_pcm_hw_constraint_ratnums(snd_pcm_runtime_t *runtime,
1032 unsigned int cond, 1083 unsigned int cond,
@@ -1054,6 +1105,10 @@ static int snd_pcm_hw_rule_ratdens(snd_pcm_hw_params_t *params,
1054 1105
1055/** 1106/**
1056 * snd_pcm_hw_constraint_ratdens 1107 * snd_pcm_hw_constraint_ratdens
1108 * @runtime: PCM runtime instance
1109 * @cond: condition bits
1110 * @var: hw_params variable to apply the ratdens constraint
1111 * @r: ratdens_t constriants
1057 */ 1112 */
1058int snd_pcm_hw_constraint_ratdens(snd_pcm_runtime_t *runtime, 1113int snd_pcm_hw_constraint_ratdens(snd_pcm_runtime_t *runtime,
1059 unsigned int cond, 1114 unsigned int cond,
@@ -1079,6 +1134,10 @@ static int snd_pcm_hw_rule_msbits(snd_pcm_hw_params_t *params,
1079 1134
1080/** 1135/**
1081 * snd_pcm_hw_constraint_msbits 1136 * snd_pcm_hw_constraint_msbits
1137 * @runtime: PCM runtime instance
1138 * @cond: condition bits
1139 * @width: sample bits width
1140 * @msbits: msbits width
1082 */ 1141 */
1083int snd_pcm_hw_constraint_msbits(snd_pcm_runtime_t *runtime, 1142int snd_pcm_hw_constraint_msbits(snd_pcm_runtime_t *runtime,
1084 unsigned int cond, 1143 unsigned int cond,
@@ -1101,6 +1160,10 @@ static int snd_pcm_hw_rule_step(snd_pcm_hw_params_t *params,
1101 1160
1102/** 1161/**
1103 * snd_pcm_hw_constraint_step 1162 * snd_pcm_hw_constraint_step
1163 * @runtime: PCM runtime instance
1164 * @cond: condition bits
1165 * @var: hw_params variable to apply the step constraint
1166 * @step: step size
1104 */ 1167 */
1105int snd_pcm_hw_constraint_step(snd_pcm_runtime_t *runtime, 1168int snd_pcm_hw_constraint_step(snd_pcm_runtime_t *runtime,
1106 unsigned int cond, 1169 unsigned int cond,
@@ -1126,6 +1189,9 @@ static int snd_pcm_hw_rule_pow2(snd_pcm_hw_params_t *params, snd_pcm_hw_rule_t *
1126 1189
1127/** 1190/**
1128 * snd_pcm_hw_constraint_pow2 1191 * snd_pcm_hw_constraint_pow2
1192 * @runtime: PCM runtime instance
1193 * @cond: condition bits
1194 * @var: hw_params variable to apply the power-of-2 constraint
1129 */ 1195 */
1130int snd_pcm_hw_constraint_pow2(snd_pcm_runtime_t *runtime, 1196int snd_pcm_hw_constraint_pow2(snd_pcm_runtime_t *runtime,
1131 unsigned int cond, 1197 unsigned int cond,
@@ -1162,7 +1228,7 @@ static void _snd_pcm_hw_param_any(snd_pcm_hw_params_t *params,
1162} 1228}
1163 1229
1164#if 0 1230#if 0
1165/** 1231/*
1166 * snd_pcm_hw_param_any 1232 * snd_pcm_hw_param_any
1167 */ 1233 */
1168int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, 1234int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
@@ -1185,7 +1251,7 @@ void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params)
1185} 1251}
1186 1252
1187#if 0 1253#if 0
1188/** 1254/*
1189 * snd_pcm_hw_params_any 1255 * snd_pcm_hw_params_any
1190 * 1256 *
1191 * Fill PARAMS with full configuration space boundaries 1257 * Fill PARAMS with full configuration space boundaries
@@ -1199,6 +1265,9 @@ int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
1199 1265
1200/** 1266/**
1201 * snd_pcm_hw_param_value 1267 * snd_pcm_hw_param_value
1268 * @params: the hw_params instance
1269 * @var: parameter to retrieve
1270 * @dir: pointer to the direction (-1,0,1) or NULL
1202 * 1271 *
1203 * Return the value for field PAR if it's fixed in configuration space 1272 * Return the value for field PAR if it's fixed in configuration space
1204 * defined by PARAMS. Return -EINVAL otherwise 1273 * defined by PARAMS. Return -EINVAL otherwise
@@ -1228,6 +1297,9 @@ static int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params,
1228 1297
1229/** 1298/**
1230 * snd_pcm_hw_param_value_min 1299 * snd_pcm_hw_param_value_min
1300 * @params: the hw_params instance
1301 * @var: parameter to retrieve
1302 * @dir: pointer to the direction (-1,0,1) or NULL
1231 * 1303 *
1232 * Return the minimum value for field PAR. 1304 * Return the minimum value for field PAR.
1233 */ 1305 */
@@ -1251,6 +1323,9 @@ unsigned int snd_pcm_hw_param_value_min(const snd_pcm_hw_params_t *params,
1251 1323
1252/** 1324/**
1253 * snd_pcm_hw_param_value_max 1325 * snd_pcm_hw_param_value_max
1326 * @params: the hw_params instance
1327 * @var: parameter to retrieve
1328 * @dir: pointer to the direction (-1,0,1) or NULL
1254 * 1329 *
1255 * Return the maximum value for field PAR. 1330 * Return the maximum value for field PAR.
1256 */ 1331 */
@@ -1302,7 +1377,7 @@ int _snd_pcm_hw_param_setinteger(snd_pcm_hw_params_t *params,
1302} 1377}
1303 1378
1304#if 0 1379#if 0
1305/** 1380/*
1306 * snd_pcm_hw_param_setinteger 1381 * snd_pcm_hw_param_setinteger
1307 * 1382 *
1308 * Inside configuration space defined by PARAMS remove from PAR all 1383 * Inside configuration space defined by PARAMS remove from PAR all
@@ -1347,6 +1422,10 @@ static int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params,
1347 1422
1348/** 1423/**
1349 * snd_pcm_hw_param_first 1424 * snd_pcm_hw_param_first
1425 * @pcm: PCM instance
1426 * @params: the hw_params instance
1427 * @var: parameter to retrieve
1428 * @dir: pointer to the direction (-1,0,1) or NULL
1350 * 1429 *
1351 * Inside configuration space defined by PARAMS remove from PAR all 1430 * Inside configuration space defined by PARAMS remove from PAR all
1352 * values > minimum. Reduce configuration space accordingly. 1431 * values > minimum. Reduce configuration space accordingly.
@@ -1388,6 +1467,10 @@ static int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params,
1388 1467
1389/** 1468/**
1390 * snd_pcm_hw_param_last 1469 * snd_pcm_hw_param_last
1470 * @pcm: PCM instance
1471 * @params: the hw_params instance
1472 * @var: parameter to retrieve
1473 * @dir: pointer to the direction (-1,0,1) or NULL
1391 * 1474 *
1392 * Inside configuration space defined by PARAMS remove from PAR all 1475 * Inside configuration space defined by PARAMS remove from PAR all
1393 * values < maximum. Reduce configuration space accordingly. 1476 * values < maximum. Reduce configuration space accordingly.
@@ -1439,6 +1522,11 @@ int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params,
1439 1522
1440/** 1523/**
1441 * snd_pcm_hw_param_min 1524 * snd_pcm_hw_param_min
1525 * @pcm: PCM instance
1526 * @params: the hw_params instance
1527 * @var: parameter to retrieve
1528 * @val: minimal value
1529 * @dir: pointer to the direction (-1,0,1) or NULL
1442 * 1530 *
1443 * Inside configuration space defined by PARAMS remove from PAR all 1531 * Inside configuration space defined by PARAMS remove from PAR all
1444 * values < VAL. Reduce configuration space accordingly. 1532 * values < VAL. Reduce configuration space accordingly.
@@ -1494,6 +1582,11 @@ static int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params,
1494 1582
1495/** 1583/**
1496 * snd_pcm_hw_param_max 1584 * snd_pcm_hw_param_max
1585 * @pcm: PCM instance
1586 * @params: the hw_params instance
1587 * @var: parameter to retrieve
1588 * @val: maximal value
1589 * @dir: pointer to the direction (-1,0,1) or NULL
1497 * 1590 *
1498 * Inside configuration space defined by PARAMS remove from PAR all 1591 * Inside configuration space defined by PARAMS remove from PAR all
1499 * values >= VAL + 1. Reduce configuration space accordingly. 1592 * values >= VAL + 1. Reduce configuration space accordingly.
@@ -1565,6 +1658,11 @@ int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params,
1565 1658
1566/** 1659/**
1567 * snd_pcm_hw_param_set 1660 * snd_pcm_hw_param_set
1661 * @pcm: PCM instance
1662 * @params: the hw_params instance
1663 * @var: parameter to retrieve
1664 * @val: value to set
1665 * @dir: pointer to the direction (-1,0,1) or NULL
1568 * 1666 *
1569 * Inside configuration space defined by PARAMS remove from PAR all 1667 * Inside configuration space defined by PARAMS remove from PAR all
1570 * values != VAL. Reduce configuration space accordingly. 1668 * values != VAL. Reduce configuration space accordingly.
@@ -1599,6 +1697,10 @@ static int _snd_pcm_hw_param_mask(snd_pcm_hw_params_t *params,
1599 1697
1600/** 1698/**
1601 * snd_pcm_hw_param_mask 1699 * snd_pcm_hw_param_mask
1700 * @pcm: PCM instance
1701 * @params: the hw_params instance
1702 * @var: parameter to retrieve
1703 * @val: mask to apply
1602 * 1704 *
1603 * Inside configuration space defined by PARAMS remove from PAR all values 1705 * Inside configuration space defined by PARAMS remove from PAR all values
1604 * not contained in MASK. Reduce configuration space accordingly. 1706 * not contained in MASK. Reduce configuration space accordingly.
@@ -1671,6 +1773,11 @@ static int boundary_nearer(int min, int mindir,
1671 1773
1672/** 1774/**
1673 * snd_pcm_hw_param_near 1775 * snd_pcm_hw_param_near
1776 * @pcm: PCM instance
1777 * @params: the hw_params instance
1778 * @var: parameter to retrieve
1779 * @best: value to set
1780 * @dir: pointer to the direction (-1,0,1) or NULL
1674 * 1781 *
1675 * Inside configuration space defined by PARAMS set PAR to the available value 1782 * Inside configuration space defined by PARAMS set PAR to the available value
1676 * nearest to VAL. Reduce configuration space accordingly. 1783 * nearest to VAL. Reduce configuration space accordingly.
@@ -1747,6 +1854,8 @@ int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
1747 1854
1748/** 1855/**
1749 * snd_pcm_hw_param_choose 1856 * snd_pcm_hw_param_choose
1857 * @pcm: PCM instance
1858 * @params: the hw_params instance
1750 * 1859 *
1751 * Choose one configuration from configuration space defined by PARAMS 1860 * Choose one configuration from configuration space defined by PARAMS
1752 * The configuration chosen is that obtained fixing in this order: 1861 * The configuration chosen is that obtained fixing in this order:
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
index 9a174fb96565..b3f5344f60be 100644
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -244,7 +244,7 @@ int snd_pcm_lib_preallocate_pages(snd_pcm_substream_t *substream,
244 244
245/** 245/**
246 * snd_pcm_lib_preallocate_pages_for_all - pre-allocation for continous memory type (all substreams) 246 * snd_pcm_lib_preallocate_pages_for_all - pre-allocation for continous memory type (all substreams)
247 * @substream: the pcm substream instance 247 * @pcm: the pcm instance
248 * @type: DMA type (SNDRV_DMA_TYPE_*) 248 * @type: DMA type (SNDRV_DMA_TYPE_*)
249 * @data: DMA type dependant data 249 * @data: DMA type dependant data
250 * @size: the requested pre-allocation size in bytes 250 * @size: the requested pre-allocation size in bytes
@@ -321,7 +321,7 @@ int snd_pcm_lib_malloc_pages(snd_pcm_substream_t *substream, size_t size)
321 if (substream->dma_buffer.area != NULL && substream->dma_buffer.bytes >= size) { 321 if (substream->dma_buffer.area != NULL && substream->dma_buffer.bytes >= size) {
322 dmab = &substream->dma_buffer; /* use the pre-allocated buffer */ 322 dmab = &substream->dma_buffer; /* use the pre-allocated buffer */
323 } else { 323 } else {
324 dmab = kcalloc(1, sizeof(*dmab), GFP_KERNEL); 324 dmab = kzalloc(sizeof(*dmab), GFP_KERNEL);
325 if (! dmab) 325 if (! dmab)
326 return -ENOMEM; 326 return -ENOMEM;
327 dmab->dev = substream->dma_buffer.dev; 327 dmab->dev = substream->dma_buffer.dev;
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 03c17159dd8e..67abebabf83e 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -859,6 +859,7 @@ static struct action_ops snd_pcm_action_start = {
859 859
860/** 860/**
861 * snd_pcm_start 861 * snd_pcm_start
862 * @substream: the PCM substream instance
862 * 863 *
863 * Start all linked streams. 864 * Start all linked streams.
864 */ 865 */
@@ -908,6 +909,8 @@ static struct action_ops snd_pcm_action_stop = {
908 909
909/** 910/**
910 * snd_pcm_stop 911 * snd_pcm_stop
912 * @substream: the PCM substream instance
913 * @state: PCM state after stopping the stream
911 * 914 *
912 * Try to stop all running streams in the substream group. 915 * Try to stop all running streams in the substream group.
913 * The state of each stream is changed to the given value after that unconditionally. 916 * The state of each stream is changed to the given value after that unconditionally.
@@ -919,6 +922,7 @@ int snd_pcm_stop(snd_pcm_substream_t *substream, int state)
919 922
920/** 923/**
921 * snd_pcm_drain_done 924 * snd_pcm_drain_done
925 * @substream: the PCM substream
922 * 926 *
923 * Stop the DMA only when the given stream is playback. 927 * Stop the DMA only when the given stream is playback.
924 * The state is changed to SETUP. 928 * The state is changed to SETUP.
@@ -1040,6 +1044,7 @@ static struct action_ops snd_pcm_action_suspend = {
1040 1044
1041/** 1045/**
1042 * snd_pcm_suspend 1046 * snd_pcm_suspend
1047 * @substream: the PCM substream
1043 * 1048 *
1044 * Trigger SUSPEND to all linked streams. 1049 * Trigger SUSPEND to all linked streams.
1045 * After this call, all streams are changed to SUSPENDED state. 1050 * After this call, all streams are changed to SUSPENDED state.
@@ -1057,6 +1062,7 @@ int snd_pcm_suspend(snd_pcm_substream_t *substream)
1057 1062
1058/** 1063/**
1059 * snd_pcm_suspend_all 1064 * snd_pcm_suspend_all
1065 * @pcm: the PCM instance
1060 * 1066 *
1061 * Trigger SUSPEND to all substreams in the given pcm. 1067 * Trigger SUSPEND to all substreams in the given pcm.
1062 * After this call, all streams are changed to SUSPENDED state. 1068 * After this call, all streams are changed to SUSPENDED state.
@@ -1272,6 +1278,9 @@ static struct action_ops snd_pcm_action_prepare = {
1272 1278
1273/** 1279/**
1274 * snd_pcm_prepare 1280 * snd_pcm_prepare
1281 * @substream: the PCM substream instance
1282 *
1283 * Prepare the PCM substream to be triggerable.
1275 */ 1284 */
1276int snd_pcm_prepare(snd_pcm_substream_t *substream) 1285int snd_pcm_prepare(snd_pcm_substream_t *substream)
1277{ 1286{
@@ -1992,7 +2001,7 @@ static int snd_pcm_open_file(struct file *file,
1992 snd_assert(rpcm_file != NULL, return -EINVAL); 2001 snd_assert(rpcm_file != NULL, return -EINVAL);
1993 *rpcm_file = NULL; 2002 *rpcm_file = NULL;
1994 2003
1995 pcm_file = kcalloc(1, sizeof(*pcm_file), GFP_KERNEL); 2004 pcm_file = kzalloc(sizeof(*pcm_file), GFP_KERNEL);
1996 if (pcm_file == NULL) { 2005 if (pcm_file == NULL) {
1997 return -ENOMEM; 2006 return -ENOMEM;
1998 } 2007 }
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index edba4118271c..7c20eafecb8a 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -101,7 +101,7 @@ static int snd_rawmidi_runtime_create(snd_rawmidi_substream_t * substream)
101{ 101{
102 snd_rawmidi_runtime_t *runtime; 102 snd_rawmidi_runtime_t *runtime;
103 103
104 if ((runtime = kcalloc(1, sizeof(*runtime), GFP_KERNEL)) == NULL) 104 if ((runtime = kzalloc(sizeof(*runtime), GFP_KERNEL)) == NULL)
105 return -ENOMEM; 105 return -ENOMEM;
106 spin_lock_init(&runtime->lock); 106 spin_lock_init(&runtime->lock);
107 init_waitqueue_head(&runtime->sleep); 107 init_waitqueue_head(&runtime->sleep);
@@ -984,7 +984,9 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun
984 spin_lock_irq(&runtime->lock); 984 spin_lock_irq(&runtime->lock);
985 } 985 }
986 spin_unlock_irq(&runtime->lock); 986 spin_unlock_irq(&runtime->lock);
987 count1 = snd_rawmidi_kernel_read1(substream, (unsigned char *)buf, count, 0); 987 count1 = snd_rawmidi_kernel_read1(substream,
988 (unsigned char __force *)buf,
989 count, 0);
988 if (count1 < 0) 990 if (count1 < 0)
989 return result > 0 ? result : count1; 991 return result > 0 ? result : count1;
990 result += count1; 992 result += count1;
@@ -1107,7 +1109,7 @@ int snd_rawmidi_transmit_ack(snd_rawmidi_substream_t * substream, int count)
1107/** 1109/**
1108 * snd_rawmidi_transmit - copy from the buffer to the device 1110 * snd_rawmidi_transmit - copy from the buffer to the device
1109 * @substream: the rawmidi substream 1111 * @substream: the rawmidi substream
1110 * @buf: the buffer pointer 1112 * @buffer: the buffer pointer
1111 * @count: the data size to transfer 1113 * @count: the data size to transfer
1112 * 1114 *
1113 * Copies data from the buffer to the device and advances the pointer. 1115 * Copies data from the buffer to the device and advances the pointer.
@@ -1213,7 +1215,9 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, size
1213 spin_lock_irq(&runtime->lock); 1215 spin_lock_irq(&runtime->lock);
1214 } 1216 }
1215 spin_unlock_irq(&runtime->lock); 1217 spin_unlock_irq(&runtime->lock);
1216 count1 = snd_rawmidi_kernel_write1(substream, (unsigned char *)buf, count, 0); 1218 count1 = snd_rawmidi_kernel_write1(substream,
1219 (unsigned char __force *)buf,
1220 count, 0);
1217 if (count1 < 0) 1221 if (count1 < 0)
1218 return result > 0 ? result : count1; 1222 return result > 0 ? result : count1;
1219 result += count1; 1223 result += count1;
@@ -1370,7 +1374,7 @@ static int snd_rawmidi_alloc_substreams(snd_rawmidi_t *rmidi,
1370 1374
1371 INIT_LIST_HEAD(&stream->substreams); 1375 INIT_LIST_HEAD(&stream->substreams);
1372 for (idx = 0; idx < count; idx++) { 1376 for (idx = 0; idx < count; idx++) {
1373 substream = kcalloc(1, sizeof(*substream), GFP_KERNEL); 1377 substream = kzalloc(sizeof(*substream), GFP_KERNEL);
1374 if (substream == NULL) 1378 if (substream == NULL)
1375 return -ENOMEM; 1379 return -ENOMEM;
1376 substream->stream = direction; 1380 substream->stream = direction;
@@ -1413,7 +1417,7 @@ int snd_rawmidi_new(snd_card_t * card, char *id, int device,
1413 snd_assert(rrawmidi != NULL, return -EINVAL); 1417 snd_assert(rrawmidi != NULL, return -EINVAL);
1414 *rrawmidi = NULL; 1418 *rrawmidi = NULL;
1415 snd_assert(card != NULL, return -ENXIO); 1419 snd_assert(card != NULL, return -ENXIO);
1416 rmidi = kcalloc(1, sizeof(*rmidi), GFP_KERNEL); 1420 rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL);
1417 if (rmidi == NULL) 1421 if (rmidi == NULL)
1418 return -ENOMEM; 1422 return -ENOMEM;
1419 rmidi->card = card; 1423 rmidi->card = card;
diff --git a/sound/core/seq/instr/ainstr_gf1.c b/sound/core/seq/instr/ainstr_gf1.c
index 32e91c6b25fe..207c2c54bf1d 100644
--- a/sound/core/seq/instr/ainstr_gf1.c
+++ b/sound/core/seq/instr/ainstr_gf1.c
@@ -61,7 +61,7 @@ static int snd_seq_gf1_copy_wave_from_stream(snd_gf1_ops_t *ops,
61 return -EFAULT; 61 return -EFAULT;
62 *data += sizeof(xp); 62 *data += sizeof(xp);
63 *len -= sizeof(xp); 63 *len -= sizeof(xp);
64 wp = kcalloc(1, sizeof(*wp), gfp_mask); 64 wp = kzalloc(sizeof(*wp), gfp_mask);
65 if (wp == NULL) 65 if (wp == NULL)
66 return -ENOMEM; 66 return -ENOMEM;
67 wp->share_id[0] = le32_to_cpu(xp.share_id[0]); 67 wp->share_id[0] = le32_to_cpu(xp.share_id[0]);
diff --git a/sound/core/seq/instr/ainstr_iw.c b/sound/core/seq/instr/ainstr_iw.c
index 2622b8679ca7..b3cee092b1a4 100644
--- a/sound/core/seq/instr/ainstr_iw.c
+++ b/sound/core/seq/instr/ainstr_iw.c
@@ -92,7 +92,7 @@ static int snd_seq_iwffff_copy_env_from_stream(__u32 req_stype,
92 points_size = (le16_to_cpu(rx.nattack) + le16_to_cpu(rx.nrelease)) * 2 * sizeof(__u16); 92 points_size = (le16_to_cpu(rx.nattack) + le16_to_cpu(rx.nrelease)) * 2 * sizeof(__u16);
93 if (points_size > *len) 93 if (points_size > *len)
94 return -EINVAL; 94 return -EINVAL;
95 rp = kcalloc(1, sizeof(*rp) + points_size, gfp_mask); 95 rp = kzalloc(sizeof(*rp) + points_size, gfp_mask);
96 if (rp == NULL) 96 if (rp == NULL)
97 return -ENOMEM; 97 return -ENOMEM;
98 rp->nattack = le16_to_cpu(rx.nattack); 98 rp->nattack = le16_to_cpu(rx.nattack);
@@ -139,7 +139,7 @@ static int snd_seq_iwffff_copy_wave_from_stream(snd_iwffff_ops_t *ops,
139 return -EFAULT; 139 return -EFAULT;
140 *data += sizeof(xp); 140 *data += sizeof(xp);
141 *len -= sizeof(xp); 141 *len -= sizeof(xp);
142 wp = kcalloc(1, sizeof(*wp), gfp_mask); 142 wp = kzalloc(sizeof(*wp), gfp_mask);
143 if (wp == NULL) 143 if (wp == NULL)
144 return -ENOMEM; 144 return -ENOMEM;
145 wp->share_id[0] = le32_to_cpu(xp.share_id[0]); 145 wp->share_id[0] = le32_to_cpu(xp.share_id[0]);
@@ -273,7 +273,7 @@ static int snd_seq_iwffff_put(void *private_data, snd_seq_kinstr_t *instr,
273 snd_seq_iwffff_instr_free(ops, ip, atomic); 273 snd_seq_iwffff_instr_free(ops, ip, atomic);
274 return -EINVAL; 274 return -EINVAL;
275 } 275 }
276 lp = kcalloc(1, sizeof(*lp), gfp_mask); 276 lp = kzalloc(sizeof(*lp), gfp_mask);
277 if (lp == NULL) { 277 if (lp == NULL) {
278 snd_seq_iwffff_instr_free(ops, ip, atomic); 278 snd_seq_iwffff_instr_free(ops, ip, atomic);
279 return -ENOMEM; 279 return -ENOMEM;
diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
index bac4b4f1a94e..1ab1cf8158c8 100644
--- a/sound/core/seq/oss/seq_oss_init.c
+++ b/sound/core/seq/oss/seq_oss_init.c
@@ -193,7 +193,7 @@ snd_seq_oss_open(struct file *file, int level)
193 int i, rc; 193 int i, rc;
194 seq_oss_devinfo_t *dp; 194 seq_oss_devinfo_t *dp;
195 195
196 if ((dp = kcalloc(1, sizeof(*dp), GFP_KERNEL)) == NULL) { 196 if ((dp = kzalloc(sizeof(*dp), GFP_KERNEL)) == NULL) {
197 snd_printk(KERN_ERR "can't malloc device info\n"); 197 snd_printk(KERN_ERR "can't malloc device info\n");
198 return -ENOMEM; 198 return -ENOMEM;
199 } 199 }
diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c
index 9aece6c65dbc..f0e95c8f2eef 100644
--- a/sound/core/seq/oss/seq_oss_midi.c
+++ b/sound/core/seq/oss/seq_oss_midi.c
@@ -76,8 +76,8 @@ snd_seq_oss_midi_lookup_ports(int client)
76 snd_seq_client_info_t *clinfo; 76 snd_seq_client_info_t *clinfo;
77 snd_seq_port_info_t *pinfo; 77 snd_seq_port_info_t *pinfo;
78 78
79 clinfo = kcalloc(1, sizeof(*clinfo), GFP_KERNEL); 79 clinfo = kzalloc(sizeof(*clinfo), GFP_KERNEL);
80 pinfo = kcalloc(1, sizeof(*pinfo), GFP_KERNEL); 80 pinfo = kzalloc(sizeof(*pinfo), GFP_KERNEL);
81 if (! clinfo || ! pinfo) { 81 if (! clinfo || ! pinfo) {
82 kfree(clinfo); 82 kfree(clinfo);
83 kfree(pinfo); 83 kfree(pinfo);
@@ -172,7 +172,7 @@ snd_seq_oss_midi_check_new_port(snd_seq_port_info_t *pinfo)
172 /* 172 /*
173 * allocate midi info record 173 * allocate midi info record
174 */ 174 */
175 if ((mdev = kcalloc(1, sizeof(*mdev), GFP_KERNEL)) == NULL) { 175 if ((mdev = kzalloc(sizeof(*mdev), GFP_KERNEL)) == NULL) {
176 snd_printk(KERN_ERR "can't malloc midi info\n"); 176 snd_printk(KERN_ERR "can't malloc midi info\n");
177 return -ENOMEM; 177 return -ENOMEM;
178 } 178 }
diff --git a/sound/core/seq/oss/seq_oss_readq.c b/sound/core/seq/oss/seq_oss_readq.c
index 0a6f2a64f692..55571e15cd38 100644
--- a/sound/core/seq/oss/seq_oss_readq.c
+++ b/sound/core/seq/oss/seq_oss_readq.c
@@ -46,7 +46,7 @@ snd_seq_oss_readq_new(seq_oss_devinfo_t *dp, int maxlen)
46{ 46{
47 seq_oss_readq_t *q; 47 seq_oss_readq_t *q;
48 48
49 if ((q = kcalloc(1, sizeof(*q), GFP_KERNEL)) == NULL) { 49 if ((q = kzalloc(sizeof(*q), GFP_KERNEL)) == NULL) {
50 snd_printk(KERN_ERR "can't malloc read queue\n"); 50 snd_printk(KERN_ERR "can't malloc read queue\n");
51 return NULL; 51 return NULL;
52 } 52 }
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c
index 1a7736cbf3a4..8257fce2ca1b 100644
--- a/sound/core/seq/oss/seq_oss_synth.c
+++ b/sound/core/seq/oss/seq_oss_synth.c
@@ -103,7 +103,7 @@ snd_seq_oss_synth_register(snd_seq_device_t *dev)
103 snd_seq_oss_reg_t *reg = SNDRV_SEQ_DEVICE_ARGPTR(dev); 103 snd_seq_oss_reg_t *reg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
104 unsigned long flags; 104 unsigned long flags;
105 105
106 if ((rec = kcalloc(1, sizeof(*rec), GFP_KERNEL)) == NULL) { 106 if ((rec = kzalloc(sizeof(*rec), GFP_KERNEL)) == NULL) {
107 snd_printk(KERN_ERR "can't malloc synth info\n"); 107 snd_printk(KERN_ERR "can't malloc synth info\n");
108 return -ENOMEM; 108 return -ENOMEM;
109 } 109 }
@@ -499,7 +499,7 @@ snd_seq_oss_synth_sysex(seq_oss_devinfo_t *dp, int dev, unsigned char *buf, snd_
499 499
500 sysex = dp->synths[dev].sysex; 500 sysex = dp->synths[dev].sysex;
501 if (sysex == NULL) { 501 if (sysex == NULL) {
502 sysex = kcalloc(1, sizeof(*sysex), GFP_KERNEL); 502 sysex = kzalloc(sizeof(*sysex), GFP_KERNEL);
503 if (sysex == NULL) 503 if (sysex == NULL)
504 return -ENOMEM; 504 return -ENOMEM;
505 dp->synths[dev].sysex = sysex; 505 dp->synths[dev].sysex = sysex;
diff --git a/sound/core/seq/oss/seq_oss_timer.c b/sound/core/seq/oss/seq_oss_timer.c
index 42ca9493fa60..64d594b3170f 100644
--- a/sound/core/seq/oss/seq_oss_timer.c
+++ b/sound/core/seq/oss/seq_oss_timer.c
@@ -46,7 +46,7 @@ snd_seq_oss_timer_new(seq_oss_devinfo_t *dp)
46{ 46{
47 seq_oss_timer_t *rec; 47 seq_oss_timer_t *rec;
48 48
49 rec = kcalloc(1, sizeof(*rec), GFP_KERNEL); 49 rec = kzalloc(sizeof(*rec), GFP_KERNEL);
50 if (rec == NULL) 50 if (rec == NULL)
51 return NULL; 51 return NULL;
52 52
diff --git a/sound/core/seq/oss/seq_oss_writeq.c b/sound/core/seq/oss/seq_oss_writeq.c
index 87f85f7ee814..b20378024547 100644
--- a/sound/core/seq/oss/seq_oss_writeq.c
+++ b/sound/core/seq/oss/seq_oss_writeq.c
@@ -38,7 +38,7 @@ snd_seq_oss_writeq_new(seq_oss_devinfo_t *dp, int maxlen)
38 seq_oss_writeq_t *q; 38 seq_oss_writeq_t *q;
39 snd_seq_client_pool_t pool; 39 snd_seq_client_pool_t pool;
40 40
41 if ((q = kcalloc(1, sizeof(*q), GFP_KERNEL)) == NULL) 41 if ((q = kzalloc(sizeof(*q), GFP_KERNEL)) == NULL)
42 return NULL; 42 return NULL;
43 q->dp = dp; 43 q->dp = dp;
44 q->maxlen = maxlen; 44 q->maxlen = maxlen;
diff --git a/sound/core/seq/seq.c b/sound/core/seq/seq.c
index 7449d2a62629..24644150f24b 100644
--- a/sound/core/seq/seq.c
+++ b/sound/core/seq/seq.c
@@ -43,7 +43,13 @@ int seq_client_load[64] = {[0 ... 63] = -1};
43int seq_default_timer_class = SNDRV_TIMER_CLASS_GLOBAL; 43int seq_default_timer_class = SNDRV_TIMER_CLASS_GLOBAL;
44int seq_default_timer_sclass = SNDRV_TIMER_SCLASS_NONE; 44int seq_default_timer_sclass = SNDRV_TIMER_SCLASS_NONE;
45int seq_default_timer_card = -1; 45int seq_default_timer_card = -1;
46int seq_default_timer_device = SNDRV_TIMER_GLOBAL_SYSTEM; 46int seq_default_timer_device =
47#ifdef CONFIG_SND_SEQ_RTCTIMER_DEFAULT
48 SNDRV_TIMER_GLOBAL_RTC
49#else
50 SNDRV_TIMER_GLOBAL_SYSTEM
51#endif
52 ;
47int seq_default_timer_subdevice = 0; 53int seq_default_timer_subdevice = 0;
48int seq_default_timer_resolution = 0; /* Hz */ 54int seq_default_timer_resolution = 0; /* Hz */
49 55
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index d8f76afd284b..a886db94b1fa 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -203,7 +203,7 @@ static client_t *seq_create_client1(int client_index, int poolsize)
203 client_t *client; 203 client_t *client;
204 204
205 /* init client data */ 205 /* init client data */
206 client = kcalloc(1, sizeof(*client), GFP_KERNEL); 206 client = kzalloc(sizeof(*client), GFP_KERNEL);
207 if (client == NULL) 207 if (client == NULL)
208 return NULL; 208 return NULL;
209 client->pool = snd_seq_pool_new(poolsize); 209 client->pool = snd_seq_pool_new(poolsize);
@@ -413,7 +413,9 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, l
413 } 413 }
414 count -= sizeof(snd_seq_event_t); 414 count -= sizeof(snd_seq_event_t);
415 buf += sizeof(snd_seq_event_t); 415 buf += sizeof(snd_seq_event_t);
416 err = snd_seq_expand_var_event(&cell->event, count, (char *)buf, 0, sizeof(snd_seq_event_t)); 416 err = snd_seq_expand_var_event(&cell->event, count,
417 (char __force *)buf, 0,
418 sizeof(snd_seq_event_t));
417 if (err < 0) 419 if (err < 0)
418 break; 420 break;
419 result += err; 421 result += err;
@@ -1009,7 +1011,8 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, size_t c
1009 } 1011 }
1010 /* set user space pointer */ 1012 /* set user space pointer */
1011 event.data.ext.len = extlen | SNDRV_SEQ_EXT_USRPTR; 1013 event.data.ext.len = extlen | SNDRV_SEQ_EXT_USRPTR;
1012 event.data.ext.ptr = (char*)buf + sizeof(snd_seq_event_t); 1014 event.data.ext.ptr = (char __force *)buf
1015 + sizeof(snd_seq_event_t);
1013 len += extlen; /* increment data length */ 1016 len += extlen; /* increment data length */
1014 } else { 1017 } else {
1015#ifdef CONFIG_COMPAT 1018#ifdef CONFIG_COMPAT
diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
index 4d80f39612e8..252b52731003 100644
--- a/sound/core/seq/seq_device.c
+++ b/sound/core/seq/seq_device.c
@@ -200,7 +200,7 @@ int snd_seq_device_new(snd_card_t *card, int device, char *id, int argsize,
200 if (ops == NULL) 200 if (ops == NULL)
201 return -ENOMEM; 201 return -ENOMEM;
202 202
203 dev = kcalloc(1, sizeof(*dev)*2 + argsize, GFP_KERNEL); 203 dev = kzalloc(sizeof(*dev)*2 + argsize, GFP_KERNEL);
204 if (dev == NULL) { 204 if (dev == NULL) {
205 unlock_driver(ops); 205 unlock_driver(ops);
206 return -ENOMEM; 206 return -ENOMEM;
diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c
index ea945a5d2a0b..5dd0e6a19e50 100644
--- a/sound/core/seq/seq_dummy.c
+++ b/sound/core/seq/seq_dummy.c
@@ -153,7 +153,7 @@ create_port(int idx, int type)
153 snd_seq_port_callback_t pcb; 153 snd_seq_port_callback_t pcb;
154 snd_seq_dummy_port_t *rec; 154 snd_seq_dummy_port_t *rec;
155 155
156 if ((rec = kcalloc(1, sizeof(*rec), GFP_KERNEL)) == NULL) 156 if ((rec = kzalloc(sizeof(*rec), GFP_KERNEL)) == NULL)
157 return NULL; 157 return NULL;
158 158
159 rec->client = my_client; 159 rec->client = my_client;
diff --git a/sound/core/seq/seq_fifo.c b/sound/core/seq/seq_fifo.c
index 3b7647ca7ad9..4767cfdc361f 100644
--- a/sound/core/seq/seq_fifo.c
+++ b/sound/core/seq/seq_fifo.c
@@ -33,7 +33,7 @@ fifo_t *snd_seq_fifo_new(int poolsize)
33{ 33{
34 fifo_t *f; 34 fifo_t *f;
35 35
36 f = kcalloc(1, sizeof(*f), GFP_KERNEL); 36 f = kzalloc(sizeof(*f), GFP_KERNEL);
37 if (f == NULL) { 37 if (f == NULL) {
38 snd_printd("malloc failed for snd_seq_fifo_new() \n"); 38 snd_printd("malloc failed for snd_seq_fifo_new() \n");
39 return NULL; 39 return NULL;
diff --git a/sound/core/seq/seq_instr.c b/sound/core/seq/seq_instr.c
index 5b40ea2ba8f4..019d43a462d7 100644
--- a/sound/core/seq/seq_instr.c
+++ b/sound/core/seq/seq_instr.c
@@ -53,7 +53,7 @@ static snd_seq_kinstr_t *snd_seq_instr_new(int add_len, int atomic)
53{ 53{
54 snd_seq_kinstr_t *instr; 54 snd_seq_kinstr_t *instr;
55 55
56 instr = kcalloc(1, sizeof(snd_seq_kinstr_t) + add_len, atomic ? GFP_ATOMIC : GFP_KERNEL); 56 instr = kzalloc(sizeof(snd_seq_kinstr_t) + add_len, atomic ? GFP_ATOMIC : GFP_KERNEL);
57 if (instr == NULL) 57 if (instr == NULL)
58 return NULL; 58 return NULL;
59 instr->add_len = add_len; 59 instr->add_len = add_len;
@@ -77,7 +77,7 @@ snd_seq_kinstr_list_t *snd_seq_instr_list_new(void)
77{ 77{
78 snd_seq_kinstr_list_t *list; 78 snd_seq_kinstr_list_t *list;
79 79
80 list = kcalloc(1, sizeof(snd_seq_kinstr_list_t), GFP_KERNEL); 80 list = kzalloc(sizeof(snd_seq_kinstr_list_t), GFP_KERNEL);
81 if (list == NULL) 81 if (list == NULL)
82 return NULL; 82 return NULL;
83 spin_lock_init(&list->lock); 83 spin_lock_init(&list->lock);
diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c
index 03acb2d519ba..d4d7d326c4b1 100644
--- a/sound/core/seq/seq_memory.c
+++ b/sound/core/seq/seq_memory.c
@@ -452,7 +452,7 @@ pool_t *snd_seq_pool_new(int poolsize)
452 pool_t *pool; 452 pool_t *pool;
453 453
454 /* create pool block */ 454 /* create pool block */
455 pool = kcalloc(1, sizeof(*pool), GFP_KERNEL); 455 pool = kzalloc(sizeof(*pool), GFP_KERNEL);
456 if (pool == NULL) { 456 if (pool == NULL) {
457 snd_printd("seq: malloc failed for pool\n"); 457 snd_printd("seq: malloc failed for pool\n");
458 return NULL; 458 return NULL;
diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c
index 4374829ea770..b4674ae3bc30 100644
--- a/sound/core/seq/seq_midi.c
+++ b/sound/core/seq/seq_midi.c
@@ -322,7 +322,7 @@ snd_seq_midisynth_register_port(snd_seq_device_t *dev)
322 client = synths[card->number]; 322 client = synths[card->number];
323 if (client == NULL) { 323 if (client == NULL) {
324 newclient = 1; 324 newclient = 1;
325 client = kcalloc(1, sizeof(*client), GFP_KERNEL); 325 client = kzalloc(sizeof(*client), GFP_KERNEL);
326 if (client == NULL) { 326 if (client == NULL) {
327 up(&register_mutex); 327 up(&register_mutex);
328 kfree(info); 328 kfree(info);
diff --git a/sound/core/seq/seq_midi_event.c b/sound/core/seq/seq_midi_event.c
index 603b63716db6..2dc1aecfb426 100644
--- a/sound/core/seq/seq_midi_event.c
+++ b/sound/core/seq/seq_midi_event.c
@@ -118,7 +118,7 @@ int snd_midi_event_new(int bufsize, snd_midi_event_t **rdev)
118 snd_midi_event_t *dev; 118 snd_midi_event_t *dev;
119 119
120 *rdev = NULL; 120 *rdev = NULL;
121 dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); 121 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
122 if (dev == NULL) 122 if (dev == NULL)
123 return -ENOMEM; 123 return -ENOMEM;
124 if (bufsize > 0) { 124 if (bufsize > 0) {
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c
index b976951fc100..57ec31df0d15 100644
--- a/sound/core/seq/seq_ports.c
+++ b/sound/core/seq/seq_ports.c
@@ -141,7 +141,7 @@ client_port_t *snd_seq_create_port(client_t *client, int port)
141 } 141 }
142 142
143 /* create a new port */ 143 /* create a new port */
144 new_port = kcalloc(1, sizeof(*new_port), GFP_KERNEL); 144 new_port = kzalloc(sizeof(*new_port), GFP_KERNEL);
145 if (! new_port) { 145 if (! new_port) {
146 snd_printd("malloc failed for registering client port\n"); 146 snd_printd("malloc failed for registering client port\n");
147 return NULL; /* failure, out of memory */ 147 return NULL; /* failure, out of memory */
@@ -488,7 +488,7 @@ int snd_seq_port_connect(client_t *connector,
488 unsigned long flags; 488 unsigned long flags;
489 int exclusive; 489 int exclusive;
490 490
491 subs = kcalloc(1, sizeof(*subs), GFP_KERNEL); 491 subs = kzalloc(sizeof(*subs), GFP_KERNEL);
492 if (! subs) 492 if (! subs)
493 return -ENOMEM; 493 return -ENOMEM;
494 494
diff --git a/sound/core/seq/seq_prioq.c b/sound/core/seq/seq_prioq.c
index a519732ed833..cd641bca9945 100644
--- a/sound/core/seq/seq_prioq.c
+++ b/sound/core/seq/seq_prioq.c
@@ -59,7 +59,7 @@ prioq_t *snd_seq_prioq_new(void)
59{ 59{
60 prioq_t *f; 60 prioq_t *f;
61 61
62 f = kcalloc(1, sizeof(*f), GFP_KERNEL); 62 f = kzalloc(sizeof(*f), GFP_KERNEL);
63 if (f == NULL) { 63 if (f == NULL) {
64 snd_printd("oops: malloc failed for snd_seq_prioq_new()\n"); 64 snd_printd("oops: malloc failed for snd_seq_prioq_new()\n");
65 return NULL; 65 return NULL;
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c
index 98de2e711fde..5f5c3cb37cbf 100644
--- a/sound/core/seq/seq_queue.c
+++ b/sound/core/seq/seq_queue.c
@@ -111,7 +111,7 @@ static queue_t *queue_new(int owner, int locked)
111{ 111{
112 queue_t *q; 112 queue_t *q;
113 113
114 q = kcalloc(1, sizeof(*q), GFP_KERNEL); 114 q = kzalloc(sizeof(*q), GFP_KERNEL);
115 if (q == NULL) { 115 if (q == NULL) {
116 snd_printd("malloc failed for snd_seq_queue_new()\n"); 116 snd_printd("malloc failed for snd_seq_queue_new()\n");
117 return NULL; 117 return NULL;
diff --git a/sound/core/seq/seq_system.c b/sound/core/seq/seq_system.c
index e8f0a6683d50..0d9eff85ab88 100644
--- a/sound/core/seq/seq_system.c
+++ b/sound/core/seq/seq_system.c
@@ -126,8 +126,8 @@ int __init snd_seq_system_client_init(void)
126 snd_seq_client_info_t *inf; 126 snd_seq_client_info_t *inf;
127 snd_seq_port_info_t *port; 127 snd_seq_port_info_t *port;
128 128
129 inf = kcalloc(1, sizeof(*inf), GFP_KERNEL); 129 inf = kzalloc(sizeof(*inf), GFP_KERNEL);
130 port = kcalloc(1, sizeof(*port), GFP_KERNEL); 130 port = kzalloc(sizeof(*port), GFP_KERNEL);
131 if (! inf || ! port) { 131 if (! inf || ! port) {
132 kfree(inf); 132 kfree(inf);
133 kfree(port); 133 kfree(port);
diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c
index a7f76fc95280..b57a3c07ff6f 100644
--- a/sound/core/seq/seq_timer.c
+++ b/sound/core/seq/seq_timer.c
@@ -60,7 +60,7 @@ seq_timer_t *snd_seq_timer_new(void)
60{ 60{
61 seq_timer_t *tmr; 61 seq_timer_t *tmr;
62 62
63 tmr = kcalloc(1, sizeof(*tmr), GFP_KERNEL); 63 tmr = kzalloc(sizeof(*tmr), GFP_KERNEL);
64 if (tmr == NULL) { 64 if (tmr == NULL) {
65 snd_printd("malloc failed for snd_seq_timer_new() \n"); 65 snd_printd("malloc failed for snd_seq_timer_new() \n");
66 return NULL; 66 return NULL;
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
index a66484b5cf0e..e4f512aa7426 100644
--- a/sound/core/seq/seq_virmidi.c
+++ b/sound/core/seq/seq_virmidi.c
@@ -205,7 +205,7 @@ static int snd_virmidi_input_open(snd_rawmidi_substream_t * substream)
205 snd_virmidi_t *vmidi; 205 snd_virmidi_t *vmidi;
206 unsigned long flags; 206 unsigned long flags;
207 207
208 vmidi = kcalloc(1, sizeof(*vmidi), GFP_KERNEL); 208 vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL);
209 if (vmidi == NULL) 209 if (vmidi == NULL)
210 return -ENOMEM; 210 return -ENOMEM;
211 vmidi->substream = substream; 211 vmidi->substream = substream;
@@ -233,7 +233,7 @@ static int snd_virmidi_output_open(snd_rawmidi_substream_t * substream)
233 snd_rawmidi_runtime_t *runtime = substream->runtime; 233 snd_rawmidi_runtime_t *runtime = substream->runtime;
234 snd_virmidi_t *vmidi; 234 snd_virmidi_t *vmidi;
235 235
236 vmidi = kcalloc(1, sizeof(*vmidi), GFP_KERNEL); 236 vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL);
237 if (vmidi == NULL) 237 if (vmidi == NULL)
238 return -ENOMEM; 238 return -ENOMEM;
239 vmidi->substream = substream; 239 vmidi->substream = substream;
@@ -508,7 +508,7 @@ int snd_virmidi_new(snd_card_t *card, int device, snd_rawmidi_t **rrmidi)
508 &rmidi)) < 0) 508 &rmidi)) < 0)
509 return err; 509 return err;
510 strcpy(rmidi->name, rmidi->id); 510 strcpy(rmidi->name, rmidi->id);
511 rdev = kcalloc(1, sizeof(*rdev), GFP_KERNEL); 511 rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
512 if (rdev == NULL) { 512 if (rdev == NULL) {
513 snd_device_free(card, rmidi); 513 snd_device_free(card, rmidi);
514 return -ENOMEM; 514 return -ENOMEM;
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 3271e9245490..9e76bddb2c0b 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -328,6 +328,10 @@ int __exit snd_minor_info_done(void)
328 * INIT PART 328 * INIT PART
329 */ 329 */
330 330
331#ifdef CONFIG_SND_GENERIC_DRIVER
332extern struct device_driver snd_generic_driver;
333#endif
334
331static int __init alsa_sound_init(void) 335static int __init alsa_sound_init(void)
332{ 336{
333 short controlnum; 337 short controlnum;
@@ -354,6 +358,9 @@ static int __init alsa_sound_init(void)
354 return -ENOMEM; 358 return -ENOMEM;
355 } 359 }
356 snd_info_minor_register(); 360 snd_info_minor_register();
361#ifdef CONFIG_SND_GENERIC_DRIVER
362 driver_register(&snd_generic_driver);
363#endif
357 for (controlnum = 0; controlnum < cards_limit; controlnum++) 364 for (controlnum = 0; controlnum < cards_limit; controlnum++)
358 devfs_mk_cdev(MKDEV(major, controlnum<<5), S_IFCHR | device_mode, "snd/controlC%d", controlnum); 365 devfs_mk_cdev(MKDEV(major, controlnum<<5), S_IFCHR | device_mode, "snd/controlC%d", controlnum);
359#ifndef MODULE 366#ifndef MODULE
@@ -369,6 +376,9 @@ static void __exit alsa_sound_exit(void)
369 for (controlnum = 0; controlnum < cards_limit; controlnum++) 376 for (controlnum = 0; controlnum < cards_limit; controlnum++)
370 devfs_remove("snd/controlC%d", controlnum); 377 devfs_remove("snd/controlC%d", controlnum);
371 378
379#ifdef CONFIG_SND_GENERIC_DRIVER
380 driver_unregister(&snd_generic_driver);
381#endif
372 snd_info_minor_unregister(); 382 snd_info_minor_unregister();
373 snd_info_done(); 383 snd_info_done();
374 snd_memory_done(); 384 snd_memory_done();
@@ -416,10 +426,13 @@ EXPORT_SYMBOL(snd_card_register);
416EXPORT_SYMBOL(snd_component_add); 426EXPORT_SYMBOL(snd_component_add);
417EXPORT_SYMBOL(snd_card_file_add); 427EXPORT_SYMBOL(snd_card_file_add);
418EXPORT_SYMBOL(snd_card_file_remove); 428EXPORT_SYMBOL(snd_card_file_remove);
429#ifdef CONFIG_SND_GENERIC_DRIVER
430EXPORT_SYMBOL(snd_card_set_generic_dev);
431#endif
419#ifdef CONFIG_PM 432#ifdef CONFIG_PM
420EXPORT_SYMBOL(snd_power_wait); 433EXPORT_SYMBOL(snd_power_wait);
421EXPORT_SYMBOL(snd_card_set_pm_callback); 434EXPORT_SYMBOL(snd_card_set_pm_callback);
422#if defined(CONFIG_PM) && defined(CONFIG_SND_GENERIC_PM) 435#ifdef CONFIG_SND_GENERIC_DRIVER
423EXPORT_SYMBOL(snd_card_set_generic_pm_callback); 436EXPORT_SYMBOL(snd_card_set_generic_pm_callback);
424#endif 437#endif
425#ifdef CONFIG_PCI 438#ifdef CONFIG_PCI
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 4104f6e292e9..22b104624084 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -98,7 +98,7 @@ static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left);
98static snd_timer_instance_t *snd_timer_instance_new(char *owner, snd_timer_t *timer) 98static snd_timer_instance_t *snd_timer_instance_new(char *owner, snd_timer_t *timer)
99{ 99{
100 snd_timer_instance_t *timeri; 100 snd_timer_instance_t *timeri;
101 timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL); 101 timeri = kzalloc(sizeof(*timeri), GFP_KERNEL);
102 if (timeri == NULL) 102 if (timeri == NULL)
103 return NULL; 103 return NULL;
104 timeri->owner = kstrdup(owner, GFP_KERNEL); 104 timeri->owner = kstrdup(owner, GFP_KERNEL);
@@ -764,7 +764,7 @@ int snd_timer_new(snd_card_t *card, char *id, snd_timer_id_t *tid, snd_timer_t *
764 snd_assert(tid != NULL, return -EINVAL); 764 snd_assert(tid != NULL, return -EINVAL);
765 snd_assert(rtimer != NULL, return -EINVAL); 765 snd_assert(rtimer != NULL, return -EINVAL);
766 *rtimer = NULL; 766 *rtimer = NULL;
767 timer = kcalloc(1, sizeof(*timer), GFP_KERNEL); 767 timer = kzalloc(sizeof(*timer), GFP_KERNEL);
768 if (timer == NULL) 768 if (timer == NULL)
769 return -ENOMEM; 769 return -ENOMEM;
770 timer->tmr_class = tid->dev_class; 770 timer->tmr_class = tid->dev_class;
@@ -1017,7 +1017,7 @@ static int snd_timer_register_system(void)
1017 return err; 1017 return err;
1018 strcpy(timer->name, "system timer"); 1018 strcpy(timer->name, "system timer");
1019 timer->hw = snd_timer_system; 1019 timer->hw = snd_timer_system;
1020 priv = kcalloc(1, sizeof(*priv), GFP_KERNEL); 1020 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1021 if (priv == NULL) { 1021 if (priv == NULL) {
1022 snd_timer_free(timer); 1022 snd_timer_free(timer);
1023 return -ENOMEM; 1023 return -ENOMEM;
@@ -1202,7 +1202,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file)
1202{ 1202{
1203 snd_timer_user_t *tu; 1203 snd_timer_user_t *tu;
1204 1204
1205 tu = kcalloc(1, sizeof(*tu), GFP_KERNEL); 1205 tu = kzalloc(sizeof(*tu), GFP_KERNEL);
1206 if (tu == NULL) 1206 if (tu == NULL)
1207 return -ENOMEM; 1207 return -ENOMEM;
1208 spin_lock_init(&tu->qlock); 1208 spin_lock_init(&tu->qlock);
@@ -1513,7 +1513,7 @@ static int snd_timer_user_info(struct file *file, snd_timer_info_t __user *_info
1513 t = tu->timeri->timer; 1513 t = tu->timeri->timer;
1514 snd_assert(t != NULL, return -ENXIO); 1514 snd_assert(t != NULL, return -ENXIO);
1515 1515
1516 info = kcalloc(1, sizeof(*info), GFP_KERNEL); 1516 info = kzalloc(sizeof(*info), GFP_KERNEL);
1517 if (! info) 1517 if (! info)
1518 return -ENOMEM; 1518 return -ENOMEM;
1519 info->card = t->card ? t->card->number : -1; 1519 info->card = t->card ? t->card->number : -1;
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
index 3b2bee19e2c0..efcb4eb2d1a0 100644
--- a/sound/drivers/Kconfig
+++ b/sound/drivers/Kconfig
@@ -29,6 +29,7 @@ config SND_DUMMY
29 tristate "Dummy (/dev/null) soundcard" 29 tristate "Dummy (/dev/null) soundcard"
30 depends on SND 30 depends on SND
31 select SND_PCM 31 select SND_PCM
32 select SND_GENERIC_DRIVER
32 help 33 help
33 Say Y here to include the dummy driver. This driver does 34 Say Y here to include the dummy driver. This driver does
34 nothing, but emulates various mixer controls and PCM devices. 35 nothing, but emulates various mixer controls and PCM devices.
@@ -44,6 +45,7 @@ config SND_VIRMIDI
44 depends on SND_SEQUENCER 45 depends on SND_SEQUENCER
45 select SND_TIMER 46 select SND_TIMER
46 select SND_RAWMIDI 47 select SND_RAWMIDI
48 select SND_GENERIC_DRIVER
47 help 49 help
48 Say Y here to include the virtual MIDI driver. This driver 50 Say Y here to include the virtual MIDI driver. This driver
49 allows to connect applications using raw MIDI devices to 51 allows to connect applications using raw MIDI devices to
@@ -59,6 +61,7 @@ config SND_MTPAV
59 depends on SND 61 depends on SND
60 select SND_TIMER 62 select SND_TIMER
61 select SND_RAWMIDI 63 select SND_RAWMIDI
64 select SND_GENERIC_DRIVER
62 help 65 help
63 To use a MOTU MidiTimePiece AV multiport MIDI adapter 66 To use a MOTU MidiTimePiece AV multiport MIDI adapter
64 connected to the parallel port, say Y here and make sure that 67 connected to the parallel port, say Y here and make sure that
@@ -72,6 +75,7 @@ config SND_SERIAL_U16550
72 depends on SND 75 depends on SND
73 select SND_TIMER 76 select SND_TIMER
74 select SND_RAWMIDI 77 select SND_RAWMIDI
78 select SND_GENERIC_DRIVER
75 help 79 help
76 To include support for MIDI serial port interfaces, say Y here 80 To include support for MIDI serial port interfaces, say Y here
77 and read <file:Documentation/sound/alsa/serial-u16550.txt>. 81 and read <file:Documentation/sound/alsa/serial-u16550.txt>.
@@ -88,6 +92,7 @@ config SND_MPU401
88 tristate "Generic MPU-401 UART driver" 92 tristate "Generic MPU-401 UART driver"
89 depends on SND 93 depends on SND
90 select SND_MPU401_UART 94 select SND_MPU401_UART
95 select SND_GENERIC_DRIVER
91 help 96 help
92 Say Y here to include support for MIDI ports compatible with 97 Say Y here to include support for MIDI ports compatible with
93 the Roland MPU-401 interface in UART mode. 98 the Roland MPU-401 interface in UART mode.
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index a61640cf7ae7..64ef7f62851d 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -337,7 +337,7 @@ static int snd_card_dummy_playback_open(snd_pcm_substream_t * substream)
337 snd_card_dummy_pcm_t *dpcm; 337 snd_card_dummy_pcm_t *dpcm;
338 int err; 338 int err;
339 339
340 dpcm = kcalloc(1, sizeof(*dpcm), GFP_KERNEL); 340 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
341 if (dpcm == NULL) 341 if (dpcm == NULL)
342 return -ENOMEM; 342 return -ENOMEM;
343 init_timer(&dpcm->timer); 343 init_timer(&dpcm->timer);
@@ -368,7 +368,7 @@ static int snd_card_dummy_capture_open(snd_pcm_substream_t * substream)
368 snd_card_dummy_pcm_t *dpcm; 368 snd_card_dummy_pcm_t *dpcm;
369 int err; 369 int err;
370 370
371 dpcm = kcalloc(1, sizeof(*dpcm), GFP_KERNEL); 371 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
372 if (dpcm == NULL) 372 if (dpcm == NULL)
373 return -ENOMEM; 373 return -ENOMEM;
374 init_timer(&dpcm->timer); 374 init_timer(&dpcm->timer);
@@ -600,6 +600,10 @@ static int __init snd_card_dummy_probe(int dev)
600 strcpy(card->driver, "Dummy"); 600 strcpy(card->driver, "Dummy");
601 strcpy(card->shortname, "Dummy"); 601 strcpy(card->shortname, "Dummy");
602 sprintf(card->longname, "Dummy %i", dev + 1); 602 sprintf(card->longname, "Dummy %i", dev + 1);
603
604 if ((err = snd_card_set_generic_dev(card)) < 0)
605 goto __nodev;
606
603 if ((err = snd_card_register(card)) == 0) { 607 if ((err = snd_card_register(card)) == 0) {
604 snd_dummy_cards[dev] = card; 608 snd_dummy_cards[dev] = card;
605 return 0; 609 return 0;
diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
index cb36ecb78697..54e2ff9b5ca1 100644
--- a/sound/drivers/mpu401/mpu401.c
+++ b/sound/drivers/mpu401/mpu401.c
@@ -77,20 +77,26 @@ static int snd_mpu401_create(int dev, snd_card_t **rcard)
77 strcat(card->longname, "polled"); 77 strcat(card->longname, "polled");
78 } 78 }
79 79
80 if (snd_mpu401_uart_new(card, 0, 80 if ((err = snd_mpu401_uart_new(card, 0,
81 MPU401_HW_MPU401, 81 MPU401_HW_MPU401,
82 port[dev], 0, 82 port[dev], 0,
83 irq[dev], irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL) < 0) { 83 irq[dev], irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL)) < 0) {
84 printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); 84 printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]);
85 snd_card_free(card); 85 goto _err;
86 return -ENODEV;
87 }
88 if ((err = snd_card_register(card)) < 0) {
89 snd_card_free(card);
90 return err;
91 } 86 }
87
88 if ((err = snd_card_set_generic_dev(card)) < 0)
89 goto _err;
90
91 if ((err = snd_card_register(card)) < 0)
92 goto _err;
93
92 *rcard = card; 94 *rcard = card;
93 return 0; 95 return 0;
96
97 _err:
98 snd_card_free(card);
99 return err;
94} 100}
95 101
96static int __devinit snd_mpu401_probe(int dev) 102static int __devinit snd_mpu401_probe(int dev)
diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c
index 0f83c5241b6b..fe3f921ffbe3 100644
--- a/sound/drivers/mpu401/mpu401_uart.c
+++ b/sound/drivers/mpu401/mpu401_uart.c
@@ -463,7 +463,7 @@ int snd_mpu401_uart_new(snd_card_t * card, int device,
463 *rrawmidi = NULL; 463 *rrawmidi = NULL;
464 if ((err = snd_rawmidi_new(card, "MPU-401U", device, 1, 1, &rmidi)) < 0) 464 if ((err = snd_rawmidi_new(card, "MPU-401U", device, 1, 1, &rmidi)) < 0)
465 return err; 465 return err;
466 mpu = kcalloc(1, sizeof(*mpu), GFP_KERNEL); 466 mpu = kzalloc(sizeof(*mpu), GFP_KERNEL);
467 if (mpu == NULL) { 467 if (mpu == NULL) {
468 snd_device_free(card, rmidi); 468 snd_device_free(card, rmidi);
469 return -ENOMEM; 469 return -ENOMEM;
diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c
index 1280a57c49eb..3a25c89d2983 100644
--- a/sound/drivers/mtpav.c
+++ b/sound/drivers/mtpav.c
@@ -688,7 +688,7 @@ static int snd_mtpav_get_RAWMIDI(mtpav_t * mcard)
688 688
689static mtpav_t *new_mtpav(void) 689static mtpav_t *new_mtpav(void)
690{ 690{
691 mtpav_t *ncrd = kcalloc(1, sizeof(*ncrd), GFP_KERNEL); 691 mtpav_t *ncrd = kzalloc(sizeof(*ncrd), GFP_KERNEL);
692 if (ncrd != NULL) { 692 if (ncrd != NULL) {
693 spin_lock_init(&ncrd->spinlock); 693 spin_lock_init(&ncrd->spinlock);
694 694
@@ -757,6 +757,9 @@ static int __init alsa_card_mtpav_init(void)
757 if (err < 0) 757 if (err < 0)
758 goto __error; 758 goto __error;
759 759
760 if ((err = snd_card_set_generic_dev(mtp_card->card)) < 0)
761 goto __error;
762
760 err = snd_card_register(mtp_card->card); // don't snd_card_register until AFTER all cards reources done! 763 err = snd_card_register(mtp_card->card); // don't snd_card_register until AFTER all cards reources done!
761 764
762 //printk("snd_card_register returned %d\n", err); 765 //printk("snd_card_register returned %d\n", err);
diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c
index c313e5205cb8..1f84d78260de 100644
--- a/sound/drivers/opl3/opl3_lib.c
+++ b/sound/drivers/opl3/opl3_lib.c
@@ -354,7 +354,7 @@ int snd_opl3_new(snd_card_t *card,
354 int err; 354 int err;
355 355
356 *ropl3 = NULL; 356 *ropl3 = NULL;
357 opl3 = kcalloc(1, sizeof(*opl3), GFP_KERNEL); 357 opl3 = kzalloc(sizeof(*opl3), GFP_KERNEL);
358 if (opl3 == NULL) 358 if (opl3 == NULL)
359 return -ENOMEM; 359 return -ENOMEM;
360 360
diff --git a/sound/drivers/opl3/opl3_oss.c b/sound/drivers/opl3/opl3_oss.c
index 33da334ae981..21a2b409d6d3 100644
--- a/sound/drivers/opl3/opl3_oss.c
+++ b/sound/drivers/opl3/opl3_oss.c
@@ -241,7 +241,7 @@ static int snd_opl3_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format,
241 } 241 }
242 242
243 size = sizeof(*put) + sizeof(fm_xinstrument_t); 243 size = sizeof(*put) + sizeof(fm_xinstrument_t);
244 put = kcalloc(1, size, GFP_KERNEL); 244 put = kzalloc(size, GFP_KERNEL);
245 if (put == NULL) 245 if (put == NULL)
246 return -ENOMEM; 246 return -ENOMEM;
247 /* build header */ 247 /* build header */
diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
index 8261464dade8..380c2c704c54 100644
--- a/sound/drivers/opl4/opl4_lib.c
+++ b/sound/drivers/opl4/opl4_lib.c
@@ -204,7 +204,7 @@ int snd_opl4_create(snd_card_t *card,
204 if (ropl4) 204 if (ropl4)
205 *ropl4 = NULL; 205 *ropl4 = NULL;
206 206
207 opl4 = kcalloc(1, sizeof(*opl4), GFP_KERNEL); 207 opl4 = kzalloc(sizeof(*opl4), GFP_KERNEL);
208 if (!opl4) 208 if (!opl4)
209 return -ENOMEM; 209 return -ENOMEM;
210 210
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
index 986df35fb829..416172ea1f47 100644
--- a/sound/drivers/serial-u16550.c
+++ b/sound/drivers/serial-u16550.c
@@ -779,7 +779,7 @@ static int __init snd_uart16550_create(snd_card_t * card,
779 int err; 779 int err;
780 780
781 781
782 if ((uart = kcalloc(1, sizeof(*uart), GFP_KERNEL)) == NULL) 782 if ((uart = kzalloc(sizeof(*uart), GFP_KERNEL)) == NULL)
783 return -ENOMEM; 783 return -ENOMEM;
784 uart->adaptor = adaptor; 784 uart->adaptor = adaptor;
785 uart->card = card; 785 uart->card = card;
@@ -928,15 +928,11 @@ static int __init snd_serial_probe(int dev)
928 base[dev], 928 base[dev],
929 adaptor[dev], 929 adaptor[dev],
930 droponfull[dev], 930 droponfull[dev],
931 &uart)) < 0) { 931 &uart)) < 0)
932 snd_card_free(card); 932 goto _err;
933 return err;
934 }
935 933
936 if ((err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi)) < 0) { 934 if ((err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi)) < 0)
937 snd_card_free(card); 935 goto _err;
938 return err;
939 }
940 936
941 sprintf(card->longname, "%s at 0x%lx, irq %d speed %d div %d outs %d ins %d adaptor %s droponfull %d", 937 sprintf(card->longname, "%s at 0x%lx, irq %d speed %d div %d outs %d ins %d adaptor %s droponfull %d",
942 card->shortname, 938 card->shortname,
@@ -949,12 +945,18 @@ static int __init snd_serial_probe(int dev)
949 adaptor_names[uart->adaptor], 945 adaptor_names[uart->adaptor],
950 uart->drop_on_full); 946 uart->drop_on_full);
951 947
952 if ((err = snd_card_register(card)) < 0) { 948 if ((err = snd_card_set_generic_dev(card)) < 0)
953 snd_card_free(card); 949 goto _err;
954 return err; 950
955 } 951 if ((err = snd_card_register(card)) < 0)
952 goto _err;
953
956 snd_serial_cards[dev] = card; 954 snd_serial_cards[dev] = card;
957 return 0; 955 return 0;
956
957 _err:
958 snd_card_free(card);
959 return err;
958} 960}
959 961
960static int __init alsa_card_serial_init(void) 962static int __init alsa_card_serial_init(void)
diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c
index 5937711e9505..af12185ab8a2 100644
--- a/sound/drivers/virmidi.c
+++ b/sound/drivers/virmidi.c
@@ -116,6 +116,10 @@ static int __init snd_card_virmidi_probe(int dev)
116 strcpy(card->driver, "VirMIDI"); 116 strcpy(card->driver, "VirMIDI");
117 strcpy(card->shortname, "VirMIDI"); 117 strcpy(card->shortname, "VirMIDI");
118 sprintf(card->longname, "Virtual MIDI Card %i", dev + 1); 118 sprintf(card->longname, "Virtual MIDI Card %i", dev + 1);
119
120 if ((err = snd_card_set_generic_dev(card)) < 0)
121 goto __nodev;
122
119 if ((err = snd_card_register(card)) == 0) { 123 if ((err = snd_card_register(card)) == 0) {
120 snd_virmidi_cards[dev] = card; 124 snd_virmidi_cards[dev] = card;
121 return 0; 125 return 0;
diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c
index c6fa5afa3e9a..4697b1d75cbb 100644
--- a/sound/drivers/vx/vx_core.c
+++ b/sound/drivers/vx/vx_core.c
@@ -782,7 +782,7 @@ vx_core_t *snd_vx_create(snd_card_t *card, struct snd_vx_hardware *hw,
782 782
783 snd_assert(card && hw && ops, return NULL); 783 snd_assert(card && hw && ops, return NULL);
784 784
785 chip = kcalloc(1, sizeof(*chip) + extra_size, GFP_KERNEL); 785 chip = kzalloc(sizeof(*chip) + extra_size, GFP_KERNEL);
786 if (! chip) { 786 if (! chip) {
787 snd_printk(KERN_ERR "vx_core: no memory\n"); 787 snd_printk(KERN_ERR "vx_core: no memory\n");
788 return NULL; 788 return NULL;
diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c
index d4becf44e247..c2312d912fc7 100644
--- a/sound/drivers/vx/vx_pcm.c
+++ b/sound/drivers/vx/vx_pcm.c
@@ -473,7 +473,7 @@ static int vx_alloc_pipe(vx_core_t *chip, int capture,
473 return err; 473 return err;
474 474
475 /* initialize the pipe record */ 475 /* initialize the pipe record */
476 pipe = kcalloc(1, sizeof(*pipe), GFP_KERNEL); 476 pipe = kzalloc(sizeof(*pipe), GFP_KERNEL);
477 if (! pipe) { 477 if (! pipe) {
478 /* release the pipe */ 478 /* release the pipe */
479 vx_init_rmh(&rmh, CMD_FREE_PIPE); 479 vx_init_rmh(&rmh, CMD_FREE_PIPE);
diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c
index a3fda859dd15..a21f7d541f86 100644
--- a/sound/i2c/cs8427.c
+++ b/sound/i2c/cs8427.c
@@ -200,7 +200,7 @@ int snd_cs8427_create(snd_i2c_bus_t *bus,
200 200
201 if ((err = snd_i2c_device_create(bus, "CS8427", CS8427_ADDR | (addr & 7), &device)) < 0) 201 if ((err = snd_i2c_device_create(bus, "CS8427", CS8427_ADDR | (addr & 7), &device)) < 0)
202 return err; 202 return err;
203 chip = device->private_data = kcalloc(1, sizeof(*chip), GFP_KERNEL); 203 chip = device->private_data = kzalloc(sizeof(*chip), GFP_KERNEL);
204 if (chip == NULL) { 204 if (chip == NULL) {
205 snd_i2c_device_free(device); 205 snd_i2c_device_free(device);
206 return -ENOMEM; 206 return -ENOMEM;
diff --git a/sound/i2c/i2c.c b/sound/i2c/i2c.c
index e8fa7e1a68e8..e4e505b9d88b 100644
--- a/sound/i2c/i2c.c
+++ b/sound/i2c/i2c.c
@@ -81,7 +81,7 @@ int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t *master
81 }; 81 };
82 82
83 *ri2c = NULL; 83 *ri2c = NULL;
84 bus = kcalloc(1, sizeof(*bus), GFP_KERNEL); 84 bus = kzalloc(sizeof(*bus), GFP_KERNEL);
85 if (bus == NULL) 85 if (bus == NULL)
86 return -ENOMEM; 86 return -ENOMEM;
87 init_MUTEX(&bus->lock_mutex); 87 init_MUTEX(&bus->lock_mutex);
@@ -108,7 +108,7 @@ int snd_i2c_device_create(snd_i2c_bus_t *bus, const char *name, unsigned char ad
108 108
109 *rdevice = NULL; 109 *rdevice = NULL;
110 snd_assert(bus != NULL, return -EINVAL); 110 snd_assert(bus != NULL, return -EINVAL);
111 device = kcalloc(1, sizeof(*device), GFP_KERNEL); 111 device = kzalloc(sizeof(*device), GFP_KERNEL);
112 if (device == NULL) 112 if (device == NULL)
113 return -ENOMEM; 113 return -ENOMEM;
114 device->addr = addr; 114 device->addr = addr;
diff --git a/sound/i2c/l3/uda1341.c b/sound/i2c/l3/uda1341.c
index e13122f3fc50..103a7dcd0dde 100644
--- a/sound/i2c/l3/uda1341.c
+++ b/sound/i2c/l3/uda1341.c
@@ -17,7 +17,7 @@
17 * 2002-05-12 Tomas Kasparek another code cleanup 17 * 2002-05-12 Tomas Kasparek another code cleanup
18 */ 18 */
19 19
20/* $Id: uda1341.c,v 1.15 2005/01/03 12:05:20 tiwai Exp $ */ 20/* $Id: uda1341.c,v 1.16 2005/09/09 13:22:34 tiwai Exp $ */
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/module.h> 23#include <linux/module.h>
@@ -670,7 +670,7 @@ int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clnt)
670 670
671 snd_assert(card != NULL, return -EINVAL); 671 snd_assert(card != NULL, return -EINVAL);
672 672
673 uda1341 = kcalloc(1, sizeof(*uda1341), GFP_KERNEL); 673 uda1341 = kzalloc(sizeof(*uda1341), GFP_KERNEL);
674 if (uda1341 == NULL) 674 if (uda1341 == NULL)
675 return -ENOMEM; 675 return -ENOMEM;
676 676
@@ -707,7 +707,7 @@ static int uda1341_attach(struct l3_client *clnt)
707{ 707{
708 struct uda1341 *uda; 708 struct uda1341 *uda;
709 709
710 uda = kcalloc(1, sizeof(*uda), 0, GFP_KERNEL); 710 uda = kzalloc(sizeof(*uda), 0, GFP_KERNEL);
711 if (!uda) 711 if (!uda)
712 return -ENOMEM; 712 return -ENOMEM;
713 713
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index 5adde308a00f..af5eadcddd92 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -92,7 +92,7 @@ int snd_ak4114_create(snd_card_t *card,
92 .dev_free = snd_ak4114_dev_free, 92 .dev_free = snd_ak4114_dev_free,
93 }; 93 };
94 94
95 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 95 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
96 if (chip == NULL) 96 if (chip == NULL)
97 return -ENOMEM; 97 return -ENOMEM;
98 spin_lock_init(&chip->lock); 98 spin_lock_init(&chip->lock);
diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c
index 0419c4336a55..d51b51dd86d6 100644
--- a/sound/i2c/other/ak4117.c
+++ b/sound/i2c/other/ak4117.c
@@ -83,7 +83,7 @@ int snd_ak4117_create(snd_card_t *card, ak4117_read_t *read, ak4117_write_t *wri
83 .dev_free = snd_ak4117_dev_free, 83 .dev_free = snd_ak4117_dev_free,
84 }; 84 };
85 85
86 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 86 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
87 if (chip == NULL) 87 if (chip == NULL)
88 return -ENOMEM; 88 return -ENOMEM;
89 spin_lock_init(&chip->lock); 89 spin_lock_init(&chip->lock);
diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c
index 2da8d7f157f4..fd65da654267 100644
--- a/sound/i2c/tea6330t.c
+++ b/sound/i2c/tea6330t.c
@@ -281,7 +281,7 @@ int snd_tea6330t_update_mixer(snd_card_t * card,
281 u8 default_treble, default_bass; 281 u8 default_treble, default_bass;
282 unsigned char bytes[7]; 282 unsigned char bytes[7];
283 283
284 tea = kcalloc(1, sizeof(*tea), GFP_KERNEL); 284 tea = kzalloc(sizeof(*tea), GFP_KERNEL);
285 if (tea == NULL) 285 if (tea == NULL)
286 return -ENOMEM; 286 return -ENOMEM;
287 if ((err = snd_i2c_device_create(bus, "TEA6330T", TEA6330T_ADDR, &device)) < 0) { 287 if ((err = snd_i2c_device_create(bus, "TEA6330T", TEA6330T_ADDR, &device)) < 0) {
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index 5c3948311528..5d6c300ac0d5 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -6,12 +6,12 @@ menu "ISA devices"
6config SND_AD1848_LIB 6config SND_AD1848_LIB
7 tristate 7 tristate
8 select SND_PCM 8 select SND_PCM
9 select SND_GENERIC_PM 9 select SND_GENERIC_DRIVER
10 10
11config SND_CS4231_LIB 11config SND_CS4231_LIB
12 tristate 12 tristate
13 select SND_PCM 13 select SND_PCM
14 select SND_GENERIC_PM 14 select SND_GENERIC_DRIVER
15 15
16config SND_AD1816A 16config SND_AD1816A
17 tristate "Analog Devices SoundPort AD1816A" 17 tristate "Analog Devices SoundPort AD1816A"
@@ -97,6 +97,7 @@ config SND_ES1688
97 select SND_OPL3_LIB 97 select SND_OPL3_LIB
98 select SND_MPU401_UART 98 select SND_MPU401_UART
99 select SND_PCM 99 select SND_PCM
100 select SND_GENERIC_DRIVER
100 help 101 help
101 Say Y here to include support for ESS AudioDrive ES688 or 102 Say Y here to include support for ESS AudioDrive ES688 or
102 ES1688 chips. 103 ES1688 chips.
@@ -110,7 +111,7 @@ config SND_ES18XX
110 select SND_OPL3_LIB 111 select SND_OPL3_LIB
111 select SND_MPU401_UART 112 select SND_MPU401_UART
112 select SND_PCM 113 select SND_PCM
113 select SND_GENERIC_PM 114 select SND_GENERIC_DRIVER
114 help 115 help
115 Say Y here to include support for ESS AudioDrive ES18xx chips. 116 Say Y here to include support for ESS AudioDrive ES18xx chips.
116 117
@@ -126,6 +127,7 @@ config SND_GUSCLASSIC
126 select SND_RAWMIDI 127 select SND_RAWMIDI
127 select SND_PCM 128 select SND_PCM
128 select SND_GUS_SYNTH 129 select SND_GUS_SYNTH
130 select SND_GENERIC_DRIVER
129 help 131 help
130 Say Y here to include support for Gravis UltraSound Classic 132 Say Y here to include support for Gravis UltraSound Classic
131 soundcards. 133 soundcards.
@@ -140,6 +142,7 @@ config SND_GUSEXTREME
140 select SND_MPU401_UART 142 select SND_MPU401_UART
141 select SND_PCM 143 select SND_PCM
142 select SND_GUS_SYNTH 144 select SND_GUS_SYNTH
145 select SND_GENERIC_DRIVER
143 help 146 help
144 Say Y here to include support for Gravis UltraSound Extreme 147 Say Y here to include support for Gravis UltraSound Extreme
145 soundcards. 148 soundcards.
@@ -153,6 +156,7 @@ config SND_GUSMAX
153 select SND_RAWMIDI 156 select SND_RAWMIDI
154 select SND_CS4231_LIB 157 select SND_CS4231_LIB
155 select SND_GUS_SYNTH 158 select SND_GUS_SYNTH
159 select SND_GENERIC_DRIVER
156 help 160 help
157 Say Y here to include support for Gravis UltraSound MAX 161 Say Y here to include support for Gravis UltraSound MAX
158 soundcards. 162 soundcards.
@@ -166,7 +170,7 @@ config SND_INTERWAVE
166 select SND_RAWMIDI 170 select SND_RAWMIDI
167 select SND_CS4231_LIB 171 select SND_CS4231_LIB
168 select SND_GUS_SYNTH 172 select SND_GUS_SYNTH
169 select ISAPNP 173 select SND_GENERIC_DRIVER
170 help 174 help
171 Say Y here to include support for AMD InterWave based 175 Say Y here to include support for AMD InterWave based
172 soundcards (Gravis UltraSound Plug & Play, STB SoundRage32, 176 soundcards (Gravis UltraSound Plug & Play, STB SoundRage32,
@@ -181,7 +185,7 @@ config SND_INTERWAVE_STB
181 select SND_RAWMIDI 185 select SND_RAWMIDI
182 select SND_CS4231_LIB 186 select SND_CS4231_LIB
183 select SND_GUS_SYNTH 187 select SND_GUS_SYNTH
184 select ISAPNP 188 select SND_GENERIC_DRIVER
185 help 189 help
186 Say Y here to include support for AMD InterWave based 190 Say Y here to include support for AMD InterWave based
187 soundcards with a TEA6330T bass and treble regulator 191 soundcards with a TEA6330T bass and treble regulator
@@ -224,6 +228,7 @@ config SND_OPTI93X
224 select SND_OPL3_LIB 228 select SND_OPL3_LIB
225 select SND_MPU401_UART 229 select SND_MPU401_UART
226 select SND_PCM 230 select SND_PCM
231 select SND_GENERIC_DRIVER
227 help 232 help
228 Say Y here to include support for soundcards based on Opti 233 Say Y here to include support for soundcards based on Opti
229 82C93x chips. 234 82C93x chips.
@@ -237,6 +242,7 @@ config SND_SB8
237 select SND_OPL3_LIB 242 select SND_OPL3_LIB
238 select SND_RAWMIDI 243 select SND_RAWMIDI
239 select SND_PCM 244 select SND_PCM
245 select SND_GENERIC_DRIVER
240 help 246 help
241 Say Y here to include support for Creative Sound Blaster 1.0/ 247 Say Y here to include support for Creative Sound Blaster 1.0/
242 2.0/Pro (8-bit) or 100% compatible soundcards. 248 2.0/Pro (8-bit) or 100% compatible soundcards.
@@ -250,6 +256,7 @@ config SND_SB16
250 select SND_OPL3_LIB 256 select SND_OPL3_LIB
251 select SND_MPU401_UART 257 select SND_MPU401_UART
252 select SND_PCM 258 select SND_PCM
259 select SND_GENERIC_DRIVER
253 help 260 help
254 Say Y here to include support for Sound Blaster 16 soundcards 261 Say Y here to include support for Sound Blaster 16 soundcards
255 (including the Plug and Play version). 262 (including the Plug and Play version).
@@ -263,6 +270,7 @@ config SND_SBAWE
263 select SND_OPL3_LIB 270 select SND_OPL3_LIB
264 select SND_MPU401_UART 271 select SND_MPU401_UART
265 select SND_PCM 272 select SND_PCM
273 select SND_GENERIC_DRIVER
266 help 274 help
267 Say Y here to include support for Sound Blaster AWE soundcards 275 Say Y here to include support for Sound Blaster AWE soundcards
268 (including the Plug and Play version). 276 (including the Plug and Play version).
diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c
index ae860360ecf9..27a9dcfbba00 100644
--- a/sound/isa/ad1816a/ad1816a_lib.c
+++ b/sound/isa/ad1816a/ad1816a_lib.c
@@ -591,7 +591,7 @@ int snd_ad1816a_create(snd_card_t *card,
591 591
592 *rchip = NULL; 592 *rchip = NULL;
593 593
594 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 594 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
595 if (chip == NULL) 595 if (chip == NULL)
596 return -ENOMEM; 596 return -ENOMEM;
597 chip->irq = -1; 597 chip->irq = -1;
diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c
index 8c399340cd72..3ebcc482b07a 100644
--- a/sound/isa/ad1848/ad1848.c
+++ b/sound/isa/ad1848/ad1848.c
@@ -91,35 +91,36 @@ static int __init snd_card_ad1848_probe(int dev)
91 irq[dev], 91 irq[dev],
92 dma1[dev], 92 dma1[dev],
93 thinkpad[dev] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT, 93 thinkpad[dev] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT,
94 &chip)) < 0) { 94 &chip)) < 0)
95 snd_card_free(card); 95 goto _err;
96 return err; 96
97 } 97 if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0)
98 goto _err;
99
100 if ((err = snd_ad1848_mixer(chip)) < 0)
101 goto _err;
98 102
99 if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0) {
100 snd_card_free(card);
101 return err;
102 }
103 if ((err = snd_ad1848_mixer(chip)) < 0) {
104 snd_card_free(card);
105 return err;
106 }
107 strcpy(card->driver, "AD1848"); 103 strcpy(card->driver, "AD1848");
108 strcpy(card->shortname, pcm->name); 104 strcpy(card->shortname, pcm->name);
109 105
110 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", 106 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
111 pcm->name, chip->port, irq[dev], dma1[dev]); 107 pcm->name, chip->port, irq[dev], dma1[dev]);
112 108
113 if (thinkpad[dev]) { 109 if (thinkpad[dev])
114 strcat(card->longname, " [Thinkpad]"); 110 strcat(card->longname, " [Thinkpad]");
115 }
116 111
117 if ((err = snd_card_register(card)) < 0) { 112 if ((err = snd_card_set_generic_dev(card)) < 0)
118 snd_card_free(card); 113 goto _err;
119 return err; 114
120 } 115 if ((err = snd_card_register(card)) < 0)
116 goto _err;
117
121 snd_ad1848_cards[dev] = card; 118 snd_ad1848_cards[dev] = card;
122 return 0; 119 return 0;
120
121 _err:
122 snd_card_free(card);
123 return err;
123} 124}
124 125
125static int __init alsa_card_ad1848_init(void) 126static int __init alsa_card_ad1848_init(void)
diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c
index bc642dc94547..303861cd03cd 100644
--- a/sound/isa/ad1848/ad1848_lib.c
+++ b/sound/isa/ad1848/ad1848_lib.c
@@ -890,7 +890,7 @@ int snd_ad1848_create(snd_card_t * card,
890 int err; 890 int err;
891 891
892 *rchip = NULL; 892 *rchip = NULL;
893 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 893 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
894 if (chip == NULL) 894 if (chip == NULL)
895 return -ENOMEM; 895 return -ENOMEM;
896 spin_lock_init(&chip->reg_lock); 896 spin_lock_init(&chip->reg_lock);
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index 1fce8b9f37cf..5252206ea388 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -438,33 +438,37 @@ static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip)
438/* 438/*
439 */ 439 */
440 440
441#ifdef CONFIG_PNP
442#define is_isapnp_selected(dev) isapnp[dev]
443#else
444#define is_isapnp_selected(dev) 0
445#endif
446
447#define PFX "cmi8330: "
448
441static int __devinit snd_cmi8330_probe(int dev, 449static int __devinit snd_cmi8330_probe(int dev,
442 struct pnp_card_link *pcard, 450 struct pnp_card_link *pcard,
443 const struct pnp_card_device_id *pid) 451 const struct pnp_card_device_id *pid)
444{ 452{
445 snd_card_t *card; 453 snd_card_t *card;
446 struct snd_cmi8330 *acard; 454 struct snd_cmi8330 *acard;
447 unsigned long flags;
448 int i, err; 455 int i, err;
449 456
450#ifdef CONFIG_PNP 457 if (! is_isapnp_selected(dev)) {
451 if (!isapnp[dev]) {
452#endif
453 if (wssport[dev] == SNDRV_AUTO_PORT) { 458 if (wssport[dev] == SNDRV_AUTO_PORT) {
454 snd_printk("specify wssport\n"); 459 snd_printk(KERN_ERR PFX "specify wssport\n");
455 return -EINVAL; 460 return -EINVAL;
456 } 461 }
457 if (sbport[dev] == SNDRV_AUTO_PORT) { 462 if (sbport[dev] == SNDRV_AUTO_PORT) {
458 snd_printk("specify sbport\n"); 463 snd_printk(KERN_ERR PFX "specify sbport\n");
459 return -EINVAL; 464 return -EINVAL;
460 } 465 }
461#ifdef CONFIG_PNP
462 } 466 }
463#endif 467
464 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 468 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
465 sizeof(struct snd_cmi8330)); 469 sizeof(struct snd_cmi8330));
466 if (card == NULL) { 470 if (card == NULL) {
467 snd_printk("could not get a new card\n"); 471 snd_printk(KERN_ERR PFX "could not get a new card\n");
468 return -ENOMEM; 472 return -ENOMEM;
469 } 473 }
470 acard = (struct snd_cmi8330 *)card->private_data; 474 acard = (struct snd_cmi8330 *)card->private_data;
@@ -473,9 +477,8 @@ static int __devinit snd_cmi8330_probe(int dev,
473#ifdef CONFIG_PNP 477#ifdef CONFIG_PNP
474 if (isapnp[dev]) { 478 if (isapnp[dev]) {
475 if ((err = snd_cmi8330_pnp(dev, acard, pcard, pid)) < 0) { 479 if ((err = snd_cmi8330_pnp(dev, acard, pcard, pid)) < 0) {
476 snd_printk("PnP detection failed\n"); 480 snd_printk(KERN_ERR PFX "PnP detection failed\n");
477 snd_card_free(card); 481 goto _err;
478 return err;
479 } 482 }
480 snd_card_set_dev(card, &pcard->card->dev); 483 snd_card_set_dev(card, &pcard->card->dev);
481 } 484 }
@@ -487,14 +490,13 @@ static int __devinit snd_cmi8330_probe(int dev,
487 wssdma[dev], 490 wssdma[dev],
488 AD1848_HW_DETECT, 491 AD1848_HW_DETECT,
489 &acard->wss)) < 0) { 492 &acard->wss)) < 0) {
490 snd_printk("(AD1848) device busy??\n"); 493 snd_printk(KERN_ERR PFX "(AD1848) device busy??\n");
491 snd_card_free(card); 494 goto _err;
492 return err;
493 } 495 }
494 if (acard->wss->hardware != AD1848_HW_CMI8330) { 496 if (acard->wss->hardware != AD1848_HW_CMI8330) {
495 snd_printk("(AD1848) not found during probe\n"); 497 snd_printk(KERN_ERR PFX "(AD1848) not found during probe\n");
496 snd_card_free(card); 498 err = -ENODEV;
497 return -ENODEV; 499 goto _err;
498 } 500 }
499 501
500 if ((err = snd_sbdsp_create(card, sbport[dev], 502 if ((err = snd_sbdsp_create(card, sbport[dev],
@@ -503,32 +505,26 @@ static int __devinit snd_cmi8330_probe(int dev,
503 sbdma8[dev], 505 sbdma8[dev],
504 sbdma16[dev], 506 sbdma16[dev],
505 SB_HW_AUTO, &acard->sb)) < 0) { 507 SB_HW_AUTO, &acard->sb)) < 0) {
506 snd_printk("(SB16) device busy??\n"); 508 snd_printk(KERN_ERR PFX "(SB16) device busy??\n");
507 snd_card_free(card); 509 goto _err;
508 return err;
509 } 510 }
510 if (acard->sb->hardware != SB_HW_16) { 511 if (acard->sb->hardware != SB_HW_16) {
511 snd_printk("(SB16) not found during probe\n"); 512 snd_printk(KERN_ERR PFX "(SB16) not found during probe\n");
512 snd_card_free(card); 513 goto _err;
513 return -ENODEV;
514 } 514 }
515 515
516 spin_lock_irqsave(&acard->wss->reg_lock, flags);
517 snd_ad1848_out(acard->wss, AD1848_MISC_INFO, 0x40); /* switch on MODE2 */ 516 snd_ad1848_out(acard->wss, AD1848_MISC_INFO, 0x40); /* switch on MODE2 */
518 for (i = CMI8330_RMUX3D; i <= CMI8330_CDINGAIN; i++) 517 for (i = CMI8330_RMUX3D; i <= CMI8330_CDINGAIN; i++)
519 snd_ad1848_out(acard->wss, i, snd_cmi8330_image[i - CMI8330_RMUX3D]); 518 snd_ad1848_out(acard->wss, i, snd_cmi8330_image[i - CMI8330_RMUX3D]);
520 spin_unlock_irqrestore(&acard->wss->reg_lock, flags);
521 519
522 if ((err = snd_cmi8330_mixer(card, acard)) < 0) { 520 if ((err = snd_cmi8330_mixer(card, acard)) < 0) {
523 snd_printk("failed to create mixers\n"); 521 snd_printk(KERN_ERR PFX "failed to create mixers\n");
524 snd_card_free(card); 522 goto _err;
525 return err;
526 } 523 }
527 524
528 if ((err = snd_cmi8330_pcm(card, acard)) < 0) { 525 if ((err = snd_cmi8330_pcm(card, acard)) < 0) {
529 snd_printk("failed to create pcms\n"); 526 snd_printk(KERN_ERR PFX "failed to create pcms\n");
530 snd_card_free(card); 527 goto _err;
531 return err;
532 } 528 }
533 529
534 strcpy(card->driver, "CMI8330/C3D"); 530 strcpy(card->driver, "CMI8330/C3D");
@@ -539,16 +535,21 @@ static int __devinit snd_cmi8330_probe(int dev,
539 wssirq[dev], 535 wssirq[dev],
540 wssdma[dev]); 536 wssdma[dev]);
541 537
542 if ((err = snd_card_register(card)) < 0) { 538 if ((err = snd_card_set_generic_dev(card)) < 0)
543 snd_card_free(card); 539 goto _err;
544 return err; 540
545 } 541 if ((err = snd_card_register(card)) < 0)
542 goto _err;
546 543
547 if (pcard) 544 if (pcard)
548 pnp_set_card_drvdata(pcard, card); 545 pnp_set_card_drvdata(pcard, card);
549 else 546 else
550 snd_cmi8330_legacy[dev] = card; 547 snd_cmi8330_legacy[dev] = card;
551 return 0; 548 return 0;
549
550 _err:
551 snd_card_free(card);
552 return err;
552} 553}
553 554
554#ifdef CONFIG_PNP 555#ifdef CONFIG_PNP
@@ -594,10 +595,8 @@ static int __init alsa_card_cmi8330_init(void)
594 for (dev = 0; dev < SNDRV_CARDS; dev++) { 595 for (dev = 0; dev < SNDRV_CARDS; dev++) {
595 if (!enable[dev]) 596 if (!enable[dev])
596 continue; 597 continue;
597#ifdef CONFIG_PNP 598 if (is_isapnp_selected(dev))
598 if (isapnp[dev])
599 continue; 599 continue;
600#endif
601 if (snd_cmi8330_probe(dev, NULL, NULL) >= 0) 600 if (snd_cmi8330_probe(dev, NULL, NULL) >= 0)
602 cards++; 601 cards++;
603 } 602 }
diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c
index 7640837659ea..9be5416bcb92 100644
--- a/sound/isa/cs423x/cs4231.c
+++ b/sound/isa/cs423x/cs4231.c
@@ -76,15 +76,15 @@ static int __init snd_card_cs4231_probe(int dev)
76 int err; 76 int err;
77 77
78 if (port[dev] == SNDRV_AUTO_PORT) { 78 if (port[dev] == SNDRV_AUTO_PORT) {
79 snd_printk("specify port\n"); 79 snd_printk(KERN_ERR "specify port\n");
80 return -EINVAL; 80 return -EINVAL;
81 } 81 }
82 if (irq[dev] == SNDRV_AUTO_IRQ) { 82 if (irq[dev] == SNDRV_AUTO_IRQ) {
83 snd_printk("specify irq\n"); 83 snd_printk(KERN_ERR "specify irq\n");
84 return -EINVAL; 84 return -EINVAL;
85 } 85 }
86 if (dma1[dev] == SNDRV_AUTO_DMA) { 86 if (dma1[dev] == SNDRV_AUTO_DMA) {
87 snd_printk("specify dma1\n"); 87 snd_printk(KERN_ERR "specify dma1\n");
88 return -EINVAL; 88 return -EINVAL;
89 } 89 }
90 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 90 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
@@ -96,15 +96,11 @@ static int __init snd_card_cs4231_probe(int dev)
96 dma1[dev], 96 dma1[dev],
97 dma2[dev], 97 dma2[dev],
98 CS4231_HW_DETECT, 98 CS4231_HW_DETECT,
99 0, &chip)) < 0) { 99 0, &chip)) < 0)
100 snd_card_free(card); 100 goto _err;
101 return err;
102 }
103 101
104 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) { 102 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0)
105 snd_card_free(card); 103 goto _err;
106 return err;
107 }
108 104
109 strcpy(card->driver, "CS4231"); 105 strcpy(card->driver, "CS4231");
110 strcpy(card->shortname, pcm->name); 106 strcpy(card->shortname, pcm->name);
@@ -113,14 +109,10 @@ static int __init snd_card_cs4231_probe(int dev)
113 if (dma2[dev] >= 0) 109 if (dma2[dev] >= 0)
114 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); 110 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
115 111
116 if ((err = snd_cs4231_mixer(chip)) < 0) { 112 if ((err = snd_cs4231_mixer(chip)) < 0)
117 snd_card_free(card); 113 goto _err;
118 return err; 114 if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0)
119 } 115 goto _err;
120 if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) {
121 snd_card_free(card);
122 return err;
123 }
124 116
125 if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { 117 if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
126 if (mpu_irq[dev] == SNDRV_AUTO_IRQ) 118 if (mpu_irq[dev] == SNDRV_AUTO_IRQ)
@@ -130,14 +122,20 @@ static int __init snd_card_cs4231_probe(int dev)
130 mpu_irq[dev], 122 mpu_irq[dev],
131 mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0, 123 mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0,
132 NULL) < 0) 124 NULL) < 0)
133 printk(KERN_ERR "cs4231: MPU401 not detected\n"); 125 printk(KERN_WARNING "cs4231: MPU401 not detected\n");
134 }
135 if ((err = snd_card_register(card)) < 0) {
136 snd_card_free(card);
137 return err;
138 } 126 }
127
128 if ((err = snd_card_set_generic_dev(card)) < 0)
129 goto _err;
130
131 if ((err = snd_card_register(card)) < 0)
132 goto _err;
139 snd_cs4231_cards[dev] = card; 133 snd_cs4231_cards[dev] = card;
140 return 0; 134 return 0;
135
136 _err:
137 snd_card_free(card);
138 return err;
141} 139}
142 140
143static int __init alsa_card_cs4231_init(void) 141static int __init alsa_card_cs4231_init(void)
diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c
index 3199941edd9b..32318258cd8e 100644
--- a/sound/isa/cs423x/cs4231_lib.c
+++ b/sound/isa/cs423x/cs4231_lib.c
@@ -1480,7 +1480,7 @@ static int snd_cs4231_new(snd_card_t * card,
1480 cs4231_t *chip; 1480 cs4231_t *chip;
1481 1481
1482 *rchip = NULL; 1482 *rchip = NULL;
1483 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1483 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1484 if (chip == NULL) 1484 if (chip == NULL)
1485 return -ENOMEM; 1485 return -ENOMEM;
1486 chip->hardware = hardware; 1486 chip->hardware = hardware;
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index 39f4eff44f5c..d28315dc72f7 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -387,6 +387,12 @@ static void snd_card_cs4236_free(snd_card_t *card)
387 } 387 }
388} 388}
389 389
390#ifdef CONFIG_PNP
391#define is_isapnp_selected(dev) isapnp[dev]
392#else
393#define is_isapnp_selected(dev) 0
394#endif
395
390static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, 396static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
391 const struct pnp_card_device_id *pid) 397 const struct pnp_card_device_id *pid)
392{ 398{
@@ -397,20 +403,16 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
397 opl3_t *opl3; 403 opl3_t *opl3;
398 int err; 404 int err;
399 405
400#ifdef CONFIG_PNP 406 if (! is_isapnp_selected(dev)) {
401 if (!isapnp[dev]) {
402#endif
403 if (port[dev] == SNDRV_AUTO_PORT) { 407 if (port[dev] == SNDRV_AUTO_PORT) {
404 snd_printk("specify port\n"); 408 snd_printk(KERN_ERR "specify port\n");
405 return -EINVAL; 409 return -EINVAL;
406 } 410 }
407 if (cport[dev] == SNDRV_AUTO_PORT) { 411 if (cport[dev] == SNDRV_AUTO_PORT) {
408 snd_printk("specify cport\n"); 412 snd_printk(KERN_ERR "specify cport\n");
409 return -EINVAL; 413 return -EINVAL;
410 } 414 }
411#ifdef CONFIG_PNP
412 } 415 }
413#endif
414 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 416 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
415 sizeof(struct snd_card_cs4236)); 417 sizeof(struct snd_card_cs4236));
416 if (card == NULL) 418 if (card == NULL)
@@ -421,8 +423,7 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
421 if (isapnp[dev]) { 423 if (isapnp[dev]) {
422 if ((err = snd_card_cs4236_pnp(dev, acard, pcard, pid))<0) { 424 if ((err = snd_card_cs4236_pnp(dev, acard, pcard, pid))<0) {
423 printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n"); 425 printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n");
424 snd_card_free(card); 426 goto _err;
425 return -ENXIO;
426 } 427 }
427 snd_card_set_dev(card, &pcard->card->dev); 428 snd_card_set_dev(card, &pcard->card->dev);
428 } 429 }
@@ -430,8 +431,8 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
430 if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT) 431 if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT)
431 if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) { 432 if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) {
432 printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]); 433 printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]);
433 snd_card_free(card); 434 err = -EBUSY;
434 return -ENOMEM; 435 goto _err;
435 } 436 }
436 437
437#ifdef CS4232 438#ifdef CS4232
@@ -443,18 +444,14 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
443 dma2[dev], 444 dma2[dev],
444 CS4231_HW_DETECT, 445 CS4231_HW_DETECT,
445 0, 446 0,
446 &chip)) < 0) { 447 &chip)) < 0)
447 snd_card_free(card); 448 goto _err;
448 return err; 449
449 } 450 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0)
450 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) { 451 goto _err;
451 snd_card_free(card); 452
452 return err; 453 if ((err = snd_cs4231_mixer(chip)) < 0)
453 } 454 goto _err;
454 if ((err = snd_cs4231_mixer(chip)) < 0) {
455 snd_card_free(card);
456 return err;
457 }
458 455
459#else /* CS4236 */ 456#else /* CS4236 */
460 if ((err = snd_cs4236_create(card, 457 if ((err = snd_cs4236_create(card,
@@ -465,18 +462,14 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
465 dma2[dev], 462 dma2[dev],
466 CS4231_HW_DETECT, 463 CS4231_HW_DETECT,
467 0, 464 0,
468 &chip)) < 0) { 465 &chip)) < 0)
469 snd_card_free(card); 466 goto _err;
470 return err; 467
471 } 468 if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0)
472 if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0) { 469 goto _err;
473 snd_card_free(card); 470
474 return err; 471 if ((err = snd_cs4236_mixer(chip)) < 0)
475 } 472 goto _err;
476 if ((err = snd_cs4236_mixer(chip)) < 0) {
477 snd_card_free(card);
478 return err;
479 }
480#endif 473#endif
481 strcpy(card->driver, pcm->name); 474 strcpy(card->driver, pcm->name);
482 strcpy(card->shortname, pcm->name); 475 strcpy(card->shortname, pcm->name);
@@ -488,21 +481,17 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
488 if (dma2[dev] >= 0) 481 if (dma2[dev] >= 0)
489 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); 482 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
490 483
491 if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) { 484 if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0)
492 snd_card_free(card); 485 goto _err;
493 return err;
494 }
495 486
496 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { 487 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
497 if (snd_opl3_create(card, 488 if (snd_opl3_create(card,
498 fm_port[dev], fm_port[dev] + 2, 489 fm_port[dev], fm_port[dev] + 2,
499 OPL3_HW_OPL3_CS, 0, &opl3) < 0) { 490 OPL3_HW_OPL3_CS, 0, &opl3) < 0) {
500 printk(KERN_ERR IDENT ": OPL3 not detected\n"); 491 printk(KERN_WARNING IDENT ": OPL3 not detected\n");
501 } else { 492 } else {
502 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { 493 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)
503 snd_card_free(card); 494 goto _err;
504 return err;
505 }
506 } 495 }
507 } 496 }
508 497
@@ -513,17 +502,23 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
513 mpu_port[dev], 0, 502 mpu_port[dev], 0,
514 mpu_irq[dev], 503 mpu_irq[dev],
515 mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL) < 0) 504 mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL) < 0)
516 printk(KERN_ERR IDENT ": MPU401 not detected\n"); 505 printk(KERN_WARNING IDENT ": MPU401 not detected\n");
517 }
518 if ((err = snd_card_register(card)) < 0) {
519 snd_card_free(card);
520 return err;
521 } 506 }
507
508 if ((err = snd_card_set_generic_dev(card)) < 0)
509 goto _err;
510
511 if ((err = snd_card_register(card)) < 0)
512 goto _err;
522 if (pcard) 513 if (pcard)
523 pnp_set_card_drvdata(pcard, card); 514 pnp_set_card_drvdata(pcard, card);
524 else 515 else
525 snd_cs4236_legacy[dev] = card; 516 snd_cs4236_legacy[dev] = card;
526 return 0; 517 return 0;
518
519 _err:
520 snd_card_free(card);
521 return err;
527} 522}
528 523
529#ifdef CONFIG_PNP 524#ifdef CONFIG_PNP
@@ -569,10 +564,8 @@ static int __init alsa_card_cs423x_init(void)
569 for (dev = 0; dev < SNDRV_CARDS; dev++) { 564 for (dev = 0; dev < SNDRV_CARDS; dev++) {
570 if (!enable[dev]) 565 if (!enable[dev])
571 continue; 566 continue;
572#ifdef CONFIG_PNP 567 if (is_isapnp_selected(dev))
573 if (isapnp[dev])
574 continue; 568 continue;
575#endif
576 if (snd_card_cs423x_probe(dev, NULL, NULL) >= 0) 569 if (snd_card_cs423x_probe(dev, NULL, NULL) >= 0)
577 cards++; 570 cards++;
578 } 571 }
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index c5eaec087b46..26a7d335ed8e 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -70,6 +70,7 @@ MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver.");
70 70
71static snd_card_t *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 71static snd_card_t *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
72 72
73#define PFX "es1688: "
73 74
74static int __init snd_audiodrive_probe(int dev) 75static int __init snd_audiodrive_probe(int dev)
75{ 76{
@@ -89,47 +90,41 @@ static int __init snd_audiodrive_probe(int dev)
89 xirq = irq[dev]; 90 xirq = irq[dev];
90 if (xirq == SNDRV_AUTO_IRQ) { 91 if (xirq == SNDRV_AUTO_IRQ) {
91 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 92 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
92 snd_card_free(card); 93 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
93 snd_printk("unable to find a free IRQ\n"); 94 err = -EBUSY;
94 return -EBUSY; 95 goto _err;
95 } 96 }
96 } 97 }
97 xmpu_irq = mpu_irq[dev]; 98 xmpu_irq = mpu_irq[dev];
98 xdma = dma8[dev]; 99 xdma = dma8[dev];
99 if (xdma == SNDRV_AUTO_DMA) { 100 if (xdma == SNDRV_AUTO_DMA) {
100 if ((xdma = snd_legacy_find_free_dma(possible_dmas)) < 0) { 101 if ((xdma = snd_legacy_find_free_dma(possible_dmas)) < 0) {
101 snd_card_free(card); 102 snd_printk(KERN_ERR PFX "unable to find a free DMA\n");
102 snd_printk("unable to find a free DMA\n"); 103 err = -EBUSY;
103 return -EBUSY; 104 goto _err;
104 } 105 }
105 } 106 }
106 107
107 if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], 108 if ((err = snd_es1688_create(card, port[dev], mpu_port[dev],
108 xirq, xmpu_irq, xdma, 109 xirq, xmpu_irq, xdma,
109 ES1688_HW_AUTO, &chip)) < 0) { 110 ES1688_HW_AUTO, &chip)) < 0)
110 snd_card_free(card); 111 goto _err;
111 return err; 112
112 } 113 if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0)
113 if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0) { 114 goto _err;
114 snd_card_free(card); 115
115 return err; 116 if ((err = snd_es1688_mixer(chip)) < 0)
116 } 117 goto _err;
117 if ((err = snd_es1688_mixer(chip)) < 0) {
118 snd_card_free(card);
119 return err;
120 }
121 118
122 strcpy(card->driver, "ES1688"); 119 strcpy(card->driver, "ES1688");
123 strcpy(card->shortname, pcm->name); 120 strcpy(card->shortname, pcm->name);
124 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port, xirq, xdma); 121 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port, xirq, xdma);
125 122
126 if ((snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_OPL3, 0, &opl3)) < 0) { 123 if ((snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_OPL3, 0, &opl3)) < 0) {
127 printk(KERN_ERR "es1688: opl3 not detected at 0x%lx\n", chip->port); 124 printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->port);
128 } else { 125 } else {
129 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { 126 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)
130 snd_card_free(card); 127 goto _err;
131 return err;
132 }
133 } 128 }
134 129
135 if (xmpu_irq >= 0 && xmpu_irq != SNDRV_AUTO_IRQ && chip->mpu_port > 0) { 130 if (xmpu_irq >= 0 && xmpu_irq != SNDRV_AUTO_IRQ && chip->mpu_port > 0) {
@@ -137,18 +132,22 @@ static int __init snd_audiodrive_probe(int dev)
137 chip->mpu_port, 0, 132 chip->mpu_port, 0,
138 xmpu_irq, 133 xmpu_irq,
139 SA_INTERRUPT, 134 SA_INTERRUPT,
140 NULL)) < 0) { 135 NULL)) < 0)
141 snd_card_free(card); 136 goto _err;
142 return err;
143 }
144 }
145 if ((err = snd_card_register(card)) < 0) {
146 snd_card_free(card);
147 return err;
148 } 137 }
138
139 if ((err = snd_card_set_generic_dev(card)) < 0)
140 goto _err;
141
142 if ((err = snd_card_register(card)) < 0)
143 goto _err;
144
149 snd_audiodrive_cards[dev] = card; 145 snd_audiodrive_cards[dev] = card;
150 return 0; 146 return 0;
151 147
148 _err:
149 snd_card_free(card);
150 return err;
152} 151}
153 152
154static int __init snd_audiodrive_legacy_auto_probe(unsigned long xport) 153static int __init snd_audiodrive_legacy_auto_probe(unsigned long xport)
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index 17f68d07d9b2..aac898765c02 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -649,7 +649,7 @@ int snd_es1688_create(snd_card_t * card,
649 int err; 649 int err;
650 650
651 *rchip = NULL; 651 *rchip = NULL;
652 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 652 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
653 if (chip == NULL) 653 if (chip == NULL)
654 return -ENOMEM; 654 return -ENOMEM;
655 chip->irq = -1; 655 chip->irq = -1;
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 1d832b2adb7c..d0ea19f42703 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -1686,7 +1686,7 @@ static int __devinit snd_es18xx_new_device(snd_card_t * card,
1686 int err; 1686 int err;
1687 1687
1688 *rchip = NULL; 1688 *rchip = NULL;
1689 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1689 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1690 if (chip == NULL) 1690 if (chip == NULL)
1691 return -ENOMEM; 1691 return -ENOMEM;
1692 spin_lock_init(&chip->reg_lock); 1692 spin_lock_init(&chip->reg_lock);
@@ -1988,6 +1988,12 @@ static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard,
1988} 1988}
1989#endif /* CONFIG_PNP */ 1989#endif /* CONFIG_PNP */
1990 1990
1991#ifdef CONFIG_PNP
1992#define is_isapnp_selected(dev) isapnp[dev]
1993#else
1994#define is_isapnp_selected(dev) 0
1995#endif
1996
1991static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, 1997static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
1992 const struct pnp_card_device_id *pid) 1998 const struct pnp_card_device_id *pid)
1993{ 1999{
@@ -1996,7 +2002,6 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
1996 int xirq, xdma1, xdma2; 2002 int xirq, xdma1, xdma2;
1997 snd_card_t *card; 2003 snd_card_t *card;
1998 struct snd_audiodrive *acard; 2004 struct snd_audiodrive *acard;
1999 snd_rawmidi_t *rmidi = NULL;
2000 es18xx_t *chip; 2005 es18xx_t *chip;
2001 opl3_t *opl3; 2006 opl3_t *opl3;
2002 int err; 2007 int err;
@@ -2019,25 +2024,25 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
2019 xirq = irq[dev]; 2024 xirq = irq[dev];
2020 if (xirq == SNDRV_AUTO_IRQ) { 2025 if (xirq == SNDRV_AUTO_IRQ) {
2021 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 2026 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
2022 snd_card_free(card); 2027 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
2023 snd_printk("unable to find a free IRQ\n"); 2028 err = -EBUSY;
2024 return -EBUSY; 2029 goto _err;
2025 } 2030 }
2026 } 2031 }
2027 xdma1 = dma1[dev]; 2032 xdma1 = dma1[dev];
2028 if (xdma1 == SNDRV_AUTO_DMA) { 2033 if (xdma1 == SNDRV_AUTO_DMA) {
2029 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 2034 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
2030 snd_card_free(card); 2035 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
2031 snd_printk("unable to find a free DMA1\n"); 2036 err = -EBUSY;
2032 return -EBUSY; 2037 goto _err;
2033 } 2038 }
2034 } 2039 }
2035 xdma2 = dma2[dev]; 2040 xdma2 = dma2[dev];
2036 if (xdma2 == SNDRV_AUTO_DMA) { 2041 if (xdma2 == SNDRV_AUTO_DMA) {
2037 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 2042 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
2038 snd_card_free(card); 2043 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
2039 snd_printk("unable to find a free DMA2\n"); 2044 err = -EBUSY;
2040 return -EBUSY; 2045 goto _err;
2041 } 2046 }
2042 } 2047 }
2043 2048
@@ -2046,10 +2051,8 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
2046 mpu_port[dev], 2051 mpu_port[dev],
2047 fm_port[dev], 2052 fm_port[dev],
2048 xirq, xdma1, xdma2, 2053 xirq, xdma1, xdma2,
2049 &chip)) < 0) { 2054 &chip)) < 0)
2050 snd_card_free(card); 2055 goto _err;
2051 return err;
2052 }
2053 2056
2054 sprintf(card->driver, "ES%x", chip->version); 2057 sprintf(card->driver, "ES%x", chip->version);
2055 sprintf(card->shortname, "ESS AudioDrive ES%x", chip->version); 2058 sprintf(card->shortname, "ESS AudioDrive ES%x", chip->version);
@@ -2064,23 +2067,18 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
2064 chip->port, 2067 chip->port,
2065 xirq, xdma1); 2068 xirq, xdma1);
2066 2069
2067 if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) { 2070 if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0)
2068 snd_card_free(card); 2071 goto _err;
2069 return err; 2072
2070 } 2073 if ((err = snd_es18xx_mixer(chip)) < 0)
2071 if ((err = snd_es18xx_mixer(chip)) < 0) { 2074 goto _err;
2072 snd_card_free(card);
2073 return err;
2074 }
2075 2075
2076 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { 2076 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
2077 if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { 2077 if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) {
2078 snd_printk(KERN_ERR PFX "opl3 not detected at 0x%lx\n", chip->fm_port); 2078 snd_printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->fm_port);
2079 } else { 2079 } else {
2080 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { 2080 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)
2081 snd_card_free(card); 2081 goto _err;
2082 return err;
2083 }
2084 } 2082 }
2085 } 2083 }
2086 2084
@@ -2088,25 +2086,28 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
2088 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, 2086 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX,
2089 chip->mpu_port, 0, 2087 chip->mpu_port, 0,
2090 xirq, 0, 2088 xirq, 0,
2091 &rmidi)) < 0) { 2089 &chip->rmidi)) < 0)
2092 snd_card_free(card); 2090 goto _err;
2093 return err;
2094 }
2095 chip->rmidi = rmidi;
2096 } 2091 }
2097 2092
2093 if ((err = snd_card_set_generic_dev(card)) < 0)
2094 goto _err;
2095
2098 /* Power Management */ 2096 /* Power Management */
2099 snd_card_set_isa_pm_callback(card, snd_es18xx_suspend, snd_es18xx_resume, chip); 2097 snd_card_set_isa_pm_callback(card, snd_es18xx_suspend, snd_es18xx_resume, chip);
2100 2098
2101 if ((err = snd_card_register(card)) < 0) { 2099 if ((err = snd_card_register(card)) < 0)
2102 snd_card_free(card); 2100 goto _err;
2103 return err; 2101
2104 }
2105 if (pcard) 2102 if (pcard)
2106 pnp_set_card_drvdata(pcard, card); 2103 pnp_set_card_drvdata(pcard, card);
2107 else 2104 else
2108 snd_audiodrive_legacy[dev] = card; 2105 snd_audiodrive_legacy[dev] = card;
2109 return 0; 2106 return 0;
2107
2108 _err:
2109 snd_card_free(card);
2110 return err;
2110} 2111}
2111 2112
2112static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport) 2113static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport)
@@ -2117,10 +2118,8 @@ static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport)
2117 for ( ; dev < SNDRV_CARDS; dev++) { 2118 for ( ; dev < SNDRV_CARDS; dev++) {
2118 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 2119 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT)
2119 continue; 2120 continue;
2120#ifdef CONFIG_PNP 2121 if (is_isapnp_selected(dev))
2121 if (isapnp[dev])
2122 continue; 2122 continue;
2123#endif
2124 port[dev] = xport; 2123 port[dev] = xport;
2125 res = snd_audiodrive_probe(dev, NULL, NULL); 2124 res = snd_audiodrive_probe(dev, NULL, NULL);
2126 if (res < 0) 2125 if (res < 0)
@@ -2177,10 +2176,8 @@ static int __init alsa_card_es18xx_init(void)
2177 for (dev = 0; dev < SNDRV_CARDS; dev++) { 2176 for (dev = 0; dev < SNDRV_CARDS; dev++) {
2178 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) 2177 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT)
2179 continue; 2178 continue;
2180#ifdef CONFIG_PNP 2179 if (is_isapnp_selected(dev))
2181 if (isapnp[dev])
2182 continue; 2180 continue;
2183#endif
2184 if (snd_audiodrive_probe(dev, NULL, NULL) >= 0) 2181 if (snd_audiodrive_probe(dev, NULL, NULL) >= 0)
2185 cards++; 2182 cards++;
2186 } 2183 }
diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c
index a636d9ce3502..8f2872f8e8f6 100644
--- a/sound/isa/gus/gus_main.c
+++ b/sound/isa/gus/gus_main.c
@@ -157,7 +157,7 @@ int snd_gus_create(snd_card_t * card,
157 }; 157 };
158 158
159 *rgus = NULL; 159 *rgus = NULL;
160 gus = kcalloc(1, sizeof(*gus), GFP_KERNEL); 160 gus = kzalloc(sizeof(*gus), GFP_KERNEL);
161 if (gus == NULL) 161 if (gus == NULL)
162 return -ENOMEM; 162 return -ENOMEM;
163 gus->gf1.irq = -1; 163 gus->gf1.irq = -1;
diff --git a/sound/isa/gus/gus_mem_proc.c b/sound/isa/gus/gus_mem_proc.c
index 886763f12132..7f96ac237f3c 100644
--- a/sound/isa/gus/gus_mem_proc.c
+++ b/sound/isa/gus/gus_mem_proc.c
@@ -98,7 +98,7 @@ int snd_gf1_mem_proc_init(snd_gus_card_t * gus)
98 98
99 for (idx = 0; idx < 4; idx++) { 99 for (idx = 0; idx < 4; idx++) {
100 if (gus->gf1.mem_alloc.banks_8[idx].size > 0) { 100 if (gus->gf1.mem_alloc.banks_8[idx].size > 0) {
101 priv = kcalloc(1, sizeof(*priv), GFP_KERNEL); 101 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
102 if (priv == NULL) 102 if (priv == NULL)
103 return -ENOMEM; 103 return -ENOMEM;
104 priv->gus = gus; 104 priv->gus = gus;
@@ -115,7 +115,7 @@ int snd_gf1_mem_proc_init(snd_gus_card_t * gus)
115 } 115 }
116 for (idx = 0; idx < 4; idx++) { 116 for (idx = 0; idx < 4; idx++) {
117 if (gus->gf1.rom_present & (1 << idx)) { 117 if (gus->gf1.rom_present & (1 << idx)) {
118 priv = kcalloc(1, sizeof(*priv), GFP_KERNEL); 118 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
119 if (priv == NULL) 119 if (priv == NULL)
120 return -ENOMEM; 120 return -ENOMEM;
121 priv->rom = 1; 121 priv->rom = 1;
diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c
index b75066ab46fc..beb01365dc46 100644
--- a/sound/isa/gus/gus_pcm.c
+++ b/sound/isa/gus/gus_pcm.c
@@ -666,7 +666,7 @@ static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream)
666 snd_pcm_runtime_t *runtime = substream->runtime; 666 snd_pcm_runtime_t *runtime = substream->runtime;
667 int err; 667 int err;
668 668
669 pcmp = kcalloc(1, sizeof(*pcmp), GFP_KERNEL); 669 pcmp = kzalloc(sizeof(*pcmp), GFP_KERNEL);
670 if (pcmp == NULL) 670 if (pcmp == NULL)
671 return -ENOMEM; 671 return -ENOMEM;
672 pcmp->gus = gus; 672 pcmp->gus = gus;
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
index a99fa5040b46..39cef38835ca 100644
--- a/sound/isa/gus/gusclassic.c
+++ b/sound/isa/gus/gusclassic.c
@@ -72,40 +72,24 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver.");
72 72
73static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 73static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
74 74
75#define PFX "gusclassic: "
75 76
76static int __init snd_gusclassic_detect(snd_gus_card_t * gus) 77static int __init snd_gusclassic_detect(snd_gus_card_t * gus)
77{ 78{
78 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 79 unsigned char d;
79#ifdef CONFIG_SND_DEBUG_DETECT
80 {
81 unsigned char d;
82 80
83 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { 81 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
84 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); 82 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
85 return -ENODEV; 83 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
86 }
87 }
88#else
89 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
90 return -ENODEV; 84 return -ENODEV;
91#endif 85 }
92 udelay(160); 86 udelay(160);
93 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 87 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
94 udelay(160); 88 udelay(160);
95#ifdef CONFIG_SND_DEBUG_DETECT 89 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
96 { 90 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
97 unsigned char d;
98
99 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
100 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
101 return -ENODEV;
102 }
103 }
104#else
105 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
106 return -ENODEV; 91 return -ENODEV;
107#endif 92 }
108
109 return 0; 93 return 0;
110} 94}
111 95
@@ -137,25 +121,25 @@ static int __init snd_gusclassic_probe(int dev)
137 xirq = irq[dev]; 121 xirq = irq[dev];
138 if (xirq == SNDRV_AUTO_IRQ) { 122 if (xirq == SNDRV_AUTO_IRQ) {
139 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 123 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
140 snd_card_free(card); 124 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
141 snd_printk("unable to find a free IRQ\n"); 125 err = -EBUSY;
142 return -EBUSY; 126 goto _err;
143 } 127 }
144 } 128 }
145 xdma1 = dma1[dev]; 129 xdma1 = dma1[dev];
146 if (xdma1 == SNDRV_AUTO_DMA) { 130 if (xdma1 == SNDRV_AUTO_DMA) {
147 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 131 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
148 snd_card_free(card); 132 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
149 snd_printk("unable to find a free DMA1\n"); 133 err = -EBUSY;
150 return -EBUSY; 134 goto _err;
151 } 135 }
152 } 136 }
153 xdma2 = dma2[dev]; 137 xdma2 = dma2[dev];
154 if (xdma2 == SNDRV_AUTO_DMA) { 138 if (xdma2 == SNDRV_AUTO_DMA) {
155 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 139 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
156 snd_card_free(card); 140 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
157 snd_printk("unable to find a free DMA2\n"); 141 err = -EBUSY;
158 return -EBUSY; 142 goto _err;
159 } 143 }
160 } 144 }
161 145
@@ -164,47 +148,48 @@ static int __init snd_gusclassic_probe(int dev)
164 port[dev], 148 port[dev],
165 xirq, xdma1, xdma2, 149 xirq, xdma1, xdma2,
166 0, channels[dev], pcm_channels[dev], 150 0, channels[dev], pcm_channels[dev],
167 0, &gus)) < 0) { 151 0, &gus)) < 0)
168 snd_card_free(card); 152 goto _err;
169 return err; 153
170 } 154 if ((err = snd_gusclassic_detect(gus)) < 0)
171 if ((err = snd_gusclassic_detect(gus)) < 0) { 155 goto _err;
172 snd_card_free(card); 156
173 return err;
174 }
175 snd_gusclassic_init(dev, gus); 157 snd_gusclassic_init(dev, gus);
176 if ((err = snd_gus_initialize(gus)) < 0) { 158 if ((err = snd_gus_initialize(gus)) < 0)
177 snd_card_free(card); 159 goto _err;
178 return err; 160
179 }
180 if (gus->max_flag || gus->ess_flag) { 161 if (gus->max_flag || gus->ess_flag) {
181 snd_printdd("GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); 162 snd_printk(KERN_ERR PFX "GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port);
182 snd_card_free(card); 163 err = -ENODEV;
183 return -ENODEV; 164 goto _err;
184 }
185 if ((err = snd_gf1_new_mixer(gus)) < 0) {
186 snd_card_free(card);
187 return err;
188 }
189 if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) {
190 snd_card_free(card);
191 return err;
192 } 165 }
166
167 if ((err = snd_gf1_new_mixer(gus)) < 0)
168 goto _err;
169
170 if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0)
171 goto _err;
172
193 if (!gus->ace_flag) { 173 if (!gus->ace_flag) {
194 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { 174 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
195 snd_card_free(card); 175 goto _err;
196 return err;
197 }
198 } 176 }
199 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1); 177 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1);
200 if (dma2 >= 0) 178 if (dma2 >= 0)
201 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 179 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
202 if ((err = snd_card_register(card)) < 0) { 180
203 snd_card_free(card); 181 if ((err = snd_card_set_generic_dev(card)) < 0)
204 return err; 182 goto _err;
205 } 183
184 if ((err = snd_card_register(card)) < 0)
185 goto _err;
186
206 snd_gusclassic_cards[dev] = card; 187 snd_gusclassic_cards[dev] = card;
207 return 0; 188 return 0;
189
190 _err:
191 snd_card_free(card);
192 return err;
208} 193}
209 194
210static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport) 195static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport)
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c
index bc6fecb18dcf..d2e7cb1df537 100644
--- a/sound/isa/gus/gusextreme.c
+++ b/sound/isa/gus/gusextreme.c
@@ -87,6 +87,7 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver.");
87 87
88static snd_card_t *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 88static snd_card_t *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
89 89
90#define PFX "gusextreme: "
90 91
91static int __init snd_gusextreme_detect(int dev, 92static int __init snd_gusextreme_detect(int dev,
92 snd_card_t * card, 93 snd_card_t * card,
@@ -94,6 +95,7 @@ static int __init snd_gusextreme_detect(int dev,
94 es1688_t *es1688) 95 es1688_t *es1688)
95{ 96{
96 unsigned long flags; 97 unsigned long flags;
98 unsigned char d;
97 99
98 /* 100 /*
99 * This is main stuff - enable access to GF1 chip... 101 * This is main stuff - enable access to GF1 chip...
@@ -123,36 +125,17 @@ static int __init snd_gusextreme_detect(int dev,
123 udelay(100); 125 udelay(100);
124 126
125 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 127 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
126#ifdef CONFIG_SND_DEBUG_DETECT 128 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
127 { 129 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
128 unsigned char d;
129
130 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
131 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
132 return -EIO;
133 }
134 }
135#else
136 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
137 return -EIO; 130 return -EIO;
138#endif 131 }
139 udelay(160); 132 udelay(160);
140 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 133 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
141 udelay(160); 134 udelay(160);
142#ifdef CONFIG_SND_DEBUG_DETECT 135 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
143 { 136 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
144 unsigned char d;
145
146 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
147 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
148 return -EIO;
149 }
150 }
151#else
152 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
153 return -EIO; 137 return -EIO;
154#endif 138 }
155
156 return 0; 139 return 0;
157} 140}
158 141
@@ -205,7 +188,7 @@ static int __init snd_gusextreme_probe(int dev)
205 xgf1_irq = gf1_irq[dev]; 188 xgf1_irq = gf1_irq[dev];
206 if (xgf1_irq == SNDRV_AUTO_IRQ) { 189 if (xgf1_irq == SNDRV_AUTO_IRQ) {
207 if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) { 190 if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) {
208 snd_printk("unable to find a free IRQ for GF1\n"); 191 snd_printk(KERN_ERR PFX "unable to find a free IRQ for GF1\n");
209 err = -EBUSY; 192 err = -EBUSY;
210 goto out; 193 goto out;
211 } 194 }
@@ -213,7 +196,7 @@ static int __init snd_gusextreme_probe(int dev)
213 xess_irq = irq[dev]; 196 xess_irq = irq[dev];
214 if (xess_irq == SNDRV_AUTO_IRQ) { 197 if (xess_irq == SNDRV_AUTO_IRQ) {
215 if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) { 198 if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) {
216 snd_printk("unable to find a free IRQ for ES1688\n"); 199 snd_printk(KERN_ERR PFX "unable to find a free IRQ for ES1688\n");
217 err = -EBUSY; 200 err = -EBUSY;
218 goto out; 201 goto out;
219 } 202 }
@@ -226,7 +209,7 @@ static int __init snd_gusextreme_probe(int dev)
226 xgf1_dma = dma1[dev]; 209 xgf1_dma = dma1[dev];
227 if (xgf1_dma == SNDRV_AUTO_DMA) { 210 if (xgf1_dma == SNDRV_AUTO_DMA) {
228 if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) { 211 if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) {
229 snd_printk("unable to find a free DMA for GF1\n"); 212 snd_printk(KERN_ERR PFX "unable to find a free DMA for GF1\n");
230 err = -EBUSY; 213 err = -EBUSY;
231 goto out; 214 goto out;
232 } 215 }
@@ -234,7 +217,7 @@ static int __init snd_gusextreme_probe(int dev)
234 xess_dma = dma8[dev]; 217 xess_dma = dma8[dev];
235 if (xess_dma == SNDRV_AUTO_DMA) { 218 if (xess_dma == SNDRV_AUTO_DMA) {
236 if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) { 219 if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) {
237 snd_printk("unable to find a free DMA for ES1688\n"); 220 snd_printk(KERN_ERR PFX "unable to find a free DMA for ES1688\n");
238 err = -EBUSY; 221 err = -EBUSY;
239 goto out; 222 goto out;
240 } 223 }
@@ -264,7 +247,7 @@ static int __init snd_gusextreme_probe(int dev)
264 goto out; 247 goto out;
265 248
266 if (!gus->ess_flag) { 249 if (!gus->ess_flag) {
267 snd_printdd("GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); 250 snd_printk(KERN_ERR PFX "GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port);
268 err = -ENODEV; 251 err = -ENODEV;
269 goto out; 252 goto out;
270 } 253 }
@@ -287,7 +270,7 @@ static int __init snd_gusextreme_probe(int dev)
287 270
288 if (snd_opl3_create(card, es1688->port, es1688->port + 2, 271 if (snd_opl3_create(card, es1688->port, es1688->port + 2,
289 OPL3_HW_OPL3, 0, &opl3) < 0) { 272 OPL3_HW_OPL3, 0, &opl3) < 0) {
290 printk(KERN_ERR "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); 273 printk(KERN_ERR PFX "gusextreme: opl3 not detected at 0x%lx\n", es1688->port);
291 } else { 274 } else {
292 if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) 275 if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0)
293 goto out; 276 goto out;
@@ -303,6 +286,10 @@ static int __init snd_gusextreme_probe(int dev)
303 286
304 sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", 287 sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i",
305 es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); 288 es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma);
289
290 if ((err = snd_card_set_generic_dev(card)) < 0)
291 goto out;
292
306 if ((err = snd_card_register(card)) < 0) 293 if ((err = snd_card_register(card)) < 0)
307 goto out; 294 goto out;
308 295
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
index 400ff34710fb..0bb44b519340 100644
--- a/sound/isa/gus/gusmax.c
+++ b/sound/isa/gus/gusmax.c
@@ -82,39 +82,25 @@ struct snd_gusmax {
82 82
83static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 83static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
84 84
85#define PFX "gusmax: "
85 86
86static int __init snd_gusmax_detect(snd_gus_card_t * gus) 87static int __init snd_gusmax_detect(snd_gus_card_t * gus)
87{ 88{
88 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 89 unsigned char d;
89#ifdef CONFIG_SND_DEBUG_DETECT
90 {
91 unsigned char d;
92 90
93 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { 91 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
94 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); 92 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
95 return -ENODEV; 93 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
96 }
97 }
98#else
99 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
100 return -ENODEV; 94 return -ENODEV;
101#endif 95 }
102 udelay(160); 96 udelay(160);
103 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 97 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
104 udelay(160); 98 udelay(160);
105#ifdef CONFIG_SND_DEBUG_DETECT 99 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
106 { 100 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
107 unsigned char d;
108
109 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
110 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
111 return -ENODEV;
112 }
113 }
114#else
115 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
116 return -ENODEV; 101 return -ENODEV;
117#endif 102 }
103
118 return 0; 104 return 0;
119} 105}
120 106
@@ -239,25 +225,25 @@ static int __init snd_gusmax_probe(int dev)
239 xirq = irq[dev]; 225 xirq = irq[dev];
240 if (xirq == SNDRV_AUTO_IRQ) { 226 if (xirq == SNDRV_AUTO_IRQ) {
241 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 227 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
242 snd_card_free(card); 228 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
243 snd_printk("unable to find a free IRQ\n"); 229 err = -EBUSY;
244 return -EBUSY; 230 goto _err;
245 } 231 }
246 } 232 }
247 xdma1 = dma1[dev]; 233 xdma1 = dma1[dev];
248 if (xdma1 == SNDRV_AUTO_DMA) { 234 if (xdma1 == SNDRV_AUTO_DMA) {
249 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 235 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
250 snd_card_free(card); 236 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
251 snd_printk("unable to find a free DMA1\n"); 237 err = -EBUSY;
252 return -EBUSY; 238 goto _err;
253 } 239 }
254 } 240 }
255 xdma2 = dma2[dev]; 241 xdma2 = dma2[dev];
256 if (xdma2 == SNDRV_AUTO_DMA) { 242 if (xdma2 == SNDRV_AUTO_DMA) {
257 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 243 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
258 snd_card_free(card); 244 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
259 snd_printk("unable to find a free DMA2\n"); 245 err = -EBUSY;
260 return -EBUSY; 246 goto _err;
261 } 247 }
262 } 248 }
263 249
@@ -266,31 +252,28 @@ static int __init snd_gusmax_probe(int dev)
266 -xirq, xdma1, xdma2, 252 -xirq, xdma1, xdma2,
267 0, channels[dev], 253 0, channels[dev],
268 pcm_channels[dev], 254 pcm_channels[dev],
269 0, &gus)) < 0) { 255 0, &gus)) < 0)
270 snd_card_free(card); 256 goto _err;
271 return err; 257
272 } 258 if ((err = snd_gusmax_detect(gus)) < 0)
273 if ((err = snd_gusmax_detect(gus)) < 0) { 259 goto _err;
274 snd_card_free(card); 260
275 return err;
276 }
277 maxcard->gus_status_reg = gus->gf1.reg_irqstat; 261 maxcard->gus_status_reg = gus->gf1.reg_irqstat;
278 maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; 262 maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2;
279 snd_gusmax_init(dev, card, gus); 263 snd_gusmax_init(dev, card, gus);
280 if ((err = snd_gus_initialize(gus)) < 0) { 264 if ((err = snd_gus_initialize(gus)) < 0)
281 snd_card_free(card); 265 goto _err;
282 return err; 266
283 }
284 if (!gus->max_flag) { 267 if (!gus->max_flag) {
285 printk(KERN_ERR "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); 268 snd_printk(KERN_ERR PFX "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port);
286 snd_card_free(card); 269 err = -ENODEV;
287 return -ENODEV; 270 goto _err;
288 } 271 }
289 272
290 if (request_irq(xirq, snd_gusmax_interrupt, SA_INTERRUPT, "GUS MAX", (void *)maxcard)) { 273 if (request_irq(xirq, snd_gusmax_interrupt, SA_INTERRUPT, "GUS MAX", (void *)maxcard)) {
291 snd_card_free(card); 274 snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq);
292 printk(KERN_ERR "gusmax: unable to grab IRQ %d\n", xirq); 275 err = -EBUSY;
293 return -EBUSY; 276 goto _err;
294 } 277 }
295 maxcard->irq = xirq; 278 maxcard->irq = xirq;
296 279
@@ -301,50 +284,46 @@ static int __init snd_gusmax_probe(int dev)
301 CS4231_HWSHARE_IRQ | 284 CS4231_HWSHARE_IRQ |
302 CS4231_HWSHARE_DMA1 | 285 CS4231_HWSHARE_DMA1 |
303 CS4231_HWSHARE_DMA2, 286 CS4231_HWSHARE_DMA2,
304 &cs4231)) < 0) { 287 &cs4231)) < 0)
305 snd_card_free(card); 288 goto _err;
306 return err; 289
307 } 290 if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0)
308 if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) { 291 goto _err;
309 snd_card_free(card); 292
310 return err; 293 if ((err = snd_cs4231_mixer(cs4231)) < 0)
311 } 294 goto _err;
312 if ((err = snd_cs4231_mixer(cs4231)) < 0) { 295
313 snd_card_free(card); 296 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0)
314 return err; 297 goto _err;
315 } 298
316 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) {
317 snd_card_free(card);
318 return err;
319 }
320 if (pcm_channels[dev] > 0) { 299 if (pcm_channels[dev] > 0) {
321 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { 300 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0)
322 snd_card_free(card); 301 goto _err;
323 return err;
324 }
325 }
326 if ((err = snd_gusmax_mixer(cs4231)) < 0) {
327 snd_card_free(card);
328 return err;
329 } 302 }
303 if ((err = snd_gusmax_mixer(cs4231)) < 0)
304 goto _err;
330 305
331 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { 306 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
332 snd_card_free(card); 307 goto _err;
333 return err;
334 }
335 308
336 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1); 309 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1);
337 if (xdma2 >= 0) 310 if (xdma2 >= 0)
338 sprintf(card->longname + strlen(card->longname), "&%i", xdma2); 311 sprintf(card->longname + strlen(card->longname), "&%i", xdma2);
339 if ((err = snd_card_register(card)) < 0) { 312
340 snd_card_free(card); 313 if ((err = snd_card_set_generic_dev(card)) < 0)
341 return err; 314 goto _err;
342 } 315
316 if ((err = snd_card_register(card)) < 0)
317 goto _err;
343 318
344 maxcard->gus = gus; 319 maxcard->gus = gus;
345 maxcard->cs4231 = cs4231; 320 maxcard->cs4231 = cs4231;
346 snd_gusmax_cards[dev] = card; 321 snd_gusmax_cards[dev] = card;
347 return 0; 322 return 0;
323
324 _err:
325 snd_card_free(card);
326 return err;
348} 327}
349 328
350static int __init snd_gusmax_legacy_auto_probe(unsigned long xport) 329static int __init snd_gusmax_legacy_auto_probe(unsigned long xport)
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index 46e867daba6a..358cba9d738f 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -73,6 +73,12 @@ static int midi[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
73static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 73static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
74static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; 74static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
75 75
76#ifdef SNDRV_STB
77#define PFX "interwave-stb: "
78#else
79#define PFX "interwave: "
80#endif
81
76module_param_array(index, int, NULL, 0444); 82module_param_array(index, int, NULL, 0444);
77MODULE_PARM_DESC(index, "Index value for InterWave soundcard."); 83MODULE_PARM_DESC(index, "Index value for InterWave soundcard.");
78module_param_array(id, charp, NULL, 0444); 84module_param_array(id, charp, NULL, 0444);
@@ -249,38 +255,20 @@ static int __devinit snd_interwave_detect(struct snd_interwave *iwcard,
249{ 255{
250 unsigned long flags; 256 unsigned long flags;
251 unsigned char rev1, rev2; 257 unsigned char rev1, rev2;
258 int d;
252 259
253 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 260 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
254#ifdef CONFIG_SND_DEBUG_DETECT 261 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
255 { 262 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
256 int d;
257
258 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
259 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
260 return -ENODEV;
261 }
262 }
263#else
264 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
265 return -ENODEV; 263 return -ENODEV;
266#endif 264 }
267 udelay(160); 265 udelay(160);
268 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 266 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
269 udelay(160); 267 udelay(160);
270#ifdef CONFIG_SND_DEBUG_DETECT 268 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
271 { 269 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
272 int d;
273
274 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
275 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
276 return -ENODEV;
277 }
278 }
279#else
280 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
281 return -ENODEV; 270 return -ENODEV;
282#endif 271 }
283
284 spin_lock_irqsave(&gus->reg_lock, flags); 272 spin_lock_irqsave(&gus->reg_lock, flags);
285 rev1 = snd_gf1_look8(gus, SNDRV_GF1_GB_VERSION_NUMBER); 273 rev1 = snd_gf1_look8(gus, SNDRV_GF1_GB_VERSION_NUMBER);
286 snd_gf1_write8(gus, SNDRV_GF1_GB_VERSION_NUMBER, ~rev1); 274 snd_gf1_write8(gus, SNDRV_GF1_GB_VERSION_NUMBER, ~rev1);
@@ -686,35 +674,33 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
686 card->private_free = snd_interwave_free; 674 card->private_free = snd_interwave_free;
687#ifdef CONFIG_PNP 675#ifdef CONFIG_PNP
688 if (isapnp[dev]) { 676 if (isapnp[dev]) {
689 if (snd_interwave_pnp(dev, iwcard, pcard, pid)) { 677 if ((err = snd_interwave_pnp(dev, iwcard, pcard, pid)) < 0)
690 snd_card_free(card); 678 goto _err;
691 return -ENODEV;
692 }
693 snd_card_set_dev(card, &pcard->card->dev); 679 snd_card_set_dev(card, &pcard->card->dev);
694 } 680 }
695#endif 681#endif
696 xirq = irq[dev]; 682 xirq = irq[dev];
697 if (xirq == SNDRV_AUTO_IRQ) { 683 if (xirq == SNDRV_AUTO_IRQ) {
698 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 684 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
699 snd_card_free(card); 685 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
700 snd_printk("unable to find a free IRQ\n"); 686 err = -EBUSY;
701 return -EBUSY; 687 goto _err;
702 } 688 }
703 } 689 }
704 xdma1 = dma1[dev]; 690 xdma1 = dma1[dev];
705 if (xdma1 == SNDRV_AUTO_DMA) { 691 if (xdma1 == SNDRV_AUTO_DMA) {
706 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 692 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
707 snd_card_free(card); 693 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
708 snd_printk("unable to find a free DMA1\n"); 694 err = -EBUSY;
709 return -EBUSY; 695 goto _err;
710 } 696 }
711 } 697 }
712 xdma2 = dma2[dev]; 698 xdma2 = dma2[dev];
713 if (xdma2 == SNDRV_AUTO_DMA) { 699 if (xdma2 == SNDRV_AUTO_DMA) {
714 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 700 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
715 snd_card_free(card); 701 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
716 snd_printk("unable to find a free DMA2\n"); 702 err = -EBUSY;
717 return -EBUSY; 703 goto _err;
718 } 704 }
719 } 705 }
720 706
@@ -722,32 +708,28 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
722 port[dev], 708 port[dev],
723 -xirq, xdma1, xdma2, 709 -xirq, xdma1, xdma2,
724 0, 32, 710 0, 32,
725 pcm_channels[dev], effect[dev], &gus)) < 0) { 711 pcm_channels[dev], effect[dev], &gus)) < 0)
726 snd_card_free(card); 712 goto _err;
727 return err; 713
728 }
729 if ((err = snd_interwave_detect(iwcard, gus, dev 714 if ((err = snd_interwave_detect(iwcard, gus, dev
730#ifdef SNDRV_STB 715#ifdef SNDRV_STB
731 , &i2c_bus 716 , &i2c_bus
732#endif 717#endif
733 )) < 0) { 718 )) < 0)
734 snd_card_free(card); 719 goto _err;
735 return err; 720
736 }
737 iwcard->gus_status_reg = gus->gf1.reg_irqstat; 721 iwcard->gus_status_reg = gus->gf1.reg_irqstat;
738 iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; 722 iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2;
739 723
740 snd_interwave_init(dev, gus); 724 snd_interwave_init(dev, gus);
741 snd_interwave_detect_memory(gus); 725 snd_interwave_detect_memory(gus);
742 if ((err = snd_gus_initialize(gus)) < 0) { 726 if ((err = snd_gus_initialize(gus)) < 0)
743 snd_card_free(card); 727 goto _err;
744 return err;
745 }
746 728
747 if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) { 729 if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) {
748 snd_card_free(card); 730 snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq);
749 snd_printk("unable to grab IRQ %d\n", xirq); 731 err = -EBUSY;
750 return -EBUSY; 732 goto _err;
751 } 733 }
752 iwcard->irq = xirq; 734 iwcard->irq = xirq;
753 735
@@ -758,34 +740,28 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
758 CS4231_HWSHARE_IRQ | 740 CS4231_HWSHARE_IRQ |
759 CS4231_HWSHARE_DMA1 | 741 CS4231_HWSHARE_DMA1 |
760 CS4231_HWSHARE_DMA2, 742 CS4231_HWSHARE_DMA2,
761 &cs4231)) < 0) { 743 &cs4231)) < 0)
762 snd_card_free(card); 744 goto _err;
763 return err; 745
764 } 746 if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0)
765 if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) { 747 goto _err;
766 snd_card_free(card); 748
767 return err;
768 }
769 sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A'); 749 sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A');
770 strcat(pcm->name, " (codec)"); 750 strcat(pcm->name, " (codec)");
771 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) { 751
772 snd_card_free(card); 752 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0)
773 return err; 753 goto _err;
774 } 754
775 if ((err = snd_cs4231_mixer(cs4231)) < 0) { 755 if ((err = snd_cs4231_mixer(cs4231)) < 0)
776 snd_card_free(card); 756 goto _err;
777 return err; 757
778 }
779 if (pcm_channels[dev] > 0) { 758 if (pcm_channels[dev] > 0) {
780 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { 759 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0)
781 snd_card_free(card); 760 goto _err;
782 return err;
783 }
784 }
785 if ((err = snd_interwave_mixer(cs4231)) < 0) {
786 snd_card_free(card);
787 return err;
788 } 761 }
762 if ((err = snd_interwave_mixer(cs4231)) < 0)
763 goto _err;
764
789#ifdef SNDRV_STB 765#ifdef SNDRV_STB
790 { 766 {
791 snd_ctl_elem_id_t id1, id2; 767 snd_ctl_elem_id_t id1, id2;
@@ -795,28 +771,20 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
795 strcpy(id1.name, "Master Playback Switch"); 771 strcpy(id1.name, "Master Playback Switch");
796 strcpy(id2.name, id1.name); 772 strcpy(id2.name, id1.name);
797 id2.index = 1; 773 id2.index = 1;
798 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { 774 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
799 snd_card_free(card); 775 goto _err;
800 return err;
801 }
802 strcpy(id1.name, "Master Playback Volume"); 776 strcpy(id1.name, "Master Playback Volume");
803 strcpy(id2.name, id1.name); 777 strcpy(id2.name, id1.name);
804 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { 778 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
805 snd_card_free(card); 779 goto _err;
806 return err; 780 if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0)
807 } 781 goto _err;
808 if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) {
809 snd_card_free(card);
810 return err;
811 }
812 } 782 }
813#endif 783#endif
814 784
815 gus->uart_enable = midi[dev]; 785 gus->uart_enable = midi[dev];
816 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { 786 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
817 snd_card_free(card); 787 goto _err;
818 return err;
819 }
820 788
821#ifndef SNDRV_STB 789#ifndef SNDRV_STB
822 str = "AMD InterWave"; 790 str = "AMD InterWave";
@@ -835,10 +803,11 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
835 if (xdma2 >= 0) 803 if (xdma2 >= 0)
836 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 804 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
837 805
838 if ((err = snd_card_register(card)) < 0) { 806 if ((err = snd_card_set_generic_dev(card)) < 0)
839 snd_card_free(card); 807 goto _err;
840 return err; 808
841 } 809 if ((err = snd_card_register(card)) < 0)
810 goto _err;
842 811
843 iwcard->cs4231 = cs4231; 812 iwcard->cs4231 = cs4231;
844 iwcard->gus = gus; 813 iwcard->gus = gus;
@@ -847,6 +816,10 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
847 else 816 else
848 snd_interwave_legacy[dev++] = card; 817 snd_interwave_legacy[dev++] = card;
849 return 0; 818 return 0;
819
820 _err:
821 snd_card_free(card);
822 return err;
850} 823}
851 824
852static int __devinit snd_interwave_probe_legacy_port(unsigned long xport) 825static int __devinit snd_interwave_probe_legacy_port(unsigned long xport)
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index 75bd6eca63e7..e2d2babcd20b 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -143,6 +143,8 @@ struct snd_opl3sa2 {
143 143
144static snd_card_t *snd_opl3sa2_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 144static snd_card_t *snd_opl3sa2_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
145 145
146#define PFX "opl3sa2: "
147
146#ifdef CONFIG_PNP 148#ifdef CONFIG_PNP
147 149
148static struct pnp_device_id snd_opl3sa2_pnpbiosids[] = { 150static struct pnp_device_id snd_opl3sa2_pnpbiosids[] = {
@@ -231,7 +233,7 @@ static int __init snd_opl3sa2_detect(opl3sa2_t *chip)
231 card = chip->card; 233 card = chip->card;
232 port = chip->port; 234 port = chip->port;
233 if ((chip->res_port = request_region(port, 2, "OPL3-SA control")) == NULL) { 235 if ((chip->res_port = request_region(port, 2, "OPL3-SA control")) == NULL) {
234 snd_printk(KERN_ERR "opl3sa2: can't grab port 0x%lx\n", port); 236 snd_printk(KERN_ERR PFX "can't grab port 0x%lx\n", port);
235 return -EBUSY; 237 return -EBUSY;
236 } 238 }
237 // snd_printk("REG 0A = 0x%x\n", snd_opl3sa2_read(chip, 0x0a)); 239 // snd_printk("REG 0A = 0x%x\n", snd_opl3sa2_read(chip, 0x0a));
@@ -668,6 +670,12 @@ static int snd_opl3sa2_dev_free(snd_device_t *device)
668 return snd_opl3sa2_free(chip); 670 return snd_opl3sa2_free(chip);
669} 671}
670 672
673#ifdef CONFIG_PNP
674#define is_isapnp_selected(dev) isapnp[dev]
675#else
676#define is_isapnp_selected(dev) 0
677#endif
678
671static int __devinit snd_opl3sa2_probe(int dev, 679static int __devinit snd_opl3sa2_probe(int dev,
672 struct pnp_dev *pdev, 680 struct pnp_dev *pdev,
673 struct pnp_card_link *pcard, 681 struct pnp_card_link *pcard,
@@ -683,34 +691,31 @@ static int __devinit snd_opl3sa2_probe(int dev,
683 }; 691 };
684 int err; 692 int err;
685 693
686#ifdef CONFIG_PNP 694 if (! is_isapnp_selected(dev)) {
687 if (!isapnp[dev]) {
688#endif
689 if (port[dev] == SNDRV_AUTO_PORT) { 695 if (port[dev] == SNDRV_AUTO_PORT) {
690 snd_printk("specify port\n"); 696 snd_printk(KERN_ERR PFX "specify port\n");
691 return -EINVAL; 697 return -EINVAL;
692 } 698 }
693 if (wss_port[dev] == SNDRV_AUTO_PORT) { 699 if (wss_port[dev] == SNDRV_AUTO_PORT) {
694 snd_printk("specify wss_port\n"); 700 snd_printk(KERN_ERR PFX "specify wss_port\n");
695 return -EINVAL; 701 return -EINVAL;
696 } 702 }
697 if (fm_port[dev] == SNDRV_AUTO_PORT) { 703 if (fm_port[dev] == SNDRV_AUTO_PORT) {
698 snd_printk("specify fm_port\n"); 704 snd_printk(KERN_ERR PFX "specify fm_port\n");
699 return -EINVAL; 705 return -EINVAL;
700 } 706 }
701 if (midi_port[dev] == SNDRV_AUTO_PORT) { 707 if (midi_port[dev] == SNDRV_AUTO_PORT) {
702 snd_printk("specify midi_port\n"); 708 snd_printk(KERN_ERR PFX "specify midi_port\n");
703 return -EINVAL; 709 return -EINVAL;
704 } 710 }
705#ifdef CONFIG_PNP
706 } 711 }
707#endif 712
708 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 713 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
709 if (card == NULL) 714 if (card == NULL)
710 return -ENOMEM; 715 return -ENOMEM;
711 strcpy(card->driver, "OPL3SA2"); 716 strcpy(card->driver, "OPL3SA2");
712 strcpy(card->shortname, "Yamaha OPL3-SA2"); 717 strcpy(card->shortname, "Yamaha OPL3-SA2");
713 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 718 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
714 if (chip == NULL) { 719 if (chip == NULL) {
715 err = -ENOMEM; 720 err = -ENOMEM;
716 goto __error; 721 goto __error;
@@ -742,7 +747,7 @@ static int __devinit snd_opl3sa2_probe(int dev,
742 if ((err = snd_opl3sa2_detect(chip)) < 0) 747 if ((err = snd_opl3sa2_detect(chip)) < 0)
743 goto __error; 748 goto __error;
744 if (request_irq(xirq, snd_opl3sa2_interrupt, SA_INTERRUPT, "OPL3-SA2", (void *)chip)) { 749 if (request_irq(xirq, snd_opl3sa2_interrupt, SA_INTERRUPT, "OPL3-SA2", (void *)chip)) {
745 snd_printk(KERN_ERR "opl3sa2: can't grab IRQ %d\n", xirq); 750 snd_printk(KERN_ERR PFX "can't grab IRQ %d\n", xirq);
746 err = -ENODEV; 751 err = -ENODEV;
747 goto __error; 752 goto __error;
748 } 753 }
@@ -795,6 +800,9 @@ static int __devinit snd_opl3sa2_probe(int dev,
795 if (dma2 >= 0) 800 if (dma2 >= 0)
796 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 801 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
797 802
803 if ((err = snd_card_set_generic_dev(card)) < 0)
804 goto __error;
805
798 if ((err = snd_card_register(card)) < 0) 806 if ((err = snd_card_register(card)) < 0)
799 goto __error; 807 goto __error;
800 808
@@ -852,8 +860,10 @@ static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *card,
852 int res; 860 int res;
853 861
854 for ( ; dev < SNDRV_CARDS; dev++) { 862 for ( ; dev < SNDRV_CARDS; dev++) {
855 if (!enable[dev] || !isapnp[dev]) 863 if (!enable[dev])
856 continue; 864 continue;
865 if (is_isapnp_selected(dev))
866 continue;
857 res = snd_opl3sa2_probe(dev, NULL, card, id); 867 res = snd_opl3sa2_probe(dev, NULL, card, id);
858 if (res < 0) 868 if (res < 0)
859 return res; 869 return res;
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index 411a702d85ba..73573cb1db6a 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -1038,8 +1038,7 @@ static int snd_opti93x_capture_prepare(snd_pcm_substream_t *substream)
1038 1038
1039 chip->c_dma_size = size; 1039 chip->c_dma_size = size;
1040 snd_opti93x_out_mask(chip, OPTi93X_IFACE_CONF, 1040 snd_opti93x_out_mask(chip, OPTi93X_IFACE_CONF,
1041 OPTi93X_CAPTURE_ENABLE | OPTi93X_CAPTURE_PIO, 1041 OPTi93X_CAPTURE_ENABLE | OPTi93X_CAPTURE_PIO, 0);
1042 (unsigned char)~(OPTi93X_CAPTURE_ENABLE | OPTi93X_CAPTURE_PIO));
1043 1042
1044 snd_dma_program(chip->dma2, runtime->dma_addr, size, 1043 snd_dma_program(chip->dma2, runtime->dma_addr, size,
1045 DMA_MODE_READ | DMA_AUTOINIT); 1044 DMA_MODE_READ | DMA_AUTOINIT);
@@ -1274,7 +1273,7 @@ static int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip,
1274 opti93x_t *codec; 1273 opti93x_t *codec;
1275 1274
1276 *rcodec = NULL; 1275 *rcodec = NULL;
1277 codec = kcalloc(1, sizeof(*codec), GFP_KERNEL); 1276 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
1278 if (codec == NULL) 1277 if (codec == NULL)
1279 return -ENOMEM; 1278 return -ENOMEM;
1280 codec->irq = -1; 1279 codec->irq = -1;
@@ -1895,8 +1894,8 @@ static void snd_card_opti9xx_free(snd_card_t *card)
1895 } 1894 }
1896} 1895}
1897 1896
1898static int __devinit snd_card_opti9xx_probe(struct pnp_card_link *pcard, 1897static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
1899 const struct pnp_card_device_id *pid) 1898 const struct pnp_card_device_id *pid)
1900{ 1899{
1901 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; 1900 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
1902 static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1}; 1901 static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1};
@@ -1966,6 +1965,10 @@ static int __devinit snd_card_opti9xx_probe(struct pnp_card_link *pcard,
1966 snd_card_free(card); 1965 snd_card_free(card);
1967 return error; 1966 return error;
1968 } 1967 }
1968 if ((error = snd_card_set_generic_dev(card)) < 0) {
1969 snd_card_free(card);
1970 return error;
1971 }
1969#ifdef CONFIG_PNP 1972#ifdef CONFIG_PNP
1970 } 1973 }
1971#endif /* CONFIG_PNP */ 1974#endif /* CONFIG_PNP */
diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c
index 028af4066595..5375705c054b 100644
--- a/sound/isa/sb/emu8000.c
+++ b/sound/isa/sb/emu8000.c
@@ -1097,7 +1097,7 @@ snd_emu8000_new(snd_card_t *card, int index, long port, int seq_ports, snd_seq_d
1097 if (seq_ports <= 0) 1097 if (seq_ports <= 0)
1098 return 0; 1098 return 0;
1099 1099
1100 hw = kcalloc(1, sizeof(*hw), GFP_KERNEL); 1100 hw = kzalloc(sizeof(*hw), GFP_KERNEL);
1101 if (hw == NULL) 1101 if (hw == NULL)
1102 return -ENOMEM; 1102 return -ENOMEM;
1103 spin_lock_init(&hw->reg_lock); 1103 spin_lock_init(&hw->reg_lock);
diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c
index db5eb8b55058..0209790dc4b5 100644
--- a/sound/isa/sb/emu8000_pcm.c
+++ b/sound/isa/sb/emu8000_pcm.c
@@ -233,7 +233,7 @@ static int emu8k_pcm_open(snd_pcm_substream_t *subs)
233 emu8k_pcm_t *rec; 233 emu8k_pcm_t *rec;
234 snd_pcm_runtime_t *runtime = subs->runtime; 234 snd_pcm_runtime_t *runtime = subs->runtime;
235 235
236 rec = kcalloc(1, sizeof(*rec), GFP_KERNEL); 236 rec = kzalloc(sizeof(*rec), GFP_KERNEL);
237 if (! rec) 237 if (! rec)
238 return -ENOMEM; 238 return -ENOMEM;
239 239
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index 60e2c53c49fc..7888783d68f5 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -351,6 +351,12 @@ static void snd_sb16_free(snd_card_t *card)
351 } 351 }
352} 352}
353 353
354#ifdef CONFIG_PNP
355#define is_isapnp_selected(dev) isapnp[dev]
356#else
357#define is_isapnp_selected(dev) 0
358#endif
359
354static int __init snd_sb16_probe(int dev, 360static int __init snd_sb16_probe(int dev,
355 struct pnp_card_link *pcard, 361 struct pnp_card_link *pcard,
356 const struct pnp_card_device_id *pid) 362 const struct pnp_card_device_id *pid)
@@ -378,10 +384,8 @@ static int __init snd_sb16_probe(int dev,
378 card->private_free = snd_sb16_free; 384 card->private_free = snd_sb16_free;
379#ifdef CONFIG_PNP 385#ifdef CONFIG_PNP
380 if (isapnp[dev]) { 386 if (isapnp[dev]) {
381 if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid))) { 387 if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid)))
382 snd_card_free(card); 388 goto _err;
383 return err;
384 }
385 snd_card_set_dev(card, &pcard->card->dev); 389 snd_card_set_dev(card, &pcard->card->dev);
386 } 390 }
387#endif 391#endif
@@ -389,41 +393,37 @@ static int __init snd_sb16_probe(int dev,
389 xirq = irq[dev]; 393 xirq = irq[dev];
390 xdma8 = dma8[dev]; 394 xdma8 = dma8[dev];
391 xdma16 = dma16[dev]; 395 xdma16 = dma16[dev];
392#ifdef CONFIG_PNP 396 if (! is_isapnp_selected(dev)) {
393 if (!isapnp[dev]) { 397 if (xirq == SNDRV_AUTO_IRQ) {
394#endif 398 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
395 if (xirq == SNDRV_AUTO_IRQ) { 399 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
396 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 400 err = -EBUSY;
397 snd_card_free(card); 401 goto _err;
398 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); 402 }
399 return -EBUSY;
400 } 403 }
401 } 404 if (xdma8 == SNDRV_AUTO_DMA) {
402 if (xdma8 == SNDRV_AUTO_DMA) { 405 if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) {
403 if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) { 406 snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n");
404 snd_card_free(card); 407 err = -EBUSY;
405 snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); 408 goto _err;
406 return -EBUSY; 409 }
407 } 410 }
408 } 411 if (xdma16 == SNDRV_AUTO_DMA) {
409 if (xdma16 == SNDRV_AUTO_DMA) { 412 if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) {
410 if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) { 413 snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n");
411 snd_card_free(card); 414 err = -EBUSY;
412 snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); 415 goto _err;
413 return -EBUSY; 416 }
414 } 417 }
415 } 418 /* non-PnP FM port address is hardwired with base port address */
416 /* non-PnP FM port address is hardwired with base port address */ 419 fm_port[dev] = port[dev];
417 fm_port[dev] = port[dev]; 420 /* block the 0x388 port to avoid PnP conflicts */
418 /* block the 0x388 port to avoid PnP conflicts */ 421 acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
419 acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
420#ifdef SNDRV_SBAWE_EMU8000 422#ifdef SNDRV_SBAWE_EMU8000
421 /* non-PnP AWE port address is hardwired with base port address */ 423 /* non-PnP AWE port address is hardwired with base port address */
422 awe_port[dev] = port[dev] + 0x400; 424 awe_port[dev] = port[dev] + 0x400;
423#endif 425#endif
424#ifdef CONFIG_PNP
425 } 426 }
426#endif
427 427
428 if ((err = snd_sbdsp_create(card, 428 if ((err = snd_sbdsp_create(card,
429 port[dev], 429 port[dev],
@@ -432,28 +432,20 @@ static int __init snd_sb16_probe(int dev,
432 xdma8, 432 xdma8,
433 xdma16, 433 xdma16,
434 SB_HW_AUTO, 434 SB_HW_AUTO,
435 &chip)) < 0) { 435 &chip)) < 0)
436 snd_card_free(card); 436 goto _err;
437 return err; 437
438 }
439 if (chip->hardware != SB_HW_16) { 438 if (chip->hardware != SB_HW_16) {
440 snd_card_free(card); 439 snd_printk(KERN_ERR PFX "SB 16 chip was not detected at 0x%lx\n", port[dev]);
441 snd_printdd("SB 16 chip was not detected at 0x%lx\n", port[dev]); 440 err = -ENODEV;
442 return -ENODEV; 441 goto _err;
443 } 442 }
444 chip->mpu_port = mpu_port[dev]; 443 chip->mpu_port = mpu_port[dev];
445#ifdef CONFIG_PNP 444 if (! is_isapnp_selected(dev) && (err = snd_sb16dsp_configure(chip)) < 0)
446 if (!isapnp[dev] && (err = snd_sb16dsp_configure(chip)) < 0) { 445 goto _err;
447#else 446
448 if ((err = snd_sb16dsp_configure(chip)) < 0) { 447 if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0)
449#endif 448 goto _err;
450 snd_card_free(card);
451 return -ENXIO;
452 }
453 if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) {
454 snd_card_free(card);
455 return -ENXIO;
456 }
457 449
458 strcpy(card->driver, 450 strcpy(card->driver,
459#ifdef SNDRV_SBAWE_EMU8000 451#ifdef SNDRV_SBAWE_EMU8000
@@ -474,10 +466,8 @@ static int __init snd_sb16_probe(int dev,
474 if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) { 466 if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) {
475 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB, 467 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB,
476 chip->mpu_port, 0, 468 chip->mpu_port, 0,
477 xirq, 0, &chip->rmidi)) < 0) { 469 xirq, 0, &chip->rmidi)) < 0)
478 snd_card_free(card); 470 goto _err;
479 return -ENXIO;
480 }
481 chip->rmidi_callback = snd_mpu401_uart_interrupt; 471 chip->rmidi_callback = snd_mpu401_uart_interrupt;
482 } 472 }
483 473
@@ -499,17 +489,13 @@ static int __init snd_sb16_probe(int dev,
499#else 489#else
500 int seqdev = 1; 490 int seqdev = 1;
501#endif 491#endif
502 if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) { 492 if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0)
503 snd_card_free(card); 493 goto _err;
504 return -ENXIO;
505 }
506 } 494 }
507 } 495 }
508 496
509 if ((err = snd_sbmixer_new(chip)) < 0) { 497 if ((err = snd_sbmixer_new(chip)) < 0)
510 snd_card_free(card); 498 goto _err;
511 return -ENXIO;
512 }
513 499
514#ifdef CONFIG_SND_SB16_CSP 500#ifdef CONFIG_SND_SB16_CSP
515 /* CSP chip on SB16ASP/AWE32 */ 501 /* CSP chip on SB16ASP/AWE32 */
@@ -525,11 +511,11 @@ static int __init snd_sb16_probe(int dev,
525#endif 511#endif
526#ifdef SNDRV_SBAWE_EMU8000 512#ifdef SNDRV_SBAWE_EMU8000
527 if (awe_port[dev] > 0) { 513 if (awe_port[dev] > 0) {
528 if (snd_emu8000_new(card, 1, awe_port[dev], 514 if ((err = snd_emu8000_new(card, 1, awe_port[dev],
529 seq_ports[dev], NULL) < 0) { 515 seq_ports[dev], NULL)) < 0) {
530 snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]); 516 snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]);
531 snd_card_free(card); 517
532 return -ENXIO; 518 goto _err;
533 } 519 }
534 } 520 }
535#endif 521#endif
@@ -541,15 +527,21 @@ static int __init snd_sb16_probe(int dev,
541 (mic_agc[dev] ? 0x00 : 0x01)); 527 (mic_agc[dev] ? 0x00 : 0x01));
542 spin_unlock_irqrestore(&chip->mixer_lock, flags); 528 spin_unlock_irqrestore(&chip->mixer_lock, flags);
543 529
544 if ((err = snd_card_register(card)) < 0) { 530 if ((err = snd_card_set_generic_dev(card)) < 0)
545 snd_card_free(card); 531 goto _err;
546 return err; 532
547 } 533 if ((err = snd_card_register(card)) < 0)
534 goto _err;
535
548 if (pcard) 536 if (pcard)
549 pnp_set_card_drvdata(pcard, card); 537 pnp_set_card_drvdata(pcard, card);
550 else 538 else
551 snd_sb16_legacy[dev] = card; 539 snd_sb16_legacy[dev] = card;
552 return 0; 540 return 0;
541
542 _err:
543 snd_card_free(card);
544 return err;
553} 545}
554 546
555static int __init snd_sb16_probe_legacy_port(unsigned long xport) 547static int __init snd_sb16_probe_legacy_port(unsigned long xport)
@@ -560,10 +552,8 @@ static int __init snd_sb16_probe_legacy_port(unsigned long xport)
560 for ( ; dev < SNDRV_CARDS; dev++) { 552 for ( ; dev < SNDRV_CARDS; dev++) {
561 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 553 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT)
562 continue; 554 continue;
563#ifdef CONFIG_PNP 555 if (is_isapnp_selected(dev))
564 if (isapnp[dev])
565 continue; 556 continue;
566#endif
567 port[dev] = xport; 557 port[dev] = xport;
568 res = snd_sb16_probe(dev, NULL, NULL); 558 res = snd_sb16_probe(dev, NULL, NULL);
569 if (res < 0) 559 if (res < 0)
@@ -621,10 +611,8 @@ static int __init alsa_card_sb16_init(void)
621 for (dev = 0; dev < SNDRV_CARDS; dev++) { 611 for (dev = 0; dev < SNDRV_CARDS; dev++) {
622 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) 612 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT)
623 continue; 613 continue;
624#ifdef CONFIG_PNP 614 if (is_isapnp_selected(dev))
625 if (isapnp[dev])
626 continue; 615 continue;
627#endif
628 if (!snd_sb16_probe(dev, NULL, NULL)) { 616 if (!snd_sb16_probe(dev, NULL, NULL)) {
629 cards++; 617 cards++;
630 continue; 618 continue;
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
index d64790bcd831..7192d4c758e6 100644
--- a/sound/isa/sb/sb16_csp.c
+++ b/sound/isa/sb/sb16_csp.c
@@ -122,7 +122,7 @@ int snd_sb_csp_new(sb_t *chip, int device, snd_hwdep_t ** rhwdep)
122 if ((err = snd_hwdep_new(chip->card, "SB16-CSP", device, &hw)) < 0) 122 if ((err = snd_hwdep_new(chip->card, "SB16-CSP", device, &hw)) < 0)
123 return err; 123 return err;
124 124
125 if ((p = kcalloc(1, sizeof(*p), GFP_KERNEL)) == NULL) { 125 if ((p = kzalloc(sizeof(*p), GFP_KERNEL)) == NULL) {
126 snd_device_free(chip->card, hw); 126 snd_device_free(chip->card, hw);
127 return -ENOMEM; 127 return -ENOMEM;
128 } 128 }
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
index e2cbc4202b3d..c41ac25e85ca 100644
--- a/sound/isa/sb/sb8.c
+++ b/sound/isa/sb/sb8.c
@@ -107,54 +107,47 @@ static int __init snd_sb8_probe(int dev)
107 dma8[dev], 107 dma8[dev],
108 -1, 108 -1,
109 SB_HW_AUTO, 109 SB_HW_AUTO,
110 &chip)) < 0) { 110 &chip)) < 0)
111 snd_card_free(card); 111 goto _err;
112 return err; 112
113 }
114 if (chip->hardware >= SB_HW_16) { 113 if (chip->hardware >= SB_HW_16) {
115 snd_card_free(card);
116 if (chip->hardware == SB_HW_ALS100) 114 if (chip->hardware == SB_HW_ALS100)
117 snd_printdd("ALS100 chip detected at 0x%lx, try snd-als100 module\n", 115 snd_printk(KERN_WARNING "ALS100 chip detected at 0x%lx, try snd-als100 module\n",
118 port[dev]); 116 port[dev]);
119 else 117 else
120 snd_printdd("SB 16 chip detected at 0x%lx, try snd-sb16 module\n", 118 snd_printk(KERN_WARNING "SB 16 chip detected at 0x%lx, try snd-sb16 module\n",
121 port[dev]); 119 port[dev]);
122 return -ENODEV; 120 err = -ENODEV;
121 goto _err;
123 } 122 }
124 123
125 if ((err = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) { 124 if ((err = snd_sb8dsp_pcm(chip, 0, NULL)) < 0)
126 snd_card_free(card); 125 goto _err;
127 return err; 126
128 } 127 if ((err = snd_sbmixer_new(chip)) < 0)
129 if ((err = snd_sbmixer_new(chip)) < 0) { 128 goto _err;
130 snd_card_free(card); 129
131 return err;
132 }
133 if (chip->hardware == SB_HW_10 || chip->hardware == SB_HW_20) { 130 if (chip->hardware == SB_HW_10 || chip->hardware == SB_HW_20) {
134 if ((err = snd_opl3_create(card, chip->port + 8, 0, 131 if ((err = snd_opl3_create(card, chip->port + 8, 0,
135 OPL3_HW_AUTO, 1, 132 OPL3_HW_AUTO, 1,
136 &opl3)) < 0) { 133 &opl3)) < 0) {
137 snd_printk(KERN_ERR "sb8: no OPL device at 0x%lx\n", chip->port + 8); 134 snd_printk(KERN_WARNING "sb8: no OPL device at 0x%lx\n", chip->port + 8);
138 } 135 }
139 } else { 136 } else {
140 if ((err = snd_opl3_create(card, chip->port, chip->port + 2, 137 if ((err = snd_opl3_create(card, chip->port, chip->port + 2,
141 OPL3_HW_AUTO, 1, 138 OPL3_HW_AUTO, 1,
142 &opl3)) < 0) { 139 &opl3)) < 0) {
143 snd_printk(KERN_ERR "sb8: no OPL device at 0x%lx-0x%lx\n", 140 snd_printk(KERN_WARNING "sb8: no OPL device at 0x%lx-0x%lx\n",
144 chip->port, chip->port + 2); 141 chip->port, chip->port + 2);
145 } 142 }
146 } 143 }
147 if (err >= 0) { 144 if (err >= 0) {
148 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { 145 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)
149 snd_card_free(card); 146 goto _err;
150 return err;
151 }
152 } 147 }
153 148
154 if ((err = snd_sb8dsp_midi(chip, 0, NULL)) < 0) { 149 if ((err = snd_sb8dsp_midi(chip, 0, NULL)) < 0)
155 snd_card_free(card); 150 goto _err;
156 return err;
157 }
158 151
159 strcpy(card->driver, chip->hardware == SB_HW_PRO ? "SB Pro" : "SB8"); 152 strcpy(card->driver, chip->hardware == SB_HW_PRO ? "SB Pro" : "SB8");
160 strcpy(card->shortname, chip->name); 153 strcpy(card->shortname, chip->name);
@@ -162,12 +155,19 @@ static int __init snd_sb8_probe(int dev)
162 chip->name, 155 chip->name,
163 chip->port, 156 chip->port,
164 irq[dev], dma8[dev]); 157 irq[dev], dma8[dev]);
165 if ((err = snd_card_register(card)) < 0) { 158
166 snd_card_free(card); 159 if ((err = snd_card_set_generic_dev(card)) < 0)
167 return err; 160 goto _err;
168 } 161
162 if ((err = snd_card_register(card)) < 0)
163 goto _err;
164
169 snd_sb8_cards[dev] = card; 165 snd_sb8_cards[dev] = card;
170 return 0; 166 return 0;
167
168 _err:
169 snd_card_free(card);
170 return err;
171} 171}
172 172
173static int __init snd_card_sb8_legacy_auto_probe(unsigned long xport) 173static int __init snd_card_sb8_legacy_auto_probe(unsigned long xport)
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
index 5b6bde213ea0..f0f205ae425f 100644
--- a/sound/isa/sb/sb_common.c
+++ b/sound/isa/sb/sb_common.c
@@ -221,7 +221,7 @@ int snd_sbdsp_create(snd_card_t *card,
221 221
222 snd_assert(r_chip != NULL, return -EINVAL); 222 snd_assert(r_chip != NULL, return -EINVAL);
223 *r_chip = NULL; 223 *r_chip = NULL;
224 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 224 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
225 if (chip == NULL) 225 if (chip == NULL)
226 return -ENOMEM; 226 return -ENOMEM;
227 spin_lock_init(&chip->reg_lock); 227 spin_lock_init(&chip->reg_lock);
diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c
index 17f585b0ddc1..52f2294da62b 100644
--- a/sound/isa/sgalaxy.c
+++ b/sound/isa/sgalaxy.c
@@ -67,6 +67,8 @@ MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver.");
67 67
68static snd_card_t *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 68static snd_card_t *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
69 69
70#define PFX "sgalaxy: "
71
70/* 72/*
71 73
72 */ 74 */
@@ -135,7 +137,7 @@ static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma)
135 } 137 }
136 138
137#if 0 139#if 0
138 snd_printdd("sgalaxy - setting up IRQ/DMA for WSS\n"); 140 snd_printdd(PFX "setting up IRQ/DMA for WSS\n");
139#endif 141#endif
140 142
141 /* initialize IRQ for WSS codec */ 143 /* initialize IRQ for WSS codec */
@@ -160,7 +162,7 @@ static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma)
160static int __init snd_sgalaxy_detect(int dev, int irq, int dma) 162static int __init snd_sgalaxy_detect(int dev, int irq, int dma)
161{ 163{
162#if 0 164#if 0
163 snd_printdd("sgalaxy - switching to WSS mode\n"); 165 snd_printdd(PFX "switching to WSS mode\n");
164#endif 166#endif
165 167
166 /* switch to WSS mode */ 168 /* switch to WSS mode */
@@ -223,11 +225,11 @@ static int __init snd_sgalaxy_probe(int dev)
223 ad1848_t *chip; 225 ad1848_t *chip;
224 226
225 if (sbport[dev] == SNDRV_AUTO_PORT) { 227 if (sbport[dev] == SNDRV_AUTO_PORT) {
226 snd_printk("specify SB port\n"); 228 snd_printk(KERN_ERR PFX "specify SB port\n");
227 return -EINVAL; 229 return -EINVAL;
228 } 230 }
229 if (wssport[dev] == SNDRV_AUTO_PORT) { 231 if (wssport[dev] == SNDRV_AUTO_PORT) {
230 snd_printk("specify WSS port\n"); 232 snd_printk(KERN_ERR PFX "specify WSS port\n");
231 return -EINVAL; 233 return -EINVAL;
232 } 234 }
233 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 235 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
@@ -237,46 +239,39 @@ static int __init snd_sgalaxy_probe(int dev)
237 xirq = irq[dev]; 239 xirq = irq[dev];
238 if (xirq == SNDRV_AUTO_IRQ) { 240 if (xirq == SNDRV_AUTO_IRQ) {
239 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 241 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
240 snd_card_free(card); 242 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
241 snd_printk("unable to find a free IRQ\n"); 243 err = -EBUSY;
242 return -EBUSY; 244 goto _err;
243 } 245 }
244 } 246 }
245 xdma1 = dma1[dev]; 247 xdma1 = dma1[dev];
246 if (xdma1 == SNDRV_AUTO_DMA) { 248 if (xdma1 == SNDRV_AUTO_DMA) {
247 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 249 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
248 snd_card_free(card); 250 snd_printk(KERN_ERR PFX "unable to find a free DMA\n");
249 snd_printk("unable to find a free DMA\n"); 251 err = -EBUSY;
250 return -EBUSY; 252 goto _err;
251 } 253 }
252 } 254 }
253 255
254 if ((err = snd_sgalaxy_detect(dev, xirq, xdma1)) < 0) { 256 if ((err = snd_sgalaxy_detect(dev, xirq, xdma1)) < 0)
255 snd_card_free(card); 257 goto _err;
256 return err;
257 }
258 258
259 if ((err = snd_ad1848_create(card, wssport[dev] + 4, 259 if ((err = snd_ad1848_create(card, wssport[dev] + 4,
260 xirq, xdma1, 260 xirq, xdma1,
261 AD1848_HW_DETECT, &chip)) < 0) { 261 AD1848_HW_DETECT, &chip)) < 0)
262 snd_card_free(card); 262 goto _err;
263 return err;
264 }
265 263
266 if ((err = snd_ad1848_pcm(chip, 0, NULL)) < 0) { 264 if ((err = snd_ad1848_pcm(chip, 0, NULL)) < 0) {
267 snd_printdd("sgalaxy - error creating new ad1848 PCM device\n"); 265 snd_printdd(PFX "error creating new ad1848 PCM device\n");
268 snd_card_free(card); 266 goto _err;
269 return err;
270 } 267 }
271 if ((err = snd_ad1848_mixer(chip)) < 0) { 268 if ((err = snd_ad1848_mixer(chip)) < 0) {
272 snd_printdd("sgalaxy - error creating new ad1848 mixer\n"); 269 snd_printdd(PFX "error creating new ad1848 mixer\n");
273 snd_card_free(card); 270 goto _err;
274 return err;
275 } 271 }
276 if (snd_sgalaxy_mixer(chip) < 0) { 272 if ((err = snd_sgalaxy_mixer(chip)) < 0) {
277 snd_printdd("sgalaxy - the mixer rewrite failed\n"); 273 snd_printdd(PFX "the mixer rewrite failed\n");
278 snd_card_free(card); 274 goto _err;
279 return err;
280 } 275 }
281 276
282 strcpy(card->driver, "Sound Galaxy"); 277 strcpy(card->driver, "Sound Galaxy");
@@ -284,12 +279,18 @@ static int __init snd_sgalaxy_probe(int dev)
284 sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", 279 sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d",
285 wssport[dev], xirq, xdma1); 280 wssport[dev], xirq, xdma1);
286 281
287 if ((err = snd_card_register(card)) < 0) { 282 if ((err = snd_card_set_generic_dev(card)) < 0)
288 snd_card_free(card); 283 goto _err;
289 return err; 284
290 } 285 if ((err = snd_card_register(card)) < 0)
286 goto _err;
287
291 snd_sgalaxy_cards[dev] = card; 288 snd_sgalaxy_cards[dev] = card;
292 return 0; 289 return 0;
290
291 _err:
292 snd_card_free(card);
293 return err;
293} 294}
294 295
295static int __init alsa_card_sgalaxy_init(void) 296static int __init alsa_card_sgalaxy_init(void)
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 3959ed694eec..9f6b58c79209 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -1262,11 +1262,6 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
1262 */ 1262 */
1263 sscape_write(sscape, GA_INTENA_REG, 0x80); 1263 sscape_write(sscape, GA_INTENA_REG, 0x80);
1264 1264
1265 if ((err = snd_card_register(card)) < 0) {
1266 printk(KERN_ERR "sscape: Failed to register sound card\n");
1267 goto _release_card;
1268 }
1269
1270 /* 1265 /*
1271 * Initialize mixer 1266 * Initialize mixer
1272 */ 1267 */
@@ -1396,6 +1391,13 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard,
1396 if (ret < 0) 1391 if (ret < 0)
1397 return ret; 1392 return ret;
1398 snd_card_set_dev(card, &pcard->card->dev); 1393 snd_card_set_dev(card, &pcard->card->dev);
1394
1395 if ((ret = snd_card_register(card)) < 0) {
1396 printk(KERN_ERR "sscape: Failed to register sound card\n");
1397 snd_card_free(card);
1398 return ret;
1399 }
1400
1399 pnp_set_card_drvdata(pcard, card); 1401 pnp_set_card_drvdata(pcard, card);
1400 ++sscape_cards; 1402 ++sscape_cards;
1401 ++idx; 1403 ++idx;
@@ -1460,6 +1462,16 @@ static int __init sscape_manual_probe(struct params *params)
1460 if (ret < 0) 1462 if (ret < 0)
1461 return ret; 1463 return ret;
1462 1464
1465 if ((ret = snd_card_set_generic_dev(card)) < 0) {
1466 snd_card_free(card);
1467 return ret;
1468 }
1469 if ((ret = snd_card_register(card)) < 0) {
1470 printk(KERN_ERR "sscape: Failed to register sound card\n");
1471 snd_card_free(card);
1472 return ret;
1473 }
1474
1463 sscape_card[sscape_cards] = card; 1475 sscape_card[sscape_cards] = card;
1464 params++; 1476 params++;
1465 sscape_cards++; 1477 sscape_cards++;
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index 79b022070ba3..0a572e0a47e6 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -622,6 +622,11 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
622 ics2115_port[dev], 622 ics2115_port[dev],
623 ics2115_irq[dev]); 623 ics2115_irq[dev]);
624 624
625 if ((err = snd_card_set_generic_dev(card)) < 0) {
626 snd_card_free(card);
627 return err;
628 }
629
625 if ((err = snd_card_register(card)) < 0) { 630 if ((err = snd_card_register(card)) < 0) {
626 snd_card_free(card); 631 snd_card_free(card);
627 return err; 632 return err;
diff --git a/sound/mips/Kconfig b/sound/mips/Kconfig
index 531f8ba96a71..2433b7727404 100644
--- a/sound/mips/Kconfig
+++ b/sound/mips/Kconfig
@@ -8,6 +8,7 @@ config SND_AU1X00
8 depends on (SOC_AU1000 || SOC_AU1100 || SOC_AU1500) && SND 8 depends on (SOC_AU1000 || SOC_AU1100 || SOC_AU1500) && SND
9 select SND_PCM 9 select SND_PCM
10 select SND_AC97_CODEC 10 select SND_AC97_CODEC
11 select SND_GENERIC_DRIVER
11 help 12 help
12 ALSA Sound driver for the Au1x00's AC97 port. 13 ALSA Sound driver for the Au1x00's AC97 port.
13 14
diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
index c20522b02134..3f9684f1d1d2 100644
--- a/sound/mips/au1x00.c
+++ b/sound/mips/au1x00.c
@@ -667,6 +667,11 @@ au1000_init(void)
667 strcpy(au1000->card->shortname, "Au1000-AC97"); 667 strcpy(au1000->card->shortname, "Au1000-AC97");
668 sprintf(au1000->card->longname, "AMD Au1000--AC97 ALSA Driver"); 668 sprintf(au1000->card->longname, "AMD Au1000--AC97 ALSA Driver");
669 669
670 if ((err = snd_card_set_generic_dev(au1000->card)) < 0) {
671 snd_card_free(au1000->card);
672 return err;
673 }
674
670 if ((err = snd_card_register(au1000->card)) < 0) { 675 if ((err = snd_card_register(au1000->card)) < 0) {
671 snd_card_free(au1000->card); 676 snd_card_free(au1000->card);
672 return err; 677 return err;
diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c
index d7a8f9f5896f..f560dd8cdb90 100644
--- a/sound/parisc/harmony.c
+++ b/sound/parisc/harmony.c
@@ -880,6 +880,8 @@ snd_harmony_create(snd_card_t *card,
880 goto free_and_ret; 880 goto free_and_ret;
881 } 881 }
882 882
883 snd_card_set_dev(card, &padev->dev);
884
883 *rchip = h; 885 *rchip = h;
884 886
885 return 0; 887 return 0;
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 1e458919cce6..a5d593c66f9f 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -316,6 +316,18 @@ config SND_YMFPCI
316 To compile this driver as a module, choose M here: the module 316 To compile this driver as a module, choose M here: the module
317 will be called snd-ymfpci. 317 will be called snd-ymfpci.
318 318
319config SND_AD1889
320 tristate "Analog Devices AD1889"
321 depends on SND
322 select SND_AC97_CODEC
323 help
324 Say Y here to include support for the integrated AC97 sound
325 device found in particular on the Hewlett-Packard [BCJ]-xxx0
326 class PA-RISC workstations, using the AD1819 codec.
327
328 To compile this as a module, choose M here: the module
329 will be called snd-ad1889.
330
319config SND_ALS4000 331config SND_ALS4000
320 tristate "Avance Logic ALS4000" 332 tristate "Avance Logic ALS4000"
321 depends on SND && ISA_DMA_API 333 depends on SND && ISA_DMA_API
diff --git a/sound/pci/Makefile b/sound/pci/Makefile
index b40575c3349a..42fabfcfc2a9 100644
--- a/sound/pci/Makefile
+++ b/sound/pci/Makefile
@@ -3,6 +3,7 @@
3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
4# 4#
5 5
6snd-ad1889-objs := ad1889.o
6snd-als4000-objs := als4000.o 7snd-als4000-objs := als4000.o
7snd-atiixp-objs := atiixp.o 8snd-atiixp-objs := atiixp.o
8snd-atiixp-modem-objs := atiixp_modem.o 9snd-atiixp-modem-objs := atiixp_modem.o
@@ -25,6 +26,7 @@ snd-via82xx-objs := via82xx.o
25snd-via82xx-modem-objs := via82xx_modem.o 26snd-via82xx-modem-objs := via82xx_modem.o
26 27
27# Toplevel Module Dependency 28# Toplevel Module Dependency
29obj-$(CONFIG_SND_AD1889) += snd-ad1889.o
28obj-$(CONFIG_SND_ALS4000) += snd-als4000.o 30obj-$(CONFIG_SND_ALS4000) += snd-als4000.o
29obj-$(CONFIG_SND_ATIIXP) += snd-atiixp.o 31obj-$(CONFIG_SND_ATIIXP) += snd-atiixp.o
30obj-$(CONFIG_SND_ATIIXP_MODEM) += snd-atiixp-modem.o 32obj-$(CONFIG_SND_ATIIXP_MODEM) += snd-atiixp-modem.o
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 5501f4440c92..e64cb07a39c2 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -112,6 +112,7 @@ static const ac97_codec_id_t snd_ac97_codec_ids[] = {
112{ 0x414c4723, 0xffffffff, "ALC650F", NULL, NULL }, /* already patched */ 112{ 0x414c4723, 0xffffffff, "ALC650F", NULL, NULL }, /* already patched */
113{ 0x414c4720, 0xfffffff0, "ALC650", patch_alc650, NULL }, 113{ 0x414c4720, 0xfffffff0, "ALC650", patch_alc650, NULL },
114{ 0x414c4760, 0xfffffff0, "ALC655", patch_alc655, NULL }, 114{ 0x414c4760, 0xfffffff0, "ALC655", patch_alc655, NULL },
115{ 0x414c4781, 0xffffffff, "ALC658D", NULL, NULL }, /* already patched */
115{ 0x414c4780, 0xfffffff0, "ALC658", patch_alc655, NULL }, 116{ 0x414c4780, 0xfffffff0, "ALC658", patch_alc655, NULL },
116{ 0x414c4790, 0xfffffff0, "ALC850", patch_alc850, NULL }, 117{ 0x414c4790, 0xfffffff0, "ALC850", patch_alc850, NULL },
117{ 0x414c4730, 0xffffffff, "ALC101", NULL, NULL }, 118{ 0x414c4730, 0xffffffff, "ALC101", NULL, NULL },
@@ -1796,7 +1797,7 @@ int snd_ac97_bus(snd_card_t *card, int num, ac97_bus_ops_t *ops,
1796 1797
1797 snd_assert(card != NULL, return -EINVAL); 1798 snd_assert(card != NULL, return -EINVAL);
1798 snd_assert(rbus != NULL, return -EINVAL); 1799 snd_assert(rbus != NULL, return -EINVAL);
1799 bus = kcalloc(1, sizeof(*bus), GFP_KERNEL); 1800 bus = kzalloc(sizeof(*bus), GFP_KERNEL);
1800 if (bus == NULL) 1801 if (bus == NULL)
1801 return -ENOMEM; 1802 return -ENOMEM;
1802 bus->card = card; 1803 bus->card = card;
@@ -1905,7 +1906,7 @@ int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97)
1905 } 1906 }
1906 1907
1907 card = bus->card; 1908 card = bus->card;
1908 ac97 = kcalloc(1, sizeof(*ac97), GFP_KERNEL); 1909 ac97 = kzalloc(sizeof(*ac97), GFP_KERNEL);
1909 if (ac97 == NULL) 1910 if (ac97 == NULL)
1910 return -ENOMEM; 1911 return -ENOMEM;
1911 ac97->private_data = template->private_data; 1912 ac97->private_data = template->private_data;
diff --git a/sound/pci/ac97/ac97_id.h b/sound/pci/ac97/ac97_id.h
index dadf387ad0b8..6d73514dc49e 100644
--- a/sound/pci/ac97/ac97_id.h
+++ b/sound/pci/ac97/ac97_id.h
@@ -52,6 +52,7 @@
52#define AC97_ID_ALC650F 0x414c4723 52#define AC97_ID_ALC650F 0x414c4723
53#define AC97_ID_ALC655 0x414c4760 53#define AC97_ID_ALC655 0x414c4760
54#define AC97_ID_ALC658 0x414c4780 54#define AC97_ID_ALC658 0x414c4780
55#define AC97_ID_ALC658D 0x414c4781
55#define AC97_ID_ALC850 0x414c4790 56#define AC97_ID_ALC850 0x414c4790
56#define AC97_ID_YMF753 0x594d4803 57#define AC97_ID_YMF753 0x594d4803
57#define AC97_ID_VT1616 0x49434551 58#define AC97_ID_VT1616 0x49434551
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index b584172c1104..045ddc743edc 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -2134,7 +2134,13 @@ int patch_alc655(ac97_t * ac97)
2134{ 2134{
2135 unsigned int val; 2135 unsigned int val;
2136 2136
2137 ac97->spec.dev_flags = (ac97->id == 0x414c4780); /* ALC658 */ 2137 if (ac97->id == AC97_ID_ALC658) {
2138 ac97->spec.dev_flags = 1; /* ALC658 */
2139 if ((snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f) == 2) {
2140 ac97->id = AC97_ID_ALC658D;
2141 ac97->spec.dev_flags = 2;
2142 }
2143 }
2138 2144
2139 ac97->build_ops = &patch_alc655_ops; 2145 ac97->build_ops = &patch_alc655_ops;
2140 2146
@@ -2143,10 +2149,15 @@ int patch_alc655(ac97_t * ac97)
2143 2149
2144 /* adjust default values */ 2150 /* adjust default values */
2145 val = snd_ac97_read(ac97, 0x7a); /* misc control */ 2151 val = snd_ac97_read(ac97, 0x7a); /* misc control */
2146 if (ac97->id == 0x414c4780) /* ALC658 */ 2152 if (ac97->spec.dev_flags) /* ALC658 */
2147 val &= ~(1 << 1); /* Pin 47 is spdif input pin */ 2153 val &= ~(1 << 1); /* Pin 47 is spdif input pin */
2148 else /* ALC655 */ 2154 else { /* ALC655 */
2149 val |= (1 << 1); /* Pin 47 is spdif input pin */ 2155 if (ac97->subsystem_vendor == 0x1462 &&
2156 ac97->subsystem_device == 0x0131) /* MSI S270 laptop */
2157 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */
2158 else
2159 val |= (1 << 1); /* Pin 47 is spdif input pin */
2160 }
2150 val &= ~(1 << 12); /* vref enable */ 2161 val &= ~(1 << 12); /* vref enable */
2151 snd_ac97_write_cache(ac97, 0x7a, val); 2162 snd_ac97_write_cache(ac97, 0x7a, val);
2152 /* set default: spdif-in enabled, 2163 /* set default: spdif-in enabled,
@@ -2159,6 +2170,11 @@ int patch_alc655(ac97_t * ac97)
2159 /* full DAC volume */ 2170 /* full DAC volume */
2160 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808); 2171 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2161 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808); 2172 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2173
2174 /* update undocumented bit... */
2175 if (ac97->id == AC97_ID_ALC658D)
2176 snd_ac97_update_bits(ac97, 0x74, 0x0800, 0x0800);
2177
2162 return 0; 2178 return 0;
2163} 2179}
2164 2180
diff --git a/sound/pci/ac97/ak4531_codec.c b/sound/pci/ac97/ak4531_codec.c
index f9ce0fd2f52f..4032c5748370 100644
--- a/sound/pci/ac97/ak4531_codec.c
+++ b/sound/pci/ac97/ak4531_codec.c
@@ -357,7 +357,7 @@ int snd_ak4531_mixer(snd_card_t * card, ak4531_t * _ak4531, ak4531_t ** rak4531)
357 snd_assert(rak4531 != NULL, return -EINVAL); 357 snd_assert(rak4531 != NULL, return -EINVAL);
358 *rak4531 = NULL; 358 *rak4531 = NULL;
359 snd_assert(card != NULL && _ak4531 != NULL, return -EINVAL); 359 snd_assert(card != NULL && _ak4531 != NULL, return -EINVAL);
360 ak4531 = kcalloc(1, sizeof(*ak4531), GFP_KERNEL); 360 ak4531 = kzalloc(sizeof(*ak4531), GFP_KERNEL);
361 if (ak4531 == NULL) 361 if (ak4531 == NULL)
362 return -ENOMEM; 362 return -ENOMEM;
363 *ak4531 = *_ak4531; 363 *ak4531 = *_ak4531;
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
new file mode 100644
index 000000000000..d7d99a25c5e5
--- /dev/null
+++ b/sound/pci/ad1889.c
@@ -0,0 +1,1090 @@
1/* Analog Devices 1889 audio driver
2 *
3 * This is a driver for the AD1889 PCI audio chipset found
4 * on the HP PA-RISC [BCJ]-xxx0 workstations.
5 *
6 * Copyright (C) 2004-2005, Kyle McMartin <kyle@parisc-linux.org>
7 * Copyright (C) 2005, Thibaut Varene <varenet@parisc-linux.org>
8 * Based on the OSS AD1889 driver by Randolph Chung <tausq@debian.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License, version 2, as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 * TODO:
24 * Do we need to take care of CCS register?
25 * Maybe we could use finer grained locking (separate locks for pb/cap)?
26 * Wishlist:
27 * Control Interface (mixer) support
28 * Better AC97 support (VSR...)?
29 * PM support
30 * MIDI support
31 * Game Port support
32 * SG DMA support (this will need *alot* of work)
33 */
34
35#include <linux/init.h>
36#include <linux/pci.h>
37#include <linux/slab.h>
38#include <linux/interrupt.h>
39#include <linux/compiler.h>
40#include <linux/delay.h>
41
42#include <sound/driver.h>
43#include <sound/core.h>
44#include <sound/pcm.h>
45#include <sound/initval.h>
46#include <sound/ac97_codec.h>
47
48#include <asm/io.h>
49
50#include "ad1889.h"
51#include "ac97/ac97_id.h"
52
53#define AD1889_DRVVER "$Revision: 1.3 $"
54
55MODULE_AUTHOR("Kyle McMartin <kyle@parisc-linux.org>, Thibaut Varene <t-bone@parisc-linux.org>");
56MODULE_DESCRIPTION("Analog Devices AD1889 ALSA sound driver");
57MODULE_LICENSE("GPL");
58MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1889}}");
59
60static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
61module_param_array(index, int, NULL, 0444);
62MODULE_PARM_DESC(index, "Index value for the AD1889 soundcard.");
63
64static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
65module_param_array(id, charp, NULL, 0444);
66MODULE_PARM_DESC(id, "ID string for the AD1889 soundcard.");
67
68static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
69module_param_array(enable, bool, NULL, 0444);
70MODULE_PARM_DESC(enable, "Enable AD1889 soundcard.");
71
72static char *ac97_quirk[SNDRV_CARDS];
73module_param_array(ac97_quirk, charp, NULL, 0444);
74MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
75
76#define DEVNAME "ad1889"
77#define PFX DEVNAME ": "
78
79/* let's use the global sound debug interfaces */
80#define ad1889_debug(fmt, arg...) snd_printd(KERN_DEBUG fmt, ## arg)
81
82/* keep track of some hw registers */
83struct ad1889_register_state {
84 u16 reg; /* reg setup */
85 u32 addr; /* dma base address */
86 unsigned long size; /* DMA buffer size */
87};
88
89struct snd_ad1889 {
90 snd_card_t *card;
91 struct pci_dev *pci;
92
93 int irq;
94 unsigned long bar;
95 void __iomem *iobase;
96
97 ac97_t *ac97;
98 ac97_bus_t *ac97_bus;
99 snd_pcm_t *pcm;
100 snd_info_entry_t *proc;
101
102 snd_pcm_substream_t *psubs;
103 snd_pcm_substream_t *csubs;
104
105 /* playback register state */
106 struct ad1889_register_state wave;
107 struct ad1889_register_state ramc;
108
109 spinlock_t lock;
110};
111
112static inline u16
113ad1889_readw(struct snd_ad1889 *chip, unsigned reg)
114{
115 return readw(chip->iobase + reg);
116}
117
118static inline void
119ad1889_writew(struct snd_ad1889 *chip, unsigned reg, u16 val)
120{
121 writew(val, chip->iobase + reg);
122}
123
124static inline u32
125ad1889_readl(struct snd_ad1889 *chip, unsigned reg)
126{
127 return readl(chip->iobase + reg);
128}
129
130static inline void
131ad1889_writel(struct snd_ad1889 *chip, unsigned reg, u32 val)
132{
133 writel(val, chip->iobase + reg);
134}
135
136static inline void
137ad1889_unmute(struct snd_ad1889 *chip)
138{
139 u16 st;
140 st = ad1889_readw(chip, AD_DS_WADA) &
141 ~(AD_DS_WADA_RWAM | AD_DS_WADA_LWAM);
142 ad1889_writew(chip, AD_DS_WADA, st);
143 ad1889_readw(chip, AD_DS_WADA);
144}
145
146static inline void
147ad1889_mute(struct snd_ad1889 *chip)
148{
149 u16 st;
150 st = ad1889_readw(chip, AD_DS_WADA) | AD_DS_WADA_RWAM | AD_DS_WADA_LWAM;
151 ad1889_writew(chip, AD_DS_WADA, st);
152 ad1889_readw(chip, AD_DS_WADA);
153}
154
155static inline void
156ad1889_load_adc_buffer_address(struct snd_ad1889 *chip, u32 address)
157{
158 ad1889_writel(chip, AD_DMA_ADCBA, address);
159 ad1889_writel(chip, AD_DMA_ADCCA, address);
160}
161
162static inline void
163ad1889_load_adc_buffer_count(struct snd_ad1889 *chip, u32 count)
164{
165 ad1889_writel(chip, AD_DMA_ADCBC, count);
166 ad1889_writel(chip, AD_DMA_ADCCC, count);
167}
168
169static inline void
170ad1889_load_adc_interrupt_count(struct snd_ad1889 *chip, u32 count)
171{
172 ad1889_writel(chip, AD_DMA_ADCIB, count);
173 ad1889_writel(chip, AD_DMA_ADCIC, count);
174}
175
176static inline void
177ad1889_load_wave_buffer_address(struct snd_ad1889 *chip, u32 address)
178{
179 ad1889_writel(chip, AD_DMA_WAVBA, address);
180 ad1889_writel(chip, AD_DMA_WAVCA, address);
181}
182
183static inline void
184ad1889_load_wave_buffer_count(struct snd_ad1889 *chip, u32 count)
185{
186 ad1889_writel(chip, AD_DMA_WAVBC, count);
187 ad1889_writel(chip, AD_DMA_WAVCC, count);
188}
189
190static inline void
191ad1889_load_wave_interrupt_count(struct snd_ad1889 *chip, u32 count)
192{
193 ad1889_writel(chip, AD_DMA_WAVIB, count);
194 ad1889_writel(chip, AD_DMA_WAVIC, count);
195}
196
197static void
198ad1889_channel_reset(struct snd_ad1889 *chip, unsigned int channel)
199{
200 u16 reg;
201
202 if (channel & AD_CHAN_WAV) {
203 /* Disable wave channel */
204 reg = ad1889_readw(chip, AD_DS_WSMC) & ~AD_DS_WSMC_WAEN;
205 ad1889_writew(chip, AD_DS_WSMC, reg);
206 chip->wave.reg = reg;
207
208 /* disable IRQs */
209 reg = ad1889_readw(chip, AD_DMA_WAV);
210 reg &= AD_DMA_IM_DIS;
211 reg &= ~AD_DMA_LOOP;
212 ad1889_writew(chip, AD_DMA_WAV, reg);
213
214 /* clear IRQ and address counters and pointers */
215 ad1889_load_wave_buffer_address(chip, 0x0);
216 ad1889_load_wave_buffer_count(chip, 0x0);
217 ad1889_load_wave_interrupt_count(chip, 0x0);
218
219 /* flush */
220 ad1889_readw(chip, AD_DMA_WAV);
221 }
222
223 if (channel & AD_CHAN_ADC) {
224 /* Disable ADC channel */
225 reg = ad1889_readw(chip, AD_DS_RAMC) & ~AD_DS_RAMC_ADEN;
226 ad1889_writew(chip, AD_DS_RAMC, reg);
227 chip->ramc.reg = reg;
228
229 reg = ad1889_readw(chip, AD_DMA_ADC);
230 reg &= AD_DMA_IM_DIS;
231 reg &= ~AD_DMA_LOOP;
232 ad1889_writew(chip, AD_DMA_ADC, reg);
233
234 ad1889_load_adc_buffer_address(chip, 0x0);
235 ad1889_load_adc_buffer_count(chip, 0x0);
236 ad1889_load_adc_interrupt_count(chip, 0x0);
237
238 /* flush */
239 ad1889_readw(chip, AD_DMA_ADC);
240 }
241}
242
243static inline u16
244snd_ad1889_ac97_read(ac97_t *ac97, unsigned short reg)
245{
246 struct snd_ad1889 *chip = ac97->private_data;
247 return ad1889_readw(chip, AD_AC97_BASE + reg);
248}
249
250static inline void
251snd_ad1889_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
252{
253 struct snd_ad1889 *chip = ac97->private_data;
254 ad1889_writew(chip, AD_AC97_BASE + reg, val);
255}
256
257static int
258snd_ad1889_ac97_ready(struct snd_ad1889 *chip)
259{
260 int retry = 400; /* average needs 352 msec */
261
262 while (!(ad1889_readw(chip, AD_AC97_ACIC) & AD_AC97_ACIC_ACRDY)
263 && --retry)
264 mdelay(1);
265 if (!retry) {
266 snd_printk(KERN_ERR PFX "[%s] Link is not ready.\n",
267 __FUNCTION__);
268 return -EIO;
269 }
270 ad1889_debug("[%s] ready after %d ms\n", __FUNCTION__, 400 - retry);
271
272 return 0;
273}
274
275static int
276snd_ad1889_hw_params(snd_pcm_substream_t *substream,
277 snd_pcm_hw_params_t *hw_params)
278{
279 return snd_pcm_lib_malloc_pages(substream,
280 params_buffer_bytes(hw_params));
281}
282
283static int
284snd_ad1889_hw_free(snd_pcm_substream_t *substream)
285{
286 return snd_pcm_lib_free_pages(substream);
287}
288
289static snd_pcm_hardware_t snd_ad1889_playback_hw = {
290 .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
291 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER,
292 .formats = SNDRV_PCM_FMTBIT_S16_LE,
293 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
294 .rate_min = 8000, /* docs say 7000, but we're lazy */
295 .rate_max = 48000,
296 .channels_min = 1,
297 .channels_max = 2,
298 .buffer_bytes_max = BUFFER_BYTES_MAX,
299 .period_bytes_min = PERIOD_BYTES_MIN,
300 .period_bytes_max = PERIOD_BYTES_MAX,
301 .periods_min = PERIODS_MIN,
302 .periods_max = PERIODS_MAX,
303 /*.fifo_size = 0,*/
304};
305
306static snd_pcm_hardware_t snd_ad1889_capture_hw = {
307 .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
308 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER,
309 .formats = SNDRV_PCM_FMTBIT_S16_LE,
310 .rates = SNDRV_PCM_RATE_48000,
311 .rate_min = 48000, /* docs say we could to VSR, but we're lazy */
312 .rate_max = 48000,
313 .channels_min = 1,
314 .channels_max = 2,
315 .buffer_bytes_max = BUFFER_BYTES_MAX,
316 .period_bytes_min = PERIOD_BYTES_MIN,
317 .period_bytes_max = PERIOD_BYTES_MAX,
318 .periods_min = PERIODS_MIN,
319 .periods_max = PERIODS_MAX,
320 /*.fifo_size = 0,*/
321};
322
323static int
324snd_ad1889_playback_open(snd_pcm_substream_t *ss)
325{
326 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss);
327 snd_pcm_runtime_t *rt = ss->runtime;
328
329 chip->psubs = ss;
330 rt->hw = snd_ad1889_playback_hw;
331
332 return 0;
333}
334
335static int
336snd_ad1889_capture_open(snd_pcm_substream_t *ss)
337{
338 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss);
339 snd_pcm_runtime_t *rt = ss->runtime;
340
341 chip->csubs = ss;
342 rt->hw = snd_ad1889_capture_hw;
343
344 return 0;
345}
346
347static int
348snd_ad1889_playback_close(snd_pcm_substream_t *ss)
349{
350 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss);
351 chip->psubs = NULL;
352 return 0;
353}
354
355static int
356snd_ad1889_capture_close(snd_pcm_substream_t *ss)
357{
358 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss);
359 chip->csubs = NULL;
360 return 0;
361}
362
363static int
364snd_ad1889_playback_prepare(snd_pcm_substream_t *ss)
365{
366 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss);
367 snd_pcm_runtime_t *rt = ss->runtime;
368 unsigned int size = snd_pcm_lib_buffer_bytes(ss);
369 unsigned int count = snd_pcm_lib_period_bytes(ss);
370 u16 reg;
371
372 ad1889_channel_reset(chip, AD_CHAN_WAV);
373
374 reg = ad1889_readw(chip, AD_DS_WSMC);
375
376 /* Mask out 16-bit / Stereo */
377 reg &= ~(AD_DS_WSMC_WA16 | AD_DS_WSMC_WAST);
378
379 if (snd_pcm_format_width(rt->format) == 16)
380 reg |= AD_DS_WSMC_WA16;
381
382 if (rt->channels > 1)
383 reg |= AD_DS_WSMC_WAST;
384
385 /* let's make sure we don't clobber ourselves */
386 spin_lock_irq(&chip->lock);
387
388 chip->wave.size = size;
389 chip->wave.reg = reg;
390 chip->wave.addr = rt->dma_addr;
391
392 ad1889_writew(chip, AD_DS_WSMC, chip->wave.reg);
393
394 /* Set sample rates on the codec */
395 ad1889_writew(chip, AD_DS_WAS, rt->rate);
396
397 /* Set up DMA */
398 ad1889_load_wave_buffer_address(chip, chip->wave.addr);
399 ad1889_load_wave_buffer_count(chip, size);
400 ad1889_load_wave_interrupt_count(chip, count);
401
402 /* writes flush */
403 ad1889_readw(chip, AD_DS_WSMC);
404
405 spin_unlock_irq(&chip->lock);
406
407 ad1889_debug("prepare playback: addr = 0x%x, count = %u, "
408 "size = %u, reg = 0x%x, rate = %u\n", chip->wave.addr,
409 count, size, reg, rt->rate);
410 return 0;
411}
412
413static int
414snd_ad1889_capture_prepare(snd_pcm_substream_t *ss)
415{
416 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss);
417 snd_pcm_runtime_t *rt = ss->runtime;
418 unsigned int size = snd_pcm_lib_buffer_bytes(ss);
419 unsigned int count = snd_pcm_lib_period_bytes(ss);
420 u16 reg;
421
422 ad1889_channel_reset(chip, AD_CHAN_ADC);
423
424 reg = ad1889_readw(chip, AD_DS_RAMC);
425
426 /* Mask out 16-bit / Stereo */
427 reg &= ~(AD_DS_RAMC_AD16 | AD_DS_RAMC_ADST);
428
429 if (snd_pcm_format_width(rt->format) == 16)
430 reg |= AD_DS_RAMC_AD16;
431
432 if (rt->channels > 1)
433 reg |= AD_DS_RAMC_ADST;
434
435 /* let's make sure we don't clobber ourselves */
436 spin_lock_irq(&chip->lock);
437
438 chip->ramc.size = size;
439 chip->ramc.reg = reg;
440 chip->ramc.addr = rt->dma_addr;
441
442 ad1889_writew(chip, AD_DS_RAMC, chip->ramc.reg);
443
444 /* Set up DMA */
445 ad1889_load_adc_buffer_address(chip, chip->ramc.addr);
446 ad1889_load_adc_buffer_count(chip, size);
447 ad1889_load_adc_interrupt_count(chip, count);
448
449 /* writes flush */
450 ad1889_readw(chip, AD_DS_RAMC);
451
452 spin_unlock_irq(&chip->lock);
453
454 ad1889_debug("prepare capture: addr = 0x%x, count = %u, "
455 "size = %u, reg = 0x%x, rate = %u\n", chip->ramc.addr,
456 count, size, reg, rt->rate);
457 return 0;
458}
459
460/* this is called in atomic context with IRQ disabled.
461 Must be as fast as possible and not sleep.
462 DMA should be *triggered* by this call.
463 The WSMC "WAEN" bit triggers DMA Wave On/Off */
464static int
465snd_ad1889_playback_trigger(snd_pcm_substream_t *ss, int cmd)
466{
467 u16 wsmc;
468 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss);
469
470 wsmc = ad1889_readw(chip, AD_DS_WSMC);
471
472 switch (cmd) {
473 case SNDRV_PCM_TRIGGER_START:
474 /* enable DMA loop & interrupts */
475 ad1889_writew(chip, AD_DMA_WAV, AD_DMA_LOOP | AD_DMA_IM_CNT);
476 wsmc |= AD_DS_WSMC_WAEN;
477 /* 1 to clear CHSS bit */
478 ad1889_writel(chip, AD_DMA_CHSS, AD_DMA_CHSS_WAVS);
479 ad1889_unmute(chip);
480 break;
481 case SNDRV_PCM_TRIGGER_STOP:
482 ad1889_mute(chip);
483 wsmc &= ~AD_DS_WSMC_WAEN;
484 break;
485 default:
486 snd_BUG();
487 return -EINVAL;
488 }
489
490 chip->wave.reg = wsmc;
491 ad1889_writew(chip, AD_DS_WSMC, wsmc);
492 ad1889_readw(chip, AD_DS_WSMC); /* flush */
493
494 /* reset the chip when STOP - will disable IRQs */
495 if (cmd == SNDRV_PCM_TRIGGER_STOP)
496 ad1889_channel_reset(chip, AD_CHAN_WAV);
497
498 return 0;
499}
500
501/* this is called in atomic context with IRQ disabled.
502 Must be as fast as possible and not sleep.
503 DMA should be *triggered* by this call.
504 The RAMC "ADEN" bit triggers DMA ADC On/Off */
505static int
506snd_ad1889_capture_trigger(snd_pcm_substream_t *ss, int cmd)
507{
508 u16 ramc;
509 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss);
510
511 ramc = ad1889_readw(chip, AD_DS_RAMC);
512
513 switch (cmd) {
514 case SNDRV_PCM_TRIGGER_START:
515 /* enable DMA loop & interrupts */
516 ad1889_writew(chip, AD_DMA_ADC, AD_DMA_LOOP | AD_DMA_IM_CNT);
517 ramc |= AD_DS_RAMC_ADEN;
518 /* 1 to clear CHSS bit */
519 ad1889_writel(chip, AD_DMA_CHSS, AD_DMA_CHSS_ADCS);
520 break;
521 case SNDRV_PCM_TRIGGER_STOP:
522 ramc &= ~AD_DS_RAMC_ADEN;
523 break;
524 default:
525 return -EINVAL;
526 }
527
528 chip->ramc.reg = ramc;
529 ad1889_writew(chip, AD_DS_RAMC, ramc);
530 ad1889_readw(chip, AD_DS_RAMC); /* flush */
531
532 /* reset the chip when STOP - will disable IRQs */
533 if (cmd == SNDRV_PCM_TRIGGER_STOP)
534 ad1889_channel_reset(chip, AD_CHAN_ADC);
535
536 return 0;
537}
538
539/* Called in atomic context with IRQ disabled */
540static snd_pcm_uframes_t
541snd_ad1889_playback_pointer(snd_pcm_substream_t *ss)
542{
543 size_t ptr = 0;
544 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss);
545
546 if (unlikely(!(chip->wave.reg & AD_DS_WSMC_WAEN)))
547 return 0;
548
549 ptr = ad1889_readl(chip, AD_DMA_WAVCA);
550 ptr -= chip->wave.addr;
551
552 snd_assert((ptr >= 0) && (ptr < chip->wave.size), return 0);
553
554 return bytes_to_frames(ss->runtime, ptr);
555}
556
557/* Called in atomic context with IRQ disabled */
558static snd_pcm_uframes_t
559snd_ad1889_capture_pointer(snd_pcm_substream_t *ss)
560{
561 size_t ptr = 0;
562 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss);
563
564 if (unlikely(!(chip->ramc.reg & AD_DS_RAMC_ADEN)))
565 return 0;
566
567 ptr = ad1889_readl(chip, AD_DMA_ADCCA);
568 ptr -= chip->ramc.addr;
569
570 snd_assert((ptr >= 0) && (ptr < chip->ramc.size), return 0);
571
572 return bytes_to_frames(ss->runtime, ptr);
573}
574
575static snd_pcm_ops_t snd_ad1889_playback_ops = {
576 .open = snd_ad1889_playback_open,
577 .close = snd_ad1889_playback_close,
578 .ioctl = snd_pcm_lib_ioctl,
579 .hw_params = snd_ad1889_hw_params,
580 .hw_free = snd_ad1889_hw_free,
581 .prepare = snd_ad1889_playback_prepare,
582 .trigger = snd_ad1889_playback_trigger,
583 .pointer = snd_ad1889_playback_pointer,
584};
585
586static snd_pcm_ops_t snd_ad1889_capture_ops = {
587 .open = snd_ad1889_capture_open,
588 .close = snd_ad1889_capture_close,
589 .ioctl = snd_pcm_lib_ioctl,
590 .hw_params = snd_ad1889_hw_params,
591 .hw_free = snd_ad1889_hw_free,
592 .prepare = snd_ad1889_capture_prepare,
593 .trigger = snd_ad1889_capture_trigger,
594 .pointer = snd_ad1889_capture_pointer,
595};
596
597static irqreturn_t
598snd_ad1889_interrupt(int irq,
599 void *dev_id,
600 struct pt_regs *regs)
601{
602 unsigned long st;
603 struct snd_ad1889 *chip = dev_id;
604
605 st = ad1889_readl(chip, AD_DMA_DISR);
606
607 /* clear ISR */
608 ad1889_writel(chip, AD_DMA_DISR, st);
609
610 st &= AD_INTR_MASK;
611
612 if (unlikely(!st))
613 return IRQ_NONE;
614
615 if (st & (AD_DMA_DISR_PMAI|AD_DMA_DISR_PTAI))
616 ad1889_debug("Unexpected master or target abort interrupt!\n");
617
618 if ((st & AD_DMA_DISR_WAVI) && chip->psubs)
619 snd_pcm_period_elapsed(chip->psubs);
620 if ((st & AD_DMA_DISR_ADCI) && chip->csubs)
621 snd_pcm_period_elapsed(chip->csubs);
622
623 return IRQ_HANDLED;
624}
625
626static void
627snd_ad1889_pcm_free(snd_pcm_t *pcm)
628{
629 struct snd_ad1889 *chip = pcm->private_data;
630 chip->pcm = NULL;
631 snd_pcm_lib_preallocate_free_for_all(pcm);
632}
633
634static int __devinit
635snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, snd_pcm_t **rpcm)
636{
637 int err;
638 snd_pcm_t *pcm;
639
640 if (rpcm)
641 *rpcm = NULL;
642
643 err = snd_pcm_new(chip->card, chip->card->driver, device, 1, 1, &pcm);
644 if (err < 0)
645 return err;
646
647 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
648 &snd_ad1889_playback_ops);
649 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
650 &snd_ad1889_capture_ops);
651
652 pcm->private_data = chip;
653 pcm->private_free = snd_ad1889_pcm_free;
654 pcm->info_flags = 0;
655 strcpy(pcm->name, chip->card->shortname);
656
657 chip->pcm = pcm;
658 chip->psubs = NULL;
659 chip->csubs = NULL;
660
661 err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
662 snd_dma_pci_data(chip->pci),
663 BUFFER_BYTES_MAX / 2,
664 BUFFER_BYTES_MAX);
665
666 if (err < 0) {
667 snd_printk(KERN_ERR PFX "buffer allocation error: %d\n", err);
668 return err;
669 }
670
671 if (rpcm)
672 *rpcm = pcm;
673
674 return 0;
675}
676
677static void
678snd_ad1889_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
679{
680 struct snd_ad1889 *chip = entry->private_data;
681 u16 reg;
682 int tmp;
683
684 reg = ad1889_readw(chip, AD_DS_WSMC);
685 snd_iprintf(buffer, "Wave output: %s\n",
686 (reg & AD_DS_WSMC_WAEN) ? "enabled" : "disabled");
687 snd_iprintf(buffer, "Wave Channels: %s\n",
688 (reg & AD_DS_WSMC_WAST) ? "stereo" : "mono");
689 snd_iprintf(buffer, "Wave Quality: %d-bit linear\n",
690 (reg & AD_DS_WSMC_WA16) ? 16 : 8);
691
692 /* WARQ is at offset 12 */
693 tmp = (reg & AD_DS_WSMC_WARQ) ?
694 (((reg & AD_DS_WSMC_WARQ >> 12) & 0x01) ? 12 : 18) : 4;
695 tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1;
696
697 snd_iprintf(buffer, "Wave FIFO: %d %s words\n\n", tmp,
698 (reg & AD_DS_WSMC_WAST) ? "stereo" : "mono");
699
700
701 snd_iprintf(buffer, "Synthesis output: %s\n",
702 reg & AD_DS_WSMC_SYEN ? "enabled" : "disabled");
703
704 /* SYRQ is at offset 4 */
705 tmp = (reg & AD_DS_WSMC_SYRQ) ?
706 (((reg & AD_DS_WSMC_SYRQ >> 4) & 0x01) ? 12 : 18) : 4;
707 tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1;
708
709 snd_iprintf(buffer, "Synthesis FIFO: %d %s words\n\n", tmp,
710 (reg & AD_DS_WSMC_WAST) ? "stereo" : "mono");
711
712 reg = ad1889_readw(chip, AD_DS_RAMC);
713 snd_iprintf(buffer, "ADC input: %s\n",
714 (reg & AD_DS_RAMC_ADEN) ? "enabled" : "disabled");
715 snd_iprintf(buffer, "ADC Channels: %s\n",
716 (reg & AD_DS_RAMC_ADST) ? "stereo" : "mono");
717 snd_iprintf(buffer, "ADC Quality: %d-bit linear\n",
718 (reg & AD_DS_RAMC_AD16) ? 16 : 8);
719
720 /* ACRQ is at offset 4 */
721 tmp = (reg & AD_DS_RAMC_ACRQ) ?
722 (((reg & AD_DS_RAMC_ACRQ >> 4) & 0x01) ? 12 : 18) : 4;
723 tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1;
724
725 snd_iprintf(buffer, "ADC FIFO: %d %s words\n\n", tmp,
726 (reg & AD_DS_RAMC_ADST) ? "stereo" : "mono");
727
728 snd_iprintf(buffer, "Resampler input: %s\n",
729 reg & AD_DS_RAMC_REEN ? "enabled" : "disabled");
730
731 /* RERQ is at offset 12 */
732 tmp = (reg & AD_DS_RAMC_RERQ) ?
733 (((reg & AD_DS_RAMC_RERQ >> 12) & 0x01) ? 12 : 18) : 4;
734 tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1;
735
736 snd_iprintf(buffer, "Resampler FIFO: %d %s words\n\n", tmp,
737 (reg & AD_DS_WSMC_WAST) ? "stereo" : "mono");
738
739
740 /* doc says LSB represents -1.5dB, but the max value (-94.5dB)
741 suggests that LSB is -3dB, which is more coherent with the logarithmic
742 nature of the dB scale */
743 reg = ad1889_readw(chip, AD_DS_WADA);
744 snd_iprintf(buffer, "Left: %s, -%d dB\n",
745 (reg & AD_DS_WADA_LWAM) ? "mute" : "unmute",
746 ((reg & AD_DS_WADA_LWAA) >> 8) * 3);
747 reg = ad1889_readw(chip, AD_DS_WADA);
748 snd_iprintf(buffer, "Right: %s, -%d dB\n",
749 (reg & AD_DS_WADA_RWAM) ? "mute" : "unmute",
750 ((reg & AD_DS_WADA_RWAA) >> 8) * 3);
751
752 reg = ad1889_readw(chip, AD_DS_WAS);
753 snd_iprintf(buffer, "Wave samplerate: %u Hz\n", reg);
754 reg = ad1889_readw(chip, AD_DS_RES);
755 snd_iprintf(buffer, "Resampler samplerate: %u Hz\n", reg);
756}
757
758static void __devinit
759snd_ad1889_proc_init(struct snd_ad1889 *chip)
760{
761 snd_info_entry_t *entry;
762
763 if (!snd_card_proc_new(chip->card, chip->card->driver, &entry))
764 snd_info_set_text_ops(entry, chip, 1024, snd_ad1889_proc_read);
765}
766
767static struct ac97_quirk ac97_quirks[] = {
768 {
769 .subvendor = 0x11d4, /* AD */
770 .subdevice = 0x1889, /* AD1889 */
771 .codec_id = AC97_ID_AD1819,
772 .name = "AD1889",
773 .type = AC97_TUNE_HP_ONLY
774 },
775 { } /* terminator */
776};
777
778static void __devinit
779snd_ad1889_ac97_xinit(struct snd_ad1889 *chip)
780{
781 u16 reg;
782
783 reg = ad1889_readw(chip, AD_AC97_ACIC);
784 reg |= AD_AC97_ACIC_ACRD; /* Reset Disable */
785 ad1889_writew(chip, AD_AC97_ACIC, reg);
786 ad1889_readw(chip, AD_AC97_ACIC); /* flush posted write */
787 udelay(10);
788 /* Interface Enable */
789 reg |= AD_AC97_ACIC_ACIE;
790 ad1889_writew(chip, AD_AC97_ACIC, reg);
791
792 snd_ad1889_ac97_ready(chip);
793
794 /* Audio Stream Output | Variable Sample Rate Mode */
795 reg = ad1889_readw(chip, AD_AC97_ACIC);
796 reg |= AD_AC97_ACIC_ASOE | AD_AC97_ACIC_VSRM;
797 ad1889_writew(chip, AD_AC97_ACIC, reg);
798 ad1889_readw(chip, AD_AC97_ACIC); /* flush posted write */
799
800}
801
802static void
803snd_ad1889_ac97_bus_free(ac97_bus_t *bus)
804{
805 struct snd_ad1889 *chip = bus->private_data;
806 chip->ac97_bus = NULL;
807}
808
809static void
810snd_ad1889_ac97_free(ac97_t *ac97)
811{
812 struct snd_ad1889 *chip = ac97->private_data;
813 chip->ac97 = NULL;
814}
815
816static int __devinit
817snd_ad1889_ac97_init(struct snd_ad1889 *chip, const char *quirk_override)
818{
819 int err;
820 ac97_template_t ac97;
821 static ac97_bus_ops_t ops = {
822 .write = snd_ad1889_ac97_write,
823 .read = snd_ad1889_ac97_read,
824 };
825
826 /* doing that here, it works. */
827 snd_ad1889_ac97_xinit(chip);
828
829 err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus);
830 if (err < 0)
831 return err;
832
833 chip->ac97_bus->private_free = snd_ad1889_ac97_bus_free;
834
835 memset(&ac97, 0, sizeof(ac97));
836 ac97.private_data = chip;
837 ac97.private_free = snd_ad1889_ac97_free;
838 ac97.pci = chip->pci;
839
840 err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97);
841 if (err < 0)
842 return err;
843
844 snd_ac97_tune_hardware(chip->ac97, ac97_quirks, quirk_override);
845
846 return 0;
847}
848
849static int
850snd_ad1889_free(struct snd_ad1889 *chip)
851{
852 if (chip->irq < 0)
853 goto skip_hw;
854
855 spin_lock_irq(&chip->lock);
856
857 ad1889_mute(chip);
858
859 /* Turn off interrupt on count and zero DMA registers */
860 ad1889_channel_reset(chip, AD_CHAN_WAV | AD_CHAN_ADC);
861
862 /* clear DISR. If we don't, we'd better jump off the Eiffel Tower */
863 ad1889_writel(chip, AD_DMA_DISR, AD_DMA_DISR_PTAI | AD_DMA_DISR_PMAI);
864 ad1889_readl(chip, AD_DMA_DISR); /* flush, dammit! */
865
866 spin_unlock_irq(&chip->lock);
867
868 synchronize_irq(chip->irq);
869
870 if (chip->irq >= 0)
871 free_irq(chip->irq, (void*)chip);
872
873skip_hw:
874 if (chip->iobase)
875 iounmap(chip->iobase);
876
877 pci_release_regions(chip->pci);
878 pci_disable_device(chip->pci);
879
880 kfree(chip);
881 return 0;
882}
883
884static inline int
885snd_ad1889_dev_free(snd_device_t *device)
886{
887 struct snd_ad1889 *chip = device->device_data;
888 return snd_ad1889_free(chip);
889}
890
891static int __devinit
892snd_ad1889_init(struct snd_ad1889 *chip)
893{
894 ad1889_writew(chip, AD_DS_CCS, AD_DS_CCS_CLKEN); /* turn on clock */
895 ad1889_readw(chip, AD_DS_CCS); /* flush posted write */
896
897 mdelay(10);
898
899 /* enable Master and Target abort interrupts */
900 ad1889_writel(chip, AD_DMA_DISR, AD_DMA_DISR_PMAE | AD_DMA_DISR_PTAE);
901
902 return 0;
903}
904
905static int __devinit
906snd_ad1889_create(snd_card_t *card,
907 struct pci_dev *pci,
908 struct snd_ad1889 **rchip)
909{
910 int err;
911
912 struct snd_ad1889 *chip;
913 static snd_device_ops_t ops = {
914 .dev_free = snd_ad1889_dev_free,
915 };
916
917 *rchip = NULL;
918
919 if ((err = pci_enable_device(pci)) < 0)
920 return err;
921
922 /* check PCI availability (32bit DMA) */
923 if (pci_set_dma_mask(pci, 0xffffffff) < 0 ||
924 pci_set_consistent_dma_mask(pci, 0xffffffff) < 0) {
925 printk(KERN_ERR PFX "error setting 32-bit DMA mask.\n");
926 pci_disable_device(pci);
927 return -ENXIO;
928 }
929
930 /* allocate chip specific data with zero-filled memory */
931 if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) {
932 pci_disable_device(pci);
933 return -ENOMEM;
934 }
935
936 chip->card = card;
937 card->private_data = chip;
938 chip->pci = pci;
939 chip->irq = -1;
940
941 /* (1) PCI resource allocation */
942 if ((err = pci_request_regions(pci, card->driver)) < 0)
943 goto free_and_ret;
944
945 chip->bar = pci_resource_start(pci, 0);
946 chip->iobase = ioremap_nocache(chip->bar, pci_resource_len(pci, 0));
947 if (chip->iobase == NULL) {
948 printk(KERN_ERR PFX "unable to reserve region.\n");
949 err = -EBUSY;
950 goto free_and_ret;
951 }
952
953 pci_set_master(pci);
954
955 spin_lock_init(&chip->lock); /* only now can we call ad1889_free */
956
957 if (request_irq(pci->irq, snd_ad1889_interrupt,
958 SA_INTERRUPT|SA_SHIRQ, card->driver, (void*)chip)) {
959 printk(KERN_ERR PFX "cannot obtain IRQ %d\n", pci->irq);
960 snd_ad1889_free(chip);
961 return -EBUSY;
962 }
963
964 chip->irq = pci->irq;
965 synchronize_irq(chip->irq);
966
967 /* (2) initialization of the chip hardware */
968 if ((err = snd_ad1889_init(chip)) < 0) {
969 snd_ad1889_free(chip);
970 return err;
971 }
972
973 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
974 snd_ad1889_free(chip);
975 return err;
976 }
977
978 snd_card_set_dev(card, &pci->dev);
979
980 *rchip = chip;
981
982 return 0;
983
984free_and_ret:
985 if (chip)
986 kfree(chip);
987 pci_disable_device(pci);
988
989 return err;
990}
991
992static int __devinit
993snd_ad1889_probe(struct pci_dev *pci,
994 const struct pci_device_id *pci_id)
995{
996 int err;
997 static int devno;
998 snd_card_t *card;
999 struct snd_ad1889 *chip;
1000
1001 /* (1) */
1002 if (devno >= SNDRV_CARDS)
1003 return -ENODEV;
1004 if (!enable[devno]) {
1005 devno++;
1006 return -ENOENT;
1007 }
1008
1009 /* (2) */
1010 card = snd_card_new(index[devno], id[devno], THIS_MODULE, 0);
1011 /* XXX REVISIT: we can probably allocate chip in this call */
1012 if (card == NULL)
1013 return -ENOMEM;
1014
1015 strcpy(card->driver, "AD1889");
1016 strcpy(card->shortname, "Analog Devices AD1889");
1017
1018 /* (3) */
1019 err = snd_ad1889_create(card, pci, &chip);
1020 if (err < 0)
1021 goto free_and_ret;
1022
1023 /* (4) */
1024 sprintf(card->longname, "%s at 0x%lx irq %i",
1025 card->shortname, chip->bar, chip->irq);
1026
1027 /* (5) */
1028 /* register AC97 mixer */
1029 err = snd_ad1889_ac97_init(chip, ac97_quirk[devno]);
1030 if (err < 0)
1031 goto free_and_ret;
1032
1033 err = snd_ad1889_pcm_init(chip, 0, NULL);
1034 if (err < 0)
1035 goto free_and_ret;
1036
1037 /* register proc interface */
1038 snd_ad1889_proc_init(chip);
1039
1040 /* (6) */
1041 err = snd_card_register(card);
1042 if (err < 0)
1043 goto free_and_ret;
1044
1045 /* (7) */
1046 pci_set_drvdata(pci, card);
1047
1048 devno++;
1049 return 0;
1050
1051free_and_ret:
1052 snd_card_free(card);
1053 return err;
1054}
1055
1056static void __devexit
1057snd_ad1889_remove(struct pci_dev *pci)
1058{
1059 snd_card_free(pci_get_drvdata(pci));
1060 pci_set_drvdata(pci, NULL);
1061}
1062
1063static struct pci_device_id snd_ad1889_ids[] = {
1064 { PCI_DEVICE(PCI_VENDOR_ID_ANALOG_DEVICES, PCI_DEVICE_ID_AD1889JS) },
1065 { 0, },
1066};
1067MODULE_DEVICE_TABLE(pci, snd_ad1889_ids);
1068
1069static struct pci_driver ad1889_pci = {
1070 .name = "AD1889 Audio",
1071 .owner = THIS_MODULE,
1072 .id_table = snd_ad1889_ids,
1073 .probe = snd_ad1889_probe,
1074 .remove = __devexit_p(snd_ad1889_remove),
1075};
1076
1077static int __init
1078alsa_ad1889_init(void)
1079{
1080 return pci_register_driver(&ad1889_pci);
1081}
1082
1083static void __exit
1084alsa_ad1889_fini(void)
1085{
1086 pci_unregister_driver(&ad1889_pci);
1087}
1088
1089module_init(alsa_ad1889_init);
1090module_exit(alsa_ad1889_fini);
diff --git a/sound/pci/ad1889.h b/sound/pci/ad1889.h
new file mode 100644
index 000000000000..5e6dad5341a1
--- /dev/null
+++ b/sound/pci/ad1889.h
@@ -0,0 +1,189 @@
1/* Analog Devices 1889 audio driver
2 * Copyright (C) 2004, Kyle McMartin <kyle@parisc-linux.org>
3 */
4
5#ifndef __AD1889_H__
6#define __AD1889_H__
7
8#define AD_DS_WSMC 0x00 /* wave/synthesis channel mixer control */
9#define AD_DS_WSMC_SYEN 0x0004 /* synthesis channel enable */
10#define AD_DS_WSMC_SYRQ 0x0030 /* synth. fifo request point */
11#define AD_DS_WSMC_WA16 0x0100 /* wave channel 16bit select */
12#define AD_DS_WSMC_WAST 0x0200 /* wave channel stereo select */
13#define AD_DS_WSMC_WAEN 0x0400 /* wave channel enable */
14#define AD_DS_WSMC_WARQ 0x3000 /* wave fifo request point */
15
16#define AD_DS_RAMC 0x02 /* resampler/ADC channel mixer control */
17#define AD_DS_RAMC_AD16 0x0001 /* ADC channel 16bit select */
18#define AD_DS_RAMC_ADST 0x0002 /* ADC channel stereo select */
19#define AD_DS_RAMC_ADEN 0x0004 /* ADC channel enable */
20#define AD_DS_RAMC_ACRQ 0x0030 /* ADC fifo request point */
21#define AD_DS_RAMC_REEN 0x0400 /* resampler channel enable */
22#define AD_DS_RAMC_RERQ 0x3000 /* res. fifo request point */
23
24#define AD_DS_WADA 0x04 /* wave channel mix attenuation */
25#define AD_DS_WADA_RWAM 0x0080 /* right wave mute */
26#define AD_DS_WADA_RWAA 0x001f /* right wave attenuation */
27#define AD_DS_WADA_LWAM 0x8000 /* left wave mute */
28#define AD_DS_WADA_LWAA 0x3e00 /* left wave attenuation */
29
30#define AD_DS_SYDA 0x06 /* synthesis channel mix attenuation */
31#define AD_DS_SYDA_RSYM 0x0080 /* right synthesis mute */
32#define AD_DS_SYDA_RSYA 0x001f /* right synthesis attenuation */
33#define AD_DS_SYDA_LSYM 0x8000 /* left synthesis mute */
34#define AD_DS_SYDA_LSYA 0x3e00 /* left synthesis attenuation */
35
36#define AD_DS_WAS 0x08 /* wave channel sample rate */
37#define AD_DS_WAS_WAS 0xffff /* sample rate mask */
38
39#define AD_DS_RES 0x0a /* resampler channel sample rate */
40#define AD_DS_RES_RES 0xffff /* sample rate mask */
41
42#define AD_DS_CCS 0x0c /* chip control/status */
43#define AD_DS_CCS_ADO 0x0001 /* ADC channel overflow */
44#define AD_DS_CCS_REO 0x0002 /* resampler channel overflow */
45#define AD_DS_CCS_SYU 0x0004 /* synthesis channel underflow */
46#define AD_DS_CCS_WAU 0x0008 /* wave channel underflow */
47/* bits 4 -> 7, 9, 11 -> 14 reserved */
48#define AD_DS_CCS_XTD 0x0100 /* xtd delay control (4096 clock cycles) */
49#define AD_DS_CCS_PDALL 0x0400 /* power */
50#define AD_DS_CCS_CLKEN 0x8000 /* clock */
51
52#define AD_DMA_RESBA 0x40 /* RES base address */
53#define AD_DMA_RESCA 0x44 /* RES current address */
54#define AD_DMA_RESBC 0x48 /* RES base count */
55#define AD_DMA_RESCC 0x4c /* RES current count */
56
57#define AD_DMA_ADCBA 0x50 /* ADC base address */
58#define AD_DMA_ADCCA 0x54 /* ADC current address */
59#define AD_DMA_ADCBC 0x58 /* ADC base count */
60#define AD_DMA_ADCCC 0x5c /* ADC current count */
61
62#define AD_DMA_SYNBA 0x60 /* synth base address */
63#define AD_DMA_SYNCA 0x64 /* synth current address */
64#define AD_DMA_SYNBC 0x68 /* synth base count */
65#define AD_DMA_SYNCC 0x6c /* synth current count */
66
67#define AD_DMA_WAVBA 0x70 /* wave base address */
68#define AD_DMA_WAVCA 0x74 /* wave current address */
69#define AD_DMA_WAVBC 0x78 /* wave base count */
70#define AD_DMA_WAVCC 0x7c /* wave current count */
71
72#define AD_DMA_RESIC 0x80 /* RES dma interrupt current byte count */
73#define AD_DMA_RESIB 0x84 /* RES dma interrupt base byte count */
74
75#define AD_DMA_ADCIC 0x88 /* ADC dma interrupt current byte count */
76#define AD_DMA_ADCIB 0x8c /* ADC dma interrupt base byte count */
77
78#define AD_DMA_SYNIC 0x90 /* synth dma interrupt current byte count */
79#define AD_DMA_SYNIB 0x94 /* synth dma interrupt base byte count */
80
81#define AD_DMA_WAVIC 0x98 /* wave dma interrupt current byte count */
82#define AD_DMA_WAVIB 0x9c /* wave dma interrupt base byte count */
83
84#define AD_DMA_ICC 0xffffff /* current byte count mask */
85#define AD_DMA_IBC 0xffffff /* base byte count mask */
86/* bits 24 -> 31 reserved */
87
88/* 4 bytes pad */
89#define AD_DMA_ADC 0xa8 /* ADC dma control and status */
90#define AD_DMA_SYNTH 0xb0 /* Synth dma control and status */
91#define AD_DMA_WAV 0xb8 /* wave dma control and status */
92#define AD_DMA_RES 0xa0 /* Resample dma control and status */
93
94#define AD_DMA_SGDE 0x0001 /* SGD mode enable */
95#define AD_DMA_LOOP 0x0002 /* loop enable */
96#define AD_DMA_IM 0x000c /* interrupt mode mask */
97#define AD_DMA_IM_DIS (~AD_DMA_IM) /* disable */
98#define AD_DMA_IM_CNT 0x0004 /* interrupt on count */
99#define AD_DMA_IM_SGD 0x0008 /* interrupt on SGD flag */
100#define AD_DMA_IM_EOL 0x000c /* interrupt on End of Linked List */
101#define AD_DMA_SGDS 0x0030 /* SGD status */
102#define AD_DMA_SFLG 0x0040 /* SGD flag */
103#define AD_DMA_EOL 0x0080 /* SGD end of list */
104/* bits 8 -> 15 reserved */
105
106#define AD_DMA_DISR 0xc0 /* dma interrupt status */
107#define AD_DMA_DISR_RESI 0x000001 /* resampler channel interrupt */
108#define AD_DMA_DISR_ADCI 0x000002 /* ADC channel interrupt */
109#define AD_DMA_DISR_SYNI 0x000004 /* synthesis channel interrupt */
110#define AD_DMA_DISR_WAVI 0x000008 /* wave channel interrupt */
111/* bits 4, 5 reserved */
112#define AD_DMA_DISR_SEPS 0x000040 /* serial eeprom status */
113/* bits 7 -> 13 reserved */
114#define AD_DMA_DISR_PMAI 0x004000 /* pci master abort interrupt */
115#define AD_DMA_DISR_PTAI 0x008000 /* pci target abort interrupt */
116#define AD_DMA_DISR_PTAE 0x010000 /* pci target abort interrupt enable */
117#define AD_DMA_DISR_PMAE 0x020000 /* pci master abort interrupt enable */
118/* bits 19 -> 31 reserved */
119
120/* interrupt mask */
121#define AD_INTR_MASK (AD_DMA_DISR_RESI|AD_DMA_DISR_ADCI| \
122 AD_DMA_DISR_WAVI|AD_DMA_DISR_SYNI| \
123 AD_DMA_DISR_PMAI|AD_DMA_DISR_PTAI)
124
125#define AD_DMA_CHSS 0xc4 /* dma channel stop status */
126#define AD_DMA_CHSS_RESS 0x000001 /* resampler channel stopped */
127#define AD_DMA_CHSS_ADCS 0x000002 /* ADC channel stopped */
128#define AD_DMA_CHSS_SYNS 0x000004 /* synthesis channel stopped */
129#define AD_DMA_CHSS_WAVS 0x000008 /* wave channel stopped */
130
131#define AD_GPIO_IPC 0xc8 /* gpio port control */
132#define AD_GPIO_OP 0xca /* gpio output port status */
133#define AD_GPIO_IP 0xcc /* gpio input port status */
134
135#define AD_AC97_BASE 0x100 /* ac97 base register */
136
137#define AD_AC97_RESET 0x100 /* reset */
138
139#define AD_AC97_PWR_CTL 0x126 /* == AC97_POWERDOWN */
140#define AD_AC97_PWR_ADC 0x0001 /* ADC ready status */
141#define AD_AC97_PWR_DAC 0x0002 /* DAC ready status */
142#define AD_AC97_PWR_PR0 0x0100 /* PR0 (ADC) powerdown */
143#define AD_AC97_PWR_PR1 0x0200 /* PR1 (DAC) powerdown */
144
145#define AD_MISC_CTL 0x176 /* misc control */
146#define AD_MISC_CTL_DACZ 0x8000 /* set for zero fill, unset for repeat */
147#define AD_MISC_CTL_ARSR 0x0001 /* set for SR1, unset for SR0 */
148#define AD_MISC_CTL_ALSR 0x0100
149#define AD_MISC_CTL_DLSR 0x0400
150#define AD_MISC_CTL_DRSR 0x0004
151
152#define AD_AC97_SR0 0x178 /* sample rate 0, 0xbb80 == 48K */
153#define AD_AC97_SR0_48K 0xbb80 /* 48KHz */
154#define AD_AC97_SR1 0x17a /* sample rate 1 */
155
156#define AD_AC97_ACIC 0x180 /* ac97 codec interface control */
157#define AD_AC97_ACIC_ACIE 0x0001 /* analog codec interface enable */
158#define AD_AC97_ACIC_ACRD 0x0002 /* analog codec reset disable */
159#define AD_AC97_ACIC_ASOE 0x0004 /* audio stream output enable */
160#define AD_AC97_ACIC_VSRM 0x0008 /* variable sample rate mode */
161#define AD_AC97_ACIC_FSDH 0x0100 /* force SDATA_OUT high */
162#define AD_AC97_ACIC_FSYH 0x0200 /* force sync high */
163#define AD_AC97_ACIC_ACRDY 0x8000 /* analog codec ready status */
164/* bits 10 -> 14 reserved */
165
166
167#define AD_DS_MEMSIZE 512
168#define AD_OPL_MEMSIZE 16
169#define AD_MIDI_MEMSIZE 16
170
171#define AD_WAV_STATE 0
172#define AD_ADC_STATE 1
173#define AD_MAX_STATES 2
174
175#define AD_CHAN_WAV 0x0001
176#define AD_CHAN_ADC 0x0002
177#define AD_CHAN_RES 0x0004
178#define AD_CHAN_SYN 0x0008
179
180
181/* The chip would support 4 GB buffers and 16 MB periods,
182 * but let's not overdo it ... */
183#define BUFFER_BYTES_MAX (256 * 1024)
184#define PERIOD_BYTES_MIN 32
185#define PERIOD_BYTES_MAX (BUFFER_BYTES_MAX / 2)
186#define PERIODS_MIN 2
187#define PERIODS_MAX (BUFFER_BYTES_MAX / PERIOD_BYTES_MIN)
188
189#endif /* __AD1889_H__ */
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index 4943299cf137..d683f7736a63 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -78,15 +78,7 @@ MODULE_PARM_DESC(spdif, "Support SPDIF I/O");
78 * Constants definition 78 * Constants definition
79 */ 79 */
80 80
81#ifndef PCI_VENDOR_ID_ALI 81#define DEVICE_ID_ALI5451 ((PCI_VENDOR_ID_AL<<16)|PCI_DEVICE_ID_AL_M5451)
82#define PCI_VENDOR_ID_ALI 0x10b9
83#endif
84
85#ifndef PCI_DEVICE_ID_ALI_5451
86#define PCI_DEVICE_ID_ALI_5451 0x5451
87#endif
88
89#define DEVICE_ID_ALI5451 ((PCI_VENDOR_ID_ALI<<16)|PCI_DEVICE_ID_ALI_5451)
90 82
91 83
92#define ALI_CHANNELS 32 84#define ALI_CHANNELS 32
@@ -326,13 +318,12 @@ static void ali_read_regs(ali_t *codec, int channel)
326static void ali_read_cfg(unsigned int vendor, unsigned deviceid) 318static void ali_read_cfg(unsigned int vendor, unsigned deviceid)
327{ 319{
328 unsigned int dwVal; 320 unsigned int dwVal;
329 struct pci_dev *pci_dev = NULL; 321 struct pci_dev *pci_dev;
330 int i,j; 322 int i,j;
331 323
332 324 pci_dev = pci_get_device(vendor, deviceid, NULL);
333 pci_dev = pci_find_device(vendor, deviceid, pci_dev); 325 if (pci_dev == NULL)
334 if (pci_dev == NULL) 326 return ;
335 return ;
336 327
337 printk("\nM%x PCI CFG\n", deviceid); 328 printk("\nM%x PCI CFG\n", deviceid);
338 printk(" "); 329 printk(" ");
@@ -349,6 +340,7 @@ static void ali_read_cfg(unsigned int vendor, unsigned deviceid)
349 } 340 }
350 printk("\n"); 341 printk("\n");
351 } 342 }
343 pci_dev_put(pci_dev);
352 } 344 }
353static void ali_read_ac97regs(ali_t *codec, int secondary) 345static void ali_read_ac97regs(ali_t *codec, int secondary)
354{ 346{
@@ -2116,6 +2108,8 @@ static int snd_ali_free(ali_t * codec)
2116#ifdef CONFIG_PM 2108#ifdef CONFIG_PM
2117 kfree(codec->image); 2109 kfree(codec->image);
2118#endif 2110#endif
2111 pci_dev_put(codec->pci_m1533);
2112 pci_dev_put(codec->pci_m7101);
2119 kfree(codec); 2113 kfree(codec);
2120 return 0; 2114 return 0;
2121} 2115}
@@ -2305,7 +2299,7 @@ static int __devinit snd_ali_create(snd_card_t * card,
2305 codec->chregs.data.ainten = 0x00; 2299 codec->chregs.data.ainten = 0x00;
2306 2300
2307 /* M1533: southbridge */ 2301 /* M1533: southbridge */
2308 pci_dev = pci_find_device(0x10b9, 0x1533, NULL); 2302 pci_dev = pci_get_device(0x10b9, 0x1533, NULL);
2309 codec->pci_m1533 = pci_dev; 2303 codec->pci_m1533 = pci_dev;
2310 if (! codec->pci_m1533) { 2304 if (! codec->pci_m1533) {
2311 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); 2305 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n");
@@ -2313,7 +2307,7 @@ static int __devinit snd_ali_create(snd_card_t * card,
2313 return -ENODEV; 2307 return -ENODEV;
2314 } 2308 }
2315 /* M7101: power management */ 2309 /* M7101: power management */
2316 pci_dev = pci_find_device(0x10b9, 0x7101, NULL); 2310 pci_dev = pci_get_device(0x10b9, 0x7101, NULL);
2317 codec->pci_m7101 = pci_dev; 2311 codec->pci_m7101 = pci_dev;
2318 if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { 2312 if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) {
2319 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); 2313 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n");
@@ -2417,6 +2411,7 @@ static void __devexit snd_ali_remove(struct pci_dev *pci)
2417 2411
2418static struct pci_driver driver = { 2412static struct pci_driver driver = {
2419 .name = "ALI 5451", 2413 .name = "ALI 5451",
2414 .owner = THIS_MODULE,
2420 .id_table = snd_ali_ids, 2415 .id_table = snd_ali_ids,
2421 .probe = snd_ali_probe, 2416 .probe = snd_ali_probe,
2422 .remove = __devexit_p(snd_ali_remove), 2417 .remove = __devexit_p(snd_ali_remove),
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index ca28b229c704..196ec1c61bb4 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -770,6 +770,7 @@ static void __devexit snd_card_als4000_remove(struct pci_dev *pci)
770 770
771static struct pci_driver driver = { 771static struct pci_driver driver = {
772 .name = "ALS4000", 772 .name = "ALS4000",
773 .owner = THIS_MODULE,
773 .id_table = snd_als4000_ids, 774 .id_table = snd_als4000_ids,
774 .probe = snd_card_als4000_probe, 775 .probe = snd_card_als4000_probe,
775 .remove = __devexit_p(snd_card_als4000_remove), 776 .remove = __devexit_p(snd_card_als4000_remove),
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 188df085b7ee..241eacf1e652 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1453,6 +1453,7 @@ static int snd_atiixp_resume(snd_card_t *card)
1453 atiixp_dma_t *dma = &chip->dmas[i]; 1453 atiixp_dma_t *dma = &chip->dmas[i];
1454 if (dma->substream && dma->suspended) { 1454 if (dma->substream && dma->suspended) {
1455 dma->ops->enable_dma(chip, 1); 1455 dma->ops->enable_dma(chip, 1);
1456 dma->substream->ops->prepare(dma->substream);
1456 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN, 1457 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN,
1457 chip->remap_addr + dma->ops->llp_offset); 1458 chip->remap_addr + dma->ops->llp_offset);
1458 writel(dma->saved_curptr, chip->remap_addr + dma->ops->dt_cur); 1459 writel(dma->saved_curptr, chip->remap_addr + dma->ops->dt_cur);
@@ -1530,7 +1531,7 @@ static int __devinit snd_atiixp_create(snd_card_t *card,
1530 if ((err = pci_enable_device(pci)) < 0) 1531 if ((err = pci_enable_device(pci)) < 0)
1531 return err; 1532 return err;
1532 1533
1533 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1534 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1534 if (chip == NULL) { 1535 if (chip == NULL) {
1535 pci_disable_device(pci); 1536 pci_disable_device(pci);
1536 return -ENOMEM; 1537 return -ENOMEM;
@@ -1644,6 +1645,7 @@ static void __devexit snd_atiixp_remove(struct pci_dev *pci)
1644 1645
1645static struct pci_driver driver = { 1646static struct pci_driver driver = {
1646 .name = "ATI IXP AC97 controller", 1647 .name = "ATI IXP AC97 controller",
1648 .owner = THIS_MODULE,
1647 .id_table = snd_atiixp_ids, 1649 .id_table = snd_atiixp_ids,
1648 .probe = snd_atiixp_probe, 1650 .probe = snd_atiixp_probe,
1649 .remove = __devexit_p(snd_atiixp_remove), 1651 .remove = __devexit_p(snd_atiixp_remove),
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 8d2002951bd7..8a59598167f9 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1208,7 +1208,7 @@ static int __devinit snd_atiixp_create(snd_card_t *card,
1208 if ((err = pci_enable_device(pci)) < 0) 1208 if ((err = pci_enable_device(pci)) < 0)
1209 return err; 1209 return err;
1210 1210
1211 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1211 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1212 if (chip == NULL) { 1212 if (chip == NULL) {
1213 pci_disable_device(pci); 1213 pci_disable_device(pci);
1214 return -ENOMEM; 1214 return -ENOMEM;
@@ -1318,6 +1318,7 @@ static void __devexit snd_atiixp_remove(struct pci_dev *pci)
1318 1318
1319static struct pci_driver driver = { 1319static struct pci_driver driver = {
1320 .name = "ATI IXP MC97 controller", 1320 .name = "ATI IXP MC97 controller",
1321 .owner = THIS_MODULE,
1321 .id_table = snd_atiixp_ids, 1322 .id_table = snd_atiixp_ids,
1322 .probe = snd_atiixp_probe, 1323 .probe = snd_atiixp_probe,
1323 .remove = __devexit_p(snd_atiixp_remove), 1324 .remove = __devexit_p(snd_atiixp_remove),
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index f6236c63aaaa..04b695d6fd48 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -79,19 +79,21 @@ static void vortex_fix_agp_bridge(struct pci_dev *via)
79 79
80static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix) 80static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix)
81{ 81{
82 struct pci_dev *via; 82 struct pci_dev *via = NULL;
83 83
84 /* autodetect if workarounds are required */ 84 /* autodetect if workarounds are required */
85 if (fix == 255) { 85 if (fix == 255) {
86 /* VIA KT133 */ 86 /* VIA KT133 */
87 via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8365_1, NULL); 87 via = pci_get_device(PCI_VENDOR_ID_VIA,
88 PCI_DEVICE_ID_VIA_8365_1, NULL);
88 /* VIA Apollo */ 89 /* VIA Apollo */
89 if (via == NULL) { 90 if (via == NULL) {
90 via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C598_1, NULL); 91 via = pci_get_device(PCI_VENDOR_ID_VIA,
91 } 92 PCI_DEVICE_ID_VIA_82C598_1, NULL);
92 /* AMD Irongate */ 93 /* AMD Irongate */
93 if (via == NULL) { 94 if (via == NULL)
94 via = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL); 95 via = pci_get_device(PCI_VENDOR_ID_AMD,
96 PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL);
95 } 97 }
96 if (via) { 98 if (via) {
97 printk(KERN_INFO CARD_NAME ": Activating latency workaround...\n"); 99 printk(KERN_INFO CARD_NAME ": Activating latency workaround...\n");
@@ -101,13 +103,17 @@ static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix)
101 } else { 103 } else {
102 if (fix & 0x1) 104 if (fix & 0x1)
103 vortex_fix_latency(vortex); 105 vortex_fix_latency(vortex);
104 if ((fix & 0x2) && (via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8365_1, NULL))) 106 if ((fix & 0x2) && (via = pci_get_device(PCI_VENDOR_ID_VIA,
107 PCI_DEVICE_ID_VIA_8365_1, NULL)))
105 vortex_fix_agp_bridge(via); 108 vortex_fix_agp_bridge(via);
106 if ((fix & 0x4) && (via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C598_1, NULL))) 109 if ((fix & 0x4) && (via = pci_get_device(PCI_VENDOR_ID_VIA,
110 PCI_DEVICE_ID_VIA_82C598_1, NULL)))
107 vortex_fix_agp_bridge(via); 111 vortex_fix_agp_bridge(via);
108 if ((fix & 0x8) && (via = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL))) 112 if ((fix & 0x8) && (via = pci_get_device(PCI_VENDOR_ID_AMD,
113 PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL)))
109 vortex_fix_agp_bridge(via); 114 vortex_fix_agp_bridge(via);
110 } 115 }
116 pci_dev_put(via);
111} 117}
112 118
113// component-destructor 119// component-destructor
@@ -150,7 +156,7 @@ snd_vortex_create(snd_card_t * card, struct pci_dev *pci, vortex_t ** rchip)
150 } 156 }
151 pci_set_dma_mask(pci, VORTEX_DMA_MASK); 157 pci_set_dma_mask(pci, VORTEX_DMA_MASK);
152 158
153 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 159 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
154 if (chip == NULL) 160 if (chip == NULL)
155 return -ENOMEM; 161 return -ENOMEM;
156 162
@@ -367,6 +373,7 @@ static void __devexit snd_vortex_remove(struct pci_dev *pci)
367// pci_driver definition 373// pci_driver definition
368static struct pci_driver driver = { 374static struct pci_driver driver = {
369 .name = CARD_NAME_SHORT, 375 .name = CARD_NAME_SHORT,
376 .owner = THIS_MODULE,
370 .id_table = snd_vortex_ids, 377 .id_table = snd_vortex_ids,
371 .probe = snd_vortex_probe, 378 .probe = snd_vortex_probe,
372 .remove = __devexit_p(snd_vortex_remove), 379 .remove = __devexit_p(snd_vortex_remove),
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 72bba7b2d983..d5261bdec583 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -1345,7 +1345,7 @@ static int __devinit snd_azf3328_create(snd_card_t * card,
1345 if ((err = pci_enable_device(pci)) < 0) 1345 if ((err = pci_enable_device(pci)) < 0)
1346 return err; 1346 return err;
1347 1347
1348 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1348 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1349 if (chip == NULL) { 1349 if (chip == NULL) {
1350 pci_disable_device(pci); 1350 pci_disable_device(pci);
1351 return -ENOMEM; 1351 return -ENOMEM;
@@ -1511,6 +1511,7 @@ static void __devexit snd_azf3328_remove(struct pci_dev *pci)
1511 1511
1512static struct pci_driver driver = { 1512static struct pci_driver driver = {
1513 .name = "AZF3328", 1513 .name = "AZF3328",
1514 .owner = THIS_MODULE,
1514 .id_table = snd_azf3328_ids, 1515 .id_table = snd_azf3328_ids,
1515 .probe = snd_azf3328_probe, 1516 .probe = snd_azf3328_probe,
1516 .remove = __devexit_p(snd_azf3328_remove), 1517 .remove = __devexit_p(snd_azf3328_remove),
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index c5557eaf3e2e..2236c958aec0 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -59,16 +59,6 @@ module_param(load_all, bool, 0444);
59MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards"); 59MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards");
60 60
61 61
62#ifndef PCI_VENDOR_ID_BROOKTREE
63#define PCI_VENDOR_ID_BROOKTREE 0x109e
64#endif
65#ifndef PCI_DEVICE_ID_BROOKTREE_878
66#define PCI_DEVICE_ID_BROOKTREE_878 0x0878
67#endif
68#ifndef PCI_DEVICE_ID_BROOKTREE_879
69#define PCI_DEVICE_ID_BROOKTREE_879 0x0879
70#endif
71
72/* register offsets */ 62/* register offsets */
73#define REG_INT_STAT 0x100 /* interrupt status */ 63#define REG_INT_STAT 0x100 /* interrupt status */
74#define REG_INT_MASK 0x104 /* interrupt mask */ 64#define REG_INT_MASK 0x104 /* interrupt mask */
@@ -720,7 +710,7 @@ static int __devinit snd_bt87x_create(snd_card_t *card,
720 if (err < 0) 710 if (err < 0)
721 return err; 711 return err;
722 712
723 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 713 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
724 if (!chip) { 714 if (!chip) {
725 pci_disable_device(pci); 715 pci_disable_device(pci);
726 return -ENOMEM; 716 return -ENOMEM;
@@ -911,6 +901,7 @@ static struct pci_device_id snd_bt87x_default_ids[] = {
911 901
912static struct pci_driver driver = { 902static struct pci_driver driver = {
913 .name = "Bt87x", 903 .name = "Bt87x",
904 .owner = THIS_MODULE,
914 .id_table = snd_bt87x_ids, 905 .id_table = snd_bt87x_ids,
915 .probe = snd_bt87x_probe, 906 .probe = snd_bt87x_probe,
916 .remove = __devexit_p(snd_bt87x_remove), 907 .remove = __devexit_p(snd_bt87x_remove),
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 7e27bfc37439..ba07960921d8 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -352,7 +352,7 @@ static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream,
352 snd_pcm_runtime_t *runtime = substream->runtime; 352 snd_pcm_runtime_t *runtime = substream->runtime;
353 int err; 353 int err;
354 354
355 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 355 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
356 356
357 if (epcm == NULL) 357 if (epcm == NULL)
358 return -ENOMEM; 358 return -ENOMEM;
@@ -419,7 +419,7 @@ static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, i
419 snd_pcm_runtime_t *runtime = substream->runtime; 419 snd_pcm_runtime_t *runtime = substream->runtime;
420 int err; 420 int err;
421 421
422 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 422 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
423 if (epcm == NULL) { 423 if (epcm == NULL) {
424 snd_printk("open_capture_channel: failed epcm alloc\n"); 424 snd_printk("open_capture_channel: failed epcm alloc\n");
425 return -ENOMEM; 425 return -ENOMEM;
@@ -1144,7 +1144,7 @@ static int __devinit snd_ca0106_create(snd_card_t *card,
1144 return -ENXIO; 1144 return -ENXIO;
1145 } 1145 }
1146 1146
1147 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1147 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1148 if (chip == NULL) { 1148 if (chip == NULL) {
1149 pci_disable_device(pci); 1149 pci_disable_device(pci);
1150 return -ENOMEM; 1150 return -ENOMEM;
@@ -1390,6 +1390,7 @@ MODULE_DEVICE_TABLE(pci, snd_ca0106_ids);
1390// pci_driver definition 1390// pci_driver definition
1391static struct pci_driver driver = { 1391static struct pci_driver driver = {
1392 .name = "CA0106", 1392 .name = "CA0106",
1393 .owner = THIS_MODULE,
1393 .id_table = snd_ca0106_ids, 1394 .id_table = snd_ca0106_ids,
1394 .probe = snd_ca0106_probe, 1395 .probe = snd_ca0106_probe,
1395 .remove = __devexit_p(snd_ca0106_remove), 1396 .remove = __devexit_p(snd_ca0106_remove),
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index b6b8882ce704..c10e4a54301b 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -482,7 +482,7 @@ static int snd_ca0106_volume_put_feedback(snd_kcontrol_t * kcontrol,
482static snd_kcontrol_new_t snd_ca0106_volume_control_analog_front = 482static snd_kcontrol_new_t snd_ca0106_volume_control_analog_front =
483{ 483{
484 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 484 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
485 .name = "Analog Front Volume", 485 .name = "Analog Front Playback Volume",
486 .info = snd_ca0106_volume_info, 486 .info = snd_ca0106_volume_info,
487 .get = snd_ca0106_volume_get_analog_front, 487 .get = snd_ca0106_volume_get_analog_front,
488 .put = snd_ca0106_volume_put_analog_front 488 .put = snd_ca0106_volume_put_analog_front
@@ -490,7 +490,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_front =
490static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe = 490static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe =
491{ 491{
492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
493 .name = "Analog Center/LFE Volume", 493 .name = "Analog Center/LFE Playback Volume",
494 .info = snd_ca0106_volume_info, 494 .info = snd_ca0106_volume_info,
495 .get = snd_ca0106_volume_get_analog_center_lfe, 495 .get = snd_ca0106_volume_get_analog_center_lfe,
496 .put = snd_ca0106_volume_put_analog_center_lfe 496 .put = snd_ca0106_volume_put_analog_center_lfe
@@ -498,7 +498,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe =
498static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown = 498static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown =
499{ 499{
500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
501 .name = "Analog Side Volume", 501 .name = "Analog Side Playback Volume",
502 .info = snd_ca0106_volume_info, 502 .info = snd_ca0106_volume_info,
503 .get = snd_ca0106_volume_get_analog_unknown, 503 .get = snd_ca0106_volume_get_analog_unknown,
504 .put = snd_ca0106_volume_put_analog_unknown 504 .put = snd_ca0106_volume_put_analog_unknown
@@ -506,7 +506,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown =
506static snd_kcontrol_new_t snd_ca0106_volume_control_analog_rear = 506static snd_kcontrol_new_t snd_ca0106_volume_control_analog_rear =
507{ 507{
508 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 508 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
509 .name = "Analog Rear Volume", 509 .name = "Analog Rear Playback Volume",
510 .info = snd_ca0106_volume_info, 510 .info = snd_ca0106_volume_info,
511 .get = snd_ca0106_volume_get_analog_rear, 511 .get = snd_ca0106_volume_get_analog_rear,
512 .put = snd_ca0106_volume_put_analog_rear 512 .put = snd_ca0106_volume_put_analog_rear
@@ -514,7 +514,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_rear =
514static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_front = 514static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_front =
515{ 515{
516 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 516 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
517 .name = "SPDIF Front Volume", 517 .name = "SPDIF Front Playback Volume",
518 .info = snd_ca0106_volume_info, 518 .info = snd_ca0106_volume_info,
519 .get = snd_ca0106_volume_get_spdif_front, 519 .get = snd_ca0106_volume_get_spdif_front,
520 .put = snd_ca0106_volume_put_spdif_front 520 .put = snd_ca0106_volume_put_spdif_front
@@ -522,7 +522,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_front =
522static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_center_lfe = 522static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_center_lfe =
523{ 523{
524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
525 .name = "SPDIF Center/LFE Volume", 525 .name = "SPDIF Center/LFE Playback Volume",
526 .info = snd_ca0106_volume_info, 526 .info = snd_ca0106_volume_info,
527 .get = snd_ca0106_volume_get_spdif_center_lfe, 527 .get = snd_ca0106_volume_get_spdif_center_lfe,
528 .put = snd_ca0106_volume_put_spdif_center_lfe 528 .put = snd_ca0106_volume_put_spdif_center_lfe
@@ -530,7 +530,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_center_lfe =
530static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_unknown = 530static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_unknown =
531{ 531{
532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
533 .name = "SPDIF Unknown Volume", 533 .name = "SPDIF Unknown Playback Volume",
534 .info = snd_ca0106_volume_info, 534 .info = snd_ca0106_volume_info,
535 .get = snd_ca0106_volume_get_spdif_unknown, 535 .get = snd_ca0106_volume_get_spdif_unknown,
536 .put = snd_ca0106_volume_put_spdif_unknown 536 .put = snd_ca0106_volume_put_spdif_unknown
@@ -538,7 +538,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_unknown =
538static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_rear = 538static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_rear =
539{ 539{
540 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 540 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
541 .name = "SPDIF Rear Volume", 541 .name = "SPDIF Rear Playback Volume",
542 .info = snd_ca0106_volume_info, 542 .info = snd_ca0106_volume_info,
543 .get = snd_ca0106_volume_get_spdif_rear, 543 .get = snd_ca0106_volume_get_spdif_rear,
544 .put = snd_ca0106_volume_put_spdif_rear 544 .put = snd_ca0106_volume_put_spdif_rear
@@ -547,7 +547,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_rear =
547static snd_kcontrol_new_t snd_ca0106_volume_control_feedback = 547static snd_kcontrol_new_t snd_ca0106_volume_control_feedback =
548{ 548{
549 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 549 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
550 .name = "CAPTURE feedback into PLAYBACK", 550 .name = "CAPTURE feedback Playback Volume",
551 .info = snd_ca0106_volume_info, 551 .info = snd_ca0106_volume_info,
552 .get = snd_ca0106_volume_get_feedback, 552 .get = snd_ca0106_volume_get_feedback,
553 .put = snd_ca0106_volume_put_feedback 553 .put = snd_ca0106_volume_put_feedback
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index b098b51099c2..1eb3315d136d 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -79,13 +79,6 @@ module_param_array(joystick_port, int, NULL, 0444);
79MODULE_PARM_DESC(joystick_port, "Joystick port address."); 79MODULE_PARM_DESC(joystick_port, "Joystick port address.");
80#endif 80#endif
81 81
82#ifndef PCI_DEVICE_ID_CMEDIA_CM8738
83#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111
84#endif
85#ifndef PCI_DEVICE_ID_CMEDIA_CM8738B
86#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112
87#endif
88
89/* 82/*
90 * CM8x38 registers definition 83 * CM8x38 registers definition
91 */ 84 */
@@ -348,25 +341,6 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address.");
348 341
349 342
350/* 343/*
351 * pci ids
352 */
353#ifndef PCI_VENDOR_ID_CMEDIA
354#define PCI_VENDOR_ID_CMEDIA 0x13F6
355#endif
356#ifndef PCI_DEVICE_ID_CMEDIA_CM8338A
357#define PCI_DEVICE_ID_CMEDIA_CM8338A 0x0100
358#endif
359#ifndef PCI_DEVICE_ID_CMEDIA_CM8338B
360#define PCI_DEVICE_ID_CMEDIA_CM8338B 0x0101
361#endif
362#ifndef PCI_DEVICE_ID_CMEDIA_CM8738
363#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111
364#endif
365#ifndef PCI_DEVICE_ID_CMEDIA_CM8738B
366#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112
367#endif
368
369/*
370 * channels for playback / capture 344 * channels for playback / capture
371 */ 345 */
372#define CM_CH_PLAY 0 346#define CM_CH_PLAY 0
@@ -2801,7 +2775,7 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci,
2801 if ((err = pci_enable_device(pci)) < 0) 2775 if ((err = pci_enable_device(pci)) < 0)
2802 return err; 2776 return err;
2803 2777
2804 cm = kcalloc(1, sizeof(*cm), GFP_KERNEL); 2778 cm = kzalloc(sizeof(*cm), GFP_KERNEL);
2805 if (cm == NULL) { 2779 if (cm == NULL) {
2806 pci_disable_device(pci); 2780 pci_disable_device(pci);
2807 return -ENOMEM; 2781 return -ENOMEM;
@@ -3063,6 +3037,7 @@ static void __devexit snd_cmipci_remove(struct pci_dev *pci)
3063 3037
3064static struct pci_driver driver = { 3038static struct pci_driver driver = {
3065 .name = "C-Media PCI", 3039 .name = "C-Media PCI",
3040 .owner = THIS_MODULE,
3066 .id_table = snd_cmipci_ids, 3041 .id_table = snd_cmipci_ids,
3067 .probe = snd_cmipci_probe, 3042 .probe = snd_cmipci_probe,
3068 .remove = __devexit_p(snd_cmipci_remove), 3043 .remove = __devexit_p(snd_cmipci_remove),
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index c7a370d4f923..dc87e0144b5a 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -57,17 +57,6 @@ module_param_array(dual_codec, bool, NULL, 0444);
57MODULE_PARM_DESC(dual_codec, "Secondary Codec ID (0 = disabled)."); 57MODULE_PARM_DESC(dual_codec, "Secondary Codec ID (0 = disabled).");
58 58
59/* 59/*
60 *
61 */
62
63#ifndef PCI_VENDOR_ID_CIRRUS
64#define PCI_VENDOR_ID_CIRRUS 0x1013
65#endif
66#ifndef PCI_DEVICE_ID_CIRRUS_4281
67#define PCI_DEVICE_ID_CIRRUS_4281 0x6005
68#endif
69
70/*
71 * Direct registers 60 * Direct registers
72 */ 61 */
73 62
@@ -1394,7 +1383,7 @@ static int __devinit snd_cs4281_create(snd_card_t * card,
1394 *rchip = NULL; 1383 *rchip = NULL;
1395 if ((err = pci_enable_device(pci)) < 0) 1384 if ((err = pci_enable_device(pci)) < 0)
1396 return err; 1385 return err;
1397 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1386 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1398 if (chip == NULL) { 1387 if (chip == NULL) {
1399 pci_disable_device(pci); 1388 pci_disable_device(pci);
1400 return -ENOMEM; 1389 return -ENOMEM;
@@ -2119,6 +2108,7 @@ static int cs4281_resume(snd_card_t *card)
2119 2108
2120static struct pci_driver driver = { 2109static struct pci_driver driver = {
2121 .name = "CS4281", 2110 .name = "CS4281",
2111 .owner = THIS_MODULE,
2122 .id_table = snd_cs4281_ids, 2112 .id_table = snd_cs4281_ids,
2123 .probe = snd_cs4281_probe, 2113 .probe = snd_cs4281_probe,
2124 .remove = __devexit_p(snd_cs4281_remove), 2114 .remove = __devexit_p(snd_cs4281_remove),
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c
index b9fff4ee6f9d..32b4f8465cef 100644
--- a/sound/pci/cs46xx/cs46xx.c
+++ b/sound/pci/cs46xx/cs46xx.c
@@ -163,6 +163,7 @@ static void __devexit snd_card_cs46xx_remove(struct pci_dev *pci)
163 163
164static struct pci_driver driver = { 164static struct pci_driver driver = {
165 .name = "Sound Fusion CS46xx", 165 .name = "Sound Fusion CS46xx",
166 .owner = THIS_MODULE,
166 .id_table = snd_cs46xx_ids, 167 .id_table = snd_cs46xx_ids,
167 .probe = snd_card_cs46xx_probe, 168 .probe = snd_card_cs46xx_probe,
168 .remove = __devexit_p(snd_card_cs46xx_remove), 169 .remove = __devexit_p(snd_card_cs46xx_remove),
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 4b052158ee33..6e3855b8b33d 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -1304,7 +1304,7 @@ static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pc
1304 cs46xx_pcm_t * cpcm; 1304 cs46xx_pcm_t * cpcm;
1305 snd_pcm_runtime_t *runtime = substream->runtime; 1305 snd_pcm_runtime_t *runtime = substream->runtime;
1306 1306
1307 cpcm = kcalloc(1, sizeof(*cpcm), GFP_KERNEL); 1307 cpcm = kzalloc(sizeof(*cpcm), GFP_KERNEL);
1308 if (cpcm == NULL) 1308 if (cpcm == NULL)
1309 return -ENOMEM; 1309 return -ENOMEM;
1310 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 1310 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
@@ -3525,17 +3525,6 @@ static void amp_voyetra_4294(cs46xx_t *chip, int change)
3525 3525
3526 3526
3527/* 3527/*
3528 * piix4 pci ids
3529 */
3530#ifndef PCI_VENDOR_ID_INTEL
3531#define PCI_VENDOR_ID_INTEL 0x8086
3532#endif /* PCI_VENDOR_ID_INTEL */
3533
3534#ifndef PCI_DEVICE_ID_INTEL_82371AB_3
3535#define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113
3536#endif /* PCI_DEVICE_ID_INTEL_82371AB_3 */
3537
3538/*
3539 * Handle the CLKRUN on a thinkpad. We must disable CLKRUN support 3528 * Handle the CLKRUN on a thinkpad. We must disable CLKRUN support
3540 * whenever we need to beat on the chip. 3529 * whenever we need to beat on the chip.
3541 * 3530 *
@@ -3548,7 +3537,7 @@ static void clkrun_hack(cs46xx_t *chip, int change)
3548{ 3537{
3549 u16 control, nval; 3538 u16 control, nval;
3550 3539
3551 if (chip->acpi_dev == NULL) 3540 if (!chip->acpi_port)
3552 return; 3541 return;
3553 3542
3554 chip->amplifier += change; 3543 chip->amplifier += change;
@@ -3571,15 +3560,20 @@ static void clkrun_hack(cs46xx_t *chip, int change)
3571 */ 3560 */
3572static void clkrun_init(cs46xx_t *chip) 3561static void clkrun_init(cs46xx_t *chip)
3573{ 3562{
3563 struct pci_dev *pdev;
3574 u8 pp; 3564 u8 pp;
3575 3565
3576 chip->acpi_dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL); 3566 chip->acpi_port = 0;
3577 if (chip->acpi_dev == NULL) 3567
3568 pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
3569 PCI_DEVICE_ID_INTEL_82371AB_3, NULL);
3570 if (pdev == NULL)
3578 return; /* Not a thinkpad thats for sure */ 3571 return; /* Not a thinkpad thats for sure */
3579 3572
3580 /* Find the control port */ 3573 /* Find the control port */
3581 pci_read_config_byte(chip->acpi_dev, 0x41, &pp); 3574 pci_read_config_byte(pdev, 0x41, &pp);
3582 chip->acpi_port = pp << 8; 3575 chip->acpi_port = pp << 8;
3576 pci_dev_put(pdev);
3583} 3577}
3584 3578
3585 3579
@@ -3780,7 +3774,7 @@ int __devinit snd_cs46xx_create(snd_card_t * card,
3780 if ((err = pci_enable_device(pci)) < 0) 3774 if ((err = pci_enable_device(pci)) < 0)
3781 return err; 3775 return err;
3782 3776
3783 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 3777 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
3784 if (chip == NULL) { 3778 if (chip == NULL) {
3785 pci_disable_device(pci); 3779 pci_disable_device(pci);
3786 return -ENOMEM; 3780 return -ENOMEM;
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index fc377c4b666c..b0e00f0a7c2f 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -223,6 +223,7 @@ static void __devexit snd_card_emu10k1_remove(struct pci_dev *pci)
223 223
224static struct pci_driver driver = { 224static struct pci_driver driver = {
225 .name = "EMU10K1_Audigy", 225 .name = "EMU10K1_Audigy",
226 .owner = THIS_MODULE,
226 .id_table = snd_emu10k1_ids, 227 .id_table = snd_emu10k1_ids,
227 .probe = snd_card_emu10k1_probe, 228 .probe = snd_card_emu10k1_probe,
228 .remove = __devexit_p(snd_card_emu10k1_remove), 229 .remove = __devexit_p(snd_card_emu10k1_remove),
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index e69d5b739e80..e87e8427f25f 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -754,12 +754,11 @@ static emu_chip_details_t emu_chip_details[] = {
754 .emu10k1_chip = 1, 754 .emu10k1_chip = 1,
755 .ac97_chip = 1, 755 .ac97_chip = 1,
756 .sblive51 = 1} , 756 .sblive51 = 1} ,
757 /* Tested by alsa bugtrack user "hus" 12th Sept 2005 */ 757 /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */
758 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, 758 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102,
759 .driver = "EMU10K1", .name = "SBLive! Player 5.1 [SB0060]", 759 .driver = "EMU10K1", .name = "SBLive! Platinum 5.1 [SB0060]",
760 .id = "Live", 760 .id = "Live",
761 .emu10k1_chip = 1, 761 .emu10k1_chip = 1,
762 .ac97_chip = 1,
763 .sblive51 = 1} , 762 .sblive51 = 1} ,
764 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, 763 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102,
765 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", 764 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]",
@@ -865,7 +864,7 @@ int __devinit snd_emu10k1_create(snd_card_t * card,
865 if ((err = pci_enable_device(pci)) < 0) 864 if ((err = pci_enable_device(pci)) < 0)
866 return err; 865 return err;
867 866
868 emu = kcalloc(1, sizeof(*emu), GFP_KERNEL); 867 emu = kzalloc(sizeof(*emu), GFP_KERNEL);
869 if (emu == NULL) { 868 if (emu == NULL) {
870 pci_disable_device(pci); 869 pci_disable_device(pci);
871 return -ENOMEM; 870 return -ENOMEM;
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 52c7826df440..ad15755a63c3 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -395,7 +395,7 @@ static int snd_emu10k1x_playback_open(snd_pcm_substream_t *substream)
395 if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) 395 if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0)
396 return err; 396 return err;
397 397
398 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 398 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
399 if (epcm == NULL) 399 if (epcm == NULL)
400 return -ENOMEM; 400 return -ENOMEM;
401 epcm->emu = chip; 401 epcm->emu = chip;
@@ -571,7 +571,7 @@ static int snd_emu10k1x_pcm_open_capture(snd_pcm_substream_t *substream)
571 if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) 571 if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0)
572 return err; 572 return err;
573 573
574 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 574 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
575 if (epcm == NULL) 575 if (epcm == NULL)
576 return -ENOMEM; 576 return -ENOMEM;
577 577
@@ -920,7 +920,7 @@ static int __devinit snd_emu10k1x_create(snd_card_t *card,
920 return -ENXIO; 920 return -ENXIO;
921 } 921 }
922 922
923 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 923 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
924 if (chip == NULL) { 924 if (chip == NULL) {
925 pci_disable_device(pci); 925 pci_disable_device(pci);
926 return -ENOMEM; 926 return -ENOMEM;
@@ -1615,6 +1615,7 @@ MODULE_DEVICE_TABLE(pci, snd_emu10k1x_ids);
1615// pci_driver definition 1615// pci_driver definition
1616static struct pci_driver driver = { 1616static struct pci_driver driver = {
1617 .name = "EMU10K1X", 1617 .name = "EMU10K1X",
1618 .owner = THIS_MODULE,
1618 .id_table = snd_emu10k1x_ids, 1619 .id_table = snd_emu10k1x_ids,
1619 .probe = snd_emu10k1x_probe, 1620 .probe = snd_emu10k1x_probe,
1620 .remove = __devexit_p(snd_emu10k1x_remove), 1621 .remove = __devexit_p(snd_emu10k1x_remove),
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 637c555cfdb1..646b5d972e6f 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -470,7 +470,7 @@ static void snd_emu10k1_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr
470{ 470{
471 u_int32_t *code; 471 u_int32_t *code;
472 snd_assert(*ptr < 512, return); 472 snd_assert(*ptr < 512, return);
473 code = (u_int32_t *)icode->code + (*ptr) * 2; 473 code = (u_int32_t __force *)icode->code + (*ptr) * 2;
474 set_bit(*ptr, icode->code_valid); 474 set_bit(*ptr, icode->code_valid);
475 code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff); 475 code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff);
476 code[1] = ((op & 0x0f) << 20) | ((r & 0x3ff) << 10) | (a & 0x3ff); 476 code[1] = ((op & 0x0f) << 20) | ((r & 0x3ff) << 10) | (a & 0x3ff);
@@ -485,7 +485,7 @@ static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned i
485{ 485{
486 u_int32_t *code; 486 u_int32_t *code;
487 snd_assert(*ptr < 1024, return); 487 snd_assert(*ptr < 1024, return);
488 code = (u_int32_t *)icode->code + (*ptr) * 2; 488 code = (u_int32_t __force *)icode->code + (*ptr) * 2;
489 set_bit(*ptr, icode->code_valid); 489 set_bit(*ptr, icode->code_valid);
490 code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff); 490 code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
491 code[1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff); 491 code[1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff);
@@ -1036,13 +1036,13 @@ static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu)
1036 spin_lock_init(&emu->fx8010.irq_lock); 1036 spin_lock_init(&emu->fx8010.irq_lock);
1037 INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); 1037 INIT_LIST_HEAD(&emu->fx8010.gpr_ctl);
1038 1038
1039 if ((icode = kcalloc(1, sizeof(*icode), GFP_KERNEL)) == NULL || 1039 if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL ||
1040 (icode->gpr_map = (u_int32_t __user *)kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), GFP_KERNEL)) == NULL || 1040 (icode->gpr_map = (u_int32_t __user *)kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
1041 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(*controls), GFP_KERNEL)) == NULL) { 1041 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(*controls), GFP_KERNEL)) == NULL) {
1042 err = -ENOMEM; 1042 err = -ENOMEM;
1043 goto __err; 1043 goto __err;
1044 } 1044 }
1045 gpr_map = (u32 *)icode->gpr_map; 1045 gpr_map = (u32 __force *)icode->gpr_map;
1046 1046
1047 icode->tram_data_map = icode->gpr_map + 512; 1047 icode->tram_data_map = icode->gpr_map + 512;
1048 icode->tram_addr_map = icode->tram_data_map + 256; 1048 icode->tram_addr_map = icode->tram_data_map + 256;
@@ -1431,7 +1431,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1431 __err: 1431 __err:
1432 kfree(controls); 1432 kfree(controls);
1433 if (icode != NULL) { 1433 if (icode != NULL) {
1434 kfree((void *)icode->gpr_map); 1434 kfree((void __force *)icode->gpr_map);
1435 kfree(icode); 1435 kfree(icode);
1436 } 1436 }
1437 return err; 1437 return err;
@@ -1503,15 +1503,15 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu)
1503 spin_lock_init(&emu->fx8010.irq_lock); 1503 spin_lock_init(&emu->fx8010.irq_lock);
1504 INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); 1504 INIT_LIST_HEAD(&emu->fx8010.gpr_ctl);
1505 1505
1506 if ((icode = kcalloc(1, sizeof(*icode), GFP_KERNEL)) == NULL) 1506 if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL)
1507 return -ENOMEM; 1507 return -ENOMEM;
1508 if ((icode->gpr_map = (u_int32_t __user *)kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), GFP_KERNEL)) == NULL || 1508 if ((icode->gpr_map = (u_int32_t __user *)kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
1509 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(emu10k1_fx8010_control_gpr_t), GFP_KERNEL)) == NULL || 1509 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(emu10k1_fx8010_control_gpr_t), GFP_KERNEL)) == NULL ||
1510 (ipcm = kcalloc(1, sizeof(*ipcm), GFP_KERNEL)) == NULL) { 1510 (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) {
1511 err = -ENOMEM; 1511 err = -ENOMEM;
1512 goto __err; 1512 goto __err;
1513 } 1513 }
1514 gpr_map = (u32 *)icode->gpr_map; 1514 gpr_map = (u32 __force *)icode->gpr_map;
1515 1515
1516 icode->tram_data_map = icode->gpr_map + 256; 1516 icode->tram_data_map = icode->gpr_map + 256;
1517 icode->tram_addr_map = icode->tram_data_map + 160; 1517 icode->tram_addr_map = icode->tram_data_map + 160;
@@ -2032,7 +2032,7 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu)
2032 kfree(ipcm); 2032 kfree(ipcm);
2033 kfree(controls); 2033 kfree(controls);
2034 if (icode != NULL) { 2034 if (icode != NULL) {
2035 kfree((void *)icode->gpr_map); 2035 kfree((void __force *)icode->gpr_map);
2036 kfree(icode); 2036 kfree(icode);
2037 } 2037 }
2038 return err; 2038 return err;
@@ -2217,7 +2217,7 @@ static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigne
2217 kfree(ipcm); 2217 kfree(ipcm);
2218 return res; 2218 return res;
2219 case SNDRV_EMU10K1_IOCTL_PCM_PEEK: 2219 case SNDRV_EMU10K1_IOCTL_PCM_PEEK:
2220 ipcm = kcalloc(1, sizeof(*ipcm), GFP_KERNEL); 2220 ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL);
2221 if (ipcm == NULL) 2221 if (ipcm == NULL)
2222 return -ENOMEM; 2222 return -ENOMEM;
2223 if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { 2223 if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index 9c35f6dde1b5..66ba27afe962 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -1016,7 +1016,7 @@ static int snd_emu10k1_efx_playback_open(snd_pcm_substream_t * substream)
1016 snd_pcm_runtime_t *runtime = substream->runtime; 1016 snd_pcm_runtime_t *runtime = substream->runtime;
1017 int i; 1017 int i;
1018 1018
1019 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 1019 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
1020 if (epcm == NULL) 1020 if (epcm == NULL)
1021 return -ENOMEM; 1021 return -ENOMEM;
1022 epcm->emu = emu; 1022 epcm->emu = emu;
@@ -1049,7 +1049,7 @@ static int snd_emu10k1_playback_open(snd_pcm_substream_t * substream)
1049 snd_pcm_runtime_t *runtime = substream->runtime; 1049 snd_pcm_runtime_t *runtime = substream->runtime;
1050 int i, err; 1050 int i, err;
1051 1051
1052 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 1052 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
1053 if (epcm == NULL) 1053 if (epcm == NULL)
1054 return -ENOMEM; 1054 return -ENOMEM;
1055 epcm->emu = emu; 1055 epcm->emu = emu;
@@ -1094,7 +1094,7 @@ static int snd_emu10k1_capture_open(snd_pcm_substream_t * substream)
1094 snd_pcm_runtime_t *runtime = substream->runtime; 1094 snd_pcm_runtime_t *runtime = substream->runtime;
1095 emu10k1_pcm_t *epcm; 1095 emu10k1_pcm_t *epcm;
1096 1096
1097 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 1097 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
1098 if (epcm == NULL) 1098 if (epcm == NULL)
1099 return -ENOMEM; 1099 return -ENOMEM;
1100 epcm->emu = emu; 1100 epcm->emu = emu;
@@ -1130,7 +1130,7 @@ static int snd_emu10k1_capture_mic_open(snd_pcm_substream_t * substream)
1130 emu10k1_pcm_t *epcm; 1130 emu10k1_pcm_t *epcm;
1131 snd_pcm_runtime_t *runtime = substream->runtime; 1131 snd_pcm_runtime_t *runtime = substream->runtime;
1132 1132
1133 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 1133 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
1134 if (epcm == NULL) 1134 if (epcm == NULL)
1135 return -ENOMEM; 1135 return -ENOMEM;
1136 epcm->emu = emu; 1136 epcm->emu = emu;
@@ -1170,7 +1170,7 @@ static int snd_emu10k1_capture_efx_open(snd_pcm_substream_t * substream)
1170 int nefx = emu->audigy ? 64 : 32; 1170 int nefx = emu->audigy ? 64 : 32;
1171 int idx; 1171 int idx;
1172 1172
1173 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 1173 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
1174 if (epcm == NULL) 1174 if (epcm == NULL)
1175 return -ENOMEM; 1175 return -ENOMEM;
1176 epcm->emu = emu; 1176 epcm->emu = emu;
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index a1691330d3b6..d59c7f345ad6 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -178,7 +178,7 @@ static int snd_p16v_pcm_open_playback_channel(snd_pcm_substream_t *substream, in
178 snd_pcm_runtime_t *runtime = substream->runtime; 178 snd_pcm_runtime_t *runtime = substream->runtime;
179 int err; 179 int err;
180 180
181 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 181 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
182 //snd_printk("epcm kcalloc: %p\n", epcm); 182 //snd_printk("epcm kcalloc: %p\n", epcm);
183 183
184 if (epcm == NULL) 184 if (epcm == NULL)
@@ -214,7 +214,7 @@ static int snd_p16v_pcm_open_capture_channel(snd_pcm_substream_t *substream, int
214 snd_pcm_runtime_t *runtime = substream->runtime; 214 snd_pcm_runtime_t *runtime = substream->runtime;
215 int err; 215 int err;
216 216
217 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); 217 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
218 //snd_printk("epcm kcalloc: %p\n", epcm); 218 //snd_printk("epcm kcalloc: %p\n", epcm);
219 219
220 if (epcm == NULL) 220 if (epcm == NULL)
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index f06b95f41a1d..bef9a59f46d7 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -100,13 +100,6 @@ MODULE_PARM_DESC(joystick, "Enable joystick.");
100#endif 100#endif
101#endif /* SUPPORT_JOYSTICK */ 101#endif /* SUPPORT_JOYSTICK */
102 102
103#ifndef PCI_DEVICE_ID_ENSONIQ_CT5880
104#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880
105#endif
106#ifndef PCI_DEVICE_ID_ENSONIQ_ES1371
107#define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371
108#endif
109
110/* ES1371 chip ID */ 103/* ES1371 chip ID */
111/* This is a little confusing because all ES1371 compatible chips have the 104/* This is a little confusing because all ES1371 compatible chips have the
112 same DEVICE_ID, the only thing differentiating them is the REV_ID field. 105 same DEVICE_ID, the only thing differentiating them is the REV_ID field.
@@ -1950,7 +1943,7 @@ static int __devinit snd_ensoniq_create(snd_card_t * card,
1950 *rensoniq = NULL; 1943 *rensoniq = NULL;
1951 if ((err = pci_enable_device(pci)) < 0) 1944 if ((err = pci_enable_device(pci)) < 0)
1952 return err; 1945 return err;
1953 ensoniq = kcalloc(1, sizeof(*ensoniq), GFP_KERNEL); 1946 ensoniq = kzalloc(sizeof(*ensoniq), GFP_KERNEL);
1954 if (ensoniq == NULL) { 1947 if (ensoniq == NULL) {
1955 pci_disable_device(pci); 1948 pci_disable_device(pci);
1956 return -ENOMEM; 1949 return -ENOMEM;
@@ -2394,6 +2387,7 @@ static void __devexit snd_audiopci_remove(struct pci_dev *pci)
2394 2387
2395static struct pci_driver driver = { 2388static struct pci_driver driver = {
2396 .name = DRIVER_NAME, 2389 .name = DRIVER_NAME,
2390 .owner = THIS_MODULE,
2397 .id_table = snd_audiopci_ids, 2391 .id_table = snd_audiopci_ids,
2398 .probe = snd_audiopci_probe, 2392 .probe = snd_audiopci_probe,
2399 .remove = __devexit_p(snd_audiopci_remove), 2393 .remove = __devexit_p(snd_audiopci_remove),
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index b492777bc30f..17fa80c23870 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -76,13 +76,6 @@ MODULE_SUPPORTED_DEVICE("{{ESS,ES1938},"
76#define SUPPORT_JOYSTICK 1 76#define SUPPORT_JOYSTICK 1
77#endif 77#endif
78 78
79#ifndef PCI_VENDOR_ID_ESS
80#define PCI_VENDOR_ID_ESS 0x125d
81#endif
82#ifndef PCI_DEVICE_ID_ESS_ES1938
83#define PCI_DEVICE_ID_ESS_ES1938 0x1969
84#endif
85
86static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 79static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
87static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 80static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
88static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 81static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
@@ -1501,7 +1494,7 @@ static int __devinit snd_es1938_create(snd_card_t * card,
1501 return -ENXIO; 1494 return -ENXIO;
1502 } 1495 }
1503 1496
1504 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1497 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1505 if (chip == NULL) { 1498 if (chip == NULL) {
1506 pci_disable_device(pci); 1499 pci_disable_device(pci);
1507 return -ENOMEM; 1500 return -ENOMEM;
@@ -1753,6 +1746,7 @@ static void __devexit snd_es1938_remove(struct pci_dev *pci)
1753 1746
1754static struct pci_driver driver = { 1747static struct pci_driver driver = {
1755 .name = "ESS ES1938 (Solo-1)", 1748 .name = "ESS ES1938 (Solo-1)",
1749 .owner = THIS_MODULE,
1756 .id_table = snd_es1938_ids, 1750 .id_table = snd_es1938_ids,
1757 .probe = snd_es1938_probe, 1751 .probe = snd_es1938_probe,
1758 .remove = __devexit_p(snd_es1938_remove), 1752 .remove = __devexit_p(snd_es1938_remove),
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 9d7a28783930..ecdcada90ca2 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -160,25 +160,6 @@ MODULE_PARM_DESC(joystick, "Enable joystick.");
160#endif 160#endif
161 161
162 162
163/* PCI Dev ID's */
164
165#ifndef PCI_VENDOR_ID_ESS
166#define PCI_VENDOR_ID_ESS 0x125D
167#endif
168
169#define PCI_VENDOR_ID_ESS_OLD 0x1285 /* Platform Tech, the people the ESS
170 was bought form */
171
172#ifndef PCI_DEVICE_ID_ESS_M2E
173#define PCI_DEVICE_ID_ESS_M2E 0x1978
174#endif
175#ifndef PCI_DEVICE_ID_ESS_M2
176#define PCI_DEVICE_ID_ESS_M2 0x1968
177#endif
178#ifndef PCI_DEVICE_ID_ESS_M1
179#define PCI_DEVICE_ID_ESS_M1 0x0100
180#endif
181
182#define NR_APUS 64 163#define NR_APUS 64
183#define NR_APU_REGS 16 164#define NR_APU_REGS 16
184 165
@@ -1596,7 +1577,7 @@ static int snd_es1968_playback_open(snd_pcm_substream_t *substream)
1596 if (apu1 < 0) 1577 if (apu1 < 0)
1597 return apu1; 1578 return apu1;
1598 1579
1599 es = kcalloc(1, sizeof(*es), GFP_KERNEL); 1580 es = kzalloc(sizeof(*es), GFP_KERNEL);
1600 if (!es) { 1581 if (!es) {
1601 snd_es1968_free_apu_pair(chip, apu1); 1582 snd_es1968_free_apu_pair(chip, apu1);
1602 return -ENOMEM; 1583 return -ENOMEM;
@@ -1641,7 +1622,7 @@ static int snd_es1968_capture_open(snd_pcm_substream_t *substream)
1641 return apu2; 1622 return apu2;
1642 } 1623 }
1643 1624
1644 es = kcalloc(1, sizeof(*es), GFP_KERNEL); 1625 es = kzalloc(sizeof(*es), GFP_KERNEL);
1645 if (!es) { 1626 if (!es) {
1646 snd_es1968_free_apu_pair(chip, apu1); 1627 snd_es1968_free_apu_pair(chip, apu1);
1647 snd_es1968_free_apu_pair(chip, apu2); 1628 snd_es1968_free_apu_pair(chip, apu2);
@@ -2588,7 +2569,7 @@ static int __devinit snd_es1968_create(snd_card_t * card,
2588 return -ENXIO; 2569 return -ENXIO;
2589 } 2570 }
2590 2571
2591 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 2572 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
2592 if (! chip) { 2573 if (! chip) {
2593 pci_disable_device(pci); 2574 pci_disable_device(pci);
2594 return -ENOMEM; 2575 return -ENOMEM;
@@ -2782,6 +2763,7 @@ static void __devexit snd_es1968_remove(struct pci_dev *pci)
2782 2763
2783static struct pci_driver driver = { 2764static struct pci_driver driver = {
2784 .name = "ES1968 (ESS Maestro)", 2765 .name = "ES1968 (ESS Maestro)",
2766 .owner = THIS_MODULE,
2785 .id_table = snd_es1968_ids, 2767 .id_table = snd_es1968_ids,
2786 .probe = snd_es1968_probe, 2768 .probe = snd_es1968_probe,
2787 .remove = __devexit_p(snd_es1968_remove), 2769 .remove = __devexit_p(snd_es1968_remove),
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 36b2f62e8573..e5cfa2a0c246 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1263,7 +1263,7 @@ static int __devinit snd_fm801_create(snd_card_t * card,
1263 *rchip = NULL; 1263 *rchip = NULL;
1264 if ((err = pci_enable_device(pci)) < 0) 1264 if ((err = pci_enable_device(pci)) < 0)
1265 return err; 1265 return err;
1266 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1266 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1267 if (chip == NULL) { 1267 if (chip == NULL) {
1268 pci_disable_device(pci); 1268 pci_disable_device(pci);
1269 return -ENOMEM; 1269 return -ENOMEM;
@@ -1462,6 +1462,7 @@ static void __devexit snd_card_fm801_remove(struct pci_dev *pci)
1462 1462
1463static struct pci_driver driver = { 1463static struct pci_driver driver = {
1464 .name = "FM801", 1464 .name = "FM801",
1465 .owner = THIS_MODULE,
1465 .id_table = snd_fm801_ids, 1466 .id_table = snd_fm801_ids,
1466 .probe = snd_card_fm801_probe, 1467 .probe = snd_card_fm801_probe,
1467 .remove = __devexit_p(snd_card_fm801_remove), 1468 .remove = __devexit_p(snd_card_fm801_remove),
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 20f7762f7144..3815403ed095 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -288,7 +288,7 @@ static int init_unsol_queue(struct hda_bus *bus)
288{ 288{
289 struct hda_bus_unsolicited *unsol; 289 struct hda_bus_unsolicited *unsol;
290 290
291 unsol = kcalloc(1, sizeof(*unsol), GFP_KERNEL); 291 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL);
292 if (! unsol) { 292 if (! unsol) {
293 snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n"); 293 snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n");
294 return -ENOMEM; 294 return -ENOMEM;
@@ -358,7 +358,7 @@ int snd_hda_bus_new(snd_card_t *card, const struct hda_bus_template *temp,
358 if (busp) 358 if (busp)
359 *busp = NULL; 359 *busp = NULL;
360 360
361 bus = kcalloc(1, sizeof(*bus), GFP_KERNEL); 361 bus = kzalloc(sizeof(*bus), GFP_KERNEL);
362 if (bus == NULL) { 362 if (bus == NULL) {
363 snd_printk(KERN_ERR "can't allocate struct hda_bus\n"); 363 snd_printk(KERN_ERR "can't allocate struct hda_bus\n");
364 return -ENOMEM; 364 return -ENOMEM;
@@ -493,7 +493,7 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
493 return -EBUSY; 493 return -EBUSY;
494 } 494 }
495 495
496 codec = kcalloc(1, sizeof(*codec), GFP_KERNEL); 496 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
497 if (codec == NULL) { 497 if (codec == NULL) {
498 snd_printk(KERN_ERR "can't allocate struct hda_codec\n"); 498 snd_printk(KERN_ERR "can't allocate struct hda_codec\n");
499 return -ENOMEM; 499 return -ENOMEM;
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 63a29a8a2860..bb53bcf76742 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -505,6 +505,7 @@ struct hda_pcm_stream {
505struct hda_pcm { 505struct hda_pcm {
506 char *name; 506 char *name;
507 struct hda_pcm_stream stream[2]; 507 struct hda_pcm_stream stream[2];
508 unsigned int is_modem; /* modem codec? */
508}; 509};
509 510
510/* codec information */ 511/* codec information */
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 1229227af5b5..5b829a1a4c60 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -98,7 +98,7 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid
98 struct hda_gnode *node; 98 struct hda_gnode *node;
99 int nconns; 99 int nconns;
100 100
101 node = kcalloc(1, sizeof(*node), GFP_KERNEL); 101 node = kzalloc(sizeof(*node), GFP_KERNEL);
102 if (node == NULL) 102 if (node == NULL)
103 return -ENOMEM; 103 return -ENOMEM;
104 node->nid = nid; 104 node->nid = nid;
@@ -886,7 +886,7 @@ int snd_hda_parse_generic_codec(struct hda_codec *codec)
886 return -ENODEV; 886 return -ENODEV;
887 } 887 }
888 888
889 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 889 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
890 if (spec == NULL) { 890 if (spec == NULL) {
891 printk(KERN_ERR "hda_generic: can't allocate spec\n"); 891 printk(KERN_ERR "hda_generic: can't allocate spec\n");
892 return -ENOMEM; 892 return -ENOMEM;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 15107df1f490..9590ece2099d 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -62,7 +62,7 @@ MODULE_PARM_DESC(enable, "Enable Intel HD audio interface.");
62module_param_array(model, charp, NULL, 0444); 62module_param_array(model, charp, NULL, 0444);
63MODULE_PARM_DESC(model, "Use the given board model."); 63MODULE_PARM_DESC(model, "Use the given board model.");
64module_param_array(position_fix, int, NULL, 0444); 64module_param_array(position_fix, int, NULL, 0444);
65MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = FIFO size, 1 = none, 2 = POSBUF)."); 65MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size).");
66 66
67MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
68MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," 68MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
@@ -164,7 +164,9 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
164/* max buffer size - no h/w limit, you can increase as you like */ 164/* max buffer size - no h/w limit, you can increase as you like */
165#define AZX_MAX_BUF_SIZE (1024*1024*1024) 165#define AZX_MAX_BUF_SIZE (1024*1024*1024)
166/* max number of PCM devics per card */ 166/* max number of PCM devics per card */
167#define AZX_MAX_PCMS 8 167#define AZX_MAX_AUDIO_PCMS 6
168#define AZX_MAX_MODEM_PCMS 2
169#define AZX_MAX_PCMS (AZX_MAX_AUDIO_PCMS + AZX_MAX_MODEM_PCMS)
168 170
169/* RIRB int mask: overrun[2], response[0] */ 171/* RIRB int mask: overrun[2], response[0] */
170#define RIRB_INT_RESPONSE 0x01 172#define RIRB_INT_RESPONSE 0x01
@@ -211,9 +213,10 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
211 213
212/* position fix mode */ 214/* position fix mode */
213enum { 215enum {
214 POS_FIX_FIFO, 216 POS_FIX_AUTO,
215 POS_FIX_NONE, 217 POS_FIX_NONE,
216 POS_FIX_POSBUF 218 POS_FIX_POSBUF,
219 POS_FIX_FIFO,
217}; 220};
218 221
219/* Defines for ATI HD Audio support in SB450 south bridge */ 222/* Defines for ATI HD Audio support in SB450 south bridge */
@@ -243,6 +246,7 @@ struct snd_azx_dev {
243 unsigned int fragsize; /* size of each period in bytes */ 246 unsigned int fragsize; /* size of each period in bytes */
244 unsigned int frags; /* number for period in the play buffer */ 247 unsigned int frags; /* number for period in the play buffer */
245 unsigned int fifo_size; /* FIFO size */ 248 unsigned int fifo_size; /* FIFO size */
249 unsigned int last_pos; /* last updated period position */
246 250
247 void __iomem *sd_addr; /* stream descriptor pointer */ 251 void __iomem *sd_addr; /* stream descriptor pointer */
248 252
@@ -256,6 +260,7 @@ struct snd_azx_dev {
256 260
257 unsigned int opened: 1; 261 unsigned int opened: 1;
258 unsigned int running: 1; 262 unsigned int running: 1;
263 unsigned int period_updating: 1;
259}; 264};
260 265
261/* CORB/RIRB */ 266/* CORB/RIRB */
@@ -724,11 +729,9 @@ static void azx_init_chip(azx_t *chip)
724 /* initialize the codec command I/O */ 729 /* initialize the codec command I/O */
725 azx_init_cmd_io(chip); 730 azx_init_cmd_io(chip);
726 731
727 if (chip->position_fix == POS_FIX_POSBUF) { 732 /* program the position buffer */
728 /* program the position buffer */ 733 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr);
729 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); 734 azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr));
730 azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr));
731 }
732 735
733 /* For ATI SB450 azalia HD audio, we need to enable snoop */ 736 /* For ATI SB450 azalia HD audio, we need to enable snoop */
734 if (chip->driver_type == AZX_DRIVER_ATI) { 737 if (chip->driver_type == AZX_DRIVER_ATI) {
@@ -763,9 +766,11 @@ static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs)
763 if (status & azx_dev->sd_int_sta_mask) { 766 if (status & azx_dev->sd_int_sta_mask) {
764 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); 767 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
765 if (azx_dev->substream && azx_dev->running) { 768 if (azx_dev->substream && azx_dev->running) {
769 azx_dev->period_updating = 1;
766 spin_unlock(&chip->reg_lock); 770 spin_unlock(&chip->reg_lock);
767 snd_pcm_period_elapsed(azx_dev->substream); 771 snd_pcm_period_elapsed(azx_dev->substream);
768 spin_lock(&chip->reg_lock); 772 spin_lock(&chip->reg_lock);
773 azx_dev->period_updating = 0;
769 } 774 }
770 } 775 }
771 } 776 }
@@ -866,11 +871,9 @@ static int azx_setup_controller(azx_t *chip, azx_dev_t *azx_dev)
866 /* upper BDL address */ 871 /* upper BDL address */
867 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr)); 872 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr));
868 873
869 if (chip->position_fix == POS_FIX_POSBUF) { 874 /* enable the position buffer */
870 /* enable the position buffer */ 875 if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
871 if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) 876 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
872 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
873 }
874 877
875 /* set the interrupt enable bits in the descriptor control register */ 878 /* set the interrupt enable bits in the descriptor control register */
876 azx_sd_writel(azx_dev, SD_CTL, azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK); 879 azx_sd_writel(azx_dev, SD_CTL, azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK);
@@ -1078,6 +1081,7 @@ static int azx_pcm_prepare(snd_pcm_substream_t *substream)
1078 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1; 1081 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1;
1079 else 1082 else
1080 azx_dev->fifo_size = 0; 1083 azx_dev->fifo_size = 0;
1084 azx_dev->last_pos = 0;
1081 1085
1082 return hinfo->ops.prepare(hinfo, apcm->codec, azx_dev->stream_tag, 1086 return hinfo->ops.prepare(hinfo, apcm->codec, azx_dev->stream_tag,
1083 azx_dev->format_val, substream); 1087 azx_dev->format_val, substream);
@@ -1133,6 +1137,26 @@ static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream)
1133 pos = azx_sd_readl(azx_dev, SD_LPIB); 1137 pos = azx_sd_readl(azx_dev, SD_LPIB);
1134 if (chip->position_fix == POS_FIX_FIFO) 1138 if (chip->position_fix == POS_FIX_FIFO)
1135 pos += azx_dev->fifo_size; 1139 pos += azx_dev->fifo_size;
1140 else if (chip->position_fix == POS_FIX_AUTO && azx_dev->period_updating) {
1141 /* check the validity of DMA position */
1142 unsigned int diff = 0;
1143 azx_dev->last_pos += azx_dev->fragsize;
1144 if (azx_dev->last_pos > pos)
1145 diff = azx_dev->last_pos - pos;
1146 if (azx_dev->last_pos >= azx_dev->bufsize) {
1147 if (pos < azx_dev->fragsize)
1148 diff = 0;
1149 azx_dev->last_pos = 0;
1150 }
1151 if (diff > 0 && diff <= azx_dev->fifo_size)
1152 pos += azx_dev->fifo_size;
1153 else {
1154 snd_printdd(KERN_INFO "hda_intel: DMA position fix %d, switching to posbuf\n", diff);
1155 chip->position_fix = POS_FIX_POSBUF;
1156 pos = *azx_dev->posbuf;
1157 }
1158 azx_dev->period_updating = 0;
1159 }
1136 } 1160 }
1137 if (pos >= azx_dev->bufsize) 1161 if (pos >= azx_dev->bufsize)
1138 pos = 0; 1162 pos = 0;
@@ -1203,12 +1227,33 @@ static int __devinit azx_pcm_create(azx_t *chip)
1203 if ((err = snd_hda_build_pcms(chip->bus)) < 0) 1227 if ((err = snd_hda_build_pcms(chip->bus)) < 0)
1204 return err; 1228 return err;
1205 1229
1230 /* create audio PCMs */
1206 pcm_dev = 0; 1231 pcm_dev = 0;
1207 list_for_each(p, &chip->bus->codec_list) { 1232 list_for_each(p, &chip->bus->codec_list) {
1208 codec = list_entry(p, struct hda_codec, list); 1233 codec = list_entry(p, struct hda_codec, list);
1209 for (c = 0; c < codec->num_pcms; c++) { 1234 for (c = 0; c < codec->num_pcms; c++) {
1235 if (codec->pcm_info[c].is_modem)
1236 continue; /* create later */
1237 if (pcm_dev >= AZX_MAX_AUDIO_PCMS) {
1238 snd_printk(KERN_ERR SFX "Too many audio PCMs\n");
1239 return -EINVAL;
1240 }
1241 err = create_codec_pcm(chip, codec, &codec->pcm_info[c], pcm_dev);
1242 if (err < 0)
1243 return err;
1244 pcm_dev++;
1245 }
1246 }
1247
1248 /* create modem PCMs */
1249 pcm_dev = AZX_MAX_AUDIO_PCMS;
1250 list_for_each(p, &chip->bus->codec_list) {
1251 codec = list_entry(p, struct hda_codec, list);
1252 for (c = 0; c < codec->num_pcms; c++) {
1253 if (! codec->pcm_info[c].is_modem)
1254 continue; /* already created */
1210 if (pcm_dev >= AZX_MAX_PCMS) { 1255 if (pcm_dev >= AZX_MAX_PCMS) {
1211 snd_printk(KERN_ERR SFX "Too many PCMs\n"); 1256 snd_printk(KERN_ERR SFX "Too many modem PCMs\n");
1212 return -EINVAL; 1257 return -EINVAL;
1213 } 1258 }
1214 err = create_codec_pcm(chip, codec, &codec->pcm_info[c], pcm_dev); 1259 err = create_codec_pcm(chip, codec, &codec->pcm_info[c], pcm_dev);
@@ -1244,8 +1289,7 @@ static int __devinit azx_init_stream(azx_t *chip)
1244 azx_dev_t *azx_dev = &chip->azx_dev[i]; 1289 azx_dev_t *azx_dev = &chip->azx_dev[i];
1245 azx_dev->bdl = (u32 *)(chip->bdl.area + off); 1290 azx_dev->bdl = (u32 *)(chip->bdl.area + off);
1246 azx_dev->bdl_addr = chip->bdl.addr + off; 1291 azx_dev->bdl_addr = chip->bdl.addr + off;
1247 if (chip->position_fix == POS_FIX_POSBUF) 1292 azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8);
1248 azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8);
1249 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ 1293 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
1250 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); 1294 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
1251 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */ 1295 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
@@ -1358,7 +1402,7 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci,
1358 if ((err = pci_enable_device(pci)) < 0) 1402 if ((err = pci_enable_device(pci)) < 0)
1359 return err; 1403 return err;
1360 1404
1361 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1405 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1362 1406
1363 if (NULL == chip) { 1407 if (NULL == chip) {
1364 snd_printk(KERN_ERR SFX "cannot allocate chip\n"); 1408 snd_printk(KERN_ERR SFX "cannot allocate chip\n");
@@ -1437,13 +1481,11 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci,
1437 snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); 1481 snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
1438 goto errout; 1482 goto errout;
1439 } 1483 }
1440 if (chip->position_fix == POS_FIX_POSBUF) { 1484 /* allocate memory for the position buffer */
1441 /* allocate memory for the position buffer */ 1485 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
1442 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 1486 chip->num_streams * 8, &chip->posbuf)) < 0) {
1443 chip->num_streams * 8, &chip->posbuf)) < 0) { 1487 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n");
1444 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); 1488 goto errout;
1445 goto errout;
1446 }
1447 } 1489 }
1448 /* allocate CORB/RIRB */ 1490 /* allocate CORB/RIRB */
1449 if ((err = azx_alloc_cmd_io(chip)) < 0) 1491 if ((err = azx_alloc_cmd_io(chip)) < 0)
@@ -1561,6 +1603,7 @@ MODULE_DEVICE_TABLE(pci, azx_ids);
1561/* pci_driver definition */ 1603/* pci_driver definition */
1562static struct pci_driver driver = { 1604static struct pci_driver driver = {
1563 .name = "HDA Intel", 1605 .name = "HDA Intel",
1606 .owner = THIS_MODULE,
1564 .id_table = azx_ids, 1607 .id_table = azx_ids,
1565 .probe = azx_probe, 1608 .probe = azx_probe,
1566 .remove = __devexit_p(azx_remove), 1609 .remove = __devexit_p(azx_remove),
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index de1217bd8e68..08f6a6efc5e6 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -207,6 +207,8 @@ static void print_codec_info(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
207 snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id); 207 snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id);
208 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id); 208 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id);
209 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id); 209 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
210 if (! codec->afg)
211 return;
210 snd_iprintf(buffer, "Default PCM: "); 212 snd_iprintf(buffer, "Default PCM: ");
211 print_pcm_caps(buffer, codec, codec->afg); 213 print_pcm_caps(buffer, codec, codec->afg);
212 snd_iprintf(buffer, "Default Amp-In caps: "); 214 snd_iprintf(buffer, "Default Amp-In caps: ");
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index bceb83a42a38..da6874d3988c 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -465,7 +465,7 @@ static int patch_ad1986a(struct hda_codec *codec)
465{ 465{
466 struct ad198x_spec *spec; 466 struct ad198x_spec *spec;
467 467
468 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 468 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
469 if (spec == NULL) 469 if (spec == NULL)
470 return -ENOMEM; 470 return -ENOMEM;
471 471
@@ -623,7 +623,7 @@ static int patch_ad1983(struct hda_codec *codec)
623{ 623{
624 struct ad198x_spec *spec; 624 struct ad198x_spec *spec;
625 625
626 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 626 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
627 if (spec == NULL) 627 if (spec == NULL)
628 return -ENOMEM; 628 return -ENOMEM;
629 629
@@ -764,7 +764,7 @@ static int patch_ad1981(struct hda_codec *codec)
764{ 764{
765 struct ad198x_spec *spec; 765 struct ad198x_spec *spec;
766 766
767 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 767 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
768 if (spec == NULL) 768 if (spec == NULL)
769 return -ENOMEM; 769 return -ENOMEM;
770 770
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 07fb4f5a54b3..523c362ec44d 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -667,7 +667,7 @@ static int patch_cmi9880(struct hda_codec *codec)
667{ 667{
668 struct cmi_spec *spec; 668 struct cmi_spec *spec;
669 669
670 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 670 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
671 if (spec == NULL) 671 if (spec == NULL)
672 return -ENOMEM; 672 return -ENOMEM;
673 673
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index eeb900ab79af..849b5b50c921 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1526,6 +1526,7 @@ static struct hda_board_config alc880_cfg_tbl[] = {
1526 /* Back 3 jack, front 2 jack (Internal add Aux-In) */ 1526 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
1527 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, 1527 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
1528 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, 1528 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
1529 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
1529 1530
1530 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ 1531 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1531 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, 1532 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
@@ -1581,6 +1582,7 @@ static struct hda_board_config alc880_cfg_tbl[] = {
1581 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG }, 1582 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1582 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG }, 1583 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1583 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG }, 1584 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
1585 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
1584 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS }, 1586 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1585 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG }, 1587 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1586 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS }, 1588 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
@@ -2093,7 +2095,7 @@ static int patch_alc880(struct hda_codec *codec)
2093 int board_config; 2095 int board_config;
2094 int i, err; 2096 int i, err;
2095 2097
2096 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 2098 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2097 if (spec == NULL) 2099 if (spec == NULL)
2098 return -ENOMEM; 2100 return -ENOMEM;
2099 2101
@@ -2365,7 +2367,7 @@ static int patch_alc260(struct hda_codec *codec)
2365 struct alc_spec *spec; 2367 struct alc_spec *spec;
2366 int board_config; 2368 int board_config;
2367 2369
2368 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 2370 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2369 if (spec == NULL) 2371 if (spec == NULL)
2370 return -ENOMEM; 2372 return -ENOMEM;
2371 2373
@@ -2615,7 +2617,7 @@ static int patch_alc882(struct hda_codec *codec)
2615{ 2617{
2616 struct alc_spec *spec; 2618 struct alc_spec *spec;
2617 2619
2618 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 2620 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2619 if (spec == NULL) 2621 if (spec == NULL)
2620 return -ENOMEM; 2622 return -ENOMEM;
2621 2623
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index b0270d1b64ce..d014b7bb70df 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -214,6 +214,7 @@ static int si3054_build_pcms(struct hda_codec *codec)
214 info->name = "Si3054 Modem"; 214 info->name = "Si3054 Modem";
215 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm; 215 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm;
216 info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm; 216 info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm;
217 info->is_modem = 1;
217 return 0; 218 return 0;
218} 219}
219 220
@@ -282,7 +283,7 @@ static struct hda_codec_ops si3054_patch_ops = {
282 283
283static int patch_si3054(struct hda_codec *codec) 284static int patch_si3054(struct hda_codec *codec)
284{ 285{
285 struct si3054_spec *spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 286 struct si3054_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
286 if (spec == NULL) 287 if (spec == NULL)
287 return -ENOMEM; 288 return -ENOMEM;
288 codec->spec = spec; 289 codec->spec = spec;
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 9d503da7320d..33a8adaea768 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -919,7 +919,7 @@ static int patch_stac9200(struct hda_codec *codec)
919 struct sigmatel_spec *spec; 919 struct sigmatel_spec *spec;
920 int err; 920 int err;
921 921
922 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 922 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
923 if (spec == NULL) 923 if (spec == NULL)
924 return -ENOMEM; 924 return -ENOMEM;
925 925
@@ -957,7 +957,7 @@ static int patch_stac922x(struct hda_codec *codec)
957 struct sigmatel_spec *spec; 957 struct sigmatel_spec *spec;
958 int err; 958 int err;
959 959
960 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 960 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
961 if (spec == NULL) 961 if (spec == NULL)
962 return -ENOMEM; 962 return -ENOMEM;
963 963
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
index 4405d96cbedf..2e0a31613ee6 100644
--- a/sound/pci/ice1712/aureon.c
+++ b/sound/pci/ice1712/aureon.c
@@ -1796,7 +1796,7 @@ static int __devinit aureon_init(ice1712_t *ice)
1796 } 1796 }
1797 1797
1798 /* to remeber the register values of CS8415 */ 1798 /* to remeber the register values of CS8415 */
1799 ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); 1799 ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL);
1800 if (! ice->akm) 1800 if (! ice->akm)
1801 return -ENOMEM; 1801 return -ENOMEM;
1802 ice->akm_codecs = 1; 1802 ice->akm_codecs = 1;
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index b97f50d10ba3..a6d98013c331 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -100,12 +100,6 @@ MODULE_PARM_DESC(cs8427_timeout, "Define reset timeout for cs8427 chip in msec r
100module_param_array(model, charp, NULL, 0444); 100module_param_array(model, charp, NULL, 0444);
101MODULE_PARM_DESC(model, "Use the given board model."); 101MODULE_PARM_DESC(model, "Use the given board model.");
102 102
103#ifndef PCI_VENDOR_ID_ICE
104#define PCI_VENDOR_ID_ICE 0x1412
105#endif
106#ifndef PCI_DEVICE_ID_ICE_1712
107#define PCI_DEVICE_ID_ICE_1712 0x1712
108#endif
109 103
110static struct pci_device_id snd_ice1712_ids[] = { 104static struct pci_device_id snd_ice1712_ids[] = {
111 { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_ICE_1712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICE1712 */ 105 { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_ICE_1712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICE1712 */
@@ -2535,7 +2529,7 @@ static int __devinit snd_ice1712_create(snd_card_t * card,
2535 return -ENXIO; 2529 return -ENXIO;
2536 } 2530 }
2537 2531
2538 ice = kcalloc(1, sizeof(*ice), GFP_KERNEL); 2532 ice = kzalloc(sizeof(*ice), GFP_KERNEL);
2539 if (ice == NULL) { 2533 if (ice == NULL) {
2540 pci_disable_device(pci); 2534 pci_disable_device(pci);
2541 return -ENOMEM; 2535 return -ENOMEM;
@@ -2741,6 +2735,7 @@ static void __devexit snd_ice1712_remove(struct pci_dev *pci)
2741 2735
2742static struct pci_driver driver = { 2736static struct pci_driver driver = {
2743 .name = "ICE1712", 2737 .name = "ICE1712",
2738 .owner = THIS_MODULE,
2744 .id_table = snd_ice1712_ids, 2739 .id_table = snd_ice1712_ids,
2745 .probe = snd_ice1712_probe, 2740 .probe = snd_ice1712_probe,
2746 .remove = __devexit_p(snd_ice1712_remove), 2741 .remove = __devexit_p(snd_ice1712_remove),
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index c7af5e5fee13..c3ce8f93740b 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -83,12 +83,6 @@ MODULE_PARM_DESC(enable, "Enable ICE1724 soundcard.");
83module_param_array(model, charp, NULL, 0444); 83module_param_array(model, charp, NULL, 0444);
84MODULE_PARM_DESC(model, "Use the given board model."); 84MODULE_PARM_DESC(model, "Use the given board model.");
85 85
86#ifndef PCI_VENDOR_ID_ICE
87#define PCI_VENDOR_ID_ICE 0x1412
88#endif
89#ifndef PCI_DEVICE_ID_VT1724
90#define PCI_DEVICE_ID_VT1724 0x1724
91#endif
92 86
93/* Both VT1720 and VT1724 have the same PCI IDs */ 87/* Both VT1720 and VT1724 have the same PCI IDs */
94static struct pci_device_id snd_vt1724_ids[] = { 88static struct pci_device_id snd_vt1724_ids[] = {
@@ -2130,7 +2124,7 @@ static int __devinit snd_vt1724_create(snd_card_t * card,
2130 if ((err = pci_enable_device(pci)) < 0) 2124 if ((err = pci_enable_device(pci)) < 0)
2131 return err; 2125 return err;
2132 2126
2133 ice = kcalloc(1, sizeof(*ice), GFP_KERNEL); 2127 ice = kzalloc(sizeof(*ice), GFP_KERNEL);
2134 if (ice == NULL) { 2128 if (ice == NULL) {
2135 pci_disable_device(pci); 2129 pci_disable_device(pci);
2136 return -ENOMEM; 2130 return -ENOMEM;
@@ -2321,6 +2315,7 @@ static void __devexit snd_vt1724_remove(struct pci_dev *pci)
2321 2315
2322static struct pci_driver driver = { 2316static struct pci_driver driver = {
2323 .name = "ICE1724", 2317 .name = "ICE1724",
2318 .owner = THIS_MODULE,
2324 .id_table = snd_vt1724_ids, 2319 .id_table = snd_vt1724_ids,
2325 .probe = snd_vt1724_probe, 2320 .probe = snd_vt1724_probe,
2326 .remove = __devexit_p(snd_vt1724_remove), 2321 .remove = __devexit_p(snd_vt1724_remove),
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index 3fb297b969cd..2437876a44e4 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -182,7 +182,7 @@ static int __devinit juli_init(ice1712_t *ice)
182 ice->num_total_dacs = 2; 182 ice->num_total_dacs = 2;
183 ice->num_total_adcs = 2; 183 ice->num_total_adcs = 2;
184 184
185 ak = ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); 185 ak = ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL);
186 if (! ak) 186 if (! ak)
187 return -ENOMEM; 187 return -ENOMEM;
188 ice->akm_codecs = 1; 188 ice->akm_codecs = 1;
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index 5bf734b04fa0..dcf1e8ca3f66 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -122,7 +122,7 @@ static int __devinit phase22_init(ice1712_t *ice)
122 } 122 }
123 123
124 // Initialize analog chips 124 // Initialize analog chips
125 ak = ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); 125 ak = ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL);
126 if (! ak) 126 if (! ak)
127 return -ENOMEM; 127 return -ENOMEM;
128 ice->akm_codecs = 1; 128 ice->akm_codecs = 1;
@@ -386,7 +386,7 @@ static int __devinit phase28_init(ice1712_t *ice)
386 ice->num_total_adcs = 2; 386 ice->num_total_adcs = 2;
387 387
388 // Initialize analog chips 388 // Initialize analog chips
389 ak = ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); 389 ak = ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL);
390 if (!ak) 390 if (!ak)
391 return -ENOMEM; 391 return -ENOMEM;
392 ice->akm_codecs = 1; 392 ice->akm_codecs = 1;
diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c
index 25f827d8fbd9..a5f852b1f575 100644
--- a/sound/pci/ice1712/pontis.c
+++ b/sound/pci/ice1712/pontis.c
@@ -781,7 +781,7 @@ static int __devinit pontis_init(ice1712_t *ice)
781 ice->num_total_adcs = 2; 781 ice->num_total_adcs = 2;
782 782
783 /* to remeber the register values */ 783 /* to remeber the register values */
784 ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); 784 ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL);
785 if (! ice->akm) 785 if (! ice->akm)
786 return -ENOMEM; 786 return -ENOMEM;
787 ice->akm_codecs = 1; 787 ice->akm_codecs = 1;
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 7b548416dcef..1a96198a17ae 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -69,6 +69,7 @@ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
69static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 69static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
70static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; 70static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
71static char *ac97_quirk[SNDRV_CARDS]; 71static char *ac97_quirk[SNDRV_CARDS];
72static int buggy_semaphore[SNDRV_CARDS];
72static int buggy_irq[SNDRV_CARDS]; 73static int buggy_irq[SNDRV_CARDS];
73static int xbox[SNDRV_CARDS]; 74static int xbox[SNDRV_CARDS];
74 75
@@ -86,6 +87,8 @@ module_param_array(ac97_clock, int, NULL, 0444);
86MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect)."); 87MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
87module_param_array(ac97_quirk, charp, NULL, 0444); 88module_param_array(ac97_quirk, charp, NULL, 0444);
88MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); 89MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
90module_param_array(buggy_semaphore, bool, NULL, 0444);
91MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
89module_param_array(buggy_irq, bool, NULL, 0444); 92module_param_array(buggy_irq, bool, NULL, 0444);
90MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards."); 93MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
91module_param_array(xbox, bool, NULL, 0444); 94module_param_array(xbox, bool, NULL, 0444);
@@ -94,62 +97,6 @@ MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 c
94/* 97/*
95 * Direct registers 98 * Direct registers
96 */ 99 */
97
98#ifndef PCI_DEVICE_ID_INTEL_82801
99#define PCI_DEVICE_ID_INTEL_82801 0x2415
100#endif
101#ifndef PCI_DEVICE_ID_INTEL_82901
102#define PCI_DEVICE_ID_INTEL_82901 0x2425
103#endif
104#ifndef PCI_DEVICE_ID_INTEL_82801BA
105#define PCI_DEVICE_ID_INTEL_82801BA 0x2445
106#endif
107#ifndef PCI_DEVICE_ID_INTEL_440MX
108#define PCI_DEVICE_ID_INTEL_440MX 0x7195
109#endif
110#ifndef PCI_DEVICE_ID_INTEL_ICH3
111#define PCI_DEVICE_ID_INTEL_ICH3 0x2485
112#endif
113#ifndef PCI_DEVICE_ID_INTEL_ICH4
114#define PCI_DEVICE_ID_INTEL_ICH4 0x24c5
115#endif
116#ifndef PCI_DEVICE_ID_INTEL_ICH5
117#define PCI_DEVICE_ID_INTEL_ICH5 0x24d5
118#endif
119#ifndef PCI_DEVICE_ID_INTEL_ESB_5
120#define PCI_DEVICE_ID_INTEL_ESB_5 0x25a6
121#endif
122#ifndef PCI_DEVICE_ID_INTEL_ICH6_18
123#define PCI_DEVICE_ID_INTEL_ICH6_18 0x266e
124#endif
125#ifndef PCI_DEVICE_ID_INTEL_ICH7_20
126#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de
127#endif
128#ifndef PCI_DEVICE_ID_INTEL_ESB2_14
129#define PCI_DEVICE_ID_INTEL_ESB2_14 0x2698
130#endif
131#ifndef PCI_DEVICE_ID_SI_7012
132#define PCI_DEVICE_ID_SI_7012 0x7012
133#endif
134#ifndef PCI_DEVICE_ID_NVIDIA_MCP_AUDIO
135#define PCI_DEVICE_ID_NVIDIA_MCP_AUDIO 0x01b1
136#endif
137#ifndef PCI_DEVICE_ID_NVIDIA_CK804_AUDIO
138#define PCI_DEVICE_ID_NVIDIA_CK804_AUDIO 0x0059
139#endif
140#ifndef PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO
141#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a
142#endif
143#ifndef PCI_DEVICE_ID_NVIDIA_CK8_AUDIO
144#define PCI_DEVICE_ID_NVIDIA_CK8_AUDIO 0x008a
145#endif
146#ifndef PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO
147#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da
148#endif
149#ifndef PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO
150#define PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO 0x00ea
151#endif
152
153enum { DEVICE_INTEL, DEVICE_INTEL_ICH4, DEVICE_SIS, DEVICE_ALI, DEVICE_NFORCE }; 100enum { DEVICE_INTEL, DEVICE_INTEL_ICH4, DEVICE_SIS, DEVICE_ALI, DEVICE_NFORCE };
154 101
155#define ICHREG(x) ICH_REG_##x 102#define ICHREG(x) ICH_REG_##x
@@ -423,6 +370,7 @@ struct _snd_intel8x0 {
423 unsigned fix_nocache: 1; /* workaround for 440MX */ 370 unsigned fix_nocache: 1; /* workaround for 440MX */
424 unsigned buggy_irq: 1; /* workaround for buggy mobos */ 371 unsigned buggy_irq: 1; /* workaround for buggy mobos */
425 unsigned xbox: 1; /* workaround for Xbox AC'97 detection */ 372 unsigned xbox: 1; /* workaround for Xbox AC'97 detection */
373 unsigned buggy_semaphore: 1; /* workaround for buggy codec semaphore */
426 374
427 int spdif_idx; /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */ 375 int spdif_idx; /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */
428 unsigned int sdm_saved; /* SDM reg value */ 376 unsigned int sdm_saved; /* SDM reg value */
@@ -577,6 +525,9 @@ static int snd_intel8x0_codec_semaphore(intel8x0_t *chip, unsigned int codec)
577 if ((igetdword(chip, ICHREG(GLOB_STA)) & codec) == 0) 525 if ((igetdword(chip, ICHREG(GLOB_STA)) & codec) == 0)
578 return -EIO; 526 return -EIO;
579 527
528 if (chip->buggy_semaphore)
529 return 0; /* just ignore ... */
530
580 /* Anyone holding a semaphore for 1 msec should be shot... */ 531 /* Anyone holding a semaphore for 1 msec should be shot... */
581 time = 100; 532 time = 100;
582 do { 533 do {
@@ -1759,6 +1710,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1759 .type = AC97_TUNE_ALC_JACK 1710 .type = AC97_TUNE_ALC_JACK
1760 }, 1711 },
1761 { 1712 {
1713 .subvendor = 0x1014,
1714 .subdevice = 0x0267,
1715 .name = "IBM NetVista A30p", /* AD1981B */
1716 .type = AC97_TUNE_HP_ONLY
1717 },
1718 {
1762 .subvendor = 0x1028, 1719 .subvendor = 0x1028,
1763 .subdevice = 0x00d8, 1720 .subdevice = 0x00d8,
1764 .name = "Dell Precision 530", /* AD1885 */ 1721 .name = "Dell Precision 530", /* AD1885 */
@@ -2599,6 +2556,7 @@ struct ich_reg_info {
2599static int __devinit snd_intel8x0_create(snd_card_t * card, 2556static int __devinit snd_intel8x0_create(snd_card_t * card,
2600 struct pci_dev *pci, 2557 struct pci_dev *pci,
2601 unsigned long device_type, 2558 unsigned long device_type,
2559 int buggy_sem,
2602 intel8x0_t ** r_intel8x0) 2560 intel8x0_t ** r_intel8x0)
2603{ 2561{
2604 intel8x0_t *chip; 2562 intel8x0_t *chip;
@@ -2646,7 +2604,7 @@ static int __devinit snd_intel8x0_create(snd_card_t * card,
2646 if ((err = pci_enable_device(pci)) < 0) 2604 if ((err = pci_enable_device(pci)) < 0)
2647 return err; 2605 return err;
2648 2606
2649 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 2607 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
2650 if (chip == NULL) { 2608 if (chip == NULL) {
2651 pci_disable_device(pci); 2609 pci_disable_device(pci);
2652 return -ENOMEM; 2610 return -ENOMEM;
@@ -2656,6 +2614,7 @@ static int __devinit snd_intel8x0_create(snd_card_t * card,
2656 chip->card = card; 2614 chip->card = card;
2657 chip->pci = pci; 2615 chip->pci = pci;
2658 chip->irq = -1; 2616 chip->irq = -1;
2617 chip->buggy_semaphore = buggy_sem;
2659 2618
2660 if (pci->vendor == PCI_VENDOR_ID_INTEL && 2619 if (pci->vendor == PCI_VENDOR_ID_INTEL &&
2661 pci->device == PCI_DEVICE_ID_INTEL_440MX) 2620 pci->device == PCI_DEVICE_ID_INTEL_440MX)
@@ -2795,19 +2754,19 @@ static struct shortname_table {
2795 unsigned int id; 2754 unsigned int id;
2796 const char *s; 2755 const char *s;
2797} shortnames[] __devinitdata = { 2756} shortnames[] __devinitdata = {
2798 { PCI_DEVICE_ID_INTEL_82801, "Intel 82801AA-ICH" }, 2757 { PCI_DEVICE_ID_INTEL_82801AA_5, "Intel 82801AA-ICH" },
2799 { PCI_DEVICE_ID_INTEL_82901, "Intel 82901AB-ICH0" }, 2758 { PCI_DEVICE_ID_INTEL_82801AB_5, "Intel 82901AB-ICH0" },
2800 { PCI_DEVICE_ID_INTEL_82801BA, "Intel 82801BA-ICH2" }, 2759 { PCI_DEVICE_ID_INTEL_82801BA_4, "Intel 82801BA-ICH2" },
2801 { PCI_DEVICE_ID_INTEL_440MX, "Intel 440MX" }, 2760 { PCI_DEVICE_ID_INTEL_440MX, "Intel 440MX" },
2802 { PCI_DEVICE_ID_INTEL_ICH3, "Intel 82801CA-ICH3" }, 2761 { PCI_DEVICE_ID_INTEL_82801CA_5, "Intel 82801CA-ICH3" },
2803 { PCI_DEVICE_ID_INTEL_ICH4, "Intel 82801DB-ICH4" }, 2762 { PCI_DEVICE_ID_INTEL_82801DB_5, "Intel 82801DB-ICH4" },
2804 { PCI_DEVICE_ID_INTEL_ICH5, "Intel ICH5" }, 2763 { PCI_DEVICE_ID_INTEL_82801EB_5, "Intel ICH5" },
2805 { PCI_DEVICE_ID_INTEL_ESB_5, "Intel 6300ESB" }, 2764 { PCI_DEVICE_ID_INTEL_ESB_5, "Intel 6300ESB" },
2806 { PCI_DEVICE_ID_INTEL_ICH6_18, "Intel ICH6" }, 2765 { PCI_DEVICE_ID_INTEL_ICH6_18, "Intel ICH6" },
2807 { PCI_DEVICE_ID_INTEL_ICH7_20, "Intel ICH7" }, 2766 { PCI_DEVICE_ID_INTEL_ICH7_20, "Intel ICH7" },
2808 { PCI_DEVICE_ID_INTEL_ESB2_14, "Intel ESB2" }, 2767 { PCI_DEVICE_ID_INTEL_ESB2_14, "Intel ESB2" },
2809 { PCI_DEVICE_ID_SI_7012, "SiS SI7012" }, 2768 { PCI_DEVICE_ID_SI_7012, "SiS SI7012" },
2810 { PCI_DEVICE_ID_NVIDIA_MCP_AUDIO, "NVidia nForce" }, 2769 { PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO, "NVidia nForce" },
2811 { PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO, "NVidia nForce2" }, 2770 { PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO, "NVidia nForce2" },
2812 { PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO, "NVidia nForce3" }, 2771 { PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO, "NVidia nForce3" },
2813 { PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO, "NVidia CK8S" }, 2772 { PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO, "NVidia CK8S" },
@@ -2860,7 +2819,8 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
2860 } 2819 }
2861 } 2820 }
2862 2821
2863 if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, &chip)) < 0) { 2822 if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data,
2823 buggy_semaphore[dev], &chip)) < 0) {
2864 snd_card_free(card); 2824 snd_card_free(card);
2865 return err; 2825 return err;
2866 } 2826 }
@@ -2904,6 +2864,7 @@ static void __devexit snd_intel8x0_remove(struct pci_dev *pci)
2904 2864
2905static struct pci_driver driver = { 2865static struct pci_driver driver = {
2906 .name = "Intel ICH", 2866 .name = "Intel ICH",
2867 .owner = THIS_MODULE,
2907 .id_table = snd_intel8x0_ids, 2868 .id_table = snd_intel8x0_ids,
2908 .probe = snd_intel8x0_probe, 2869 .probe = snd_intel8x0_probe,
2909 .remove = __devexit_p(snd_intel8x0_remove), 2870 .remove = __devexit_p(snd_intel8x0_remove),
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index bb758c77d211..9e2060d56c24 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -73,51 +73,6 @@ MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
73/* 73/*
74 * Direct registers 74 * Direct registers
75 */ 75 */
76
77#ifndef PCI_DEVICE_ID_INTEL_82801_6
78#define PCI_DEVICE_ID_INTEL_82801_6 0x2416
79#endif
80#ifndef PCI_DEVICE_ID_INTEL_82901_6
81#define PCI_DEVICE_ID_INTEL_82901_6 0x2426
82#endif
83#ifndef PCI_DEVICE_ID_INTEL_82801BA_6
84#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2446
85#endif
86#ifndef PCI_DEVICE_ID_INTEL_440MX_6
87#define PCI_DEVICE_ID_INTEL_440MX_6 0x7196
88#endif
89#ifndef PCI_DEVICE_ID_INTEL_ICH3_6
90#define PCI_DEVICE_ID_INTEL_ICH3_6 0x2486
91#endif
92#ifndef PCI_DEVICE_ID_INTEL_ICH4_6
93#define PCI_DEVICE_ID_INTEL_ICH4_6 0x24c6
94#endif
95#ifndef PCI_DEVICE_ID_INTEL_ICH5_6
96#define PCI_DEVICE_ID_INTEL_ICH5_6 0x24d6
97#endif
98#ifndef PCI_DEVICE_ID_INTEL_ICH6_6
99#define PCI_DEVICE_ID_INTEL_ICH6_6 0x266d
100#endif
101#ifndef PCI_DEVICE_ID_INTEL_ICH7_6
102#define PCI_DEVICE_ID_INTEL_ICH7_6 0x27dd
103#endif
104#ifndef PCI_DEVICE_ID_SI_7013
105#define PCI_DEVICE_ID_SI_7013 0x7013
106#endif
107#ifndef PCI_DEVICE_ID_NVIDIA_MCP_MODEM
108#define PCI_DEVICE_ID_NVIDIA_MCP_MODEM 0x01c1
109#endif
110#ifndef PCI_DEVICE_ID_NVIDIA_MCP2_MODEM
111#define PCI_DEVICE_ID_NVIDIA_MCP2_MODEM 0x0069
112#endif
113#ifndef PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM
114#define PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM 0x0089
115#endif
116#ifndef PCI_DEVICE_ID_NVIDIA_MCP3_MODEM
117#define PCI_DEVICE_ID_NVIDIA_MCP3_MODEM 0x00d9
118#endif
119
120
121enum { DEVICE_INTEL, DEVICE_SIS, DEVICE_ALI, DEVICE_NFORCE }; 76enum { DEVICE_INTEL, DEVICE_SIS, DEVICE_ALI, DEVICE_NFORCE };
122 77
123#define ICHREG(x) ICH_REG_##x 78#define ICHREG(x) ICH_REG_##x
@@ -1158,7 +1113,7 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
1158 if ((err = pci_enable_device(pci)) < 0) 1113 if ((err = pci_enable_device(pci)) < 0)
1159 return err; 1114 return err;
1160 1115
1161 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1116 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1162 if (chip == NULL) { 1117 if (chip == NULL) {
1163 pci_disable_device(pci); 1118 pci_disable_device(pci);
1164 return -ENOMEM; 1119 return -ENOMEM;
@@ -1283,18 +1238,18 @@ static struct shortname_table {
1283 unsigned int id; 1238 unsigned int id;
1284 const char *s; 1239 const char *s;
1285} shortnames[] __devinitdata = { 1240} shortnames[] __devinitdata = {
1286 { PCI_DEVICE_ID_INTEL_82801_6, "Intel 82801AA-ICH" }, 1241 { PCI_DEVICE_ID_INTEL_82801AA_6, "Intel 82801AA-ICH" },
1287 { PCI_DEVICE_ID_INTEL_82901_6, "Intel 82901AB-ICH0" }, 1242 { PCI_DEVICE_ID_INTEL_82801AB_6, "Intel 82901AB-ICH0" },
1288 { PCI_DEVICE_ID_INTEL_82801BA_6, "Intel 82801BA-ICH2" }, 1243 { PCI_DEVICE_ID_INTEL_82801BA_6, "Intel 82801BA-ICH2" },
1289 { PCI_DEVICE_ID_INTEL_440MX_6, "Intel 440MX" }, 1244 { PCI_DEVICE_ID_INTEL_440MX_6, "Intel 440MX" },
1290 { PCI_DEVICE_ID_INTEL_ICH3_6, "Intel 82801CA-ICH3" }, 1245 { PCI_DEVICE_ID_INTEL_82801CA_6, "Intel 82801CA-ICH3" },
1291 { PCI_DEVICE_ID_INTEL_ICH4_6, "Intel 82801DB-ICH4" }, 1246 { PCI_DEVICE_ID_INTEL_82801DB_6, "Intel 82801DB-ICH4" },
1292 { PCI_DEVICE_ID_INTEL_ICH5_6, "Intel ICH5" }, 1247 { PCI_DEVICE_ID_INTEL_82801EB_6, "Intel ICH5" },
1293 { PCI_DEVICE_ID_INTEL_ICH6_6, "Intel ICH6" }, 1248 { PCI_DEVICE_ID_INTEL_ICH6_17, "Intel ICH6" },
1294 { PCI_DEVICE_ID_INTEL_ICH7_6, "Intel ICH7" }, 1249 { PCI_DEVICE_ID_INTEL_ICH7_19, "Intel ICH7" },
1295 { 0x7446, "AMD AMD768" }, 1250 { 0x7446, "AMD AMD768" },
1296 { PCI_DEVICE_ID_SI_7013, "SiS SI7013" }, 1251 { PCI_DEVICE_ID_SI_7013, "SiS SI7013" },
1297 { PCI_DEVICE_ID_NVIDIA_MCP_MODEM, "NVidia nForce" }, 1252 { PCI_DEVICE_ID_NVIDIA_MCP1_MODEM, "NVidia nForce" },
1298 { PCI_DEVICE_ID_NVIDIA_MCP2_MODEM, "NVidia nForce2" }, 1253 { PCI_DEVICE_ID_NVIDIA_MCP2_MODEM, "NVidia nForce2" },
1299 { PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM, "NVidia nForce2s" }, 1254 { PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM, "NVidia nForce2s" },
1300 { PCI_DEVICE_ID_NVIDIA_MCP3_MODEM, "NVidia nForce3" }, 1255 { PCI_DEVICE_ID_NVIDIA_MCP3_MODEM, "NVidia nForce3" },
@@ -1371,6 +1326,7 @@ static void __devexit snd_intel8x0m_remove(struct pci_dev *pci)
1371 1326
1372static struct pci_driver driver = { 1327static struct pci_driver driver = {
1373 .name = "Intel ICH Modem", 1328 .name = "Intel ICH Modem",
1329 .owner = THIS_MODULE,
1374 .id_table = snd_intel8x0m_ids, 1330 .id_table = snd_intel8x0m_ids,
1375 .probe = snd_intel8x0m_probe, 1331 .probe = snd_intel8x0m_probe,
1376 .remove = __devexit_p(snd_intel8x0m_remove), 1332 .remove = __devexit_p(snd_intel8x0m_remove),
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index d2aa9c82d41e..09f9cbe116a3 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2220,7 +2220,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
2220 if ((err = pci_enable_device(pci)) < 0) 2220 if ((err = pci_enable_device(pci)) < 0)
2221 return err; 2221 return err;
2222 2222
2223 korg1212 = kcalloc(1, sizeof(*korg1212), GFP_KERNEL); 2223 korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL);
2224 if (korg1212 == NULL) { 2224 if (korg1212 == NULL) {
2225 pci_disable_device(pci); 2225 pci_disable_device(pci);
2226 return -ENOMEM; 2226 return -ENOMEM;
@@ -2534,6 +2534,7 @@ static void __devexit snd_korg1212_remove(struct pci_dev *pci)
2534 2534
2535static struct pci_driver driver = { 2535static struct pci_driver driver = {
2536 .name = "korg1212", 2536 .name = "korg1212",
2537 .owner = THIS_MODULE,
2537 .id_table = snd_korg1212_ids, 2538 .id_table = snd_korg1212_ids,
2538 .probe = snd_korg1212_probe, 2539 .probe = snd_korg1212_probe,
2539 .remove = __devexit_p(snd_korg1212_remove), 2540 .remove = __devexit_p(snd_korg1212_remove),
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 39b5e7db1543..2693b6f731f3 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -872,35 +872,6 @@ struct snd_m3 {
872/* 872/*
873 * pci ids 873 * pci ids
874 */ 874 */
875
876#ifndef PCI_VENDOR_ID_ESS
877#define PCI_VENDOR_ID_ESS 0x125D
878#endif
879#ifndef PCI_DEVICE_ID_ESS_ALLEGRO_1
880#define PCI_DEVICE_ID_ESS_ALLEGRO_1 0x1988
881#endif
882#ifndef PCI_DEVICE_ID_ESS_ALLEGRO
883#define PCI_DEVICE_ID_ESS_ALLEGRO 0x1989
884#endif
885#ifndef PCI_DEVICE_ID_ESS_CANYON3D_2LE
886#define PCI_DEVICE_ID_ESS_CANYON3D_2LE 0x1990
887#endif
888#ifndef PCI_DEVICE_ID_ESS_CANYON3D_2
889#define PCI_DEVICE_ID_ESS_CANYON3D_2 0x1992
890#endif
891#ifndef PCI_DEVICE_ID_ESS_MAESTRO3
892#define PCI_DEVICE_ID_ESS_MAESTRO3 0x1998
893#endif
894#ifndef PCI_DEVICE_ID_ESS_MAESTRO3_1
895#define PCI_DEVICE_ID_ESS_MAESTRO3_1 0x1999
896#endif
897#ifndef PCI_DEVICE_ID_ESS_MAESTRO3_HW
898#define PCI_DEVICE_ID_ESS_MAESTRO3_HW 0x199a
899#endif
900#ifndef PCI_DEVICE_ID_ESS_MAESTRO3_2
901#define PCI_DEVICE_ID_ESS_MAESTRO3_2 0x199b
902#endif
903
904static struct pci_device_id snd_m3_ids[] = { 875static struct pci_device_id snd_m3_ids[] = {
905 {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO_1, PCI_ANY_ID, PCI_ANY_ID, 876 {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO_1, PCI_ANY_ID, PCI_ANY_ID,
906 PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, 877 PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0},
@@ -2689,7 +2660,7 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci,
2689 return -ENXIO; 2660 return -ENXIO;
2690 } 2661 }
2691 2662
2692 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 2663 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
2693 if (chip == NULL) { 2664 if (chip == NULL) {
2694 pci_disable_device(pci); 2665 pci_disable_device(pci);
2695 return -ENOMEM; 2666 return -ENOMEM;
@@ -2890,6 +2861,7 @@ static void __devexit snd_m3_remove(struct pci_dev *pci)
2890 2861
2891static struct pci_driver driver = { 2862static struct pci_driver driver = {
2892 .name = "Maestro3", 2863 .name = "Maestro3",
2864 .owner = THIS_MODULE,
2893 .id_table = snd_m3_ids, 2865 .id_table = snd_m3_ids,
2894 .probe = snd_m3_probe, 2866 .probe = snd_m3_probe,
2895 .remove = __devexit_p(snd_m3_remove), 2867 .remove = __devexit_p(snd_m3_remove),
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 6c868d913634..1a62c7f6c52b 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -1004,7 +1004,7 @@ static int __devinit snd_mixart_create(mixart_mgr_t *mgr, snd_card_t *card, int
1004 .dev_free = snd_mixart_chip_dev_free, 1004 .dev_free = snd_mixart_chip_dev_free,
1005 }; 1005 };
1006 1006
1007 mgr->chip[idx] = chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1007 mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1008 if (! chip) { 1008 if (! chip) {
1009 snd_printk(KERN_ERR "cannot allocate chip\n"); 1009 snd_printk(KERN_ERR "cannot allocate chip\n");
1010 return -ENOMEM; 1010 return -ENOMEM;
@@ -1292,7 +1292,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
1292 1292
1293 /* 1293 /*
1294 */ 1294 */
1295 mgr = kcalloc(1, sizeof(*mgr), GFP_KERNEL); 1295 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
1296 if (! mgr) { 1296 if (! mgr) {
1297 pci_disable_device(pci); 1297 pci_disable_device(pci);
1298 return -ENOMEM; 1298 return -ENOMEM;
@@ -1424,6 +1424,7 @@ static void __devexit snd_mixart_remove(struct pci_dev *pci)
1424 1424
1425static struct pci_driver driver = { 1425static struct pci_driver driver = {
1426 .name = "Digigram miXart", 1426 .name = "Digigram miXart",
1427 .owner = THIS_MODULE,
1427 .id_table = snd_mixart_ids, 1428 .id_table = snd_mixart_ids,
1428 .probe = snd_mixart_probe, 1429 .probe = snd_mixart_probe,
1429 .remove = __devexit_p(snd_mixart_remove), 1430 .remove = __devexit_p(snd_mixart_remove),
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 2bbeb10ff7c4..5c55a3b1d121 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -259,21 +259,6 @@ struct snd_nm256 {
259/* 259/*
260 * PCI ids 260 * PCI ids
261 */ 261 */
262
263#ifndef PCI_VENDOR_ID_NEOMAGIC
264#define PCI_VENDOR_ID_NEOMEGIC 0x10c8
265#endif
266#ifndef PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO
267#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005
268#endif
269#ifndef PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO
270#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006
271#endif
272#ifndef PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO
273#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016
274#endif
275
276
277static struct pci_device_id snd_nm256_ids[] = { 262static struct pci_device_id snd_nm256_ids[] = {
278 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 263 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
279 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 264 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -840,7 +825,7 @@ static void snd_nm256_setup_stream(nm256_t *chip, nm256_stream_t *s,
840 runtime->hw = *hw_ptr; 825 runtime->hw = *hw_ptr;
841 runtime->hw.buffer_bytes_max = s->bufsize; 826 runtime->hw.buffer_bytes_max = s->bufsize;
842 runtime->hw.period_bytes_max = s->bufsize / 2; 827 runtime->hw.period_bytes_max = s->bufsize / 2;
843 runtime->dma_area = (void*) s->bufptr; 828 runtime->dma_area = (void __force *) s->bufptr;
844 runtime->dma_addr = s->bufptr_addr; 829 runtime->dma_addr = s->bufptr_addr;
845 runtime->dma_bytes = s->bufsize; 830 runtime->dma_bytes = s->bufsize;
846 runtime->private_data = s; 831 runtime->private_data = s;
@@ -1404,7 +1389,7 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci,
1404 if ((err = pci_enable_device(pci)) < 0) 1389 if ((err = pci_enable_device(pci)) < 0)
1405 return err; 1390 return err;
1406 1391
1407 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1392 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1408 if (chip == NULL) { 1393 if (chip == NULL) {
1409 pci_disable_device(pci); 1394 pci_disable_device(pci);
1410 return -ENOMEM; 1395 return -ENOMEM;
@@ -1683,6 +1668,7 @@ static void __devexit snd_nm256_remove(struct pci_dev *pci)
1683 1668
1684static struct pci_driver driver = { 1669static struct pci_driver driver = {
1685 .name = "NeoMagic 256", 1670 .name = "NeoMagic 256",
1671 .owner = THIS_MODULE,
1686 .id_table = snd_nm256_ids, 1672 .id_table = snd_nm256_ids,
1687 .probe = snd_nm256_probe, 1673 .probe = snd_nm256_probe,
1688 .remove = __devexit_p(snd_nm256_remove), 1674 .remove = __devexit_p(snd_nm256_remove),
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index 456be39e8e4a..3daeecb9eb0e 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -192,20 +192,6 @@ MODULE_SUPPORTED_DEVICE("{{RME,Digi32}," "{RME,Digi32/8}," "{RME,Digi32 PRO}}");
192#define RME32_PRO_REVISION_WITH_8414 150 192#define RME32_PRO_REVISION_WITH_8414 150
193 193
194 194
195/* PCI vendor/device ID's */
196#ifndef PCI_VENDOR_ID_XILINX_RME
197# define PCI_VENDOR_ID_XILINX_RME 0xea60
198#endif
199#ifndef PCI_DEVICE_ID_DIGI32
200# define PCI_DEVICE_ID_DIGI32 0x9896
201#endif
202#ifndef PCI_DEVICE_ID_DIGI32_PRO
203# define PCI_DEVICE_ID_DIGI32_PRO 0x9897
204#endif
205#ifndef PCI_DEVICE_ID_DIGI32_8
206# define PCI_DEVICE_ID_DIGI32_8 0x9898
207#endif
208
209typedef struct snd_rme32 { 195typedef struct snd_rme32 {
210 spinlock_t lock; 196 spinlock_t lock;
211 int irq; 197 int irq;
@@ -692,7 +678,8 @@ snd_rme32_playback_hw_params(snd_pcm_substream_t * substream,
692 if (err < 0) 678 if (err < 0)
693 return err; 679 return err;
694 } else { 680 } else {
695 runtime->dma_area = (void *)(rme32->iobase + RME32_IO_DATA_BUFFER); 681 runtime->dma_area = (void __force *)(rme32->iobase +
682 RME32_IO_DATA_BUFFER);
696 runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER; 683 runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER;
697 runtime->dma_bytes = RME32_BUFFER_SIZE; 684 runtime->dma_bytes = RME32_BUFFER_SIZE;
698 } 685 }
@@ -746,7 +733,8 @@ snd_rme32_capture_hw_params(snd_pcm_substream_t * substream,
746 if (err < 0) 733 if (err < 0)
747 return err; 734 return err;
748 } else { 735 } else {
749 runtime->dma_area = (void *)rme32->iobase + RME32_IO_DATA_BUFFER; 736 runtime->dma_area = (void __force *)rme32->iobase +
737 RME32_IO_DATA_BUFFER;
750 runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER; 738 runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER;
751 runtime->dma_bytes = RME32_BUFFER_SIZE; 739 runtime->dma_bytes = RME32_BUFFER_SIZE;
752 } 740 }
@@ -2024,6 +2012,7 @@ static void __devexit snd_rme32_remove(struct pci_dev *pci)
2024 2012
2025static struct pci_driver driver = { 2013static struct pci_driver driver = {
2026 .name = "RME Digi32", 2014 .name = "RME Digi32",
2015 .owner = THIS_MODULE,
2027 .id_table = snd_rme32_ids, 2016 .id_table = snd_rme32_ids,
2028 .probe = snd_rme32_probe, 2017 .probe = snd_rme32_probe,
2029 .remove = __devexit_p(snd_rme32_remove), 2018 .remove = __devexit_p(snd_rme32_remove),
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index 9645e9004a48..9983b66dc564 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -200,25 +200,6 @@ MODULE_PARM_DESC(enable, "Enable RME Digi96 soundcard.");
200#define RME96_AD1852_VOL_BITS 14 200#define RME96_AD1852_VOL_BITS 14
201#define RME96_AD1855_VOL_BITS 10 201#define RME96_AD1855_VOL_BITS 10
202 202
203/*
204 * PCI vendor/device ids, could in the future be defined in <linux/pci.h>,
205 * therefore #ifndef is used.
206 */
207#ifndef PCI_VENDOR_ID_XILINX
208#define PCI_VENDOR_ID_XILINX 0x10ee
209#endif
210#ifndef PCI_DEVICE_ID_DIGI96
211#define PCI_DEVICE_ID_DIGI96 0x3fc0
212#endif
213#ifndef PCI_DEVICE_ID_DIGI96_8
214#define PCI_DEVICE_ID_DIGI96_8 0x3fc1
215#endif
216#ifndef PCI_DEVICE_ID_DIGI96_8_PRO
217#define PCI_DEVICE_ID_DIGI96_8_PRO 0x3fc2
218#endif
219#ifndef PCI_DEVICE_ID_DIGI96_8_PAD_OR_PST
220#define PCI_DEVICE_ID_DIGI96_8_PAD_OR_PST 0x3fc3
221#endif
222 203
223typedef struct snd_rme96 { 204typedef struct snd_rme96 {
224 spinlock_t lock; 205 spinlock_t lock;
@@ -985,7 +966,8 @@ snd_rme96_playback_hw_params(snd_pcm_substream_t *substream,
985 snd_pcm_runtime_t *runtime = substream->runtime; 966 snd_pcm_runtime_t *runtime = substream->runtime;
986 int err, rate, dummy; 967 int err, rate, dummy;
987 968
988 runtime->dma_area = (void *)(rme96->iobase + RME96_IO_PLAY_BUFFER); 969 runtime->dma_area = (void __force *)(rme96->iobase +
970 RME96_IO_PLAY_BUFFER);
989 runtime->dma_addr = rme96->port + RME96_IO_PLAY_BUFFER; 971 runtime->dma_addr = rme96->port + RME96_IO_PLAY_BUFFER;
990 runtime->dma_bytes = RME96_BUFFER_SIZE; 972 runtime->dma_bytes = RME96_BUFFER_SIZE;
991 973
@@ -1037,7 +1019,8 @@ snd_rme96_capture_hw_params(snd_pcm_substream_t *substream,
1037 snd_pcm_runtime_t *runtime = substream->runtime; 1019 snd_pcm_runtime_t *runtime = substream->runtime;
1038 int err, isadat, rate; 1020 int err, isadat, rate;
1039 1021
1040 runtime->dma_area = (void *)(rme96->iobase + RME96_IO_REC_BUFFER); 1022 runtime->dma_area = (void __force *)(rme96->iobase +
1023 RME96_IO_REC_BUFFER);
1041 runtime->dma_addr = rme96->port + RME96_IO_REC_BUFFER; 1024 runtime->dma_addr = rme96->port + RME96_IO_REC_BUFFER;
1042 runtime->dma_bytes = RME96_BUFFER_SIZE; 1025 runtime->dma_bytes = RME96_BUFFER_SIZE;
1043 1026
@@ -2430,6 +2413,7 @@ static void __devexit snd_rme96_remove(struct pci_dev *pci)
2430 2413
2431static struct pci_driver driver = { 2414static struct pci_driver driver = {
2432 .name = "RME Digi96", 2415 .name = "RME Digi96",
2416 .owner = THIS_MODULE,
2433 .id_table = snd_rme96_ids, 2417 .id_table = snd_rme96_ids,
2434 .probe = snd_rme96_probe, 2418 .probe = snd_rme96_probe,
2435 .remove = __devexit_p(snd_rme96_remove), 2419 .remove = __devexit_p(snd_rme96_remove),
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 6694866089b5..52525eb198c7 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -370,13 +370,6 @@ MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
370#define UNITY_GAIN 32768 370#define UNITY_GAIN 32768
371#define MINUS_INFINITY_GAIN 0 371#define MINUS_INFINITY_GAIN 0
372 372
373#ifndef PCI_VENDOR_ID_XILINX
374#define PCI_VENDOR_ID_XILINX 0x10ee
375#endif
376#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP
377#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5
378#endif
379
380/* the size of a substream (1 mono data stream) */ 373/* the size of a substream (1 mono data stream) */
381 374
382#define HDSP_CHANNEL_BUFFER_SAMPLES (16*1024) 375#define HDSP_CHANNEL_BUFFER_SAMPLES (16*1024)
@@ -4899,6 +4892,7 @@ static int snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp)
4899 } 4892 }
4900 4893
4901 if (!(hdsp->state & HDSP_InitializationComplete)) { 4894 if (!(hdsp->state & HDSP_InitializationComplete)) {
4895 strcpy(card->shortname, "Hammerfall DSP");
4902 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, 4896 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name,
4903 hdsp->port, hdsp->irq); 4897 hdsp->port, hdsp->irq);
4904 4898
@@ -5222,6 +5216,7 @@ static void __devexit snd_hdsp_remove(struct pci_dev *pci)
5222 5216
5223static struct pci_driver driver = { 5217static struct pci_driver driver = {
5224 .name = "RME Hammerfall DSP", 5218 .name = "RME Hammerfall DSP",
5219 .owner = THIS_MODULE,
5225 .id_table = snd_hdsp_ids, 5220 .id_table = snd_hdsp_ids,
5226 .probe = snd_hdsp_probe, 5221 .probe = snd_hdsp_probe,
5227 .remove = __devexit_p(snd_hdsp_remove), 5222 .remove = __devexit_p(snd_hdsp_remove),
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 5d786d113b25..fc3f3283ff37 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -301,18 +301,6 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
301#define UNITY_GAIN 32768 /* = 65536/2 */ 301#define UNITY_GAIN 32768 /* = 65536/2 */
302#define MINUS_INFINITY_GAIN 0 302#define MINUS_INFINITY_GAIN 0
303 303
304/* PCI info */
305#ifndef PCI_VENDOR_ID_XILINX
306#define PCI_VENDOR_ID_XILINX 0x10ee
307#endif
308#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP
309#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5
310#endif
311#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI
312#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6
313#endif
314
315
316/* Number of channels for different Speed Modes */ 304/* Number of channels for different Speed Modes */
317#define MADI_SS_CHANNELS 64 305#define MADI_SS_CHANNELS 64
318#define MADI_DS_CHANNELS 32 306#define MADI_DS_CHANNELS 32
@@ -3652,6 +3640,7 @@ static void __devexit snd_hdspm_remove(struct pci_dev *pci)
3652 3640
3653static struct pci_driver driver = { 3641static struct pci_driver driver = {
3654 .name = "RME Hammerfall DSP MADI", 3642 .name = "RME Hammerfall DSP MADI",
3643 .owner = THIS_MODULE,
3655 .id_table = snd_hdspm_ids, 3644 .id_table = snd_hdspm_ids,
3656 .probe = snd_hdspm_probe, 3645 .probe = snd_hdspm_probe,
3657 .remove = __devexit_p(snd_hdspm_remove), 3646 .remove = __devexit_p(snd_hdspm_remove),
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index 8ee4d6fd6ea7..b600f45e1834 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -120,13 +120,6 @@ MODULE_SUPPORTED_DEVICE("{{RME,Hammerfall},"
120 120
121#define RME9652_REV15_buf_pos(x) ((((x)&0xE0000000)>>26)|((x)&RME9652_buf_pos)) 121#define RME9652_REV15_buf_pos(x) ((((x)&0xE0000000)>>26)|((x)&RME9652_buf_pos))
122 122
123#ifndef PCI_VENDOR_ID_XILINX
124#define PCI_VENDOR_ID_XILINX 0x10ee
125#endif
126#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL
127#define PCI_DEVICE_ID_XILINX_HAMMERFALL 0x3fc4
128#endif
129
130/* amount of io space we remap for register access. i'm not sure we 123/* amount of io space we remap for register access. i'm not sure we
131 even need this much, but 1K is nice round number :) 124 even need this much, but 1K is nice round number :)
132*/ 125*/
@@ -2661,6 +2654,7 @@ static void __devexit snd_rme9652_remove(struct pci_dev *pci)
2661 2654
2662static struct pci_driver driver = { 2655static struct pci_driver driver = {
2663 .name = "RME Digi9652 (Hammerfall)", 2656 .name = "RME Digi9652 (Hammerfall)",
2657 .owner = THIS_MODULE,
2664 .id_table = snd_rme9652_ids, 2658 .id_table = snd_rme9652_ids,
2665 .probe = snd_rme9652_probe, 2659 .probe = snd_rme9652_probe,
2666 .remove = __devexit_p(snd_rme9652_remove), 2660 .remove = __devexit_p(snd_rme9652_remove),
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index 60ecb2bdb65e..1f6c2bfd43fd 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -50,13 +50,6 @@ MODULE_SUPPORTED_DEVICE("{{S3,SonicVibes PCI}}");
50#define SUPPORT_JOYSTICK 1 50#define SUPPORT_JOYSTICK 1
51#endif 51#endif
52 52
53#ifndef PCI_VENDOR_ID_S3
54#define PCI_VENDOR_ID_S3 0x5333
55#endif
56#ifndef PCI_DEVICE_ID_S3_SONICVIBES
57#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00
58#endif
59
60static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
61static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
62static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 55static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
@@ -1257,7 +1250,7 @@ static int __devinit snd_sonicvibes_create(snd_card_t * card,
1257 return -ENXIO; 1250 return -ENXIO;
1258 } 1251 }
1259 1252
1260 sonic = kcalloc(1, sizeof(*sonic), GFP_KERNEL); 1253 sonic = kzalloc(sizeof(*sonic), GFP_KERNEL);
1261 if (sonic == NULL) { 1254 if (sonic == NULL) {
1262 pci_disable_device(pci); 1255 pci_disable_device(pci);
1263 return -ENOMEM; 1256 return -ENOMEM;
@@ -1515,6 +1508,7 @@ static void __devexit snd_sonic_remove(struct pci_dev *pci)
1515 1508
1516static struct pci_driver driver = { 1509static struct pci_driver driver = {
1517 .name = "S3 SonicVibes", 1510 .name = "S3 SonicVibes",
1511 .owner = THIS_MODULE,
1518 .id_table = snd_sonic_ids, 1512 .id_table = snd_sonic_ids,
1519 .probe = snd_sonic_probe, 1513 .probe = snd_sonic_probe,
1520 .remove = __devexit_p(snd_sonic_remove), 1514 .remove = __devexit_p(snd_sonic_remove),
diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c
index 940d531575c0..a8ca8e17853f 100644
--- a/sound/pci/trident/trident.c
+++ b/sound/pci/trident/trident.c
@@ -177,6 +177,7 @@ static void __devexit snd_trident_remove(struct pci_dev *pci)
177 177
178static struct pci_driver driver = { 178static struct pci_driver driver = {
179 .name = "Trident4DWaveAudio", 179 .name = "Trident4DWaveAudio",
180 .owner = THIS_MODULE,
180 .id_table = snd_trident_ids, 181 .id_table = snd_trident_ids,
181 .probe = snd_trident_probe, 182 .probe = snd_trident_probe,
182 .remove = __devexit_p(snd_trident_remove), 183 .remove = __devexit_p(snd_trident_remove),
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index f30d9d947862..777da9a7298b 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -2960,7 +2960,7 @@ static int __devinit snd_trident_mixer(trident_t * trident, int pcm_spdif_device
2960 .read = snd_trident_codec_read, 2960 .read = snd_trident_codec_read,
2961 }; 2961 };
2962 2962
2963 uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); 2963 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
2964 if (!uctl) 2964 if (!uctl)
2965 return -ENOMEM; 2965 return -ENOMEM;
2966 2966
@@ -3546,7 +3546,7 @@ int __devinit snd_trident_create(snd_card_t * card,
3546 return -ENXIO; 3546 return -ENXIO;
3547 } 3547 }
3548 3548
3549 trident = kcalloc(1, sizeof(*trident), GFP_KERNEL); 3549 trident = kzalloc(sizeof(*trident), GFP_KERNEL);
3550 if (trident == NULL) { 3550 if (trident == NULL) {
3551 pci_disable_device(pci); 3551 pci_disable_device(pci);
3552 return -ENOMEM; 3552 return -ENOMEM;
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 56c6e52d7264..6db7de6b9719 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -104,14 +104,6 @@ module_param_array(dxs_support, int, NULL, 0444);
104MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); 104MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)");
105 105
106 106
107/* pci ids */
108#ifndef PCI_DEVICE_ID_VIA_82C686_5
109#define PCI_DEVICE_ID_VIA_82C686_5 0x3058
110#endif
111#ifndef PCI_DEVICE_ID_VIA_8233_5
112#define PCI_DEVICE_ID_VIA_8233_5 0x3059
113#endif
114
115/* revision numbers for via686 */ 107/* revision numbers for via686 */
116#define VIA_REV_686_A 0x10 108#define VIA_REV_686_A 0x10
117#define VIA_REV_686_B 0x11 109#define VIA_REV_686_B 0x11
@@ -1935,11 +1927,12 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
1935 * DXS channels don't work properly with VRA if MC97 is disabled. 1927 * DXS channels don't work properly with VRA if MC97 is disabled.
1936 */ 1928 */
1937 struct pci_dev *pci; 1929 struct pci_dev *pci;
1938 pci = pci_find_device(0x1106, 0x3068, NULL); /* MC97 */ 1930 pci = pci_get_device(0x1106, 0x3068, NULL); /* MC97 */
1939 if (pci) { 1931 if (pci) {
1940 unsigned char data; 1932 unsigned char data;
1941 pci_read_config_byte(pci, 0x44, &data); 1933 pci_read_config_byte(pci, 0x44, &data);
1942 pci_write_config_byte(pci, 0x44, data | 0x40); 1934 pci_write_config_byte(pci, 0x44, data | 0x40);
1935 pci_dev_put(pci);
1943 } 1936 }
1944 } 1937 }
1945 1938
@@ -2065,7 +2058,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
2065 if ((err = pci_enable_device(pci)) < 0) 2058 if ((err = pci_enable_device(pci)) < 0)
2066 return err; 2059 return err;
2067 2060
2068 if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL) { 2061 if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) {
2069 pci_disable_device(pci); 2062 pci_disable_device(pci);
2070 return -ENOMEM; 2063 return -ENOMEM;
2071 } 2064 }
@@ -2350,6 +2343,7 @@ static void __devexit snd_via82xx_remove(struct pci_dev *pci)
2350 2343
2351static struct pci_driver driver = { 2344static struct pci_driver driver = {
2352 .name = "VIA 82xx Audio", 2345 .name = "VIA 82xx Audio",
2346 .owner = THIS_MODULE,
2353 .id_table = snd_via82xx_ids, 2347 .id_table = snd_via82xx_ids,
2354 .probe = snd_via82xx_probe, 2348 .probe = snd_via82xx_probe,
2355 .remove = __devexit_p(snd_via82xx_remove), 2349 .remove = __devexit_p(snd_via82xx_remove),
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 5872d438a04a..7eac6f6ac737 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -1083,7 +1083,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
1083 if ((err = pci_enable_device(pci)) < 0) 1083 if ((err = pci_enable_device(pci)) < 0)
1084 return err; 1084 return err;
1085 1085
1086 if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL) { 1086 if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) {
1087 pci_disable_device(pci); 1087 pci_disable_device(pci);
1088 return -ENOMEM; 1088 return -ENOMEM;
1089 } 1089 }
@@ -1207,6 +1207,7 @@ static void __devexit snd_via82xx_remove(struct pci_dev *pci)
1207 1207
1208static struct pci_driver driver = { 1208static struct pci_driver driver = {
1209 .name = "VIA 82xx Modem", 1209 .name = "VIA 82xx Modem",
1210 .owner = THIS_MODULE,
1210 .id_table = snd_via82xx_modem_ids, 1211 .id_table = snd_via82xx_modem_ids,
1211 .probe = snd_via82xx_probe, 1212 .probe = snd_via82xx_probe,
1212 .remove = __devexit_p(snd_via82xx_remove), 1213 .remove = __devexit_p(snd_via82xx_remove),
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c
index dca6bd2c7580..2a7ad9dec021 100644
--- a/sound/pci/vx222/vx222.c
+++ b/sound/pci/vx222/vx222.c
@@ -252,6 +252,7 @@ static void __devexit snd_vx222_remove(struct pci_dev *pci)
252 252
253static struct pci_driver driver = { 253static struct pci_driver driver = {
254 .name = "Digigram VX222", 254 .name = "Digigram VX222",
255 .owner = THIS_MODULE,
255 .id_table = snd_vx222_ids, 256 .id_table = snd_vx222_ids,
256 .probe = snd_vx222_probe, 257 .probe = snd_vx222_probe,
257 .remove = __devexit_p(snd_vx222_remove), 258 .remove = __devexit_p(snd_vx222_remove),
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
index 5b5b624b47d0..2e69abe51aa9 100644
--- a/sound/pci/ymfpci/ymfpci.c
+++ b/sound/pci/ymfpci/ymfpci.c
@@ -352,6 +352,7 @@ static void __devexit snd_card_ymfpci_remove(struct pci_dev *pci)
352 352
353static struct pci_driver driver = { 353static struct pci_driver driver = {
354 .name = "Yamaha DS-XG PCI", 354 .name = "Yamaha DS-XG PCI",
355 .owner = THIS_MODULE,
355 .id_table = snd_ymfpci_ids, 356 .id_table = snd_ymfpci_ids,
356 .probe = snd_card_ymfpci_probe, 357 .probe = snd_card_ymfpci_probe,
357 .remove = __devexit_p(snd_card_ymfpci_remove), 358 .remove = __devexit_p(snd_card_ymfpci_remove),
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 054836412dc4..27fa523639ae 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -839,7 +839,7 @@ static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream)
839 snd_pcm_runtime_t *runtime = substream->runtime; 839 snd_pcm_runtime_t *runtime = substream->runtime;
840 ymfpci_pcm_t *ypcm; 840 ymfpci_pcm_t *ypcm;
841 841
842 ypcm = kcalloc(1, sizeof(*ypcm), GFP_KERNEL); 842 ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL);
843 if (ypcm == NULL) 843 if (ypcm == NULL)
844 return -ENOMEM; 844 return -ENOMEM;
845 ypcm->chip = chip; 845 ypcm->chip = chip;
@@ -957,7 +957,7 @@ static int snd_ymfpci_capture_open(snd_pcm_substream_t * substream,
957 snd_pcm_runtime_t *runtime = substream->runtime; 957 snd_pcm_runtime_t *runtime = substream->runtime;
958 ymfpci_pcm_t *ypcm; 958 ymfpci_pcm_t *ypcm;
959 959
960 ypcm = kcalloc(1, sizeof(*ypcm), GFP_KERNEL); 960 ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL);
961 if (ypcm == NULL) 961 if (ypcm == NULL)
962 return -ENOMEM; 962 return -ENOMEM;
963 ypcm->chip = chip; 963 ypcm->chip = chip;
@@ -2270,7 +2270,7 @@ int __devinit snd_ymfpci_create(snd_card_t * card,
2270 if ((err = pci_enable_device(pci)) < 0) 2270 if ((err = pci_enable_device(pci)) < 0)
2271 return err; 2271 return err;
2272 2272
2273 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 2273 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
2274 if (chip == NULL) { 2274 if (chip == NULL) {
2275 pci_disable_device(pci); 2275 pci_disable_device(pci);
2276 return -ENOMEM; 2276 return -ENOMEM;
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
index a2132e3763dd..0208c54896b3 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
@@ -151,7 +151,7 @@ pdacf_t *snd_pdacf_create(snd_card_t *card)
151{ 151{
152 pdacf_t *chip; 152 pdacf_t *chip;
153 153
154 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 154 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
155 if (chip == NULL) 155 if (chip == NULL)
156 return NULL; 156 return NULL;
157 chip->card = card; 157 chip->card = card;
diff --git a/sound/ppc/Kconfig b/sound/ppc/Kconfig
index 75213bf4d567..206b9333f91f 100644
--- a/sound/ppc/Kconfig
+++ b/sound/ppc/Kconfig
@@ -13,11 +13,24 @@ config SND_POWERMAC
13 tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)" 13 tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)"
14 depends on SND && I2C && INPUT && PPC_PMAC 14 depends on SND && I2C && INPUT && PPC_PMAC
15 select SND_PCM 15 select SND_PCM
16 select SND_GENERIC_DRIVER
16 help 17 help
17 Say Y here to include support for the integrated sound device. 18 Say Y here to include support for the integrated sound device.
18 19
19 To compile this driver as a module, choose M here: the module 20 To compile this driver as a module, choose M here: the module
20 will be called snd-powermac. 21 will be called snd-powermac.
21 22
22endmenu 23config SND_POWERMAC_AUTO_DRC
24 bool "Toggle DRC automatically at headphone/line plug-in"
25 depends on SND_POWERMAC
26 default y
27 help
28 Say Y here to enable the automatic toggle of DRC (dynamic
29 range compression) on Tumbler/Snapper.
30 If this feature is enabled, DRC is turned off when the
31 headphone/line jack is plugged, and turned on when unplugged.
23 32
33 Note that you can turn on/off DRC manually even without this
34 option.
35
36endmenu
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index c89e82eb06a6..e35b48d29c45 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -988,6 +988,7 @@ static int __init snd_pmac_detect(pmac_t *chip)
988 case 0x33: 988 case 0x33:
989 case 0x29: 989 case 0x29:
990 case 0x24: 990 case 0x24:
991 case 0x5c:
991 chip->num_freqs = ARRAY_SIZE(tumbler_freqs); 992 chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
992 chip->model = PMAC_SNAPPER; 993 chip->model = PMAC_SNAPPER;
993 chip->can_byte_swap = 0; /* FIXME: check this */ 994 chip->can_byte_swap = 0; /* FIXME: check this */
@@ -1159,7 +1160,7 @@ int __init snd_pmac_new(snd_card_t *card, pmac_t **chip_return)
1159 snd_runtime_check(chip_return, return -EINVAL); 1160 snd_runtime_check(chip_return, return -EINVAL);
1160 *chip_return = NULL; 1161 *chip_return = NULL;
1161 1162
1162 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1163 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1163 if (chip == NULL) 1164 if (chip == NULL)
1164 return -ENOMEM; 1165 return -ENOMEM;
1165 chip->card = card; 1166 chip->card = card;
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
index 231f6432ea6d..a6d8cbf4064f 100644
--- a/sound/ppc/powermac.c
+++ b/sound/ppc/powermac.c
@@ -131,6 +131,9 @@ static int __init snd_pmac_probe(void)
131 if (enable_beep) 131 if (enable_beep)
132 snd_pmac_attach_beep(chip); 132 snd_pmac_attach_beep(chip);
133 133
134 if ((err = snd_card_set_generic_dev(card)) < 0)
135 goto __error;
136
134 if ((err = snd_card_register(card)) < 0) 137 if ((err = snd_card_register(card)) < 0)
135 goto __error; 138 goto __error;
136 139
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index b94437c024b1..65384afcfc3f 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -948,7 +948,6 @@ static void device_change_handler(void *self)
948 msleep(10); 948 msleep(10);
949 check_mute(chip, &mix->amp_mute, 1, mix->auto_mute_notify, 949 check_mute(chip, &mix->amp_mute, 1, mix->auto_mute_notify,
950 chip->speaker_sw_ctl); 950 chip->speaker_sw_ctl);
951 mix->drc_enable = 0;
952 } else { 951 } else {
953 /* unmute speaker, mute others */ 952 /* unmute speaker, mute others */
954 check_mute(chip, &mix->amp_mute, 0, mix->auto_mute_notify, 953 check_mute(chip, &mix->amp_mute, 0, mix->auto_mute_notify,
@@ -960,20 +959,21 @@ static void device_change_handler(void *self)
960 if (mix->line_mute.addr != 0) 959 if (mix->line_mute.addr != 0)
961 check_mute(chip, &mix->line_mute, 1, mix->auto_mute_notify, 960 check_mute(chip, &mix->line_mute, 1, mix->auto_mute_notify,
962 chip->lineout_sw_ctl); 961 chip->lineout_sw_ctl);
963 mix->drc_enable = 1;
964 } 962 }
965 if (mix->auto_mute_notify) { 963 if (mix->auto_mute_notify)
966 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, 964 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
967 &chip->hp_detect_ctl->id); 965 &chip->hp_detect_ctl->id);
966
967#ifdef CONFIG_SND_POWERMAC_AUTO_DRC
968 mix->drc_enable = ! (headphone || lineout);
969 if (mix->auto_mute_notify)
968 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, 970 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
969 &chip->drc_sw_ctl->id); 971 &chip->drc_sw_ctl->id);
970 }
971
972 /* first set the DRC so the speaker do not explode -ReneR */
973 if (chip->model == PMAC_TUMBLER) 972 if (chip->model == PMAC_TUMBLER)
974 tumbler_set_drc(mix); 973 tumbler_set_drc(mix);
975 else 974 else
976 snapper_set_drc(mix); 975 snapper_set_drc(mix);
976#endif
977 977
978 /* reset the master volume so the correct amplification is applied */ 978 /* reset the master volume so the correct amplification is applied */
979 tumbler_set_master_volume(mix); 979 tumbler_set_master_volume(mix);
@@ -1370,6 +1370,17 @@ int __init snd_pmac_tumbler_init(pmac_t *chip)
1370 if ((err = snd_ctl_add(chip->card, chip->drc_sw_ctl)) < 0) 1370 if ((err = snd_ctl_add(chip->card, chip->drc_sw_ctl)) < 0)
1371 return err; 1371 return err;
1372 1372
1373 /* set initial DRC range to 60% */
1374 if (chip->model == PMAC_TUMBLER)
1375 mix->drc_range = (TAS3001_DRC_MAX * 6) / 10;
1376 else
1377 mix->drc_range = (TAS3004_DRC_MAX * 6) / 10;
1378 mix->drc_enable = 1; /* will be changed later if AUTO_DRC is set */
1379 if (chip->model == PMAC_TUMBLER)
1380 tumbler_set_drc(mix);
1381 else
1382 snapper_set_drc(mix);
1383
1373#ifdef CONFIG_PM 1384#ifdef CONFIG_PM
1374 chip->suspend = tumbler_suspend; 1385 chip->suspend = tumbler_suspend;
1375 chip->resume = tumbler_resume; 1386 chip->resume = tumbler_resume;
diff --git a/sound/sparc/Kconfig b/sound/sparc/Kconfig
index 25a8a558ef92..09ab138646a6 100644
--- a/sound/sparc/Kconfig
+++ b/sound/sparc/Kconfig
@@ -7,6 +7,7 @@ config SND_SUN_AMD7930
7 tristate "Sun AMD7930" 7 tristate "Sun AMD7930"
8 depends on SBUS && SND 8 depends on SBUS && SND
9 select SND_PCM 9 select SND_PCM
10 select SND_GENERIC_DRIVER
10 help 11 help
11 Say Y here to include support for AMD7930 sound device on Sun. 12 Say Y here to include support for AMD7930 sound device on Sun.
12 13
@@ -17,6 +18,7 @@ config SND_SUN_CS4231
17 tristate "Sun CS4231" 18 tristate "Sun CS4231"
18 depends on SND 19 depends on SND
19 select SND_PCM 20 select SND_PCM
21 select SND_GENERIC_DRIVER
20 help 22 help
21 Say Y here to include support for CS4231 sound device on Sun. 23 Say Y here to include support for CS4231 sound device on Sun.
22 24
@@ -27,6 +29,7 @@ config SND_SUN_DBRI
27 tristate "Sun DBRI" 29 tristate "Sun DBRI"
28 depends on SND && SBUS 30 depends on SND && SBUS
29 select SND_PCM 31 select SND_PCM
32 select SND_GENERIC_DRIVER
30 help 33 help
31 Say Y here to include support for DBRI sound device on Sun. 34 Say Y here to include support for DBRI sound device on Sun.
32 35
diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c
index bd8a850e93ea..46d504ba7e03 100644
--- a/sound/sparc/amd7930.c
+++ b/sound/sparc/amd7930.c
@@ -967,7 +967,7 @@ static int __init snd_amd7930_create(snd_card_t *card,
967 int err; 967 int err;
968 968
969 *ramd = NULL; 969 *ramd = NULL;
970 amd = kcalloc(1, sizeof(*amd), GFP_KERNEL); 970 amd = kzalloc(sizeof(*amd), GFP_KERNEL);
971 if (amd == NULL) 971 if (amd == NULL)
972 return -ENOMEM; 972 return -ENOMEM;
973 973
@@ -1088,6 +1088,9 @@ static int __init amd7930_attach(int prom_node, struct sbus_dev *sdev)
1088 if ((err = snd_amd7930_mixer(amd)) < 0) 1088 if ((err = snd_amd7930_mixer(amd)) < 0)
1089 goto out_err; 1089 goto out_err;
1090 1090
1091 if ((err = snd_card_set_generic_dev(card)) < 0)
1092 goto out_err;
1093
1091 if ((err = snd_card_register(card)) < 0) 1094 if ((err = snd_card_register(card)) < 0)
1092 goto out_err; 1095 goto out_err;
1093 1096
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index 36f9fe4d7bea..2fb27c4e951f 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -1915,6 +1915,9 @@ static int cs4231_attach_finish(snd_card_t *card, cs4231_t *chip)
1915 if ((err = snd_cs4231_timer(chip)) < 0) 1915 if ((err = snd_cs4231_timer(chip)) < 0)
1916 goto out_err; 1916 goto out_err;
1917 1917
1918 if ((err = snd_card_set_generic_dev(card)) < 0)
1919 goto out_err;
1920
1918 if ((err = snd_card_register(card)) < 0) 1921 if ((err = snd_card_register(card)) < 0)
1919 goto out_err; 1922 goto out_err;
1920 1923
@@ -1966,7 +1969,7 @@ static int __init snd_cs4231_sbus_create(snd_card_t *card,
1966 int err; 1969 int err;
1967 1970
1968 *rchip = NULL; 1971 *rchip = NULL;
1969 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1972 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1970 if (chip == NULL) 1973 if (chip == NULL)
1971 return -ENOMEM; 1974 return -ENOMEM;
1972 1975
@@ -2080,7 +2083,7 @@ static int __init snd_cs4231_ebus_create(snd_card_t *card,
2080 int err; 2083 int err;
2081 2084
2082 *rchip = NULL; 2085 *rchip = NULL;
2083 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 2086 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
2084 if (chip == NULL) 2087 if (chip == NULL)
2085 return -ENOMEM; 2088 return -ENOMEM;
2086 2089
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 941c7b1e7ebb..b5c4c15ae7f0 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Driver for DBRI sound chip found on Sparcs. 2 * Driver for DBRI sound chip found on Sparcs.
3 * Copyright (C) 2004 Martin Habets (mhabets@users.sourceforge.net) 3 * Copyright (C) 2004, 2005 Martin Habets (mhabets@users.sourceforge.net)
4 * 4 *
5 * Based entirely upon drivers/sbus/audio/dbri.c which is: 5 * Based entirely upon drivers/sbus/audio/dbri.c which is:
6 * Copyright (C) 1997 Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de) 6 * Copyright (C) 1997 Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de)
@@ -43,6 +43,12 @@
43 * audio devices. But the SUN HW group decided against it, at least on my 43 * audio devices. But the SUN HW group decided against it, at least on my
44 * LX the speakerbox connector has at least 1 pin missing and 1 wrongly 44 * LX the speakerbox connector has at least 1 pin missing and 1 wrongly
45 * connected. 45 * connected.
46 *
47 * I've tried to stick to the following function naming conventions:
48 * snd_* ALSA stuff
49 * cs4215_* CS4215 codec specfic stuff
50 * dbri_* DBRI high-level stuff
51 * other DBRI low-level stuff
46 */ 52 */
47 53
48#include <sound/driver.h> 54#include <sound/driver.h>
@@ -87,7 +93,7 @@ MODULE_PARM_DESC(enable, "Enable Sun DBRI soundcard.");
87#define D_DESC (1<<5) 93#define D_DESC (1<<5)
88 94
89static int dbri_debug = 0; 95static int dbri_debug = 0;
90module_param(dbri_debug, int, 0444); 96module_param(dbri_debug, int, 0644);
91MODULE_PARM_DESC(dbri_debug, "Debug value for Sun DBRI soundcard."); 97MODULE_PARM_DESC(dbri_debug, "Debug value for Sun DBRI soundcard.");
92 98
93#ifdef DBRI_DEBUG 99#ifdef DBRI_DEBUG
@@ -320,7 +326,8 @@ typedef struct snd_dbri {
320 void __iomem *regs; /* dbri HW regs */ 326 void __iomem *regs; /* dbri HW regs */
321 int dbri_version; /* 'e' and up is OK */ 327 int dbri_version; /* 'e' and up is OK */
322 int dbri_irqp; /* intr queue pointer */ 328 int dbri_irqp; /* intr queue pointer */
323 int wait_seen; 329 int wait_send; /* sequence of command buffers send */
330 int wait_ackd; /* sequence of command buffers acknowledged */
324 331
325 struct dbri_pipe pipes[DBRI_NO_PIPES]; /* DBRI's 32 data pipes */ 332 struct dbri_pipe pipes[DBRI_NO_PIPES]; /* DBRI's 32 data pipes */
326 struct dbri_desc descs[DBRI_NO_DESCS]; 333 struct dbri_desc descs[DBRI_NO_DESCS];
@@ -625,16 +632,13 @@ static __u32 reverse_bytes(__u32 b, int len)
625 632
626Commands are sent to the DBRI by building a list of them in memory, 633Commands are sent to the DBRI by building a list of them in memory,
627then writing the address of the first list item to DBRI register 8. 634then writing the address of the first list item to DBRI register 8.
628The list is terminated with a WAIT command, which can generate a 635The list is terminated with a WAIT command, which generates a
629CPU interrupt if required. 636CPU interrupt to signal completion.
630 637
631Since the DBRI can run in parallel with the CPU, several means of 638Since the DBRI can run in parallel with the CPU, several means of
632synchronization present themselves. The original scheme (Rudolf's) 639synchronization present themselves. The method implemented here is close
633was to set a flag when we "cmdlock"ed the DBRI, clear the flag when 640to the original scheme (Rudolf's), and uses 2 counters (wait_send and
634an interrupt signaled completion, and wait on a wait_queue if a routine 641wait_ackd) to synchronize the command buffer between the CPU and the DBRI.
635attempted to cmdlock while the flag was set. The problems arose when
636we tried to cmdlock from inside an interrupt handler, which might
637cause scheduling in an interrupt (if we waited), etc, etc
638 642
639A more sophisticated scheme might involve a circular command buffer 643A more sophisticated scheme might involve a circular command buffer
640or an array of command buffers. A routine could fill one with 644or an array of command buffers. A routine could fill one with
@@ -642,70 +646,75 @@ commands and link it onto a list. When a interrupt signaled
642completion of the current command buffer, look on the list for 646completion of the current command buffer, look on the list for
643the next one. 647the next one.
644 648
645I've decided to implement something much simpler - after each command,
646the CPU waits for the DBRI to finish the command by polling the P bit
647in DBRI register 0. I've tried to implement this in such a way
648that might make implementing a more sophisticated scheme easier.
649
650Every time a routine wants to write commands to the DBRI, it must 649Every time a routine wants to write commands to the DBRI, it must
651first call dbri_cmdlock() and get an initial pointer into dbri->dma->cmd 650first call dbri_cmdlock() and get an initial pointer into dbri->dma->cmd
652in return. After the commands have been writen, dbri_cmdsend() is 651in return. dbri_cmdlock() will block if the previous commands have not
653called with the final pointer value. 652been completed yet. After this the commands can be written to the buffer,
653and dbri_cmdsend() is called with the final pointer value to send them
654to the DBRI.
654 655
655*/ 656*/
656 657
658static void dbri_process_interrupt_buffer(snd_dbri_t * dbri);
659
657enum dbri_lock_t { NoGetLock, GetLock }; 660enum dbri_lock_t { NoGetLock, GetLock };
661#define MAXLOOPS 10
658 662
659static volatile s32 *dbri_cmdlock(snd_dbri_t * dbri, enum dbri_lock_t get) 663static volatile s32 *dbri_cmdlock(snd_dbri_t * dbri, enum dbri_lock_t get)
660{ 664{
665 int maxloops = MAXLOOPS;
666
661#ifndef SMP 667#ifndef SMP
662 if ((get == GetLock) && spin_is_locked(&dbri->lock)) { 668 if ((get == GetLock) && spin_is_locked(&dbri->lock)) {
663 printk(KERN_ERR "DBRI: cmdlock called while in spinlock."); 669 printk(KERN_ERR "DBRI: cmdlock called while in spinlock.");
664 } 670 }
665#endif 671#endif
666 672
673 /* Delay if previous commands are still being processed */
674 while ((--maxloops) > 0 && (dbri->wait_send != dbri->wait_ackd)) {
675 msleep_interruptible(1);
676 /* If dbri_cmdlock() got called from inside the
677 * interrupt handler, this will do the processing.
678 */
679 dbri_process_interrupt_buffer(dbri);
680 }
681 if (maxloops == 0) {
682 printk(KERN_ERR "DBRI: Chip never completed command buffer %d\n",
683 dbri->wait_send);
684 } else {
685 dprintk(D_CMD, "Chip completed command buffer (%d)\n",
686 MAXLOOPS - maxloops - 1);
687 }
688
667 /*if (get == GetLock) spin_lock(&dbri->lock); */ 689 /*if (get == GetLock) spin_lock(&dbri->lock); */
668 return &dbri->dma->cmd[0]; 690 return &dbri->dma->cmd[0];
669} 691}
670 692
671static void dbri_process_interrupt_buffer(snd_dbri_t *);
672
673static void dbri_cmdsend(snd_dbri_t * dbri, volatile s32 * cmd) 693static void dbri_cmdsend(snd_dbri_t * dbri, volatile s32 * cmd)
674{ 694{
675 int MAXLOOPS = 1000000;
676 int maxloops = MAXLOOPS;
677 volatile s32 *ptr; 695 volatile s32 *ptr;
696 u32 reg;
678 697
679 for (ptr = &dbri->dma->cmd[0]; ptr < cmd; ptr++) { 698 for (ptr = &dbri->dma->cmd[0]; ptr < cmd; ptr++) {
680 dprintk(D_CMD, "cmd: %lx:%08x\n", (unsigned long)ptr, *ptr); 699 dprintk(D_CMD, "cmd: %lx:%08x\n", (unsigned long)ptr, *ptr);
681 } 700 }
682 701
683 if ((cmd - &dbri->dma->cmd[0]) >= DBRI_NO_CMDS - 1) { 702 if ((cmd - &dbri->dma->cmd[0]) >= DBRI_NO_CMDS - 1) {
684 printk("DBRI: Command buffer overflow! (bug in driver)\n"); 703 printk(KERN_ERR "DBRI: Command buffer overflow! (bug in driver)\n");
685 /* Ignore the last part. */ 704 /* Ignore the last part. */
686 cmd = &dbri->dma->cmd[DBRI_NO_CMDS - 3]; 705 cmd = &dbri->dma->cmd[DBRI_NO_CMDS - 3];
687 } 706 }
688 707
708 dbri->wait_send++;
709 dbri->wait_send &= 0xffff; /* restrict it to a 16 bit counter. */
689 *(cmd++) = DBRI_CMD(D_PAUSE, 0, 0); 710 *(cmd++) = DBRI_CMD(D_PAUSE, 0, 0);
690 *(cmd++) = DBRI_CMD(D_WAIT, 1, 0); 711 *(cmd++) = DBRI_CMD(D_WAIT, 1, dbri->wait_send);
691 dbri->wait_seen = 0; 712
713 /* Set command pointer and signal it is valid. */
692 sbus_writel(dbri->dma_dvma, dbri->regs + REG8); 714 sbus_writel(dbri->dma_dvma, dbri->regs + REG8);
693 while ((--maxloops) > 0 && (sbus_readl(dbri->regs + REG0) & D_P)) 715 reg = sbus_readl(dbri->regs + REG0);
694 barrier(); 716 reg |= D_P;
695 if (maxloops == 0) { 717 sbus_writel(reg, dbri->regs + REG0);
696 printk(KERN_ERR "DBRI: Chip never completed command buffer\n");
697 dprintk(D_CMD, "DBRI: Chip never completed command buffer\n");
698 } else {
699 while ((--maxloops) > 0 && (!dbri->wait_seen))
700 dbri_process_interrupt_buffer(dbri);
701 if (maxloops == 0) {
702 printk(KERN_ERR "DBRI: Chip never acked WAIT\n");
703 dprintk(D_CMD, "DBRI: Chip never acked WAIT\n");
704 } else {
705 dprintk(D_CMD, "Chip completed command "
706 "buffer (%d)\n", MAXLOOPS - maxloops);
707 }
708 }
709 718
710 /*spin_unlock(&dbri->lock); */ 719 /*spin_unlock(&dbri->lock); */
711} 720}
@@ -757,10 +766,11 @@ static void dbri_initialize(snd_dbri_t * dbri)
757 for (n = 0; n < DBRI_NO_PIPES; n++) 766 for (n = 0; n < DBRI_NO_PIPES; n++)
758 dbri->pipes[n].desc = dbri->pipes[n].first_desc = -1; 767 dbri->pipes[n].desc = dbri->pipes[n].first_desc = -1;
759 768
760 /* We should query the openprom to see what burst sizes this 769 /* A brute approach - DBRI falls back to working burst size by itself
761 * SBus supports. For now, just disable all SBus bursts */ 770 * On SS20 D_S does not work, so do not try so high. */
762 tmp = sbus_readl(dbri->regs + REG0); 771 tmp = sbus_readl(dbri->regs + REG0);
763 tmp &= ~(D_G | D_S | D_E); 772 tmp |= D_G | D_E;
773 tmp &= ~D_S;
764 sbus_writel(tmp, dbri->regs + REG0); 774 sbus_writel(tmp, dbri->regs + REG0);
765 775
766 /* 776 /*
@@ -805,13 +815,13 @@ static void reset_pipe(snd_dbri_t * dbri, int pipe)
805 volatile int *cmd; 815 volatile int *cmd;
806 816
807 if (pipe < 0 || pipe > 31) { 817 if (pipe < 0 || pipe > 31) {
808 printk("DBRI: reset_pipe called with illegal pipe number\n"); 818 printk(KERN_ERR "DBRI: reset_pipe called with illegal pipe number\n");
809 return; 819 return;
810 } 820 }
811 821
812 sdp = dbri->pipes[pipe].sdp; 822 sdp = dbri->pipes[pipe].sdp;
813 if (sdp == 0) { 823 if (sdp == 0) {
814 printk("DBRI: reset_pipe called on uninitialized pipe\n"); 824 printk(KERN_ERR "DBRI: reset_pipe called on uninitialized pipe\n");
815 return; 825 return;
816 } 826 }
817 827
@@ -834,12 +844,12 @@ static void reset_pipe(snd_dbri_t * dbri, int pipe)
834static void setup_pipe(snd_dbri_t * dbri, int pipe, int sdp) 844static void setup_pipe(snd_dbri_t * dbri, int pipe, int sdp)
835{ 845{
836 if (pipe < 0 || pipe > 31) { 846 if (pipe < 0 || pipe > 31) {
837 printk("DBRI: setup_pipe called with illegal pipe number\n"); 847 printk(KERN_ERR "DBRI: setup_pipe called with illegal pipe number\n");
838 return; 848 return;
839 } 849 }
840 850
841 if ((sdp & 0xf800) != sdp) { 851 if ((sdp & 0xf800) != sdp) {
842 printk("DBRI: setup_pipe called with strange SDP value\n"); 852 printk(KERN_ERR "DBRI: setup_pipe called with strange SDP value\n");
843 /* sdp &= 0xf800; */ 853 /* sdp &= 0xf800; */
844 } 854 }
845 855
@@ -872,13 +882,13 @@ static void link_time_slot(snd_dbri_t * dbri, int pipe,
872 int nextpipe; 882 int nextpipe;
873 883
874 if (pipe < 0 || pipe > 31 || basepipe < 0 || basepipe > 31) { 884 if (pipe < 0 || pipe > 31 || basepipe < 0 || basepipe > 31) {
875 printk 885 printk(KERN_ERR
876 ("DBRI: link_time_slot called with illegal pipe number\n"); 886 "DBRI: link_time_slot called with illegal pipe number\n");
877 return; 887 return;
878 } 888 }
879 889
880 if (dbri->pipes[pipe].sdp == 0 || dbri->pipes[basepipe].sdp == 0) { 890 if (dbri->pipes[pipe].sdp == 0 || dbri->pipes[basepipe].sdp == 0) {
881 printk("DBRI: link_time_slot called on uninitialized pipe\n"); 891 printk(KERN_ERR "DBRI: link_time_slot called on uninitialized pipe\n");
882 return; 892 return;
883 } 893 }
884 894
@@ -960,8 +970,8 @@ static void unlink_time_slot(snd_dbri_t * dbri, int pipe,
960 int val; 970 int val;
961 971
962 if (pipe < 0 || pipe > 31 || prevpipe < 0 || prevpipe > 31) { 972 if (pipe < 0 || pipe > 31 || prevpipe < 0 || prevpipe > 31) {
963 printk 973 printk(KERN_ERR
964 ("DBRI: unlink_time_slot called with illegal pipe number\n"); 974 "DBRI: unlink_time_slot called with illegal pipe number\n");
965 return; 975 return;
966 } 976 }
967 977
@@ -1001,22 +1011,22 @@ static void xmit_fixed(snd_dbri_t * dbri, int pipe, unsigned int data)
1001 volatile s32 *cmd; 1011 volatile s32 *cmd;
1002 1012
1003 if (pipe < 16 || pipe > 31) { 1013 if (pipe < 16 || pipe > 31) {
1004 printk("DBRI: xmit_fixed: Illegal pipe number\n"); 1014 printk(KERN_ERR "DBRI: xmit_fixed: Illegal pipe number\n");
1005 return; 1015 return;
1006 } 1016 }
1007 1017
1008 if (D_SDP_MODE(dbri->pipes[pipe].sdp) == 0) { 1018 if (D_SDP_MODE(dbri->pipes[pipe].sdp) == 0) {
1009 printk("DBRI: xmit_fixed: Uninitialized pipe %d\n", pipe); 1019 printk(KERN_ERR "DBRI: xmit_fixed: Uninitialized pipe %d\n", pipe);
1010 return; 1020 return;
1011 } 1021 }
1012 1022
1013 if (D_SDP_MODE(dbri->pipes[pipe].sdp) != D_SDP_FIXED) { 1023 if (D_SDP_MODE(dbri->pipes[pipe].sdp) != D_SDP_FIXED) {
1014 printk("DBRI: xmit_fixed: Non-fixed pipe %d\n", pipe); 1024 printk(KERN_ERR "DBRI: xmit_fixed: Non-fixed pipe %d\n", pipe);
1015 return; 1025 return;
1016 } 1026 }
1017 1027
1018 if (!(dbri->pipes[pipe].sdp & D_SDP_TO_SER)) { 1028 if (!(dbri->pipes[pipe].sdp & D_SDP_TO_SER)) {
1019 printk("DBRI: xmit_fixed: Called on receive pipe %d\n", pipe); 1029 printk(KERN_ERR "DBRI: xmit_fixed: Called on receive pipe %d\n", pipe);
1020 return; 1030 return;
1021 } 1031 }
1022 1032
@@ -1036,17 +1046,17 @@ static void xmit_fixed(snd_dbri_t * dbri, int pipe, unsigned int data)
1036static void recv_fixed(snd_dbri_t * dbri, int pipe, volatile __u32 * ptr) 1046static void recv_fixed(snd_dbri_t * dbri, int pipe, volatile __u32 * ptr)
1037{ 1047{
1038 if (pipe < 16 || pipe > 31) { 1048 if (pipe < 16 || pipe > 31) {
1039 printk("DBRI: recv_fixed called with illegal pipe number\n"); 1049 printk(KERN_ERR "DBRI: recv_fixed called with illegal pipe number\n");
1040 return; 1050 return;
1041 } 1051 }
1042 1052
1043 if (D_SDP_MODE(dbri->pipes[pipe].sdp) != D_SDP_FIXED) { 1053 if (D_SDP_MODE(dbri->pipes[pipe].sdp) != D_SDP_FIXED) {
1044 printk("DBRI: recv_fixed called on non-fixed pipe %d\n", pipe); 1054 printk(KERN_ERR "DBRI: recv_fixed called on non-fixed pipe %d\n", pipe);
1045 return; 1055 return;
1046 } 1056 }
1047 1057
1048 if (dbri->pipes[pipe].sdp & D_SDP_TO_SER) { 1058 if (dbri->pipes[pipe].sdp & D_SDP_TO_SER) {
1049 printk("DBRI: recv_fixed called on transmit pipe %d\n", pipe); 1059 printk(KERN_ERR "DBRI: recv_fixed called on transmit pipe %d\n", pipe);
1050 return; 1060 return;
1051 } 1061 }
1052 1062
@@ -1075,12 +1085,12 @@ static int setup_descs(snd_dbri_t * dbri, int streamno, unsigned int period)
1075 int last_desc = -1; 1085 int last_desc = -1;
1076 1086
1077 if (info->pipe < 0 || info->pipe > 15) { 1087 if (info->pipe < 0 || info->pipe > 15) {
1078 printk("DBRI: setup_descs: Illegal pipe number\n"); 1088 printk(KERN_ERR "DBRI: setup_descs: Illegal pipe number\n");
1079 return -2; 1089 return -2;
1080 } 1090 }
1081 1091
1082 if (dbri->pipes[info->pipe].sdp == 0) { 1092 if (dbri->pipes[info->pipe].sdp == 0) {
1083 printk("DBRI: setup_descs: Uninitialized pipe %d\n", 1093 printk(KERN_ERR "DBRI: setup_descs: Uninitialized pipe %d\n",
1084 info->pipe); 1094 info->pipe);
1085 return -2; 1095 return -2;
1086 } 1096 }
@@ -1090,20 +1100,20 @@ static int setup_descs(snd_dbri_t * dbri, int streamno, unsigned int period)
1090 1100
1091 if (streamno == DBRI_PLAY) { 1101 if (streamno == DBRI_PLAY) {
1092 if (!(dbri->pipes[info->pipe].sdp & D_SDP_TO_SER)) { 1102 if (!(dbri->pipes[info->pipe].sdp & D_SDP_TO_SER)) {
1093 printk("DBRI: setup_descs: Called on receive pipe %d\n", 1103 printk(KERN_ERR "DBRI: setup_descs: Called on receive pipe %d\n",
1094 info->pipe); 1104 info->pipe);
1095 return -2; 1105 return -2;
1096 } 1106 }
1097 } else { 1107 } else {
1098 if (dbri->pipes[info->pipe].sdp & D_SDP_TO_SER) { 1108 if (dbri->pipes[info->pipe].sdp & D_SDP_TO_SER) {
1099 printk 1109 printk(KERN_ERR
1100 ("DBRI: setup_descs: Called on transmit pipe %d\n", 1110 "DBRI: setup_descs: Called on transmit pipe %d\n",
1101 info->pipe); 1111 info->pipe);
1102 return -2; 1112 return -2;
1103 } 1113 }
1104 /* Should be able to queue multiple buffers to receive on a pipe */ 1114 /* Should be able to queue multiple buffers to receive on a pipe */
1105 if (pipe_active(dbri, info->pipe)) { 1115 if (pipe_active(dbri, info->pipe)) {
1106 printk("DBRI: recv_on_pipe: Called on active pipe %d\n", 1116 printk(KERN_ERR "DBRI: recv_on_pipe: Called on active pipe %d\n",
1107 info->pipe); 1117 info->pipe);
1108 return -2; 1118 return -2;
1109 } 1119 }
@@ -1120,7 +1130,7 @@ static int setup_descs(snd_dbri_t * dbri, int streamno, unsigned int period)
1120 break; 1130 break;
1121 } 1131 }
1122 if (desc == DBRI_NO_DESCS) { 1132 if (desc == DBRI_NO_DESCS) {
1123 printk("DBRI: setup_descs: No descriptors\n"); 1133 printk(KERN_ERR "DBRI: setup_descs: No descriptors\n");
1124 return -1; 1134 return -1;
1125 } 1135 }
1126 1136
@@ -1165,7 +1175,7 @@ static int setup_descs(snd_dbri_t * dbri, int streamno, unsigned int period)
1165 } 1175 }
1166 1176
1167 if (first_desc == -1 || last_desc == -1) { 1177 if (first_desc == -1 || last_desc == -1) {
1168 printk("DBRI: setup_descs: Not enough descriptors available\n"); 1178 printk(KERN_ERR "DBRI: setup_descs: Not enough descriptors available\n");
1169 return -1; 1179 return -1;
1170 } 1180 }
1171 1181
@@ -1270,7 +1280,7 @@ static void reset_chi(snd_dbri_t * dbri, enum master_or_slave master_or_slave,
1270 int divisor = 12288 / clockrate; 1280 int divisor = 12288 / clockrate;
1271 1281
1272 if (divisor > 255 || divisor * clockrate != 12288) 1282 if (divisor > 255 || divisor * clockrate != 12288)
1273 printk("DBRI: illegal bits_per_frame in setup_chi\n"); 1283 printk(KERN_ERR "DBRI: illegal bits_per_frame in setup_chi\n");
1274 1284
1275 *(cmd++) = DBRI_CMD(D_CHI, 0, D_CHI_CHICM(divisor) | D_CHI_FD 1285 *(cmd++) = DBRI_CMD(D_CHI, 0, D_CHI_CHICM(divisor) | D_CHI_FD
1276 | D_CHI_BPF(bits_per_frame)); 1286 | D_CHI_BPF(bits_per_frame));
@@ -1474,7 +1484,6 @@ static int cs4215_setctrl(snd_dbri_t * dbri)
1474 /* Temporarily mute outputs, and wait 1/8000 sec (125 us) 1484 /* Temporarily mute outputs, and wait 1/8000 sec (125 us)
1475 * to make sure this takes. This avoids clicking noises. 1485 * to make sure this takes. This avoids clicking noises.
1476 */ 1486 */
1477
1478 cs4215_setdata(dbri, 1); 1487 cs4215_setdata(dbri, 1);
1479 udelay(125); 1488 udelay(125);
1480 1489
@@ -1530,8 +1539,8 @@ static int cs4215_setctrl(snd_dbri_t * dbri)
1530 tmp |= D_C; /* Enable CHI */ 1539 tmp |= D_C; /* Enable CHI */
1531 sbus_writel(tmp, dbri->regs + REG0); 1540 sbus_writel(tmp, dbri->regs + REG0);
1532 1541
1533 for (i = 64; ((dbri->mm.status & 0xe4) != 0x20); --i) { 1542 for (i = 10; ((dbri->mm.status & 0xe4) != 0x20); --i) {
1534 udelay(125); 1543 msleep_interruptible(1);
1535 } 1544 }
1536 if (i == 0) { 1545 if (i == 0) {
1537 dprintk(D_MM, "CS4215 didn't respond to CLB (0x%02x)\n", 1546 dprintk(D_MM, "CS4215 didn't respond to CLB (0x%02x)\n",
@@ -1678,8 +1687,8 @@ buffer and calls dbri_process_one_interrupt() for each interrupt word.
1678Complicated interrupts are handled by dedicated functions (which 1687Complicated interrupts are handled by dedicated functions (which
1679appear first in this file). Any pending interrupts can be serviced by 1688appear first in this file). Any pending interrupts can be serviced by
1680calling dbri_process_interrupt_buffer(), which works even if the CPU's 1689calling dbri_process_interrupt_buffer(), which works even if the CPU's
1681interrupts are disabled. This function is used by dbri_cmdsend() 1690interrupts are disabled. This function is used by dbri_cmdlock()
1682to make sure we're synced up with the chip after each command sequence, 1691to make sure we're synced up with the chip before each command sequence,
1683even if we're running cli'ed. 1692even if we're running cli'ed.
1684 1693
1685*/ 1694*/
@@ -1765,11 +1774,13 @@ DECLARE_TASKLET(xmit_descs_task, xmit_descs, 0);
1765 * Called by main interrupt handler when DBRI signals transmission complete 1774 * Called by main interrupt handler when DBRI signals transmission complete
1766 * on a pipe (interrupt triggered by the B bit in a transmit descriptor). 1775 * on a pipe (interrupt triggered by the B bit in a transmit descriptor).
1767 * 1776 *
1768 * Walks through the pipe's list of transmit buffer descriptors, releasing 1777 * Walks through the pipe's list of transmit buffer descriptors and marks
1769 * each one's DMA buffer (if present), flagging the descriptor available, 1778 * them as available. Stops when the first descriptor is found without
1770 * and signaling its callback routine (if present), before proceeding
1771 * to the next one. Stops when the first descriptor is found without
1772 * TBC (Transmit Buffer Complete) set, or we've run through them all. 1779 * TBC (Transmit Buffer Complete) set, or we've run through them all.
1780 *
1781 * The DMA buffers are not released, but re-used. Since the transmit buffer
1782 * descriptors are not clobbered, they can be re-submitted as is. This is
1783 * done by the xmit_descs() tasklet above since that could take longer.
1773 */ 1784 */
1774 1785
1775static void transmission_complete_intr(snd_dbri_t * dbri, int pipe) 1786static void transmission_complete_intr(snd_dbri_t * dbri, int pipe)
@@ -1885,7 +1896,11 @@ static void dbri_process_one_interrupt(snd_dbri_t * dbri, int x)
1885 } 1896 }
1886 1897
1887 if (channel == D_INTR_CMD && command == D_WAIT) { 1898 if (channel == D_INTR_CMD && command == D_WAIT) {
1888 dbri->wait_seen++; 1899 dbri->wait_ackd = val;
1900 if (dbri->wait_send != val) {
1901 printk(KERN_ERR "Processing wait command %d when %d was send.\n",
1902 val, dbri->wait_send);
1903 }
1889 return; 1904 return;
1890 } 1905 }
1891 1906
@@ -1994,8 +2009,7 @@ static irqreturn_t snd_dbri_interrupt(int irq, void *dev_id,
1994 * The only one I've seen is MRR, which will be triggered 2009 * The only one I've seen is MRR, which will be triggered
1995 * if you let a transmit pipe underrun, then try to CDP it. 2010 * if you let a transmit pipe underrun, then try to CDP it.
1996 * 2011 *
1997 * If these things persist, we should probably reset 2012 * If these things persist, we reset the chip.
1998 * and re-init the chip.
1999 */ 2013 */
2000 if ((++errcnt) % 10 == 0) { 2014 if ((++errcnt) % 10 == 0) {
2001 dprintk(D_INT, "Interrupt errors exceeded.\n"); 2015 dprintk(D_INT, "Interrupt errors exceeded.\n");
@@ -2094,7 +2108,7 @@ static int snd_dbri_hw_params(snd_pcm_substream_t * substream,
2094 2108
2095 if ((ret = snd_pcm_lib_malloc_pages(substream, 2109 if ((ret = snd_pcm_lib_malloc_pages(substream,
2096 params_buffer_bytes(hw_params))) < 0) { 2110 params_buffer_bytes(hw_params))) < 0) {
2097 snd_printk(KERN_ERR "malloc_pages failed with %d\n", ret); 2111 printk(KERN_ERR "malloc_pages failed with %d\n", ret);
2098 return ret; 2112 return ret;
2099 } 2113 }
2100 2114
@@ -2455,8 +2469,7 @@ static int __init snd_dbri_mixer(snd_dbri_t * dbri)
2455 2469
2456 for (idx = 0; idx < NUM_CS4215_CONTROLS; idx++) { 2470 for (idx = 0; idx < NUM_CS4215_CONTROLS; idx++) {
2457 if ((err = snd_ctl_add(card, 2471 if ((err = snd_ctl_add(card,
2458 snd_ctl_new1(&dbri_controls[idx], 2472 snd_ctl_new1(&dbri_controls[idx], dbri))) < 0)
2459 dbri))) < 0)
2460 return err; 2473 return err;
2461 } 2474 }
2462 2475
@@ -2490,8 +2503,6 @@ static void dbri_debug_read(snd_info_entry_t * entry,
2490 int pipe; 2503 int pipe;
2491 snd_iprintf(buffer, "debug=%d\n", dbri_debug); 2504 snd_iprintf(buffer, "debug=%d\n", dbri_debug);
2492 2505
2493 snd_iprintf(buffer, "CHI pipe in=%d, out=%d\n",
2494 dbri->chi_in_pipe, dbri->chi_out_pipe);
2495 for (pipe = 0; pipe < 32; pipe++) { 2506 for (pipe = 0; pipe < 32; pipe++) {
2496 if (pipe_active(dbri, pipe)) { 2507 if (pipe_active(dbri, pipe)) {
2497 struct dbri_pipe *pptr = &dbri->pipes[pipe]; 2508 struct dbri_pipe *pptr = &dbri->pipes[pipe];
@@ -2506,18 +2517,6 @@ static void dbri_debug_read(snd_info_entry_t * entry,
2506 } 2517 }
2507 } 2518 }
2508} 2519}
2509
2510static void dbri_debug_write(snd_info_entry_t * entry,
2511 snd_info_buffer_t * buffer)
2512{
2513 char line[80];
2514 int i;
2515
2516 if (snd_info_get_line(buffer, line, 80) == 0) {
2517 sscanf(line, "%d\n", &i);
2518 dbri_debug = i & 0x3f;
2519 }
2520}
2521#endif 2520#endif
2522 2521
2523void snd_dbri_proc(snd_dbri_t * dbri) 2522void snd_dbri_proc(snd_dbri_t * dbri)
@@ -2531,9 +2530,7 @@ void snd_dbri_proc(snd_dbri_t * dbri)
2531#ifdef DBRI_DEBUG 2530#ifdef DBRI_DEBUG
2532 err = snd_card_proc_new(dbri->card, "debug", &entry); 2531 err = snd_card_proc_new(dbri->card, "debug", &entry);
2533 snd_info_set_text_ops(entry, dbri, 4096, dbri_debug_read); 2532 snd_info_set_text_ops(entry, dbri, 4096, dbri_debug_read);
2534 entry->mode = S_IFREG | S_IRUGO | S_IWUSR; /* Writable for root */ 2533 entry->mode = S_IFREG | S_IRUGO; /* Readable only. */
2535 entry->c.text.write_size = 256;
2536 entry->c.text.write = dbri_debug_write;
2537#endif 2534#endif
2538} 2535}
2539 2536
@@ -2637,7 +2634,11 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev)
2637 return -ENOENT; 2634 return -ENOENT;
2638 } 2635 }
2639 2636
2640 prom_getproperty(prom_node, "intr", (char *)&irq, sizeof(irq)); 2637 err = prom_getproperty(prom_node, "intr", (char *)&irq, sizeof(irq));
2638 if (err < 0) {
2639 printk(KERN_ERR "DBRI-%d: Firmware node lacks IRQ property.\n", dev);
2640 return -ENODEV;
2641 }
2641 2642
2642 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 2643 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
2643 sizeof(snd_dbri_t)); 2644 sizeof(snd_dbri_t));
@@ -2657,26 +2658,20 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev)
2657 } 2658 }
2658 2659
2659 dbri = (snd_dbri_t *) card->private_data; 2660 dbri = (snd_dbri_t *) card->private_data;
2660 if ((err = snd_dbri_pcm(dbri)) < 0) { 2661 if ((err = snd_dbri_pcm(dbri)) < 0)
2661 snd_dbri_free(dbri); 2662 goto _err;
2662 snd_card_free(card);
2663 return err;
2664 }
2665 2663
2666 if ((err = snd_dbri_mixer(dbri)) < 0) { 2664 if ((err = snd_dbri_mixer(dbri)) < 0)
2667 snd_dbri_free(dbri); 2665 goto _err;
2668 snd_card_free(card);
2669 return err;
2670 }
2671 2666
2672 /* /proc file handling */ 2667 /* /proc file handling */
2673 snd_dbri_proc(dbri); 2668 snd_dbri_proc(dbri);
2674 2669
2675 if ((err = snd_card_register(card)) < 0) { 2670 if ((err = snd_card_set_generic_dev(card)) < 0)
2676 snd_dbri_free(dbri); 2671 goto _err;
2677 snd_card_free(card); 2672
2678 return err; 2673 if ((err = snd_card_register(card)) < 0)
2679 } 2674 goto _err;
2680 2675
2681 printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n", 2676 printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n",
2682 dev, dbri->regs, 2677 dev, dbri->regs,
@@ -2684,6 +2679,11 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev)
2684 dev++; 2679 dev++;
2685 2680
2686 return 0; 2681 return 0;
2682
2683 _err:
2684 snd_dbri_free(dbri);
2685 snd_card_free(card);
2686 return err;
2687} 2687}
2688 2688
2689/* Probe for the dbri chip and then attach the driver. */ 2689/* Probe for the dbri chip and then attach the driver. */
diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c
index 60d0b2c66698..9e2b4c0c8a8a 100644
--- a/sound/synth/emux/emux.c
+++ b/sound/synth/emux/emux.c
@@ -40,7 +40,7 @@ int snd_emux_new(snd_emux_t **remu)
40 snd_emux_t *emu; 40 snd_emux_t *emu;
41 41
42 *remu = NULL; 42 *remu = NULL;
43 emu = kcalloc(1, sizeof(*emu), GFP_KERNEL); 43 emu = kzalloc(sizeof(*emu), GFP_KERNEL);
44 if (emu == NULL) 44 if (emu == NULL)
45 return -ENOMEM; 45 return -ENOMEM;
46 46
diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c
index e41b28d9bf52..8ccd33f4aa57 100644
--- a/sound/synth/emux/emux_seq.c
+++ b/sound/synth/emux/emux_seq.c
@@ -146,7 +146,7 @@ snd_emux_create_port(snd_emux_t *emu, char *name,
146 int i, type, cap; 146 int i, type, cap;
147 147
148 /* Allocate structures for this channel */ 148 /* Allocate structures for this channel */
149 if ((p = kcalloc(1, sizeof(*p), GFP_KERNEL)) == NULL) { 149 if ((p = kzalloc(sizeof(*p), GFP_KERNEL)) == NULL) {
150 snd_printk("no memory\n"); 150 snd_printk("no memory\n");
151 return NULL; 151 return NULL;
152 } 152 }
diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c
index 901a7db05bde..d0925ea50838 100644
--- a/sound/synth/emux/soundfont.c
+++ b/sound/synth/emux/soundfont.c
@@ -266,7 +266,7 @@ newsf(snd_sf_list_t *sflist, int type, char *name)
266 } 266 }
267 267
268 /* not found -- create a new one */ 268 /* not found -- create a new one */
269 sf = kcalloc(1, sizeof(*sf), GFP_KERNEL); 269 sf = kzalloc(sizeof(*sf), GFP_KERNEL);
270 if (sf == NULL) 270 if (sf == NULL)
271 return NULL; 271 return NULL;
272 sf->id = sflist->fonts_size; 272 sf->id = sflist->fonts_size;
@@ -346,7 +346,7 @@ sf_zone_new(snd_sf_list_t *sflist, snd_soundfont_t *sf)
346{ 346{
347 snd_sf_zone_t *zp; 347 snd_sf_zone_t *zp;
348 348
349 if ((zp = kcalloc(1, sizeof(*zp), GFP_KERNEL)) == NULL) 349 if ((zp = kzalloc(sizeof(*zp), GFP_KERNEL)) == NULL)
350 return NULL; 350 return NULL;
351 zp->next = sf->zones; 351 zp->next = sf->zones;
352 sf->zones = zp; 352 sf->zones = zp;
@@ -377,7 +377,7 @@ sf_sample_new(snd_sf_list_t *sflist, snd_soundfont_t *sf)
377{ 377{
378 snd_sf_sample_t *sp; 378 snd_sf_sample_t *sp;
379 379
380 if ((sp = kcalloc(1, sizeof(*sp), GFP_KERNEL)) == NULL) 380 if ((sp = kzalloc(sizeof(*sp), GFP_KERNEL)) == NULL)
381 return NULL; 381 return NULL;
382 382
383 sp->next = sf->samples; 383 sp->next = sf->samples;
@@ -1362,7 +1362,7 @@ snd_sf_new(snd_sf_callback_t *callback, snd_util_memhdr_t *hdr)
1362{ 1362{
1363 snd_sf_list_t *sflist; 1363 snd_sf_list_t *sflist;
1364 1364
1365 if ((sflist = kcalloc(1, sizeof(*sflist), GFP_KERNEL)) == NULL) 1365 if ((sflist = kzalloc(sizeof(*sflist), GFP_KERNEL)) == NULL)
1366 return NULL; 1366 return NULL;
1367 1367
1368 init_MUTEX(&sflist->presets_mutex); 1368 init_MUTEX(&sflist->presets_mutex);
diff --git a/sound/synth/util_mem.c b/sound/synth/util_mem.c
index 8b131a11e549..5f75bf31bc36 100644
--- a/sound/synth/util_mem.c
+++ b/sound/synth/util_mem.c
@@ -38,7 +38,7 @@ snd_util_memhdr_new(int memsize)
38{ 38{
39 snd_util_memhdr_t *hdr; 39 snd_util_memhdr_t *hdr;
40 40
41 hdr = kcalloc(1, sizeof(*hdr), GFP_KERNEL); 41 hdr = kzalloc(sizeof(*hdr), GFP_KERNEL);
42 if (hdr == NULL) 42 if (hdr == NULL)
43 return NULL; 43 return NULL;
44 hdr->size = memsize; 44 hdr->size = memsize;
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index bfbec5876659..d5ae2055b896 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -1439,9 +1439,11 @@ static int snd_usb_pcm_prepare(snd_pcm_substream_t *substream)
1439 1439
1440static snd_pcm_hardware_t snd_usb_playback = 1440static snd_pcm_hardware_t snd_usb_playback =
1441{ 1441{
1442 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1442 .info = SNDRV_PCM_INFO_MMAP |
1443 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1443 SNDRV_PCM_INFO_MMAP_VALID |
1444 SNDRV_PCM_INFO_MMAP_VALID), 1444 SNDRV_PCM_INFO_BATCH |
1445 SNDRV_PCM_INFO_INTERLEAVED |
1446 SNDRV_PCM_INFO_BLOCK_TRANSFER,
1445 .buffer_bytes_max = (256*1024), 1447 .buffer_bytes_max = (256*1024),
1446 .period_bytes_min = 64, 1448 .period_bytes_min = 64,
1447 .period_bytes_max = (128*1024), 1449 .period_bytes_max = (128*1024),
@@ -1451,9 +1453,11 @@ static snd_pcm_hardware_t snd_usb_playback =
1451 1453
1452static snd_pcm_hardware_t snd_usb_capture = 1454static snd_pcm_hardware_t snd_usb_capture =
1453{ 1455{
1454 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1456 .info = SNDRV_PCM_INFO_MMAP |
1455 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1457 SNDRV_PCM_INFO_MMAP_VALID |
1456 SNDRV_PCM_INFO_MMAP_VALID), 1458 SNDRV_PCM_INFO_BATCH |
1459 SNDRV_PCM_INFO_INTERLEAVED |
1460 SNDRV_PCM_INFO_BLOCK_TRANSFER,
1457 .buffer_bytes_max = (256*1024), 1461 .buffer_bytes_max = (256*1024),
1458 .period_bytes_min = 64, 1462 .period_bytes_min = 64,
1459 .period_bytes_max = (128*1024), 1463 .period_bytes_max = (128*1024),
@@ -3132,7 +3136,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
3132 return -ENOMEM; 3136 return -ENOMEM;
3133 } 3137 }
3134 3138
3135 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 3139 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
3136 if (! chip) { 3140 if (! chip) {
3137 snd_card_free(card); 3141 snd_card_free(card);
3138 return -ENOMEM; 3142 return -ENOMEM;
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 93dedde3c428..e0d0365453b3 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -841,7 +841,7 @@ static int snd_usbmidi_in_endpoint_create(snd_usb_midi_t* umidi,
841 int length; 841 int length;
842 842
843 rep->in = NULL; 843 rep->in = NULL;
844 ep = kcalloc(1, sizeof(*ep), GFP_KERNEL); 844 ep = kzalloc(sizeof(*ep), GFP_KERNEL);
845 if (!ep) 845 if (!ep)
846 return -ENOMEM; 846 return -ENOMEM;
847 ep->umidi = umidi; 847 ep->umidi = umidi;
@@ -913,7 +913,7 @@ static int snd_usbmidi_out_endpoint_create(snd_usb_midi_t* umidi,
913 void* buffer; 913 void* buffer;
914 914
915 rep->out = NULL; 915 rep->out = NULL;
916 ep = kcalloc(1, sizeof(*ep), GFP_KERNEL); 916 ep = kzalloc(sizeof(*ep), GFP_KERNEL);
917 if (!ep) 917 if (!ep)
918 return -ENOMEM; 918 return -ENOMEM;
919 ep->umidi = umidi; 919 ep->umidi = umidi;
@@ -1537,7 +1537,7 @@ int snd_usb_create_midi_interface(snd_usb_audio_t* chip,
1537 int out_ports, in_ports; 1537 int out_ports, in_ports;
1538 int i, err; 1538 int i, err;
1539 1539
1540 umidi = kcalloc(1, sizeof(*umidi), GFP_KERNEL); 1540 umidi = kzalloc(sizeof(*umidi), GFP_KERNEL);
1541 if (!umidi) 1541 if (!umidi)
1542 return -ENOMEM; 1542 return -ENOMEM;
1543 umidi->chip = chip; 1543 umidi->chip = chip;
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index fa7056f5caaf..c3c08c9cb46e 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -824,7 +824,7 @@ static void build_feature_ctl(mixer_build_t *state, unsigned char *desc,
824 if (check_ignored_ctl(state, unitid, control)) 824 if (check_ignored_ctl(state, unitid, control))
825 return; 825 return;
826 826
827 cval = kcalloc(1, sizeof(*cval), GFP_KERNEL); 827 cval = kzalloc(sizeof(*cval), GFP_KERNEL);
828 if (! cval) { 828 if (! cval) {
829 snd_printk(KERN_ERR "cannot malloc kcontrol\n"); 829 snd_printk(KERN_ERR "cannot malloc kcontrol\n");
830 return; 830 return;
@@ -997,7 +997,7 @@ static void build_mixer_unit_ctl(mixer_build_t *state, unsigned char *desc,
997 if (check_ignored_ctl(state, unitid, 0)) 997 if (check_ignored_ctl(state, unitid, 0))
998 return; 998 return;
999 999
1000 cval = kcalloc(1, sizeof(*cval), GFP_KERNEL); 1000 cval = kzalloc(sizeof(*cval), GFP_KERNEL);
1001 if (! cval) 1001 if (! cval)
1002 return; 1002 return;
1003 1003
@@ -1244,7 +1244,7 @@ static int build_audio_procunit(mixer_build_t *state, int unitid, unsigned char
1244 continue; 1244 continue;
1245 if (check_ignored_ctl(state, unitid, valinfo->control)) 1245 if (check_ignored_ctl(state, unitid, valinfo->control))
1246 continue; 1246 continue;
1247 cval = kcalloc(1, sizeof(*cval), GFP_KERNEL); 1247 cval = kzalloc(sizeof(*cval), GFP_KERNEL);
1248 if (! cval) { 1248 if (! cval) {
1249 snd_printk(KERN_ERR "cannot malloc kcontrol\n"); 1249 snd_printk(KERN_ERR "cannot malloc kcontrol\n");
1250 return -ENOMEM; 1250 return -ENOMEM;
@@ -1430,7 +1430,7 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned
1430 if (check_ignored_ctl(state, unitid, 0)) 1430 if (check_ignored_ctl(state, unitid, 0))
1431 return 0; 1431 return 0;
1432 1432
1433 cval = kcalloc(1, sizeof(*cval), GFP_KERNEL); 1433 cval = kzalloc(sizeof(*cval), GFP_KERNEL);
1434 if (! cval) { 1434 if (! cval) {
1435 snd_printk(KERN_ERR "cannot malloc kcontrol\n"); 1435 snd_printk(KERN_ERR "cannot malloc kcontrol\n");
1436 return -ENOMEM; 1436 return -ENOMEM;
@@ -1945,7 +1945,7 @@ int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif)
1945 1945
1946 strcpy(chip->card->mixername, "USB Mixer"); 1946 strcpy(chip->card->mixername, "USB Mixer");
1947 1947
1948 mixer = kcalloc(1, sizeof(*mixer), GFP_KERNEL); 1948 mixer = kzalloc(sizeof(*mixer), GFP_KERNEL);
1949 if (!mixer) 1949 if (!mixer)
1950 return -ENOMEM; 1950 return -ENOMEM;
1951 mixer->chip = chip; 1951 mixer->chip = chip;
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index 62dfd28b3b07..0f09e0de52dd 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -957,7 +957,7 @@ static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int c
957 957
958 for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; 958 for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
959 i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { 959 i <= SNDRV_PCM_STREAM_CAPTURE; ++i) {
960 usX2Y_substream[i] = kcalloc(1, sizeof(snd_usX2Y_substream_t), GFP_KERNEL); 960 usX2Y_substream[i] = kzalloc(sizeof(snd_usX2Y_substream_t), GFP_KERNEL);
961 if (NULL == usX2Y_substream[i]) { 961 if (NULL == usX2Y_substream[i]) {
962 snd_printk(KERN_ERR "cannot malloc\n"); 962 snd_printk(KERN_ERR "cannot malloc\n");
963 return -ENOMEM; 963 return -ENOMEM;