aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/genericirq.tmpl4
-rw-r--r--Documentation/cachetlb.txt23
-rw-r--r--Documentation/feature-removal-schedule.txt25
-rw-r--r--Documentation/filesystems/bfs.txt2
-rw-r--r--Documentation/hwmon/f71805f56
-rw-r--r--Documentation/hwmon/it8715
-rw-r--r--Documentation/hwmon/k8temp2
-rw-r--r--Documentation/hwmon/pc8742738
-rw-r--r--Documentation/hwmon/sysfs-interface4
-rw-r--r--Documentation/hwmon/w83627ehf2
-rw-r--r--Documentation/hwmon/w83791d2
-rw-r--r--Documentation/hwmon/w83793110
-rw-r--r--Documentation/kernel-parameters.txt6
-rw-r--r--MAINTAINERS22
-rw-r--r--Makefile23
-rw-r--r--arch/arm/Kconfig13
-rw-r--r--arch/arm/kernel/apm.c2
-rw-r--r--arch/arm/kernel/calls.S13
-rw-r--r--arch/arm/kernel/ecard.c2
-rw-r--r--arch/arm/kernel/head.S19
-rw-r--r--arch/arm/kernel/setup.c3
-rw-r--r--arch/arm/mach-at91rm9200/at91sam9260_devices.c1
-rw-r--r--arch/arm/mach-at91rm9200/board-sam9260ek.c1
-rw-r--r--arch/arm/mach-imx/Makefile2
-rw-r--r--arch/arm/mach-imx/cpufreq.c287
-rw-r--r--arch/arm/mach-netx/time.c42
-rw-r--r--arch/arm/mach-omap1/Kconfig1
-rw-r--r--arch/arm/mach-omap1/board-osk.c1
-rw-r--r--arch/arm/mach-pxa/time.c45
-rw-r--r--arch/arm/mach-pxa/trizeps4.c5
-rw-r--r--arch/arm/mach-sa1100/jornada720.c229
-rw-r--r--arch/arm/mm/consistent.c2
-rw-r--r--arch/arm/mm/copypage-v4mc.c2
-rw-r--r--arch/arm/mm/copypage-v6.c6
-rw-r--r--arch/arm/mm/copypage-xscale.c2
-rw-r--r--arch/arm/mm/fault-armv.c2
-rw-r--r--arch/arm/mm/flush.c2
-rw-r--r--arch/arm/mm/ioremap.c100
-rw-r--r--arch/arm/mm/mmu.c8
-rw-r--r--arch/arm/mm/pgd.c2
-rw-r--r--arch/arm/mm/proc-arm1020.S4
-rw-r--r--arch/arm/mm/proc-arm1020e.S4
-rw-r--r--arch/arm/mm/proc-arm1022.S6
-rw-r--r--arch/arm/mm/proc-arm1026.S6
-rw-r--r--arch/arm/mm/proc-arm6_7.S10
-rw-r--r--arch/arm/mm/proc-arm720.S6
-rw-r--r--arch/arm/mm/proc-arm920.S6
-rw-r--r--arch/arm/mm/proc-arm922.S6
-rw-r--r--arch/arm/mm/proc-arm925.S6
-rw-r--r--arch/arm/mm/proc-arm926.S8
-rw-r--r--arch/arm/mm/proc-sa110.S6
-rw-r--r--arch/arm/mm/proc-sa1100.S6
-rw-r--r--arch/arm/mm/proc-syms.c2
-rw-r--r--arch/arm/mm/proc-v6.S39
-rw-r--r--arch/arm/mm/proc-xsc3.S6
-rw-r--r--arch/arm/mm/proc-xscale.S6
-rw-r--r--arch/arm/vfp/vfpmodule.c26
-rw-r--r--arch/arm26/kernel/ecard.c2
-rw-r--r--arch/arm26/kernel/irq.c2
-rw-r--r--arch/cris/arch-v10/drivers/axisflashmap.c2
-rw-r--r--arch/cris/arch-v10/drivers/gpio.c2
-rw-r--r--arch/cris/arch-v32/drivers/axisflashmap.c2
-rw-r--r--arch/cris/arch-v32/drivers/gpio.c2
-rw-r--r--arch/cris/arch-v32/kernel/signal.c2
-rw-r--r--arch/cris/kernel/profile.c2
-rw-r--r--arch/h8300/kernel/ints.c2
-rw-r--r--arch/h8300/platform/h8s/ints.c2
-rw-r--r--arch/i386/defconfig2
-rw-r--r--arch/i386/kernel/apm.c2
-rw-r--r--arch/i386/kernel/entry.S32
-rw-r--r--arch/i386/kernel/microcode.c6
-rw-r--r--arch/i386/kernel/smpboot.c2
-rw-r--r--arch/i386/kernel/traps.c83
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_hwperf.c2
-rw-r--r--arch/m68k/mm/kmap.c2
-rw-r--r--arch/mips/kernel/apm.c2
-rw-r--r--arch/mips/mm/init.c25
-rw-r--r--arch/parisc/hpux/sys_hpux.c2
-rw-r--r--arch/parisc/kernel/unwind.c2
-rw-r--r--arch/powerpc/kernel/nvram_64.c4
-rw-r--r--arch/powerpc/kernel/pci_32.c2
-rw-r--r--arch/powerpc/mm/imalloc.c6
-rw-r--r--arch/powerpc/platforms/pseries/eeh_cache.c2
-rw-r--r--arch/ppc/8260_io/fcc_enet.c4
-rw-r--r--arch/ppc/8xx_io/cs4218_tdm.c2
-rw-r--r--arch/s390/Kconfig2
-rw-r--r--arch/s390/defconfig47
-rw-r--r--arch/s390/hypfs/hypfs_diag.c4
-rw-r--r--arch/s390/kernel/debug.c8
-rw-r--r--arch/s390/kernel/ipl.c59
-rw-r--r--arch/s390/kernel/reipl.S6
-rw-r--r--arch/s390/kernel/reipl64.S5
-rw-r--r--arch/s390/kernel/reset.S42
-rw-r--r--arch/s390/kernel/s390_ext.c2
-rw-r--r--arch/sparc/defconfig711
-rw-r--r--arch/sparc/kernel/irq.c4
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c8
-rw-r--r--arch/sparc/kernel/sun4d_irq.c2
-rw-r--r--arch/sparc/kernel/time.c5
-rw-r--r--arch/sparc/lib/Makefile4
-rw-r--r--arch/sparc/lib/atomic32.c39
-rw-r--r--arch/sparc/lib/bitops.S109
-rw-r--r--arch/sparc64/kernel/head.S7
-rw-r--r--arch/sparc64/kernel/irq.c24
-rw-r--r--arch/sparc64/kernel/smp.c7
-rw-r--r--arch/sparc64/kernel/sys_sunos32.c4
-rw-r--r--arch/um/drivers/net_kern.c15
-rw-r--r--arch/um/include/net_kern.h2
-rw-r--r--arch/um/sys-i386/ldt.c4
-rw-r--r--arch/x86_64/Makefile2
-rw-r--r--arch/x86_64/defconfig2
-rw-r--r--arch/x86_64/kernel/entry.S33
-rw-r--r--arch/x86_64/kernel/traps.c84
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S2
-rw-r--r--arch/xtensa/kernel/Makefile2
-rw-r--r--arch/xtensa/kernel/syscall.c2
-rw-r--r--block/as-iosched.c15
-rw-r--r--block/cfq-iosched.c18
-rw-r--r--block/ll_rw_blk.c28
-rw-r--r--crypto/blkcipher.c1
-rw-r--r--drivers/acorn/block/fd1772.c4
-rw-r--r--drivers/ata/Kconfig6
-rw-r--r--drivers/ata/ahci.c2
-rw-r--r--drivers/ata/ata_piix.c22
-rw-r--r--drivers/ata/libata-core.c14
-rw-r--r--drivers/ata/libata-scsi.c4
-rw-r--r--drivers/ata/pata_legacy.c4
-rw-r--r--drivers/ata/pata_qdi.c4
-rw-r--r--drivers/ata/pata_rz1000.c2
-rw-r--r--drivers/ata/pata_via.c9
-rw-r--r--drivers/ata/pata_winbond.c4
-rw-r--r--drivers/ata/pdc_adma.c4
-rw-r--r--drivers/ata/sata_svw.c41
-rw-r--r--drivers/atm/eni.c4
-rw-r--r--drivers/atm/he.c2
-rw-r--r--drivers/atm/lanai.c2
-rw-r--r--drivers/atm/nicstar.c4
-rw-r--r--drivers/atm/zatm.c4
-rw-r--r--drivers/base/class.c2
-rw-r--r--drivers/base/dmapool.c2
-rw-r--r--drivers/base/platform.c4
-rw-r--r--drivers/block/Kconfig7
-rw-r--r--drivers/block/Makefile1
-rw-r--r--drivers/block/cciss.c25
-rw-r--r--drivers/block/cpqarray.c10
-rw-r--r--drivers/block/swim_iop.c578
-rw-r--r--drivers/cdrom/cdrom.c8
-rw-r--r--drivers/cdrom/cm206.c2
-rw-r--r--drivers/char/Kconfig8
-rw-r--r--drivers/char/consolemap.c2
-rw-r--r--drivers/char/lcd.c2
-rw-r--r--drivers/char/lp.c2
-rw-r--r--drivers/char/mxser_new.c8
-rw-r--r--drivers/char/n_r3964.c37
-rw-r--r--drivers/char/n_tty.c1
-rw-r--r--drivers/char/pcmcia/synclink_cs.c2
-rw-r--r--drivers/char/rio/riocmd.c2
-rw-r--r--drivers/char/rtc.c38
-rw-r--r--drivers/char/sx.c8
-rw-r--r--drivers/char/synclink.c2
-rw-r--r--drivers/char/synclinkmp.c4
-rw-r--r--drivers/char/sysrq.c37
-rw-r--r--drivers/char/tty_io.c8
-rw-r--r--drivers/char/viocons.c10
-rw-r--r--drivers/char/vt.c2
-rw-r--r--drivers/char/vt_ioctl.c10
-rw-r--r--drivers/fc4/fc.c10
-rw-r--r--drivers/hwmon/Kconfig56
-rw-r--r--drivers/hwmon/Makefile3
-rw-r--r--drivers/hwmon/ams/Makefile8
-rw-r--r--drivers/hwmon/ams/ams-core.c265
-rw-r--r--drivers/hwmon/ams/ams-i2c.c299
-rw-r--r--drivers/hwmon/ams/ams-input.c160
-rw-r--r--drivers/hwmon/ams/ams-pmu.c207
-rw-r--r--drivers/hwmon/ams/ams.h72
-rw-r--r--drivers/hwmon/f71805f.c569
-rw-r--r--drivers/hwmon/hdaps.c68
-rw-r--r--drivers/hwmon/hwmon-vid.c4
-rw-r--r--drivers/hwmon/it87.c202
-rw-r--r--drivers/hwmon/k8temp.c4
-rw-r--r--drivers/hwmon/pc87360.c2
-rw-r--r--drivers/hwmon/pc87427.c627
-rw-r--r--drivers/hwmon/w83627ehf.c2
-rw-r--r--drivers/hwmon/w83792d.c2
-rw-r--r--drivers/hwmon/w83793.c1609
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c2
-rw-r--r--drivers/i2c/chips/tps65010.c21
-rw-r--r--drivers/ide/ide-floppy.c2
-rw-r--r--drivers/ide/ide-tape.c8
-rw-r--r--drivers/ide/pci/hpt366.c886
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c113
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c2
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h2
-rw-r--r--drivers/input/keyboard/amikbd.c2
-rw-r--r--drivers/input/keyboard/hilkbd.c5
-rw-r--r--drivers/input/keyboard/sunkbd.c2
-rw-r--r--drivers/isdn/act2000/act2000_isa.c2
-rw-r--r--drivers/isdn/capi/capidrv.c2
-rw-r--r--drivers/isdn/divert/divert_procfs.c2
-rw-r--r--drivers/isdn/divert/isdn_divert.c6
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c118
-rw-r--r--drivers/isdn/hysdn/hysdn_procconf.c2
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c2
-rw-r--r--drivers/isdn/i4l/isdn_audio.c6
-rw-r--r--drivers/isdn/i4l/isdn_net.c2
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c2
-rw-r--r--drivers/isdn/pcbit/layer2.c2
-rw-r--r--drivers/kvm/Kconfig4
-rw-r--r--drivers/kvm/kvm.h8
-rw-r--r--drivers/kvm/kvm_main.c38
-rw-r--r--drivers/kvm/kvm_svm.h2
-rw-r--r--drivers/kvm/kvm_vmx.h2
-rw-r--r--drivers/kvm/mmu.c17
-rw-r--r--drivers/kvm/paging_tmpl.h20
-rw-r--r--drivers/kvm/svm.c78
-rw-r--r--drivers/kvm/vmx.c62
-rw-r--r--drivers/kvm/x86_emulate.c8
-rw-r--r--drivers/kvm/x86_emulate.h2
-rw-r--r--drivers/macintosh/adb.c2
-rw-r--r--drivers/macintosh/apm_emu.c2
-rw-r--r--drivers/macintosh/smu.c2
-rw-r--r--drivers/macintosh/via-pmu68k.c2
-rw-r--r--drivers/md/faulty.c2
-rw-r--r--drivers/md/raid1.c2
-rw-r--r--drivers/md/raid10.c6
-rw-r--r--drivers/md/raid5.c20
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c2
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c2
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusbdecfe.c4
-rw-r--r--drivers/media/video/dabusb.c4
-rw-r--r--drivers/media/video/planb.c2
-rw-r--r--drivers/media/video/usbvideo/usbvideo.c2
-rw-r--r--drivers/media/video/videocodec.c2
-rw-r--r--drivers/message/i2o/core.h4
-rw-r--r--drivers/message/i2o/driver.c2
-rw-r--r--drivers/message/i2o/exec-osm.c2
-rw-r--r--drivers/message/i2o/i2o_config.c4
-rw-r--r--drivers/mtd/devices/mtd_dataflash.c2
-rw-r--r--drivers/mtd/rfd_ftl.c2
-rw-r--r--drivers/net/appletalk/ipddp.c2
-rw-r--r--drivers/net/bsd_comp.c2
-rw-r--r--drivers/net/irda/donauboe.c2
-rw-r--r--drivers/net/irda/irda-usb.c2
-rw-r--r--drivers/net/irda/irport.c2
-rw-r--r--drivers/net/lp486e.c4
-rw-r--r--drivers/net/phy/phy_device.c2
-rw-r--r--drivers/net/ppp_deflate.c4
-rw-r--r--drivers/net/ppp_mppe.c2
-rw-r--r--drivers/net/skge.c2
-rw-r--r--drivers/net/slip.c6
-rw-r--r--drivers/net/wan/hostess_sv11.c2
-rw-r--r--drivers/net/wan/pc300_drv.c2
-rw-r--r--drivers/net/wan/pc300_tty.c2
-rw-r--r--drivers/net/wan/x25_asy.c8
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_download.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c2
-rw-r--r--drivers/net/wireless/ipw2100.c2
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c2
-rw-r--r--drivers/net/wireless/wavelan_cs.c2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c2
-rw-r--r--drivers/parisc/iosapic.c2
-rw-r--r--drivers/pci/hotplug/cpqphp_nvram.c8
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c2
-rw-r--r--drivers/pci/pcie/aer/aerdrv.c2
-rw-r--r--drivers/pcmcia/at91_cf.c2
-rw-r--r--drivers/pcmcia/omap_cf.c2
-rw-r--r--drivers/pnp/isapnp/core.c22
-rw-r--r--drivers/pnp/pnpacpi/core.c6
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c22
-rw-r--r--drivers/pnp/pnpbios/core.c16
-rw-r--r--drivers/pnp/pnpbios/proc.c8
-rw-r--r--drivers/pnp/pnpbios/rsparser.c16
-rw-r--r--drivers/rtc/rtc-at91rm9200.c5
-rw-r--r--drivers/rtc/rtc-dev.c2
-rw-r--r--drivers/rtc/rtc-omap.c3
-rw-r--r--drivers/rtc/rtc-proc.c4
-rw-r--r--drivers/rtc/rtc-s3c.c6
-rw-r--r--drivers/rtc/rtc-sa1100.c4
-rw-r--r--drivers/rtc/rtc-sysfs.c2
-rw-r--r--drivers/s390/char/con3215.c2
-rw-r--r--drivers/s390/char/keyboard.c2
-rw-r--r--drivers/s390/char/sclp_cpi.c4
-rw-r--r--drivers/s390/cio/cio.c25
-rw-r--r--drivers/s390/cio/css.c3
-rw-r--r--drivers/s390/cio/qdio.c13
-rw-r--r--drivers/s390/crypto/ap_bus.c14
-rw-r--r--drivers/s390/crypto/zcrypt_cex2a.c4
-rw-r--r--drivers/s390/crypto/zcrypt_pcica.c4
-rw-r--r--drivers/s390/crypto/zcrypt_pcixcc.c2
-rw-r--r--drivers/s390/net/ctcmain.c6
-rw-r--r--drivers/s390/net/iucv.c2
-rw-r--r--drivers/s390/scsi/zfcp_aux.c2
-rw-r--r--drivers/sbus/char/vfc_dev.c2
-rw-r--r--drivers/scsi/aacraid/aachba.c2
-rw-r--r--drivers/scsi/aacraid/comminit.c2
-rw-r--r--drivers/scsi/aha1542.c2
-rw-r--r--drivers/scsi/aic7xxx_old.c2
-rw-r--r--drivers/scsi/dc395x.c2
-rw-r--r--drivers/scsi/dpt_i2o.c10
-rw-r--r--drivers/scsi/initio.c2
-rw-r--r--drivers/scsi/osst.c2
-rw-r--r--drivers/scsi/pluto.c2
-rw-r--r--drivers/scsi/sr_ioctl.c2
-rw-r--r--drivers/scsi/sr_vendor.c4
-rw-r--r--drivers/scsi/sun3_NCR5380.c6
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c2
-rw-r--r--drivers/serial/8250_pci.c24
-rw-r--r--drivers/usb/gadget/at91_udc.c2
-rw-r--r--drivers/usb/gadget/serial.c2
-rw-r--r--drivers/usb/host/hc_crisv10.c2
-rw-r--r--drivers/usb/misc/auerswald.c4
-rw-r--r--drivers/usb/misc/uss720.c2
-rw-r--r--drivers/usb/net/rndis_host.c2
-rw-r--r--drivers/usb/serial/cypress_m8.c2
-rw-r--r--drivers/usb/serial/digi_acceleport.c4
-rw-r--r--drivers/usb/serial/io_ti.c2
-rw-r--r--drivers/usb/serial/ipaq.c2
-rw-r--r--drivers/usb/serial/kobil_sct.c4
-rw-r--r--drivers/usb/serial/pl2303.c2
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c2
-rw-r--r--drivers/usb/serial/whiteheat.c4
-rw-r--r--drivers/usb/storage/sddr09.c2
-rw-r--r--drivers/video/amba-clcd.c2
-rw-r--r--drivers/video/amifb.c8
-rw-r--r--drivers/video/aty/atyfb_base.c4
-rw-r--r--drivers/video/matrox/i2c-matroxfb.c2
-rw-r--r--drivers/video/matrox/matroxfb_base.c2
-rw-r--r--drivers/video/matrox/matroxfb_crtc2.c2
-rw-r--r--drivers/video/sstfb.c335
-rw-r--r--drivers/w1/slaves/Kconfig4
-rw-r--r--fs/aio.c2
-rw-r--r--fs/autofs4/inode.c2
-rw-r--r--fs/befs/btree.c2
-rw-r--r--fs/befs/debug.c6
-rw-r--r--fs/bfs/inode.c4
-rw-r--r--fs/binfmt_misc.c2
-rw-r--r--fs/bio.c2
-rw-r--r--fs/block_dev.c202
-rw-r--r--fs/cifs/cifssmb.c2
-rw-r--r--fs/debugfs/inode.c39
-rw-r--r--fs/inode.c43
-rw-r--r--fs/jffs/inode-v23.c4
-rw-r--r--fs/jffs/intrep.c14
-rw-r--r--fs/jfs/jfs_dtree.c4
-rw-r--r--fs/jfs/jfs_imap.c2
-rw-r--r--fs/lockd/clntlock.c10
-rw-r--r--fs/lockd/clntproc.c39
-rw-r--r--fs/lockd/svclock.c4
-rw-r--r--fs/lockd/svcshare.c2
-rw-r--r--fs/lockd/xdr.c8
-rw-r--r--fs/lockd/xdr4.c8
-rw-r--r--fs/namespace.c5
-rw-r--r--fs/ncpfs/inode.c34
-rw-r--r--fs/nfs/nfs4proc.c2
-rw-r--r--fs/nfsd/export.c33
-rw-r--r--fs/nfsd/lockd.c2
-rw-r--r--fs/nfsd/nfs4proc.c625
-rw-r--r--fs/nfsd/nfs4state.c91
-rw-r--r--fs/nfsd/nfs4xdr.c14
-rw-r--r--fs/nfsd/nfsfh.c6
-rw-r--r--fs/nfsd/vfs.c2
-rw-r--r--fs/ocfs2/alloc.c2
-rw-r--r--fs/ocfs2/cluster/heartbeat.c4
-rw-r--r--fs/ocfs2/cluster/nodemanager.c6
-rw-r--r--fs/ocfs2/cluster/tcp.c10
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c4
-rw-r--r--fs/ocfs2/dlm/dlmlock.c4
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c2
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c6
-rw-r--r--fs/ocfs2/file.c8
-rw-r--r--fs/ocfs2/localalloc.c2
-rw-r--r--fs/ocfs2/slot_map.c2
-rw-r--r--fs/ocfs2/suballoc.c6
-rw-r--r--fs/ocfs2/super.c6
-rw-r--r--fs/ocfs2/vote.c4
-rw-r--r--fs/pipe.c12
-rw-r--r--fs/read_write.c2
-rw-r--r--fs/reiserfs/xattr_acl.c2
-rw-r--r--fs/smbfs/inode.c5
-rw-r--r--fs/smbfs/proc.c6
-rw-r--r--fs/smbfs/smbiod.c5
-rw-r--r--fs/splice.c8
-rw-r--r--include/asm-alpha/cacheflush.h1
-rw-r--r--include/asm-arm/arch-imx/imx-regs.h10
-rw-r--r--include/asm-arm/arch-s3c2410/regs-udc.h7
-rw-r--r--include/asm-arm/cacheflush.h2
-rw-r--r--include/asm-arm/cpu-multi32.h7
-rw-r--r--include/asm-arm/cpu-single.h4
-rw-r--r--include/asm-arm/pgtable.h11
-rw-r--r--include/asm-arm/processor.h16
-rw-r--r--include/asm-arm/system.h63
-rw-r--r--include/asm-arm/thread_info.h2
-rw-r--r--include/asm-arm/unistd.h13
-rw-r--r--include/asm-arm26/cacheflush.h1
-rw-r--r--include/asm-avr32/cacheflush.h1
-rw-r--r--include/asm-avr32/pgalloc.h2
-rw-r--r--include/asm-cris/cacheflush.h1
-rw-r--r--include/asm-frv/cacheflush.h1
-rw-r--r--include/asm-frv/thread_info.h2
-rw-r--r--include/asm-generic/vmlinux.lds.h22
-rw-r--r--include/asm-h8300/cacheflush.h1
-rw-r--r--include/asm-i386/cacheflush.h1
-rw-r--r--include/asm-i386/thread_info.h2
-rw-r--r--include/asm-i386/unwind.h91
-rw-r--r--include/asm-ia64/cacheflush.h1
-rw-r--r--include/asm-ia64/pci.h3
-rw-r--r--include/asm-ia64/scatterlist.h3
-rw-r--r--include/asm-ia64/thread_info.h2
-rw-r--r--include/asm-m32r/cacheflush.h3
-rw-r--r--include/asm-m68k/cacheflush.h2
-rw-r--r--include/asm-m68k/swim_iop.h221
-rw-r--r--include/asm-m68knommu/cacheflush.h1
-rw-r--r--include/asm-mips/cacheflush.h2
-rw-r--r--include/asm-mips/page.h16
-rw-r--r--include/asm-parisc/cacheflush.h2
-rw-r--r--include/asm-powerpc/cacheflush.h1
-rw-r--r--include/asm-powerpc/thread_info.h2
-rw-r--r--include/asm-s390/cacheflush.h1
-rw-r--r--include/asm-s390/qdio.h1
-rw-r--r--include/asm-s390/reset.h1
-rw-r--r--include/asm-sh/cpu-sh2/cacheflush.h2
-rw-r--r--include/asm-sh/cpu-sh3/cacheflush.h3
-rw-r--r--include/asm-sh/cpu-sh4/cacheflush.h1
-rw-r--r--include/asm-sh/thread_info.h2
-rw-r--r--include/asm-sh64/cacheflush.h2
-rw-r--r--include/asm-sh64/pgalloc.h2
-rw-r--r--include/asm-sparc/bitops.h100
-rw-r--r--include/asm-sparc/cacheflush.h1
-rw-r--r--include/asm-sparc64/cacheflush.h1
-rw-r--r--include/asm-sparc64/hw_irq.h2
-rw-r--r--include/asm-sparc64/percpu.h10
-rw-r--r--include/asm-v850/cacheflush.h1
-rw-r--r--include/asm-x86_64/cacheflush.h1
-rw-r--r--include/asm-x86_64/thread_info.h2
-rw-r--r--include/asm-x86_64/unwind.h96
-rw-r--r--include/asm-xtensa/cacheflush.h2
-rw-r--r--include/asm-xtensa/termbits.h11
-rw-r--r--include/asm-xtensa/uaccess.h1
-rw-r--r--include/linux/aio.h1
-rw-r--r--include/linux/bio.h1
-rw-r--r--include/linux/coda_linux.h2
-rw-r--r--include/linux/cpuset.h22
-rw-r--r--include/linux/fb.h2
-rw-r--r--include/linux/freezer.h11
-rw-r--r--include/linux/fs.h1
-rw-r--r--include/linux/gameport.h2
-rw-r--r--include/linux/highmem.h7
-rw-r--r--include/linux/i2c-id.h1
-rw-r--r--include/linux/init_task.h1
-rw-r--r--include/linux/lockd/bind.h2
-rw-r--r--include/linux/lockd/lockd.h2
-rw-r--r--include/linux/lockd/sm_inter.h2
-rw-r--r--include/linux/lockd/xdr.h8
-rw-r--r--include/linux/lockdep.h16
-rw-r--r--include/linux/mount.h1
-rw-r--r--include/linux/n_r3964.h2
-rw-r--r--include/linux/ncp_mount.h2
-rw-r--r--include/linux/netfilter_bridge.h1
-rw-r--r--include/linux/netfilter_ipv4.h2
-rw-r--r--include/linux/netfilter_ipv6.h2
-rw-r--r--include/linux/nfsd/nfsd.h4
-rw-r--r--include/linux/nfsd/state.h1
-rw-r--r--include/linux/nfsd/xdr4.h40
-rw-r--r--include/linux/nsproxy.h1
-rw-r--r--include/linux/pci_ids.h4
-rw-r--r--include/linux/pipe_fs_i.h5
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/reciprocal_div.h32
-rw-r--r--include/linux/sched.h1
-rw-r--r--include/linux/slab.h306
-rw-r--r--include/linux/slab_def.h100
-rw-r--r--include/linux/smb_fs_sb.h2
-rw-r--r--include/linux/sysrq.h22
-rw-r--r--include/linux/unwind.h63
-rw-r--r--include/linux/workqueue.h36
-rw-r--r--include/net/bluetooth/hci.h4
-rw-r--r--include/net/ip6_fib.h4
-rw-r--r--include/net/netfilter/nf_conntrack_compat.h10
-rw-r--r--include/net/sctp/structs.h10
-rw-r--r--include/net/sctp/user.h2
-rw-r--r--include/rdma/ib_verbs.h77
-rw-r--r--include/video/sstfb.h13
-rw-r--r--ipc/msgutil.c4
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/cpuset.c82
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/lockdep.c203
-rw-r--r--kernel/module.c25
-rw-r--r--kernel/nsproxy.c4
-rw-r--r--kernel/power/Kconfig9
-rw-r--r--kernel/power/process.c21
-rw-r--r--kernel/relay.c4
-rw-r--r--kernel/sched.c4
-rw-r--r--kernel/signal.c4
-rw-r--r--kernel/sysctl.c3
-rw-r--r--kernel/timer.c14
-rw-r--r--kernel/unwind.c1305
-rw-r--r--kernel/workqueue.c16
-rw-r--r--lib/Kconfig5
-rw-r--r--lib/Kconfig.debug18
-rw-r--r--lib/Makefile5
-rw-r--r--lib/fault-inject.c32
-rw-r--r--lib/ioremap.c1
-rw-r--r--lib/reciprocal_div.c9
-rw-r--r--mm/hugetlb.c8
-rw-r--r--mm/memory.c10
-rw-r--r--mm/mincore.c183
-rw-r--r--mm/oom_kill.c2
-rw-r--r--mm/page_alloc.c2
-rw-r--r--mm/slab.c28
-rw-r--r--mm/slob.c16
-rw-r--r--mm/vmscan.c8
-rw-r--r--net/bluetooth/hci_sock.c4
-rw-r--r--net/bridge/br_netfilter.c188
-rw-r--r--net/dccp/ccids/ccid3.c6
-rw-r--r--net/ipv4/netfilter/Kconfig2
-rw-r--r--net/ipv4/netfilter/arp_tables.c5
-rw-r--r--net/ipv4/netfilter/ip_tables.c181
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c8
-rw-r--r--net/ipv4/tcp.c5
-rw-r--r--net/ipv6/ipv6_sockglue.c23
-rw-r--r--net/ipv6/netfilter/ip6_tables.c5
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/netfilter/Kconfig2
-rw-r--r--net/netfilter/xt_CONNMARK.c14
-rw-r--r--net/netfilter/xt_CONNSECMARK.c14
-rw-r--r--net/netfilter/xt_connbytes.c14
-rw-r--r--net/netfilter/xt_connmark.c7
-rw-r--r--net/netfilter/xt_conntrack.c8
-rw-r--r--net/netfilter/xt_helper.c8
-rw-r--r--net/netfilter/xt_physdev.c12
-rw-r--r--net/netfilter/xt_state.c7
-rw-r--r--net/sctp/associola.c1
-rw-r--r--net/sctp/ipv6.c38
-rw-r--r--net/sctp/protocol.c70
-rw-r--r--net/sctp/socket.c118
-rw-r--r--net/sctp/ulpevent.c4
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c11
-rw-r--r--net/sunrpc/cache.c31
-rw-r--r--net/sunrpc/svc.c2
-rw-r--r--net/sunrpc/svcauth_unix.c5
-rw-r--r--net/tipc/config.c2
-rw-r--r--scripts/kconfig/conf.c2
-rw-r--r--scripts/kconfig/confdata.c37
-rw-r--r--scripts/kconfig/gconf.c35
-rw-r--r--scripts/kconfig/gconf.glade4
-rw-r--r--scripts/kconfig/lkc.h2
-rw-r--r--scripts/kconfig/lkc_proto.h3
-rw-r--r--scripts/kconfig/mconf.c21
-rw-r--r--scripts/kconfig/qconf.cc15
-rw-r--r--scripts/kconfig/qconf.h3
-rw-r--r--scripts/kconfig/symbol.c3
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped2
-rw-r--r--scripts/kconfig/zconf.y2
-rw-r--r--scripts/mod/modpost.c1
-rw-r--r--sound/core/oss/mixer_oss.c2
-rw-r--r--sound/oss/ad1848.c2
-rw-r--r--sound/oss/cs4232.c2
-rw-r--r--sound/oss/dmasound/tas3001c.c14
-rw-r--r--sound/oss/dmasound/tas3004.c15
-rw-r--r--sound/oss/emu10k1/audio.c6
-rw-r--r--sound/oss/emu10k1/cardmi.c2
-rw-r--r--sound/oss/emu10k1/cardmo.c2
-rw-r--r--sound/oss/emu10k1/midi.c10
-rw-r--r--sound/oss/emu10k1/mixer.c2
-rw-r--r--sound/oss/hal2.c2
-rw-r--r--sound/oss/mpu401.c2
-rw-r--r--sound/oss/opl3.c2
-rw-r--r--sound/oss/sb_common.c2
-rw-r--r--sound/oss/sb_midi.c4
-rw-r--r--sound/oss/sb_mixer.c2
-rw-r--r--sound/oss/v_midi.c2
-rw-r--r--sound/oss/waveartist.c2
576 files changed, 9337 insertions, 6770 deletions
diff --git a/Documentation/DocBook/genericirq.tmpl b/Documentation/DocBook/genericirq.tmpl
index 0f4a4b6321e4..4215f69ce7e6 100644
--- a/Documentation/DocBook/genericirq.tmpl
+++ b/Documentation/DocBook/genericirq.tmpl
@@ -303,10 +303,10 @@ desc->status |= running;
303do { 303do {
304 if (desc->status & masked) 304 if (desc->status & masked)
305 desc->chip->enable(); 305 desc->chip->enable();
306 desc-status &= ~pending; 306 desc->status &= ~pending;
307 handle_IRQ_event(desc->action); 307 handle_IRQ_event(desc->action);
308} while (status & pending); 308} while (status & pending);
309desc-status &= ~running; 309desc->status &= ~running;
310desc->chip->end(); 310desc->chip->end();
311 </programlisting> 311 </programlisting>
312 </para> 312 </para>
diff --git a/Documentation/cachetlb.txt b/Documentation/cachetlb.txt
index 53245c429f7d..73e794f0ff09 100644
--- a/Documentation/cachetlb.txt
+++ b/Documentation/cachetlb.txt
@@ -179,10 +179,21 @@ Here are the routines, one by one:
179 lines associated with 'mm'. 179 lines associated with 'mm'.
180 180
181 This interface is used to handle whole address space 181 This interface is used to handle whole address space
182 page table operations such as what happens during 182 page table operations such as what happens during exit and exec.
183 fork, exit, and exec. 183
1842) void flush_cache_dup_mm(struct mm_struct *mm)
185
186 This interface flushes an entire user address space from
187 the caches. That is, after running, there will be no cache
188 lines associated with 'mm'.
189
190 This interface is used to handle whole address space
191 page table operations such as what happens during fork.
192
193 This option is separate from flush_cache_mm to allow some
194 optimizations for VIPT caches.
184 195
1852) void flush_cache_range(struct vm_area_struct *vma, 1963) void flush_cache_range(struct vm_area_struct *vma,
186 unsigned long start, unsigned long end) 197 unsigned long start, unsigned long end)
187 198
188 Here we are flushing a specific range of (user) virtual 199 Here we are flushing a specific range of (user) virtual
@@ -199,7 +210,7 @@ Here are the routines, one by one:
199 call flush_cache_page (see below) for each entry which may be 210 call flush_cache_page (see below) for each entry which may be
200 modified. 211 modified.
201 212
2023) void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn) 2134) void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn)
203 214
204 This time we need to remove a PAGE_SIZE sized range 215 This time we need to remove a PAGE_SIZE sized range
205 from the cache. The 'vma' is the backing structure used by 216 from the cache. The 'vma' is the backing structure used by
@@ -220,7 +231,7 @@ Here are the routines, one by one:
220 231
221 This is used primarily during fault processing. 232 This is used primarily during fault processing.
222 233
2234) void flush_cache_kmaps(void) 2345) void flush_cache_kmaps(void)
224 235
225 This routine need only be implemented if the platform utilizes 236 This routine need only be implemented if the platform utilizes
226 highmem. It will be called right before all of the kmaps 237 highmem. It will be called right before all of the kmaps
@@ -232,7 +243,7 @@ Here are the routines, one by one:
232 243
233 This routing should be implemented in asm/highmem.h 244 This routing should be implemented in asm/highmem.h
234 245
2355) void flush_cache_vmap(unsigned long start, unsigned long end) 2466) void flush_cache_vmap(unsigned long start, unsigned long end)
236 void flush_cache_vunmap(unsigned long start, unsigned long end) 247 void flush_cache_vunmap(unsigned long start, unsigned long end)
237 248
238 Here in these two interfaces we are flushing a specific range 249 Here in these two interfaces we are flushing a specific range
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 64ce44da5936..30f3c8c9c12a 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -151,15 +151,6 @@ Who: Thomas Gleixner <tglx@linutronix.de>
151 151
152--------------------------- 152---------------------------
153 153
154What: I2C interface of the it87 driver
155When: January 2007
156Why: The ISA interface is faster and should be always available. The I2C
157 probing is also known to cause trouble in at least one case (see
158 bug #5889.)
159Who: Jean Delvare <khali@linux-fr.org>
160
161---------------------------
162
163What: Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports 154What: Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports
164 (temporary transition config option provided until then) 155 (temporary transition config option provided until then)
165 The transition config option will also be removed at the same time. 156 The transition config option will also be removed at the same time.
@@ -216,22 +207,6 @@ Who: Thomas Gleixner <tglx@linutronix.de>
216 207
217--------------------------- 208---------------------------
218 209
219What: Bridge netfilter deferred IPv4/IPv6 output hook calling
220When: January 2007
221Why: The deferred output hooks are a layering violation causing unusual
222 and broken behaviour on bridge devices. Examples of things they
223 break include QoS classifation using the MARK or CLASSIFY targets,
224 the IPsec policy match and connection tracking with VLANs on a
225 bridge. Their only use is to enable bridge output port filtering
226 within iptables with the physdev match, which can also be done by
227 combining iptables and ebtables using netfilter marks. Until it
228 will get removed the hook deferral is disabled by default and is
229 only enabled when needed.
230
231Who: Patrick McHardy <kaber@trash.net>
232
233---------------------------
234
235What: PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment 210What: PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment
236When: October 2008 211When: October 2008
237Why: The stacking of class devices makes these values misleading and 212Why: The stacking of class devices makes these values misleading and
diff --git a/Documentation/filesystems/bfs.txt b/Documentation/filesystems/bfs.txt
index d2841e0bcf02..ea825e178e79 100644
--- a/Documentation/filesystems/bfs.txt
+++ b/Documentation/filesystems/bfs.txt
@@ -54,4 +54,4 @@ The first 4 bytes should be 0x1badface.
54If you have any patches, questions or suggestions regarding this BFS 54If you have any patches, questions or suggestions regarding this BFS
55implementation please contact the author: 55implementation please contact the author:
56 56
57Tigran A. Aivazian <tigran@veritas.com> 57Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
diff --git a/Documentation/hwmon/f71805f b/Documentation/hwmon/f71805f
index 2ca69df669c3..bfd0f154959c 100644
--- a/Documentation/hwmon/f71805f
+++ b/Documentation/hwmon/f71805f
@@ -6,6 +6,10 @@ Supported chips:
6 Prefix: 'f71805f' 6 Prefix: 'f71805f'
7 Addresses scanned: none, address read from Super I/O config space 7 Addresses scanned: none, address read from Super I/O config space
8 Datasheet: Provided by Fintek on request 8 Datasheet: Provided by Fintek on request
9 * Fintek F71872F/FG
10 Prefix: 'f71872f'
11 Addresses scanned: none, address read from Super I/O config space
12 Datasheet: Provided by Fintek on request
9 13
10Author: Jean Delvare <khali@linux-fr.org> 14Author: Jean Delvare <khali@linux-fr.org>
11 15
@@ -13,8 +17,8 @@ Thanks to Denis Kieft from Barracuda Networks for the donation of a
13test system (custom Jetway K8M8MS motherboard, with CPU and RAM) and 17test system (custom Jetway K8M8MS motherboard, with CPU and RAM) and
14for providing initial documentation. 18for providing initial documentation.
15 19
16Thanks to Kris Chen from Fintek for answering technical questions and 20Thanks to Kris Chen and Aaron Huang from Fintek for answering technical
17providing additional documentation. 21questions and providing additional documentation.
18 22
19Thanks to Chris Lin from Jetway for providing wiring schematics and 23Thanks to Chris Lin from Jetway for providing wiring schematics and
20answering technical questions. 24answering technical questions.
@@ -28,8 +32,11 @@ capabilities. It can monitor up to 9 voltages (counting its own power
28source), 3 fans and 3 temperature sensors. 32source), 3 fans and 3 temperature sensors.
29 33
30This chip also has fan controlling features, using either DC or PWM, in 34This chip also has fan controlling features, using either DC or PWM, in
31three different modes (one manual, two automatic). The driver doesn't 35three different modes (one manual, two automatic).
32support these features yet. 36
37The Fintek F71872F/FG Super I/O chip is almost the same, with two
38additional internal voltages monitored (VSB and battery). It also features
396 VID inputs. The VID inputs are not yet supported by this driver.
33 40
34The driver assumes that no more than one chip is present, which seems 41The driver assumes that no more than one chip is present, which seems
35reasonable. 42reasonable.
@@ -42,7 +49,8 @@ Voltages are sampled by an 8-bit ADC with a LSB of 8 mV. The supported
42range is thus from 0 to 2.040 V. Voltage values outside of this range 49range is thus from 0 to 2.040 V. Voltage values outside of this range
43need external resistors. An exception is in0, which is used to monitor 50need external resistors. An exception is in0, which is used to monitor
44the chip's own power source (+3.3V), and is divided internally by a 51the chip's own power source (+3.3V), and is divided internally by a
45factor 2. 52factor 2. For the F71872F/FG, in9 (VSB) and in10 (battery) are also
53divided internally by a factor 2.
46 54
47The two LSB of the voltage limit registers are not used (always 0), so 55The two LSB of the voltage limit registers are not used (always 0), so
48you can only set the limits in steps of 32 mV (before scaling). 56you can only set the limits in steps of 32 mV (before scaling).
@@ -61,9 +69,12 @@ in5 VIN5 +12V 200K 20K 11.00 1.05 V
61in6 VIN6 VCC1.5V 10K - 1.00 1.50 V 69in6 VIN6 VCC1.5V 10K - 1.00 1.50 V
62in7 VIN7 VCORE 10K - 1.00 ~1.40 V (1) 70in7 VIN7 VCORE 10K - 1.00 ~1.40 V (1)
63in8 VIN8 VSB5V 200K 47K 1.00 0.95 V 71in8 VIN8 VSB5V 200K 47K 1.00 0.95 V
72in10 VSB VSB3.3V int. int. 2.00 1.65 V (3)
73in9 VBAT VBATTERY int. int. 2.00 1.50 V (3)
64 74
65(1) Depends on your hardware setup. 75(1) Depends on your hardware setup.
66(2) Obviously not correct, swapping R1 and R2 would make more sense. 76(2) Obviously not correct, swapping R1 and R2 would make more sense.
77(3) F71872F/FG only.
67 78
68These values can be used as hints at best, as motherboard manufacturers 79These values can be used as hints at best, as motherboard manufacturers
69are free to use a completely different setup. As a matter of fact, the 80are free to use a completely different setup. As a matter of fact, the
@@ -103,3 +114,38 @@ sensor. Each channel can be used for connecting either a thermal diode
103or a thermistor. The driver reports the currently selected mode, but 114or a thermistor. The driver reports the currently selected mode, but
104doesn't allow changing it. In theory, the BIOS should have configured 115doesn't allow changing it. In theory, the BIOS should have configured
105everything properly. 116everything properly.
117
118
119Fan Control
120-----------
121
122Both PWM (pulse-width modulation) and DC fan speed control methods are
123supported. The right one to use depends on external circuitry on the
124motherboard, so the driver assumes that the BIOS set the method
125properly. The driver will report the method, but won't let you change
126it.
127
128When the PWM method is used, you can select the operating frequency,
129from 187.5 kHz (default) to 31 Hz. The best frequency depends on the
130fan model. As a rule of thumb, lower frequencies seem to give better
131control, but may generate annoying high-pitch noise. Fintek recommends
132not going below 1 kHz, as the fan tachometers get confused by lower
133frequencies as well.
134
135When the DC method is used, Fintek recommends not going below 5 V, which
136corresponds to a pwm value of 106 for the driver. The driver doesn't
137enforce this limit though.
138
139Three different fan control modes are supported:
140
141* Manual mode
142 You ask for a specific PWM duty cycle or DC voltage.
143
144* Fan speed mode
145 You ask for a specific fan speed. This mode assumes that pwm1
146 corresponds to fan1, pwm2 to fan2 and pwm3 to fan3.
147
148* Temperature mode
149 You define 3 temperature/fan speed trip points, and the fan speed is
150 adjusted depending on the measured temperature, using interpolation.
151 This mode is not yet supported by the driver.
diff --git a/Documentation/hwmon/it87 b/Documentation/hwmon/it87
index e783fd62e308..74a80992d237 100644
--- a/Documentation/hwmon/it87
+++ b/Documentation/hwmon/it87
@@ -9,8 +9,7 @@ Supported chips:
9 http://www.ite.com.tw/ 9 http://www.ite.com.tw/
10 * IT8712F 10 * IT8712F
11 Prefix: 'it8712' 11 Prefix: 'it8712'
12 Addresses scanned: I2C 0x2d 12 Addresses scanned: from Super I/O config space (8 I/O ports)
13 from Super I/O config space (8 I/O ports)
14 Datasheet: Publicly available at the ITE website 13 Datasheet: Publicly available at the ITE website
15 http://www.ite.com.tw/ 14 http://www.ite.com.tw/
16 * IT8716F 15 * IT8716F
@@ -53,6 +52,18 @@ Module Parameters
53 misconfigured by BIOS - PWM values would be inverted. This option tries 52 misconfigured by BIOS - PWM values would be inverted. This option tries
54 to fix this. Please contact your BIOS manufacturer and ask him for fix. 53 to fix this. Please contact your BIOS manufacturer and ask him for fix.
55 54
55
56Hardware Interfaces
57-------------------
58
59All the chips suported by this driver are LPC Super-I/O chips, accessed
60through the LPC bus (ISA-like I/O ports). The IT8712F additionally has an
61SMBus interface to the hardware monitoring functions. This driver no
62longer supports this interface though, as it is slower and less reliable
63than the ISA access, and was only available on a small number of
64motherboard models.
65
66
56Description 67Description
57----------- 68-----------
58 69
diff --git a/Documentation/hwmon/k8temp b/Documentation/hwmon/k8temp
index 30d123b8d920..0005c7166146 100644
--- a/Documentation/hwmon/k8temp
+++ b/Documentation/hwmon/k8temp
@@ -8,7 +8,7 @@ Supported chips:
8 Datasheet: http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/32559.pdf 8 Datasheet: http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/32559.pdf
9 9
10Author: Rudolf Marek 10Author: Rudolf Marek
11Contact: Rudolf Marek <r.marek@sh.cvut.cz> 11Contact: Rudolf Marek <r.marek@assembler.cz>
12 12
13Description 13Description
14----------- 14-----------
diff --git a/Documentation/hwmon/pc87427 b/Documentation/hwmon/pc87427
new file mode 100644
index 000000000000..9a0708f9f49e
--- /dev/null
+++ b/Documentation/hwmon/pc87427
@@ -0,0 +1,38 @@
1Kernel driver pc87427
2=====================
3
4Supported chips:
5 * National Semiconductor PC87427
6 Prefix: 'pc87427'
7 Addresses scanned: none, address read from Super I/O config space
8 Datasheet: http://www.winbond.com.tw/E-WINBONDHTM/partner/apc_007.html
9
10Author: Jean Delvare <khali@linux-fr.org>
11
12Thanks to Amir Habibi at Candelis for setting up a test system, and to
13Michael Kress for testing several iterations of this driver.
14
15
16Description
17-----------
18
19The National Semiconductor Super I/O chip includes complete hardware
20monitoring capabilities. It can monitor up to 18 voltages, 8 fans and
216 temperature sensors. Only the fans are supported at the moment.
22
23This chip also has fan controlling features, which are not yet supported
24by this driver either.
25
26The driver assumes that no more than one chip is present, which seems
27reasonable.
28
29
30Fan Monitoring
31--------------
32
33Fan rotation speeds are reported as 14-bit values from a gated clock
34signal. Speeds down to 83 RPM can be measured.
35
36An alarm is triggered if the rotation speed drops below a programmable
37limit. Another alarm is triggered if the speed is too low to to be measured
38(including stalled or missing fan).
diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface
index d1d390aaf620..efef3b962cd3 100644
--- a/Documentation/hwmon/sysfs-interface
+++ b/Documentation/hwmon/sysfs-interface
@@ -208,12 +208,14 @@ temp[1-*]_auto_point[1-*]_temp_hyst
208**************** 208****************
209 209
210temp[1-*]_type Sensor type selection. 210temp[1-*]_type Sensor type selection.
211 Integers 1 to 4 or thermistor Beta value (typically 3435) 211 Integers 1 to 6 or thermistor Beta value (typically 3435)
212 RW 212 RW
213 1: PII/Celeron Diode 213 1: PII/Celeron Diode
214 2: 3904 transistor 214 2: 3904 transistor
215 3: thermal diode 215 3: thermal diode
216 4: thermistor (default/unknown Beta) 216 4: thermistor (default/unknown Beta)
217 5: AMD AMDSI
218 6: Intel PECI
217 Not all types are supported by all chips 219 Not all types are supported by all chips
218 220
219temp[1-*]_max Temperature max value. 221temp[1-*]_max Temperature max value.
diff --git a/Documentation/hwmon/w83627ehf b/Documentation/hwmon/w83627ehf
index caa610a297e8..8a15a7408753 100644
--- a/Documentation/hwmon/w83627ehf
+++ b/Documentation/hwmon/w83627ehf
@@ -10,7 +10,7 @@ Supported chips:
10Authors: 10Authors:
11 Jean Delvare <khali@linux-fr.org> 11 Jean Delvare <khali@linux-fr.org>
12 Yuan Mu (Winbond) 12 Yuan Mu (Winbond)
13 Rudolf Marek <r.marek@sh.cvut.cz> 13 Rudolf Marek <r.marek@assembler.cz>
14 14
15Description 15Description
16----------- 16-----------
diff --git a/Documentation/hwmon/w83791d b/Documentation/hwmon/w83791d
index 19b2ed739fa1..db9881df88a5 100644
--- a/Documentation/hwmon/w83791d
+++ b/Documentation/hwmon/w83791d
@@ -18,7 +18,7 @@ Credits:
18 and Mark Studebaker <mdsxyz123@yahoo.com> 18 and Mark Studebaker <mdsxyz123@yahoo.com>
19 w83792d.c: 19 w83792d.c:
20 Chunhao Huang <DZShen@Winbond.com.tw>, 20 Chunhao Huang <DZShen@Winbond.com.tw>,
21 Rudolf Marek <r.marek@sh.cvut.cz> 21 Rudolf Marek <r.marek@assembler.cz>
22 22
23Additional contributors: 23Additional contributors:
24 Sven Anders <anders@anduras.de> 24 Sven Anders <anders@anduras.de>
diff --git a/Documentation/hwmon/w83793 b/Documentation/hwmon/w83793
new file mode 100644
index 000000000000..45e5408340e0
--- /dev/null
+++ b/Documentation/hwmon/w83793
@@ -0,0 +1,110 @@
1Kernel driver w83793
2====================
3
4Supported chips:
5 * Winbond W83793G/W83793R
6 Prefix: 'w83793'
7 Addresses scanned: I2C 0x2c - 0x2f
8 Datasheet: Still not published
9
10Authors:
11 Yuan Mu (Winbond Electronics)
12 Rudolf Marek <r.marek@assembler.cz>
13
14
15Module parameters
16-----------------
17
18* reset int
19 (default 0)
20 This parameter is not recommended, it will lose motherboard specific
21 settings. Use 'reset=1' to reset the chip when loading this module.
22
23* force_subclients=bus,caddr,saddr1,saddr2
24 This is used to force the i2c addresses for subclients of
25 a certain chip. Typical usage is `force_subclients=0,0x2f,0x4a,0x4b'
26 to force the subclients of chip 0x2f on bus 0 to i2c addresses
27 0x4a and 0x4b.
28
29
30Description
31-----------
32
33This driver implements support for Winbond W83793G/W83793R chips.
34
35* Exported features
36 This driver exports 10 voltage sensors, up to 12 fan tachometer inputs,
37 6 remote temperatures, up to 8 sets of PWM fan controls, SmartFan
38 (automatic fan speed control) on all temperature/PWM combinations, 2
39 sets of 6-pin CPU VID input.
40
41* Sensor resolutions
42 If your motherboard maker used the reference design, the resolution of
43 voltage0-2 is 2mV, resolution of voltage3/4/5 is 16mV, 8mV for voltage6,
44 24mV for voltage7/8. Temp1-4 have a 0.25 degree Celsius resolution,
45 temp5-6 have a 1 degree Celsiis resolution.
46
47* Temperature sensor types
48 Temp1-4 have 3 possible types. It can be read from (and written to)
49 temp[1-4]_type.
50 - If the value of 0, the related temperature channel stops
51 monitoring.
52 - If the value is 3, it starts monitoring using a remote termal diode
53 (default).
54 - If the value is 5, it starts monitoring using the temperature sensor
55 in AMD CPU and get result by AMDSI.
56 - If the value is 6, it starts monitoring using the temperature sensor
57 in Intel CPU and get result by PECI.
58 Temp5-6 can be connected to external thermistors (value of
59 temp[5-6]_type is 4). They can also be disabled (value is 0).
60
61* Alarm mechanism
62 For voltage sensors, an alarm triggers if the measured value is below
63 the low voltage limit or over the high voltage limit.
64 For temperature sensors, an alarm triggers if the measured value goes
65 above the high temperature limit, and wears off only after the measured
66 value drops below the hysteresis value.
67 For fan sensors, an alarm triggers if the measured value is below the
68 low speed limit.
69
70* SmartFan/PWM control
71 If you want to set a pwm fan to manual mode, you just need to make sure it
72 is not controlled by any temp channel, for example, you want to set fan1
73 to manual mode, you need to check the value of temp[1-6]_fan_map, make
74 sure bit 0 is cleared in the 6 values. And then set the pwm1 value to
75 control the fan.
76
77 Each temperature channel can control all the 8 PWM outputs (by setting the
78 corresponding bit in tempX_fan_map), you can set the temperature channel
79 mode using temp[1-6]_pwm_enable, 2 is Thermal Cruise mode and 3
80 is the SmartFanII mode. Temperature channels will try to speed up or
81 slow down all controlled fans, this means one fan can receive different
82 PWM value requests from different temperature channels, but the chip
83 will always pick the safest (max) PWM value for each fan.
84
85 In Thermal Cruise mode, the chip attempts to keep the temperature at a
86 predefined value, within a tolerance margin. So if tempX_input >
87 thermal_cruiseX + toleranceX, the chip will increase the PWM value,
88 if tempX_input < thermal_cruiseX - toleranceX, the chip will decrease
89 the PWM value. If the temperature is within the tolerance range, the PWM
90 value is left unchanged.
91
92 SmartFanII works differently, you have to define up to 7 PWM, temperature
93 trip points, defining a PWM/temperature curve which the chip will follow.
94 While not fundamentally different from the Thermal Cruise mode, the
95 implementation is quite different, giving you a finer-grained control.
96
97* Chassis
98 If the case open alarm triggers, it will stay in this state unless cleared
99 by any write to the sysfs file "chassis".
100
101* VID and VRM
102 The VRM version is detected automatically, don't modify the it unless you
103 *do* know the cpu VRM version and it's not properly detected.
104
105
106Notes
107-----
108
109 Only Fan1-5 and PWM1-3 are guaranteed to always exist, other fan inputs and
110 PWM outputs may or may not exist depending on the chip pin configuration.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index d8323b8893c3..ef69c75780bf 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1656,6 +1656,12 @@ and is between 256 and 4096 characters. It is defined in the file
1656 sym53c416= [HW,SCSI] 1656 sym53c416= [HW,SCSI]
1657 See header of drivers/scsi/sym53c416.c. 1657 See header of drivers/scsi/sym53c416.c.
1658 1658
1659 sysrq_always_enabled
1660 [KNL]
1661 Ignore sysrq setting - this boot parameter will
1662 neutralize any effect of /proc/sys/kernel/sysrq.
1663 Useful for debugging.
1664
1659 t128= [HW,SCSI] 1665 t128= [HW,SCSI]
1660 See header of drivers/scsi/t128.c. 1666 See header of drivers/scsi/t128.c.
1661 1667
diff --git a/MAINTAINERS b/MAINTAINERS
index 8a0bfeca55c9..dea5b2a6de0a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -277,7 +277,7 @@ S: Maintained
277 277
278ALI1563 I2C DRIVER 278ALI1563 I2C DRIVER
279P: Rudolf Marek 279P: Rudolf Marek
280M: r.marek@sh.cvut.cz 280M: r.marek@assembler.cz
281L: i2c@lm-sensors.org 281L: i2c@lm-sensors.org
282S: Maintained 282S: Maintained
283 283
@@ -296,6 +296,13 @@ L: info-linux@geode.amd.com
296W: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html 296W: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html
297S: Supported 297S: Supported
298 298
299AMS (Apple Motion Sensor) DRIVER
300P: Stelian Pop
301M: stelian@popies.net
302P: Michael Hanselmann
303M: linux-kernel@hansmi.ch
304S: Supported
305
299AMSO1100 RNIC DRIVER 306AMSO1100 RNIC DRIVER
300P: Tom Tucker 307P: Tom Tucker
301M: tom@opengridcomputing.com 308M: tom@opengridcomputing.com
@@ -1747,6 +1754,13 @@ W: http://nfs.sourceforge.net/
1747W: http://www.cse.unsw.edu.au/~neilb/patches/linux-devel/ 1754W: http://www.cse.unsw.edu.au/~neilb/patches/linux-devel/
1748S: Maintained 1755S: Maintained
1749 1756
1757KERNEL VIRTUAL MACHINE (KVM)
1758P: Avi Kivity
1759M: avi@qumranet.com
1760L: kvm-devel@lists.sourceforge.net
1761W: kvm.sourceforge.net
1762S: Supported
1763
1750KEXEC 1764KEXEC
1751P: Eric Biederman 1765P: Eric Biederman
1752M: ebiederm@xmission.com 1766M: ebiederm@xmission.com
@@ -3429,6 +3443,12 @@ M: bezaur@gmail.com
3429L: lm-sensors@lm-sensors.org 3443L: lm-sensors@lm-sensors.org
3430S: Maintained 3444S: Maintained
3431 3445
3446W83793 HARDWARE MONITORING DRIVER
3447P: Rudolf Marek
3448M: r.marek@assembler.cz
3449L: lm-sensors@lm-sensors.org
3450S: Maintained
3451
3432W83L51xD SD/MMC CARD INTERFACE DRIVER 3452W83L51xD SD/MMC CARD INTERFACE DRIVER
3433P: Pierre Ossman 3453P: Pierre Ossman
3434M: drzeus-wbsd@drzeus.cx 3454M: drzeus-wbsd@drzeus.cx
diff --git a/Makefile b/Makefile
index 4eabaa8afbff..4a4720387936 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 19 3SUBLEVEL = 20
4EXTRAVERSION = 4EXTRAVERSION =-rc1
5NAME=Avast! A bilge rat! 5NAME=Avast! A bilge rat!
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -496,11 +496,6 @@ else
496CFLAGS += -fomit-frame-pointer 496CFLAGS += -fomit-frame-pointer
497endif 497endif
498 498
499ifdef CONFIG_UNWIND_INFO
500CFLAGS += -fasynchronous-unwind-tables
501LDFLAGS_vmlinux += --eh-frame-hdr
502endif
503
504ifdef CONFIG_DEBUG_INFO 499ifdef CONFIG_DEBUG_INFO
505CFLAGS += -g 500CFLAGS += -g
506endif 501endif
@@ -1390,12 +1385,18 @@ endif #ifeq ($(mixed-targets),1)
1390 1385
1391PHONY += checkstack kernelrelease kernelversion 1386PHONY += checkstack kernelrelease kernelversion
1392 1387
1393# Use $(SUBARCH) here instead of $(ARCH) so that this works for UML. 1388# UML needs a little special treatment here. It wants to use the host
1394# In the UML case, $(SUBARCH) is the name of the underlying 1389# toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone
1395# architecture, while for all other arches, it is the same as $(ARCH). 1390# else wants $(ARCH), including people doing cross-builds, which means
1391# that $(SUBARCH) doesn't work here.
1392ifeq ($(ARCH), um)
1393CHECKSTACK_ARCH := $(SUBARCH)
1394else
1395CHECKSTACK_ARCH := $(ARCH)
1396endif
1396checkstack: 1397checkstack:
1397 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ 1398 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1398 $(PERL) $(src)/scripts/checkstack.pl $(SUBARCH) 1399 $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
1399 1400
1400kernelrelease: 1401kernelrelease:
1401 $(if $(wildcard include/config/kernel.release), $(Q)echo $(KERNELRELEASE), \ 1402 $(if $(wildcard include/config/kernel.release), $(Q)echo $(KERNELRELEASE), \
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index aa1d400d721a..6783c2e5512d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -740,7 +740,7 @@ config XIP_PHYS_ADDR
740 740
741endmenu 741endmenu
742 742
743if (ARCH_SA1100 || ARCH_INTEGRATOR || ARCH_OMAP) 743if (ARCH_SA1100 || ARCH_INTEGRATOR || ARCH_OMAP || ARCH_IMX )
744 744
745menu "CPU Frequency scaling" 745menu "CPU Frequency scaling"
746 746
@@ -767,6 +767,15 @@ config CPU_FREQ_INTEGRATOR
767 767
768 If in doubt, say Y. 768 If in doubt, say Y.
769 769
770config CPU_FREQ_IMX
771 tristate "CPUfreq driver for i.MX CPUs"
772 depends on ARCH_IMX && CPU_FREQ
773 default n
774 help
775 This enables the CPUfreq driver for i.MX CPUs.
776
777 If in doubt, say N.
778
770endmenu 779endmenu
771 780
772endif 781endif
@@ -945,6 +954,8 @@ source "drivers/video/Kconfig"
945 954
946source "sound/Kconfig" 955source "sound/Kconfig"
947 956
957source "drivers/hid/Kconfig"
958
948source "drivers/usb/Kconfig" 959source "drivers/usb/Kconfig"
949 960
950source "drivers/mmc/Kconfig" 961source "drivers/mmc/Kconfig"
diff --git a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c
index a11fb9a40c04..2c37b70b17ab 100644
--- a/arch/arm/kernel/apm.c
+++ b/arch/arm/kernel/apm.c
@@ -423,7 +423,7 @@ static int apm_open(struct inode * inode, struct file * filp)
423{ 423{
424 struct apm_user *as; 424 struct apm_user *as;
425 425
426 as = (struct apm_user *)kzalloc(sizeof(*as), GFP_KERNEL); 426 as = kzalloc(sizeof(*as), GFP_KERNEL);
427 if (as) { 427 if (as) {
428 /* 428 /*
429 * XXX - this is a tiny bit broken, when we consider BSD 429 * XXX - this is a tiny bit broken, when we consider BSD
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index 3173924a9b60..e8f74363328c 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -331,6 +331,19 @@
331 CALL(sys_mbind) 331 CALL(sys_mbind)
332/* 320 */ CALL(sys_get_mempolicy) 332/* 320 */ CALL(sys_get_mempolicy)
333 CALL(sys_set_mempolicy) 333 CALL(sys_set_mempolicy)
334 CALL(sys_openat)
335 CALL(sys_mkdirat)
336 CALL(sys_mknodat)
337/* 325 */ CALL(sys_fchownat)
338 CALL(sys_futimesat)
339 CALL(sys_fstatat64)
340 CALL(sys_unlinkat)
341 CALL(sys_renameat)
342/* 330 */ CALL(sys_linkat)
343 CALL(sys_symlinkat)
344 CALL(sys_readlinkat)
345 CALL(sys_fchmodat)
346 CALL(sys_faccessat)
334#ifndef syscalls_counted 347#ifndef syscalls_counted
335.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls 348.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
336#define syscalls_counted 349#define syscalls_counted
diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
index a786f769035d..71257e3d513f 100644
--- a/arch/arm/kernel/ecard.c
+++ b/arch/arm/kernel/ecard.c
@@ -353,7 +353,7 @@ int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num)
353 } 353 }
354 if (c_id(&excd) == 0x80) { /* loader */ 354 if (c_id(&excd) == 0x80) { /* loader */
355 if (!ec->loader) { 355 if (!ec->loader) {
356 ec->loader = (loader_t)kmalloc(c_len(&excd), 356 ec->loader = kmalloc(c_len(&excd),
357 GFP_KERNEL); 357 GFP_KERNEL);
358 if (ec->loader) 358 if (ec->loader)
359 ecard_readbytes(ec->loader, ec, 359 ecard_readbytes(ec->loader, ec,
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index bda0748ffb00..d994561816a1 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -22,30 +22,31 @@
22#include <asm/thread_info.h> 22#include <asm/thread_info.h>
23#include <asm/system.h> 23#include <asm/system.h>
24 24
25#define KERNEL_RAM_ADDR (PAGE_OFFSET + TEXT_OFFSET) 25#define KERNEL_RAM_VADDR (PAGE_OFFSET + TEXT_OFFSET)
26#define KERNEL_RAM_PADDR (PHYS_OFFSET + TEXT_OFFSET)
26 27
27/* 28/*
28 * swapper_pg_dir is the virtual address of the initial page table. 29 * swapper_pg_dir is the virtual address of the initial page table.
29 * We place the page tables 16K below KERNEL_RAM_ADDR. Therefore, we must 30 * We place the page tables 16K below KERNEL_RAM_VADDR. Therefore, we must
30 * make sure that KERNEL_RAM_ADDR is correctly set. Currently, we expect 31 * make sure that KERNEL_RAM_VADDR is correctly set. Currently, we expect
31 * the least significant 16 bits to be 0x8000, but we could probably 32 * the least significant 16 bits to be 0x8000, but we could probably
32 * relax this restriction to KERNEL_RAM_ADDR >= PAGE_OFFSET + 0x4000. 33 * relax this restriction to KERNEL_RAM_VADDR >= PAGE_OFFSET + 0x4000.
33 */ 34 */
34#if (KERNEL_RAM_ADDR & 0xffff) != 0x8000 35#if (KERNEL_RAM_VADDR & 0xffff) != 0x8000
35#error KERNEL_RAM_ADDR must start at 0xXXXX8000 36#error KERNEL_RAM_VADDR must start at 0xXXXX8000
36#endif 37#endif
37 38
38 .globl swapper_pg_dir 39 .globl swapper_pg_dir
39 .equ swapper_pg_dir, KERNEL_RAM_ADDR - 0x4000 40 .equ swapper_pg_dir, KERNEL_RAM_VADDR - 0x4000
40 41
41 .macro pgtbl, rd 42 .macro pgtbl, rd
42 ldr \rd, =(__virt_to_phys(KERNEL_RAM_ADDR - 0x4000)) 43 ldr \rd, =(KERNEL_RAM_PADDR - 0x4000)
43 .endm 44 .endm
44 45
45#ifdef CONFIG_XIP_KERNEL 46#ifdef CONFIG_XIP_KERNEL
46#define TEXTADDR XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) 47#define TEXTADDR XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
47#else 48#else
48#define TEXTADDR KERNEL_RAM_ADDR 49#define TEXTADDR KERNEL_RAM_VADDR
49#endif 50#endif
50 51
51/* 52/*
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 238dd9b6db84..cf2bd4242803 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -354,9 +354,6 @@ static void __init setup_processor(void)
354#ifndef CONFIG_ARM_THUMB 354#ifndef CONFIG_ARM_THUMB
355 elf_hwcap &= ~HWCAP_THUMB; 355 elf_hwcap &= ~HWCAP_THUMB;
356#endif 356#endif
357#ifndef CONFIG_VFP
358 elf_hwcap &= ~HWCAP_VFP;
359#endif
360 357
361 cpu_proc_init(); 358 cpu_proc_init();
362} 359}
diff --git a/arch/arm/mach-at91rm9200/at91sam9260_devices.c b/arch/arm/mach-at91rm9200/at91sam9260_devices.c
index a6c596dc4516..f42d3a40ec3c 100644
--- a/arch/arm/mach-at91rm9200/at91sam9260_devices.c
+++ b/arch/arm/mach-at91rm9200/at91sam9260_devices.c
@@ -18,6 +18,7 @@
18#include <asm/arch/gpio.h> 18#include <asm/arch/gpio.h>
19#include <asm/arch/at91sam9260.h> 19#include <asm/arch/at91sam9260.h>
20#include <asm/arch/at91sam926x_mc.h> 20#include <asm/arch/at91sam926x_mc.h>
21#include <asm/arch/at91sam9260_matrix.h>
21 22
22#include "generic.h" 23#include "generic.h"
23 24
diff --git a/arch/arm/mach-at91rm9200/board-sam9260ek.c b/arch/arm/mach-at91rm9200/board-sam9260ek.c
index ffca9bdec37b..da5d58ac870b 100644
--- a/arch/arm/mach-at91rm9200/board-sam9260ek.c
+++ b/arch/arm/mach-at91rm9200/board-sam9260ek.c
@@ -119,6 +119,7 @@ static struct spi_board_info ek_spi_devices[] = {
119 * MACB Ethernet device 119 * MACB Ethernet device
120 */ 120 */
121static struct __initdata eth_platform_data ek_macb_data = { 121static struct __initdata eth_platform_data ek_macb_data = {
122 .phy_irq_pin = AT91_PIN_PA7,
122 .is_rmii = 1, 123 .is_rmii = 1,
123}; 124};
124 125
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 0b27d79f2efd..02272aa36e90 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -9,6 +9,8 @@
9 9
10obj-y += irq.o time.o dma.o generic.o 10obj-y += irq.o time.o dma.o generic.o
11 11
12obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o
13
12# Specific board support 14# Specific board support
13obj-$(CONFIG_ARCH_MX1ADS) += mx1ads.o 15obj-$(CONFIG_ARCH_MX1ADS) += mx1ads.o
14 16
diff --git a/arch/arm/mach-imx/cpufreq.c b/arch/arm/mach-imx/cpufreq.c
new file mode 100644
index 000000000000..ac5f99895660
--- /dev/null
+++ b/arch/arm/mach-imx/cpufreq.c
@@ -0,0 +1,287 @@
1/*
2 * cpu.c: clock scaling for the iMX
3 *
4 * Copyright (C) 2000 2001, The Delft University of Technology
5 * Copyright (c) 2004 Sascha Hauer <sascha@saschahauer.de>
6 * Copyright (C) 2006 Inky Lung <ilung@cwlinux.com>
7 * Copyright (C) 2006 Pavel Pisa, PiKRON <ppisa@pikron.com>
8 *
9 * Based on SA1100 version written by:
10 * - Johan Pouwelse (J.A.Pouwelse@its.tudelft.nl): initial version
11 * - Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29/*#define DEBUG*/
30
31#include <linux/kernel.h>
32#include <linux/types.h>
33#include <linux/init.h>
34#include <linux/cpufreq.h>
35#include <asm/system.h>
36
37#include <asm/hardware.h>
38
39#include "generic.h"
40
41#ifndef __val2mfld
42#define __val2mfld(mask,val) (((mask)&~((mask)<<1))*(val)&(mask))
43#endif
44#ifndef __mfld2val
45#define __mfld2val(mask,val) (((val)&(mask))/((mask)&~((mask)<<1)))
46#endif
47
48#define CR_920T_CLOCK_MODE 0xC0000000
49#define CR_920T_FASTBUS_MODE 0x00000000
50#define CR_920T_ASYNC_MODE 0xC0000000
51
52static u32 mpctl0_at_boot;
53
54static void imx_set_async_mode(void)
55{
56 adjust_cr(CR_920T_CLOCK_MODE, CR_920T_ASYNC_MODE);
57}
58
59static void imx_set_fastbus_mode(void)
60{
61 adjust_cr(CR_920T_CLOCK_MODE, CR_920T_FASTBUS_MODE);
62}
63
64static void imx_set_mpctl0(u32 mpctl0)
65{
66 unsigned long flags;
67
68 if (mpctl0 == 0) {
69 local_irq_save(flags);
70 CSCR &= ~CSCR_MPEN;
71 local_irq_restore(flags);
72 return;
73 }
74
75 local_irq_save(flags);
76 MPCTL0 = mpctl0;
77 CSCR |= CSCR_MPEN;
78 local_irq_restore(flags);
79}
80
81/**
82 * imx_compute_mpctl - compute new PLL parameters
83 * @new_mpctl: pointer to location assigned by new PLL control register value
84 * @cur_mpctl: current PLL control register parameters
85 * @freq: required frequency in Hz
86 * @relation: is one of %CPUFREQ_RELATION_L (supremum)
87 * and %CPUFREQ_RELATION_H (infimum)
88 */
89long imx_compute_mpctl(u32 *new_mpctl, u32 cur_mpctl, unsigned long freq, int relation)
90{
91 u32 f_ref = (CSCR & CSCR_SYSTEM_SEL) ? 16000000 : (CLK32 * 512);
92 u32 mfi;
93 u32 mfn;
94 u32 mfd;
95 u32 pd;
96 unsigned long long ll;
97 long l;
98 long quot;
99
100 /* Fdppl=2*Fref*(MFI+MFN/(MFD+1))/(PD+1) */
101 /* PD=<0,15>, MFD=<1,1023>, MFI=<5,15> MFN=<0,1022> */
102
103 if (cur_mpctl) {
104 mfd = ((cur_mpctl >> 16) & 0x3ff) + 1;
105 pd = ((cur_mpctl >> 26) & 0xf) + 1;
106 } else {
107 pd=2; mfd=313;
108 }
109
110 /* pd=2; mfd=313; mfi=8; mfn=183; */
111 /* (MFI+MFN/(MFD)) = Fdppl / (2*Fref) * (PD); */
112
113 quot = (f_ref + (1 << 9)) >> 10;
114 l = (freq * pd + quot) / (2 * quot);
115 mfi = l >> 10;
116 mfn = ((l & ((1 << 10) - 1)) * mfd + (1 << 9)) >> 10;
117
118 mfd -= 1;
119 pd -= 1;
120
121 *new_mpctl = ((mfi & 0xf) << 10) | (mfn & 0x3ff) | ((mfd & 0x3ff) << 16)
122 | ((pd & 0xf) << 26);
123
124 ll = 2 * (unsigned long long)f_ref * ( (mfi<<16) + (mfn<<16) / (mfd+1) );
125 quot = (pd+1) * (1<<16);
126 ll += quot / 2;
127 do_div(ll, quot);
128 freq = ll;
129
130 pr_debug(KERN_DEBUG "imx: new PLL parameters pd=%d mfd=%d mfi=%d mfn=%d, freq=%ld\n",
131 pd, mfd, mfi, mfn, freq);
132
133 return freq;
134}
135
136
137static int imx_verify_speed(struct cpufreq_policy *policy)
138{
139 if (policy->cpu != 0)
140 return -EINVAL;
141
142 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
143
144 return 0;
145}
146
147static unsigned int imx_get_speed(unsigned int cpu)
148{
149 unsigned int freq;
150 unsigned int cr;
151 unsigned int cscr;
152 unsigned int bclk_div;
153
154 if (cpu)
155 return 0;
156
157 cscr = CSCR;
158 bclk_div = __mfld2val(CSCR_BCLK_DIV, cscr) + 1;
159 cr = get_cr();
160
161 if((cr & CR_920T_CLOCK_MODE) == CR_920T_FASTBUS_MODE) {
162 freq = imx_get_system_clk();
163 freq = (freq + bclk_div/2) / bclk_div;
164 } else {
165 freq = imx_get_mcu_clk();
166 if (cscr & CSCR_MPU_PRESC)
167 freq /= 2;
168 }
169
170 freq = (freq + 500) / 1000;
171
172 return freq;
173}
174
175static int imx_set_target(struct cpufreq_policy *policy,
176 unsigned int target_freq,
177 unsigned int relation)
178{
179 struct cpufreq_freqs freqs;
180 u32 mpctl0 = 0;
181 u32 cscr;
182 unsigned long flags;
183 long freq;
184 long sysclk;
185 unsigned int bclk_div = 1;
186
187 freq = target_freq * 1000;
188
189 pr_debug(KERN_DEBUG "imx: requested frequency %ld Hz, mpctl0 at boot 0x%08x\n",
190 freq, mpctl0_at_boot);
191
192 sysclk = imx_get_system_clk();
193
194 if (freq > sysclk + 1000000) {
195 freq = imx_compute_mpctl(&mpctl0, mpctl0_at_boot, freq, relation);
196 if (freq < 0) {
197 printk(KERN_WARNING "imx: target frequency %ld Hz cannot be set\n", freq);
198 return -EINVAL;
199 }
200 } else {
201 if(freq + 1000 < sysclk) {
202 if (relation == CPUFREQ_RELATION_L)
203 bclk_div = (sysclk - 1000) / freq;
204 else
205 bclk_div = (sysclk + freq + 1000) / freq;
206
207 if(bclk_div > 16)
208 bclk_div = 16;
209 }
210 freq = (sysclk + bclk_div / 2) / bclk_div;
211 }
212
213 freqs.old = imx_get_speed(0);
214 freqs.new = (freq + 500) / 1000;
215 freqs.cpu = 0;
216 freqs.flags = 0;
217
218 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
219
220 local_irq_save(flags);
221
222 imx_set_fastbus_mode();
223
224 imx_set_mpctl0(mpctl0);
225
226 cscr = CSCR;
227 cscr &= ~CSCR_BCLK_DIV;
228 cscr |= __val2mfld(CSCR_BCLK_DIV, bclk_div - 1);
229 CSCR = cscr;
230
231 if(mpctl0) {
232 CSCR |= CSCR_MPLL_RESTART;
233
234 /* Wait until MPLL is stablized */
235 while( CSCR & CSCR_MPLL_RESTART );
236
237 imx_set_async_mode();
238 }
239
240 local_irq_restore(flags);
241
242 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
243
244 pr_debug(KERN_INFO "imx: set frequency %ld Hz, running from %s\n",
245 freq, mpctl0? "MPLL": "SPLL");
246
247 return 0;
248}
249
250static int __init imx_cpufreq_driver_init(struct cpufreq_policy *policy)
251{
252 printk(KERN_INFO "i.MX cpu freq change driver v1.0\n");
253
254 if (policy->cpu != 0)
255 return -EINVAL;
256
257 policy->cur = policy->min = policy->max = imx_get_speed(0);
258 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
259 policy->cpuinfo.min_freq = 8000;
260 policy->cpuinfo.max_freq = 200000;
261 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
262 return 0;
263}
264
265static struct cpufreq_driver imx_driver = {
266 .flags = CPUFREQ_STICKY,
267 .verify = imx_verify_speed,
268 .target = imx_set_target,
269 .get = imx_get_speed,
270 .init = imx_cpufreq_driver_init,
271 .name = "imx",
272};
273
274static int __init imx_cpufreq_init(void)
275{
276
277 mpctl0_at_boot = 0;
278
279 if((CSCR & CSCR_MPEN) &&
280 ((get_cr() & CR_920T_CLOCK_MODE) != CR_920T_FASTBUS_MODE))
281 mpctl0_at_boot = MPCTL0;
282
283 return cpufreq_register_driver(&imx_driver);
284}
285
286arch_initcall(imx_cpufreq_init);
287
diff --git a/arch/arm/mach-netx/time.c b/arch/arm/mach-netx/time.c
index 0993336c0b55..5773b55ef4a6 100644
--- a/arch/arm/mach-netx/time.c
+++ b/arch/arm/mach-netx/time.c
@@ -19,6 +19,8 @@
19 19
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/clocksource.h>
22 24
23#include <asm/hardware.h> 25#include <asm/hardware.h>
24#include <asm/io.h> 26#include <asm/io.h>
@@ -26,15 +28,6 @@
26#include <asm/arch/netx-regs.h> 28#include <asm/arch/netx-regs.h>
27 29
28/* 30/*
29 * Returns number of us since last clock interrupt. Note that interrupts
30 * will have been disabled by do_gettimeoffset()
31 */
32static unsigned long netx_gettimeoffset(void)
33{
34 return readl(NETX_GPIO_COUNTER_CURRENT(0)) / 100;
35}
36
37/*
38 * IRQ handler for the timer 31 * IRQ handler for the timer
39 */ 32 */
40static irqreturn_t 33static irqreturn_t
@@ -43,6 +36,7 @@ netx_timer_interrupt(int irq, void *dev_id)
43 write_seqlock(&xtime_lock); 36 write_seqlock(&xtime_lock);
44 37
45 timer_tick(); 38 timer_tick();
39
46 write_sequnlock(&xtime_lock); 40 write_sequnlock(&xtime_lock);
47 41
48 /* acknowledge interrupt */ 42 /* acknowledge interrupt */
@@ -51,13 +45,26 @@ netx_timer_interrupt(int irq, void *dev_id)
51 return IRQ_HANDLED; 45 return IRQ_HANDLED;
52} 46}
53 47
54
55static struct irqaction netx_timer_irq = { 48static struct irqaction netx_timer_irq = {
56 .name = "NetX Timer Tick", 49 .name = "NetX Timer Tick",
57 .flags = IRQF_DISABLED | IRQF_TIMER, 50 .flags = IRQF_DISABLED | IRQF_TIMER,
58 .handler = netx_timer_interrupt, 51 .handler = netx_timer_interrupt,
59}; 52};
60 53
54cycle_t netx_get_cycles(void)
55{
56 return readl(NETX_GPIO_COUNTER_CURRENT(1));
57}
58
59static struct clocksource clocksource_netx = {
60 .name = "netx_timer",
61 .rating = 200,
62 .read = netx_get_cycles,
63 .mask = CLOCKSOURCE_MASK(32),
64 .shift = 20,
65 .is_continuous = 1,
66};
67
61/* 68/*
62 * Set up timer interrupt 69 * Set up timer interrupt
63 */ 70 */
@@ -80,9 +87,20 @@ static void __init netx_timer_init(void)
80 NETX_GPIO_COUNTER_CTRL(0)); 87 NETX_GPIO_COUNTER_CTRL(0));
81 88
82 setup_irq(NETX_IRQ_TIMER0, &netx_timer_irq); 89 setup_irq(NETX_IRQ_TIMER0, &netx_timer_irq);
90
91 /* Setup timer one for clocksource */
92 writel(0, NETX_GPIO_COUNTER_CTRL(1));
93 writel(0, NETX_GPIO_COUNTER_CURRENT(1));
94 writel(0xFFFFFFFF, NETX_GPIO_COUNTER_MAX(1));
95
96 writel(NETX_GPIO_COUNTER_CTRL_RUN,
97 NETX_GPIO_COUNTER_CTRL(1));
98
99 clocksource_netx.mult =
100 clocksource_hz2mult(CLOCK_TICK_RATE, clocksource_netx.shift);
101 clocksource_register(&clocksource_netx);
83} 102}
84 103
85struct sys_timer netx_timer = { 104struct sys_timer netx_timer = {
86 .init = netx_timer_init, 105 .init = netx_timer_init,
87 .offset = netx_gettimeoffset,
88}; 106};
diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index d135568dc9e7..8781aaeb576b 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -43,6 +43,7 @@ config MACH_OMAP_H3
43config MACH_OMAP_OSK 43config MACH_OMAP_OSK
44 bool "TI OSK Support" 44 bool "TI OSK Support"
45 depends on ARCH_OMAP1 && ARCH_OMAP16XX 45 depends on ARCH_OMAP1 && ARCH_OMAP16XX
46 select TPS65010
46 help 47 help
47 TI OMAP 5912 OSK (OMAP Starter Kit) board support. Say Y here 48 TI OMAP 5912 OSK (OMAP Starter Kit) board support. Say Y here
48 if you have such a board. 49 if you have such a board.
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index 3a622801d7b0..7d0cf7af88ce 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/irq.h> 32#include <linux/irq.h>
33#include <linux/interrupt.h>
33 34
34#include <linux/mtd/mtd.h> 35#include <linux/mtd/mtd.h>
35#include <linux/mtd/partitions.h> 36#include <linux/mtd/partitions.h>
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c
index b91466861029..3775b8f38429 100644
--- a/arch/arm/mach-pxa/time.c
+++ b/arch/arm/mach-pxa/time.c
@@ -18,6 +18,7 @@
18#include <linux/signal.h> 18#include <linux/signal.h>
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/clocksource.h>
21 22
22#include <asm/system.h> 23#include <asm/system.h>
23#include <asm/hardware.h> 24#include <asm/hardware.h>
@@ -48,27 +49,6 @@ static int pxa_set_rtc(void)
48 return 0; 49 return 0;
49} 50}
50 51
51/* IRQs are disabled before entering here from do_gettimeofday() */
52static unsigned long pxa_gettimeoffset (void)
53{
54 long ticks_to_match, elapsed, usec;
55
56 /* Get ticks before next timer match */
57 ticks_to_match = OSMR0 - OSCR;
58
59 /* We need elapsed ticks since last match */
60 elapsed = LATCH - ticks_to_match;
61
62 /* don't get fooled by the workaround in pxa_timer_interrupt() */
63 if (elapsed <= 0)
64 return 0;
65
66 /* Now convert them to usec */
67 usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH;
68
69 return usec;
70}
71
72#ifdef CONFIG_NO_IDLE_HZ 52#ifdef CONFIG_NO_IDLE_HZ
73static unsigned long initial_match; 53static unsigned long initial_match;
74static int match_posponed; 54static int match_posponed;
@@ -121,6 +101,20 @@ static struct irqaction pxa_timer_irq = {
121 .handler = pxa_timer_interrupt, 101 .handler = pxa_timer_interrupt,
122}; 102};
123 103
104cycle_t pxa_get_cycles(void)
105{
106 return OSCR;
107}
108
109static struct clocksource clocksource_pxa = {
110 .name = "pxa_timer",
111 .rating = 200,
112 .read = pxa_get_cycles,
113 .mask = CLOCKSOURCE_MASK(32),
114 .shift = 20,
115 .is_continuous = 1,
116};
117
124static void __init pxa_timer_init(void) 118static void __init pxa_timer_init(void)
125{ 119{
126 struct timespec tv; 120 struct timespec tv;
@@ -139,6 +133,14 @@ static void __init pxa_timer_init(void)
139 OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */ 133 OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */
140 OSMR0 = OSCR + LATCH; /* set initial match */ 134 OSMR0 = OSCR + LATCH; /* set initial match */
141 local_irq_restore(flags); 135 local_irq_restore(flags);
136
137 /* on PXA OSCR runs continiously and is not written to, so we can use it
138 * as clock source directly.
139 */
140 clocksource_pxa.mult =
141 clocksource_hz2mult(CLOCK_TICK_RATE, clocksource_pxa.shift);
142 clocksource_register(&clocksource_pxa);
143
142} 144}
143 145
144#ifdef CONFIG_NO_IDLE_HZ 146#ifdef CONFIG_NO_IDLE_HZ
@@ -211,7 +213,6 @@ struct sys_timer pxa_timer = {
211 .init = pxa_timer_init, 213 .init = pxa_timer_init,
212 .suspend = pxa_timer_suspend, 214 .suspend = pxa_timer_suspend,
213 .resume = pxa_timer_resume, 215 .resume = pxa_timer_resume,
214 .offset = pxa_gettimeoffset,
215#ifdef CONFIG_NO_IDLE_HZ 216#ifdef CONFIG_NO_IDLE_HZ
216 .dyn_tick = &pxa_dyn_tick, 217 .dyn_tick = &pxa_dyn_tick,
217#endif 218#endif
diff --git a/arch/arm/mach-pxa/trizeps4.c b/arch/arm/mach-pxa/trizeps4.c
index c1827d021ba8..119c64b7223f 100644
--- a/arch/arm/mach-pxa/trizeps4.c
+++ b/arch/arm/mach-pxa/trizeps4.c
@@ -393,10 +393,6 @@ static struct pxafb_mach_info sharp_lcd = {
393 .pxafb_backlight_power = board_backlight_power, 393 .pxafb_backlight_power = board_backlight_power,
394}; 394};
395 395
396static void __init trizeps4_fixup(struct machine_desc *desc, struct tag *tags, char **cmdline, struct meminfo *mi)
397{
398}
399
400static void __init trizeps4_init(void) 396static void __init trizeps4_init(void)
401{ 397{
402 platform_add_devices(trizeps4_devices, ARRAY_SIZE(trizeps4_devices)); 398 platform_add_devices(trizeps4_devices, ARRAY_SIZE(trizeps4_devices));
@@ -469,7 +465,6 @@ MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module")
469 .phys_io = 0x40000000, 465 .phys_io = 0x40000000,
470 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, 466 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
471 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100, 467 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100,
472 .fixup = trizeps4_fixup,
473 .init_machine = trizeps4_init, 468 .init_machine = trizeps4_init,
474 .map_io = trizeps4_map_io, 469 .map_io = trizeps4_map_io,
475 .init_irq = pxa_init_irq, 470 .init_irq = pxa_init_irq,
diff --git a/arch/arm/mach-sa1100/jornada720.c b/arch/arm/mach-sa1100/jornada720.c
index 17f5a43acdb7..54ecdaa373d6 100644
--- a/arch/arm/mach-sa1100/jornada720.c
+++ b/arch/arm/mach-sa1100/jornada720.c
@@ -1,5 +1,15 @@
1/* 1/*
2 * linux/arch/arm/mach-sa1100/jornada720.c 2 * linux/arch/arm/mach-sa1100/jornada720.c
3 *
4 * HP Jornada720 init code
5 *
6 * Copyright (C) 2006 Filip Zyzniewski <filip.zyzniewski@tefnet.pl>
7 * Copyright (C) 2005 Michael Gernoth <michael@gernoth.net>
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 *
3 */ 13 */
4 14
5#include <linux/init.h> 15#include <linux/init.h>
@@ -10,13 +20,13 @@
10#include <linux/ioport.h> 20#include <linux/ioport.h>
11#include <linux/mtd/mtd.h> 21#include <linux/mtd/mtd.h>
12#include <linux/mtd/partitions.h> 22#include <linux/mtd/partitions.h>
23#include <video/s1d13xxxfb.h>
13 24
14#include <asm/hardware.h> 25#include <asm/hardware.h>
15#include <asm/hardware/sa1111.h> 26#include <asm/hardware/sa1111.h>
16#include <asm/irq.h> 27#include <asm/irq.h>
17#include <asm/mach-types.h> 28#include <asm/mach-types.h>
18#include <asm/setup.h> 29#include <asm/setup.h>
19
20#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
21#include <asm/mach/flash.h> 31#include <asm/mach/flash.h>
22#include <asm/mach/map.h> 32#include <asm/mach/map.h>
@@ -24,13 +34,170 @@
24 34
25#include "generic.h" 35#include "generic.h"
26 36
37/*
38 * HP Documentation referred in this file:
39 * http://www.jlime.com/downloads/development/docs/jornada7xx/jornada720.txt
40 */
41
42/* line 110 of HP's doc */
43#define TUCR_VAL 0x20000400
44
45/* memory space (line 52 of HP's doc) */
46#define SA1111REGSTART 0x40000000
47#define SA1111REGLEN 0x00001fff
48#define EPSONREGSTART 0x48000000
49#define EPSONREGLEN 0x00100000
50#define EPSONFBSTART 0x48200000
51/* 512kB framebuffer */
52#define EPSONFBLEN 512*1024
53
54static struct s1d13xxxfb_regval s1d13xxxfb_initregs[] = {
55 /* line 344 of HP's doc */
56 {0x0001,0x00}, // Miscellaneous Register
57 {0x01FC,0x00}, // Display Mode Register
58 {0x0004,0x00}, // General IO Pins Configuration Register 0
59 {0x0005,0x00}, // General IO Pins Configuration Register 1
60 {0x0008,0x00}, // General IO Pins Control Register 0
61 {0x0009,0x00}, // General IO Pins Control Register 1
62 {0x0010,0x01}, // Memory Clock Configuration Register
63 {0x0014,0x11}, // LCD Pixel Clock Configuration Register
64 {0x0018,0x01}, // CRT/TV Pixel Clock Configuration Register
65 {0x001C,0x01}, // MediaPlug Clock Configuration Register
66 {0x001E,0x01}, // CPU To Memory Wait State Select Register
67 {0x0020,0x00}, // Memory Configuration Register
68 {0x0021,0x45}, // DRAM Refresh Rate Register
69 {0x002A,0x01}, // DRAM Timings Control Register 0
70 {0x002B,0x03}, // DRAM Timings Control Register 1
71 {0x0030,0x1c}, // Panel Type Register
72 {0x0031,0x00}, // MOD Rate Register
73 {0x0032,0x4F}, // LCD Horizontal Display Width Register
74 {0x0034,0x07}, // LCD Horizontal Non-Display Period Register
75 {0x0035,0x01}, // TFT FPLINE Start Position Register
76 {0x0036,0x0B}, // TFT FPLINE Pulse Width Register
77 {0x0038,0xEF}, // LCD Vertical Display Height Register 0
78 {0x0039,0x00}, // LCD Vertical Display Height Register 1
79 {0x003A,0x13}, // LCD Vertical Non-Display Period Register
80 {0x003B,0x0B}, // TFT FPFRAME Start Position Register
81 {0x003C,0x01}, // TFT FPFRAME Pulse Width Register
82 {0x0040,0x05}, // LCD Display Mode Register (2:4bpp,3:8bpp,5:16bpp)
83 {0x0041,0x00}, // LCD Miscellaneous Register
84 {0x0042,0x00}, // LCD Display Start Address Register 0
85 {0x0043,0x00}, // LCD Display Start Address Register 1
86 {0x0044,0x00}, // LCD Display Start Address Register 2
87 {0x0046,0x80}, // LCD Memory Address Offset Register 0
88 {0x0047,0x02}, // LCD Memory Address Offset Register 1
89 {0x0048,0x00}, // LCD Pixel Panning Register
90 {0x004A,0x00}, // LCD Display FIFO High Threshold Control Register
91 {0x004B,0x00}, // LCD Display FIFO Low Threshold Control Register
92 {0x0050,0x4F}, // CRT/TV Horizontal Display Width Register
93 {0x0052,0x13}, // CRT/TV Horizontal Non-Display Period Register
94 {0x0053,0x01}, // CRT/TV HRTC Start Position Register
95 {0x0054,0x0B}, // CRT/TV HRTC Pulse Width Register
96 {0x0056,0xDF}, // CRT/TV Vertical Display Height Register 0
97 {0x0057,0x01}, // CRT/TV Vertical Display Height Register 1
98 {0x0058,0x2B}, // CRT/TV Vertical Non-Display Period Register
99 {0x0059,0x09}, // CRT/TV VRTC Start Position Register
100 {0x005A,0x01}, // CRT/TV VRTC Pulse Width Register
101 {0x005B,0x10}, // TV Output Control Register
102 {0x0060,0x03}, // CRT/TV Display Mode Register (2:4bpp,3:8bpp,5:16bpp)
103 {0x0062,0x00}, // CRT/TV Display Start Address Register 0
104 {0x0063,0x00}, // CRT/TV Display Start Address Register 1
105 {0x0064,0x00}, // CRT/TV Display Start Address Register 2
106 {0x0066,0x40}, // CRT/TV Memory Address Offset Register 0
107 {0x0067,0x01}, // CRT/TV Memory Address Offset Register 1
108 {0x0068,0x00}, // CRT/TV Pixel Panning Register
109 {0x006A,0x00}, // CRT/TV Display FIFO High Threshold Control Register
110 {0x006B,0x00}, // CRT/TV Display FIFO Low Threshold Control Register
111 {0x0070,0x00}, // LCD Ink/Cursor Control Register
112 {0x0071,0x01}, // LCD Ink/Cursor Start Address Register
113 {0x0072,0x00}, // LCD Cursor X Position Register 0
114 {0x0073,0x00}, // LCD Cursor X Position Register 1
115 {0x0074,0x00}, // LCD Cursor Y Position Register 0
116 {0x0075,0x00}, // LCD Cursor Y Position Register 1
117 {0x0076,0x00}, // LCD Ink/Cursor Blue Color 0 Register
118 {0x0077,0x00}, // LCD Ink/Cursor Green Color 0 Register
119 {0x0078,0x00}, // LCD Ink/Cursor Red Color 0 Register
120 {0x007A,0x1F}, // LCD Ink/Cursor Blue Color 1 Register
121 {0x007B,0x3F}, // LCD Ink/Cursor Green Color 1 Register
122 {0x007C,0x1F}, // LCD Ink/Cursor Red Color 1 Register
123 {0x007E,0x00}, // LCD Ink/Cursor FIFO Threshold Register
124 {0x0080,0x00}, // CRT/TV Ink/Cursor Control Register
125 {0x0081,0x01}, // CRT/TV Ink/Cursor Start Address Register
126 {0x0082,0x00}, // CRT/TV Cursor X Position Register 0
127 {0x0083,0x00}, // CRT/TV Cursor X Position Register 1
128 {0x0084,0x00}, // CRT/TV Cursor Y Position Register 0
129 {0x0085,0x00}, // CRT/TV Cursor Y Position Register 1
130 {0x0086,0x00}, // CRT/TV Ink/Cursor Blue Color 0 Register
131 {0x0087,0x00}, // CRT/TV Ink/Cursor Green Color 0 Register
132 {0x0088,0x00}, // CRT/TV Ink/Cursor Red Color 0 Register
133 {0x008A,0x1F}, // CRT/TV Ink/Cursor Blue Color 1 Register
134 {0x008B,0x3F}, // CRT/TV Ink/Cursor Green Color 1 Register
135 {0x008C,0x1F}, // CRT/TV Ink/Cursor Red Color 1 Register
136 {0x008E,0x00}, // CRT/TV Ink/Cursor FIFO Threshold Register
137 {0x0100,0x00}, // BitBlt Control Register 0
138 {0x0101,0x00}, // BitBlt Control Register 1
139 {0x0102,0x00}, // BitBlt ROP Code/Color Expansion Register
140 {0x0103,0x00}, // BitBlt Operation Register
141 {0x0104,0x00}, // BitBlt Source Start Address Register 0
142 {0x0105,0x00}, // BitBlt Source Start Address Register 1
143 {0x0106,0x00}, // BitBlt Source Start Address Register 2
144 {0x0108,0x00}, // BitBlt Destination Start Address Register 0
145 {0x0109,0x00}, // BitBlt Destination Start Address Register 1
146 {0x010A,0x00}, // BitBlt Destination Start Address Register 2
147 {0x010C,0x00}, // BitBlt Memory Address Offset Register 0
148 {0x010D,0x00}, // BitBlt Memory Address Offset Register 1
149 {0x0110,0x00}, // BitBlt Width Register 0
150 {0x0111,0x00}, // BitBlt Width Register 1
151 {0x0112,0x00}, // BitBlt Height Register 0
152 {0x0113,0x00}, // BitBlt Height Register 1
153 {0x0114,0x00}, // BitBlt Background Color Register 0
154 {0x0115,0x00}, // BitBlt Background Color Register 1
155 {0x0118,0x00}, // BitBlt Foreground Color Register 0
156 {0x0119,0x00}, // BitBlt Foreground Color Register 1
157 {0x01E0,0x00}, // Look-Up Table Mode Register
158 {0x01E2,0x00}, // Look-Up Table Address Register
159 /* not sure, wouldn't like to mess with the driver */
160 {0x01E4,0x00}, // Look-Up Table Data Register
161 /* jornada doc says 0x00, but I trust the driver */
162 {0x01F0,0x10}, // Power Save Configuration Register
163 {0x01F1,0x00}, // Power Save Status Register
164 {0x01F4,0x00}, // CPU-to-Memory Access Watchdog Timer Register
165 {0x01FC,0x01}, // Display Mode Register(0x01:LCD, 0x02:CRT, 0x03:LCD&CRT)
166};
167
168static struct s1d13xxxfb_pdata s1d13xxxfb_data = {
169 .initregs = s1d13xxxfb_initregs,
170 .initregssize = ARRAY_SIZE(s1d13xxxfb_initregs),
171 .platform_init_video = NULL
172};
27 173
28#define JORTUCR_VAL 0x20000400 174static struct resource s1d13xxxfb_resources[] = {
175 [0] = {
176 .start = EPSONFBSTART,
177 .end = EPSONFBSTART + EPSONFBLEN,
178 .flags = IORESOURCE_MEM,
179 },
180 [1] = {
181 .start = EPSONREGSTART,
182 .end = EPSONREGSTART + EPSONREGLEN,
183 .flags = IORESOURCE_MEM,
184 }
185};
186
187static struct platform_device s1d13xxxfb_device = {
188 .name = S1D_DEVICENAME,
189 .id = 0,
190 .dev = {
191 .platform_data = &s1d13xxxfb_data,
192 },
193 .num_resources = ARRAY_SIZE(s1d13xxxfb_resources),
194 .resource = s1d13xxxfb_resources,
195};
29 196
30static struct resource sa1111_resources[] = { 197static struct resource sa1111_resources[] = {
31 [0] = { 198 [0] = {
32 .start = 0x40000000, 199 .start = SA1111REGSTART,
33 .end = 0x40001fff, 200 .end = SA1111REGSTART + SA1111REGLEN,
34 .flags = IORESOURCE_MEM, 201 .flags = IORESOURCE_MEM,
35 }, 202 },
36 [1] = { 203 [1] = {
@@ -53,18 +220,32 @@ static struct platform_device sa1111_device = {
53 .resource = sa1111_resources, 220 .resource = sa1111_resources,
54}; 221};
55 222
223static struct platform_device jornada720_mcu_device = {
224 .name = "jornada720_mcu",
225 .id = -1,
226};
227
56static struct platform_device *devices[] __initdata = { 228static struct platform_device *devices[] __initdata = {
57 &sa1111_device, 229 &sa1111_device,
230 &jornada720_mcu_device,
231 &s1d13xxxfb_device,
58}; 232};
59 233
234/* a stub for now, we theoretically cannot suspend without a flashboard */
235int pm_suspend(suspend_state_t state)
236{
237 return -1;
238}
239
60static int __init jornada720_init(void) 240static int __init jornada720_init(void)
61{ 241{
62 int ret = -ENODEV; 242 int ret = -ENODEV;
63 243
64 if (machine_is_jornada720()) { 244 if (machine_is_jornada720()) {
65 GPDR |= GPIO_GPIO20; 245 GPDR |= GPIO_GPIO20;
66 TUCR = JORTUCR_VAL; /* set the oscillator out to the SA-1101 */ 246 /* oscillator setup (line 116 of HP's doc) */
67 247 TUCR = TUCR_VAL;
248 /* resetting SA1111 (line 118 of HP's doc) */
68 GPSR = GPIO_GPIO20; 249 GPSR = GPIO_GPIO20;
69 udelay(1); 250 udelay(1);
70 GPCR = GPIO_GPIO20; 251 GPCR = GPIO_GPIO20;
@@ -72,10 +253,6 @@ static int __init jornada720_init(void)
72 GPSR = GPIO_GPIO20; 253 GPSR = GPIO_GPIO20;
73 udelay(20); 254 udelay(20);
74 255
75 /* LDD4 is speaker, LDD3 is microphone */
76 PPSR &= ~(PPC_LDD3 | PPC_LDD4);
77 PPDR |= PPC_LDD3 | PPC_LDD4;
78
79 ret = platform_add_devices(devices, ARRAY_SIZE(devices)); 256 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
80 } 257 }
81 return ret; 258 return ret;
@@ -85,19 +262,19 @@ arch_initcall(jornada720_init);
85 262
86static struct map_desc jornada720_io_desc[] __initdata = { 263static struct map_desc jornada720_io_desc[] __initdata = {
87 { /* Epson registers */ 264 { /* Epson registers */
88 .virtual = 0xf0000000, 265 .virtual = 0xf0000000,
89 .pfn = __phys_to_pfn(0x48000000), 266 .pfn = __phys_to_pfn(EPSONREGSTART),
90 .length = 0x00100000, 267 .length = EPSONREGLEN,
91 .type = MT_DEVICE 268 .type = MT_DEVICE
92 }, { /* Epson frame buffer */ 269 }, { /* Epson frame buffer */
93 .virtual = 0xf1000000, 270 .virtual = 0xf1000000,
94 .pfn = __phys_to_pfn(0x48200000), 271 .pfn = __phys_to_pfn(EPSONFBSTART),
95 .length = 0x00100000, 272 .length = EPSONFBLEN,
96 .type = MT_DEVICE 273 .type = MT_DEVICE
97 }, { /* SA-1111 */ 274 }, { /* SA-1111 */
98 .virtual = 0xf4000000, 275 .virtual = 0xf4000000,
99 .pfn = __phys_to_pfn(0x40000000), 276 .pfn = __phys_to_pfn(SA1111REGSTART),
100 .length = 0x00100000, 277 .length = SA1111REGLEN,
101 .type = MT_DEVICE 278 .type = MT_DEVICE
102 } 279 }
103}; 280};
@@ -106,7 +283,7 @@ static void __init jornada720_map_io(void)
106{ 283{
107 sa1100_map_io(); 284 sa1100_map_io();
108 iotable_init(jornada720_io_desc, ARRAY_SIZE(jornada720_io_desc)); 285 iotable_init(jornada720_io_desc, ARRAY_SIZE(jornada720_io_desc));
109 286
110 sa1100_register_uart(0, 3); 287 sa1100_register_uart(0, 3);
111 sa1100_register_uart(1, 1); 288 sa1100_register_uart(1, 1);
112} 289}
@@ -116,7 +293,7 @@ static struct mtd_partition jornada720_partitions[] = {
116 .name = "JORNADA720 boot firmware", 293 .name = "JORNADA720 boot firmware",
117 .size = 0x00040000, 294 .size = 0x00040000,
118 .offset = 0, 295 .offset = 0,
119 .mask_flags = MTD_WRITEABLE, /* force read-only */ 296 .mask_flags = MTD_WRITEABLE, /* force read-only */
120 }, { 297 }, {
121 .name = "JORNADA720 kernel", 298 .name = "JORNADA720 kernel",
122 .size = 0x000c0000, 299 .size = 0x000c0000,
@@ -139,7 +316,7 @@ static struct mtd_partition jornada720_partitions[] = {
139 .offset = 0x00540000, 316 .offset = 0x00540000,
140 }, { 317 }, {
141 .name = "JORNADA720 usr local", 318 .name = "JORNADA720 usr local",
142 .size = 0, /* will expand to the end of the flash */ 319 .size = 0, /* will expand to the end of the flash */
143 .offset = 0x00d00000, 320 .offset = 0x00d00000,
144 } 321 }
145}; 322};
@@ -147,10 +324,12 @@ static struct mtd_partition jornada720_partitions[] = {
147static void jornada720_set_vpp(int vpp) 324static void jornada720_set_vpp(int vpp)
148{ 325{
149 if (vpp) 326 if (vpp)
150 PPSR |= 0x80; 327 /* enabling flash write (line 470 of HP's doc) */
328 PPSR |= PPC_LDD7;
151 else 329 else
152 PPSR &= ~0x80; 330 /* disabling flash write (line 470 of HP's doc) */
153 PPDR |= 0x80; 331 PPSR &= ~PPC_LDD7;
332 PPDR |= PPC_LDD7;
154} 333}
155 334
156static struct flash_platform_data jornada720_flash_data = { 335static struct flash_platform_data jornada720_flash_data = {
diff --git a/arch/arm/mm/consistent.c b/arch/arm/mm/consistent.c
index b797217e82be..6a9c362fef5e 100644
--- a/arch/arm/mm/consistent.c
+++ b/arch/arm/mm/consistent.c
@@ -238,7 +238,7 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
238 * x86 does not mark the pages reserved... 238 * x86 does not mark the pages reserved...
239 */ 239 */
240 SetPageReserved(page); 240 SetPageReserved(page);
241 set_pte(pte, mk_pte(page, prot)); 241 set_pte_ext(pte, mk_pte(page, prot), 0);
242 page++; 242 page++;
243 pte++; 243 pte++;
244 off++; 244 off++;
diff --git a/arch/arm/mm/copypage-v4mc.c b/arch/arm/mm/copypage-v4mc.c
index df1645e14b4c..408b05ae6b9b 100644
--- a/arch/arm/mm/copypage-v4mc.c
+++ b/arch/arm/mm/copypage-v4mc.c
@@ -71,7 +71,7 @@ void v4_mc_copy_user_page(void *kto, const void *kfrom, unsigned long vaddr)
71{ 71{
72 spin_lock(&minicache_lock); 72 spin_lock(&minicache_lock);
73 73
74 set_pte(TOP_PTE(0xffff8000), pfn_pte(__pa(kfrom) >> PAGE_SHIFT, minicache_pgprot)); 74 set_pte_ext(TOP_PTE(0xffff8000), pfn_pte(__pa(kfrom) >> PAGE_SHIFT, minicache_pgprot), 0);
75 flush_tlb_kernel_page(0xffff8000); 75 flush_tlb_kernel_page(0xffff8000);
76 76
77 mc_copy_user_page((void *)0xffff8000, kto); 77 mc_copy_user_page((void *)0xffff8000, kto);
diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
index 3d0d3a963d20..865777dec161 100644
--- a/arch/arm/mm/copypage-v6.c
+++ b/arch/arm/mm/copypage-v6.c
@@ -70,8 +70,8 @@ static void v6_copy_user_page_aliasing(void *kto, const void *kfrom, unsigned lo
70 */ 70 */
71 spin_lock(&v6_lock); 71 spin_lock(&v6_lock);
72 72
73 set_pte(TOP_PTE(from_address) + offset, pfn_pte(__pa(kfrom) >> PAGE_SHIFT, PAGE_KERNEL)); 73 set_pte_ext(TOP_PTE(from_address) + offset, pfn_pte(__pa(kfrom) >> PAGE_SHIFT, PAGE_KERNEL), 0);
74 set_pte(TOP_PTE(to_address) + offset, pfn_pte(__pa(kto) >> PAGE_SHIFT, PAGE_KERNEL)); 74 set_pte_ext(TOP_PTE(to_address) + offset, pfn_pte(__pa(kto) >> PAGE_SHIFT, PAGE_KERNEL), 0);
75 75
76 from = from_address + (offset << PAGE_SHIFT); 76 from = from_address + (offset << PAGE_SHIFT);
77 to = to_address + (offset << PAGE_SHIFT); 77 to = to_address + (offset << PAGE_SHIFT);
@@ -110,7 +110,7 @@ static void v6_clear_user_page_aliasing(void *kaddr, unsigned long vaddr)
110 */ 110 */
111 spin_lock(&v6_lock); 111 spin_lock(&v6_lock);
112 112
113 set_pte(TOP_PTE(to_address) + offset, pfn_pte(__pa(kaddr) >> PAGE_SHIFT, PAGE_KERNEL)); 113 set_pte_ext(TOP_PTE(to_address) + offset, pfn_pte(__pa(kaddr) >> PAGE_SHIFT, PAGE_KERNEL), 0);
114 flush_tlb_kernel_page(to); 114 flush_tlb_kernel_page(to);
115 clear_page((void *)to); 115 clear_page((void *)to);
116 116
diff --git a/arch/arm/mm/copypage-xscale.c b/arch/arm/mm/copypage-xscale.c
index 84ebe0aa379e..aea5da723596 100644
--- a/arch/arm/mm/copypage-xscale.c
+++ b/arch/arm/mm/copypage-xscale.c
@@ -93,7 +93,7 @@ void xscale_mc_copy_user_page(void *kto, const void *kfrom, unsigned long vaddr)
93{ 93{
94 spin_lock(&minicache_lock); 94 spin_lock(&minicache_lock);
95 95
96 set_pte(TOP_PTE(COPYPAGE_MINICACHE), pfn_pte(__pa(kfrom) >> PAGE_SHIFT, minicache_pgprot)); 96 set_pte_ext(TOP_PTE(COPYPAGE_MINICACHE), pfn_pte(__pa(kfrom) >> PAGE_SHIFT, minicache_pgprot), 0);
97 flush_tlb_kernel_page(COPYPAGE_MINICACHE); 97 flush_tlb_kernel_page(COPYPAGE_MINICACHE);
98 98
99 mc_copy_user_page((void *)COPYPAGE_MINICACHE, kto); 99 mc_copy_user_page((void *)COPYPAGE_MINICACHE, kto);
diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c
index 7fc1b35a6746..cf95c5d0ce4c 100644
--- a/arch/arm/mm/fault-armv.c
+++ b/arch/arm/mm/fault-armv.c
@@ -61,7 +61,7 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
61 if (pte_present(entry) && pte_val(entry) & shared_pte_mask) { 61 if (pte_present(entry) && pte_val(entry) & shared_pte_mask) {
62 flush_cache_page(vma, address, pte_pfn(entry)); 62 flush_cache_page(vma, address, pte_pfn(entry));
63 pte_val(entry) &= ~shared_pte_mask; 63 pte_val(entry) &= ~shared_pte_mask;
64 set_pte(pte, entry); 64 set_pte_at(vma->vm_mm, address, pte, entry);
65 flush_tlb_page(vma, address); 65 flush_tlb_page(vma, address);
66 ret = 1; 66 ret = 1;
67 } 67 }
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index 454205b789d5..628348c9f6c5 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -26,7 +26,7 @@ static void flush_pfn_alias(unsigned long pfn, unsigned long vaddr)
26 unsigned long to = ALIAS_FLUSH_START + (CACHE_COLOUR(vaddr) << PAGE_SHIFT); 26 unsigned long to = ALIAS_FLUSH_START + (CACHE_COLOUR(vaddr) << PAGE_SHIFT);
27 const int zero = 0; 27 const int zero = 0;
28 28
29 set_pte(TOP_PTE(to), pfn_pte(pfn, PAGE_KERNEL)); 29 set_pte_ext(TOP_PTE(to), pfn_pte(pfn, PAGE_KERNEL), 0);
30 flush_tlb_kernel_page(to); 30 flush_tlb_kernel_page(to);
31 31
32 asm( "mcrr p15, 0, %1, %0, c14\n" 32 asm( "mcrr p15, 0, %1, %0, c14\n"
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index 465440592791..3bb3951920bc 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -38,89 +38,71 @@
38 */ 38 */
39#define VM_ARM_SECTION_MAPPING 0x80000000 39#define VM_ARM_SECTION_MAPPING 0x80000000
40 40
41static inline void 41static int remap_area_pte(pmd_t *pmd, unsigned long addr, unsigned long end,
42remap_area_pte(pte_t * pte, unsigned long address, unsigned long size, 42 unsigned long phys_addr, pgprot_t prot)
43 unsigned long phys_addr, pgprot_t pgprot)
44{ 43{
45 unsigned long end; 44 pte_t *pte;
45
46 pte = pte_alloc_kernel(pmd, addr);
47 if (!pte)
48 return -ENOMEM;
46 49
47 address &= ~PMD_MASK;
48 end = address + size;
49 if (end > PMD_SIZE)
50 end = PMD_SIZE;
51 BUG_ON(address >= end);
52 do { 50 do {
53 if (!pte_none(*pte)) 51 if (!pte_none(*pte))
54 goto bad; 52 goto bad;
55 53
56 set_pte(pte, pfn_pte(phys_addr >> PAGE_SHIFT, pgprot)); 54 set_pte_ext(pte, pfn_pte(phys_addr >> PAGE_SHIFT, prot), 0);
57 address += PAGE_SIZE;
58 phys_addr += PAGE_SIZE; 55 phys_addr += PAGE_SIZE;
59 pte++; 56 } while (pte++, addr += PAGE_SIZE, addr != end);
60 } while (address && (address < end)); 57 return 0;
61 return;
62 58
63 bad: 59 bad:
64 printk("remap_area_pte: page already exists\n"); 60 printk(KERN_CRIT "remap_area_pte: page already exists\n");
65 BUG(); 61 BUG();
66} 62}
67 63
68static inline int 64static inline int remap_area_pmd(pgd_t *pgd, unsigned long addr,
69remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size, 65 unsigned long end, unsigned long phys_addr,
70 unsigned long phys_addr, unsigned long flags) 66 pgprot_t prot)
71{ 67{
72 unsigned long end; 68 unsigned long next;
73 pgprot_t pgprot; 69 pmd_t *pmd;
74 70 int ret = 0;
75 address &= ~PGDIR_MASK;
76 end = address + size;
77 71
78 if (end > PGDIR_SIZE) 72 pmd = pmd_alloc(&init_mm, pgd, addr);
79 end = PGDIR_SIZE; 73 if (!pmd)
74 return -ENOMEM;
80 75
81 phys_addr -= address;
82 BUG_ON(address >= end);
83
84 pgprot = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_WRITE | flags);
85 do { 76 do {
86 pte_t * pte = pte_alloc_kernel(pmd, address); 77 next = pmd_addr_end(addr, end);
87 if (!pte) 78 ret = remap_area_pte(pmd, addr, next, phys_addr, prot);
88 return -ENOMEM; 79 if (ret)
89 remap_area_pte(pte, address, end - address, address + phys_addr, pgprot); 80 return ret;
90 address = (address + PMD_SIZE) & PMD_MASK; 81 phys_addr += next - addr;
91 pmd++; 82 } while (pmd++, addr = next, addr != end);
92 } while (address && (address < end)); 83 return ret;
93 return 0;
94} 84}
95 85
96static int 86static int remap_area_pages(unsigned long start, unsigned long pfn,
97remap_area_pages(unsigned long start, unsigned long pfn, 87 unsigned long size, unsigned long flags)
98 unsigned long size, unsigned long flags)
99{ 88{
100 unsigned long address = start; 89 unsigned long addr = start;
101 unsigned long end = start + size; 90 unsigned long next, end = start + size;
102 unsigned long phys_addr = __pfn_to_phys(pfn); 91 unsigned long phys_addr = __pfn_to_phys(pfn);
92 pgprot_t prot = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG |
93 L_PTE_DIRTY | L_PTE_WRITE | flags);
94 pgd_t *pgd;
103 int err = 0; 95 int err = 0;
104 pgd_t * dir;
105 96
106 phys_addr -= address; 97 BUG_ON(addr >= end);
107 dir = pgd_offset(&init_mm, address); 98 pgd = pgd_offset_k(addr);
108 BUG_ON(address >= end);
109 do { 99 do {
110 pmd_t *pmd = pmd_alloc(&init_mm, dir, address); 100 next = pgd_addr_end(addr, end);
111 if (!pmd) { 101 err = remap_area_pmd(pgd, addr, next, phys_addr, prot);
112 err = -ENOMEM; 102 if (err)
113 break;
114 }
115 if (remap_area_pmd(pmd, address, end - address,
116 phys_addr + address, flags)) {
117 err = -ENOMEM;
118 break; 103 break;
119 } 104 phys_addr += next - addr;
120 105 } while (pgd++, addr = next, addr != end);
121 address = (address + PGDIR_SIZE) & PGDIR_MASK;
122 dir++;
123 } while (address && (address < end));
124 106
125 return err; 107 return err;
126} 108}
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index b7f194af20b4..f028aef9a861 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -294,12 +294,6 @@ static void __init build_mem_type_table(void)
294 mem_types[MT_DEVICE].prot_pte |= L_PTE_BUFFERABLE; 294 mem_types[MT_DEVICE].prot_pte |= L_PTE_BUFFERABLE;
295 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_BUFFERED; 295 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_BUFFERED;
296 296
297 /*
298 * User pages need to be mapped with the ASID
299 * (iow, non-global)
300 */
301 user_pgprot |= L_PTE_ASID;
302
303#ifdef CONFIG_SMP 297#ifdef CONFIG_SMP
304 /* 298 /*
305 * Mark memory with the "shared" attribute for SMP systems 299 * Mark memory with the "shared" attribute for SMP systems
@@ -408,7 +402,7 @@ alloc_init_page(unsigned long virt, unsigned long phys, unsigned int prot_l1, pg
408 } 402 }
409 ptep = pte_offset_kernel(pmdp, virt); 403 ptep = pte_offset_kernel(pmdp, virt);
410 404
411 set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, prot)); 405 set_pte_ext(ptep, pfn_pte(phys >> PAGE_SHIFT, prot), 0);
412} 406}
413 407
414/* 408/*
diff --git a/arch/arm/mm/pgd.c b/arch/arm/mm/pgd.c
index 20c1b0df75f2..50b9aed6000d 100644
--- a/arch/arm/mm/pgd.c
+++ b/arch/arm/mm/pgd.c
@@ -57,7 +57,7 @@ pgd_t *get_pgd_slow(struct mm_struct *mm)
57 57
58 init_pmd = pmd_offset(init_pgd, 0); 58 init_pmd = pmd_offset(init_pgd, 0);
59 init_pte = pte_offset_map_nested(init_pmd, 0); 59 init_pte = pte_offset_map_nested(init_pmd, 0);
60 set_pte(new_pte, *init_pte); 60 set_pte_ext(new_pte, *init_pte, 0);
61 pte_unmap_nested(init_pte); 61 pte_unmap_nested(init_pte);
62 pte_unmap(new_pte); 62 pte_unmap(new_pte);
63 } 63 }
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
index 289b8e6f504d..700c04d6996e 100644
--- a/arch/arm/mm/proc-arm1020.S
+++ b/arch/arm/mm/proc-arm1020.S
@@ -397,7 +397,7 @@ ENTRY(cpu_arm1020_switch_mm)
397 * Set a PTE and flush it out 397 * Set a PTE and flush it out
398 */ 398 */
399 .align 5 399 .align 5
400ENTRY(cpu_arm1020_set_pte) 400ENTRY(cpu_arm1020_set_pte_ext)
401#ifdef CONFIG_MMU 401#ifdef CONFIG_MMU
402 str r1, [r0], #-2048 @ linux version 402 str r1, [r0], #-2048 @ linux version
403 403
@@ -477,7 +477,7 @@ arm1020_processor_functions:
477 .word cpu_arm1020_do_idle 477 .word cpu_arm1020_do_idle
478 .word cpu_arm1020_dcache_clean_area 478 .word cpu_arm1020_dcache_clean_area
479 .word cpu_arm1020_switch_mm 479 .word cpu_arm1020_switch_mm
480 .word cpu_arm1020_set_pte 480 .word cpu_arm1020_set_pte_ext
481 .size arm1020_processor_functions, . - arm1020_processor_functions 481 .size arm1020_processor_functions, . - arm1020_processor_functions
482 482
483 .section ".rodata" 483 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S
index bed9db6ba582..1cc206ab5eae 100644
--- a/arch/arm/mm/proc-arm1020e.S
+++ b/arch/arm/mm/proc-arm1020e.S
@@ -381,7 +381,7 @@ ENTRY(cpu_arm1020e_switch_mm)
381 * Set a PTE and flush it out 381 * Set a PTE and flush it out
382 */ 382 */
383 .align 5 383 .align 5
384ENTRY(cpu_arm1020e_set_pte) 384ENTRY(cpu_arm1020e_set_pte_ext)
385#ifdef CONFIG_MMU 385#ifdef CONFIG_MMU
386 str r1, [r0], #-2048 @ linux version 386 str r1, [r0], #-2048 @ linux version
387 387
@@ -458,7 +458,7 @@ arm1020e_processor_functions:
458 .word cpu_arm1020e_do_idle 458 .word cpu_arm1020e_do_idle
459 .word cpu_arm1020e_dcache_clean_area 459 .word cpu_arm1020e_dcache_clean_area
460 .word cpu_arm1020e_switch_mm 460 .word cpu_arm1020e_switch_mm
461 .word cpu_arm1020e_set_pte 461 .word cpu_arm1020e_set_pte_ext
462 .size arm1020e_processor_functions, . - arm1020e_processor_functions 462 .size arm1020e_processor_functions, . - arm1020e_processor_functions
463 463
464 .section ".rodata" 464 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S
index d2a7c1b9cab9..aff0ea08e2f8 100644
--- a/arch/arm/mm/proc-arm1022.S
+++ b/arch/arm/mm/proc-arm1022.S
@@ -358,12 +358,12 @@ ENTRY(cpu_arm1022_switch_mm)
358 mov pc, lr 358 mov pc, lr
359 359
360/* 360/*
361 * cpu_arm1022_set_pte(ptep, pte) 361 * cpu_arm1022_set_pte_ext(ptep, pte, ext)
362 * 362 *
363 * Set a PTE and flush it out 363 * Set a PTE and flush it out
364 */ 364 */
365 .align 5 365 .align 5
366ENTRY(cpu_arm1022_set_pte) 366ENTRY(cpu_arm1022_set_pte_ext)
367#ifdef CONFIG_MMU 367#ifdef CONFIG_MMU
368 str r1, [r0], #-2048 @ linux version 368 str r1, [r0], #-2048 @ linux version
369 369
@@ -441,7 +441,7 @@ arm1022_processor_functions:
441 .word cpu_arm1022_do_idle 441 .word cpu_arm1022_do_idle
442 .word cpu_arm1022_dcache_clean_area 442 .word cpu_arm1022_dcache_clean_area
443 .word cpu_arm1022_switch_mm 443 .word cpu_arm1022_switch_mm
444 .word cpu_arm1022_set_pte 444 .word cpu_arm1022_set_pte_ext
445 .size arm1022_processor_functions, . - arm1022_processor_functions 445 .size arm1022_processor_functions, . - arm1022_processor_functions
446 446
447 .section ".rodata" 447 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S
index 3247ce5c0177..65e43a109085 100644
--- a/arch/arm/mm/proc-arm1026.S
+++ b/arch/arm/mm/proc-arm1026.S
@@ -347,12 +347,12 @@ ENTRY(cpu_arm1026_switch_mm)
347 mov pc, lr 347 mov pc, lr
348 348
349/* 349/*
350 * cpu_arm1026_set_pte(ptep, pte) 350 * cpu_arm1026_set_pte_ext(ptep, pte, ext)
351 * 351 *
352 * Set a PTE and flush it out 352 * Set a PTE and flush it out
353 */ 353 */
354 .align 5 354 .align 5
355ENTRY(cpu_arm1026_set_pte) 355ENTRY(cpu_arm1026_set_pte_ext)
356#ifdef CONFIG_MMU 356#ifdef CONFIG_MMU
357 str r1, [r0], #-2048 @ linux version 357 str r1, [r0], #-2048 @ linux version
358 358
@@ -436,7 +436,7 @@ arm1026_processor_functions:
436 .word cpu_arm1026_do_idle 436 .word cpu_arm1026_do_idle
437 .word cpu_arm1026_dcache_clean_area 437 .word cpu_arm1026_dcache_clean_area
438 .word cpu_arm1026_switch_mm 438 .word cpu_arm1026_switch_mm
439 .word cpu_arm1026_set_pte 439 .word cpu_arm1026_set_pte_ext
440 .size arm1026_processor_functions, . - arm1026_processor_functions 440 .size arm1026_processor_functions, . - arm1026_processor_functions
441 441
442 .section .rodata 442 .section .rodata
diff --git a/arch/arm/mm/proc-arm6_7.S b/arch/arm/mm/proc-arm6_7.S
index ce4f9eef763c..123a7dc7a433 100644
--- a/arch/arm/mm/proc-arm6_7.S
+++ b/arch/arm/mm/proc-arm6_7.S
@@ -209,14 +209,14 @@ ENTRY(cpu_arm7_switch_mm)
209 mov pc, lr 209 mov pc, lr
210 210
211/* 211/*
212 * Function: arm6_7_set_pte(pte_t *ptep, pte_t pte) 212 * Function: arm6_7_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext)
213 * Params : r0 = Address to set 213 * Params : r0 = Address to set
214 * : r1 = value to set 214 * : r1 = value to set
215 * Purpose : Set a PTE and flush it out of any WB cache 215 * Purpose : Set a PTE and flush it out of any WB cache
216 */ 216 */
217 .align 5 217 .align 5
218ENTRY(cpu_arm6_set_pte) 218ENTRY(cpu_arm6_set_pte_ext)
219ENTRY(cpu_arm7_set_pte) 219ENTRY(cpu_arm7_set_pte_ext)
220#ifdef CONFIG_MMU 220#ifdef CONFIG_MMU
221 str r1, [r0], #-2048 @ linux version 221 str r1, [r0], #-2048 @ linux version
222 222
@@ -299,7 +299,7 @@ ENTRY(arm6_processor_functions)
299 .word cpu_arm6_do_idle 299 .word cpu_arm6_do_idle
300 .word cpu_arm6_dcache_clean_area 300 .word cpu_arm6_dcache_clean_area
301 .word cpu_arm6_switch_mm 301 .word cpu_arm6_switch_mm
302 .word cpu_arm6_set_pte 302 .word cpu_arm6_set_pte_ext
303 .size arm6_processor_functions, . - arm6_processor_functions 303 .size arm6_processor_functions, . - arm6_processor_functions
304 304
305/* 305/*
@@ -315,7 +315,7 @@ ENTRY(arm7_processor_functions)
315 .word cpu_arm7_do_idle 315 .word cpu_arm7_do_idle
316 .word cpu_arm7_dcache_clean_area 316 .word cpu_arm7_dcache_clean_area
317 .word cpu_arm7_switch_mm 317 .word cpu_arm7_switch_mm
318 .word cpu_arm7_set_pte 318 .word cpu_arm7_set_pte_ext
319 .size arm7_processor_functions, . - arm7_processor_functions 319 .size arm7_processor_functions, . - arm7_processor_functions
320 320
321 .section ".rodata" 321 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
index c04c194da785..dc763be43362 100644
--- a/arch/arm/mm/proc-arm720.S
+++ b/arch/arm/mm/proc-arm720.S
@@ -88,13 +88,13 @@ ENTRY(cpu_arm720_switch_mm)
88 mov pc, lr 88 mov pc, lr
89 89
90/* 90/*
91 * Function: arm720_set_pte(pte_t *ptep, pte_t pte) 91 * Function: arm720_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext)
92 * Params : r0 = Address to set 92 * Params : r0 = Address to set
93 * : r1 = value to set 93 * : r1 = value to set
94 * Purpose : Set a PTE and flush it out of any WB cache 94 * Purpose : Set a PTE and flush it out of any WB cache
95 */ 95 */
96 .align 5 96 .align 5
97ENTRY(cpu_arm720_set_pte) 97ENTRY(cpu_arm720_set_pte_ext)
98#ifdef CONFIG_MMU 98#ifdef CONFIG_MMU
99 str r1, [r0], #-2048 @ linux version 99 str r1, [r0], #-2048 @ linux version
100 100
@@ -204,7 +204,7 @@ ENTRY(arm720_processor_functions)
204 .word cpu_arm720_do_idle 204 .word cpu_arm720_do_idle
205 .word cpu_arm720_dcache_clean_area 205 .word cpu_arm720_dcache_clean_area
206 .word cpu_arm720_switch_mm 206 .word cpu_arm720_switch_mm
207 .word cpu_arm720_set_pte 207 .word cpu_arm720_set_pte_ext
208 .size arm720_processor_functions, . - arm720_processor_functions 208 .size arm720_processor_functions, . - arm720_processor_functions
209 209
210 .section ".rodata" 210 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
index 65cbb2851bff..75c945ed6c4d 100644
--- a/arch/arm/mm/proc-arm920.S
+++ b/arch/arm/mm/proc-arm920.S
@@ -344,12 +344,12 @@ ENTRY(cpu_arm920_switch_mm)
344 mov pc, lr 344 mov pc, lr
345 345
346/* 346/*
347 * cpu_arm920_set_pte(ptep, pte) 347 * cpu_arm920_set_pte(ptep, pte, ext)
348 * 348 *
349 * Set a PTE and flush it out 349 * Set a PTE and flush it out
350 */ 350 */
351 .align 5 351 .align 5
352ENTRY(cpu_arm920_set_pte) 352ENTRY(cpu_arm920_set_pte_ext)
353#ifdef CONFIG_MMU 353#ifdef CONFIG_MMU
354 str r1, [r0], #-2048 @ linux version 354 str r1, [r0], #-2048 @ linux version
355 355
@@ -423,7 +423,7 @@ arm920_processor_functions:
423 .word cpu_arm920_do_idle 423 .word cpu_arm920_do_idle
424 .word cpu_arm920_dcache_clean_area 424 .word cpu_arm920_dcache_clean_area
425 .word cpu_arm920_switch_mm 425 .word cpu_arm920_switch_mm
426 .word cpu_arm920_set_pte 426 .word cpu_arm920_set_pte_ext
427 .size arm920_processor_functions, . - arm920_processor_functions 427 .size arm920_processor_functions, . - arm920_processor_functions
428 428
429 .section ".rodata" 429 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
index 52761b70d735..ffb751b877ff 100644
--- a/arch/arm/mm/proc-arm922.S
+++ b/arch/arm/mm/proc-arm922.S
@@ -348,12 +348,12 @@ ENTRY(cpu_arm922_switch_mm)
348 mov pc, lr 348 mov pc, lr
349 349
350/* 350/*
351 * cpu_arm922_set_pte(ptep, pte) 351 * cpu_arm922_set_pte_ext(ptep, pte, ext)
352 * 352 *
353 * Set a PTE and flush it out 353 * Set a PTE and flush it out
354 */ 354 */
355 .align 5 355 .align 5
356ENTRY(cpu_arm922_set_pte) 356ENTRY(cpu_arm922_set_pte_ext)
357#ifdef CONFIG_MMU 357#ifdef CONFIG_MMU
358 str r1, [r0], #-2048 @ linux version 358 str r1, [r0], #-2048 @ linux version
359 359
@@ -427,7 +427,7 @@ arm922_processor_functions:
427 .word cpu_arm922_do_idle 427 .word cpu_arm922_do_idle
428 .word cpu_arm922_dcache_clean_area 428 .word cpu_arm922_dcache_clean_area
429 .word cpu_arm922_switch_mm 429 .word cpu_arm922_switch_mm
430 .word cpu_arm922_set_pte 430 .word cpu_arm922_set_pte_ext
431 .size arm922_processor_functions, . - arm922_processor_functions 431 .size arm922_processor_functions, . - arm922_processor_functions
432 432
433 .section ".rodata" 433 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S
index 5b74339d1588..44c2c997819f 100644
--- a/arch/arm/mm/proc-arm925.S
+++ b/arch/arm/mm/proc-arm925.S
@@ -391,12 +391,12 @@ ENTRY(cpu_arm925_switch_mm)
391 mov pc, lr 391 mov pc, lr
392 392
393/* 393/*
394 * cpu_arm925_set_pte(ptep, pte) 394 * cpu_arm925_set_pte_ext(ptep, pte, ext)
395 * 395 *
396 * Set a PTE and flush it out 396 * Set a PTE and flush it out
397 */ 397 */
398 .align 5 398 .align 5
399ENTRY(cpu_arm925_set_pte) 399ENTRY(cpu_arm925_set_pte_ext)
400#ifdef CONFIG_MMU 400#ifdef CONFIG_MMU
401 str r1, [r0], #-2048 @ linux version 401 str r1, [r0], #-2048 @ linux version
402 402
@@ -490,7 +490,7 @@ arm925_processor_functions:
490 .word cpu_arm925_do_idle 490 .word cpu_arm925_do_idle
491 .word cpu_arm925_dcache_clean_area 491 .word cpu_arm925_dcache_clean_area
492 .word cpu_arm925_switch_mm 492 .word cpu_arm925_switch_mm
493 .word cpu_arm925_set_pte 493 .word cpu_arm925_set_pte_ext
494 .size arm925_processor_functions, . - arm925_processor_functions 494 .size arm925_processor_functions, . - arm925_processor_functions
495 495
496 .section ".rodata" 496 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
index 8628ed29a955..5b80b6bdd0cb 100644
--- a/arch/arm/mm/proc-arm926.S
+++ b/arch/arm/mm/proc-arm926.S
@@ -348,12 +348,12 @@ ENTRY(cpu_arm926_switch_mm)
348 mov pc, lr 348 mov pc, lr
349 349
350/* 350/*
351 * cpu_arm926_set_pte(ptep, pte) 351 * cpu_arm926_set_pte_ext(ptep, pte, ext)
352 * 352 *
353 * Set a PTE and flush it out 353 * Set a PTE and flush it out
354 */ 354 */
355 .align 5 355 .align 5
356ENTRY(cpu_arm926_set_pte) 356ENTRY(cpu_arm926_set_pte_ext)
357#ifdef CONFIG_MMU 357#ifdef CONFIG_MMU
358 str r1, [r0], #-2048 @ linux version 358 str r1, [r0], #-2048 @ linux version
359 359
@@ -439,7 +439,7 @@ arm926_processor_functions:
439 .word cpu_arm926_do_idle 439 .word cpu_arm926_do_idle
440 .word cpu_arm926_dcache_clean_area 440 .word cpu_arm926_dcache_clean_area
441 .word cpu_arm926_switch_mm 441 .word cpu_arm926_switch_mm
442 .word cpu_arm926_set_pte 442 .word cpu_arm926_set_pte_ext
443 .size arm926_processor_functions, . - arm926_processor_functions 443 .size arm926_processor_functions, . - arm926_processor_functions
444 444
445 .section ".rodata" 445 .section ".rodata"
@@ -480,7 +480,7 @@ __arm926_proc_info:
480 b __arm926_setup 480 b __arm926_setup
481 .long cpu_arch_name 481 .long cpu_arch_name
482 .long cpu_elf_name 482 .long cpu_elf_name
483 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_VFP|HWCAP_EDSP|HWCAP_JAVA 483 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
484 .long cpu_arm926_name 484 .long cpu_arm926_name
485 .long arm926_processor_functions 485 .long arm926_processor_functions
486 .long v4wbi_tlb_fns 486 .long v4wbi_tlb_fns
diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S
index cd7d865c9d19..6e226e12989f 100644
--- a/arch/arm/mm/proc-sa110.S
+++ b/arch/arm/mm/proc-sa110.S
@@ -146,12 +146,12 @@ ENTRY(cpu_sa110_switch_mm)
146#endif 146#endif
147 147
148/* 148/*
149 * cpu_sa110_set_pte(ptep, pte) 149 * cpu_sa110_set_pte_ext(ptep, pte, ext)
150 * 150 *
151 * Set a PTE and flush it out 151 * Set a PTE and flush it out
152 */ 152 */
153 .align 5 153 .align 5
154ENTRY(cpu_sa110_set_pte) 154ENTRY(cpu_sa110_set_pte_ext)
155#ifdef CONFIG_MMU 155#ifdef CONFIG_MMU
156 str r1, [r0], #-2048 @ linux version 156 str r1, [r0], #-2048 @ linux version
157 157
@@ -222,7 +222,7 @@ ENTRY(sa110_processor_functions)
222 .word cpu_sa110_do_idle 222 .word cpu_sa110_do_idle
223 .word cpu_sa110_dcache_clean_area 223 .word cpu_sa110_dcache_clean_area
224 .word cpu_sa110_switch_mm 224 .word cpu_sa110_switch_mm
225 .word cpu_sa110_set_pte 225 .word cpu_sa110_set_pte_ext
226 .size sa110_processor_functions, . - sa110_processor_functions 226 .size sa110_processor_functions, . - sa110_processor_functions
227 227
228 .section ".rodata" 228 .section ".rodata"
diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S
index b776653cc31c..9afb11d089fe 100644
--- a/arch/arm/mm/proc-sa1100.S
+++ b/arch/arm/mm/proc-sa1100.S
@@ -159,12 +159,12 @@ ENTRY(cpu_sa1100_switch_mm)
159#endif 159#endif
160 160
161/* 161/*
162 * cpu_sa1100_set_pte(ptep, pte) 162 * cpu_sa1100_set_pte_ext(ptep, pte, ext)
163 * 163 *
164 * Set a PTE and flush it out 164 * Set a PTE and flush it out
165 */ 165 */
166 .align 5 166 .align 5
167ENTRY(cpu_sa1100_set_pte) 167ENTRY(cpu_sa1100_set_pte_ext)
168#ifdef CONFIG_MMU 168#ifdef CONFIG_MMU
169 str r1, [r0], #-2048 @ linux version 169 str r1, [r0], #-2048 @ linux version
170 170
@@ -237,7 +237,7 @@ ENTRY(sa1100_processor_functions)
237 .word cpu_sa1100_do_idle 237 .word cpu_sa1100_do_idle
238 .word cpu_sa1100_dcache_clean_area 238 .word cpu_sa1100_dcache_clean_area
239 .word cpu_sa1100_switch_mm 239 .word cpu_sa1100_switch_mm
240 .word cpu_sa1100_set_pte 240 .word cpu_sa1100_set_pte_ext
241 .size sa1100_processor_functions, . - sa1100_processor_functions 241 .size sa1100_processor_functions, . - sa1100_processor_functions
242 242
243 .section ".rodata" 243 .section ".rodata"
diff --git a/arch/arm/mm/proc-syms.c b/arch/arm/mm/proc-syms.c
index ab143557e688..9f396b4fa0b7 100644
--- a/arch/arm/mm/proc-syms.c
+++ b/arch/arm/mm/proc-syms.c
@@ -17,7 +17,7 @@
17 17
18#ifndef MULTI_CPU 18#ifndef MULTI_CPU
19EXPORT_SYMBOL(cpu_dcache_clean_area); 19EXPORT_SYMBOL(cpu_dcache_clean_area);
20EXPORT_SYMBOL(cpu_set_pte); 20EXPORT_SYMBOL(cpu_set_pte_ext);
21#else 21#else
22EXPORT_SYMBOL(processor); 22EXPORT_SYMBOL(processor);
23#endif 23#endif
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index b440c8a1d345..7b1843befb9c 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -103,13 +103,14 @@ ENTRY(cpu_v6_switch_mm)
103 mov pc, lr 103 mov pc, lr
104 104
105/* 105/*
106 * cpu_v6_set_pte(ptep, pte) 106 * cpu_v6_set_pte_ext(ptep, pte, ext)
107 * 107 *
108 * Set a level 2 translation table entry. 108 * Set a level 2 translation table entry.
109 * 109 *
110 * - ptep - pointer to level 2 translation table entry 110 * - ptep - pointer to level 2 translation table entry
111 * (hardware version is stored at -1024 bytes) 111 * (hardware version is stored at -1024 bytes)
112 * - pte - PTE value to store 112 * - pte - PTE value to store
113 * - ext - value for extended PTE bits
113 * 114 *
114 * Permissions: 115 * Permissions:
115 * YUWD APX AP1 AP0 SVC User 116 * YUWD APX AP1 AP0 SVC User
@@ -121,33 +122,34 @@ ENTRY(cpu_v6_switch_mm)
121 * 11x0 0 1 0 r/w r/o 122 * 11x0 0 1 0 r/w r/o
122 * 1111 0 1 1 r/w r/w 123 * 1111 0 1 1 r/w r/w
123 */ 124 */
124ENTRY(cpu_v6_set_pte) 125ENTRY(cpu_v6_set_pte_ext)
125#ifdef CONFIG_MMU 126#ifdef CONFIG_MMU
126 str r1, [r0], #-2048 @ linux version 127 str r1, [r0], #-2048 @ linux version
127 128
128 bic r2, r1, #0x000003f0 129 bic r3, r1, #0x000003f0
129 bic r2, r2, #0x00000003 130 bic r3, r3, #0x00000003
130 orr r2, r2, #PTE_EXT_AP0 | 2 131 orr r3, r3, r2
132 orr r3, r3, #PTE_EXT_AP0 | 2
131 133
132 tst r1, #L_PTE_WRITE 134 tst r1, #L_PTE_WRITE
133 tstne r1, #L_PTE_DIRTY 135 tstne r1, #L_PTE_DIRTY
134 orreq r2, r2, #PTE_EXT_APX 136 orreq r3, r3, #PTE_EXT_APX
135 137
136 tst r1, #L_PTE_USER 138 tst r1, #L_PTE_USER
137 orrne r2, r2, #PTE_EXT_AP1 139 orrne r3, r3, #PTE_EXT_AP1
138 tstne r2, #PTE_EXT_APX 140 tstne r3, #PTE_EXT_APX
139 bicne r2, r2, #PTE_EXT_APX | PTE_EXT_AP0 141 bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
140 142
141 tst r1, #L_PTE_YOUNG 143 tst r1, #L_PTE_YOUNG
142 biceq r2, r2, #PTE_EXT_APX | PTE_EXT_AP_MASK 144 biceq r3, r3, #PTE_EXT_APX | PTE_EXT_AP_MASK
143 145
144 tst r1, #L_PTE_EXEC 146 tst r1, #L_PTE_EXEC
145 orreq r2, r2, #PTE_EXT_XN 147 orreq r3, r3, #PTE_EXT_XN
146 148
147 tst r1, #L_PTE_PRESENT 149 tst r1, #L_PTE_PRESENT
148 moveq r2, #0 150 moveq r3, #0
149 151
150 str r2, [r0] 152 str r3, [r0]
151 mcr p15, 0, r0, c7, c10, 1 @ flush_pte 153 mcr p15, 0, r0, c7, c10, 1 @ flush_pte
152#endif 154#endif
153 mov pc, lr 155 mov pc, lr
@@ -156,7 +158,7 @@ ENTRY(cpu_v6_set_pte)
156 158
157 159
158cpu_v6_name: 160cpu_v6_name:
159 .asciz "Some Random V6 Processor" 161 .asciz "ARMv6-compatible processor"
160 .align 162 .align
161 163
162 .section ".text.init", #alloc, #execinstr 164 .section ".text.init", #alloc, #execinstr
@@ -207,11 +209,6 @@ __v6_setup:
207#endif 209#endif
208 mcr p15, 0, r4, c2, c0, 1 @ load TTB1 210 mcr p15, 0, r4, c2, c0, 1 @ load TTB1
209#endif /* CONFIG_MMU */ 211#endif /* CONFIG_MMU */
210#ifdef CONFIG_VFP
211 mrc p15, 0, r0, c1, c0, 2
212 orr r0, r0, #(0xf << 20)
213 mcr p15, 0, r0, c1, c0, 2 @ Enable full access to VFP
214#endif
215 adr r5, v6_crval 212 adr r5, v6_crval
216 ldmia r5, {r5, r6} 213 ldmia r5, {r5, r6}
217 mrc p15, 0, r0, c1, c0, 0 @ read control register 214 mrc p15, 0, r0, c1, c0, 0 @ read control register
@@ -238,7 +235,7 @@ ENTRY(v6_processor_functions)
238 .word cpu_v6_do_idle 235 .word cpu_v6_do_idle
239 .word cpu_v6_dcache_clean_area 236 .word cpu_v6_dcache_clean_area
240 .word cpu_v6_switch_mm 237 .word cpu_v6_switch_mm
241 .word cpu_v6_set_pte 238 .word cpu_v6_set_pte_ext
242 .size v6_processor_functions, . - v6_processor_functions 239 .size v6_processor_functions, . - v6_processor_functions
243 240
244 .type cpu_arch_name, #object 241 .type cpu_arch_name, #object
@@ -273,7 +270,7 @@ __v6_proc_info:
273 b __v6_setup 270 b __v6_setup
274 .long cpu_arch_name 271 .long cpu_arch_name
275 .long cpu_elf_name 272 .long cpu_elf_name
276 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_VFP|HWCAP_EDSP|HWCAP_JAVA 273 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
277 .long cpu_v6_name 274 .long cpu_v6_name
278 .long v6_processor_functions 275 .long v6_processor_functions
279 .long v6wbi_tlb_fns 276 .long v6wbi_tlb_fns
diff --git a/arch/arm/mm/proc-xsc3.S b/arch/arm/mm/proc-xsc3.S
index 1ef564d0957f..43494ae8f01a 100644
--- a/arch/arm/mm/proc-xsc3.S
+++ b/arch/arm/mm/proc-xsc3.S
@@ -357,13 +357,13 @@ ENTRY(cpu_xsc3_switch_mm)
357 cpwait_ret lr, ip 357 cpwait_ret lr, ip
358 358
359/* 359/*
360 * cpu_xsc3_set_pte(ptep, pte) 360 * cpu_xsc3_set_pte_ext(ptep, pte, ext)
361 * 361 *
362 * Set a PTE and flush it out 362 * Set a PTE and flush it out
363 * 363 *
364 */ 364 */
365 .align 5 365 .align 5
366ENTRY(cpu_xsc3_set_pte) 366ENTRY(cpu_xsc3_set_pte_ext)
367 str r1, [r0], #-2048 @ linux version 367 str r1, [r0], #-2048 @ linux version
368 368
369 bic r2, r1, #0xff0 @ Keep C, B bits 369 bic r2, r1, #0xff0 @ Keep C, B bits
@@ -457,7 +457,7 @@ ENTRY(xsc3_processor_functions)
457 .word cpu_xsc3_do_idle 457 .word cpu_xsc3_do_idle
458 .word cpu_xsc3_dcache_clean_area 458 .word cpu_xsc3_dcache_clean_area
459 .word cpu_xsc3_switch_mm 459 .word cpu_xsc3_switch_mm
460 .word cpu_xsc3_set_pte 460 .word cpu_xsc3_set_pte_ext
461 .size xsc3_processor_functions, . - xsc3_processor_functions 461 .size xsc3_processor_functions, . - xsc3_processor_functions
462 462
463 .section ".rodata" 463 .section ".rodata"
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index cc1004b3e511..490e11b34231 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -421,14 +421,14 @@ ENTRY(cpu_xscale_switch_mm)
421 cpwait_ret lr, ip 421 cpwait_ret lr, ip
422 422
423/* 423/*
424 * cpu_xscale_set_pte(ptep, pte) 424 * cpu_xscale_set_pte_ext(ptep, pte, ext)
425 * 425 *
426 * Set a PTE and flush it out 426 * Set a PTE and flush it out
427 * 427 *
428 * Errata 40: must set memory to write-through for user read-only pages. 428 * Errata 40: must set memory to write-through for user read-only pages.
429 */ 429 */
430 .align 5 430 .align 5
431ENTRY(cpu_xscale_set_pte) 431ENTRY(cpu_xscale_set_pte_ext)
432 str r1, [r0], #-2048 @ linux version 432 str r1, [r0], #-2048 @ linux version
433 433
434 bic r2, r1, #0xff0 434 bic r2, r1, #0xff0
@@ -529,7 +529,7 @@ ENTRY(xscale_processor_functions)
529 .word cpu_xscale_do_idle 529 .word cpu_xscale_do_idle
530 .word cpu_xscale_dcache_clean_area 530 .word cpu_xscale_dcache_clean_area
531 .word cpu_xscale_switch_mm 531 .word cpu_xscale_switch_mm
532 .word cpu_xscale_set_pte 532 .word cpu_xscale_set_pte_ext
533 .size xscale_processor_functions, . - xscale_processor_functions 533 .size xscale_processor_functions, . - xscale_processor_functions
534 534
535 .section ".rodata" 535 .section ".rodata"
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index f08eafbddcc1..e26cc1f59948 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -263,13 +263,24 @@ void VFP9_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs)
263 if (exceptions) 263 if (exceptions)
264 vfp_raise_exceptions(exceptions, trigger, orig_fpscr, regs); 264 vfp_raise_exceptions(exceptions, trigger, orig_fpscr, regs);
265} 265}
266 266
267/* 267/*
268 * VFP support code initialisation. 268 * VFP support code initialisation.
269 */ 269 */
270static int __init vfp_init(void) 270static int __init vfp_init(void)
271{ 271{
272 unsigned int vfpsid; 272 unsigned int vfpsid;
273 unsigned int cpu_arch = cpu_architecture();
274 u32 access = 0;
275
276 if (cpu_arch >= CPU_ARCH_ARMv6) {
277 access = get_copro_access();
278
279 /*
280 * Enable full access to VFP (cp10 and cp11)
281 */
282 set_copro_access(access | CPACC_FULL(10) | CPACC_FULL(11));
283 }
273 284
274 /* 285 /*
275 * First check that there is a VFP that we can use. 286 * First check that there is a VFP that we can use.
@@ -281,6 +292,12 @@ static int __init vfp_init(void)
281 printk(KERN_INFO "VFP support v0.3: "); 292 printk(KERN_INFO "VFP support v0.3: ");
282 if (VFP_arch) { 293 if (VFP_arch) {
283 printk("not present\n"); 294 printk("not present\n");
295
296 /*
297 * Restore the copro access register.
298 */
299 if (cpu_arch >= CPU_ARCH_ARMv6)
300 set_copro_access(access);
284 } else if (vfpsid & FPSID_NODOUBLE) { 301 } else if (vfpsid & FPSID_NODOUBLE) {
285 printk("no double precision support\n"); 302 printk("no double precision support\n");
286 } else { 303 } else {
@@ -291,9 +308,16 @@ static int __init vfp_init(void)
291 (vfpsid & FPSID_PART_MASK) >> FPSID_PART_BIT, 308 (vfpsid & FPSID_PART_MASK) >> FPSID_PART_BIT,
292 (vfpsid & FPSID_VARIANT_MASK) >> FPSID_VARIANT_BIT, 309 (vfpsid & FPSID_VARIANT_MASK) >> FPSID_VARIANT_BIT,
293 (vfpsid & FPSID_REV_MASK) >> FPSID_REV_BIT); 310 (vfpsid & FPSID_REV_MASK) >> FPSID_REV_BIT);
311
294 vfp_vector = vfp_support_entry; 312 vfp_vector = vfp_support_entry;
295 313
296 thread_register_notifier(&vfp_notifier_block); 314 thread_register_notifier(&vfp_notifier_block);
315
316 /*
317 * We detected VFP, and the support code is
318 * in place; report VFP support to userspace.
319 */
320 elf_hwcap |= HWCAP_VFP;
297 } 321 }
298 return 0; 322 return 0;
299} 323}
diff --git a/arch/arm26/kernel/ecard.c b/arch/arm26/kernel/ecard.c
index 43dd41be71fb..9dbc17247c6f 100644
--- a/arch/arm26/kernel/ecard.c
+++ b/arch/arm26/kernel/ecard.c
@@ -215,7 +215,7 @@ int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num)
215 } 215 }
216 if (c_id(&excd) == 0x80) { /* loader */ 216 if (c_id(&excd) == 0x80) { /* loader */
217 if (!ec->loader) { 217 if (!ec->loader) {
218 ec->loader = (loader_t)kmalloc(c_len(&excd), 218 ec->loader = kmalloc(c_len(&excd),
219 GFP_KERNEL); 219 GFP_KERNEL);
220 if (ec->loader) 220 if (ec->loader)
221 ecard_readbytes(ec->loader, ec, 221 ecard_readbytes(ec->loader, ec,
diff --git a/arch/arm26/kernel/irq.c b/arch/arm26/kernel/irq.c
index d87d68b77d66..d53382c83bf9 100644
--- a/arch/arm26/kernel/irq.c
+++ b/arch/arm26/kernel/irq.c
@@ -545,7 +545,7 @@ int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_
545 (irq_flags & IRQF_SHARED && !dev_id)) 545 (irq_flags & IRQF_SHARED && !dev_id))
546 return -EINVAL; 546 return -EINVAL;
547 547
548 action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL); 548 action = kmalloc(sizeof(struct irqaction), GFP_KERNEL);
549 if (!action) 549 if (!action)
550 return -ENOMEM; 550 return -ENOMEM;
551 551
diff --git a/arch/cris/arch-v10/drivers/axisflashmap.c b/arch/cris/arch-v10/drivers/axisflashmap.c
index 4fa81abab0c7..ffade19a14e6 100644
--- a/arch/cris/arch-v10/drivers/axisflashmap.c
+++ b/arch/cris/arch-v10/drivers/axisflashmap.c
@@ -516,7 +516,7 @@ static int __init init_axis_flash(void)
516#else 516#else
517 struct mtd_info *mtd_ram; 517 struct mtd_info *mtd_ram;
518 518
519 mtd_ram = (struct mtd_info *)kmalloc(sizeof(struct mtd_info), 519 mtd_ram = kmalloc(sizeof(struct mtd_info),
520 GFP_KERNEL); 520 GFP_KERNEL);
521 if (!mtd_ram) { 521 if (!mtd_ram) {
522 panic("axisflashmap couldn't allocate memory for " 522 panic("axisflashmap couldn't allocate memory for "
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
index fcba6632ed7b..9aba18b931dd 100644
--- a/arch/cris/arch-v10/drivers/gpio.c
+++ b/arch/cris/arch-v10/drivers/gpio.c
@@ -440,7 +440,7 @@ gpio_open(struct inode *inode, struct file *filp)
440 if (p > GPIO_MINOR_LAST) 440 if (p > GPIO_MINOR_LAST)
441 return -EINVAL; 441 return -EINVAL;
442 442
443 priv = (struct gpio_private *)kmalloc(sizeof(struct gpio_private), 443 priv = kmalloc(sizeof(struct gpio_private),
444 GFP_KERNEL); 444 GFP_KERNEL);
445 445
446 if (!priv) 446 if (!priv)
diff --git a/arch/cris/arch-v32/drivers/axisflashmap.c b/arch/cris/arch-v32/drivers/axisflashmap.c
index 41952320e00a..5180d45412fc 100644
--- a/arch/cris/arch-v32/drivers/axisflashmap.c
+++ b/arch/cris/arch-v32/drivers/axisflashmap.c
@@ -427,7 +427,7 @@ static int __init init_axis_flash(void)
427#else 427#else
428 struct mtd_info *mtd_ram; 428 struct mtd_info *mtd_ram;
429 429
430 mtd_ram = (struct mtd_info *)kmalloc(sizeof(struct mtd_info), 430 mtd_ram = kmalloc(sizeof(struct mtd_info),
431 GFP_KERNEL); 431 GFP_KERNEL);
432 if (!mtd_ram) { 432 if (!mtd_ram) {
433 panic("axisflashmap couldn't allocate memory for " 433 panic("axisflashmap couldn't allocate memory for "
diff --git a/arch/cris/arch-v32/drivers/gpio.c b/arch/cris/arch-v32/drivers/gpio.c
index c3f876b4da6b..08d36f0955c6 100644
--- a/arch/cris/arch-v32/drivers/gpio.c
+++ b/arch/cris/arch-v32/drivers/gpio.c
@@ -423,7 +423,7 @@ gpio_open(struct inode *inode, struct file *filp)
423 if (p > GPIO_MINOR_LAST) 423 if (p > GPIO_MINOR_LAST)
424 return -EINVAL; 424 return -EINVAL;
425 425
426 priv = (struct gpio_private *)kmalloc(sizeof(struct gpio_private), 426 priv = kmalloc(sizeof(struct gpio_private),
427 GFP_KERNEL); 427 GFP_KERNEL);
428 428
429 if (!priv) 429 if (!priv)
diff --git a/arch/cris/arch-v32/kernel/signal.c b/arch/cris/arch-v32/kernel/signal.c
index 99e59b3eacf8..7cd6ac803409 100644
--- a/arch/cris/arch-v32/kernel/signal.c
+++ b/arch/cris/arch-v32/kernel/signal.c
@@ -686,7 +686,7 @@ keep_debug_flags(unsigned long oldccs, unsigned long oldspc,
686int __init 686int __init
687cris_init_signal(void) 687cris_init_signal(void)
688{ 688{
689 u16* data = (u16*)kmalloc(PAGE_SIZE, GFP_KERNEL); 689 u16* data = kmalloc(PAGE_SIZE, GFP_KERNEL);
690 690
691 /* This is movu.w __NR_sigreturn, r9; break 13; */ 691 /* This is movu.w __NR_sigreturn, r9; break 13; */
692 data[0] = 0x9c5f; 692 data[0] = 0x9c5f;
diff --git a/arch/cris/kernel/profile.c b/arch/cris/kernel/profile.c
index 69c52189f044..f60ab785f235 100644
--- a/arch/cris/kernel/profile.c
+++ b/arch/cris/kernel/profile.c
@@ -59,7 +59,7 @@ static int
59__init init_cris_profile(void) 59__init init_cris_profile(void)
60{ 60{
61 struct proc_dir_entry *entry; 61 struct proc_dir_entry *entry;
62 sample_buffer = (char*)kmalloc(SAMPLE_BUFFER_SIZE, GFP_KERNEL); 62 sample_buffer = kmalloc(SAMPLE_BUFFER_SIZE, GFP_KERNEL);
63 sample_buffer_pos = sample_buffer; 63 sample_buffer_pos = sample_buffer;
64 entry = create_proc_entry("system_profile", S_IWUSR | S_IRUGO, NULL); 64 entry = create_proc_entry("system_profile", S_IWUSR | S_IRUGO, NULL);
65 if (entry) { 65 if (entry) {
diff --git a/arch/h8300/kernel/ints.c b/arch/h8300/kernel/ints.c
index 1bfc77e391d5..587ef7f4fcc7 100644
--- a/arch/h8300/kernel/ints.c
+++ b/arch/h8300/kernel/ints.c
@@ -141,7 +141,7 @@ int request_irq(unsigned int irq,
141 return -EBUSY; 141 return -EBUSY;
142 142
143 if (use_kmalloc) 143 if (use_kmalloc)
144 irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC); 144 irq_handle = kmalloc(sizeof(irq_handler_t), GFP_ATOMIC);
145 else { 145 else {
146 /* use bootmem allocater */ 146 /* use bootmem allocater */
147 irq_handle = (irq_handler_t *)alloc_bootmem(sizeof(irq_handler_t)); 147 irq_handle = (irq_handler_t *)alloc_bootmem(sizeof(irq_handler_t));
diff --git a/arch/h8300/platform/h8s/ints.c b/arch/h8300/platform/h8s/ints.c
index 270440de4610..567f681ddfec 100644
--- a/arch/h8300/platform/h8s/ints.c
+++ b/arch/h8300/platform/h8s/ints.c
@@ -176,7 +176,7 @@ int request_irq(unsigned int irq,
176 } 176 }
177 177
178 if (use_kmalloc) 178 if (use_kmalloc)
179 irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC); 179 irq_handle = kmalloc(sizeof(irq_handler_t), GFP_ATOMIC);
180 else { 180 else {
181 /* use bootmem allocater */ 181 /* use bootmem allocater */
182 irq_handle = (irq_handler_t *)alloc_bootmem(sizeof(irq_handler_t)); 182 irq_handle = (irq_handler_t *)alloc_bootmem(sizeof(irq_handler_t));
diff --git a/arch/i386/defconfig b/arch/i386/defconfig
index 3265208e5899..e075ff05c46d 100644
--- a/arch/i386/defconfig
+++ b/arch/i386/defconfig
@@ -1493,8 +1493,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
1493# CONFIG_DEBUG_VM is not set 1493# CONFIG_DEBUG_VM is not set
1494# CONFIG_DEBUG_LIST is not set 1494# CONFIG_DEBUG_LIST is not set
1495# CONFIG_FRAME_POINTER is not set 1495# CONFIG_FRAME_POINTER is not set
1496CONFIG_UNWIND_INFO=y
1497CONFIG_STACK_UNWIND=y
1498# CONFIG_FORCED_INLINING is not set 1496# CONFIG_FORCED_INLINING is not set
1499# CONFIG_HEADERS_CHECK is not set 1497# CONFIG_HEADERS_CHECK is not set
1500# CONFIG_RCU_TORTURE_TEST is not set 1498# CONFIG_RCU_TORTURE_TEST is not set
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index a97847da9ed5..b75cff25de4b 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -1604,7 +1604,7 @@ static int do_open(struct inode * inode, struct file * filp)
1604{ 1604{
1605 struct apm_user * as; 1605 struct apm_user * as;
1606 1606
1607 as = (struct apm_user *)kmalloc(sizeof(*as), GFP_KERNEL); 1607 as = kmalloc(sizeof(*as), GFP_KERNEL);
1608 if (as == NULL) { 1608 if (as == NULL) {
1609 printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n", 1609 printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n",
1610 sizeof(*as)); 1610 sizeof(*as));
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
index de34b7fed3c1..06461b8b715d 100644
--- a/arch/i386/kernel/entry.S
+++ b/arch/i386/kernel/entry.S
@@ -979,38 +979,6 @@ ENTRY(spurious_interrupt_bug)
979 jmp error_code 979 jmp error_code
980 CFI_ENDPROC 980 CFI_ENDPROC
981 981
982#ifdef CONFIG_STACK_UNWIND
983ENTRY(arch_unwind_init_running)
984 CFI_STARTPROC
985 movl 4(%esp), %edx
986 movl (%esp), %ecx
987 leal 4(%esp), %eax
988 movl %ebx, PT_EBX(%edx)
989 xorl %ebx, %ebx
990 movl %ebx, PT_ECX(%edx)
991 movl %ebx, PT_EDX(%edx)
992 movl %esi, PT_ESI(%edx)
993 movl %edi, PT_EDI(%edx)
994 movl %ebp, PT_EBP(%edx)
995 movl %ebx, PT_EAX(%edx)
996 movl $__USER_DS, PT_DS(%edx)
997 movl $__USER_DS, PT_ES(%edx)
998 movl $0, PT_GS(%edx)
999 movl %ebx, PT_ORIG_EAX(%edx)
1000 movl %ecx, PT_EIP(%edx)
1001 movl 12(%esp), %ecx
1002 movl $__KERNEL_CS, PT_CS(%edx)
1003 movl %ebx, PT_EFLAGS(%edx)
1004 movl %eax, PT_OLDESP(%edx)
1005 movl 8(%esp), %eax
1006 movl %ecx, 8(%esp)
1007 movl PT_EBX(%edx), %ebx
1008 movl $__KERNEL_DS, PT_OLDSS(%edx)
1009 jmpl *%eax
1010 CFI_ENDPROC
1011ENDPROC(arch_unwind_init_running)
1012#endif
1013
1014ENTRY(kernel_thread_helper) 982ENTRY(kernel_thread_helper)
1015 pushl $0 # fake return address for unwinder 983 pushl $0 # fake return address for unwinder
1016 CFI_STARTPROC 984 CFI_STARTPROC
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 972346604f9d..47ffec57c0cb 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Intel CPU Microcode Update Driver for Linux 2 * Intel CPU Microcode Update Driver for Linux
3 * 3 *
4 * Copyright (C) 2000-2004 Tigran Aivazian 4 * Copyright (C) 2000-2006 Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
5 * 2006 Shaohua Li <shaohua.li@intel.com> 5 * 2006 Shaohua Li <shaohua.li@intel.com>
6 * 6 *
7 * This driver allows to upgrade microcode on Intel processors 7 * This driver allows to upgrade microcode on Intel processors
@@ -92,7 +92,7 @@
92#include <asm/processor.h> 92#include <asm/processor.h>
93 93
94MODULE_DESCRIPTION("Intel CPU (IA-32) Microcode Update Driver"); 94MODULE_DESCRIPTION("Intel CPU (IA-32) Microcode Update Driver");
95MODULE_AUTHOR("Tigran Aivazian <tigran@veritas.com>"); 95MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>");
96MODULE_LICENSE("GPL"); 96MODULE_LICENSE("GPL");
97 97
98#define MICROCODE_VERSION "1.14a" 98#define MICROCODE_VERSION "1.14a"
@@ -752,7 +752,7 @@ static int __init microcode_init (void)
752 register_hotcpu_notifier(&mc_cpu_notifier); 752 register_hotcpu_notifier(&mc_cpu_notifier);
753 753
754 printk(KERN_INFO 754 printk(KERN_INFO
755 "IA-32 Microcode Update Driver: v" MICROCODE_VERSION " <tigran@veritas.com>\n"); 755 "IA-32 Microcode Update Driver: v" MICROCODE_VERSION " <tigran@aivazian.fsnet.co.uk>\n");
756 return 0; 756 return 0;
757} 757}
758 758
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index b0f84e5778ad..aef39be81361 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -69,9 +69,7 @@ static int __devinitdata smp_b_stepping;
69 69
70/* Number of siblings per CPU package */ 70/* Number of siblings per CPU package */
71int smp_num_siblings = 1; 71int smp_num_siblings = 1;
72#ifdef CONFIG_SMP
73EXPORT_SYMBOL(smp_num_siblings); 72EXPORT_SYMBOL(smp_num_siblings);
74#endif
75 73
76/* Last level cache ID of each logical CPU */ 74/* Last level cache ID of each logical CPU */
77int cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID}; 75int cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID};
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 2b30dbf8d117..0efad8aeb41a 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -94,11 +94,6 @@ asmlinkage void spurious_interrupt_bug(void);
94asmlinkage void machine_check(void); 94asmlinkage void machine_check(void);
95 95
96int kstack_depth_to_print = 24; 96int kstack_depth_to_print = 24;
97#ifdef CONFIG_STACK_UNWIND
98static int call_trace = 1;
99#else
100#define call_trace (-1)
101#endif
102ATOMIC_NOTIFIER_HEAD(i386die_chain); 97ATOMIC_NOTIFIER_HEAD(i386die_chain);
103 98
104int register_die_notifier(struct notifier_block *nb) 99int register_die_notifier(struct notifier_block *nb)
@@ -152,33 +147,6 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
152 return ebp; 147 return ebp;
153} 148}
154 149
155struct ops_and_data {
156 struct stacktrace_ops *ops;
157 void *data;
158};
159
160static asmlinkage int
161dump_trace_unwind(struct unwind_frame_info *info, void *data)
162{
163 struct ops_and_data *oad = (struct ops_and_data *)data;
164 int n = 0;
165 unsigned long sp = UNW_SP(info);
166
167 if (arch_unw_user_mode(info))
168 return -1;
169 while (unwind(info) == 0 && UNW_PC(info)) {
170 n++;
171 oad->ops->address(oad->data, UNW_PC(info));
172 if (arch_unw_user_mode(info))
173 break;
174 if ((sp & ~(PAGE_SIZE - 1)) == (UNW_SP(info) & ~(PAGE_SIZE - 1))
175 && sp > UNW_SP(info))
176 break;
177 sp = UNW_SP(info);
178 }
179 return n;
180}
181
182#define MSG(msg) ops->warning(data, msg) 150#define MSG(msg) ops->warning(data, msg)
183 151
184void dump_trace(struct task_struct *task, struct pt_regs *regs, 152void dump_trace(struct task_struct *task, struct pt_regs *regs,
@@ -190,41 +158,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
190 if (!task) 158 if (!task)
191 task = current; 159 task = current;
192 160
193 if (call_trace >= 0) {
194 int unw_ret = 0;
195 struct unwind_frame_info info;
196 struct ops_and_data oad = { .ops = ops, .data = data };
197
198 if (regs) {
199 if (unwind_init_frame_info(&info, task, regs) == 0)
200 unw_ret = dump_trace_unwind(&info, &oad);
201 } else if (task == current)
202 unw_ret = unwind_init_running(&info, dump_trace_unwind,
203 &oad);
204 else {
205 if (unwind_init_blocked(&info, task) == 0)
206 unw_ret = dump_trace_unwind(&info, &oad);
207 }
208 if (unw_ret > 0) {
209 if (call_trace == 1 && !arch_unw_user_mode(&info)) {
210 ops->warning_symbol(data,
211 "DWARF2 unwinder stuck at %s",
212 UNW_PC(&info));
213 if (UNW_SP(&info) >= PAGE_OFFSET) {
214 MSG("Leftover inexact backtrace:");
215 stack = (void *)UNW_SP(&info);
216 if (!stack)
217 return;
218 ebp = UNW_FP(&info);
219 } else
220 MSG("Full inexact backtrace again:");
221 } else if (call_trace >= 1)
222 return;
223 else
224 MSG("Full inexact backtrace again:");
225 } else
226 MSG("Inexact backtrace:");
227 }
228 if (!stack) { 161 if (!stack) {
229 unsigned long dummy; 162 unsigned long dummy;
230 stack = &dummy; 163 stack = &dummy;
@@ -1258,19 +1191,3 @@ static int __init kstack_setup(char *s)
1258 return 1; 1191 return 1;
1259} 1192}
1260__setup("kstack=", kstack_setup); 1193__setup("kstack=", kstack_setup);
1261
1262#ifdef CONFIG_STACK_UNWIND
1263static int __init call_trace_setup(char *s)
1264{
1265 if (strcmp(s, "old") == 0)
1266 call_trace = -1;
1267 else if (strcmp(s, "both") == 0)
1268 call_trace = 0;
1269 else if (strcmp(s, "newfallback") == 0)
1270 call_trace = 1;
1271 else if (strcmp(s, "new") == 2)
1272 call_trace = 2;
1273 return 1;
1274}
1275__setup("call_trace=", call_trace_setup);
1276#endif
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index 462ea178f49a..33367996d72d 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -189,7 +189,7 @@ static void print_pci_topology(struct seq_file *s)
189 int e; 189 int e;
190 190
191 for (sz = PAGE_SIZE; sz < 16 * PAGE_SIZE; sz += PAGE_SIZE) { 191 for (sz = PAGE_SIZE; sz < 16 * PAGE_SIZE; sz += PAGE_SIZE) {
192 if (!(p = (char *)kmalloc(sz, GFP_KERNEL))) 192 if (!(p = kmalloc(sz, GFP_KERNEL)))
193 break; 193 break;
194 e = ia64_sn_ioif_get_pci_topology(__pa(p), sz); 194 e = ia64_sn_ioif_get_pci_topology(__pa(p), sz);
195 if (e == SALRET_OK) 195 if (e == SALRET_OK)
diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
index b54ef1726c55..46b7d6035aab 100644
--- a/arch/m68k/mm/kmap.c
+++ b/arch/m68k/mm/kmap.c
@@ -59,7 +59,7 @@ static struct vm_struct *get_io_area(unsigned long size)
59 unsigned long addr; 59 unsigned long addr;
60 struct vm_struct **p, *tmp, *area; 60 struct vm_struct **p, *tmp, *area;
61 61
62 area = (struct vm_struct *)kmalloc(sizeof(*area), GFP_KERNEL); 62 area = kmalloc(sizeof(*area), GFP_KERNEL);
63 if (!area) 63 if (!area)
64 return NULL; 64 return NULL;
65 addr = KMAP_START; 65 addr = KMAP_START;
diff --git a/arch/mips/kernel/apm.c b/arch/mips/kernel/apm.c
index 528e731049c1..ba16d07588cb 100644
--- a/arch/mips/kernel/apm.c
+++ b/arch/mips/kernel/apm.c
@@ -356,7 +356,7 @@ static int apm_open(struct inode * inode, struct file * filp)
356{ 356{
357 struct apm_user *as; 357 struct apm_user *as;
358 358
359 as = (struct apm_user *)kzalloc(sizeof(*as), GFP_KERNEL); 359 as = kzalloc(sizeof(*as), GFP_KERNEL);
360 if (as) { 360 if (as) {
361 /* 361 /*
362 * XXX - this is a tiny bit broken, when we consider BSD 362 * XXX - this is a tiny bit broken, when we consider BSD
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index ea2d15370bb7..30245c09d025 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -203,6 +203,31 @@ static inline void kunmap_coherent(struct page *page)
203 preempt_check_resched(); 203 preempt_check_resched();
204} 204}
205 205
206void copy_user_highpage(struct page *to, struct page *from,
207 unsigned long vaddr, struct vm_area_struct *vma)
208{
209 void *vfrom, *vto;
210
211 vto = kmap_atomic(to, KM_USER1);
212 if (cpu_has_dc_aliases) {
213 vfrom = kmap_coherent(from, vaddr);
214 copy_page(vto, vfrom);
215 kunmap_coherent(from);
216 } else {
217 vfrom = kmap_atomic(from, KM_USER0);
218 copy_page(vto, vfrom);
219 kunmap_atomic(vfrom, KM_USER0);
220 }
221 if (((vma->vm_flags & VM_EXEC) && !cpu_has_ic_fills_f_dc) ||
222 pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK))
223 flush_data_cache_page((unsigned long)vto);
224 kunmap_atomic(vto, KM_USER1);
225 /* Make sure this page is cleared on other CPU's too before using it */
226 smp_wmb();
227}
228
229EXPORT_SYMBOL(copy_user_highpage);
230
206void copy_to_user_page(struct vm_area_struct *vma, 231void copy_to_user_page(struct vm_area_struct *vma,
207 struct page *page, unsigned long vaddr, void *dst, const void *src, 232 struct page *page, unsigned long vaddr, void *dst, const void *src,
208 unsigned long len) 233 unsigned long len)
diff --git a/arch/parisc/hpux/sys_hpux.c b/arch/parisc/hpux/sys_hpux.c
index d88309209f56..04c2ff444396 100644
--- a/arch/parisc/hpux/sys_hpux.c
+++ b/arch/parisc/hpux/sys_hpux.c
@@ -475,7 +475,7 @@ int hpux_sysfs(int opcode, unsigned long arg1, unsigned long arg2)
475 printk(KERN_DEBUG "len of arg1 = %d\n", len); 475 printk(KERN_DEBUG "len of arg1 = %d\n", len);
476 if (len == 0) 476 if (len == 0)
477 return 0; 477 return 0;
478 fsname = (char *) kmalloc(len, GFP_KERNEL); 478 fsname = kmalloc(len, GFP_KERNEL);
479 if ( !fsname ) { 479 if ( !fsname ) {
480 printk(KERN_DEBUG "failed to kmalloc fsname\n"); 480 printk(KERN_DEBUG "failed to kmalloc fsname\n");
481 return 0; 481 return 0;
diff --git a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c
index 920bdbf8404f..c10ab47d81fa 100644
--- a/arch/parisc/kernel/unwind.c
+++ b/arch/parisc/kernel/unwind.c
@@ -343,7 +343,7 @@ void unwind_frame_init_from_blocked_task(struct unwind_frame_info *info, struct
343 struct pt_regs *r = &t->thread.regs; 343 struct pt_regs *r = &t->thread.regs;
344 struct pt_regs *r2; 344 struct pt_regs *r2;
345 345
346 r2 = (struct pt_regs *)kmalloc(sizeof(struct pt_regs), GFP_KERNEL); 346 r2 = kmalloc(sizeof(struct pt_regs), GFP_KERNEL);
347 if (!r2) 347 if (!r2)
348 return; 348 return;
349 *r2 = *r; 349 *r2 = *r;
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 6960f090991e..869cebbba967 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -505,7 +505,7 @@ static int nvram_scan_partitions(void)
505 return -ENODEV; 505 return -ENODEV;
506 total_size = ppc_md.nvram_size(); 506 total_size = ppc_md.nvram_size();
507 507
508 header = (char *) kmalloc(NVRAM_HEADER_LEN, GFP_KERNEL); 508 header = kmalloc(NVRAM_HEADER_LEN, GFP_KERNEL);
509 if (!header) { 509 if (!header) {
510 printk(KERN_ERR "nvram_scan_partitions: Failed kmalloc\n"); 510 printk(KERN_ERR "nvram_scan_partitions: Failed kmalloc\n");
511 return -ENOMEM; 511 return -ENOMEM;
@@ -574,7 +574,7 @@ static int __init nvram_init(void)
574 } 574 }
575 575
576 /* initialize our anchor for the nvram partition list */ 576 /* initialize our anchor for the nvram partition list */
577 nvram_part = (struct nvram_partition *) kmalloc(sizeof(struct nvram_partition), GFP_KERNEL); 577 nvram_part = kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);
578 if (!nvram_part) { 578 if (!nvram_part) {
579 printk(KERN_ERR "nvram_init: Failed kmalloc\n"); 579 printk(KERN_ERR "nvram_init: Failed kmalloc\n");
580 return -ENOMEM; 580 return -ENOMEM;
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 8336deafc624..2847cd51a2d7 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -670,7 +670,7 @@ pcibios_make_OF_bus_map(void)
670 struct pci_controller* hose; 670 struct pci_controller* hose;
671 struct property *map_prop; 671 struct property *map_prop;
672 672
673 pci_to_OF_bus_map = (u8*)kmalloc(pci_bus_count, GFP_KERNEL); 673 pci_to_OF_bus_map = kmalloc(pci_bus_count, GFP_KERNEL);
674 if (!pci_to_OF_bus_map) { 674 if (!pci_to_OF_bus_map) {
675 printk(KERN_ERR "Can't allocate OF bus map !\n"); 675 printk(KERN_ERR "Can't allocate OF bus map !\n");
676 return; 676 return;
diff --git a/arch/powerpc/mm/imalloc.c b/arch/powerpc/mm/imalloc.c
index add8c1a9af68..c831815c31f0 100644
--- a/arch/powerpc/mm/imalloc.c
+++ b/arch/powerpc/mm/imalloc.c
@@ -138,7 +138,7 @@ static struct vm_struct * split_im_region(unsigned long v_addr,
138 struct vm_struct *vm2 = NULL; 138 struct vm_struct *vm2 = NULL;
139 struct vm_struct *new_vm = NULL; 139 struct vm_struct *new_vm = NULL;
140 140
141 vm1 = (struct vm_struct *) kmalloc(sizeof(*vm1), GFP_KERNEL); 141 vm1 = kmalloc(sizeof(*vm1), GFP_KERNEL);
142 if (vm1 == NULL) { 142 if (vm1 == NULL) {
143 printk(KERN_ERR "%s() out of memory\n", __FUNCTION__); 143 printk(KERN_ERR "%s() out of memory\n", __FUNCTION__);
144 return NULL; 144 return NULL;
@@ -172,7 +172,7 @@ static struct vm_struct * split_im_region(unsigned long v_addr,
172 * uppermost remainder, and use existing parent one for the 172 * uppermost remainder, and use existing parent one for the
173 * lower remainder of parent range 173 * lower remainder of parent range
174 */ 174 */
175 vm2 = (struct vm_struct *) kmalloc(sizeof(*vm2), GFP_KERNEL); 175 vm2 = kmalloc(sizeof(*vm2), GFP_KERNEL);
176 if (vm2 == NULL) { 176 if (vm2 == NULL) {
177 printk(KERN_ERR "%s() out of memory\n", __FUNCTION__); 177 printk(KERN_ERR "%s() out of memory\n", __FUNCTION__);
178 kfree(vm1); 178 kfree(vm1);
@@ -206,7 +206,7 @@ static struct vm_struct * __add_new_im_area(unsigned long req_addr,
206 break; 206 break;
207 } 207 }
208 208
209 area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL); 209 area = kmalloc(sizeof(*area), GFP_KERNEL);
210 if (!area) 210 if (!area)
211 return NULL; 211 return NULL;
212 area->flags = 0; 212 area->flags = 0;
diff --git a/arch/powerpc/platforms/pseries/eeh_cache.c b/arch/powerpc/platforms/pseries/eeh_cache.c
index b6b462d3c604..f2bae04424f8 100644
--- a/arch/powerpc/platforms/pseries/eeh_cache.c
+++ b/arch/powerpc/platforms/pseries/eeh_cache.c
@@ -153,7 +153,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
153 return piar; 153 return piar;
154 } 154 }
155 } 155 }
156 piar = (struct pci_io_addr_range *)kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC); 156 piar = kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC);
157 if (!piar) 157 if (!piar)
158 return NULL; 158 return NULL;
159 159
diff --git a/arch/ppc/8260_io/fcc_enet.c b/arch/ppc/8260_io/fcc_enet.c
index 709952c25f29..06b84c372e58 100644
--- a/arch/ppc/8260_io/fcc_enet.c
+++ b/arch/ppc/8260_io/fcc_enet.c
@@ -1892,10 +1892,10 @@ init_fcc_param(fcc_info_t *fip, struct net_device *dev,
1892 /* Allocate space for the buffer descriptors from regular memory. 1892 /* Allocate space for the buffer descriptors from regular memory.
1893 * Initialize base addresses for the buffer descriptors. 1893 * Initialize base addresses for the buffer descriptors.
1894 */ 1894 */
1895 cep->rx_bd_base = (cbd_t *)kmalloc(sizeof(cbd_t) * RX_RING_SIZE, 1895 cep->rx_bd_base = kmalloc(sizeof(cbd_t) * RX_RING_SIZE,
1896 GFP_KERNEL | GFP_DMA); 1896 GFP_KERNEL | GFP_DMA);
1897 ep->fen_genfcc.fcc_rbase = __pa(cep->rx_bd_base); 1897 ep->fen_genfcc.fcc_rbase = __pa(cep->rx_bd_base);
1898 cep->tx_bd_base = (cbd_t *)kmalloc(sizeof(cbd_t) * TX_RING_SIZE, 1898 cep->tx_bd_base = kmalloc(sizeof(cbd_t) * TX_RING_SIZE,
1899 GFP_KERNEL | GFP_DMA); 1899 GFP_KERNEL | GFP_DMA);
1900 ep->fen_genfcc.fcc_tbase = __pa(cep->tx_bd_base); 1900 ep->fen_genfcc.fcc_tbase = __pa(cep->tx_bd_base);
1901 1901
diff --git a/arch/ppc/8xx_io/cs4218_tdm.c b/arch/ppc/8xx_io/cs4218_tdm.c
index c71ef3c2e7bf..b7bb5f0b3c5f 100644
--- a/arch/ppc/8xx_io/cs4218_tdm.c
+++ b/arch/ppc/8xx_io/cs4218_tdm.c
@@ -2601,7 +2601,7 @@ int __init tdm8xx_sound_init(void)
2601 /* Initialize beep stuff */ 2601 /* Initialize beep stuff */
2602 orig_mksound = kd_mksound; 2602 orig_mksound = kd_mksound;
2603 kd_mksound = cs_mksound; 2603 kd_mksound = cs_mksound;
2604 beep_buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL); 2604 beep_buf = kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL);
2605 if (beep_buf == NULL) 2605 if (beep_buf == NULL)
2606 printk(KERN_WARNING "dmasound: no memory for " 2606 printk(KERN_WARNING "dmasound: no memory for "
2607 "beep buffer\n"); 2607 "beep buffer\n");
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index ff690564edbd..12272361c018 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -407,7 +407,7 @@ config APPLDATA_BASE
407 407
408config APPLDATA_MEM 408config APPLDATA_MEM
409 tristate "Monitor memory management statistics" 409 tristate "Monitor memory management statistics"
410 depends on APPLDATA_BASE 410 depends on APPLDATA_BASE && VM_EVENT_COUNTERS
411 help 411 help
412 This provides memory management related data to the Linux - VM Monitor 412 This provides memory management related data to the Linux - VM Monitor
413 Stream, like paging/swapping rate, memory utilisation, etc. 413 Stream, like paging/swapping rate, memory utilisation, etc.
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index a6ec919ba83f..5368cf4a350e 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -1,14 +1,15 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc2 3# Linux kernel version: 2.6.20-rc1
4# Wed Oct 18 17:11:10 2006 4# Fri Dec 15 16:52:28 2006
5# 5#
6CONFIG_MMU=y 6CONFIG_MMU=y
7CONFIG_LOCKDEP_SUPPORT=y 7CONFIG_LOCKDEP_SUPPORT=y
8CONFIG_STACKTRACE_SUPPORT=y 8CONFIG_STACKTRACE_SUPPORT=y
9CONFIG_RWSEM_XCHGADD_ALGORITHM=y 9CONFIG_RWSEM_XCHGADD_ALGORITHM=y
10# CONFIG_ARCH_HAS_ILOG2_U32 is not set
11# CONFIG_ARCH_HAS_ILOG2_U64 is not set
10CONFIG_GENERIC_HWEIGHT=y 12CONFIG_GENERIC_HWEIGHT=y
11CONFIG_GENERIC_CALIBRATE_DELAY=y
12CONFIG_GENERIC_TIME=y 13CONFIG_GENERIC_TIME=y
13CONFIG_S390=y 14CONFIG_S390=y
14CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 15CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
@@ -37,12 +38,13 @@ CONFIG_AUDIT=y
37CONFIG_IKCONFIG=y 38CONFIG_IKCONFIG=y
38CONFIG_IKCONFIG_PROC=y 39CONFIG_IKCONFIG_PROC=y
39# CONFIG_CPUSETS is not set 40# CONFIG_CPUSETS is not set
41CONFIG_SYSFS_DEPRECATED=y
40# CONFIG_RELAY is not set 42# CONFIG_RELAY is not set
41CONFIG_INITRAMFS_SOURCE="" 43CONFIG_INITRAMFS_SOURCE=""
42# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 44# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
43CONFIG_SYSCTL=y 45CONFIG_SYSCTL=y
44# CONFIG_EMBEDDED is not set 46# CONFIG_EMBEDDED is not set
45# CONFIG_SYSCTL_SYSCALL is not set 47CONFIG_SYSCTL_SYSCALL=y
46CONFIG_KALLSYMS=y 48CONFIG_KALLSYMS=y
47# CONFIG_KALLSYMS_ALL is not set 49# CONFIG_KALLSYMS_ALL is not set
48# CONFIG_KALLSYMS_EXTRA_PASS is not set 50# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -119,6 +121,7 @@ CONFIG_PACK_STACK=y
119CONFIG_CHECK_STACK=y 121CONFIG_CHECK_STACK=y
120CONFIG_STACK_GUARD=256 122CONFIG_STACK_GUARD=256
121# CONFIG_WARN_STACK is not set 123# CONFIG_WARN_STACK is not set
124CONFIG_ARCH_POPULATES_NODE_MAP=y
122CONFIG_SELECT_MEMORY_MODEL=y 125CONFIG_SELECT_MEMORY_MODEL=y
123CONFIG_FLATMEM_MANUAL=y 126CONFIG_FLATMEM_MANUAL=y
124# CONFIG_DISCONTIGMEM_MANUAL is not set 127# CONFIG_DISCONTIGMEM_MANUAL is not set
@@ -128,6 +131,7 @@ CONFIG_FLAT_NODE_MEM_MAP=y
128# CONFIG_SPARSEMEM_STATIC is not set 131# CONFIG_SPARSEMEM_STATIC is not set
129CONFIG_SPLIT_PTLOCK_CPUS=4 132CONFIG_SPLIT_PTLOCK_CPUS=4
130CONFIG_RESOURCES_64BIT=y 133CONFIG_RESOURCES_64BIT=y
134CONFIG_HOLES_IN_ZONE=y
131 135
132# 136#
133# I/O subsystem configuration 137# I/O subsystem configuration
@@ -196,6 +200,7 @@ CONFIG_INET_TCP_DIAG=y
196# CONFIG_TCP_CONG_ADVANCED is not set 200# CONFIG_TCP_CONG_ADVANCED is not set
197CONFIG_TCP_CONG_CUBIC=y 201CONFIG_TCP_CONG_CUBIC=y
198CONFIG_DEFAULT_TCP_CONG="cubic" 202CONFIG_DEFAULT_TCP_CONG="cubic"
203# CONFIG_TCP_MD5SIG is not set
199CONFIG_IPV6=y 204CONFIG_IPV6=y
200# CONFIG_IPV6_PRIVACY is not set 205# CONFIG_IPV6_PRIVACY is not set
201# CONFIG_IPV6_ROUTER_PREF is not set 206# CONFIG_IPV6_ROUTER_PREF is not set
@@ -211,7 +216,6 @@ CONFIG_INET6_XFRM_MODE_BEET=y
211# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 216# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
212CONFIG_IPV6_SIT=y 217CONFIG_IPV6_SIT=y
213# CONFIG_IPV6_TUNNEL is not set 218# CONFIG_IPV6_TUNNEL is not set
214# CONFIG_IPV6_SUBTREES is not set
215# CONFIG_IPV6_MULTIPLE_TABLES is not set 219# CONFIG_IPV6_MULTIPLE_TABLES is not set
216# CONFIG_NETWORK_SECMARK is not set 220# CONFIG_NETWORK_SECMARK is not set
217# CONFIG_NETFILTER is not set 221# CONFIG_NETFILTER is not set
@@ -246,6 +250,7 @@ CONFIG_IPV6_SIT=y
246# QoS and/or fair queueing 250# QoS and/or fair queueing
247# 251#
248CONFIG_NET_SCHED=y 252CONFIG_NET_SCHED=y
253CONFIG_NET_SCH_FIFO=y
249CONFIG_NET_SCH_CLK_JIFFIES=y 254CONFIG_NET_SCH_CLK_JIFFIES=y
250# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set 255# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
251# CONFIG_NET_SCH_CLK_CPU is not set 256# CONFIG_NET_SCH_CLK_CPU is not set
@@ -277,6 +282,7 @@ CONFIG_NET_CLS_ROUTE=y
277CONFIG_NET_CLS_FW=m 282CONFIG_NET_CLS_FW=m
278CONFIG_NET_CLS_U32=m 283CONFIG_NET_CLS_U32=m
279# CONFIG_CLS_U32_PERF is not set 284# CONFIG_CLS_U32_PERF is not set
285CONFIG_CLS_U32_MARK=y
280CONFIG_NET_CLS_RSVP=m 286CONFIG_NET_CLS_RSVP=m
281CONFIG_NET_CLS_RSVP6=m 287CONFIG_NET_CLS_RSVP6=m
282# CONFIG_NET_EMATCH is not set 288# CONFIG_NET_EMATCH is not set
@@ -315,6 +321,7 @@ CONFIG_SYS_HYPERVISOR=y
315# 321#
316# CONFIG_RAID_ATTRS is not set 322# CONFIG_RAID_ATTRS is not set
317CONFIG_SCSI=y 323CONFIG_SCSI=y
324# CONFIG_SCSI_TGT is not set
318CONFIG_SCSI_NETLINK=y 325CONFIG_SCSI_NETLINK=y
319CONFIG_SCSI_PROC_FS=y 326CONFIG_SCSI_PROC_FS=y
320 327
@@ -335,6 +342,7 @@ CONFIG_CHR_DEV_SG=y
335CONFIG_SCSI_MULTI_LUN=y 342CONFIG_SCSI_MULTI_LUN=y
336CONFIG_SCSI_CONSTANTS=y 343CONFIG_SCSI_CONSTANTS=y
337CONFIG_SCSI_LOGGING=y 344CONFIG_SCSI_LOGGING=y
345CONFIG_SCSI_SCAN_ASYNC=y
338 346
339# 347#
340# SCSI Transports 348# SCSI Transports
@@ -546,6 +554,7 @@ CONFIG_DNOTIFY=y
546# CONFIG_AUTOFS_FS is not set 554# CONFIG_AUTOFS_FS is not set
547# CONFIG_AUTOFS4_FS is not set 555# CONFIG_AUTOFS4_FS is not set
548# CONFIG_FUSE_FS is not set 556# CONFIG_FUSE_FS is not set
557CONFIG_GENERIC_ACL=y
549 558
550# 559#
551# CD-ROM/DVD Filesystems 560# CD-ROM/DVD Filesystems
@@ -571,7 +580,7 @@ CONFIG_TMPFS=y
571CONFIG_TMPFS_POSIX_ACL=y 580CONFIG_TMPFS_POSIX_ACL=y
572# CONFIG_HUGETLB_PAGE is not set 581# CONFIG_HUGETLB_PAGE is not set
573CONFIG_RAMFS=y 582CONFIG_RAMFS=y
574# CONFIG_CONFIGFS_FS is not set 583CONFIG_CONFIGFS_FS=m
575 584
576# 585#
577# Miscellaneous filesystems 586# Miscellaneous filesystems
@@ -616,7 +625,6 @@ CONFIG_SUNRPC=y
616# CONFIG_CODA_FS is not set 625# CONFIG_CODA_FS is not set
617# CONFIG_AFS_FS is not set 626# CONFIG_AFS_FS is not set
618# CONFIG_9P_FS is not set 627# CONFIG_9P_FS is not set
619CONFIG_GENERIC_ACL=y
620 628
621# 629#
622# Partition Types 630# Partition Types
@@ -646,6 +654,14 @@ CONFIG_MSDOS_PARTITION=y
646# CONFIG_NLS is not set 654# CONFIG_NLS is not set
647 655
648# 656#
657# Distributed Lock Manager
658#
659CONFIG_DLM=m
660CONFIG_DLM_TCP=y
661# CONFIG_DLM_SCTP is not set
662# CONFIG_DLM_DEBUG is not set
663
664#
649# Instrumentation Support 665# Instrumentation Support
650# 666#
651 667
@@ -663,6 +679,8 @@ CONFIG_TRACE_IRQFLAGS_SUPPORT=y
663CONFIG_ENABLE_MUST_CHECK=y 679CONFIG_ENABLE_MUST_CHECK=y
664CONFIG_MAGIC_SYSRQ=y 680CONFIG_MAGIC_SYSRQ=y
665# CONFIG_UNUSED_SYMBOLS is not set 681# CONFIG_UNUSED_SYMBOLS is not set
682CONFIG_DEBUG_FS=y
683CONFIG_HEADERS_CHECK=y
666CONFIG_DEBUG_KERNEL=y 684CONFIG_DEBUG_KERNEL=y
667CONFIG_LOG_BUF_SHIFT=17 685CONFIG_LOG_BUF_SHIFT=17
668# CONFIG_SCHEDSTATS is not set 686# CONFIG_SCHEDSTATS is not set
@@ -679,13 +697,11 @@ CONFIG_DEBUG_SPINLOCK_SLEEP=y
679# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 697# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
680# CONFIG_DEBUG_KOBJECT is not set 698# CONFIG_DEBUG_KOBJECT is not set
681# CONFIG_DEBUG_INFO is not set 699# CONFIG_DEBUG_INFO is not set
682CONFIG_DEBUG_FS=y
683# CONFIG_DEBUG_VM is not set 700# CONFIG_DEBUG_VM is not set
684# CONFIG_DEBUG_LIST is not set 701# CONFIG_DEBUG_LIST is not set
685# CONFIG_FRAME_POINTER is not set 702# CONFIG_FRAME_POINTER is not set
686# CONFIG_UNWIND_INFO is not set 703# CONFIG_UNWIND_INFO is not set
687CONFIG_FORCED_INLINING=y 704CONFIG_FORCED_INLINING=y
688CONFIG_HEADERS_CHECK=y
689# CONFIG_RCU_TORTURE_TEST is not set 705# CONFIG_RCU_TORTURE_TEST is not set
690# CONFIG_LKDTM is not set 706# CONFIG_LKDTM is not set
691 707
@@ -699,10 +715,11 @@ CONFIG_HEADERS_CHECK=y
699# Cryptographic options 715# Cryptographic options
700# 716#
701CONFIG_CRYPTO=y 717CONFIG_CRYPTO=y
702CONFIG_CRYPTO_ALGAPI=m 718CONFIG_CRYPTO_ALGAPI=y
703CONFIG_CRYPTO_BLKCIPHER=m 719CONFIG_CRYPTO_BLKCIPHER=y
704CONFIG_CRYPTO_MANAGER=m 720CONFIG_CRYPTO_MANAGER=y
705# CONFIG_CRYPTO_HMAC is not set 721# CONFIG_CRYPTO_HMAC is not set
722# CONFIG_CRYPTO_XCBC is not set
706# CONFIG_CRYPTO_NULL is not set 723# CONFIG_CRYPTO_NULL is not set
707# CONFIG_CRYPTO_MD4 is not set 724# CONFIG_CRYPTO_MD4 is not set
708# CONFIG_CRYPTO_MD5 is not set 725# CONFIG_CRYPTO_MD5 is not set
@@ -713,8 +730,10 @@ CONFIG_CRYPTO_MANAGER=m
713# CONFIG_CRYPTO_SHA512 is not set 730# CONFIG_CRYPTO_SHA512 is not set
714# CONFIG_CRYPTO_WP512 is not set 731# CONFIG_CRYPTO_WP512 is not set
715# CONFIG_CRYPTO_TGR192 is not set 732# CONFIG_CRYPTO_TGR192 is not set
733# CONFIG_CRYPTO_GF128MUL is not set
716CONFIG_CRYPTO_ECB=m 734CONFIG_CRYPTO_ECB=m
717CONFIG_CRYPTO_CBC=m 735CONFIG_CRYPTO_CBC=y
736# CONFIG_CRYPTO_LRW is not set
718# CONFIG_CRYPTO_DES is not set 737# CONFIG_CRYPTO_DES is not set
719# CONFIG_CRYPTO_DES_S390 is not set 738# CONFIG_CRYPTO_DES_S390 is not set
720# CONFIG_CRYPTO_BLOWFISH is not set 739# CONFIG_CRYPTO_BLOWFISH is not set
@@ -740,8 +759,10 @@ CONFIG_CRYPTO_CBC=m
740# 759#
741# Library routines 760# Library routines
742# 761#
762CONFIG_BITREVERSE=m
743# CONFIG_CRC_CCITT is not set 763# CONFIG_CRC_CCITT is not set
744# CONFIG_CRC16 is not set 764# CONFIG_CRC16 is not set
745CONFIG_CRC32=m 765CONFIG_CRC32=m
746# CONFIG_LIBCRC32C is not set 766# CONFIG_LIBCRC32C is not set
747CONFIG_PLIST=y 767CONFIG_PLIST=y
768CONFIG_IOMAP_COPY=y
diff --git a/arch/s390/hypfs/hypfs_diag.c b/arch/s390/hypfs/hypfs_diag.c
index 443fa377d9ff..2782cf9da5b4 100644
--- a/arch/s390/hypfs/hypfs_diag.c
+++ b/arch/s390/hypfs/hypfs_diag.c
@@ -379,7 +379,7 @@ static void *diag204_alloc_vbuf(int pages)
379static void *diag204_alloc_rbuf(void) 379static void *diag204_alloc_rbuf(void)
380{ 380{
381 diag204_buf = (void*)__get_free_pages(GFP_KERNEL,0); 381 diag204_buf = (void*)__get_free_pages(GFP_KERNEL,0);
382 if (diag204_buf) 382 if (!diag204_buf)
383 return ERR_PTR(-ENOMEM); 383 return ERR_PTR(-ENOMEM);
384 diag204_buf_pages = 1; 384 diag204_buf_pages = 1;
385 return diag204_buf; 385 return diag204_buf;
@@ -521,7 +521,7 @@ __init int hypfs_diag_init(void)
521 } 521 }
522 rc = diag224_get_name_table(); 522 rc = diag224_get_name_table();
523 if (rc) { 523 if (rc) {
524 diag224_delete_name_table(); 524 diag204_free_buffer();
525 printk(KERN_ERR "hypfs: could not get name table.\n"); 525 printk(KERN_ERR "hypfs: could not get name table.\n");
526 } 526 }
527 return rc; 527 return rc;
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index ef5266fbce62..bb57bc0e3fc8 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -191,13 +191,13 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
191 debug_entry_t*** areas; 191 debug_entry_t*** areas;
192 int i,j; 192 int i,j;
193 193
194 areas = (debug_entry_t ***) kmalloc(nr_areas * 194 areas = kmalloc(nr_areas *
195 sizeof(debug_entry_t**), 195 sizeof(debug_entry_t**),
196 GFP_KERNEL); 196 GFP_KERNEL);
197 if (!areas) 197 if (!areas)
198 goto fail_malloc_areas; 198 goto fail_malloc_areas;
199 for (i = 0; i < nr_areas; i++) { 199 for (i = 0; i < nr_areas; i++) {
200 areas[i] = (debug_entry_t**) kmalloc(pages_per_area * 200 areas[i] = kmalloc(pages_per_area *
201 sizeof(debug_entry_t*),GFP_KERNEL); 201 sizeof(debug_entry_t*),GFP_KERNEL);
202 if (!areas[i]) { 202 if (!areas[i]) {
203 goto fail_malloc_areas2; 203 goto fail_malloc_areas2;
@@ -242,7 +242,7 @@ debug_info_alloc(char *name, int pages_per_area, int nr_areas, int buf_size,
242 242
243 /* alloc everything */ 243 /* alloc everything */
244 244
245 rc = (debug_info_t*) kmalloc(sizeof(debug_info_t), GFP_KERNEL); 245 rc = kmalloc(sizeof(debug_info_t), GFP_KERNEL);
246 if(!rc) 246 if(!rc)
247 goto fail_malloc_rc; 247 goto fail_malloc_rc;
248 rc->active_entries = kcalloc(nr_areas, sizeof(int), GFP_KERNEL); 248 rc->active_entries = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
@@ -634,7 +634,7 @@ found:
634 rc = -ENOMEM; 634 rc = -ENOMEM;
635 goto out; 635 goto out;
636 } 636 }
637 p_info = (file_private_info_t *) kmalloc(sizeof(file_private_info_t), 637 p_info = kmalloc(sizeof(file_private_info_t),
638 GFP_KERNEL); 638 GFP_KERNEL);
639 if(!p_info){ 639 if(!p_info){
640 if(debug_info_snapshot) 640 if(debug_info_snapshot)
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index a36bea1188d9..9e9972e8a52b 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -609,42 +609,12 @@ static ssize_t on_panic_store(struct subsystem *subsys, const char *buf,
609static struct subsys_attribute on_panic_attr = 609static struct subsys_attribute on_panic_attr =
610 __ATTR(on_panic, 0644, on_panic_show, on_panic_store); 610 __ATTR(on_panic, 0644, on_panic_show, on_panic_store);
611 611
612static void print_fcp_block(struct ipl_parameter_block *fcp_block)
613{
614 printk(KERN_EMERG "wwpn: %016llx\n",
615 (unsigned long long)fcp_block->ipl_info.fcp.wwpn);
616 printk(KERN_EMERG "lun: %016llx\n",
617 (unsigned long long)fcp_block->ipl_info.fcp.lun);
618 printk(KERN_EMERG "bootprog: %lld\n",
619 (unsigned long long)fcp_block->ipl_info.fcp.bootprog);
620 printk(KERN_EMERG "br_lba: %lld\n",
621 (unsigned long long)fcp_block->ipl_info.fcp.br_lba);
622 printk(KERN_EMERG "device: %llx\n",
623 (unsigned long long)fcp_block->ipl_info.fcp.devno);
624 printk(KERN_EMERG "opt: %x\n", fcp_block->ipl_info.fcp.opt);
625}
626
627void do_reipl(void) 612void do_reipl(void)
628{ 613{
629 struct ccw_dev_id devid; 614 struct ccw_dev_id devid;
630 static char buf[100]; 615 static char buf[100];
631 char loadparm[LOADPARM_LEN + 1]; 616 char loadparm[LOADPARM_LEN + 1];
632 617
633 switch (reipl_type) {
634 case IPL_TYPE_CCW:
635 reipl_get_ascii_loadparm(loadparm);
636 printk(KERN_EMERG "reboot on ccw device: 0.0.%04x\n",
637 reipl_block_ccw->ipl_info.ccw.devno);
638 printk(KERN_EMERG "loadparm = '%s'\n", loadparm);
639 break;
640 case IPL_TYPE_FCP:
641 printk(KERN_EMERG "reboot on fcp device:\n");
642 print_fcp_block(reipl_block_fcp);
643 break;
644 default:
645 break;
646 }
647
648 switch (reipl_method) { 618 switch (reipl_method) {
649 case IPL_METHOD_CCW_CIO: 619 case IPL_METHOD_CCW_CIO:
650 devid.devno = reipl_block_ccw->ipl_info.ccw.devno; 620 devid.devno = reipl_block_ccw->ipl_info.ccw.devno;
@@ -654,6 +624,7 @@ void do_reipl(void)
654 reipl_ccw_dev(&devid); 624 reipl_ccw_dev(&devid);
655 break; 625 break;
656 case IPL_METHOD_CCW_VM: 626 case IPL_METHOD_CCW_VM:
627 reipl_get_ascii_loadparm(loadparm);
657 if (strlen(loadparm) == 0) 628 if (strlen(loadparm) == 0)
658 sprintf(buf, "IPL %X", 629 sprintf(buf, "IPL %X",
659 reipl_block_ccw->ipl_info.ccw.devno); 630 reipl_block_ccw->ipl_info.ccw.devno);
@@ -683,7 +654,6 @@ void do_reipl(void)
683 diag308(DIAG308_IPL, NULL); 654 diag308(DIAG308_IPL, NULL);
684 break; 655 break;
685 } 656 }
686 printk(KERN_EMERG "reboot failed!\n");
687 signal_processor(smp_processor_id(), sigp_stop_and_store_status); 657 signal_processor(smp_processor_id(), sigp_stop_and_store_status);
688} 658}
689 659
@@ -692,19 +662,6 @@ static void do_dump(void)
692 struct ccw_dev_id devid; 662 struct ccw_dev_id devid;
693 static char buf[100]; 663 static char buf[100];
694 664
695 switch (dump_type) {
696 case IPL_TYPE_CCW:
697 printk(KERN_EMERG "Automatic dump on ccw device: 0.0.%04x\n",
698 dump_block_ccw->ipl_info.ccw.devno);
699 break;
700 case IPL_TYPE_FCP:
701 printk(KERN_EMERG "Automatic dump on fcp device:\n");
702 print_fcp_block(dump_block_fcp);
703 break;
704 default:
705 return;
706 }
707
708 switch (dump_method) { 665 switch (dump_method) {
709 case IPL_METHOD_CCW_CIO: 666 case IPL_METHOD_CCW_CIO:
710 smp_send_stop(); 667 smp_send_stop();
@@ -1037,15 +994,21 @@ static void do_reset_calls(void)
1037} 994}
1038 995
1039extern void reset_mcck_handler(void); 996extern void reset_mcck_handler(void);
997extern void reset_pgm_handler(void);
998extern __u32 dump_prefix_page;
1040 999
1041void s390_reset_system(void) 1000void s390_reset_system(void)
1042{ 1001{
1043 struct _lowcore *lc; 1002 struct _lowcore *lc;
1044 1003
1045 /* Stack for interrupt/machine check handler */
1046 lc = (struct _lowcore *)(unsigned long) store_prefix(); 1004 lc = (struct _lowcore *)(unsigned long) store_prefix();
1005
1006 /* Stack for interrupt/machine check handler */
1047 lc->panic_stack = S390_lowcore.panic_stack; 1007 lc->panic_stack = S390_lowcore.panic_stack;
1048 1008
1009 /* Save prefix page address for dump case */
1010 dump_prefix_page = (unsigned long) lc;
1011
1049 /* Disable prefixing */ 1012 /* Disable prefixing */
1050 set_prefix(0); 1013 set_prefix(0);
1051 1014
@@ -1056,5 +1019,11 @@ void s390_reset_system(void)
1056 S390_lowcore.mcck_new_psw.mask = PSW_KERNEL_BITS & ~PSW_MASK_MCHECK; 1019 S390_lowcore.mcck_new_psw.mask = PSW_KERNEL_BITS & ~PSW_MASK_MCHECK;
1057 S390_lowcore.mcck_new_psw.addr = 1020 S390_lowcore.mcck_new_psw.addr =
1058 PSW_ADDR_AMODE | (unsigned long) &reset_mcck_handler; 1021 PSW_ADDR_AMODE | (unsigned long) &reset_mcck_handler;
1022
1023 /* Set new program check handler */
1024 S390_lowcore.program_new_psw.mask = PSW_KERNEL_BITS & ~PSW_MASK_MCHECK;
1025 S390_lowcore.program_new_psw.addr =
1026 PSW_ADDR_AMODE | (unsigned long) &reset_pgm_handler;
1027
1059 do_reset_calls(); 1028 do_reset_calls();
1060} 1029}
diff --git a/arch/s390/kernel/reipl.S b/arch/s390/kernel/reipl.S
index f9434d42ce9f..c3f4d9b95083 100644
--- a/arch/s390/kernel/reipl.S
+++ b/arch/s390/kernel/reipl.S
@@ -16,7 +16,7 @@ do_reipl_asm: basr %r13,0
16 stm %r0,%r15,__LC_GPREGS_SAVE_AREA 16 stm %r0,%r15,__LC_GPREGS_SAVE_AREA
17 stctl %c0,%c15,__LC_CREGS_SAVE_AREA 17 stctl %c0,%c15,__LC_CREGS_SAVE_AREA
18 stam %a0,%a15,__LC_AREGS_SAVE_AREA 18 stam %a0,%a15,__LC_AREGS_SAVE_AREA
19 stpx __LC_PREFIX_SAVE_AREA 19 mvc __LC_PREFIX_SAVE_AREA(4),dump_prefix_page-.Lpg0(%r13)
20 stckc .Lclkcmp-.Lpg0(%r13) 20 stckc .Lclkcmp-.Lpg0(%r13)
21 mvc __LC_CLOCK_COMP_SAVE_AREA(8),.Lclkcmp-.Lpg0(%r13) 21 mvc __LC_CLOCK_COMP_SAVE_AREA(8),.Lclkcmp-.Lpg0(%r13)
22 stpt __LC_CPU_TIMER_SAVE_AREA 22 stpt __LC_CPU_TIMER_SAVE_AREA
@@ -79,3 +79,7 @@ do_reipl_asm: basr %r13,0
79 .long 0x00000000,0x00000000 79 .long 0x00000000,0x00000000
80 .long 0x00000000,0x00000000 80 .long 0x00000000,0x00000000
81 .long 0x00000000,0x00000000 81 .long 0x00000000,0x00000000
82 .globl dump_prefix_page
83dump_prefix_page:
84 .long 0x00000000
85
diff --git a/arch/s390/kernel/reipl64.S b/arch/s390/kernel/reipl64.S
index f18ef260ca23..dbb3eed38865 100644
--- a/arch/s390/kernel/reipl64.S
+++ b/arch/s390/kernel/reipl64.S
@@ -20,7 +20,7 @@ do_reipl_asm: basr %r13,0
20 stg %r0,__LC_GPREGS_SAVE_AREA-0x1000+8(%r1) 20 stg %r0,__LC_GPREGS_SAVE_AREA-0x1000+8(%r1)
21 stctg %c0,%c15,__LC_CREGS_SAVE_AREA-0x1000(%r1) 21 stctg %c0,%c15,__LC_CREGS_SAVE_AREA-0x1000(%r1)
22 stam %a0,%a15,__LC_AREGS_SAVE_AREA-0x1000(%r1) 22 stam %a0,%a15,__LC_AREGS_SAVE_AREA-0x1000(%r1)
23 stpx __LC_PREFIX_SAVE_AREA-0x1000(%r1) 23 mvc __LC_PREFIX_SAVE_AREA-0x1000(4,%r1),dump_prefix_page-.Lpg0(%r13)
24 stfpc __LC_FP_CREG_SAVE_AREA-0x1000(%r1) 24 stfpc __LC_FP_CREG_SAVE_AREA-0x1000(%r1)
25 stckc .Lclkcmp-.Lpg0(%r13) 25 stckc .Lclkcmp-.Lpg0(%r13)
26 mvc __LC_CLOCK_COMP_SAVE_AREA-0x1000(8,%r1),.Lclkcmp-.Lpg0(%r13) 26 mvc __LC_CLOCK_COMP_SAVE_AREA-0x1000(8,%r1),.Lclkcmp-.Lpg0(%r13)
@@ -103,3 +103,6 @@ do_reipl_asm: basr %r13,0
103 .long 0x00000000,0x00000000 103 .long 0x00000000,0x00000000
104 .long 0x00000000,0x00000000 104 .long 0x00000000,0x00000000
105 .long 0x00000000,0x00000000 105 .long 0x00000000,0x00000000
106 .globl dump_prefix_page
107dump_prefix_page:
108 .long 0x00000000
diff --git a/arch/s390/kernel/reset.S b/arch/s390/kernel/reset.S
index be8688c0665c..8a87355161fa 100644
--- a/arch/s390/kernel/reset.S
+++ b/arch/s390/kernel/reset.S
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) IBM Corp. 2006 4 * Copyright (C) IBM Corp. 2006
5 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> 5 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
6 * Michael Holzheu <holzheu@de.ibm.com>
6 */ 7 */
7 8
8#include <asm/ptrace.h> 9#include <asm/ptrace.h>
@@ -27,6 +28,26 @@ reset_mcck_handler:
27s390_reset_mcck_handler: 28s390_reset_mcck_handler:
28 .quad 0 29 .quad 0
29 30
31 .globl reset_pgm_handler
32reset_pgm_handler:
33 stmg %r0,%r15,__LC_SAVE_AREA
34 basr %r13,0
350: lg %r15,__LC_PANIC_STACK # load panic stack
36 aghi %r15,-STACK_FRAME_OVERHEAD
37 lg %r1,s390_reset_pgm_handler-0b(%r13)
38 ltgr %r1,%r1
39 jz 1f
40 basr %r14,%r1
41 lmg %r0,%r15,__LC_SAVE_AREA
42 lpswe __LC_PGM_OLD_PSW
431: lpswe disabled_wait_psw-0b(%r13)
44 .globl s390_reset_pgm_handler
45s390_reset_pgm_handler:
46 .quad 0
47 .align 8
48disabled_wait_psw:
49 .quad 0x0002000180000000,0x0000000000000000 + reset_pgm_handler
50
30#else /* CONFIG_64BIT */ 51#else /* CONFIG_64BIT */
31 52
32 .globl reset_mcck_handler 53 .globl reset_mcck_handler
@@ -45,4 +66,25 @@ reset_mcck_handler:
45s390_reset_mcck_handler: 66s390_reset_mcck_handler:
46 .long 0 67 .long 0
47 68
69 .globl reset_pgm_handler
70reset_pgm_handler:
71 stm %r0,%r15,__LC_SAVE_AREA
72 basr %r13,0
730: l %r15,__LC_PANIC_STACK # load panic stack
74 ahi %r15,-STACK_FRAME_OVERHEAD
75 l %r1,s390_reset_pgm_handler-0b(%r13)
76 ltr %r1,%r1
77 jz 1f
78 basr %r14,%r1
79 lm %r0,%r15,__LC_SAVE_AREA
80 lpsw __LC_PGM_OLD_PSW
81
821: lpsw disabled_wait_psw-0b(%r13)
83 .globl s390_reset_pgm_handler
84s390_reset_pgm_handler:
85 .long 0
86disabled_wait_psw:
87 .align 8
88 .long 0x000a0000,0x00000000 + reset_pgm_handler
89
48#endif /* CONFIG_64BIT */ 90#endif /* CONFIG_64BIT */
diff --git a/arch/s390/kernel/s390_ext.c b/arch/s390/kernel/s390_ext.c
index 4faf96f8a834..bc5beaa8f98e 100644
--- a/arch/s390/kernel/s390_ext.c
+++ b/arch/s390/kernel/s390_ext.c
@@ -37,7 +37,7 @@ int register_external_interrupt(__u16 code, ext_int_handler_t handler)
37 ext_int_info_t *p; 37 ext_int_info_t *p;
38 int index; 38 int index;
39 39
40 p = (ext_int_info_t *) kmalloc(sizeof(ext_int_info_t), GFP_ATOMIC); 40 p = kmalloc(sizeof(ext_int_info_t), GFP_ATOMIC);
41 if (p == NULL) 41 if (p == NULL)
42 return -ENOMEM; 42 return -ENOMEM;
43 p->code = code; 43 p->code = code;
diff --git a/arch/sparc/defconfig b/arch/sparc/defconfig
index a69856263009..79e54894529d 100644
--- a/arch/sparc/defconfig
+++ b/arch/sparc/defconfig
@@ -1,41 +1,59 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.20-rc1
4# Sun Dec 17 14:20:47 2006
3# 5#
4CONFIG_MMU=y 6CONFIG_MMU=y
5CONFIG_UID16=y
6CONFIG_HIGHMEM=y 7CONFIG_HIGHMEM=y
7CONFIG_GENERIC_ISA_DMA=y 8CONFIG_GENERIC_ISA_DMA=y
9CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
8 10
9# 11#
10# Code maturity level options 12# Code maturity level options
11# 13#
12CONFIG_EXPERIMENTAL=y 14CONFIG_EXPERIMENTAL=y
13CONFIG_CLEAN_COMPILE=y
14CONFIG_STANDALONE=y
15CONFIG_BROKEN_ON_SMP=y 15CONFIG_BROKEN_ON_SMP=y
16CONFIG_INIT_ENV_ARG_LIMIT=32
16 17
17# 18#
18# General setup 19# General setup
19# 20#
21CONFIG_LOCALVERSION=""
22CONFIG_LOCALVERSION_AUTO=y
20CONFIG_SWAP=y 23CONFIG_SWAP=y
21CONFIG_SYSVIPC=y 24CONFIG_SYSVIPC=y
25# CONFIG_IPC_NS is not set
22CONFIG_POSIX_MQUEUE=y 26CONFIG_POSIX_MQUEUE=y
23# CONFIG_BSD_PROCESS_ACCT is not set 27# CONFIG_BSD_PROCESS_ACCT is not set
24CONFIG_SYSCTL=y 28# CONFIG_TASKSTATS is not set
29# CONFIG_UTS_NS is not set
25# CONFIG_AUDIT is not set 30# CONFIG_AUDIT is not set
26CONFIG_LOG_BUF_SHIFT=14
27# CONFIG_HOTPLUG is not set
28# CONFIG_IKCONFIG is not set 31# CONFIG_IKCONFIG is not set
32CONFIG_SYSFS_DEPRECATED=y
33# CONFIG_RELAY is not set
34CONFIG_INITRAMFS_SOURCE=""
35# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
36CONFIG_SYSCTL=y
29# CONFIG_EMBEDDED is not set 37# CONFIG_EMBEDDED is not set
38CONFIG_UID16=y
39CONFIG_SYSCTL_SYSCALL=y
30CONFIG_KALLSYMS=y 40CONFIG_KALLSYMS=y
31# CONFIG_KALLSYMS_ALL is not set 41# CONFIG_KALLSYMS_ALL is not set
42# CONFIG_KALLSYMS_EXTRA_PASS is not set
43CONFIG_HOTPLUG=y
44CONFIG_PRINTK=y
45CONFIG_BUG=y
46CONFIG_ELF_CORE=y
47CONFIG_BASE_FULL=y
32CONFIG_FUTEX=y 48CONFIG_FUTEX=y
33CONFIG_EPOLL=y 49CONFIG_EPOLL=y
34CONFIG_IOSCHED_NOOP=y 50CONFIG_SHMEM=y
35CONFIG_IOSCHED_AS=y 51CONFIG_SLAB=y
36CONFIG_IOSCHED_DEADLINE=y 52CONFIG_VM_EVENT_COUNTERS=y
37CONFIG_IOSCHED_CFQ=y 53CONFIG_RT_MUTEXES=y
38# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 54# CONFIG_TINY_SHMEM is not set
55CONFIG_BASE_SMALL=0
56# CONFIG_SLOB is not set
39 57
40# 58#
41# Loadable module support 59# Loadable module support
@@ -43,17 +61,36 @@ CONFIG_IOSCHED_CFQ=y
43CONFIG_MODULES=y 61CONFIG_MODULES=y
44CONFIG_MODULE_UNLOAD=y 62CONFIG_MODULE_UNLOAD=y
45# CONFIG_MODULE_FORCE_UNLOAD is not set 63# CONFIG_MODULE_FORCE_UNLOAD is not set
46CONFIG_OBSOLETE_MODPARM=y
47# CONFIG_MODVERSIONS is not set 64# CONFIG_MODVERSIONS is not set
65# CONFIG_MODULE_SRCVERSION_ALL is not set
48CONFIG_KMOD=y 66CONFIG_KMOD=y
49 67
50# 68#
51# General setup 69# Block layer
70#
71CONFIG_BLOCK=y
72# CONFIG_LBD is not set
73# CONFIG_BLK_DEV_IO_TRACE is not set
74# CONFIG_LSF is not set
75
76#
77# IO Schedulers
78#
79CONFIG_IOSCHED_NOOP=y
80CONFIG_IOSCHED_AS=y
81CONFIG_IOSCHED_DEADLINE=y
82CONFIG_IOSCHED_CFQ=y
83# CONFIG_DEFAULT_AS is not set
84# CONFIG_DEFAULT_DEADLINE is not set
85CONFIG_DEFAULT_CFQ=y
86# CONFIG_DEFAULT_NOOP is not set
87CONFIG_DEFAULT_IOSCHED="cfq"
88
89#
90# General machine setup
52# 91#
53CONFIG_VT=y
54CONFIG_VT_CONSOLE=y
55CONFIG_HW_CONSOLE=y
56# CONFIG_SMP is not set 92# CONFIG_SMP is not set
93CONFIG_SPARC=y
57CONFIG_SPARC32=y 94CONFIG_SPARC32=y
58CONFIG_SBUS=y 95CONFIG_SBUS=y
59CONFIG_SBUSCHAR=y 96CONFIG_SBUSCHAR=y
@@ -61,73 +98,170 @@ CONFIG_SERIAL_CONSOLE=y
61CONFIG_SUN_AUXIO=y 98CONFIG_SUN_AUXIO=y
62CONFIG_SUN_IO=y 99CONFIG_SUN_IO=y
63CONFIG_RWSEM_GENERIC_SPINLOCK=y 100CONFIG_RWSEM_GENERIC_SPINLOCK=y
101CONFIG_GENERIC_FIND_NEXT_BIT=y
102CONFIG_GENERIC_HWEIGHT=y
103CONFIG_GENERIC_CALIBRATE_DELAY=y
104CONFIG_ARCH_MAY_HAVE_PC_FDC=y
105# CONFIG_ARCH_HAS_ILOG2_U32 is not set
106# CONFIG_ARCH_HAS_ILOG2_U64 is not set
64CONFIG_SUN_PM=y 107CONFIG_SUN_PM=y
65# CONFIG_SUN4 is not set 108# CONFIG_SUN4 is not set
66CONFIG_PCI=y 109CONFIG_PCI=y
67# CONFIG_PCI_LEGACY_PROC is not set 110# CONFIG_PCI_MULTITHREAD_PROBE is not set
68# CONFIG_PCI_NAMES is not set 111# CONFIG_PCI_DEBUG is not set
69CONFIG_SUN_OPENPROMFS=m 112CONFIG_SUN_OPENPROMFS=m
113# CONFIG_SPARC_LED is not set
70CONFIG_BINFMT_ELF=y 114CONFIG_BINFMT_ELF=y
71CONFIG_BINFMT_AOUT=y 115CONFIG_BINFMT_AOUT=y
72CONFIG_BINFMT_MISC=m 116CONFIG_BINFMT_MISC=m
73CONFIG_SUNOS_EMUL=y 117CONFIG_SUNOS_EMUL=y
118CONFIG_SELECT_MEMORY_MODEL=y
119CONFIG_FLATMEM_MANUAL=y
120# CONFIG_DISCONTIGMEM_MANUAL is not set
121# CONFIG_SPARSEMEM_MANUAL is not set
122CONFIG_FLATMEM=y
123CONFIG_FLAT_NODE_MEM_MAP=y
124# CONFIG_SPARSEMEM_STATIC is not set
125CONFIG_SPLIT_PTLOCK_CPUS=4
126# CONFIG_RESOURCES_64BIT is not set
74 127
75# 128#
76# Parallel port support 129# Networking
77# 130#
78# CONFIG_PARPORT is not set 131CONFIG_NET=y
79 132
80# 133#
81# Generic Driver Options 134# Networking options
82# 135#
83# CONFIG_DEBUG_DRIVER is not set 136# CONFIG_NETDEBUG is not set
137CONFIG_PACKET=y
138# CONFIG_PACKET_MMAP is not set
139CONFIG_UNIX=y
140CONFIG_XFRM=y
141CONFIG_XFRM_USER=m
142# CONFIG_XFRM_SUB_POLICY is not set
143CONFIG_NET_KEY=m
144CONFIG_INET=y
145# CONFIG_IP_MULTICAST is not set
146# CONFIG_IP_ADVANCED_ROUTER is not set
147CONFIG_IP_FIB_HASH=y
148CONFIG_IP_PNP=y
149CONFIG_IP_PNP_DHCP=y
150# CONFIG_IP_PNP_BOOTP is not set
151# CONFIG_IP_PNP_RARP is not set
152# CONFIG_NET_IPIP is not set
153# CONFIG_NET_IPGRE is not set
154# CONFIG_ARPD is not set
155# CONFIG_SYN_COOKIES is not set
156CONFIG_INET_AH=y
157CONFIG_INET_ESP=y
158CONFIG_INET_IPCOMP=y
159CONFIG_INET_XFRM_TUNNEL=y
160CONFIG_INET_TUNNEL=y
161CONFIG_INET_XFRM_MODE_TRANSPORT=y
162CONFIG_INET_XFRM_MODE_TUNNEL=y
163CONFIG_INET_XFRM_MODE_BEET=y
164CONFIG_INET_DIAG=y
165CONFIG_INET_TCP_DIAG=y
166# CONFIG_TCP_CONG_ADVANCED is not set
167CONFIG_TCP_CONG_CUBIC=y
168CONFIG_DEFAULT_TCP_CONG="cubic"
169# CONFIG_TCP_MD5SIG is not set
170CONFIG_IPV6=m
171CONFIG_IPV6_PRIVACY=y
172# CONFIG_IPV6_ROUTER_PREF is not set
173CONFIG_INET6_AH=m
174CONFIG_INET6_ESP=m
175CONFIG_INET6_IPCOMP=m
176# CONFIG_IPV6_MIP6 is not set
177CONFIG_INET6_XFRM_TUNNEL=m
178CONFIG_INET6_TUNNEL=m
179CONFIG_INET6_XFRM_MODE_TRANSPORT=m
180CONFIG_INET6_XFRM_MODE_TUNNEL=m
181CONFIG_INET6_XFRM_MODE_BEET=m
182# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
183CONFIG_IPV6_SIT=m
184CONFIG_IPV6_TUNNEL=m
185# CONFIG_IPV6_MULTIPLE_TABLES is not set
186# CONFIG_NETWORK_SECMARK is not set
187# CONFIG_NETFILTER is not set
84 188
85# 189#
86# Graphics support 190# DCCP Configuration (EXPERIMENTAL)
87# 191#
88# CONFIG_FB is not set 192# CONFIG_IP_DCCP is not set
89 193
90# 194#
91# Console display driver support 195# SCTP Configuration (EXPERIMENTAL)
92# 196#
93# CONFIG_MDA_CONSOLE is not set 197CONFIG_IP_SCTP=m
94# CONFIG_PROM_CONSOLE is not set 198# CONFIG_SCTP_DBG_MSG is not set
95CONFIG_DUMMY_CONSOLE=y 199CONFIG_SCTP_DBG_OBJCNT=y
200# CONFIG_SCTP_HMAC_NONE is not set
201# CONFIG_SCTP_HMAC_SHA1 is not set
202CONFIG_SCTP_HMAC_MD5=y
96 203
97# 204#
98# Memory Technology Devices (MTD) 205# TIPC Configuration (EXPERIMENTAL)
99# 206#
100# CONFIG_MTD is not set 207# CONFIG_TIPC is not set
208# CONFIG_ATM is not set
209# CONFIG_BRIDGE is not set
210# CONFIG_VLAN_8021Q is not set
211# CONFIG_DECNET is not set
212# CONFIG_LLC2 is not set
213# CONFIG_IPX is not set
214# CONFIG_ATALK is not set
215# CONFIG_X25 is not set
216# CONFIG_LAPB is not set
217# CONFIG_ECONET is not set
218# CONFIG_WAN_ROUTER is not set
101 219
102# 220#
103# Serial drivers 221# QoS and/or fair queueing
104# 222#
105# CONFIG_SERIAL_8250 is not set 223# CONFIG_NET_SCHED is not set
106 224
107# 225#
108# Non-8250 serial port support 226# Network testing
109# 227#
110CONFIG_SERIAL_SUNCORE=y 228CONFIG_NET_PKTGEN=m
111CONFIG_SERIAL_SUNZILOG=y 229# CONFIG_HAMRADIO is not set
112CONFIG_SERIAL_SUNZILOG_CONSOLE=y 230# CONFIG_IRDA is not set
113CONFIG_SERIAL_SUNSU=y 231# CONFIG_BT is not set
114CONFIG_SERIAL_SUNSU_CONSOLE=y 232# CONFIG_IEEE80211 is not set
115# CONFIG_SERIAL_SUNSAB is not set
116CONFIG_SERIAL_CORE=y
117CONFIG_SERIAL_CORE_CONSOLE=y
118 233
119# 234#
120# Misc Linux/SPARC drivers 235# Device Drivers
236#
237
238#
239# Generic Driver Options
240#
241CONFIG_STANDALONE=y
242CONFIG_PREVENT_FIRMWARE_BUILD=y
243# CONFIG_FW_LOADER is not set
244# CONFIG_DEBUG_DRIVER is not set
245# CONFIG_SYS_HYPERVISOR is not set
246
247#
248# Connector - unified userspace <-> kernelspace linker
249#
250# CONFIG_CONNECTOR is not set
251
252#
253# Memory Technology Devices (MTD)
254#
255# CONFIG_MTD is not set
256
257#
258# Parallel port support
259#
260# CONFIG_PARPORT is not set
261
262#
263# Plug and Play support
121# 264#
122CONFIG_SUN_OPENPROMIO=m
123CONFIG_SUN_MOSTEK_RTC=m
124# CONFIG_SUN_BPP is not set
125# CONFIG_SUN_VIDEOPIX is not set
126# CONFIG_SUN_AURORA is not set
127# CONFIG_TADPOLE_TS102_UCTRL is not set
128# CONFIG_SUN_JSFLASH is not set
129CONFIG_APM_RTC_IS_GMT=y
130CONFIG_RTC=m
131 265
132# 266#
133# Block devices 267# Block devices
@@ -137,28 +271,37 @@ CONFIG_RTC=m
137# CONFIG_BLK_CPQ_CISS_DA is not set 271# CONFIG_BLK_CPQ_CISS_DA is not set
138# CONFIG_BLK_DEV_DAC960 is not set 272# CONFIG_BLK_DEV_DAC960 is not set
139# CONFIG_BLK_DEV_UMEM is not set 273# CONFIG_BLK_DEV_UMEM is not set
274# CONFIG_BLK_DEV_COW_COMMON is not set
140CONFIG_BLK_DEV_LOOP=m 275CONFIG_BLK_DEV_LOOP=m
141CONFIG_BLK_DEV_CRYPTOLOOP=m 276CONFIG_BLK_DEV_CRYPTOLOOP=m
142# CONFIG_BLK_DEV_NBD is not set 277# CONFIG_BLK_DEV_NBD is not set
143# CONFIG_BLK_DEV_CARMEL is not set 278# CONFIG_BLK_DEV_SX8 is not set
144CONFIG_BLK_DEV_RAM=y 279CONFIG_BLK_DEV_RAM=y
280CONFIG_BLK_DEV_RAM_COUNT=16
145CONFIG_BLK_DEV_RAM_SIZE=4096 281CONFIG_BLK_DEV_RAM_SIZE=4096
282CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
146CONFIG_BLK_DEV_INITRD=y 283CONFIG_BLK_DEV_INITRD=y
284# CONFIG_CDROM_PKTCDVD is not set
285# CONFIG_ATA_OVER_ETH is not set
147 286
148# 287#
149# ATA/ATAPI/MFM/RLL support 288# Misc devices
150# 289#
151# CONFIG_IDE is not set 290# CONFIG_SGI_IOC4 is not set
291# CONFIG_TIFM_CORE is not set
152 292
153# 293#
154# ISDN subsystem 294# ATA/ATAPI/MFM/RLL support
155# 295#
156# CONFIG_ISDN is not set 296# CONFIG_IDE is not set
157 297
158# 298#
159# SCSI device support 299# SCSI device support
160# 300#
301# CONFIG_RAID_ATTRS is not set
161CONFIG_SCSI=y 302CONFIG_SCSI=y
303# CONFIG_SCSI_TGT is not set
304# CONFIG_SCSI_NETLINK is not set
162CONFIG_SCSI_PROC_FS=y 305CONFIG_SCSI_PROC_FS=y
163 306
164# 307#
@@ -170,6 +313,7 @@ CONFIG_BLK_DEV_SD=y
170CONFIG_BLK_DEV_SR=m 313CONFIG_BLK_DEV_SR=m
171# CONFIG_BLK_DEV_SR_VENDOR is not set 314# CONFIG_BLK_DEV_SR_VENDOR is not set
172CONFIG_CHR_DEV_SG=m 315CONFIG_CHR_DEV_SG=m
316# CONFIG_CHR_DEV_SCH is not set
173 317
174# 318#
175# Some SCSI devices (e.g. CD jukebox) support multiple LUNs 319# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
@@ -177,57 +321,58 @@ CONFIG_CHR_DEV_SG=m
177# CONFIG_SCSI_MULTI_LUN is not set 321# CONFIG_SCSI_MULTI_LUN is not set
178# CONFIG_SCSI_CONSTANTS is not set 322# CONFIG_SCSI_CONSTANTS is not set
179# CONFIG_SCSI_LOGGING is not set 323# CONFIG_SCSI_LOGGING is not set
324# CONFIG_SCSI_SCAN_ASYNC is not set
180 325
181# 326#
182# SCSI Transport Attributes 327# SCSI Transports
183# 328#
184CONFIG_SCSI_SPI_ATTRS=m 329CONFIG_SCSI_SPI_ATTRS=m
185# CONFIG_SCSI_FC_ATTRS is not set 330# CONFIG_SCSI_FC_ATTRS is not set
331# CONFIG_SCSI_ISCSI_ATTRS is not set
332# CONFIG_SCSI_SAS_ATTRS is not set
333# CONFIG_SCSI_SAS_LIBSAS is not set
186 334
187# 335#
188# SCSI low-level drivers 336# SCSI low-level drivers
189# 337#
338# CONFIG_ISCSI_TCP is not set
190# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 339# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
340# CONFIG_SCSI_3W_9XXX is not set
191# CONFIG_SCSI_ACARD is not set 341# CONFIG_SCSI_ACARD is not set
192# CONFIG_SCSI_AACRAID is not set 342# CONFIG_SCSI_AACRAID is not set
193# CONFIG_SCSI_AIC7XXX is not set 343# CONFIG_SCSI_AIC7XXX is not set
194# CONFIG_SCSI_AIC7XXX_OLD is not set 344# CONFIG_SCSI_AIC7XXX_OLD is not set
195# CONFIG_SCSI_AIC79XX is not set 345# CONFIG_SCSI_AIC79XX is not set
346# CONFIG_SCSI_AIC94XX is not set
196# CONFIG_SCSI_DPT_I2O is not set 347# CONFIG_SCSI_DPT_I2O is not set
197# CONFIG_SCSI_ADVANSYS is not set 348# CONFIG_SCSI_ARCMSR is not set
198# CONFIG_SCSI_MEGARAID is not set 349# CONFIG_MEGARAID_NEWGEN is not set
199# CONFIG_SCSI_SATA is not set 350# CONFIG_MEGARAID_LEGACY is not set
200# CONFIG_SCSI_BUSLOGIC is not set 351# CONFIG_MEGARAID_SAS is not set
352# CONFIG_SCSI_HPTIOP is not set
201# CONFIG_SCSI_DMX3191D is not set 353# CONFIG_SCSI_DMX3191D is not set
202# CONFIG_SCSI_EATA is not set
203# CONFIG_SCSI_EATA_PIO is not set
204# CONFIG_SCSI_FUTURE_DOMAIN is not set 354# CONFIG_SCSI_FUTURE_DOMAIN is not set
205# CONFIG_SCSI_GDTH is not set
206# CONFIG_SCSI_IPS is not set 355# CONFIG_SCSI_IPS is not set
356# CONFIG_SCSI_INITIO is not set
207# CONFIG_SCSI_INIA100 is not set 357# CONFIG_SCSI_INIA100 is not set
358# CONFIG_SCSI_STEX is not set
208# CONFIG_SCSI_SYM53C8XX_2 is not set 359# CONFIG_SCSI_SYM53C8XX_2 is not set
209# CONFIG_SCSI_IPR is not set
210# CONFIG_SCSI_QLOGIC_ISP is not set
211# CONFIG_SCSI_QLOGIC_FC is not set
212# CONFIG_SCSI_QLOGIC_1280 is not set 360# CONFIG_SCSI_QLOGIC_1280 is not set
213CONFIG_SCSI_QLOGICPTI=m 361CONFIG_SCSI_QLOGICPTI=m
214CONFIG_SCSI_QLA2XXX=y 362# CONFIG_SCSI_QLA_FC is not set
215# CONFIG_SCSI_QLA21XX is not set 363# CONFIG_SCSI_QLA_ISCSI is not set
216# CONFIG_SCSI_QLA22XX is not set 364# CONFIG_SCSI_LPFC is not set
217# CONFIG_SCSI_QLA2300 is not set
218# CONFIG_SCSI_QLA2322 is not set
219# CONFIG_SCSI_QLA6312 is not set
220# CONFIG_SCSI_QLA6322 is not set
221# CONFIG_SCSI_DC395x is not set 365# CONFIG_SCSI_DC395x is not set
222# CONFIG_SCSI_DC390T is not set 366# CONFIG_SCSI_DC390T is not set
223# CONFIG_SCSI_NSP32 is not set 367# CONFIG_SCSI_NSP32 is not set
224# CONFIG_SCSI_DEBUG is not set 368# CONFIG_SCSI_DEBUG is not set
225CONFIG_SCSI_SUNESP=y 369CONFIG_SCSI_SUNESP=y
370# CONFIG_SCSI_SRP is not set
226 371
227# 372#
228# Fibre Channel support 373# Serial ATA (prod) and Parallel ATA (experimental) drivers
229# 374#
230# CONFIG_FC4 is not set 375# CONFIG_ATA is not set
231 376
232# 377#
233# Multi-device support (RAID and LVM) 378# Multi-device support (RAID and LVM)
@@ -235,85 +380,31 @@ CONFIG_SCSI_SUNESP=y
235# CONFIG_MD is not set 380# CONFIG_MD is not set
236 381
237# 382#
238# Networking support 383# Fusion MPT device support
239#
240CONFIG_NET=y
241
242#
243# Networking options
244# 384#
245CONFIG_PACKET=y 385# CONFIG_FUSION is not set
246# CONFIG_PACKET_MMAP is not set 386# CONFIG_FUSION_SPI is not set
247CONFIG_NETLINK_DEV=y 387# CONFIG_FUSION_FC is not set
248CONFIG_UNIX=y 388# CONFIG_FUSION_SAS is not set
249CONFIG_NET_KEY=m
250CONFIG_INET=y
251# CONFIG_IP_MULTICAST is not set
252# CONFIG_IP_ADVANCED_ROUTER is not set
253CONFIG_IP_PNP=y
254CONFIG_IP_PNP_DHCP=y
255# CONFIG_IP_PNP_BOOTP is not set
256# CONFIG_IP_PNP_RARP is not set
257# CONFIG_NET_IPIP is not set
258# CONFIG_NET_IPGRE is not set
259# CONFIG_ARPD is not set
260# CONFIG_SYN_COOKIES is not set
261CONFIG_INET_AH=y
262CONFIG_INET_ESP=y
263CONFIG_INET_IPCOMP=y
264CONFIG_IPV6=m
265CONFIG_IPV6_PRIVACY=y
266CONFIG_INET6_AH=m
267CONFIG_INET6_ESP=m
268CONFIG_INET6_IPCOMP=m
269CONFIG_IPV6_TUNNEL=m
270# CONFIG_NETFILTER is not set
271CONFIG_XFRM=y
272CONFIG_XFRM_USER=m
273 389
274# 390#
275# SCTP Configuration (EXPERIMENTAL) 391# IEEE 1394 (FireWire) support
276# 392#
277CONFIG_IP_SCTP=m 393# CONFIG_IEEE1394 is not set
278# CONFIG_SCTP_DBG_MSG is not set
279CONFIG_SCTP_DBG_OBJCNT=y
280# CONFIG_SCTP_HMAC_NONE is not set
281# CONFIG_SCTP_HMAC_SHA1 is not set
282CONFIG_SCTP_HMAC_MD5=y
283# CONFIG_ATM is not set
284# CONFIG_BRIDGE is not set
285# CONFIG_VLAN_8021Q is not set
286# CONFIG_DECNET is not set
287# CONFIG_LLC2 is not set
288# CONFIG_IPX is not set
289# CONFIG_ATALK is not set
290# CONFIG_X25 is not set
291# CONFIG_LAPB is not set
292# CONFIG_NET_DIVERT is not set
293# CONFIG_ECONET is not set
294# CONFIG_WAN_ROUTER is not set
295# CONFIG_NET_HW_FLOWCONTROL is not set
296 394
297# 395#
298# QoS and/or fair queueing 396# I2O device support
299# 397#
300# CONFIG_NET_SCHED is not set 398# CONFIG_I2O is not set
301 399
302# 400#
303# Network testing 401# Network device support
304# 402#
305CONFIG_NET_PKTGEN=m
306# CONFIG_NETPOLL is not set
307# CONFIG_NET_POLL_CONTROLLER is not set
308# CONFIG_HAMRADIO is not set
309# CONFIG_IRDA is not set
310# CONFIG_BT is not set
311CONFIG_NETDEVICES=y 403CONFIG_NETDEVICES=y
312CONFIG_DUMMY=m 404CONFIG_DUMMY=m
313# CONFIG_BONDING is not set 405# CONFIG_BONDING is not set
314# CONFIG_EQUALIZER is not set 406# CONFIG_EQUALIZER is not set
315CONFIG_TUN=m 407CONFIG_TUN=m
316# CONFIG_ETHERTAP is not set
317 408
318# 409#
319# ARCnet devices 410# ARCnet devices
@@ -321,6 +412,11 @@ CONFIG_TUN=m
321# CONFIG_ARCNET is not set 412# CONFIG_ARCNET is not set
322 413
323# 414#
415# PHY device support
416#
417# CONFIG_PHYLIB is not set
418
419#
324# Ethernet (10 or 100Mbit) 420# Ethernet (10 or 100Mbit)
325# 421#
326CONFIG_NET_ETHERNET=y 422CONFIG_NET_ETHERNET=y
@@ -330,6 +426,7 @@ CONFIG_HAPPYMEAL=m
330CONFIG_SUNBMAC=m 426CONFIG_SUNBMAC=m
331CONFIG_SUNQE=m 427CONFIG_SUNQE=m
332# CONFIG_SUNGEM is not set 428# CONFIG_SUNGEM is not set
429# CONFIG_CASSINI is not set
333# CONFIG_NET_VENDOR_3COM is not set 430# CONFIG_NET_VENDOR_3COM is not set
334 431
335# 432#
@@ -350,14 +447,22 @@ CONFIG_SUNQE=m
350# CONFIG_HAMACHI is not set 447# CONFIG_HAMACHI is not set
351# CONFIG_YELLOWFIN is not set 448# CONFIG_YELLOWFIN is not set
352# CONFIG_R8169 is not set 449# CONFIG_R8169 is not set
450# CONFIG_SIS190 is not set
451# CONFIG_SKGE is not set
452# CONFIG_SKY2 is not set
353# CONFIG_SK98LIN is not set 453# CONFIG_SK98LIN is not set
354# CONFIG_TIGON3 is not set 454# CONFIG_TIGON3 is not set
455# CONFIG_BNX2 is not set
456# CONFIG_QLA3XXX is not set
355 457
356# 458#
357# Ethernet (10000 Mbit) 459# Ethernet (10000 Mbit)
358# 460#
461# CONFIG_CHELSIO_T1 is not set
359# CONFIG_IXGB is not set 462# CONFIG_IXGB is not set
360# CONFIG_S2IO is not set 463# CONFIG_S2IO is not set
464# CONFIG_MYRI10GE is not set
465# CONFIG_NETXEN_NIC is not set
361 466
362# 467#
363# Token Ring devices 468# Token Ring devices
@@ -380,17 +485,24 @@ CONFIG_SUNQE=m
380# CONFIG_NET_FC is not set 485# CONFIG_NET_FC is not set
381# CONFIG_SHAPER is not set 486# CONFIG_SHAPER is not set
382# CONFIG_NETCONSOLE is not set 487# CONFIG_NETCONSOLE is not set
488# CONFIG_NETPOLL is not set
489# CONFIG_NET_POLL_CONTROLLER is not set
383 490
384# 491#
385# Unix98 PTY support 492# ISDN subsystem
386# 493#
387CONFIG_UNIX98_PTYS=y 494# CONFIG_ISDN is not set
388CONFIG_UNIX98_PTY_COUNT=256 495
496#
497# Telephony Support
498#
499# CONFIG_PHONE is not set
389 500
390# 501#
391# Input device support 502# Input device support
392# 503#
393CONFIG_INPUT=y 504CONFIG_INPUT=y
505# CONFIG_INPUT_FF_MEMLESS is not set
394 506
395# 507#
396# Userland interfaces 508# Userland interfaces
@@ -405,17 +517,6 @@ CONFIG_INPUT_EVDEV=m
405CONFIG_INPUT_EVBUG=m 517CONFIG_INPUT_EVBUG=m
406 518
407# 519#
408# Input I/O drivers
409#
410# CONFIG_GAMEPORT is not set
411CONFIG_SOUND_GAMEPORT=y
412CONFIG_SERIO=m
413# CONFIG_SERIO_I8042 is not set
414CONFIG_SERIO_SERPORT=m
415# CONFIG_SERIO_CT82C710 is not set
416# CONFIG_SERIO_PCIPS2 is not set
417
418#
419# Input Device Drivers 520# Input Device Drivers
420# 521#
421CONFIG_INPUT_KEYBOARD=y 522CONFIG_INPUT_KEYBOARD=y
@@ -424,6 +525,7 @@ CONFIG_KEYBOARD_SUNKBD=m
424# CONFIG_KEYBOARD_LKKBD is not set 525# CONFIG_KEYBOARD_LKKBD is not set
425# CONFIG_KEYBOARD_XTKBD is not set 526# CONFIG_KEYBOARD_XTKBD is not set
426# CONFIG_KEYBOARD_NEWTON is not set 527# CONFIG_KEYBOARD_NEWTON is not set
528# CONFIG_KEYBOARD_STOWAWAY is not set
427CONFIG_INPUT_MOUSE=y 529CONFIG_INPUT_MOUSE=y
428CONFIG_MOUSE_PS2=m 530CONFIG_MOUSE_PS2=m
429CONFIG_MOUSE_SERIAL=m 531CONFIG_MOUSE_SERIAL=m
@@ -433,29 +535,239 @@ CONFIG_MOUSE_SERIAL=m
433# CONFIG_INPUT_MISC is not set 535# CONFIG_INPUT_MISC is not set
434 536
435# 537#
538# Hardware I/O ports
539#
540CONFIG_SERIO=m
541# CONFIG_SERIO_I8042 is not set
542CONFIG_SERIO_SERPORT=m
543# CONFIG_SERIO_PCIPS2 is not set
544CONFIG_SERIO_LIBPS2=m
545# CONFIG_SERIO_RAW is not set
546# CONFIG_GAMEPORT is not set
547
548#
549# Character devices
550#
551CONFIG_VT=y
552CONFIG_VT_CONSOLE=y
553CONFIG_HW_CONSOLE=y
554# CONFIG_VT_HW_CONSOLE_BINDING is not set
555# CONFIG_SERIAL_NONSTANDARD is not set
556
557#
558# Serial drivers
559#
560
561#
562# Non-8250 serial port support
563#
564CONFIG_SERIAL_SUNCORE=y
565CONFIG_SERIAL_SUNZILOG=y
566CONFIG_SERIAL_SUNZILOG_CONSOLE=y
567CONFIG_SERIAL_SUNSU=y
568CONFIG_SERIAL_SUNSU_CONSOLE=y
569# CONFIG_SERIAL_SUNSAB is not set
570CONFIG_SERIAL_CORE=y
571CONFIG_SERIAL_CORE_CONSOLE=y
572# CONFIG_SERIAL_JSM is not set
573CONFIG_UNIX98_PTYS=y
574CONFIG_LEGACY_PTYS=y
575CONFIG_LEGACY_PTY_COUNT=256
576
577#
578# IPMI
579#
580# CONFIG_IPMI_HANDLER is not set
581
582#
583# Watchdog Cards
584#
585# CONFIG_WATCHDOG is not set
586CONFIG_HW_RANDOM=m
587CONFIG_RTC=m
588# CONFIG_DTLK is not set
589# CONFIG_R3964 is not set
590# CONFIG_APPLICOM is not set
591# CONFIG_DRM is not set
592# CONFIG_RAW_DRIVER is not set
593
594#
595# TPM devices
596#
597# CONFIG_TCG_TPM is not set
598
599#
600# I2C support
601#
602# CONFIG_I2C is not set
603
604#
605# SPI support
606#
607# CONFIG_SPI is not set
608# CONFIG_SPI_MASTER is not set
609
610#
611# Dallas's 1-wire bus
612#
613# CONFIG_W1 is not set
614
615#
616# Hardware Monitoring support
617#
618CONFIG_HWMON=y
619# CONFIG_HWMON_VID is not set
620# CONFIG_SENSORS_ABITUGURU is not set
621# CONFIG_SENSORS_F71805F is not set
622# CONFIG_SENSORS_PC87427 is not set
623# CONFIG_SENSORS_VT1211 is not set
624# CONFIG_HWMON_DEBUG_CHIP is not set
625
626#
627# Multimedia devices
628#
629# CONFIG_VIDEO_DEV is not set
630
631#
632# Digital Video Broadcasting Devices
633#
634# CONFIG_DVB is not set
635
636#
637# Graphics support
638#
639CONFIG_FIRMWARE_EDID=y
640# CONFIG_FB is not set
641
642#
643# Console display driver support
644#
645# CONFIG_PROM_CONSOLE is not set
646CONFIG_DUMMY_CONSOLE=y
647# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
648
649#
650# Sound
651#
652# CONFIG_SOUND is not set
653
654#
655# HID Devices
656#
657CONFIG_HID=y
658
659#
660# USB support
661#
662CONFIG_USB_ARCH_HAS_HCD=y
663CONFIG_USB_ARCH_HAS_OHCI=y
664CONFIG_USB_ARCH_HAS_EHCI=y
665# CONFIG_USB is not set
666
667#
668# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
669#
670
671#
672# USB Gadget Support
673#
674# CONFIG_USB_GADGET is not set
675
676#
677# MMC/SD Card support
678#
679# CONFIG_MMC is not set
680
681#
682# LED devices
683#
684# CONFIG_NEW_LEDS is not set
685
686#
687# LED drivers
688#
689
690#
691# LED Triggers
692#
693
694#
695# InfiniBand support
696#
697# CONFIG_INFINIBAND is not set
698
699#
700# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
701#
702
703#
704# Real Time Clock
705#
706# CONFIG_RTC_CLASS is not set
707
708#
709# DMA Engine support
710#
711# CONFIG_DMA_ENGINE is not set
712
713#
714# DMA Clients
715#
716
717#
718# DMA Devices
719#
720
721#
722# Virtualization
723#
724
725#
726# Misc Linux/SPARC drivers
727#
728CONFIG_SUN_OPENPROMIO=m
729CONFIG_SUN_MOSTEK_RTC=m
730# CONFIG_SUN_BPP is not set
731# CONFIG_SUN_VIDEOPIX is not set
732# CONFIG_TADPOLE_TS102_UCTRL is not set
733# CONFIG_SUN_JSFLASH is not set
734
735#
736# Unix98 PTY support
737#
738CONFIG_UNIX98_PTY_COUNT=256
739
740#
436# File systems 741# File systems
437# 742#
438CONFIG_EXT2_FS=y 743CONFIG_EXT2_FS=y
439CONFIG_EXT2_FS_XATTR=y 744CONFIG_EXT2_FS_XATTR=y
440CONFIG_EXT2_FS_POSIX_ACL=y 745CONFIG_EXT2_FS_POSIX_ACL=y
441CONFIG_EXT2_FS_SECURITY=y 746CONFIG_EXT2_FS_SECURITY=y
747# CONFIG_EXT2_FS_XIP is not set
442# CONFIG_EXT3_FS is not set 748# CONFIG_EXT3_FS is not set
443# CONFIG_JBD is not set 749# CONFIG_EXT4DEV_FS is not set
444CONFIG_FS_MBCACHE=y 750CONFIG_FS_MBCACHE=y
445# CONFIG_REISERFS_FS is not set 751# CONFIG_REISERFS_FS is not set
446# CONFIG_JFS_FS is not set 752# CONFIG_JFS_FS is not set
447CONFIG_FS_POSIX_ACL=y 753CONFIG_FS_POSIX_ACL=y
448CONFIG_XFS_FS=m 754CONFIG_XFS_FS=m
449CONFIG_XFS_RT=y
450CONFIG_XFS_QUOTA=y 755CONFIG_XFS_QUOTA=y
451CONFIG_XFS_SECURITY=y 756CONFIG_XFS_SECURITY=y
452CONFIG_XFS_POSIX_ACL=y 757CONFIG_XFS_POSIX_ACL=y
758CONFIG_XFS_RT=y
759# CONFIG_GFS2_FS is not set
760# CONFIG_OCFS2_FS is not set
453# CONFIG_MINIX_FS is not set 761# CONFIG_MINIX_FS is not set
454CONFIG_ROMFS_FS=m 762CONFIG_ROMFS_FS=m
763CONFIG_INOTIFY=y
764CONFIG_INOTIFY_USER=y
455# CONFIG_QUOTA is not set 765# CONFIG_QUOTA is not set
456CONFIG_QUOTACTL=y 766CONFIG_QUOTACTL=y
767CONFIG_DNOTIFY=y
457CONFIG_AUTOFS_FS=m 768CONFIG_AUTOFS_FS=m
458CONFIG_AUTOFS4_FS=m 769CONFIG_AUTOFS4_FS=m
770# CONFIG_FUSE_FS is not set
459 771
460# 772#
461# CD-ROM/DVD Filesystems 773# CD-ROM/DVD Filesystems
@@ -468,7 +780,8 @@ CONFIG_ISO9660_FS=m
468# 780#
469# DOS/FAT/NT Filesystems 781# DOS/FAT/NT Filesystems
470# 782#
471# CONFIG_FAT_FS is not set 783# CONFIG_MSDOS_FS is not set
784# CONFIG_VFAT_FS is not set
472# CONFIG_NTFS_FS is not set 785# CONFIG_NTFS_FS is not set
473 786
474# 787#
@@ -476,13 +789,12 @@ CONFIG_ISO9660_FS=m
476# 789#
477CONFIG_PROC_FS=y 790CONFIG_PROC_FS=y
478CONFIG_PROC_KCORE=y 791CONFIG_PROC_KCORE=y
792CONFIG_PROC_SYSCTL=y
479CONFIG_SYSFS=y 793CONFIG_SYSFS=y
480# CONFIG_DEVFS_FS is not set
481CONFIG_DEVPTS_FS_XATTR=y
482# CONFIG_DEVPTS_FS_SECURITY is not set
483# CONFIG_TMPFS is not set 794# CONFIG_TMPFS is not set
484# CONFIG_HUGETLB_PAGE is not set 795# CONFIG_HUGETLB_PAGE is not set
485CONFIG_RAMFS=y 796CONFIG_RAMFS=y
797# CONFIG_CONFIGFS_FS is not set
486 798
487# 799#
488# Miscellaneous filesystems 800# Miscellaneous filesystems
@@ -512,17 +824,23 @@ CONFIG_NFS_FS=y
512# CONFIG_NFSD is not set 824# CONFIG_NFSD is not set
513CONFIG_ROOT_NFS=y 825CONFIG_ROOT_NFS=y
514CONFIG_LOCKD=y 826CONFIG_LOCKD=y
515# CONFIG_EXPORTFS is not set 827CONFIG_NFS_COMMON=y
516CONFIG_SUNRPC=y 828CONFIG_SUNRPC=y
517CONFIG_SUNRPC_GSS=m 829CONFIG_SUNRPC_GSS=m
518CONFIG_RPCSEC_GSS_KRB5=m 830CONFIG_RPCSEC_GSS_KRB5=m
831# CONFIG_RPCSEC_GSS_SPKM3 is not set
519# CONFIG_SMB_FS is not set 832# CONFIG_SMB_FS is not set
520CONFIG_CIFS=m 833CONFIG_CIFS=m
521# CONFIG_CIFS_STATS is not set 834# CONFIG_CIFS_STATS is not set
835# CONFIG_CIFS_WEAK_PW_HASH is not set
836# CONFIG_CIFS_XATTR is not set
837# CONFIG_CIFS_DEBUG2 is not set
838# CONFIG_CIFS_EXPERIMENTAL is not set
522# CONFIG_NCP_FS is not set 839# CONFIG_NCP_FS is not set
523# CONFIG_CODA_FS is not set 840# CONFIG_CODA_FS is not set
524CONFIG_AFS_FS=m 841CONFIG_AFS_FS=m
525CONFIG_RXRPC=m 842CONFIG_RXRPC=m
843# CONFIG_9P_FS is not set
526 844
527# 845#
528# Partition Types 846# Partition Types
@@ -559,6 +877,7 @@ CONFIG_NLS_DEFAULT="iso8859-1"
559# CONFIG_NLS_ISO8859_8 is not set 877# CONFIG_NLS_ISO8859_8 is not set
560# CONFIG_NLS_CODEPAGE_1250 is not set 878# CONFIG_NLS_CODEPAGE_1250 is not set
561# CONFIG_NLS_CODEPAGE_1251 is not set 879# CONFIG_NLS_CODEPAGE_1251 is not set
880# CONFIG_NLS_ASCII is not set
562# CONFIG_NLS_ISO8859_1 is not set 881# CONFIG_NLS_ISO8859_1 is not set
563# CONFIG_NLS_ISO8859_2 is not set 882# CONFIG_NLS_ISO8859_2 is not set
564# CONFIG_NLS_ISO8859_3 is not set 883# CONFIG_NLS_ISO8859_3 is not set
@@ -575,70 +894,104 @@ CONFIG_NLS_DEFAULT="iso8859-1"
575# CONFIG_NLS_UTF8 is not set 894# CONFIG_NLS_UTF8 is not set
576 895
577# 896#
578# Sound 897# Distributed Lock Manager
579#
580# CONFIG_SOUND is not set
581
582#
583# USB support
584# 898#
585# CONFIG_USB is not set 899# CONFIG_DLM is not set
586
587#
588# USB Gadget Support
589#
590# CONFIG_USB_GADGET is not set
591 900
592# 901#
593# Watchdog Cards 902# Instrumentation Support
594# 903#
595# CONFIG_WATCHDOG is not set 904# CONFIG_PROFILING is not set
596 905
597# 906#
598# Kernel hacking 907# Kernel hacking
599# 908#
909# CONFIG_PRINTK_TIME is not set
910CONFIG_ENABLE_MUST_CHECK=y
911CONFIG_MAGIC_SYSRQ=y
912# CONFIG_UNUSED_SYMBOLS is not set
913# CONFIG_DEBUG_FS is not set
914# CONFIG_HEADERS_CHECK is not set
600CONFIG_DEBUG_KERNEL=y 915CONFIG_DEBUG_KERNEL=y
601# CONFIG_DEBUG_STACK_USAGE is not set 916CONFIG_LOG_BUF_SHIFT=14
917CONFIG_DETECT_SOFTLOCKUP=y
918# CONFIG_SCHEDSTATS is not set
602# CONFIG_DEBUG_SLAB is not set 919# CONFIG_DEBUG_SLAB is not set
603CONFIG_MAGIC_SYSRQ=y 920# CONFIG_DEBUG_RT_MUTEXES is not set
921# CONFIG_RT_MUTEX_TESTER is not set
604# CONFIG_DEBUG_SPINLOCK is not set 922# CONFIG_DEBUG_SPINLOCK is not set
605# CONFIG_DEBUG_HIGHMEM is not set 923# CONFIG_DEBUG_MUTEXES is not set
924# CONFIG_DEBUG_RWSEMS is not set
606# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 925# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
607# CONFIG_DEBUG_BUGVERBOSE is not set 926# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
927# CONFIG_DEBUG_KOBJECT is not set
928# CONFIG_DEBUG_HIGHMEM is not set
929CONFIG_DEBUG_BUGVERBOSE=y
930# CONFIG_DEBUG_INFO is not set
931# CONFIG_DEBUG_VM is not set
932# CONFIG_DEBUG_LIST is not set
933CONFIG_FORCED_INLINING=y
934# CONFIG_RCU_TORTURE_TEST is not set
935# CONFIG_DEBUG_STACK_USAGE is not set
608 936
609# 937#
610# Security options 938# Security options
611# 939#
940# CONFIG_KEYS is not set
612# CONFIG_SECURITY is not set 941# CONFIG_SECURITY is not set
613 942
614# 943#
615# Cryptographic options 944# Cryptographic options
616# 945#
617CONFIG_CRYPTO=y 946CONFIG_CRYPTO=y
947CONFIG_CRYPTO_ALGAPI=y
948CONFIG_CRYPTO_BLKCIPHER=y
949CONFIG_CRYPTO_HASH=y
950CONFIG_CRYPTO_MANAGER=y
618CONFIG_CRYPTO_HMAC=y 951CONFIG_CRYPTO_HMAC=y
952# CONFIG_CRYPTO_XCBC is not set
619CONFIG_CRYPTO_NULL=m 953CONFIG_CRYPTO_NULL=m
620CONFIG_CRYPTO_MD4=y 954CONFIG_CRYPTO_MD4=y
621CONFIG_CRYPTO_MD5=y 955CONFIG_CRYPTO_MD5=y
622CONFIG_CRYPTO_SHA1=y 956CONFIG_CRYPTO_SHA1=y
623CONFIG_CRYPTO_SHA256=m 957CONFIG_CRYPTO_SHA256=m
624CONFIG_CRYPTO_SHA512=m 958CONFIG_CRYPTO_SHA512=m
959# CONFIG_CRYPTO_WP512 is not set
960# CONFIG_CRYPTO_TGR192 is not set
961# CONFIG_CRYPTO_GF128MUL is not set
962CONFIG_CRYPTO_ECB=m
963CONFIG_CRYPTO_CBC=y
964# CONFIG_CRYPTO_LRW is not set
625CONFIG_CRYPTO_DES=y 965CONFIG_CRYPTO_DES=y
626CONFIG_CRYPTO_BLOWFISH=m 966CONFIG_CRYPTO_BLOWFISH=m
627CONFIG_CRYPTO_TWOFISH=m 967CONFIG_CRYPTO_TWOFISH=m
968CONFIG_CRYPTO_TWOFISH_COMMON=m
628CONFIG_CRYPTO_SERPENT=m 969CONFIG_CRYPTO_SERPENT=m
629CONFIG_CRYPTO_AES=m 970CONFIG_CRYPTO_AES=m
630CONFIG_CRYPTO_CAST5=m 971CONFIG_CRYPTO_CAST5=m
631CONFIG_CRYPTO_CAST6=m 972CONFIG_CRYPTO_CAST6=m
973# CONFIG_CRYPTO_TEA is not set
632CONFIG_CRYPTO_ARC4=m 974CONFIG_CRYPTO_ARC4=m
975# CONFIG_CRYPTO_KHAZAD is not set
976# CONFIG_CRYPTO_ANUBIS is not set
633CONFIG_CRYPTO_DEFLATE=y 977CONFIG_CRYPTO_DEFLATE=y
634CONFIG_CRYPTO_MICHAEL_MIC=m 978CONFIG_CRYPTO_MICHAEL_MIC=m
635CONFIG_CRYPTO_CRC32C=m 979CONFIG_CRYPTO_CRC32C=m
636# CONFIG_CRYPTO_TEST is not set 980# CONFIG_CRYPTO_TEST is not set
637 981
638# 982#
983# Hardware crypto devices
984#
985
986#
639# Library routines 987# Library routines
640# 988#
989CONFIG_BITREVERSE=y
990# CONFIG_CRC_CCITT is not set
991# CONFIG_CRC16 is not set
641CONFIG_CRC32=y 992CONFIG_CRC32=y
642CONFIG_LIBCRC32C=m 993CONFIG_LIBCRC32C=m
643CONFIG_ZLIB_INFLATE=y 994CONFIG_ZLIB_INFLATE=y
644CONFIG_ZLIB_DEFLATE=y 995CONFIG_ZLIB_DEFLATE=y
996CONFIG_PLIST=y
997CONFIG_IOMAP_COPY=y
diff --git a/arch/sparc/kernel/irq.c b/arch/sparc/kernel/irq.c
index c8cb211b9072..5b4841d067c1 100644
--- a/arch/sparc/kernel/irq.c
+++ b/arch/sparc/kernel/irq.c
@@ -425,7 +425,7 @@ int request_fast_irq(unsigned int irq,
425 } 425 }
426 426
427 if (action == NULL) 427 if (action == NULL)
428 action = (struct irqaction *)kmalloc(sizeof(struct irqaction), 428 action = kmalloc(sizeof(struct irqaction),
429 GFP_ATOMIC); 429 GFP_ATOMIC);
430 430
431 if (!action) { 431 if (!action) {
@@ -528,7 +528,7 @@ int request_irq(unsigned int irq,
528 } 528 }
529 529
530 if (action == NULL) 530 if (action == NULL)
531 action = (struct irqaction *)kmalloc(sizeof(struct irqaction), 531 action = kmalloc(sizeof(struct irqaction),
532 GFP_ATOMIC); 532 GFP_ATOMIC);
533 533
534 if (!action) { 534 if (!action) {
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index 33dadd9f2871..d8e008a04e2b 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -83,9 +83,6 @@ extern int __divdi3(int, int);
83/* Private functions with odd calling conventions. */ 83/* Private functions with odd calling conventions. */
84extern void ___atomic24_add(void); 84extern void ___atomic24_add(void);
85extern void ___atomic24_sub(void); 85extern void ___atomic24_sub(void);
86extern void ___set_bit(void);
87extern void ___clear_bit(void);
88extern void ___change_bit(void);
89extern void ___rw_read_enter(void); 86extern void ___rw_read_enter(void);
90extern void ___rw_read_try(void); 87extern void ___rw_read_try(void);
91extern void ___rw_read_exit(void); 88extern void ___rw_read_exit(void);
@@ -125,11 +122,6 @@ EXPORT_SYMBOL(pfn_base);
125EXPORT_SYMBOL(___atomic24_add); 122EXPORT_SYMBOL(___atomic24_add);
126EXPORT_SYMBOL(___atomic24_sub); 123EXPORT_SYMBOL(___atomic24_sub);
127 124
128/* Bit operations. */
129EXPORT_SYMBOL(___set_bit);
130EXPORT_SYMBOL(___clear_bit);
131EXPORT_SYMBOL(___change_bit);
132
133/* Per-CPU information table */ 125/* Per-CPU information table */
134EXPORT_PER_CPU_SYMBOL(__cpu_data); 126EXPORT_PER_CPU_SYMBOL(__cpu_data);
135 127
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index cf1b8baa57ea..0e27e226e0e2 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -327,7 +327,7 @@ int sun4d_request_irq(unsigned int irq,
327 } 327 }
328 328
329 if (action == NULL) 329 if (action == NULL)
330 action = (struct irqaction *)kmalloc(sizeof(struct irqaction), 330 action = kmalloc(sizeof(struct irqaction),
331 GFP_ATOMIC); 331 GFP_ATOMIC);
332 332
333 if (!action) { 333 if (!action) {
diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c
index 6c7aa51b590f..2fcce000d877 100644
--- a/arch/sparc/kernel/time.c
+++ b/arch/sparc/kernel/time.c
@@ -78,7 +78,6 @@ unsigned long profile_pc(struct pt_regs *regs)
78 extern char __copy_user_begin[], __copy_user_end[]; 78 extern char __copy_user_begin[], __copy_user_end[];
79 extern char __atomic_begin[], __atomic_end[]; 79 extern char __atomic_begin[], __atomic_end[];
80 extern char __bzero_begin[], __bzero_end[]; 80 extern char __bzero_begin[], __bzero_end[];
81 extern char __bitops_begin[], __bitops_end[];
82 81
83 unsigned long pc = regs->pc; 82 unsigned long pc = regs->pc;
84 83
@@ -88,9 +87,7 @@ unsigned long profile_pc(struct pt_regs *regs)
88 (pc >= (unsigned long) __atomic_begin && 87 (pc >= (unsigned long) __atomic_begin &&
89 pc < (unsigned long) __atomic_end) || 88 pc < (unsigned long) __atomic_end) ||
90 (pc >= (unsigned long) __bzero_begin && 89 (pc >= (unsigned long) __bzero_begin &&
91 pc < (unsigned long) __bzero_end) || 90 pc < (unsigned long) __bzero_end))
92 (pc >= (unsigned long) __bitops_begin &&
93 pc < (unsigned long) __bitops_end))
94 pc = regs->u_regs[UREG_RETPC]; 91 pc = regs->u_regs[UREG_RETPC];
95 return pc; 92 return pc;
96} 93}
diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
index 5db7e1d85385..9ddc5b9ce3bd 100644
--- a/arch/sparc/lib/Makefile
+++ b/arch/sparc/lib/Makefile
@@ -7,7 +7,7 @@ EXTRA_AFLAGS := -ansi -DST_DIV0=0x02
7lib-y := mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o memcpy.o memset.o \ 7lib-y := mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o memcpy.o memset.o \
8 strlen.o checksum.o blockops.o memscan.o memcmp.o strncmp.o \ 8 strlen.o checksum.o blockops.o memscan.o memcmp.o strncmp.o \
9 strncpy_from_user.o divdi3.o udivdi3.o strlen_user.o \ 9 strncpy_from_user.o divdi3.o udivdi3.o strlen_user.o \
10 copy_user.o locks.o atomic.o atomic32.o bitops.o \ 10 copy_user.o locks.o atomic.o \
11 lshrdi3.o ashldi3.o rwsem.o muldi3.o bitext.o 11 lshrdi3.o ashldi3.o rwsem.o muldi3.o bitext.o
12 12
13obj-y += iomap.o 13obj-y += iomap.o atomic32.o
diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c
index de84f8534bac..53ddcd9d1e60 100644
--- a/arch/sparc/lib/atomic32.c
+++ b/arch/sparc/lib/atomic32.c
@@ -76,3 +76,42 @@ void atomic_set(atomic_t *v, int i)
76 spin_unlock_irqrestore(ATOMIC_HASH(v), flags); 76 spin_unlock_irqrestore(ATOMIC_HASH(v), flags);
77} 77}
78EXPORT_SYMBOL(atomic_set); 78EXPORT_SYMBOL(atomic_set);
79
80unsigned long ___set_bit(unsigned long *addr, unsigned long mask)
81{
82 unsigned long old, flags;
83
84 spin_lock_irqsave(ATOMIC_HASH(addr), flags);
85 old = *addr;
86 *addr = old | mask;
87 spin_unlock_irqrestore(ATOMIC_HASH(addr), flags);
88
89 return old & mask;
90}
91EXPORT_SYMBOL(___set_bit);
92
93unsigned long ___clear_bit(unsigned long *addr, unsigned long mask)
94{
95 unsigned long old, flags;
96
97 spin_lock_irqsave(ATOMIC_HASH(addr), flags);
98 old = *addr;
99 *addr = old & ~mask;
100 spin_unlock_irqrestore(ATOMIC_HASH(addr), flags);
101
102 return old & mask;
103}
104EXPORT_SYMBOL(___clear_bit);
105
106unsigned long ___change_bit(unsigned long *addr, unsigned long mask)
107{
108 unsigned long old, flags;
109
110 spin_lock_irqsave(ATOMIC_HASH(addr), flags);
111 old = *addr;
112 *addr = old ^ mask;
113 spin_unlock_irqrestore(ATOMIC_HASH(addr), flags);
114
115 return old & mask;
116}
117EXPORT_SYMBOL(___change_bit);
diff --git a/arch/sparc/lib/bitops.S b/arch/sparc/lib/bitops.S
deleted file mode 100644
index cb7fb66a40c8..000000000000
--- a/arch/sparc/lib/bitops.S
+++ /dev/null
@@ -1,109 +0,0 @@
1/* bitops.S: Low level assembler bit operations.
2 *
3 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
4 */
5
6#include <asm/ptrace.h>
7#include <asm/psr.h>
8
9 .text
10 .align 4
11
12 .globl __bitops_begin
13__bitops_begin:
14
15 /* Take bits in %g2 and set them in word at %g1,
16 * return whether bits were set in original value
17 * in %g2. %g4 holds value to restore into %o7
18 * in delay slot of jmpl return, %g3 + %g5 + %g7 can be
19 * used as temporaries and thus is considered clobbered
20 * by all callers.
21 */
22 .globl ___set_bit
23___set_bit:
24 rd %psr, %g3
25 nop; nop; nop;
26 or %g3, PSR_PIL, %g5
27 wr %g5, 0x0, %psr
28 nop; nop; nop
29#ifdef CONFIG_SMP
30 set bitops_spinlock, %g5
312: ldstub [%g5], %g7 ! Spin on the byte lock for SMP.
32 orcc %g7, 0x0, %g0 ! Did we get it?
33 bne 2b ! Nope...
34#endif
35 ld [%g1], %g7
36 or %g7, %g2, %g5
37 and %g7, %g2, %g2
38#ifdef CONFIG_SMP
39 st %g5, [%g1]
40 set bitops_spinlock, %g5
41 stb %g0, [%g5]
42#else
43 st %g5, [%g1]
44#endif
45 wr %g3, 0x0, %psr
46 nop; nop; nop
47 jmpl %o7, %g0
48 mov %g4, %o7
49
50 /* Same as above, but clears the bits from %g2 instead. */
51 .globl ___clear_bit
52___clear_bit:
53 rd %psr, %g3
54 nop; nop; nop
55 or %g3, PSR_PIL, %g5
56 wr %g5, 0x0, %psr
57 nop; nop; nop
58#ifdef CONFIG_SMP
59 set bitops_spinlock, %g5
602: ldstub [%g5], %g7 ! Spin on the byte lock for SMP.
61 orcc %g7, 0x0, %g0 ! Did we get it?
62 bne 2b ! Nope...
63#endif
64 ld [%g1], %g7
65 andn %g7, %g2, %g5
66 and %g7, %g2, %g2
67#ifdef CONFIG_SMP
68 st %g5, [%g1]
69 set bitops_spinlock, %g5
70 stb %g0, [%g5]
71#else
72 st %g5, [%g1]
73#endif
74 wr %g3, 0x0, %psr
75 nop; nop; nop
76 jmpl %o7, %g0
77 mov %g4, %o7
78
79 /* Same thing again, but this time toggles the bits from %g2. */
80 .globl ___change_bit
81___change_bit:
82 rd %psr, %g3
83 nop; nop; nop
84 or %g3, PSR_PIL, %g5
85 wr %g5, 0x0, %psr
86 nop; nop; nop
87#ifdef CONFIG_SMP
88 set bitops_spinlock, %g5
892: ldstub [%g5], %g7 ! Spin on the byte lock for SMP.
90 orcc %g7, 0x0, %g0 ! Did we get it?
91 bne 2b ! Nope...
92#endif
93 ld [%g1], %g7
94 xor %g7, %g2, %g5
95 and %g7, %g2, %g2
96#ifdef CONFIG_SMP
97 st %g5, [%g1]
98 set bitops_spinlock, %g5
99 stb %g0, [%g5]
100#else
101 st %g5, [%g1]
102#endif
103 wr %g3, 0x0, %psr
104 nop; nop; nop
105 jmpl %o7, %g0
106 mov %g4, %o7
107
108 .globl __bitops_end
109__bitops_end:
diff --git a/arch/sparc64/kernel/head.S b/arch/sparc64/kernel/head.S
index 03ffaf895a22..baea10a98196 100644
--- a/arch/sparc64/kernel/head.S
+++ b/arch/sparc64/kernel/head.S
@@ -78,11 +78,7 @@ sparc_ramdisk_image64:
78 78
79 /* PROM cif handler code address is in %o4. */ 79 /* PROM cif handler code address is in %o4. */
80sparc64_boot: 80sparc64_boot:
811: rd %pc, %g7 81 mov %o4, %l7
82 set 1b, %g1
83 cmp %g1, %g7
84 be,pn %xcc, sparc64_boot_after_remap
85 mov %o4, %l7
86 82
87 /* We need to remap the kernel. Use position independant 83 /* We need to remap the kernel. Use position independant
88 * code to remap us to KERNBASE. 84 * code to remap us to KERNBASE.
@@ -295,7 +291,6 @@ is_sun4v:
295 291
296 add %sp, (192 + 128), %sp 292 add %sp, (192 + 128), %sp
297 293
298sparc64_boot_after_remap:
299 sethi %hi(prom_root_compatible), %g1 294 sethi %hi(prom_root_compatible), %g1
300 or %g1, %lo(prom_root_compatible), %g1 295 or %g1, %lo(prom_root_compatible), %g1
301 sethi %hi(prom_sun4v_name), %g7 296 sethi %hi(prom_sun4v_name), %g7
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index d64b1ea848de..c3d068c7a412 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -372,14 +372,14 @@ static void run_pre_handler(unsigned int virt_irq)
372 } 372 }
373} 373}
374 374
375static struct hw_interrupt_type sun4u_irq = { 375static struct irq_chip sun4u_irq = {
376 .typename = "sun4u", 376 .typename = "sun4u",
377 .enable = sun4u_irq_enable, 377 .enable = sun4u_irq_enable,
378 .disable = sun4u_irq_disable, 378 .disable = sun4u_irq_disable,
379 .end = sun4u_irq_end, 379 .end = sun4u_irq_end,
380}; 380};
381 381
382static struct hw_interrupt_type sun4u_irq_ack = { 382static struct irq_chip sun4u_irq_ack = {
383 .typename = "sun4u+ack", 383 .typename = "sun4u+ack",
384 .enable = sun4u_irq_enable, 384 .enable = sun4u_irq_enable,
385 .disable = sun4u_irq_disable, 385 .disable = sun4u_irq_disable,
@@ -387,14 +387,14 @@ static struct hw_interrupt_type sun4u_irq_ack = {
387 .end = sun4u_irq_end, 387 .end = sun4u_irq_end,
388}; 388};
389 389
390static struct hw_interrupt_type sun4v_irq = { 390static struct irq_chip sun4v_irq = {
391 .typename = "sun4v", 391 .typename = "sun4v",
392 .enable = sun4v_irq_enable, 392 .enable = sun4v_irq_enable,
393 .disable = sun4v_irq_disable, 393 .disable = sun4v_irq_disable,
394 .end = sun4v_irq_end, 394 .end = sun4v_irq_end,
395}; 395};
396 396
397static struct hw_interrupt_type sun4v_irq_ack = { 397static struct irq_chip sun4v_irq_ack = {
398 .typename = "sun4v+ack", 398 .typename = "sun4v+ack",
399 .enable = sun4v_irq_enable, 399 .enable = sun4v_irq_enable,
400 .disable = sun4v_irq_disable, 400 .disable = sun4v_irq_disable,
@@ -493,22 +493,6 @@ out:
493 return bucket->virt_irq; 493 return bucket->virt_irq;
494} 494}
495 495
496void hw_resend_irq(struct hw_interrupt_type *handler, unsigned int virt_irq)
497{
498 struct ino_bucket *bucket = virt_irq_to_bucket(virt_irq);
499 unsigned long pstate;
500 unsigned int *ent;
501
502 __asm__ __volatile__("rdpr %%pstate, %0" : "=r" (pstate));
503 __asm__ __volatile__("wrpr %0, %1, %%pstate"
504 : : "r" (pstate), "i" (PSTATE_IE));
505 ent = irq_work(smp_processor_id());
506 bucket->irq_chain = *ent;
507 *ent = __irq(bucket);
508 set_softint(1 << PIL_DEVICE_IRQ);
509 __asm__ __volatile__("wrpr %0, 0x0, %%pstate" : : "r" (pstate));
510}
511
512void ack_bad_irq(unsigned int virt_irq) 496void ack_bad_irq(unsigned int virt_irq)
513{ 497{
514 struct ino_bucket *bucket = virt_irq_to_bucket(virt_irq); 498 struct ino_bucket *bucket = virt_irq_to_bucket(virt_irq);
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index cc09d8266414..0a4958536bcd 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -1447,11 +1447,8 @@ void __init setup_per_cpu_areas(void)
1447 char *ptr; 1447 char *ptr;
1448 1448
1449 /* Copy section for each CPU (we discard the original) */ 1449 /* Copy section for each CPU (we discard the original) */
1450 goal = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES); 1450 goal = PERCPU_ENOUGH_ROOM;
1451#ifdef CONFIG_MODULES 1451
1452 if (goal < PERCPU_ENOUGH_ROOM)
1453 goal = PERCPU_ENOUGH_ROOM;
1454#endif
1455 __per_cpu_shift = 0; 1452 __per_cpu_shift = 0;
1456 for (size = 1UL; size < goal; size <<= 1UL) 1453 for (size = 1UL; size < goal; size <<= 1UL)
1457 __per_cpu_shift++; 1454 __per_cpu_shift++;
diff --git a/arch/sparc64/kernel/sys_sunos32.c b/arch/sparc64/kernel/sys_sunos32.c
index 4446f66590fa..2ebc2c051383 100644
--- a/arch/sparc64/kernel/sys_sunos32.c
+++ b/arch/sparc64/kernel/sys_sunos32.c
@@ -1055,7 +1055,7 @@ asmlinkage int sunos_msgsys(int op, u32 arg1, u32 arg2, u32 arg3, u32 arg4)
1055 break; 1055 break;
1056 case 2: 1056 case 2:
1057 rval = -EFAULT; 1057 rval = -EFAULT;
1058 kmbuf = (struct msgbuf *)kmalloc(sizeof(struct msgbuf) + arg3, 1058 kmbuf = kmalloc(sizeof(struct msgbuf) + arg3,
1059 GFP_KERNEL); 1059 GFP_KERNEL);
1060 if (!kmbuf) 1060 if (!kmbuf)
1061 break; 1061 break;
@@ -1078,7 +1078,7 @@ asmlinkage int sunos_msgsys(int op, u32 arg1, u32 arg2, u32 arg3, u32 arg4)
1078 break; 1078 break;
1079 case 3: 1079 case 3:
1080 rval = -EFAULT; 1080 rval = -EFAULT;
1081 kmbuf = (struct msgbuf *)kmalloc(sizeof(struct msgbuf) + arg3, 1081 kmbuf = kmalloc(sizeof(struct msgbuf) + arg3,
1082 GFP_KERNEL); 1082 GFP_KERNEL);
1083 if (!kmbuf || sunos_msgbuf_get((struct msgbuf32 __user *)(unsigned long)arg2, 1083 if (!kmbuf || sunos_msgbuf_get((struct msgbuf32 __user *)(unsigned long)arg2,
1084 kmbuf, arg3)) 1084 kmbuf, arg3))
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index b2e9762e13c5..afe3d427ddfa 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -72,9 +72,11 @@ static int uml_net_rx(struct net_device *dev)
72 return pkt_len; 72 return pkt_len;
73} 73}
74 74
75static void uml_dev_close(void* dev) 75static void uml_dev_close(struct work_struct *work)
76{ 76{
77 dev_close( (struct net_device *) dev); 77 struct uml_net_private *lp =
78 container_of(work, struct uml_net_private, work);
79 dev_close(lp->dev);
78} 80}
79 81
80irqreturn_t uml_net_interrupt(int irq, void *dev_id) 82irqreturn_t uml_net_interrupt(int irq, void *dev_id)
@@ -89,7 +91,6 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id)
89 spin_lock(&lp->lock); 91 spin_lock(&lp->lock);
90 while((err = uml_net_rx(dev)) > 0) ; 92 while((err = uml_net_rx(dev)) > 0) ;
91 if(err < 0) { 93 if(err < 0) {
92 DECLARE_WORK(close_work, uml_dev_close, dev);
93 printk(KERN_ERR 94 printk(KERN_ERR
94 "Device '%s' read returned %d, shutting it down\n", 95 "Device '%s' read returned %d, shutting it down\n",
95 dev->name, err); 96 dev->name, err);
@@ -97,9 +98,10 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id)
97 * again lp->lock. 98 * again lp->lock.
98 * And dev_close() can be safely called multiple times on the 99 * And dev_close() can be safely called multiple times on the
99 * same device, since it tests for (dev->flags & IFF_UP). So 100 * same device, since it tests for (dev->flags & IFF_UP). So
100 * there's no harm in delaying the device shutdown. */ 101 * there's no harm in delaying the device shutdown.
101 schedule_work(&close_work); 102 * Furthermore, the workqueue will not re-enqueue an already
102#error this is not permitted - close_work will go out of scope 103 * enqueued work item. */
104 schedule_work(&lp->work);
103 goto out; 105 goto out;
104 } 106 }
105 reactivate_fd(lp->fd, UM_ETH_IRQ); 107 reactivate_fd(lp->fd, UM_ETH_IRQ);
@@ -365,6 +367,7 @@ static int eth_configure(int n, void *init, char *mac,
365 /* This points to the transport private data. It's still clear, but we 367 /* This points to the transport private data. It's still clear, but we
366 * must memset it to 0 *now*. Let's help the drivers. */ 368 * must memset it to 0 *now*. Let's help the drivers. */
367 memset(lp, 0, size); 369 memset(lp, 0, size);
370 INIT_WORK(&lp->work, uml_dev_close);
368 371
369 /* sysfs register */ 372 /* sysfs register */
370 if (!driver_registered) { 373 if (!driver_registered) {
diff --git a/arch/um/include/net_kern.h b/arch/um/include/net_kern.h
index 280459fb0b26..218f8b47fdcd 100644
--- a/arch/um/include/net_kern.h
+++ b/arch/um/include/net_kern.h
@@ -11,6 +11,7 @@
11#include <linux/skbuff.h> 11#include <linux/skbuff.h>
12#include <linux/socket.h> 12#include <linux/socket.h>
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/workqueue.h>
14 15
15struct uml_net { 16struct uml_net {
16 struct list_head list; 17 struct list_head list;
@@ -26,6 +27,7 @@ struct uml_net_private {
26 struct net_device *dev; 27 struct net_device *dev;
27 struct timer_list tl; 28 struct timer_list tl;
28 struct net_device_stats stats; 29 struct net_device_stats stats;
30 struct work_struct work;
29 int fd; 31 int fd;
30 unsigned char mac[ETH_ALEN]; 32 unsigned char mac[ETH_ALEN];
31 unsigned short (*protocol)(struct sk_buff *); 33 unsigned short (*protocol)(struct sk_buff *);
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index 49057d8bc668..5db7737df0ff 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -166,7 +166,7 @@ static long read_ldt_from_host(void __user * ptr, unsigned long bytecount)
166 struct ptrace_ldt ptrace_ldt = (struct ptrace_ldt) { 166 struct ptrace_ldt ptrace_ldt = (struct ptrace_ldt) {
167 .func = 0, 167 .func = 0,
168 .bytecount = bytecount, 168 .bytecount = bytecount,
169 .ptr = (void *)kmalloc(bytecount, GFP_KERNEL)}; 169 .ptr = kmalloc(bytecount, GFP_KERNEL)};
170 u32 cpu; 170 u32 cpu;
171 171
172 if(ptrace_ldt.ptr == NULL) 172 if(ptrace_ldt.ptr == NULL)
@@ -426,7 +426,7 @@ void ldt_get_host_info(void)
426 host_ldt_entries = dummy_list; 426 host_ldt_entries = dummy_list;
427 else { 427 else {
428 size = (size + 1) * sizeof(dummy_list[0]); 428 size = (size + 1) * sizeof(dummy_list[0]);
429 host_ldt_entries = (short *)kmalloc(size, GFP_KERNEL); 429 host_ldt_entries = kmalloc(size, GFP_KERNEL);
430 if(host_ldt_entries == NULL) { 430 if(host_ldt_entries == NULL) {
431 printk("ldt_get_host_info: couldn't allocate host ldt list\n"); 431 printk("ldt_get_host_info: couldn't allocate host ldt list\n");
432 goto out_free; 432 goto out_free;
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index b471b8550d03..2941a915d4ef 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -45,9 +45,7 @@ cflags-kernel-$(CONFIG_REORDER) += -ffunction-sections
45# actually it makes the kernel smaller too. 45# actually it makes the kernel smaller too.
46cflags-y += -fno-reorder-blocks 46cflags-y += -fno-reorder-blocks
47cflags-y += -Wno-sign-compare 47cflags-y += -Wno-sign-compare
48ifneq ($(CONFIG_UNWIND_INFO),y)
49cflags-y += -fno-asynchronous-unwind-tables 48cflags-y += -fno-asynchronous-unwind-tables
50endif
51ifneq ($(CONFIG_DEBUG_INFO),y) 49ifneq ($(CONFIG_DEBUG_INFO),y)
52# -fweb shrinks the kernel a bit, but the difference is very small 50# -fweb shrinks the kernel a bit, but the difference is very small
53# it also messes up debugging, so don't use it for now. 51# it also messes up debugging, so don't use it for now.
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index 1a1c6a1a299b..ac80b1209fc0 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1523,8 +1523,6 @@ CONFIG_DEBUG_FS=y
1523# CONFIG_DEBUG_VM is not set 1523# CONFIG_DEBUG_VM is not set
1524# CONFIG_DEBUG_LIST is not set 1524# CONFIG_DEBUG_LIST is not set
1525# CONFIG_FRAME_POINTER is not set 1525# CONFIG_FRAME_POINTER is not set
1526CONFIG_UNWIND_INFO=y
1527CONFIG_STACK_UNWIND=y
1528# CONFIG_FORCED_INLINING is not set 1526# CONFIG_FORCED_INLINING is not set
1529# CONFIG_HEADERS_CHECK is not set 1527# CONFIG_HEADERS_CHECK is not set
1530# CONFIG_RCU_TORTURE_TEST is not set 1528# CONFIG_RCU_TORTURE_TEST is not set
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 601d332c4b79..9f5dac64aa8f 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -1155,36 +1155,3 @@ ENTRY(call_softirq)
1155 ret 1155 ret
1156 CFI_ENDPROC 1156 CFI_ENDPROC
1157ENDPROC(call_softirq) 1157ENDPROC(call_softirq)
1158
1159#ifdef CONFIG_STACK_UNWIND
1160ENTRY(arch_unwind_init_running)
1161 CFI_STARTPROC
1162 movq %r15, R15(%rdi)
1163 movq %r14, R14(%rdi)
1164 xchgq %rsi, %rdx
1165 movq %r13, R13(%rdi)
1166 movq %r12, R12(%rdi)
1167 xorl %eax, %eax
1168 movq %rbp, RBP(%rdi)
1169 movq %rbx, RBX(%rdi)
1170 movq (%rsp), %rcx
1171 movq %rax, R11(%rdi)
1172 movq %rax, R10(%rdi)
1173 movq %rax, R9(%rdi)
1174 movq %rax, R8(%rdi)
1175 movq %rax, RAX(%rdi)
1176 movq %rax, RCX(%rdi)
1177 movq %rax, RDX(%rdi)
1178 movq %rax, RSI(%rdi)
1179 movq %rax, RDI(%rdi)
1180 movq %rax, ORIG_RAX(%rdi)
1181 movq %rcx, RIP(%rdi)
1182 leaq 8(%rsp), %rcx
1183 movq $__KERNEL_CS, CS(%rdi)
1184 movq %rax, EFLAGS(%rdi)
1185 movq %rcx, RSP(%rdi)
1186 movq $__KERNEL_DS, SS(%rdi)
1187 jmpq *%rdx
1188 CFI_ENDPROC
1189ENDPROC(arch_unwind_init_running)
1190#endif
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index b54ccc07f379..1d9eb6db732a 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -110,11 +110,6 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
110} 110}
111 111
112int kstack_depth_to_print = 12; 112int kstack_depth_to_print = 12;
113#ifdef CONFIG_STACK_UNWIND
114static int call_trace = 1;
115#else
116#define call_trace (-1)
117#endif
118 113
119#ifdef CONFIG_KALLSYMS 114#ifdef CONFIG_KALLSYMS
120void printk_address(unsigned long address) 115void printk_address(unsigned long address)
@@ -217,32 +212,6 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
217 return NULL; 212 return NULL;
218} 213}
219 214
220struct ops_and_data {
221 struct stacktrace_ops *ops;
222 void *data;
223};
224
225static int dump_trace_unwind(struct unwind_frame_info *info, void *context)
226{
227 struct ops_and_data *oad = (struct ops_and_data *)context;
228 int n = 0;
229 unsigned long sp = UNW_SP(info);
230
231 if (arch_unw_user_mode(info))
232 return -1;
233 while (unwind(info) == 0 && UNW_PC(info)) {
234 n++;
235 oad->ops->address(oad->data, UNW_PC(info));
236 if (arch_unw_user_mode(info))
237 break;
238 if ((sp & ~(PAGE_SIZE - 1)) == (UNW_SP(info) & ~(PAGE_SIZE - 1))
239 && sp > UNW_SP(info))
240 break;
241 sp = UNW_SP(info);
242 }
243 return n;
244}
245
246#define MSG(txt) ops->warning(data, txt) 215#define MSG(txt) ops->warning(data, txt)
247 216
248/* 217/*
@@ -270,40 +239,6 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
270 if (!tsk) 239 if (!tsk)
271 tsk = current; 240 tsk = current;
272 241
273 if (call_trace >= 0) {
274 int unw_ret = 0;
275 struct unwind_frame_info info;
276 struct ops_and_data oad = { .ops = ops, .data = data };
277
278 if (regs) {
279 if (unwind_init_frame_info(&info, tsk, regs) == 0)
280 unw_ret = dump_trace_unwind(&info, &oad);
281 } else if (tsk == current)
282 unw_ret = unwind_init_running(&info, dump_trace_unwind,
283 &oad);
284 else {
285 if (unwind_init_blocked(&info, tsk) == 0)
286 unw_ret = dump_trace_unwind(&info, &oad);
287 }
288 if (unw_ret > 0) {
289 if (call_trace == 1 && !arch_unw_user_mode(&info)) {
290 ops->warning_symbol(data,
291 "DWARF2 unwinder stuck at %s",
292 UNW_PC(&info));
293 if ((long)UNW_SP(&info) < 0) {
294 MSG("Leftover inexact backtrace:");
295 stack = (unsigned long *)UNW_SP(&info);
296 if (!stack)
297 goto out;
298 } else
299 MSG("Full inexact backtrace again:");
300 } else if (call_trace >= 1)
301 goto out;
302 else
303 MSG("Full inexact backtrace again:");
304 } else
305 MSG("Inexact backtrace:");
306 }
307 if (!stack) { 242 if (!stack) {
308 unsigned long dummy; 243 unsigned long dummy;
309 stack = &dummy; 244 stack = &dummy;
@@ -387,7 +322,6 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
387 tinfo = current_thread_info(); 322 tinfo = current_thread_info();
388 HANDLE_STACK (valid_stack_ptr(tinfo, stack)); 323 HANDLE_STACK (valid_stack_ptr(tinfo, stack));
389#undef HANDLE_STACK 324#undef HANDLE_STACK
390out:
391 put_cpu(); 325 put_cpu();
392} 326}
393EXPORT_SYMBOL(dump_trace); 327EXPORT_SYMBOL(dump_trace);
@@ -1188,21 +1122,3 @@ static int __init kstack_setup(char *s)
1188 return 0; 1122 return 0;
1189} 1123}
1190early_param("kstack", kstack_setup); 1124early_param("kstack", kstack_setup);
1191
1192#ifdef CONFIG_STACK_UNWIND
1193static int __init call_trace_setup(char *s)
1194{
1195 if (!s)
1196 return -EINVAL;
1197 if (strcmp(s, "old") == 0)
1198 call_trace = -1;
1199 else if (strcmp(s, "both") == 0)
1200 call_trace = 0;
1201 else if (strcmp(s, "newfallback") == 0)
1202 call_trace = 1;
1203 else if (strcmp(s, "new") == 0)
1204 call_trace = 2;
1205 return 0;
1206}
1207early_param("call_trace", call_trace_setup);
1208#endif
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index 514be5dd2303..1e54ddf2338d 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -221,9 +221,7 @@ SECTIONS
221 /* Sections to be discarded */ 221 /* Sections to be discarded */
222 /DISCARD/ : { 222 /DISCARD/ : {
223 *(.exitcall.exit) 223 *(.exitcall.exit)
224#ifndef CONFIG_UNWIND_INFO
225 *(.eh_frame) 224 *(.eh_frame)
226#endif
227 } 225 }
228 226
229 STABS_DEBUG 227 STABS_DEBUG
diff --git a/arch/xtensa/kernel/Makefile b/arch/xtensa/kernel/Makefile
index d573017a5dde..71f733c4f66d 100644
--- a/arch/xtensa/kernel/Makefile
+++ b/arch/xtensa/kernel/Makefile
@@ -6,7 +6,7 @@ extra-y := head.o vmlinux.lds
6 6
7 7
8obj-y := align.o entry.o irq.o coprocessor.o process.o ptrace.o semaphore.o \ 8obj-y := align.o entry.o irq.o coprocessor.o process.o ptrace.o semaphore.o \
9 setup.o signal.o syscalls.o time.o traps.o vectors.o platform.o \ 9 setup.o signal.o syscall.o time.o traps.o vectors.o platform.o \
10 pci-dma.o 10 pci-dma.o
11 11
12## windowspill.o 12## windowspill.o
diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c
index 418268f49766..fe3834bc1dbf 100644
--- a/arch/xtensa/kernel/syscall.c
+++ b/arch/xtensa/kernel/syscall.c
@@ -16,7 +16,7 @@
16 * 16 *
17 */ 17 */
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include <asm/syscalls.h> 19#include <asm/syscall.h>
20#include <asm/unistd.h> 20#include <asm/unistd.h>
21#include <linux/linkage.h> 21#include <linux/linkage.h>
22#include <linux/stringify.h> 22#include <linux/stringify.h>
diff --git a/block/as-iosched.c b/block/as-iosched.c
index 5934c4bfd52a..ef126277b4b3 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -1462,20 +1462,7 @@ static struct elevator_type iosched_as = {
1462 1462
1463static int __init as_init(void) 1463static int __init as_init(void)
1464{ 1464{
1465 int ret; 1465 return elv_register(&iosched_as);
1466
1467 ret = elv_register(&iosched_as);
1468 if (!ret) {
1469 /*
1470 * don't allow AS to get unregistered, since we would have
1471 * to browse all tasks in the system and release their
1472 * as_io_context first
1473 */
1474 __module_get(THIS_MODULE);
1475 return 0;
1476 }
1477
1478 return ret;
1479} 1466}
1480 1467
1481static void __exit as_exit(void) 1468static void __exit as_exit(void)
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 78c6b312bd30..533a2938ffd6 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -219,9 +219,12 @@ static int cfq_queue_empty(request_queue_t *q)
219 return !cfqd->busy_queues; 219 return !cfqd->busy_queues;
220} 220}
221 221
222static inline pid_t cfq_queue_pid(struct task_struct *task, int rw) 222static inline pid_t cfq_queue_pid(struct task_struct *task, int rw, int is_sync)
223{ 223{
224 if (rw == READ || rw == WRITE_SYNC) 224 /*
225 * Use the per-process queue, for read requests and syncronous writes
226 */
227 if (!(rw & REQ_RW) || is_sync)
225 return task->pid; 228 return task->pid;
226 229
227 return CFQ_KEY_ASYNC; 230 return CFQ_KEY_ASYNC;
@@ -473,7 +476,7 @@ static struct request *
473cfq_find_rq_fmerge(struct cfq_data *cfqd, struct bio *bio) 476cfq_find_rq_fmerge(struct cfq_data *cfqd, struct bio *bio)
474{ 477{
475 struct task_struct *tsk = current; 478 struct task_struct *tsk = current;
476 pid_t key = cfq_queue_pid(tsk, bio_data_dir(bio)); 479 pid_t key = cfq_queue_pid(tsk, bio_data_dir(bio), bio_sync(bio));
477 struct cfq_queue *cfqq; 480 struct cfq_queue *cfqq;
478 481
479 cfqq = cfq_find_cfq_hash(cfqd, key, tsk->ioprio); 482 cfqq = cfq_find_cfq_hash(cfqd, key, tsk->ioprio);
@@ -1748,6 +1751,9 @@ static int cfq_may_queue(request_queue_t *q, int rw)
1748 struct cfq_data *cfqd = q->elevator->elevator_data; 1751 struct cfq_data *cfqd = q->elevator->elevator_data;
1749 struct task_struct *tsk = current; 1752 struct task_struct *tsk = current;
1750 struct cfq_queue *cfqq; 1753 struct cfq_queue *cfqq;
1754 unsigned int key;
1755
1756 key = cfq_queue_pid(tsk, rw, rw & REQ_RW_SYNC);
1751 1757
1752 /* 1758 /*
1753 * don't force setup of a queue from here, as a call to may_queue 1759 * don't force setup of a queue from here, as a call to may_queue
@@ -1755,7 +1761,7 @@ static int cfq_may_queue(request_queue_t *q, int rw)
1755 * so just lookup a possibly existing queue, or return 'may queue' 1761 * so just lookup a possibly existing queue, or return 'may queue'
1756 * if that fails 1762 * if that fails
1757 */ 1763 */
1758 cfqq = cfq_find_cfq_hash(cfqd, cfq_queue_pid(tsk, rw), tsk->ioprio); 1764 cfqq = cfq_find_cfq_hash(cfqd, key, tsk->ioprio);
1759 if (cfqq) { 1765 if (cfqq) {
1760 cfq_init_prio_data(cfqq); 1766 cfq_init_prio_data(cfqq);
1761 cfq_prio_boost(cfqq); 1767 cfq_prio_boost(cfqq);
@@ -1798,10 +1804,10 @@ cfq_set_request(request_queue_t *q, struct request *rq, gfp_t gfp_mask)
1798 struct task_struct *tsk = current; 1804 struct task_struct *tsk = current;
1799 struct cfq_io_context *cic; 1805 struct cfq_io_context *cic;
1800 const int rw = rq_data_dir(rq); 1806 const int rw = rq_data_dir(rq);
1801 pid_t key = cfq_queue_pid(tsk, rw); 1807 const int is_sync = rq_is_sync(rq);
1808 pid_t key = cfq_queue_pid(tsk, rw, is_sync);
1802 struct cfq_queue *cfqq; 1809 struct cfq_queue *cfqq;
1803 unsigned long flags; 1810 unsigned long flags;
1804 int is_sync = key != CFQ_KEY_ASYNC;
1805 1811
1806 might_sleep_if(gfp_mask & __GFP_WAIT); 1812 might_sleep_if(gfp_mask & __GFP_WAIT);
1807 1813
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index a541b42c08e3..79807dbc306e 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -2058,15 +2058,16 @@ static void freed_request(request_queue_t *q, int rw, int priv)
2058 * Returns NULL on failure, with queue_lock held. 2058 * Returns NULL on failure, with queue_lock held.
2059 * Returns !NULL on success, with queue_lock *not held*. 2059 * Returns !NULL on success, with queue_lock *not held*.
2060 */ 2060 */
2061static struct request *get_request(request_queue_t *q, int rw, struct bio *bio, 2061static struct request *get_request(request_queue_t *q, int rw_flags,
2062 gfp_t gfp_mask) 2062 struct bio *bio, gfp_t gfp_mask)
2063{ 2063{
2064 struct request *rq = NULL; 2064 struct request *rq = NULL;
2065 struct request_list *rl = &q->rq; 2065 struct request_list *rl = &q->rq;
2066 struct io_context *ioc = NULL; 2066 struct io_context *ioc = NULL;
2067 const int rw = rw_flags & 0x01;
2067 int may_queue, priv; 2068 int may_queue, priv;
2068 2069
2069 may_queue = elv_may_queue(q, rw); 2070 may_queue = elv_may_queue(q, rw_flags);
2070 if (may_queue == ELV_MQUEUE_NO) 2071 if (may_queue == ELV_MQUEUE_NO)
2071 goto rq_starved; 2072 goto rq_starved;
2072 2073
@@ -2114,7 +2115,7 @@ static struct request *get_request(request_queue_t *q, int rw, struct bio *bio,
2114 2115
2115 spin_unlock_irq(q->queue_lock); 2116 spin_unlock_irq(q->queue_lock);
2116 2117
2117 rq = blk_alloc_request(q, rw, priv, gfp_mask); 2118 rq = blk_alloc_request(q, rw_flags, priv, gfp_mask);
2118 if (unlikely(!rq)) { 2119 if (unlikely(!rq)) {
2119 /* 2120 /*
2120 * Allocation failed presumably due to memory. Undo anything 2121 * Allocation failed presumably due to memory. Undo anything
@@ -2162,12 +2163,13 @@ out:
2162 * 2163 *
2163 * Called with q->queue_lock held, and returns with it unlocked. 2164 * Called with q->queue_lock held, and returns with it unlocked.
2164 */ 2165 */
2165static struct request *get_request_wait(request_queue_t *q, int rw, 2166static struct request *get_request_wait(request_queue_t *q, int rw_flags,
2166 struct bio *bio) 2167 struct bio *bio)
2167{ 2168{
2169 const int rw = rw_flags & 0x01;
2168 struct request *rq; 2170 struct request *rq;
2169 2171
2170 rq = get_request(q, rw, bio, GFP_NOIO); 2172 rq = get_request(q, rw_flags, bio, GFP_NOIO);
2171 while (!rq) { 2173 while (!rq) {
2172 DEFINE_WAIT(wait); 2174 DEFINE_WAIT(wait);
2173 struct request_list *rl = &q->rq; 2175 struct request_list *rl = &q->rq;
@@ -2175,7 +2177,7 @@ static struct request *get_request_wait(request_queue_t *q, int rw,
2175 prepare_to_wait_exclusive(&rl->wait[rw], &wait, 2177 prepare_to_wait_exclusive(&rl->wait[rw], &wait,
2176 TASK_UNINTERRUPTIBLE); 2178 TASK_UNINTERRUPTIBLE);
2177 2179
2178 rq = get_request(q, rw, bio, GFP_NOIO); 2180 rq = get_request(q, rw_flags, bio, GFP_NOIO);
2179 2181
2180 if (!rq) { 2182 if (!rq) {
2181 struct io_context *ioc; 2183 struct io_context *ioc;
@@ -2910,6 +2912,7 @@ static int __make_request(request_queue_t *q, struct bio *bio)
2910 int el_ret, nr_sectors, barrier, err; 2912 int el_ret, nr_sectors, barrier, err;
2911 const unsigned short prio = bio_prio(bio); 2913 const unsigned short prio = bio_prio(bio);
2912 const int sync = bio_sync(bio); 2914 const int sync = bio_sync(bio);
2915 int rw_flags;
2913 2916
2914 nr_sectors = bio_sectors(bio); 2917 nr_sectors = bio_sectors(bio);
2915 2918
@@ -2984,10 +2987,19 @@ static int __make_request(request_queue_t *q, struct bio *bio)
2984 2987
2985get_rq: 2988get_rq:
2986 /* 2989 /*
2990 * This sync check and mask will be re-done in init_request_from_bio(),
2991 * but we need to set it earlier to expose the sync flag to the
2992 * rq allocator and io schedulers.
2993 */
2994 rw_flags = bio_data_dir(bio);
2995 if (sync)
2996 rw_flags |= REQ_RW_SYNC;
2997
2998 /*
2987 * Grab a free request. This is might sleep but can not fail. 2999 * Grab a free request. This is might sleep but can not fail.
2988 * Returns with the queue unlocked. 3000 * Returns with the queue unlocked.
2989 */ 3001 */
2990 req = get_request_wait(q, bio_data_dir(bio), bio); 3002 req = get_request_wait(q, rw_flags, bio);
2991 3003
2992 /* 3004 /*
2993 * After dropping the lock and possibly sleeping here, our request 3005 * After dropping the lock and possibly sleeping here, our request
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
index 034c939bf91a..6e93004f2181 100644
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -17,7 +17,6 @@
17#include <linux/crypto.h> 17#include <linux/crypto.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/io.h>
21#include <linux/module.h> 20#include <linux/module.h>
22#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
23#include <linux/seq_file.h> 22#include <linux/seq_file.h>
diff --git a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c
index 048542341204..674bf81c6e66 100644
--- a/drivers/acorn/block/fd1772.c
+++ b/drivers/acorn/block/fd1772.c
@@ -1549,12 +1549,12 @@ int fd1772_init(void)
1549#ifdef TRACKBUFFER 1549#ifdef TRACKBUFFER
1550 BufferDrive = BufferSide = BufferTrack = -1; 1550 BufferDrive = BufferSide = BufferTrack = -1;
1551 /* Atari uses 512 - I want to eventually cope with 1K sectors */ 1551 /* Atari uses 512 - I want to eventually cope with 1K sectors */
1552 DMABuffer = (char *)kmalloc((FD1772_MAX_SECTORS+1)*512,GFP_KERNEL); 1552 DMABuffer = kmalloc((FD1772_MAX_SECTORS+1)*512,GFP_KERNEL);
1553 TrackBuffer = DMABuffer + 512; 1553 TrackBuffer = DMABuffer + 512;
1554#else 1554#else
1555 /* Allocate memory for the DMAbuffer - on the Atari this takes it 1555 /* Allocate memory for the DMAbuffer - on the Atari this takes it
1556 out of some special memory... */ 1556 out of some special memory... */
1557 DMABuffer = (char *) kmalloc(2048); /* Copes with pretty large sectors */ 1557 DMABuffer = kmalloc(2048); /* Copes with pretty large sectors */
1558#endif 1558#endif
1559 err = -ENOMEM; 1559 err = -ENOMEM;
1560 if (!DMAbuffer) 1560 if (!DMAbuffer)
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 984ab284382a..b34e0a958d0f 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -40,9 +40,9 @@ config ATA_PIIX
40 tristate "Intel PIIX/ICH SATA support" 40 tristate "Intel PIIX/ICH SATA support"
41 depends on PCI 41 depends on PCI
42 help 42 help
43 This option enables support for ICH5/6/7/8 Serial ATA. 43 This option enables support for ICH5/6/7/8 Serial ATA
44 If PATA support was enabled previously, this enables 44 and support for PATA on the Intel PIIX3/PIIX4/ICH series
45 support for select Intel PIIX/ICH PATA host controllers. 45 PATA host controllers.
46 46
47 If unsure, say N. 47 If unsure, say N.
48 48
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index f36da488a2c1..dbae6d971041 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -645,8 +645,6 @@ static int ahci_reset_controller(void __iomem *mmio, struct pci_dev *pdev)
645 u32 cap_save, impl_save, tmp; 645 u32 cap_save, impl_save, tmp;
646 646
647 cap_save = readl(mmio + HOST_CAP); 647 cap_save = readl(mmio + HOST_CAP);
648 cap_save &= ( (1<<28) | (1<<17) );
649 cap_save |= (1 << 27);
650 impl_save = readl(mmio + HOST_PORTS_IMPL); 648 impl_save = readl(mmio + HOST_PORTS_IMPL);
651 649
652 /* global controller reset */ 650 /* global controller reset */
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index c7de0bb1591f..47701b286f8b 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -226,14 +226,26 @@ static const struct pci_device_id piix_pci_tbl[] = {
226 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 226 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
227 /* 2801GBM/GHM (ICH7M, identical to ICH6M) */ 227 /* 2801GBM/GHM (ICH7M, identical to ICH6M) */
228 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci }, 228 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci },
229 /* Enterprise Southbridge 2 (where's the datasheet?) */ 229 /* Enterprise Southbridge 2 (631xESB/632xESB) */
230 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 230 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
231 /* SATA Controller 1 IDE (ICH8, no datasheet yet) */ 231 /* SATA Controller 1 IDE (ICH8) */
232 { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, 232 { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
233 /* SATA Controller 2 IDE (ICH8, ditto) */ 233 /* SATA Controller 2 IDE (ICH8) */
234 { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, 234 { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
235 /* Mobile SATA Controller IDE (ICH8M, ditto) */ 235 /* Mobile SATA Controller IDE (ICH8M) */
236 { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, 236 { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
237 /* SATA Controller IDE (ICH9) */
238 { 0x8086, 0x2920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
239 /* SATA Controller IDE (ICH9) */
240 { 0x8086, 0x2921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
241 /* SATA Controller IDE (ICH9) */
242 { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
243 /* SATA Controller IDE (ICH9M) */
244 { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
245 /* SATA Controller IDE (ICH9M) */
246 { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
247 /* SATA Controller IDE (ICH9M) */
248 { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
237 249
238 { } /* terminate list */ 250 { } /* terminate list */
239}; 251};
@@ -330,7 +342,7 @@ static const struct ata_port_operations ich_pata_ops = {
330 342
331 .port_start = ata_port_start, 343 .port_start = ata_port_start,
332 .port_stop = ata_port_stop, 344 .port_stop = ata_port_stop,
333 .host_stop = ata_host_stop, 345 .host_stop = piix_host_stop,
334}; 346};
335 347
336static const struct ata_port_operations piix_sata_ops = { 348static const struct ata_port_operations piix_sata_ops = {
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 011c0a8a2dcc..0d51d13b16bf 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1332,7 +1332,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
1332} 1332}
1333 1333
1334/** 1334/**
1335 * ata_exec_internal_sg - execute libata internal command 1335 * ata_exec_internal - execute libata internal command
1336 * @dev: Device to which the command is sent 1336 * @dev: Device to which the command is sent
1337 * @tf: Taskfile registers for the command and the result 1337 * @tf: Taskfile registers for the command and the result
1338 * @cdb: CDB for packet command 1338 * @cdb: CDB for packet command
@@ -1353,11 +1353,17 @@ unsigned ata_exec_internal(struct ata_device *dev,
1353 struct ata_taskfile *tf, const u8 *cdb, 1353 struct ata_taskfile *tf, const u8 *cdb,
1354 int dma_dir, void *buf, unsigned int buflen) 1354 int dma_dir, void *buf, unsigned int buflen)
1355{ 1355{
1356 struct scatterlist sg; 1356 struct scatterlist *psg = NULL, sg;
1357 unsigned int n_elem = 0;
1357 1358
1358 sg_init_one(&sg, buf, buflen); 1359 if (dma_dir != DMA_NONE) {
1360 WARN_ON(!buf);
1361 sg_init_one(&sg, buf, buflen);
1362 psg = &sg;
1363 n_elem++;
1364 }
1359 1365
1360 return ata_exec_internal_sg(dev, tf, cdb, dma_dir, &sg, 1); 1366 return ata_exec_internal_sg(dev, tf, cdb, dma_dir, psg, n_elem);
1361} 1367}
1362 1368
1363/** 1369/**
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 664e1377b54c..a4790be41d1c 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1539,7 +1539,7 @@ static unsigned int ata_scsi_rbuf_get(struct scsi_cmnd *cmd, u8 **buf_out)
1539 struct scatterlist *sg; 1539 struct scatterlist *sg;
1540 1540
1541 sg = (struct scatterlist *) cmd->request_buffer; 1541 sg = (struct scatterlist *) cmd->request_buffer;
1542 buf = kmap_atomic(sg->page, KM_USER0) + sg->offset; 1542 buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
1543 buflen = sg->length; 1543 buflen = sg->length;
1544 } else { 1544 } else {
1545 buf = cmd->request_buffer; 1545 buf = cmd->request_buffer;
@@ -1567,7 +1567,7 @@ static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf)
1567 struct scatterlist *sg; 1567 struct scatterlist *sg;
1568 1568
1569 sg = (struct scatterlist *) cmd->request_buffer; 1569 sg = (struct scatterlist *) cmd->request_buffer;
1570 kunmap_atomic(buf - sg->offset, KM_USER0); 1570 kunmap_atomic(buf - sg->offset, KM_IRQ0);
1571 } 1571 }
1572} 1572}
1573 1573
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index c7d1738e4e69..e7bf9d89c8ee 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -698,8 +698,10 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
698 goto fail_io; 698 goto fail_io;
699 699
700 pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0); 700 pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0);
701 if (pdev == NULL) 701 if (IS_ERR(pdev)) {
702 ret = PTR_ERR(pdev);
702 goto fail_dev; 703 goto fail_dev;
704 }
703 705
704 if (ht6560a & mask) { 706 if (ht6560a & mask) {
705 ops = &ht6560a_port_ops; 707 ops = &ht6560a_port_ops;
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index 36f621abc390..afc0d990e7d6 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -247,8 +247,8 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
247 */ 247 */
248 248
249 pdev = platform_device_register_simple(DRV_NAME, nr_qdi_host, NULL, 0); 249 pdev = platform_device_register_simple(DRV_NAME, nr_qdi_host, NULL, 0);
250 if (pdev == NULL) 250 if (IS_ERR(pdev))
251 return -ENOMEM; 251 return PTR_ERR(pdev);
252 252
253 memset(&ae, 0, sizeof(struct ata_probe_ent)); 253 memset(&ae, 0, sizeof(struct ata_probe_ent));
254 INIT_LIST_HEAD(&ae.node); 254 INIT_LIST_HEAD(&ae.node);
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 3677c642c9f9..adf4cc134f25 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -105,8 +105,6 @@ static struct ata_port_operations rz1000_port_ops = {
105 .exec_command = ata_exec_command, 105 .exec_command = ata_exec_command,
106 .dev_select = ata_std_dev_select, 106 .dev_select = ata_std_dev_select,
107 107
108 .error_handler = rz1000_error_handler,
109
110 .bmdma_setup = ata_bmdma_setup, 108 .bmdma_setup = ata_bmdma_setup,
111 .bmdma_start = ata_bmdma_start, 109 .bmdma_start = ata_bmdma_start,
112 .bmdma_stop = ata_bmdma_stop, 110 .bmdma_stop = ata_bmdma_stop,
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index cc09d47fb927..ff93e8f71cf8 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -161,10 +161,15 @@ static int via_pre_reset(struct ata_port *ap)
161 return -ENOENT; 161 return -ENOENT;
162 } 162 }
163 163
164 if ((config->flags & VIA_UDMA) >= VIA_UDMA_66) 164 if ((config->flags & VIA_UDMA) >= VIA_UDMA_100)
165 ap->cbl = via_cable_detect(ap); 165 ap->cbl = via_cable_detect(ap);
166 else 166 /* The UDMA66 series has no cable detect so do drive side detect */
167 else if ((config->flags & VIA_UDMA) < VIA_UDMA_66)
167 ap->cbl = ATA_CBL_PATA40; 168 ap->cbl = ATA_CBL_PATA40;
169 else
170 ap->cbl = ATA_CBL_PATA_UNK;
171
172
168 return ata_std_prereset(ap); 173 return ata_std_prereset(ap);
169} 174}
170 175
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c
index 3ea345cde52e..5d1f518e1cc7 100644
--- a/drivers/ata/pata_winbond.c
+++ b/drivers/ata/pata_winbond.c
@@ -206,8 +206,8 @@ static __init int winbond_init_one(unsigned long port)
206 */ 206 */
207 207
208 pdev = platform_device_register_simple(DRV_NAME, nr_winbond_host, NULL, 0); 208 pdev = platform_device_register_simple(DRV_NAME, nr_winbond_host, NULL, 0);
209 if (pdev == NULL) 209 if (IS_ERR(pdev))
210 return -ENOMEM; 210 return PTR_ERR(pdev);
211 211
212 memset(&ae, 0, sizeof(struct ata_probe_ent)); 212 memset(&ae, 0, sizeof(struct ata_probe_ent));
213 INIT_LIST_HEAD(&ae.node); 213 INIT_LIST_HEAD(&ae.node);
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c
index 9021e34d2096..90786d7a20bb 100644
--- a/drivers/ata/pdc_adma.c
+++ b/drivers/ata/pdc_adma.c
@@ -551,7 +551,7 @@ static int adma_port_start(struct ata_port *ap)
551 return rc; 551 return rc;
552 adma_enter_reg_mode(ap); 552 adma_enter_reg_mode(ap);
553 rc = -ENOMEM; 553 rc = -ENOMEM;
554 pp = kcalloc(1, sizeof(*pp), GFP_KERNEL); 554 pp = kzalloc(sizeof(*pp), GFP_KERNEL);
555 if (!pp) 555 if (!pp)
556 goto err_out; 556 goto err_out;
557 pp->pkt = dma_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma, 557 pp->pkt = dma_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma,
@@ -672,7 +672,7 @@ static int adma_ata_init_one(struct pci_dev *pdev,
672 if (rc) 672 if (rc)
673 goto err_out_iounmap; 673 goto err_out_iounmap;
674 674
675 probe_ent = kcalloc(1, sizeof(*probe_ent), GFP_KERNEL); 675 probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
676 if (probe_ent == NULL) { 676 if (probe_ent == NULL) {
677 rc = -ENOMEM; 677 rc = -ENOMEM;
678 goto err_out_iounmap; 678 goto err_out_iounmap;
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index db32d15b7fa1..d89c9590b845 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -56,6 +56,8 @@
56#define DRV_VERSION "2.0" 56#define DRV_VERSION "2.0"
57 57
58enum { 58enum {
59 K2_FLAG_NO_ATAPI_DMA = (1 << 29),
60
59 /* Taskfile registers offsets */ 61 /* Taskfile registers offsets */
60 K2_SATA_TF_CMD_OFFSET = 0x00, 62 K2_SATA_TF_CMD_OFFSET = 0x00,
61 K2_SATA_TF_DATA_OFFSET = 0x00, 63 K2_SATA_TF_DATA_OFFSET = 0x00,
@@ -83,11 +85,33 @@ enum {
83 85
84 /* Port stride */ 86 /* Port stride */
85 K2_SATA_PORT_OFFSET = 0x100, 87 K2_SATA_PORT_OFFSET = 0x100,
88
89 board_svw4 = 0,
90 board_svw8 = 1,
91};
92
93static const struct k2_board_info {
94 unsigned int n_ports;
95 unsigned long port_flags;
96} k2_board_info[] = {
97 /* board_svw4 */
98 { 4, K2_FLAG_NO_ATAPI_DMA },
99
100 /* board_svw8 */
101 { 8, K2_FLAG_NO_ATAPI_DMA },
86}; 102};
87 103
88static u8 k2_stat_check_status(struct ata_port *ap); 104static u8 k2_stat_check_status(struct ata_port *ap);
89 105
90 106
107static int k2_sata_check_atapi_dma(struct ata_queued_cmd *qc)
108{
109 if (qc->ap->flags & K2_FLAG_NO_ATAPI_DMA)
110 return -1; /* ATAPI DMA not supported */
111
112 return 0;
113}
114
91static u32 k2_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) 115static u32 k2_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
92{ 116{
93 if (sc_reg > SCR_CONTROL) 117 if (sc_reg > SCR_CONTROL)
@@ -313,6 +337,7 @@ static const struct ata_port_operations k2_sata_ops = {
313 .check_status = k2_stat_check_status, 337 .check_status = k2_stat_check_status,
314 .exec_command = ata_exec_command, 338 .exec_command = ata_exec_command,
315 .dev_select = ata_std_dev_select, 339 .dev_select = ata_std_dev_select,
340 .check_atapi_dma = k2_sata_check_atapi_dma,
316 .bmdma_setup = k2_bmdma_setup_mmio, 341 .bmdma_setup = k2_bmdma_setup_mmio,
317 .bmdma_start = k2_bmdma_start_mmio, 342 .bmdma_start = k2_bmdma_start_mmio,
318 .bmdma_stop = ata_bmdma_stop, 343 .bmdma_stop = ata_bmdma_stop,
@@ -359,6 +384,8 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
359 struct ata_probe_ent *probe_ent = NULL; 384 struct ata_probe_ent *probe_ent = NULL;
360 unsigned long base; 385 unsigned long base;
361 void __iomem *mmio_base; 386 void __iomem *mmio_base;
387 const struct k2_board_info *board_info =
388 &k2_board_info[ent->driver_data];
362 int pci_dev_busy = 0; 389 int pci_dev_busy = 0;
363 int rc; 390 int rc;
364 int i; 391 int i;
@@ -424,7 +451,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
424 451
425 probe_ent->sht = &k2_sata_sht; 452 probe_ent->sht = &k2_sata_sht;
426 probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 453 probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
427 ATA_FLAG_MMIO; 454 ATA_FLAG_MMIO | board_info->port_flags;
428 probe_ent->port_ops = &k2_sata_ops; 455 probe_ent->port_ops = &k2_sata_ops;
429 probe_ent->n_ports = 4; 456 probe_ent->n_ports = 4;
430 probe_ent->irq = pdev->irq; 457 probe_ent->irq = pdev->irq;
@@ -441,7 +468,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
441 /* different controllers have different number of ports - currently 4 or 8 */ 468 /* different controllers have different number of ports - currently 4 or 8 */
442 /* All ports are on the same function. Multi-function device is no 469 /* All ports are on the same function. Multi-function device is no
443 * longer available. This should not be seen in any system. */ 470 * longer available. This should not be seen in any system. */
444 for (i = 0; i < ent->driver_data; i++) 471 for (i = 0; i < board_info->n_ports; i++)
445 k2_sata_setup_port(&probe_ent->port[i], base + i * K2_SATA_PORT_OFFSET); 472 k2_sata_setup_port(&probe_ent->port[i], base + i * K2_SATA_PORT_OFFSET);
446 473
447 pci_set_master(pdev); 474 pci_set_master(pdev);
@@ -469,11 +496,11 @@ err_out:
469 * controller 496 * controller
470 * */ 497 * */
471static const struct pci_device_id k2_sata_pci_tbl[] = { 498static const struct pci_device_id k2_sata_pci_tbl[] = {
472 { PCI_VDEVICE(SERVERWORKS, 0x0240), 4 }, 499 { PCI_VDEVICE(SERVERWORKS, 0x0240), board_svw4 },
473 { PCI_VDEVICE(SERVERWORKS, 0x0241), 4 }, 500 { PCI_VDEVICE(SERVERWORKS, 0x0241), board_svw4 },
474 { PCI_VDEVICE(SERVERWORKS, 0x0242), 8 }, 501 { PCI_VDEVICE(SERVERWORKS, 0x0242), board_svw8 },
475 { PCI_VDEVICE(SERVERWORKS, 0x024a), 4 }, 502 { PCI_VDEVICE(SERVERWORKS, 0x024a), board_svw4 },
476 { PCI_VDEVICE(SERVERWORKS, 0x024b), 4 }, 503 { PCI_VDEVICE(SERVERWORKS, 0x024b), board_svw4 },
477 504
478 { } 505 { }
479}; 506};
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index bc1b13c8f5d7..5aab7bd473ac 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -1832,7 +1832,7 @@ static int __devinit eni_start(struct atm_dev *dev)
1832 /* initialize memory management */ 1832 /* initialize memory management */
1833 buffer_mem = eni_dev->mem - (buf - eni_dev->ram); 1833 buffer_mem = eni_dev->mem - (buf - eni_dev->ram);
1834 eni_dev->free_list_size = buffer_mem/MID_MIN_BUF_SIZE/2; 1834 eni_dev->free_list_size = buffer_mem/MID_MIN_BUF_SIZE/2;
1835 eni_dev->free_list = (struct eni_free *) kmalloc( 1835 eni_dev->free_list = kmalloc(
1836 sizeof(struct eni_free)*(eni_dev->free_list_size+1),GFP_KERNEL); 1836 sizeof(struct eni_free)*(eni_dev->free_list_size+1),GFP_KERNEL);
1837 if (!eni_dev->free_list) { 1837 if (!eni_dev->free_list) {
1838 printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n", 1838 printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n",
@@ -2232,7 +2232,7 @@ static int __devinit eni_init_one(struct pci_dev *pci_dev,
2232 goto out0; 2232 goto out0;
2233 } 2233 }
2234 2234
2235 eni_dev = (struct eni_dev *) kmalloc(sizeof(struct eni_dev),GFP_KERNEL); 2235 eni_dev = kmalloc(sizeof(struct eni_dev),GFP_KERNEL);
2236 if (!eni_dev) goto out0; 2236 if (!eni_dev) goto out0;
2237 if (!cpu_zeroes) { 2237 if (!cpu_zeroes) {
2238 cpu_zeroes = pci_alloc_consistent(pci_dev,ENI_ZEROES_SIZE, 2238 cpu_zeroes = pci_alloc_consistent(pci_dev,ENI_ZEROES_SIZE,
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index 7d9b4e52f0bf..db33f6f4dd2a 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -2351,7 +2351,7 @@ he_open(struct atm_vcc *vcc)
2351 2351
2352 cid = he_mkcid(he_dev, vpi, vci); 2352 cid = he_mkcid(he_dev, vpi, vci);
2353 2353
2354 he_vcc = (struct he_vcc *) kmalloc(sizeof(struct he_vcc), GFP_ATOMIC); 2354 he_vcc = kmalloc(sizeof(struct he_vcc), GFP_ATOMIC);
2355 if (he_vcc == NULL) { 2355 if (he_vcc == NULL) {
2356 hprintk("unable to allocate he_vcc during open\n"); 2356 hprintk("unable to allocate he_vcc during open\n");
2357 return -ENOMEM; 2357 return -ENOMEM;
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index 267825501dfe..09f477d4237a 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -2602,7 +2602,7 @@ static int __devinit lanai_init_one(struct pci_dev *pci,
2602 struct atm_dev *atmdev; 2602 struct atm_dev *atmdev;
2603 int result; 2603 int result;
2604 2604
2605 lanai = (struct lanai_dev *) kmalloc(sizeof(*lanai), GFP_KERNEL); 2605 lanai = kmalloc(sizeof(*lanai), GFP_KERNEL);
2606 if (lanai == NULL) { 2606 if (lanai == NULL) {
2607 printk(KERN_ERR DEV_LABEL 2607 printk(KERN_ERR DEV_LABEL
2608 ": couldn't allocate dev_data structure!\n"); 2608 ": couldn't allocate dev_data structure!\n");
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index bd0904594805..aab9b3733d52 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -997,7 +997,7 @@ static scq_info *get_scq(int size, u32 scd)
997 if (size != VBR_SCQSIZE && size != CBR_SCQSIZE) 997 if (size != VBR_SCQSIZE && size != CBR_SCQSIZE)
998 return NULL; 998 return NULL;
999 999
1000 scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL); 1000 scq = kmalloc(sizeof(scq_info), GFP_KERNEL);
1001 if (scq == NULL) 1001 if (scq == NULL)
1002 return NULL; 1002 return NULL;
1003 scq->org = kmalloc(2 * size, GFP_KERNEL); 1003 scq->org = kmalloc(2 * size, GFP_KERNEL);
@@ -1006,7 +1006,7 @@ static scq_info *get_scq(int size, u32 scd)
1006 kfree(scq); 1006 kfree(scq);
1007 return NULL; 1007 return NULL;
1008 } 1008 }
1009 scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) * 1009 scq->skb = kmalloc(sizeof(struct sk_buff *) *
1010 (size / NS_SCQE_SIZE), GFP_KERNEL); 1010 (size / NS_SCQE_SIZE), GFP_KERNEL);
1011 if (scq->skb == NULL) 1011 if (scq->skb == NULL)
1012 { 1012 {
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 7df0f373188e..756d4f760da3 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -996,7 +996,7 @@ static int start_tx(struct atm_dev *dev)
996 996
997 DPRINTK("start_tx\n"); 997 DPRINTK("start_tx\n");
998 zatm_dev = ZATM_DEV(dev); 998 zatm_dev = ZATM_DEV(dev);
999 zatm_dev->tx_map = (struct atm_vcc **) kmalloc(sizeof(struct atm_vcc *)* 999 zatm_dev->tx_map = kmalloc(sizeof(struct atm_vcc *)*
1000 zatm_dev->chans,GFP_KERNEL); 1000 zatm_dev->chans,GFP_KERNEL);
1001 if (!zatm_dev->tx_map) return -ENOMEM; 1001 if (!zatm_dev->tx_map) return -ENOMEM;
1002 zatm_dev->tx_bw = ATM_OC3_PCR; 1002 zatm_dev->tx_bw = ATM_OC3_PCR;
@@ -1591,7 +1591,7 @@ static int __devinit zatm_init_one(struct pci_dev *pci_dev,
1591 struct zatm_dev *zatm_dev; 1591 struct zatm_dev *zatm_dev;
1592 int ret = -ENOMEM; 1592 int ret = -ENOMEM;
1593 1593
1594 zatm_dev = (struct zatm_dev *) kmalloc(sizeof(*zatm_dev), GFP_KERNEL); 1594 zatm_dev = kmalloc(sizeof(*zatm_dev), GFP_KERNEL);
1595 if (!zatm_dev) { 1595 if (!zatm_dev) {
1596 printk(KERN_EMERG "%s: memory shortage\n", DEV_LABEL); 1596 printk(KERN_EMERG "%s: memory shortage\n", DEV_LABEL);
1597 goto out; 1597 goto out;
diff --git a/drivers/base/class.c b/drivers/base/class.c
index f098881f45b2..8bf2ca2e56b5 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -163,6 +163,8 @@ int class_register(struct class * cls)
163void class_unregister(struct class * cls) 163void class_unregister(struct class * cls)
164{ 164{
165 pr_debug("device class '%s': unregistering\n", cls->name); 165 pr_debug("device class '%s': unregistering\n", cls->name);
166 if (cls->virtual_dir)
167 kobject_unregister(cls->virtual_dir);
166 remove_class_attrs(cls); 168 remove_class_attrs(cls);
167 subsystem_unregister(&cls->subsys); 169 subsystem_unregister(&cls->subsys);
168} 170}
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index dbe0735f8c9e..f95d50277274 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -173,7 +173,7 @@ pool_alloc_page (struct dma_pool *pool, gfp_t mem_flags)
173 mapsize = (mapsize + BITS_PER_LONG - 1) / BITS_PER_LONG; 173 mapsize = (mapsize + BITS_PER_LONG - 1) / BITS_PER_LONG;
174 mapsize *= sizeof (long); 174 mapsize *= sizeof (long);
175 175
176 page = (struct dma_page *) kmalloc (mapsize + sizeof *page, mem_flags); 176 page = kmalloc(mapsize + sizeof *page, mem_flags);
177 if (!page) 177 if (!page)
178 return NULL; 178 return NULL;
179 page->vaddr = dma_alloc_coherent (pool->dev, 179 page->vaddr = dma_alloc_coherent (pool->dev,
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index d1df4a087924..f9c903ba9fcd 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(platform_device_add_resources);
212 * pointer. The memory associated with the platform data will be freed 212 * pointer. The memory associated with the platform data will be freed
213 * when the platform device is released. 213 * when the platform device is released.
214 */ 214 */
215int platform_device_add_data(struct platform_device *pdev, void *data, size_t size) 215int platform_device_add_data(struct platform_device *pdev, const void *data, size_t size)
216{ 216{
217 void *d; 217 void *d;
218 218
@@ -473,7 +473,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister);
473 * Returns zero if the driver registered and bound to a device, else returns 473 * Returns zero if the driver registered and bound to a device, else returns
474 * a negative error code and with the driver not registered. 474 * a negative error code and with the driver not registered.
475 */ 475 */
476int platform_driver_probe(struct platform_driver *drv, 476int __init_or_module platform_driver_probe(struct platform_driver *drv,
477 int (*probe)(struct platform_device *)) 477 int (*probe)(struct platform_device *))
478{ 478{
479 int retval, code; 479 int retval, code;
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index ce9cfcb6071c..58c1debf86f1 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -28,13 +28,6 @@ config ATARI_FLOPPY
28 tristate "Atari floppy support" 28 tristate "Atari floppy support"
29 depends on ATARI 29 depends on ATARI
30 30
31config BLK_DEV_SWIM_IOP
32 bool "Macintosh IIfx/Quadra 900/Quadra 950 floppy support (EXPERIMENTAL)"
33 depends on MAC && EXPERIMENTAL && BROKEN
34 help
35 Say Y here to support the SWIM (Super Woz Integrated Machine) IOP
36 floppy controller on the Macintosh IIfx and Quadra 900/950.
37
38config MAC_FLOPPY 31config MAC_FLOPPY
39 tristate "Support for PowerMac floppy" 32 tristate "Support for PowerMac floppy"
40 depends on PPC_PMAC && !PPC_PMAC64 33 depends on PPC_PMAC && !PPC_PMAC64
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 410f259a8031..dd88e33c1eb1 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -9,7 +9,6 @@ obj-$(CONFIG_MAC_FLOPPY) += swim3.o
9obj-$(CONFIG_BLK_DEV_FD) += floppy.o 9obj-$(CONFIG_BLK_DEV_FD) += floppy.o
10obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o 10obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o
11obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o 11obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o
12obj-$(CONFIG_BLK_DEV_SWIM_IOP) += swim_iop.o
13obj-$(CONFIG_ATARI_ACSI) += acsi.o 12obj-$(CONFIG_ATARI_ACSI) += acsi.o
14obj-$(CONFIG_ATARI_SLM) += acsi_slm.o 13obj-$(CONFIG_ATARI_SLM) += acsi_slm.o
15obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o 14obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index ee159edb6b88..d719a5d8f435 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1039,7 +1039,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
1039 status = -ENOMEM; 1039 status = -ENOMEM;
1040 goto cleanup1; 1040 goto cleanup1;
1041 } 1041 }
1042 buff_size = (int *)kmalloc(MAXSGENTRIES * sizeof(int), 1042 buff_size = kmalloc(MAXSGENTRIES * sizeof(int),
1043 GFP_KERNEL); 1043 GFP_KERNEL);
1044 if (!buff_size) { 1044 if (!buff_size) {
1045 status = -ENOMEM; 1045 status = -ENOMEM;
@@ -2837,7 +2837,7 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2837 if (err) { 2837 if (err) {
2838 printk(KERN_ERR "cciss: Cannot obtain PCI resources, " 2838 printk(KERN_ERR "cciss: Cannot obtain PCI resources, "
2839 "aborting\n"); 2839 "aborting\n");
2840 goto err_out_disable_pdev; 2840 return err;
2841 } 2841 }
2842 2842
2843 subsystem_vendor_id = pdev->subsystem_vendor; 2843 subsystem_vendor_id = pdev->subsystem_vendor;
@@ -2865,7 +2865,7 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2865#ifdef CCISS_DEBUG 2865#ifdef CCISS_DEBUG
2866 printk("address 0 = %x\n", c->paddr); 2866 printk("address 0 = %x\n", c->paddr);
2867#endif /* CCISS_DEBUG */ 2867#endif /* CCISS_DEBUG */
2868 c->vaddr = remap_pci_mem(c->paddr, 200); 2868 c->vaddr = remap_pci_mem(c->paddr, 0x250);
2869 2869
2870 /* Wait for the board to become ready. (PCI hotplug needs this.) 2870 /* Wait for the board to become ready. (PCI hotplug needs this.)
2871 * We poll for up to 120 secs, once per 100ms. */ 2871 * We poll for up to 120 secs, once per 100ms. */
@@ -3004,11 +3004,12 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
3004 } 3004 }
3005 return 0; 3005 return 0;
3006 3006
3007 err_out_free_res: 3007err_out_free_res:
3008 /*
3009 * Deliberately omit pci_disable_device(): it does something nasty to
3010 * Smart Array controllers that pci_enable_device does not undo
3011 */
3008 pci_release_regions(pdev); 3012 pci_release_regions(pdev);
3009
3010 err_out_disable_pdev:
3011 pci_disable_device(pdev);
3012 return err; 3013 return err;
3013} 3014}
3014 3015
@@ -3382,8 +3383,11 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3382 if (drv->queue) 3383 if (drv->queue)
3383 blk_cleanup_queue(drv->queue); 3384 blk_cleanup_queue(drv->queue);
3384 } 3385 }
3386 /*
3387 * Deliberately omit pci_disable_device(): it does something nasty to
3388 * Smart Array controllers that pci_enable_device does not undo
3389 */
3385 pci_release_regions(pdev); 3390 pci_release_regions(pdev);
3386 pci_disable_device(pdev);
3387 pci_set_drvdata(pdev, NULL); 3391 pci_set_drvdata(pdev, NULL);
3388 free_hba(i); 3392 free_hba(i);
3389 return -1; 3393 return -1;
@@ -3452,8 +3456,11 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
3452#ifdef CONFIG_CISS_SCSI_TAPE 3456#ifdef CONFIG_CISS_SCSI_TAPE
3453 kfree(hba[i]->scsi_rejects.complete); 3457 kfree(hba[i]->scsi_rejects.complete);
3454#endif 3458#endif
3459 /*
3460 * Deliberately omit pci_disable_device(): it does something nasty to
3461 * Smart Array controllers that pci_enable_device does not undo
3462 */
3455 pci_release_regions(pdev); 3463 pci_release_regions(pdev);
3456 pci_disable_device(pdev);
3457 pci_set_drvdata(pdev, NULL); 3464 pci_set_drvdata(pdev, NULL);
3458 free_hba(i); 3465 free_hba(i);
3459} 3466}
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index d5f519ebbc08..b94cd1c32131 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -1625,7 +1625,7 @@ static void start_fwbk(int ctlr)
1625 " processing\n"); 1625 " processing\n");
1626 /* Command does not return anything, but idasend command needs a 1626 /* Command does not return anything, but idasend command needs a
1627 buffer */ 1627 buffer */
1628 id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); 1628 id_ctlr_buf = kmalloc(sizeof(id_ctlr_t), GFP_KERNEL);
1629 if(id_ctlr_buf==NULL) 1629 if(id_ctlr_buf==NULL)
1630 { 1630 {
1631 printk(KERN_WARNING "cpqarray: Out of memory. " 1631 printk(KERN_WARNING "cpqarray: Out of memory. "
@@ -1660,14 +1660,14 @@ static void getgeometry(int ctlr)
1660 1660
1661 info_p->log_drv_map = 0; 1661 info_p->log_drv_map = 0;
1662 1662
1663 id_ldrive = (id_log_drv_t *)kmalloc(sizeof(id_log_drv_t), GFP_KERNEL); 1663 id_ldrive = kmalloc(sizeof(id_log_drv_t), GFP_KERNEL);
1664 if(id_ldrive == NULL) 1664 if(id_ldrive == NULL)
1665 { 1665 {
1666 printk( KERN_ERR "cpqarray: out of memory.\n"); 1666 printk( KERN_ERR "cpqarray: out of memory.\n");
1667 return; 1667 return;
1668 } 1668 }
1669 1669
1670 id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); 1670 id_ctlr_buf = kmalloc(sizeof(id_ctlr_t), GFP_KERNEL);
1671 if(id_ctlr_buf == NULL) 1671 if(id_ctlr_buf == NULL)
1672 { 1672 {
1673 kfree(id_ldrive); 1673 kfree(id_ldrive);
@@ -1675,7 +1675,7 @@ static void getgeometry(int ctlr)
1675 return; 1675 return;
1676 } 1676 }
1677 1677
1678 id_lstatus_buf = (sense_log_drv_stat_t *)kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL); 1678 id_lstatus_buf = kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL);
1679 if(id_lstatus_buf == NULL) 1679 if(id_lstatus_buf == NULL)
1680 { 1680 {
1681 kfree(id_ctlr_buf); 1681 kfree(id_ctlr_buf);
@@ -1684,7 +1684,7 @@ static void getgeometry(int ctlr)
1684 return; 1684 return;
1685 } 1685 }
1686 1686
1687 sense_config_buf = (config_t *)kmalloc(sizeof(config_t), GFP_KERNEL); 1687 sense_config_buf = kmalloc(sizeof(config_t), GFP_KERNEL);
1688 if(sense_config_buf == NULL) 1688 if(sense_config_buf == NULL)
1689 { 1689 {
1690 kfree(id_lstatus_buf); 1690 kfree(id_lstatus_buf);
diff --git a/drivers/block/swim_iop.c b/drivers/block/swim_iop.c
deleted file mode 100644
index ed7b06cf3e68..000000000000
--- a/drivers/block/swim_iop.c
+++ /dev/null
@@ -1,578 +0,0 @@
1/*
2 * Driver for the SWIM (Super Woz Integrated Machine) IOP
3 * floppy controller on the Macintosh IIfx and Quadra 900/950
4 *
5 * Written by Joshua M. Thompson (funaho@jurai.org)
6 * based on the SWIM3 driver (c) 1996 by Paul Mackerras.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 *
13 * 1999-06-12 (jmt) - Initial implementation.
14 */
15
16/*
17 * -------------------
18 * Theory of Operation
19 * -------------------
20 *
21 * Since the SWIM IOP is message-driven we implement a simple request queue
22 * system. One outstanding request may be queued at any given time (this is
23 * an IOP limitation); only when that request has completed can a new request
24 * be sent.
25 */
26
27#include <linux/stddef.h>
28#include <linux/kernel.h>
29#include <linux/sched.h>
30#include <linux/timer.h>
31#include <linux/delay.h>
32#include <linux/fd.h>
33#include <linux/ioctl.h>
34#include <linux/blkdev.h>
35#include <asm/io.h>
36#include <asm/uaccess.h>
37#include <asm/mac_iop.h>
38#include <asm/swim_iop.h>
39
40#define DRIVER_VERSION "Version 0.1 (1999-06-12)"
41
42#define MAX_FLOPPIES 4
43
44enum swim_state {
45 idle,
46 available,
47 revalidating,
48 transferring,
49 ejecting
50};
51
52struct floppy_state {
53 enum swim_state state;
54 int drive_num; /* device number */
55 int secpercyl; /* disk geometry information */
56 int secpertrack;
57 int total_secs;
58 int write_prot; /* 1 if write-protected, 0 if not, -1 dunno */
59 int ref_count;
60 struct timer_list timeout;
61 int ejected;
62 struct wait_queue *wait;
63 int wanted;
64 int timeout_pending;
65};
66
67struct swim_iop_req {
68 int sent;
69 int complete;
70 __u8 command[32];
71 struct floppy_state *fs;
72 void (*done)(struct swim_iop_req *);
73};
74
75static struct swim_iop_req *current_req;
76static int floppy_count;
77
78static struct floppy_state floppy_states[MAX_FLOPPIES];
79static DEFINE_SPINLOCK(swim_iop_lock);
80
81#define CURRENT elv_next_request(swim_queue)
82
83static char *drive_names[7] = {
84 "not installed", /* DRV_NONE */
85 "unknown (1)", /* DRV_UNKNOWN */
86 "a 400K drive", /* DRV_400K */
87 "an 800K drive" /* DRV_800K */
88 "unknown (4)", /* ???? */
89 "an FDHD", /* DRV_FDHD */
90 "unknown (6)", /* ???? */
91 "an Apple HD20" /* DRV_HD20 */
92};
93
94int swimiop_init(void);
95static void swimiop_init_request(struct swim_iop_req *);
96static int swimiop_send_request(struct swim_iop_req *);
97static void swimiop_receive(struct iop_msg *);
98static void swimiop_status_update(int, struct swim_drvstatus *);
99static int swimiop_eject(struct floppy_state *fs);
100
101static int floppy_ioctl(struct inode *inode, struct file *filp,
102 unsigned int cmd, unsigned long param);
103static int floppy_open(struct inode *inode, struct file *filp);
104static int floppy_release(struct inode *inode, struct file *filp);
105static int floppy_check_change(struct gendisk *disk);
106static int floppy_revalidate(struct gendisk *disk);
107static int grab_drive(struct floppy_state *fs, enum swim_state state,
108 int interruptible);
109static void release_drive(struct floppy_state *fs);
110static void set_timeout(struct floppy_state *fs, int nticks,
111 void (*proc)(unsigned long));
112static void fd_request_timeout(unsigned long);
113static void do_fd_request(request_queue_t * q);
114static void start_request(struct floppy_state *fs);
115
116static struct block_device_operations floppy_fops = {
117 .open = floppy_open,
118 .release = floppy_release,
119 .ioctl = floppy_ioctl,
120 .media_changed = floppy_check_change,
121 .revalidate_disk= floppy_revalidate,
122};
123
124static struct request_queue *swim_queue;
125/*
126 * SWIM IOP initialization
127 */
128
129int swimiop_init(void)
130{
131 volatile struct swim_iop_req req;
132 struct swimcmd_status *cmd = (struct swimcmd_status *) &req.command[0];
133 struct swim_drvstatus *ds = &cmd->status;
134 struct floppy_state *fs;
135 int i;
136
137 current_req = NULL;
138 floppy_count = 0;
139
140 if (!iop_ism_present)
141 return -ENODEV;
142
143 if (register_blkdev(FLOPPY_MAJOR, "fd"))
144 return -EBUSY;
145
146 swim_queue = blk_init_queue(do_fd_request, &swim_iop_lock);
147 if (!swim_queue) {
148 unregister_blkdev(FLOPPY_MAJOR, "fd");
149 return -ENOMEM;
150 }
151
152 printk("SWIM-IOP: %s by Joshua M. Thompson (funaho@jurai.org)\n",
153 DRIVER_VERSION);
154
155 if (iop_listen(SWIM_IOP, SWIM_CHAN, swimiop_receive, "SWIM") != 0) {
156 printk(KERN_ERR "SWIM-IOP: IOP channel already in use; can't initialize.\n");
157 unregister_blkdev(FLOPPY_MAJOR, "fd");
158 blk_cleanup_queue(swim_queue);
159 return -EBUSY;
160 }
161
162 printk(KERN_ERR "SWIM_IOP: probing for installed drives.\n");
163
164 for (i = 0 ; i < MAX_FLOPPIES ; i++) {
165 memset(&floppy_states[i], 0, sizeof(struct floppy_state));
166 fs = &floppy_states[floppy_count];
167
168 swimiop_init_request(&req);
169 cmd->code = CMD_STATUS;
170 cmd->drive_num = i + 1;
171 if (swimiop_send_request(&req) != 0) continue;
172 while (!req.complete);
173 if (cmd->error != 0) {
174 printk(KERN_ERR "SWIM-IOP: probe on drive %d returned error %d\n", i, (uint) cmd->error);
175 continue;
176 }
177 if (ds->installed != 0x01) continue;
178 printk("SWIM-IOP: drive %d is %s (%s, %s, %s, %s)\n", i,
179 drive_names[ds->info.type],
180 ds->info.external? "ext" : "int",
181 ds->info.scsi? "scsi" : "floppy",
182 ds->info.fixed? "fixed" : "removable",
183 ds->info.secondary? "secondary" : "primary");
184 swimiop_status_update(floppy_count, ds);
185 fs->state = idle;
186
187 init_timer(&fs->timeout);
188 floppy_count++;
189 }
190 printk("SWIM-IOP: detected %d installed drives.\n", floppy_count);
191
192 for (i = 0; i < floppy_count; i++) {
193 struct gendisk *disk = alloc_disk(1);
194 if (!disk)
195 continue;
196 disk->major = FLOPPY_MAJOR;
197 disk->first_minor = i;
198 disk->fops = &floppy_fops;
199 sprintf(disk->disk_name, "fd%d", i);
200 disk->private_data = &floppy_states[i];
201 disk->queue = swim_queue;
202 set_capacity(disk, 2880 * 2);
203 add_disk(disk);
204 }
205
206 return 0;
207}
208
209static void swimiop_init_request(struct swim_iop_req *req)
210{
211 req->sent = 0;
212 req->complete = 0;
213 req->done = NULL;
214}
215
216static int swimiop_send_request(struct swim_iop_req *req)
217{
218 unsigned long flags;
219 int err;
220
221 /* It's doubtful an interrupt routine would try to send */
222 /* a SWIM request, but I'd rather play it safe here. */
223
224 local_irq_save(flags);
225
226 if (current_req != NULL) {
227 local_irq_restore(flags);
228 return -ENOMEM;
229 }
230
231 current_req = req;
232
233 /* Interrupts should be back on for iop_send_message() */
234
235 local_irq_restore(flags);
236
237 err = iop_send_message(SWIM_IOP, SWIM_CHAN, (void *) req,
238 sizeof(req->command), (__u8 *) &req->command[0],
239 swimiop_receive);
240
241 /* No race condition here; we own current_req at this point */
242
243 if (err) {
244 current_req = NULL;
245 } else {
246 req->sent = 1;
247 }
248 return err;
249}
250
251/*
252 * Receive a SWIM message from the IOP.
253 *
254 * This will be called in two cases:
255 *
256 * 1. A message has been successfully sent to the IOP.
257 * 2. An unsolicited message was received from the IOP.
258 */
259
260void swimiop_receive(struct iop_msg *msg)
261{
262 struct swim_iop_req *req;
263 struct swimmsg_status *sm;
264 struct swim_drvstatus *ds;
265
266 req = current_req;
267
268 switch(msg->status) {
269 case IOP_MSGSTATUS_COMPLETE:
270 memcpy(&req->command[0], &msg->reply[0], sizeof(req->command));
271 req->complete = 1;
272 if (req->done) (*req->done)(req);
273 current_req = NULL;
274 break;
275 case IOP_MSGSTATUS_UNSOL:
276 sm = (struct swimmsg_status *) &msg->message[0];
277 ds = &sm->status;
278 swimiop_status_update(sm->drive_num, ds);
279 iop_complete_message(msg);
280 break;
281 }
282}
283
284static void swimiop_status_update(int drive_num, struct swim_drvstatus *ds)
285{
286 struct floppy_state *fs = &floppy_states[drive_num];
287
288 fs->write_prot = (ds->write_prot == 0x80);
289 if ((ds->disk_in_drive != 0x01) && (ds->disk_in_drive != 0x02)) {
290 fs->ejected = 1;
291 } else {
292 fs->ejected = 0;
293 }
294 switch(ds->info.type) {
295 case DRV_400K:
296 fs->secpercyl = 10;
297 fs->secpertrack = 10;
298 fs->total_secs = 800;
299 break;
300 case DRV_800K:
301 fs->secpercyl = 20;
302 fs->secpertrack = 10;
303 fs->total_secs = 1600;
304 break;
305 case DRV_FDHD:
306 fs->secpercyl = 36;
307 fs->secpertrack = 18;
308 fs->total_secs = 2880;
309 break;
310 default:
311 fs->secpercyl = 0;
312 fs->secpertrack = 0;
313 fs->total_secs = 0;
314 break;
315 }
316}
317
318static int swimiop_eject(struct floppy_state *fs)
319{
320 int err, n;
321 struct swim_iop_req req;
322 struct swimcmd_eject *cmd = (struct swimcmd_eject *) &req.command[0];
323
324 err = grab_drive(fs, ejecting, 1);
325 if (err) return err;
326
327 swimiop_init_request(&req);
328 cmd->code = CMD_EJECT;
329 cmd->drive_num = fs->drive_num;
330 err = swimiop_send_request(&req);
331 if (err) {
332 release_drive(fs);
333 return err;
334 }
335 for (n = 2*HZ; n > 0; --n) {
336 if (req.complete) break;
337 if (signal_pending(current)) {
338 err = -EINTR;
339 break;
340 }
341 schedule_timeout_interruptible(1);
342 }
343 release_drive(fs);
344 return cmd->error;
345}
346
347static struct floppy_struct floppy_type =
348 { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL }; /* 7 1.44MB 3.5" */
349
350static int floppy_ioctl(struct inode *inode, struct file *filp,
351 unsigned int cmd, unsigned long param)
352{
353 struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
354 int err;
355
356 if ((cmd & 0x80) && !capable(CAP_SYS_ADMIN))
357 return -EPERM;
358
359 switch (cmd) {
360 case FDEJECT:
361 if (fs->ref_count != 1)
362 return -EBUSY;
363 err = swimiop_eject(fs);
364 return err;
365 case FDGETPRM:
366 if (copy_to_user((void *) param, (void *) &floppy_type,
367 sizeof(struct floppy_struct)))
368 return -EFAULT;
369 return 0;
370 }
371 return -ENOTTY;
372}
373
374static int floppy_open(struct inode *inode, struct file *filp)
375{
376 struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
377
378 if (fs->ref_count == -1 || filp->f_flags & O_EXCL)
379 return -EBUSY;
380
381 if ((filp->f_flags & O_NDELAY) == 0 && (filp->f_mode & 3)) {
382 check_disk_change(inode->i_bdev);
383 if (fs->ejected)
384 return -ENXIO;
385 }
386
387 if ((filp->f_mode & 2) && fs->write_prot)
388 return -EROFS;
389
390 if (filp->f_flags & O_EXCL)
391 fs->ref_count = -1;
392 else
393 ++fs->ref_count;
394
395 return 0;
396}
397
398static int floppy_release(struct inode *inode, struct file *filp)
399{
400 struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
401 if (fs->ref_count > 0)
402 fs->ref_count--;
403 return 0;
404}
405
406static int floppy_check_change(struct gendisk *disk)
407{
408 struct floppy_state *fs = disk->private_data;
409 return fs->ejected;
410}
411
412static int floppy_revalidate(struct gendisk *disk)
413{
414 struct floppy_state *fs = disk->private_data;
415 grab_drive(fs, revalidating, 0);
416 /* yadda, yadda */
417 release_drive(fs);
418 return 0;
419}
420
421static void floppy_off(unsigned int nr)
422{
423}
424
425static int grab_drive(struct floppy_state *fs, enum swim_state state,
426 int interruptible)
427{
428 unsigned long flags;
429
430 local_irq_save(flags);
431 if (fs->state != idle) {
432 ++fs->wanted;
433 while (fs->state != available) {
434 if (interruptible && signal_pending(current)) {
435 --fs->wanted;
436 local_irq_restore(flags);
437 return -EINTR;
438 }
439 interruptible_sleep_on(&fs->wait);
440 }
441 --fs->wanted;
442 }
443 fs->state = state;
444 local_irq_restore(flags);
445 return 0;
446}
447
448static void release_drive(struct floppy_state *fs)
449{
450 unsigned long flags;
451
452 local_irq_save(flags);
453 fs->state = idle;
454 start_request(fs);
455 local_irq_restore(flags);
456}
457
458static void set_timeout(struct floppy_state *fs, int nticks,
459 void (*proc)(unsigned long))
460{
461 unsigned long flags;
462
463 local_irq_save(flags);
464 if (fs->timeout_pending)
465 del_timer(&fs->timeout);
466 init_timer(&fs->timeout);
467 fs->timeout.expires = jiffies + nticks;
468 fs->timeout.function = proc;
469 fs->timeout.data = (unsigned long) fs;
470 add_timer(&fs->timeout);
471 fs->timeout_pending = 1;
472 local_irq_restore(flags);
473}
474
475static void do_fd_request(request_queue_t * q)
476{
477 int i;
478
479 for (i = 0 ; i < floppy_count ; i++) {
480 start_request(&floppy_states[i]);
481 }
482}
483
484static void fd_request_complete(struct swim_iop_req *req)
485{
486 struct floppy_state *fs = req->fs;
487 struct swimcmd_rw *cmd = (struct swimcmd_rw *) &req->command[0];
488
489 del_timer(&fs->timeout);
490 fs->timeout_pending = 0;
491 fs->state = idle;
492 if (cmd->error) {
493 printk(KERN_ERR "SWIM-IOP: error %d on read/write request.\n", cmd->error);
494 end_request(CURRENT, 0);
495 } else {
496 CURRENT->sector += cmd->num_blocks;
497 CURRENT->current_nr_sectors -= cmd->num_blocks;
498 if (CURRENT->current_nr_sectors <= 0) {
499 end_request(CURRENT, 1);
500 return;
501 }
502 }
503 start_request(fs);
504}
505
506static void fd_request_timeout(unsigned long data)
507{
508 struct floppy_state *fs = (struct floppy_state *) data;
509
510 fs->timeout_pending = 0;
511 end_request(CURRENT, 0);
512 fs->state = idle;
513}
514
515static void start_request(struct floppy_state *fs)
516{
517 volatile struct swim_iop_req req;
518 struct swimcmd_rw *cmd = (struct swimcmd_rw *) &req.command[0];
519
520 if (fs->state == idle && fs->wanted) {
521 fs->state = available;
522 wake_up(&fs->wait);
523 return;
524 }
525 while (CURRENT && fs->state == idle) {
526 if (CURRENT->bh && !buffer_locked(CURRENT->bh))
527 panic("floppy: block not locked");
528#if 0
529 printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%ld buf=%p\n",
530 CURRENT->rq_disk->disk_name, CURRENT->cmd,
531 CURRENT->sector, CURRENT->nr_sectors, CURRENT->buffer);
532 printk(" errors=%d current_nr_sectors=%ld\n",
533 CURRENT->errors, CURRENT->current_nr_sectors);
534#endif
535
536 if (CURRENT->sector < 0 || CURRENT->sector >= fs->total_secs) {
537 end_request(CURRENT, 0);
538 continue;
539 }
540 if (CURRENT->current_nr_sectors == 0) {
541 end_request(CURRENT, 1);
542 continue;
543 }
544 if (fs->ejected) {
545 end_request(CURRENT, 0);
546 continue;
547 }
548
549 swimiop_init_request(&req);
550 req.fs = fs;
551 req.done = fd_request_complete;
552
553 if (CURRENT->cmd == WRITE) {
554 if (fs->write_prot) {
555 end_request(CURRENT, 0);
556 continue;
557 }
558 cmd->code = CMD_WRITE;
559 } else {
560 cmd->code = CMD_READ;
561
562 }
563 cmd->drive_num = fs->drive_num;
564 cmd->buffer = CURRENT->buffer;
565 cmd->first_block = CURRENT->sector;
566 cmd->num_blocks = CURRENT->current_nr_sectors;
567
568 if (swimiop_send_request(&req)) {
569 end_request(CURRENT, 0);
570 continue;
571 }
572
573 set_timeout(fs, HZ*CURRENT->current_nr_sectors,
574 fd_request_timeout);
575
576 fs->state = transferring;
577 }
578}
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 2df5cf4ec743..e4a2f8f3a1d7 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -1810,7 +1810,7 @@ static int dvd_read_disckey(struct cdrom_device_info *cdi, dvd_struct *s)
1810 1810
1811 size = sizeof(s->disckey.value) + 4; 1811 size = sizeof(s->disckey.value) + 4;
1812 1812
1813 if ((buf = (u_char *) kmalloc(size, GFP_KERNEL)) == NULL) 1813 if ((buf = kmalloc(size, GFP_KERNEL)) == NULL)
1814 return -ENOMEM; 1814 return -ENOMEM;
1815 1815
1816 init_cdrom_command(&cgc, buf, size, CGC_DATA_READ); 1816 init_cdrom_command(&cgc, buf, size, CGC_DATA_READ);
@@ -1861,7 +1861,7 @@ static int dvd_read_manufact(struct cdrom_device_info *cdi, dvd_struct *s)
1861 1861
1862 size = sizeof(s->manufact.value) + 4; 1862 size = sizeof(s->manufact.value) + 4;
1863 1863
1864 if ((buf = (u_char *) kmalloc(size, GFP_KERNEL)) == NULL) 1864 if ((buf = kmalloc(size, GFP_KERNEL)) == NULL)
1865 return -ENOMEM; 1865 return -ENOMEM;
1866 1866
1867 init_cdrom_command(&cgc, buf, size, CGC_DATA_READ); 1867 init_cdrom_command(&cgc, buf, size, CGC_DATA_READ);
@@ -2849,7 +2849,7 @@ static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
2849 /* FIXME: we need upper bound checking, too!! */ 2849 /* FIXME: we need upper bound checking, too!! */
2850 if (lba < 0) 2850 if (lba < 0)
2851 return -EINVAL; 2851 return -EINVAL;
2852 cgc.buffer = (char *) kmalloc(blocksize, GFP_KERNEL); 2852 cgc.buffer = kmalloc(blocksize, GFP_KERNEL);
2853 if (cgc.buffer == NULL) 2853 if (cgc.buffer == NULL)
2854 return -ENOMEM; 2854 return -ENOMEM;
2855 memset(&sense, 0, sizeof(sense)); 2855 memset(&sense, 0, sizeof(sense));
@@ -3031,7 +3031,7 @@ static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
3031 int size = sizeof(dvd_struct); 3031 int size = sizeof(dvd_struct);
3032 if (!CDROM_CAN(CDC_DVD)) 3032 if (!CDROM_CAN(CDC_DVD))
3033 return -ENOSYS; 3033 return -ENOSYS;
3034 if ((s = (dvd_struct *) kmalloc(size, GFP_KERNEL)) == NULL) 3034 if ((s = kmalloc(size, GFP_KERNEL)) == NULL)
3035 return -ENOMEM; 3035 return -ENOMEM;
3036 cdinfo(CD_DO_IOCTL, "entering DVD_READ_STRUCT\n"); 3036 cdinfo(CD_DO_IOCTL, "entering DVD_READ_STRUCT\n");
3037 if (copy_from_user(s, (dvd_struct __user *)arg, size)) { 3037 if (copy_from_user(s, (dvd_struct __user *)arg, size)) {
diff --git a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c
index e6d8e9ededea..b6c61bbb20e1 100644
--- a/drivers/cdrom/cm206.c
+++ b/drivers/cdrom/cm206.c
@@ -1420,7 +1420,7 @@ int __init cm206_init(void)
1420 return -EIO; 1420 return -EIO;
1421 } 1421 }
1422 printk(" adapter at 0x%x", cm206_base); 1422 printk(" adapter at 0x%x", cm206_base);
1423 cd = (struct cm206_struct *) kmalloc(size, GFP_KERNEL); 1423 cd = kmalloc(size, GFP_KERNEL);
1424 if (!cd) 1424 if (!cd)
1425 goto out_base; 1425 goto out_base;
1426 /* Now we have found the adaptor card, try to reset it. As we have 1426 /* Now we have found the adaptor card, try to reset it. As we have
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 0a3aee29e067..9e43e39dc35c 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -97,7 +97,7 @@ config SERIAL_NONSTANDARD
97 97
98config COMPUTONE 98config COMPUTONE
99 tristate "Computone IntelliPort Plus serial support" 99 tristate "Computone IntelliPort Plus serial support"
100 depends on SERIAL_NONSTANDARD 100 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
101 ---help--- 101 ---help---
102 This driver supports the entire family of Intelliport II/Plus 102 This driver supports the entire family of Intelliport II/Plus
103 controllers with the exception of the MicroChannel controllers and 103 controllers with the exception of the MicroChannel controllers and
@@ -203,7 +203,7 @@ config MOXA_SMARTIO
203 203
204config MOXA_SMARTIO_NEW 204config MOXA_SMARTIO_NEW
205 tristate "Moxa SmartIO support v. 2.0 (EXPERIMENTAL)" 205 tristate "Moxa SmartIO support v. 2.0 (EXPERIMENTAL)"
206 depends on SERIAL_NONSTANDARD 206 depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
207 help 207 help
208 Say Y here if you have a Moxa SmartIO multiport serial card and/or 208 Say Y here if you have a Moxa SmartIO multiport serial card and/or
209 want to help develop a new version of this driver. 209 want to help develop a new version of this driver.
@@ -218,7 +218,7 @@ config MOXA_SMARTIO_NEW
218 218
219config ISI 219config ISI
220 tristate "Multi-Tech multiport card support (EXPERIMENTAL)" 220 tristate "Multi-Tech multiport card support (EXPERIMENTAL)"
221 depends on SERIAL_NONSTANDARD 221 depends on SERIAL_NONSTANDARD && PCI
222 select FW_LOADER 222 select FW_LOADER
223 help 223 help
224 This is a driver for the Multi-Tech cards which provide several 224 This is a driver for the Multi-Tech cards which provide several
@@ -312,7 +312,7 @@ config SPECIALIX_RTSCTS
312 312
313config SX 313config SX
314 tristate "Specialix SX (and SI) card support" 314 tristate "Specialix SX (and SI) card support"
315 depends on SERIAL_NONSTANDARD 315 depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
316 help 316 help
317 This is a driver for the SX and SI multiport serial cards. 317 This is a driver for the SX and SI multiport serial cards.
318 Please read the file <file:Documentation/sx.txt> for details. 318 Please read the file <file:Documentation/sx.txt> for details.
diff --git a/drivers/char/consolemap.c b/drivers/char/consolemap.c
index 04a12027a740..b99b7561260d 100644
--- a/drivers/char/consolemap.c
+++ b/drivers/char/consolemap.c
@@ -443,7 +443,7 @@ int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui)
443 p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc; 443 p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
444 if (p && p->readonly) return -EIO; 444 if (p && p->readonly) return -EIO;
445 if (!p || --p->refcount) { 445 if (!p || --p->refcount) {
446 q = (struct uni_pagedir *)kmalloc(sizeof(*p), GFP_KERNEL); 446 q = kmalloc(sizeof(*p), GFP_KERNEL);
447 if (!q) { 447 if (!q) {
448 if (p) p->refcount++; 448 if (p) p->refcount++;
449 return -ENOMEM; 449 return -ENOMEM;
diff --git a/drivers/char/lcd.c b/drivers/char/lcd.c
index da601fd6c07a..d649abbf0857 100644
--- a/drivers/char/lcd.c
+++ b/drivers/char/lcd.c
@@ -459,7 +459,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
459 (&display, (struct lcd_display *) arg, 459 (&display, (struct lcd_display *) arg,
460 sizeof(struct lcd_display))) 460 sizeof(struct lcd_display)))
461 return -EFAULT; 461 return -EFAULT;
462 rom = (unsigned char *) kmalloc((128), GFP_ATOMIC); 462 rom = kmalloc((128), GFP_ATOMIC);
463 if (rom == NULL) { 463 if (rom == NULL) {
464 printk(KERN_ERR LCD "kmalloc() failed in %s\n", 464 printk(KERN_ERR LCD "kmalloc() failed in %s\n",
465 __FUNCTION__); 465 __FUNCTION__);
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index b70b5388b5a8..b51d08be0bcf 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -525,7 +525,7 @@ static int lp_open(struct inode * inode, struct file * file)
525 return -EIO; 525 return -EIO;
526 } 526 }
527 } 527 }
528 lp_table[minor].lp_buffer = (char *) kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); 528 lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL);
529 if (!lp_table[minor].lp_buffer) { 529 if (!lp_table[minor].lp_buffer) {
530 LP_F(minor) &= ~LP_BUSY; 530 LP_F(minor) &= ~LP_BUSY;
531 return -ENOMEM; 531 return -ENOMEM;
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c
index efa8076c33e0..cd989dce7c53 100644
--- a/drivers/char/mxser_new.c
+++ b/drivers/char/mxser_new.c
@@ -315,6 +315,7 @@ static struct mxser_mon_ext mon_data_ext;
315static int mxser_set_baud_method[MXSER_PORTS + 1]; 315static int mxser_set_baud_method[MXSER_PORTS + 1];
316static spinlock_t gm_lock; 316static spinlock_t gm_lock;
317 317
318#ifdef CONFIG_PCI
318static int CheckIsMoxaMust(int io) 319static int CheckIsMoxaMust(int io)
319{ 320{
320 u8 oldmcr, hwid; 321 u8 oldmcr, hwid;
@@ -337,6 +338,7 @@ static int CheckIsMoxaMust(int io)
337 } 338 }
338 return MOXA_OTHER_UART; 339 return MOXA_OTHER_UART;
339} 340}
341#endif
340 342
341static void process_txrx_fifo(struct mxser_port *info) 343static void process_txrx_fifo(struct mxser_port *info)
342{ 344{
@@ -2380,9 +2382,11 @@ static void mxser_release_res(struct mxser_board *brd, struct pci_dev *pdev,
2380 if (irq) 2382 if (irq)
2381 free_irq(brd->irq, brd); 2383 free_irq(brd->irq, brd);
2382 if (pdev != NULL) { /* PCI */ 2384 if (pdev != NULL) { /* PCI */
2385#ifdef CONFIG_PCI
2383 pci_release_region(pdev, 2); 2386 pci_release_region(pdev, 2);
2384 pci_release_region(pdev, 3); 2387 pci_release_region(pdev, 3);
2385 pci_dev_put(pdev); 2388 pci_dev_put(pdev);
2389#endif
2386 } else { 2390 } else {
2387 release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); 2391 release_region(brd->ports[0].ioaddr, 8 * brd->info->nports);
2388 release_region(brd->vector, 1); 2392 release_region(brd->vector, 1);
@@ -2546,6 +2550,7 @@ static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd)
2546static int __devinit mxser_probe(struct pci_dev *pdev, 2550static int __devinit mxser_probe(struct pci_dev *pdev,
2547 const struct pci_device_id *ent) 2551 const struct pci_device_id *ent)
2548{ 2552{
2553#ifdef CONFIG_PCI
2549 struct mxser_board *brd; 2554 struct mxser_board *brd;
2550 unsigned int i, j; 2555 unsigned int i, j;
2551 unsigned long ioaddress; 2556 unsigned long ioaddress;
@@ -2644,6 +2649,9 @@ err_relio:
2644 brd->info = NULL; 2649 brd->info = NULL;
2645err: 2650err:
2646 return retval; 2651 return retval;
2652#else
2653 return -ENODEV;
2654#endif
2647} 2655}
2648 2656
2649static void __devexit mxser_remove(struct pci_dev *pdev) 2657static void __devexit mxser_remove(struct pci_dev *pdev)
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
index 103d338f21e2..dc6d41841457 100644
--- a/drivers/char/n_r3964.c
+++ b/drivers/char/n_r3964.c
@@ -125,8 +125,8 @@ static void transmit_block(struct r3964_info *pInfo);
125static void receive_char(struct r3964_info *pInfo, const unsigned char c); 125static void receive_char(struct r3964_info *pInfo, const unsigned char c);
126static void receive_error(struct r3964_info *pInfo, const char flag); 126static void receive_error(struct r3964_info *pInfo, const char flag);
127static void on_timeout(unsigned long priv); 127static void on_timeout(unsigned long priv);
128static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg); 128static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg);
129static int read_telegram(struct r3964_info *pInfo, pid_t pid, unsigned char __user *buf); 129static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user *buf);
130static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, 130static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
131 int error_code, struct r3964_block_header *pBlock); 131 int error_code, struct r3964_block_header *pBlock);
132static struct r3964_message* remove_msg(struct r3964_info *pInfo, 132static struct r3964_message* remove_msg(struct r3964_info *pInfo,
@@ -829,7 +829,7 @@ static void on_timeout(unsigned long priv)
829} 829}
830 830
831static struct r3964_client_info *findClient( 831static struct r3964_client_info *findClient(
832 struct r3964_info *pInfo, pid_t pid) 832 struct r3964_info *pInfo, struct pid *pid)
833{ 833{
834 struct r3964_client_info *pClient; 834 struct r3964_client_info *pClient;
835 835
@@ -843,7 +843,7 @@ static struct r3964_client_info *findClient(
843 return NULL; 843 return NULL;
844} 844}
845 845
846static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) 846static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg)
847{ 847{
848 struct r3964_client_info *pClient; 848 struct r3964_client_info *pClient;
849 struct r3964_client_info **ppClient; 849 struct r3964_client_info **ppClient;
@@ -858,7 +858,7 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg)
858 858
859 if(pClient->pid == pid) 859 if(pClient->pid == pid)
860 { 860 {
861 TRACE_PS("removing client %d from client list", pid); 861 TRACE_PS("removing client %d from client list", pid_nr(pid));
862 *ppClient = pClient->next; 862 *ppClient = pClient->next;
863 while(pClient->msg_count) 863 while(pClient->msg_count)
864 { 864 {
@@ -869,6 +869,7 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg)
869 TRACE_M("enable_signals - msg kfree %p",pMsg); 869 TRACE_M("enable_signals - msg kfree %p",pMsg);
870 } 870 }
871 } 871 }
872 put_pid(pClient->pid);
872 kfree(pClient); 873 kfree(pClient);
873 TRACE_M("enable_signals - kfree %p",pClient); 874 TRACE_M("enable_signals - kfree %p",pClient);
874 return 0; 875 return 0;
@@ -892,10 +893,10 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg)
892 if(pClient==NULL) 893 if(pClient==NULL)
893 return -ENOMEM; 894 return -ENOMEM;
894 895
895 TRACE_PS("add client %d to client list", pid); 896 TRACE_PS("add client %d to client list", pid_nr(pid));
896 spin_lock_init(&pClient->lock); 897 spin_lock_init(&pClient->lock);
897 pClient->sig_flags=arg; 898 pClient->sig_flags=arg;
898 pClient->pid = pid; 899 pClient->pid = get_pid(pid);
899 pClient->next=pInfo->firstClient; 900 pClient->next=pInfo->firstClient;
900 pClient->first_msg = NULL; 901 pClient->first_msg = NULL;
901 pClient->last_msg = NULL; 902 pClient->last_msg = NULL;
@@ -908,7 +909,7 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg)
908 return 0; 909 return 0;
909} 910}
910 911
911static int read_telegram(struct r3964_info *pInfo, pid_t pid, unsigned char __user *buf) 912static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user *buf)
912{ 913{
913 struct r3964_client_info *pClient; 914 struct r3964_client_info *pClient;
914 struct r3964_block_header *block; 915 struct r3964_block_header *block;
@@ -1005,7 +1006,7 @@ queue_the_message:
1005 /* Send SIGIO signal to client process: */ 1006 /* Send SIGIO signal to client process: */
1006 if(pClient->sig_flags & R3964_USE_SIGIO) 1007 if(pClient->sig_flags & R3964_USE_SIGIO)
1007 { 1008 {
1008 kill_proc(pClient->pid, SIGIO, 1); 1009 kill_pid(pClient->pid, SIGIO, 1);
1009 } 1010 }
1010} 1011}
1011 1012
@@ -1042,7 +1043,7 @@ static void remove_client_block(struct r3964_info *pInfo,
1042{ 1043{
1043 struct r3964_block_header *block; 1044 struct r3964_block_header *block;
1044 1045
1045 TRACE_PS("remove_client_block PID %d", pClient->pid); 1046 TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid));
1046 1047
1047 block=pClient->next_block_to_read; 1048 block=pClient->next_block_to_read;
1048 if(block) 1049 if(block)
@@ -1157,6 +1158,7 @@ static void r3964_close(struct tty_struct *tty)
1157 TRACE_M("r3964_close - msg kfree %p",pMsg); 1158 TRACE_M("r3964_close - msg kfree %p",pMsg);
1158 } 1159 }
1159 } 1160 }
1161 put_pid(pClient->pid);
1160 kfree(pClient); 1162 kfree(pClient);
1161 TRACE_M("r3964_close - client kfree %p",pClient); 1163 TRACE_M("r3964_close - client kfree %p",pClient);
1162 pClient=pNext; 1164 pClient=pNext;
@@ -1193,12 +1195,11 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
1193 struct r3964_client_message theMsg; 1195 struct r3964_client_message theMsg;
1194 DECLARE_WAITQUEUE (wait, current); 1196 DECLARE_WAITQUEUE (wait, current);
1195 1197
1196 int pid = current->pid;
1197 int count; 1198 int count;
1198 1199
1199 TRACE_L("read()"); 1200 TRACE_L("read()");
1200 1201
1201 pClient=findClient(pInfo, pid); 1202 pClient=findClient(pInfo, task_pid(current));
1202 if(pClient) 1203 if(pClient)
1203 { 1204 {
1204 pMsg = remove_msg(pInfo, pClient); 1205 pMsg = remove_msg(pInfo, pClient);
@@ -1252,7 +1253,6 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file,
1252 struct r3964_block_header *pHeader; 1253 struct r3964_block_header *pHeader;
1253 struct r3964_client_info *pClient; 1254 struct r3964_client_info *pClient;
1254 unsigned char *new_data; 1255 unsigned char *new_data;
1255 int pid;
1256 1256
1257 TRACE_L("write request, %d characters", count); 1257 TRACE_L("write request, %d characters", count);
1258/* 1258/*
@@ -1295,9 +1295,7 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file,
1295 pHeader->locks = 0; 1295 pHeader->locks = 0;
1296 pHeader->owner = NULL; 1296 pHeader->owner = NULL;
1297 1297
1298 pid=current->pid; 1298 pClient=findClient(pInfo, task_pid(current));
1299
1300 pClient=findClient(pInfo, pid);
1301 if(pClient) 1299 if(pClient)
1302 { 1300 {
1303 pHeader->owner = pClient; 1301 pHeader->owner = pClient;
@@ -1328,7 +1326,7 @@ static int r3964_ioctl(struct tty_struct * tty, struct file * file,
1328 switch(cmd) 1326 switch(cmd)
1329 { 1327 {
1330 case R3964_ENABLE_SIGNALS: 1328 case R3964_ENABLE_SIGNALS:
1331 return enable_signals(pInfo, current->pid, arg); 1329 return enable_signals(pInfo, task_pid(current), arg);
1332 case R3964_SETPRIORITY: 1330 case R3964_SETPRIORITY:
1333 if(arg<R3964_MASTER || arg>R3964_SLAVE) 1331 if(arg<R3964_MASTER || arg>R3964_SLAVE)
1334 return -EINVAL; 1332 return -EINVAL;
@@ -1341,7 +1339,7 @@ static int r3964_ioctl(struct tty_struct * tty, struct file * file,
1341 pInfo->flags &= ~R3964_BCC; 1339 pInfo->flags &= ~R3964_BCC;
1342 return 0; 1340 return 0;
1343 case R3964_READ_TELEGRAM: 1341 case R3964_READ_TELEGRAM:
1344 return read_telegram(pInfo, current->pid, (unsigned char __user *)arg); 1342 return read_telegram(pInfo, task_pid(current), (unsigned char __user *)arg);
1345 default: 1343 default:
1346 return -ENOIOCTLCMD; 1344 return -ENOIOCTLCMD;
1347 } 1345 }
@@ -1357,7 +1355,6 @@ static unsigned int r3964_poll(struct tty_struct * tty, struct file * file,
1357 struct poll_table_struct *wait) 1355 struct poll_table_struct *wait)
1358{ 1356{
1359 struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data; 1357 struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data;
1360 int pid=current->pid;
1361 struct r3964_client_info *pClient; 1358 struct r3964_client_info *pClient;
1362 struct r3964_message *pMsg=NULL; 1359 struct r3964_message *pMsg=NULL;
1363 unsigned long flags; 1360 unsigned long flags;
@@ -1365,7 +1362,7 @@ static unsigned int r3964_poll(struct tty_struct * tty, struct file * file,
1365 1362
1366 TRACE_L("POLL"); 1363 TRACE_L("POLL");
1367 1364
1368 pClient=findClient(pInfo,pid); 1365 pClient=findClient(pInfo, task_pid(current));
1369 if(pClient) 1366 if(pClient)
1370 { 1367 {
1371 poll_wait(file, &pInfo->read_wait, wait); 1368 poll_wait(file, &pInfo->read_wait, wait);
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index e96a00fe1389..2bdb0144a22e 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1151,7 +1151,6 @@ static int copy_from_read_buf(struct tty_struct *tty,
1151 n = min(*nr, n); 1151 n = min(*nr, n);
1152 spin_unlock_irqrestore(&tty->read_lock, flags); 1152 spin_unlock_irqrestore(&tty->read_lock, flags);
1153 if (n) { 1153 if (n) {
1154 mb();
1155 retval = copy_to_user(*b, &tty->read_buf[tty->read_tail], n); 1154 retval = copy_to_user(*b, &tty->read_buf[tty->read_tail], n);
1156 n -= retval; 1155 n -= retval;
1157 spin_lock_irqsave(&tty->read_lock, flags); 1156 spin_lock_irqsave(&tty->read_lock, flags);
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 5152cedd8878..f108c136800a 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -541,7 +541,7 @@ static int mgslpc_probe(struct pcmcia_device *link)
541 if (debug_level >= DEBUG_LEVEL_INFO) 541 if (debug_level >= DEBUG_LEVEL_INFO)
542 printk("mgslpc_attach\n"); 542 printk("mgslpc_attach\n");
543 543
544 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); 544 info = kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL);
545 if (!info) { 545 if (!info) {
546 printk("Error can't allocate device instance data\n"); 546 printk("Error can't allocate device instance data\n");
547 return -ENOMEM; 547 return -ENOMEM;
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 167ebc84e8d7..245f03195b7c 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -556,7 +556,7 @@ struct CmdBlk *RIOGetCmdBlk(void)
556{ 556{
557 struct CmdBlk *CmdBlkP; 557 struct CmdBlk *CmdBlkP;
558 558
559 CmdBlkP = (struct CmdBlk *)kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC); 559 CmdBlkP = kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC);
560 if (CmdBlkP) 560 if (CmdBlkP)
561 memset(CmdBlkP, 0, sizeof(struct CmdBlk)); 561 memset(CmdBlkP, 0, sizeof(struct CmdBlk));
562 return CmdBlkP; 562 return CmdBlkP;
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 66a7385bc34a..e1d70e8b6268 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -113,7 +113,7 @@ static int rtc_has_irq = 1;
113#define hpet_set_rtc_irq_bit(arg) 0 113#define hpet_set_rtc_irq_bit(arg) 0
114#define hpet_rtc_timer_init() do { } while (0) 114#define hpet_rtc_timer_init() do { } while (0)
115#define hpet_rtc_dropped_irq() 0 115#define hpet_rtc_dropped_irq() 0
116static inline irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) {return 0;} 116static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) {return 0;}
117#else 117#else
118extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); 118extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id);
119#endif 119#endif
@@ -165,7 +165,9 @@ static void mask_rtc_irq_bit(unsigned char bit)
165} 165}
166#endif 166#endif
167 167
168#ifdef CONFIG_PROC_FS
168static int rtc_proc_open(struct inode *inode, struct file *file); 169static int rtc_proc_open(struct inode *inode, struct file *file);
170#endif
169 171
170/* 172/*
171 * Bits in rtc_status. (6 bits of room for future expansion) 173 * Bits in rtc_status. (6 bits of room for future expansion)
@@ -906,6 +908,7 @@ static struct miscdevice rtc_dev = {
906 .fops = &rtc_fops, 908 .fops = &rtc_fops,
907}; 909};
908 910
911#ifdef CONFIG_PROC_FS
909static const struct file_operations rtc_proc_fops = { 912static const struct file_operations rtc_proc_fops = {
910 .owner = THIS_MODULE, 913 .owner = THIS_MODULE,
911 .open = rtc_proc_open, 914 .open = rtc_proc_open,
@@ -913,14 +916,13 @@ static const struct file_operations rtc_proc_fops = {
913 .llseek = seq_lseek, 916 .llseek = seq_lseek,
914 .release = single_release, 917 .release = single_release,
915}; 918};
916
917#if defined(RTC_IRQ) && !defined(__sparc__)
918static irq_handler_t rtc_int_handler_ptr;
919#endif 919#endif
920 920
921static int __init rtc_init(void) 921static int __init rtc_init(void)
922{ 922{
923#ifdef CONFIG_PROC_FS
923 struct proc_dir_entry *ent; 924 struct proc_dir_entry *ent;
925#endif
924#if defined(__alpha__) || defined(__mips__) 926#if defined(__alpha__) || defined(__mips__)
925 unsigned int year, ctrl; 927 unsigned int year, ctrl;
926 char *guess = NULL; 928 char *guess = NULL;
@@ -932,9 +934,11 @@ static int __init rtc_init(void)
932 struct sparc_isa_bridge *isa_br; 934 struct sparc_isa_bridge *isa_br;
933 struct sparc_isa_device *isa_dev; 935 struct sparc_isa_device *isa_dev;
934#endif 936#endif
935#endif 937#else
936#ifndef __sparc__
937 void *r; 938 void *r;
939#ifdef RTC_IRQ
940 irq_handler_t rtc_int_handler_ptr;
941#endif
938#endif 942#endif
939 943
940#ifdef __sparc__ 944#ifdef __sparc__
@@ -958,6 +962,7 @@ static int __init rtc_init(void)
958 } 962 }
959 } 963 }
960#endif 964#endif
965 rtc_has_irq = 0;
961 printk(KERN_ERR "rtc_init: no PC rtc found\n"); 966 printk(KERN_ERR "rtc_init: no PC rtc found\n");
962 return -EIO; 967 return -EIO;
963 968
@@ -972,6 +977,7 @@ found:
972 * PCI Slot 2 INTA# (and some INTx# in Slot 1). 977 * PCI Slot 2 INTA# (and some INTx# in Slot 1).
973 */ 978 */
974 if (request_irq(rtc_irq, rtc_interrupt, IRQF_SHARED, "rtc", (void *)&rtc_port)) { 979 if (request_irq(rtc_irq, rtc_interrupt, IRQF_SHARED, "rtc", (void *)&rtc_port)) {
980 rtc_has_irq = 0;
975 printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq); 981 printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq);
976 return -EIO; 982 return -EIO;
977 } 983 }
@@ -982,6 +988,9 @@ no_irq:
982 else 988 else
983 r = request_mem_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"); 989 r = request_mem_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc");
984 if (!r) { 990 if (!r) {
991#ifdef RTC_IRQ
992 rtc_has_irq = 0;
993#endif
985 printk(KERN_ERR "rtc: I/O resource %lx is not free.\n", 994 printk(KERN_ERR "rtc: I/O resource %lx is not free.\n",
986 (long)(RTC_PORT(0))); 995 (long)(RTC_PORT(0)));
987 return -EIO; 996 return -EIO;
@@ -996,6 +1005,7 @@ no_irq:
996 1005
997 if(request_irq(RTC_IRQ, rtc_int_handler_ptr, IRQF_DISABLED, "rtc", NULL)) { 1006 if(request_irq(RTC_IRQ, rtc_int_handler_ptr, IRQF_DISABLED, "rtc", NULL)) {
998 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */ 1007 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */
1008 rtc_has_irq = 0;
999 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); 1009 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
1000 if (RTC_IOMAPPED) 1010 if (RTC_IOMAPPED)
1001 release_region(RTC_PORT(0), RTC_IO_EXTENT); 1011 release_region(RTC_PORT(0), RTC_IO_EXTENT);
@@ -1012,21 +1022,19 @@ no_irq:
1012 if (misc_register(&rtc_dev)) { 1022 if (misc_register(&rtc_dev)) {
1013#ifdef RTC_IRQ 1023#ifdef RTC_IRQ
1014 free_irq(RTC_IRQ, NULL); 1024 free_irq(RTC_IRQ, NULL);
1025 rtc_has_irq = 0;
1015#endif 1026#endif
1016 release_region(RTC_PORT(0), RTC_IO_EXTENT); 1027 release_region(RTC_PORT(0), RTC_IO_EXTENT);
1017 return -ENODEV; 1028 return -ENODEV;
1018 } 1029 }
1019 1030
1031#ifdef CONFIG_PROC_FS
1020 ent = create_proc_entry("driver/rtc", 0, NULL); 1032 ent = create_proc_entry("driver/rtc", 0, NULL);
1021 if (!ent) { 1033 if (ent)
1022#ifdef RTC_IRQ 1034 ent->proc_fops = &rtc_proc_fops;
1023 free_irq(RTC_IRQ, NULL); 1035 else
1036 printk(KERN_WARNING "rtc: Failed to register with procfs.\n");
1024#endif 1037#endif
1025 release_region(RTC_PORT(0), RTC_IO_EXTENT);
1026 misc_deregister(&rtc_dev);
1027 return -ENOMEM;
1028 }
1029 ent->proc_fops = &rtc_proc_fops;
1030 1038
1031#if defined(__alpha__) || defined(__mips__) 1039#if defined(__alpha__) || defined(__mips__)
1032 rtc_freq = HZ; 1040 rtc_freq = HZ;
@@ -1159,6 +1167,7 @@ static void rtc_dropped_irq(unsigned long data)
1159} 1167}
1160#endif 1168#endif
1161 1169
1170#ifdef CONFIG_PROC_FS
1162/* 1171/*
1163 * Info exported via "/proc/driver/rtc". 1172 * Info exported via "/proc/driver/rtc".
1164 */ 1173 */
@@ -1243,6 +1252,7 @@ static int rtc_proc_open(struct inode *inode, struct file *file)
1243{ 1252{
1244 return single_open(file, rtc_proc_show, NULL); 1253 return single_open(file, rtc_proc_show, NULL);
1245} 1254}
1255#endif
1246 1256
1247void rtc_get_rtc_time(struct rtc_time *rtc_tm) 1257void rtc_get_rtc_time(struct rtc_time *rtc_tm)
1248{ 1258{
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index a3008ce13015..1da92a689ae4 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -2498,8 +2498,10 @@ static void __devexit sx_remove_card(struct sx_board *board,
2498 /* It is safe/allowed to del_timer a non-active timer */ 2498 /* It is safe/allowed to del_timer a non-active timer */
2499 del_timer(&board->timer); 2499 del_timer(&board->timer);
2500 if (pdev) { 2500 if (pdev) {
2501#ifdef CONFIG_PCI
2501 pci_iounmap(pdev, board->base); 2502 pci_iounmap(pdev, board->base);
2502 pci_release_region(pdev, IS_CF_BOARD(board) ? 3 : 2); 2503 pci_release_region(pdev, IS_CF_BOARD(board) ? 3 : 2);
2504#endif
2503 } else { 2505 } else {
2504 iounmap(board->base); 2506 iounmap(board->base);
2505 release_region(board->hw_base, board->hw_len); 2507 release_region(board->hw_base, board->hw_len);
@@ -2601,6 +2603,7 @@ static struct eisa_driver sx_eisadriver = {
2601 2603
2602#endif 2604#endif
2603 2605
2606#ifdef CONFIG_PCI
2604 /******************************************************** 2607 /********************************************************
2605 * Setting bit 17 in the CNTRL register of the PLX 9050 * 2608 * Setting bit 17 in the CNTRL register of the PLX 9050 *
2606 * chip forces a retry on writes while a read is pending.* 2609 * chip forces a retry on writes while a read is pending.*
@@ -2632,10 +2635,12 @@ static void __devinit fix_sx_pci(struct pci_dev *pdev, struct sx_board *board)
2632 } 2635 }
2633 iounmap(rebase); 2636 iounmap(rebase);
2634} 2637}
2638#endif
2635 2639
2636static int __devinit sx_pci_probe(struct pci_dev *pdev, 2640static int __devinit sx_pci_probe(struct pci_dev *pdev,
2637 const struct pci_device_id *ent) 2641 const struct pci_device_id *ent)
2638{ 2642{
2643#ifdef CONFIG_PCI
2639 struct sx_board *board; 2644 struct sx_board *board;
2640 unsigned int i, reg; 2645 unsigned int i, reg;
2641 int retval = -EIO; 2646 int retval = -EIO;
@@ -2700,6 +2705,9 @@ err_flag:
2700 board->flags &= ~SX_BOARD_PRESENT; 2705 board->flags &= ~SX_BOARD_PRESENT;
2701err: 2706err:
2702 return retval; 2707 return retval;
2708#else
2709 return -ENODEV;
2710#endif
2703} 2711}
2704 2712
2705static void __devexit sx_pci_remove(struct pci_dev *pdev) 2713static void __devexit sx_pci_remove(struct pci_dev *pdev)
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index acc6fab601cc..3fa625db9e4b 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -4332,7 +4332,7 @@ static struct mgsl_struct* mgsl_allocate_device(void)
4332{ 4332{
4333 struct mgsl_struct *info; 4333 struct mgsl_struct *info;
4334 4334
4335 info = (struct mgsl_struct *)kmalloc(sizeof(struct mgsl_struct), 4335 info = kmalloc(sizeof(struct mgsl_struct),
4336 GFP_KERNEL); 4336 GFP_KERNEL);
4337 4337
4338 if (!info) { 4338 if (!info) {
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 53e8ccf94fe3..8f4d67afe5bf 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -2730,7 +2730,7 @@ static int startup(SLMP_INFO * info)
2730 return 0; 2730 return 0;
2731 2731
2732 if (!info->tx_buf) { 2732 if (!info->tx_buf) {
2733 info->tx_buf = (unsigned char *)kmalloc(info->max_frame_size, GFP_KERNEL); 2733 info->tx_buf = kmalloc(info->max_frame_size, GFP_KERNEL);
2734 if (!info->tx_buf) { 2734 if (!info->tx_buf) {
2735 printk(KERN_ERR"%s(%d):%s can't allocate transmit buffer\n", 2735 printk(KERN_ERR"%s(%d):%s can't allocate transmit buffer\n",
2736 __FILE__,__LINE__,info->device_name); 2736 __FILE__,__LINE__,info->device_name);
@@ -3798,7 +3798,7 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
3798{ 3798{
3799 SLMP_INFO *info; 3799 SLMP_INFO *info;
3800 3800
3801 info = (SLMP_INFO *)kmalloc(sizeof(SLMP_INFO), 3801 info = kmalloc(sizeof(SLMP_INFO),
3802 GFP_KERNEL); 3802 GFP_KERNEL);
3803 3803
3804 if (!info) { 3804 if (!info) {
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 05810c8d20bc..13935235e066 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -41,7 +41,34 @@
41#include <asm/irq_regs.h> 41#include <asm/irq_regs.h>
42 42
43/* Whether we react on sysrq keys or just ignore them */ 43/* Whether we react on sysrq keys or just ignore them */
44int sysrq_enabled = 1; 44int __read_mostly __sysrq_enabled = 1;
45
46static int __read_mostly sysrq_always_enabled;
47
48int sysrq_on(void)
49{
50 return __sysrq_enabled || sysrq_always_enabled;
51}
52
53/*
54 * A value of 1 means 'all', other nonzero values are an op mask:
55 */
56static inline int sysrq_on_mask(int mask)
57{
58 return sysrq_always_enabled || __sysrq_enabled == 1 ||
59 (__sysrq_enabled & mask);
60}
61
62static int __init sysrq_always_enabled_setup(char *str)
63{
64 sysrq_always_enabled = 1;
65 printk(KERN_INFO "debug: sysrq always enabled.\n");
66
67 return 1;
68}
69
70__setup("sysrq_always_enabled", sysrq_always_enabled_setup);
71
45 72
46static void sysrq_handle_loglevel(int key, struct tty_struct *tty) 73static void sysrq_handle_loglevel(int key, struct tty_struct *tty)
47{ 74{
@@ -379,8 +406,7 @@ void __handle_sysrq(int key, struct tty_struct *tty, int check_mask)
379 * Should we check for enabled operations (/proc/sysrq-trigger 406 * Should we check for enabled operations (/proc/sysrq-trigger
380 * should not) and is the invoked operation enabled? 407 * should not) and is the invoked operation enabled?
381 */ 408 */
382 if (!check_mask || sysrq_enabled == 1 || 409 if (!check_mask || sysrq_on_mask(op_p->enable_mask)) {
383 (sysrq_enabled & op_p->enable_mask)) {
384 printk("%s\n", op_p->action_msg); 410 printk("%s\n", op_p->action_msg);
385 console_loglevel = orig_log_level; 411 console_loglevel = orig_log_level;
386 op_p->handler(key, tty); 412 op_p->handler(key, tty);
@@ -414,9 +440,8 @@ void __handle_sysrq(int key, struct tty_struct *tty, int check_mask)
414 */ 440 */
415void handle_sysrq(int key, struct tty_struct *tty) 441void handle_sysrq(int key, struct tty_struct *tty)
416{ 442{
417 if (!sysrq_enabled) 443 if (sysrq_on())
418 return; 444 __handle_sysrq(key, tty, 1);
419 __handle_sysrq(key, tty, 1);
420} 445}
421EXPORT_SYMBOL(handle_sysrq); 446EXPORT_SYMBOL(handle_sysrq);
422 447
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 4044c864fdd4..47a6eacb10bc 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -3335,18 +3335,13 @@ static void __do_SAK(struct work_struct *work)
3335 int session; 3335 int session;
3336 int i; 3336 int i;
3337 struct file *filp; 3337 struct file *filp;
3338 struct tty_ldisc *disc;
3339 struct fdtable *fdt; 3338 struct fdtable *fdt;
3340 3339
3341 if (!tty) 3340 if (!tty)
3342 return; 3341 return;
3343 session = tty->session; 3342 session = tty->session;
3344 3343
3345 /* We don't want an ldisc switch during this */ 3344 tty_ldisc_flush(tty);
3346 disc = tty_ldisc_ref(tty);
3347 if (disc && disc->flush_buffer)
3348 disc->flush_buffer(tty);
3349 tty_ldisc_deref(disc);
3350 3345
3351 if (tty->driver->flush_buffer) 3346 if (tty->driver->flush_buffer)
3352 tty->driver->flush_buffer(tty); 3347 tty->driver->flush_buffer(tty);
@@ -3821,6 +3816,7 @@ struct tty_struct *get_current_tty(void)
3821 barrier(); 3816 barrier();
3822 return tty; 3817 return tty;
3823} 3818}
3819EXPORT_SYMBOL_GPL(get_current_tty);
3824 3820
3825/* 3821/*
3826 * Initialize the console device. This is called *early*, so 3822 * Initialize the console device. This is called *early*, so
diff --git a/drivers/char/viocons.c b/drivers/char/viocons.c
index 6d2e314860df..0e0da443cbd5 100644
--- a/drivers/char/viocons.c
+++ b/drivers/char/viocons.c
@@ -61,10 +61,7 @@
61static DEFINE_SPINLOCK(consolelock); 61static DEFINE_SPINLOCK(consolelock);
62static DEFINE_SPINLOCK(consoleloglock); 62static DEFINE_SPINLOCK(consoleloglock);
63 63
64#ifdef CONFIG_MAGIC_SYSRQ
65static int vio_sysrq_pressed; 64static int vio_sysrq_pressed;
66extern int sysrq_enabled;
67#endif
68 65
69#define VIOCHAR_NUM_BUF 16 66#define VIOCHAR_NUM_BUF 16
70 67
@@ -936,8 +933,10 @@ static void vioHandleData(struct HvLpEvent *event)
936 */ 933 */
937 num_pushed = 0; 934 num_pushed = 0;
938 for (index = 0; index < cevent->len; index++) { 935 for (index = 0; index < cevent->len; index++) {
939#ifdef CONFIG_MAGIC_SYSRQ 936 /*
940 if (sysrq_enabled) { 937 * Will be optimized away if !CONFIG_MAGIC_SYSRQ:
938 */
939 if (sysrq_on()) {
941 /* 0x0f is the ascii character for ^O */ 940 /* 0x0f is the ascii character for ^O */
942 if (cevent->data[index] == '\x0f') { 941 if (cevent->data[index] == '\x0f') {
943 vio_sysrq_pressed = 1; 942 vio_sysrq_pressed = 1;
@@ -956,7 +955,6 @@ static void vioHandleData(struct HvLpEvent *event)
956 continue; 955 continue;
957 } 956 }
958 } 957 }
959#endif
960 /* 958 /*
961 * The sysrq sequence isn't included in this check if 959 * The sysrq sequence isn't included in this check if
962 * sysrq is enabled and compiled into the kernel because 960 * sysrq is enabled and compiled into the kernel because
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index a8239dac994f..06c32a3e3ca4 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -784,7 +784,7 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines)
784 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) 784 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows)
785 return 0; 785 return 0;
786 786
787 newscreen = (unsigned short *) kmalloc(new_screen_size, GFP_USER); 787 newscreen = kmalloc(new_screen_size, GFP_USER);
788 if (!newscreen) 788 if (!newscreen)
789 return -ENOMEM; 789 return -ENOMEM;
790 790
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index ac5d60edbafa..dc8368ebb1ac 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -129,7 +129,7 @@ do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_str
129 !capable(CAP_SYS_RESOURCE)) 129 !capable(CAP_SYS_RESOURCE))
130 return -EPERM; 130 return -EPERM;
131 131
132 key_map = (ushort *) kmalloc(sizeof(plain_map), 132 key_map = kmalloc(sizeof(plain_map),
133 GFP_KERNEL); 133 GFP_KERNEL);
134 if (!key_map) 134 if (!key_map)
135 return -ENOMEM; 135 return -ENOMEM;
@@ -259,7 +259,7 @@ do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
259 sz = 256; 259 sz = 256;
260 while (sz < funcbufsize - funcbufleft + delta) 260 while (sz < funcbufsize - funcbufleft + delta)
261 sz <<= 1; 261 sz <<= 1;
262 fnw = (char *) kmalloc(sz, GFP_KERNEL); 262 fnw = kmalloc(sz, GFP_KERNEL);
263 if(!fnw) { 263 if(!fnw) {
264 ret = -ENOMEM; 264 ret = -ENOMEM;
265 goto reterr; 265 goto reterr;
@@ -1087,7 +1087,7 @@ static void complete_change_console(struct vc_data *vc)
1087 switch_screen(vc); 1087 switch_screen(vc);
1088 1088
1089 /* 1089 /*
1090 * This can't appear below a successful kill_proc(). If it did, 1090 * This can't appear below a successful kill_pid(). If it did,
1091 * then the *blank_screen operation could occur while X, having 1091 * then the *blank_screen operation could occur while X, having
1092 * received acqsig, is waking up on another processor. This 1092 * received acqsig, is waking up on another processor. This
1093 * condition can lead to overlapping accesses to the VGA range 1093 * condition can lead to overlapping accesses to the VGA range
@@ -1110,7 +1110,7 @@ static void complete_change_console(struct vc_data *vc)
1110 */ 1110 */
1111 if (vc->vt_mode.mode == VT_PROCESS) { 1111 if (vc->vt_mode.mode == VT_PROCESS) {
1112 /* 1112 /*
1113 * Send the signal as privileged - kill_proc() will 1113 * Send the signal as privileged - kill_pid() will
1114 * tell us if the process has gone or something else 1114 * tell us if the process has gone or something else
1115 * is awry 1115 * is awry
1116 */ 1116 */
@@ -1170,7 +1170,7 @@ void change_console(struct vc_data *new_vc)
1170 vc = vc_cons[fg_console].d; 1170 vc = vc_cons[fg_console].d;
1171 if (vc->vt_mode.mode == VT_PROCESS) { 1171 if (vc->vt_mode.mode == VT_PROCESS) {
1172 /* 1172 /*
1173 * Send the signal as privileged - kill_proc() will 1173 * Send the signal as privileged - kill_pid() will
1174 * tell us if the process has gone or something else 1174 * tell us if the process has gone or something else
1175 * is awry 1175 * is awry
1176 */ 1176 */
diff --git a/drivers/fc4/fc.c b/drivers/fc4/fc.c
index ca4e67a022d0..22b62b3cd14e 100644
--- a/drivers/fc4/fc.c
+++ b/drivers/fc4/fc.c
@@ -266,7 +266,7 @@ static void fcp_report_map_done(fc_channel *fc, int i, int status)
266 printk ("FC: Bad magic from REPORT_AL_MAP on %s - %08x\n", fc->name, p->magic); 266 printk ("FC: Bad magic from REPORT_AL_MAP on %s - %08x\n", fc->name, p->magic);
267 fc->state = FC_STATE_OFFLINE; 267 fc->state = FC_STATE_OFFLINE;
268 } else { 268 } else {
269 fc->posmap = (fcp_posmap *)kzalloc(sizeof(fcp_posmap)+p->len, GFP_KERNEL); 269 fc->posmap = kzalloc(sizeof(fcp_posmap)+p->len, GFP_KERNEL);
270 if (!fc->posmap) { 270 if (!fc->posmap) {
271 printk("FC: Not enough memory, offlining channel\n"); 271 printk("FC: Not enough memory, offlining channel\n");
272 fc->state = FC_STATE_OFFLINE; 272 fc->state = FC_STATE_OFFLINE;
@@ -355,7 +355,7 @@ void fcp_register(fc_channel *fc, u8 type, int unregister)
355 for (i = fc->can_queue; i < fc->scsi_bitmap_end; i++) 355 for (i = fc->can_queue; i < fc->scsi_bitmap_end; i++)
356 set_bit (i, fc->scsi_bitmap); 356 set_bit (i, fc->scsi_bitmap);
357 fc->scsi_free = fc->can_queue; 357 fc->scsi_free = fc->can_queue;
358 fc->cmd_slots = (fcp_cmnd **)kzalloc(slots * sizeof(fcp_cmnd*), GFP_KERNEL); 358 fc->cmd_slots = kzalloc(slots * sizeof(fcp_cmnd*), GFP_KERNEL);
359 fc->abort_count = 0; 359 fc->abort_count = 0;
360 } else { 360 } else {
361 fc->scsi_name[0] = 0; 361 fc->scsi_name[0] = 0;
@@ -933,7 +933,7 @@ int fcp_scsi_dev_reset(struct scsi_cmnd *SCpnt)
933 DECLARE_MUTEX_LOCKED(sem); 933 DECLARE_MUTEX_LOCKED(sem);
934 934
935 if (!fc->rst_pkt) { 935 if (!fc->rst_pkt) {
936 fc->rst_pkt = (struct scsi_cmnd *) kmalloc(sizeof(SCpnt), GFP_KERNEL); 936 fc->rst_pkt = kmalloc(sizeof(SCpnt), GFP_KERNEL);
937 if (!fc->rst_pkt) return FAILED; 937 if (!fc->rst_pkt) return FAILED;
938 938
939 fcmd = FCP_CMND(fc->rst_pkt); 939 fcmd = FCP_CMND(fc->rst_pkt);
@@ -1107,7 +1107,7 @@ int fc_do_plogi(fc_channel *fc, unsigned char alpa, fc_wwn *node, fc_wwn *nport)
1107 logi *l; 1107 logi *l;
1108 int status; 1108 int status;
1109 1109
1110 l = (logi *)kzalloc(2 * sizeof(logi), GFP_KERNEL); 1110 l = kzalloc(2 * sizeof(logi), GFP_KERNEL);
1111 if (!l) return -ENOMEM; 1111 if (!l) return -ENOMEM;
1112 l->code = LS_PLOGI; 1112 l->code = LS_PLOGI;
1113 memcpy (&l->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn)); 1113 memcpy (&l->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn));
@@ -1141,7 +1141,7 @@ int fc_do_prli(fc_channel *fc, unsigned char alpa)
1141 prli *p; 1141 prli *p;
1142 int status; 1142 int status;
1143 1143
1144 p = (prli *)kzalloc(2 * sizeof(prli), GFP_KERNEL); 1144 p = kzalloc(2 * sizeof(prli), GFP_KERNEL);
1145 if (!p) return -ENOMEM; 1145 if (!p) return -ENOMEM;
1146 p->code = LS_PRLI; 1146 p->code = LS_PRLI;
1147 p->params[0] = 0x08002000; 1147 p->params[0] = 0x08002000;
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index e76d91906c99..891ef6d0b1bf 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -106,6 +106,31 @@ config SENSORS_K8TEMP
106 This driver can also be built as a module. If so, the module 106 This driver can also be built as a module. If so, the module
107 will be called k8temp. 107 will be called k8temp.
108 108
109config SENSORS_AMS
110 tristate "Apple Motion Sensor driver"
111 depends on HWMON && PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL
112 help
113 Support for the motion sensor included in PowerBooks. Includes
114 implementations for PMU and I2C.
115
116 This driver can also be built as a module. If so, the module
117 will be called ams.
118
119config SENSORS_AMS_PMU
120 bool "PMU variant"
121 depends on SENSORS_AMS && ADB_PMU
122 default y
123 help
124 PMU variant of motion sensor, found in late 2005 PowerBooks.
125
126config SENSORS_AMS_I2C
127 bool "I2C variant"
128 depends on SENSORS_AMS && I2C
129 default y
130 help
131 I2C variant of motion sensor, found in early 2005 PowerBooks and
132 iBooks.
133
109config SENSORS_ASB100 134config SENSORS_ASB100
110 tristate "Asus ASB100 Bach" 135 tristate "Asus ASB100 Bach"
111 depends on HWMON && I2C && EXPERIMENTAL 136 depends on HWMON && I2C && EXPERIMENTAL
@@ -142,11 +167,12 @@ config SENSORS_DS1621
142 will be called ds1621. 167 will be called ds1621.
143 168
144config SENSORS_F71805F 169config SENSORS_F71805F
145 tristate "Fintek F71805F/FG" 170 tristate "Fintek F71805F/FG and F71872F/FG"
146 depends on HWMON && EXPERIMENTAL 171 depends on HWMON && EXPERIMENTAL
147 help 172 help
148 If you say yes here you get support for hardware monitoring 173 If you say yes here you get support for hardware monitoring
149 features of the Fintek F71805F/FG chips. 174 features of the Fintek F71805F/FG and F71872F/FG Super-I/O
175 chips.
150 176
151 This driver can also be built as a module. If so, the module 177 This driver can also be built as a module. If so, the module
152 will be called f71805f. 178 will be called f71805f.
@@ -353,6 +379,19 @@ config SENSORS_PC87360
353 This driver can also be built as a module. If so, the module 379 This driver can also be built as a module. If so, the module
354 will be called pc87360. 380 will be called pc87360.
355 381
382config SENSORS_PC87427
383 tristate "National Semiconductor PC87427"
384 depends on HWMON && EXPERIMENTAL
385 help
386 If you say yes here you get access to the hardware monitoring
387 functions of the National Semiconductor PC87427 Super-I/O chip.
388 The chip has two distinct logical devices, one for fan speed
389 monitoring and control, and one for voltage and temperature
390 monitoring. Only fan speed monitoring is supported right now.
391
392 This driver can also be built as a module. If so, the module
393 will be called pc87427.
394
356config SENSORS_SIS5595 395config SENSORS_SIS5595
357 tristate "Silicon Integrated Systems Corp. SiS5595" 396 tristate "Silicon Integrated Systems Corp. SiS5595"
358 depends on HWMON && I2C && PCI && EXPERIMENTAL 397 depends on HWMON && I2C && PCI && EXPERIMENTAL
@@ -474,6 +513,16 @@ config SENSORS_W83792D
474 This driver can also be built as a module. If so, the module 513 This driver can also be built as a module. If so, the module
475 will be called w83792d. 514 will be called w83792d.
476 515
516config SENSORS_W83793
517 tristate "Winbond W83793"
518 depends on HWMON && I2C && EXPERIMENTAL
519 help
520 If you say yes here you get support for the Winbond W83793
521 hardware monitoring chip.
522
523 This driver can also be built as a module. If so, the module
524 will be called w83793.
525
477config SENSORS_W83L785TS 526config SENSORS_W83L785TS
478 tristate "Winbond W83L785TS-S" 527 tristate "Winbond W83L785TS-S"
479 depends on HWMON && I2C && EXPERIMENTAL 528 depends on HWMON && I2C && EXPERIMENTAL
@@ -527,6 +576,9 @@ config SENSORS_HDAPS
527 This driver also provides an absolute input class device, allowing 576 This driver also provides an absolute input class device, allowing
528 the laptop to act as a pinball machine-esque joystick. 577 the laptop to act as a pinball machine-esque joystick.
529 578
579 If your ThinkPad is not recognized by the driver, please update to latest
580 BIOS. This is especially the case for some R52 ThinkPads.
581
530 Say Y here if you have an applicable laptop and want to experience 582 Say Y here if you have an applicable laptop and want to experience
531 the awesome power of hdaps. 583 the awesome power of hdaps.
532 584
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index af01cc64f7d2..31661124271e 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_HWMON_VID) += hwmon-vid.o
9obj-$(CONFIG_SENSORS_ASB100) += asb100.o 9obj-$(CONFIG_SENSORS_ASB100) += asb100.o
10obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o 10obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o
11obj-$(CONFIG_SENSORS_W83792D) += w83792d.o 11obj-$(CONFIG_SENSORS_W83792D) += w83792d.o
12obj-$(CONFIG_SENSORS_W83793) += w83793.o
12obj-$(CONFIG_SENSORS_W83781D) += w83781d.o 13obj-$(CONFIG_SENSORS_W83781D) += w83781d.o
13obj-$(CONFIG_SENSORS_W83791D) += w83791d.o 14obj-$(CONFIG_SENSORS_W83791D) += w83791d.o
14 15
@@ -18,6 +19,7 @@ obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o
18obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o 19obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
19obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o 20obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
20obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o 21obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
22obj-$(CONFIG_SENSORS_AMS) += ams/
21obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o 23obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
22obj-$(CONFIG_SENSORS_DS1621) += ds1621.o 24obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
23obj-$(CONFIG_SENSORS_F71805F) += f71805f.o 25obj-$(CONFIG_SENSORS_F71805F) += f71805f.o
@@ -41,6 +43,7 @@ obj-$(CONFIG_SENSORS_LM90) += lm90.o
41obj-$(CONFIG_SENSORS_LM92) += lm92.o 43obj-$(CONFIG_SENSORS_LM92) += lm92.o
42obj-$(CONFIG_SENSORS_MAX1619) += max1619.o 44obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
43obj-$(CONFIG_SENSORS_PC87360) += pc87360.o 45obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
46obj-$(CONFIG_SENSORS_PC87427) += pc87427.o
44obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o 47obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
45obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o 48obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
46obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o 49obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
diff --git a/drivers/hwmon/ams/Makefile b/drivers/hwmon/ams/Makefile
new file mode 100644
index 000000000000..41c95b2089dc
--- /dev/null
+++ b/drivers/hwmon/ams/Makefile
@@ -0,0 +1,8 @@
1#
2# Makefile for Apple Motion Sensor driver
3#
4
5ams-y := ams-core.o ams-input.o
6ams-$(CONFIG_SENSORS_AMS_PMU) += ams-pmu.o
7ams-$(CONFIG_SENSORS_AMS_I2C) += ams-i2c.o
8obj-$(CONFIG_SENSORS_AMS) += ams.o
diff --git a/drivers/hwmon/ams/ams-core.c b/drivers/hwmon/ams/ams-core.c
new file mode 100644
index 000000000000..f1f0f5d0442c
--- /dev/null
+++ b/drivers/hwmon/ams/ams-core.c
@@ -0,0 +1,265 @@
1/*
2 * Apple Motion Sensor driver
3 *
4 * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
5 * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#include <linux/module.h>
23#include <linux/types.h>
24#include <linux/errno.h>
25#include <linux/init.h>
26#include <linux/module.h>
27#include <asm/pmac_pfunc.h>
28#include <asm/of_platform.h>
29
30#include "ams.h"
31
32/* There is only one motion sensor per machine */
33struct ams ams_info;
34
35static unsigned int verbose;
36module_param(verbose, bool, 0644);
37MODULE_PARM_DESC(verbose, "Show free falls and shocks in kernel output");
38
39/* Call with ams_info.lock held! */
40void ams_sensors(s8 *x, s8 *y, s8 *z)
41{
42 u32 orient = ams_info.vflag? ams_info.orient1 : ams_info.orient2;
43
44 if (orient & 0x80)
45 /* X and Y swapped */
46 ams_info.get_xyz(y, x, z);
47 else
48 ams_info.get_xyz(x, y, z);
49
50 if (orient & 0x04)
51 *z = ~(*z);
52 if (orient & 0x02)
53 *y = ~(*y);
54 if (orient & 0x01)
55 *x = ~(*x);
56}
57
58static ssize_t ams_show_current(struct device *dev,
59 struct device_attribute *attr, char *buf)
60{
61 s8 x, y, z;
62
63 mutex_lock(&ams_info.lock);
64 ams_sensors(&x, &y, &z);
65 mutex_unlock(&ams_info.lock);
66
67 return snprintf(buf, PAGE_SIZE, "%d %d %d\n", x, y, z);
68}
69
70static DEVICE_ATTR(current, S_IRUGO, ams_show_current, NULL);
71
72static void ams_handle_irq(void *data)
73{
74 enum ams_irq irq = *((enum ams_irq *)data);
75
76 spin_lock(&ams_info.irq_lock);
77
78 ams_info.worker_irqs |= irq;
79 schedule_work(&ams_info.worker);
80
81 spin_unlock(&ams_info.irq_lock);
82}
83
84static enum ams_irq ams_freefall_irq_data = AMS_IRQ_FREEFALL;
85static struct pmf_irq_client ams_freefall_client = {
86 .owner = THIS_MODULE,
87 .handler = ams_handle_irq,
88 .data = &ams_freefall_irq_data,
89};
90
91static enum ams_irq ams_shock_irq_data = AMS_IRQ_SHOCK;
92static struct pmf_irq_client ams_shock_client = {
93 .owner = THIS_MODULE,
94 .handler = ams_handle_irq,
95 .data = &ams_shock_irq_data,
96};
97
98/* Once hard disk parking is implemented in the kernel, this function can
99 * trigger it.
100 */
101static void ams_worker(struct work_struct *work)
102{
103 mutex_lock(&ams_info.lock);
104
105 if (ams_info.has_device) {
106 unsigned long flags;
107
108 spin_lock_irqsave(&ams_info.irq_lock, flags);
109
110 if (ams_info.worker_irqs & AMS_IRQ_FREEFALL) {
111 if (verbose)
112 printk(KERN_INFO "ams: freefall detected!\n");
113
114 ams_info.worker_irqs &= ~AMS_IRQ_FREEFALL;
115
116 /* we must call this with interrupts enabled */
117 spin_unlock_irqrestore(&ams_info.irq_lock, flags);
118 ams_info.clear_irq(AMS_IRQ_FREEFALL);
119 spin_lock_irqsave(&ams_info.irq_lock, flags);
120 }
121
122 if (ams_info.worker_irqs & AMS_IRQ_SHOCK) {
123 if (verbose)
124 printk(KERN_INFO "ams: shock detected!\n");
125
126 ams_info.worker_irqs &= ~AMS_IRQ_SHOCK;
127
128 /* we must call this with interrupts enabled */
129 spin_unlock_irqrestore(&ams_info.irq_lock, flags);
130 ams_info.clear_irq(AMS_IRQ_SHOCK);
131 spin_lock_irqsave(&ams_info.irq_lock, flags);
132 }
133
134 spin_unlock_irqrestore(&ams_info.irq_lock, flags);
135 }
136
137 mutex_unlock(&ams_info.lock);
138}
139
140/* Call with ams_info.lock held! */
141int ams_sensor_attach(void)
142{
143 int result;
144 u32 *prop;
145
146 /* Get orientation */
147 prop = (u32*)get_property(ams_info.of_node, "orientation", NULL);
148 if (!prop)
149 return -ENODEV;
150 ams_info.orient1 = *prop;
151 ams_info.orient2 = *(prop + 1);
152
153 /* Register freefall interrupt handler */
154 result = pmf_register_irq_client(ams_info.of_node,
155 "accel-int-1",
156 &ams_freefall_client);
157 if (result < 0)
158 return -ENODEV;
159
160 /* Reset saved irqs */
161 ams_info.worker_irqs = 0;
162
163 /* Register shock interrupt handler */
164 result = pmf_register_irq_client(ams_info.of_node,
165 "accel-int-2",
166 &ams_shock_client);
167 if (result < 0)
168 goto release_freefall;
169
170 /* Create device */
171 ams_info.of_dev = of_platform_device_create(ams_info.of_node, "ams", NULL);
172 if (!ams_info.of_dev) {
173 result = -ENODEV;
174 goto release_shock;
175 }
176
177 /* Create attributes */
178 result = device_create_file(&ams_info.of_dev->dev, &dev_attr_current);
179 if (result)
180 goto release_of;
181
182 ams_info.vflag = !!(ams_info.get_vendor() & 0x10);
183
184 /* Init input device */
185 result = ams_input_init();
186 if (result)
187 goto release_device_file;
188
189 return result;
190release_device_file:
191 device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
192release_of:
193 of_device_unregister(ams_info.of_dev);
194release_shock:
195 pmf_unregister_irq_client(&ams_shock_client);
196release_freefall:
197 pmf_unregister_irq_client(&ams_freefall_client);
198 return result;
199}
200
201int __init ams_init(void)
202{
203 struct device_node *np;
204
205 spin_lock_init(&ams_info.irq_lock);
206 mutex_init(&ams_info.lock);
207 INIT_WORK(&ams_info.worker, ams_worker);
208
209#ifdef CONFIG_SENSORS_AMS_I2C
210 np = of_find_node_by_name(NULL, "accelerometer");
211 if (np && device_is_compatible(np, "AAPL,accelerometer_1"))
212 /* Found I2C motion sensor */
213 return ams_i2c_init(np);
214#endif
215
216#ifdef CONFIG_SENSORS_AMS_PMU
217 np = of_find_node_by_name(NULL, "sms");
218 if (np && device_is_compatible(np, "sms"))
219 /* Found PMU motion sensor */
220 return ams_pmu_init(np);
221#endif
222
223 printk(KERN_ERR "ams: No motion sensor found.\n");
224
225 return -ENODEV;
226}
227
228void ams_exit(void)
229{
230 mutex_lock(&ams_info.lock);
231
232 if (ams_info.has_device) {
233 /* Remove input device */
234 ams_input_exit();
235
236 /* Shut down implementation */
237 ams_info.exit();
238
239 /* Flush interrupt worker
240 *
241 * We do this after ams_info.exit(), because an interrupt might
242 * have arrived before disabling them.
243 */
244 flush_scheduled_work();
245
246 /* Remove attributes */
247 device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
248
249 /* Remove device */
250 of_device_unregister(ams_info.of_dev);
251
252 /* Remove handler */
253 pmf_unregister_irq_client(&ams_shock_client);
254 pmf_unregister_irq_client(&ams_freefall_client);
255 }
256
257 mutex_unlock(&ams_info.lock);
258}
259
260MODULE_AUTHOR("Stelian Pop, Michael Hanselmann");
261MODULE_DESCRIPTION("Apple Motion Sensor driver");
262MODULE_LICENSE("GPL");
263
264module_init(ams_init);
265module_exit(ams_exit);
diff --git a/drivers/hwmon/ams/ams-i2c.c b/drivers/hwmon/ams/ams-i2c.c
new file mode 100644
index 000000000000..0d24bdfea53e
--- /dev/null
+++ b/drivers/hwmon/ams/ams-i2c.c
@@ -0,0 +1,299 @@
1/*
2 * Apple Motion Sensor driver (I2C variant)
3 *
4 * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
5 * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
6 *
7 * Clean room implementation based on the reverse engineered Mac OS X driver by
8 * Johannes Berg <johannes@sipsolutions.net>, documentation available at
9 * http://johannes.sipsolutions.net/PowerBook/Apple_Motion_Sensor_Specification
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
17#include <linux/module.h>
18#include <linux/types.h>
19#include <linux/errno.h>
20#include <linux/init.h>
21#include <linux/delay.h>
22
23#include "ams.h"
24
25/* AMS registers */
26#define AMS_COMMAND 0x00 /* command register */
27#define AMS_STATUS 0x01 /* status register */
28#define AMS_CTRL1 0x02 /* read control 1 (number of values) */
29#define AMS_CTRL2 0x03 /* read control 2 (offset?) */
30#define AMS_CTRL3 0x04 /* read control 3 (size of each value?) */
31#define AMS_DATA1 0x05 /* read data 1 */
32#define AMS_DATA2 0x06 /* read data 2 */
33#define AMS_DATA3 0x07 /* read data 3 */
34#define AMS_DATA4 0x08 /* read data 4 */
35#define AMS_DATAX 0x20 /* data X */
36#define AMS_DATAY 0x21 /* data Y */
37#define AMS_DATAZ 0x22 /* data Z */
38#define AMS_FREEFALL 0x24 /* freefall int control */
39#define AMS_SHOCK 0x25 /* shock int control */
40#define AMS_SENSLOW 0x26 /* sensitivity low limit */
41#define AMS_SENSHIGH 0x27 /* sensitivity high limit */
42#define AMS_CTRLX 0x28 /* control X */
43#define AMS_CTRLY 0x29 /* control Y */
44#define AMS_CTRLZ 0x2A /* control Z */
45#define AMS_UNKNOWN1 0x2B /* unknown 1 */
46#define AMS_UNKNOWN2 0x2C /* unknown 2 */
47#define AMS_UNKNOWN3 0x2D /* unknown 3 */
48#define AMS_VENDOR 0x2E /* vendor */
49
50/* AMS commands - use with the AMS_COMMAND register */
51enum ams_i2c_cmd {
52 AMS_CMD_NOOP = 0,
53 AMS_CMD_VERSION,
54 AMS_CMD_READMEM,
55 AMS_CMD_WRITEMEM,
56 AMS_CMD_ERASEMEM,
57 AMS_CMD_READEE,
58 AMS_CMD_WRITEEE,
59 AMS_CMD_RESET,
60 AMS_CMD_START,
61};
62
63static int ams_i2c_attach(struct i2c_adapter *adapter);
64static int ams_i2c_detach(struct i2c_adapter *adapter);
65
66static struct i2c_driver ams_i2c_driver = {
67 .driver = {
68 .name = "ams",
69 .owner = THIS_MODULE,
70 },
71 .attach_adapter = ams_i2c_attach,
72 .detach_adapter = ams_i2c_detach,
73};
74
75static s32 ams_i2c_read(u8 reg)
76{
77 return i2c_smbus_read_byte_data(&ams_info.i2c_client, reg);
78}
79
80static int ams_i2c_write(u8 reg, u8 value)
81{
82 return i2c_smbus_write_byte_data(&ams_info.i2c_client, reg, value);
83}
84
85static int ams_i2c_cmd(enum ams_i2c_cmd cmd)
86{
87 s32 result;
88 int remaining = HZ / 20;
89
90 ams_i2c_write(AMS_COMMAND, cmd);
91 mdelay(5);
92
93 while (remaining) {
94 result = ams_i2c_read(AMS_COMMAND);
95 if (result == 0 || result & 0x80)
96 return 0;
97
98 remaining = schedule_timeout(remaining);
99 }
100
101 return -1;
102}
103
104static void ams_i2c_set_irq(enum ams_irq reg, char enable)
105{
106 if (reg & AMS_IRQ_FREEFALL) {
107 u8 val = ams_i2c_read(AMS_CTRLX);
108 if (enable)
109 val |= 0x80;
110 else
111 val &= ~0x80;
112 ams_i2c_write(AMS_CTRLX, val);
113 }
114
115 if (reg & AMS_IRQ_SHOCK) {
116 u8 val = ams_i2c_read(AMS_CTRLY);
117 if (enable)
118 val |= 0x80;
119 else
120 val &= ~0x80;
121 ams_i2c_write(AMS_CTRLY, val);
122 }
123
124 if (reg & AMS_IRQ_GLOBAL) {
125 u8 val = ams_i2c_read(AMS_CTRLZ);
126 if (enable)
127 val |= 0x80;
128 else
129 val &= ~0x80;
130 ams_i2c_write(AMS_CTRLZ, val);
131 }
132}
133
134static void ams_i2c_clear_irq(enum ams_irq reg)
135{
136 if (reg & AMS_IRQ_FREEFALL)
137 ams_i2c_write(AMS_FREEFALL, 0);
138
139 if (reg & AMS_IRQ_SHOCK)
140 ams_i2c_write(AMS_SHOCK, 0);
141}
142
143static u8 ams_i2c_get_vendor(void)
144{
145 return ams_i2c_read(AMS_VENDOR);
146}
147
148static void ams_i2c_get_xyz(s8 *x, s8 *y, s8 *z)
149{
150 *x = ams_i2c_read(AMS_DATAX);
151 *y = ams_i2c_read(AMS_DATAY);
152 *z = ams_i2c_read(AMS_DATAZ);
153}
154
155static int ams_i2c_attach(struct i2c_adapter *adapter)
156{
157 unsigned long bus;
158 int vmaj, vmin;
159 int result;
160
161 /* There can be only one */
162 if (unlikely(ams_info.has_device))
163 return -ENODEV;
164
165 if (strncmp(adapter->name, "uni-n", 5))
166 return -ENODEV;
167
168 bus = simple_strtoul(adapter->name + 6, NULL, 10);
169 if (bus != ams_info.i2c_bus)
170 return -ENODEV;
171
172 ams_info.i2c_client.addr = ams_info.i2c_address;
173 ams_info.i2c_client.adapter = adapter;
174 ams_info.i2c_client.driver = &ams_i2c_driver;
175 strcpy(ams_info.i2c_client.name, "Apple Motion Sensor");
176
177 if (ams_i2c_cmd(AMS_CMD_RESET)) {
178 printk(KERN_INFO "ams: Failed to reset the device\n");
179 return -ENODEV;
180 }
181
182 if (ams_i2c_cmd(AMS_CMD_START)) {
183 printk(KERN_INFO "ams: Failed to start the device\n");
184 return -ENODEV;
185 }
186
187 /* get version/vendor information */
188 ams_i2c_write(AMS_CTRL1, 0x02);
189 ams_i2c_write(AMS_CTRL2, 0x85);
190 ams_i2c_write(AMS_CTRL3, 0x01);
191
192 ams_i2c_cmd(AMS_CMD_READMEM);
193
194 vmaj = ams_i2c_read(AMS_DATA1);
195 vmin = ams_i2c_read(AMS_DATA2);
196 if (vmaj != 1 || vmin != 52) {
197 printk(KERN_INFO "ams: Incorrect device version (%d.%d)\n",
198 vmaj, vmin);
199 return -ENODEV;
200 }
201
202 ams_i2c_cmd(AMS_CMD_VERSION);
203
204 vmaj = ams_i2c_read(AMS_DATA1);
205 vmin = ams_i2c_read(AMS_DATA2);
206 if (vmaj != 0 || vmin != 1) {
207 printk(KERN_INFO "ams: Incorrect firmware version (%d.%d)\n",
208 vmaj, vmin);
209 return -ENODEV;
210 }
211
212 /* Disable interrupts */
213 ams_i2c_set_irq(AMS_IRQ_ALL, 0);
214
215 result = ams_sensor_attach();
216 if (result < 0)
217 return result;
218
219 /* Set default values */
220 ams_i2c_write(AMS_SENSLOW, 0x15);
221 ams_i2c_write(AMS_SENSHIGH, 0x60);
222 ams_i2c_write(AMS_CTRLX, 0x08);
223 ams_i2c_write(AMS_CTRLY, 0x0F);
224 ams_i2c_write(AMS_CTRLZ, 0x4F);
225 ams_i2c_write(AMS_UNKNOWN1, 0x14);
226
227 /* Clear interrupts */
228 ams_i2c_clear_irq(AMS_IRQ_ALL);
229
230 ams_info.has_device = 1;
231
232 /* Enable interrupts */
233 ams_i2c_set_irq(AMS_IRQ_ALL, 1);
234
235 printk(KERN_INFO "ams: Found I2C based motion sensor\n");
236
237 return 0;
238}
239
240static int ams_i2c_detach(struct i2c_adapter *adapter)
241{
242 if (ams_info.has_device) {
243 /* Disable interrupts */
244 ams_i2c_set_irq(AMS_IRQ_ALL, 0);
245
246 /* Clear interrupts */
247 ams_i2c_clear_irq(AMS_IRQ_ALL);
248
249 printk(KERN_INFO "ams: Unloading\n");
250
251 ams_info.has_device = 0;
252 }
253
254 return 0;
255}
256
257static void ams_i2c_exit(void)
258{
259 i2c_del_driver(&ams_i2c_driver);
260}
261
262int __init ams_i2c_init(struct device_node *np)
263{
264 char *tmp_bus;
265 int result;
266 u32 *prop;
267
268 mutex_lock(&ams_info.lock);
269
270 /* Set implementation stuff */
271 ams_info.of_node = np;
272 ams_info.exit = ams_i2c_exit;
273 ams_info.get_vendor = ams_i2c_get_vendor;
274 ams_info.get_xyz = ams_i2c_get_xyz;
275 ams_info.clear_irq = ams_i2c_clear_irq;
276 ams_info.bustype = BUS_I2C;
277
278 /* look for bus either using "reg" or by path */
279 prop = (u32*)get_property(ams_info.of_node, "reg", NULL);
280 if (!prop) {
281 result = -ENODEV;
282
283 goto exit;
284 }
285
286 tmp_bus = strstr(ams_info.of_node->full_name, "/i2c-bus@");
287 if (tmp_bus)
288 ams_info.i2c_bus = *(tmp_bus + 9) - '0';
289 else
290 ams_info.i2c_bus = ((*prop) >> 8) & 0x0f;
291 ams_info.i2c_address = ((*prop) & 0xff) >> 1;
292
293 result = i2c_add_driver(&ams_i2c_driver);
294
295exit:
296 mutex_unlock(&ams_info.lock);
297
298 return result;
299}
diff --git a/drivers/hwmon/ams/ams-input.c b/drivers/hwmon/ams/ams-input.c
new file mode 100644
index 000000000000..f126aa485134
--- /dev/null
+++ b/drivers/hwmon/ams/ams-input.c
@@ -0,0 +1,160 @@
1/*
2 * Apple Motion Sensor driver (joystick emulation)
3 *
4 * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
5 * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
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
13#include <linux/module.h>
14
15#include <linux/types.h>
16#include <linux/errno.h>
17#include <linux/init.h>
18#include <linux/delay.h>
19
20#include "ams.h"
21
22static unsigned int joystick;
23module_param(joystick, bool, 0644);
24MODULE_PARM_DESC(joystick, "Enable the input class device on module load");
25
26static unsigned int invert;
27module_param(invert, bool, 0644);
28MODULE_PARM_DESC(invert, "Invert input data on X and Y axis");
29
30static int ams_input_kthread(void *data)
31{
32 s8 x, y, z;
33
34 while (!kthread_should_stop()) {
35 mutex_lock(&ams_info.lock);
36
37 ams_sensors(&x, &y, &z);
38
39 x -= ams_info.xcalib;
40 y -= ams_info.ycalib;
41 z -= ams_info.zcalib;
42
43 input_report_abs(ams_info.idev, ABS_X, invert ? -x : x);
44 input_report_abs(ams_info.idev, ABS_Y, invert ? -y : y);
45 input_report_abs(ams_info.idev, ABS_Z, z);
46
47 input_sync(ams_info.idev);
48
49 mutex_unlock(&ams_info.lock);
50
51 msleep(25);
52 }
53
54 return 0;
55}
56
57static int ams_input_open(struct input_dev *dev)
58{
59 ams_info.kthread = kthread_run(ams_input_kthread, NULL, "kams");
60 return IS_ERR(ams_info.kthread) ? PTR_ERR(ams_info.kthread) : 0;
61}
62
63static void ams_input_close(struct input_dev *dev)
64{
65 kthread_stop(ams_info.kthread);
66}
67
68/* Call with ams_info.lock held! */
69static void ams_input_enable(void)
70{
71 s8 x, y, z;
72
73 if (ams_info.idev)
74 return;
75
76 ams_sensors(&x, &y, &z);
77 ams_info.xcalib = x;
78 ams_info.ycalib = y;
79 ams_info.zcalib = z;
80
81 ams_info.idev = input_allocate_device();
82 if (!ams_info.idev)
83 return;
84
85 ams_info.idev->name = "Apple Motion Sensor";
86 ams_info.idev->id.bustype = ams_info.bustype;
87 ams_info.idev->id.vendor = 0;
88 ams_info.idev->open = ams_input_open;
89 ams_info.idev->close = ams_input_close;
90 ams_info.idev->cdev.dev = &ams_info.of_dev->dev;
91
92 input_set_abs_params(ams_info.idev, ABS_X, -50, 50, 3, 0);
93 input_set_abs_params(ams_info.idev, ABS_Y, -50, 50, 3, 0);
94 input_set_abs_params(ams_info.idev, ABS_Z, -50, 50, 3, 0);
95
96 set_bit(EV_ABS, ams_info.idev->evbit);
97 set_bit(EV_KEY, ams_info.idev->evbit);
98 set_bit(BTN_TOUCH, ams_info.idev->keybit);
99
100 if (input_register_device(ams_info.idev)) {
101 input_free_device(ams_info.idev);
102 ams_info.idev = NULL;
103 return;
104 }
105}
106
107/* Call with ams_info.lock held! */
108static void ams_input_disable(void)
109{
110 if (ams_info.idev) {
111 input_unregister_device(ams_info.idev);
112 ams_info.idev = NULL;
113 }
114}
115
116static ssize_t ams_input_show_joystick(struct device *dev,
117 struct device_attribute *attr, char *buf)
118{
119 return sprintf(buf, "%d\n", joystick);
120}
121
122static ssize_t ams_input_store_joystick(struct device *dev,
123 struct device_attribute *attr, const char *buf, size_t count)
124{
125 if (sscanf(buf, "%d\n", &joystick) != 1)
126 return -EINVAL;
127
128 mutex_lock(&ams_info.lock);
129
130 if (joystick)
131 ams_input_enable();
132 else
133 ams_input_disable();
134
135 mutex_unlock(&ams_info.lock);
136
137 return count;
138}
139
140static DEVICE_ATTR(joystick, S_IRUGO | S_IWUSR,
141 ams_input_show_joystick, ams_input_store_joystick);
142
143/* Call with ams_info.lock held! */
144int ams_input_init(void)
145{
146 int result;
147
148 result = device_create_file(&ams_info.of_dev->dev, &dev_attr_joystick);
149
150 if (!result && joystick)
151 ams_input_enable();
152 return result;
153}
154
155/* Call with ams_info.lock held! */
156void ams_input_exit()
157{
158 ams_input_disable();
159 device_remove_file(&ams_info.of_dev->dev, &dev_attr_joystick);
160}
diff --git a/drivers/hwmon/ams/ams-pmu.c b/drivers/hwmon/ams/ams-pmu.c
new file mode 100644
index 000000000000..4636ae031a53
--- /dev/null
+++ b/drivers/hwmon/ams/ams-pmu.c
@@ -0,0 +1,207 @@
1/*
2 * Apple Motion Sensor driver (PMU variant)
3 *
4 * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/module.h>
13#include <linux/types.h>
14#include <linux/errno.h>
15#include <linux/init.h>
16#include <linux/adb.h>
17#include <linux/pmu.h>
18
19#include "ams.h"
20
21/* Attitude */
22#define AMS_X 0x00
23#define AMS_Y 0x01
24#define AMS_Z 0x02
25
26/* Not exactly known, maybe chip vendor */
27#define AMS_VENDOR 0x03
28
29/* Freefall registers */
30#define AMS_FF_CLEAR 0x04
31#define AMS_FF_ENABLE 0x05
32#define AMS_FF_LOW_LIMIT 0x06
33#define AMS_FF_DEBOUNCE 0x07
34
35/* Shock registers */
36#define AMS_SHOCK_CLEAR 0x08
37#define AMS_SHOCK_ENABLE 0x09
38#define AMS_SHOCK_HIGH_LIMIT 0x0a
39#define AMS_SHOCK_DEBOUNCE 0x0b
40
41/* Global interrupt and power control register */
42#define AMS_CONTROL 0x0c
43
44static u8 ams_pmu_cmd;
45
46static void ams_pmu_req_complete(struct adb_request *req)
47{
48 complete((struct completion *)req->arg);
49}
50
51/* Only call this function from task context */
52static void ams_pmu_set_register(u8 reg, u8 value)
53{
54 static struct adb_request req;
55 DECLARE_COMPLETION(req_complete);
56
57 req.arg = &req_complete;
58 if (pmu_request(&req, ams_pmu_req_complete, 4, ams_pmu_cmd, 0x00, reg, value))
59 return;
60
61 wait_for_completion(&req_complete);
62}
63
64/* Only call this function from task context */
65static u8 ams_pmu_get_register(u8 reg)
66{
67 static struct adb_request req;
68 DECLARE_COMPLETION(req_complete);
69
70 req.arg = &req_complete;
71 if (pmu_request(&req, ams_pmu_req_complete, 3, ams_pmu_cmd, 0x01, reg))
72 return 0;
73
74 wait_for_completion(&req_complete);
75
76 if (req.reply_len > 0)
77 return req.reply[0];
78 else
79 return 0;
80}
81
82/* Enables or disables the specified interrupts */
83static void ams_pmu_set_irq(enum ams_irq reg, char enable)
84{
85 if (reg & AMS_IRQ_FREEFALL) {
86 u8 val = ams_pmu_get_register(AMS_FF_ENABLE);
87 if (enable)
88 val |= 0x80;
89 else
90 val &= ~0x80;
91 ams_pmu_set_register(AMS_FF_ENABLE, val);
92 }
93
94 if (reg & AMS_IRQ_SHOCK) {
95 u8 val = ams_pmu_get_register(AMS_SHOCK_ENABLE);
96 if (enable)
97 val |= 0x80;
98 else
99 val &= ~0x80;
100 ams_pmu_set_register(AMS_SHOCK_ENABLE, val);
101 }
102
103 if (reg & AMS_IRQ_GLOBAL) {
104 u8 val = ams_pmu_get_register(AMS_CONTROL);
105 if (enable)
106 val |= 0x80;
107 else
108 val &= ~0x80;
109 ams_pmu_set_register(AMS_CONTROL, val);
110 }
111}
112
113static void ams_pmu_clear_irq(enum ams_irq reg)
114{
115 if (reg & AMS_IRQ_FREEFALL)
116 ams_pmu_set_register(AMS_FF_CLEAR, 0x00);
117
118 if (reg & AMS_IRQ_SHOCK)
119 ams_pmu_set_register(AMS_SHOCK_CLEAR, 0x00);
120}
121
122static u8 ams_pmu_get_vendor(void)
123{
124 return ams_pmu_get_register(AMS_VENDOR);
125}
126
127static void ams_pmu_get_xyz(s8 *x, s8 *y, s8 *z)
128{
129 *x = ams_pmu_get_register(AMS_X);
130 *y = ams_pmu_get_register(AMS_Y);
131 *z = ams_pmu_get_register(AMS_Z);
132}
133
134static void ams_pmu_exit(void)
135{
136 /* Disable interrupts */
137 ams_pmu_set_irq(AMS_IRQ_ALL, 0);
138
139 /* Clear interrupts */
140 ams_pmu_clear_irq(AMS_IRQ_ALL);
141
142 ams_info.has_device = 0;
143
144 printk(KERN_INFO "ams: Unloading\n");
145}
146
147int __init ams_pmu_init(struct device_node *np)
148{
149 u32 *prop;
150 int result;
151
152 mutex_lock(&ams_info.lock);
153
154 /* Set implementation stuff */
155 ams_info.of_node = np;
156 ams_info.exit = ams_pmu_exit;
157 ams_info.get_vendor = ams_pmu_get_vendor;
158 ams_info.get_xyz = ams_pmu_get_xyz;
159 ams_info.clear_irq = ams_pmu_clear_irq;
160 ams_info.bustype = BUS_HOST;
161
162 /* Get PMU command, should be 0x4e, but we can never know */
163 prop = (u32*)get_property(ams_info.of_node, "reg", NULL);
164 if (!prop) {
165 result = -ENODEV;
166 goto exit;
167 }
168 ams_pmu_cmd = ((*prop) >> 8) & 0xff;
169
170 /* Disable interrupts */
171 ams_pmu_set_irq(AMS_IRQ_ALL, 0);
172
173 /* Clear interrupts */
174 ams_pmu_clear_irq(AMS_IRQ_ALL);
175
176 result = ams_sensor_attach();
177 if (result < 0)
178 goto exit;
179
180 /* Set default values */
181 ams_pmu_set_register(AMS_FF_LOW_LIMIT, 0x15);
182 ams_pmu_set_register(AMS_FF_ENABLE, 0x08);
183 ams_pmu_set_register(AMS_FF_DEBOUNCE, 0x14);
184
185 ams_pmu_set_register(AMS_SHOCK_HIGH_LIMIT, 0x60);
186 ams_pmu_set_register(AMS_SHOCK_ENABLE, 0x0f);
187 ams_pmu_set_register(AMS_SHOCK_DEBOUNCE, 0x14);
188
189 ams_pmu_set_register(AMS_CONTROL, 0x4f);
190
191 /* Clear interrupts */
192 ams_pmu_clear_irq(AMS_IRQ_ALL);
193
194 ams_info.has_device = 1;
195
196 /* Enable interrupts */
197 ams_pmu_set_irq(AMS_IRQ_ALL, 1);
198
199 printk(KERN_INFO "ams: Found PMU based motion sensor\n");
200
201 result = 0;
202
203exit:
204 mutex_unlock(&ams_info.lock);
205
206 return result;
207}
diff --git a/drivers/hwmon/ams/ams.h b/drivers/hwmon/ams/ams.h
new file mode 100644
index 000000000000..240730e6bcde
--- /dev/null
+++ b/drivers/hwmon/ams/ams.h
@@ -0,0 +1,72 @@
1#include <linux/i2c.h>
2#include <linux/input.h>
3#include <linux/kthread.h>
4#include <linux/mutex.h>
5#include <linux/spinlock.h>
6#include <linux/types.h>
7#include <asm/of_device.h>
8
9enum ams_irq {
10 AMS_IRQ_FREEFALL = 0x01,
11 AMS_IRQ_SHOCK = 0x02,
12 AMS_IRQ_GLOBAL = 0x04,
13 AMS_IRQ_ALL =
14 AMS_IRQ_FREEFALL |
15 AMS_IRQ_SHOCK |
16 AMS_IRQ_GLOBAL,
17};
18
19struct ams {
20 /* Locks */
21 spinlock_t irq_lock;
22 struct mutex lock;
23
24 /* General properties */
25 struct device_node *of_node;
26 struct of_device *of_dev;
27 char has_device;
28 char vflag;
29 u32 orient1;
30 u32 orient2;
31
32 /* Interrupt worker */
33 struct work_struct worker;
34 u8 worker_irqs;
35
36 /* Implementation
37 *
38 * Only call these functions with the main lock held.
39 */
40 void (*exit)(void);
41
42 void (*get_xyz)(s8 *x, s8 *y, s8 *z);
43 u8 (*get_vendor)(void);
44
45 void (*clear_irq)(enum ams_irq reg);
46
47#ifdef CONFIG_SENSORS_AMS_I2C
48 /* I2C properties */
49 int i2c_bus;
50 int i2c_address;
51 struct i2c_client i2c_client;
52#endif
53
54 /* Joystick emulation */
55 struct task_struct *kthread;
56 struct input_dev *idev;
57 __u16 bustype;
58
59 /* calibrated null values */
60 int xcalib, ycalib, zcalib;
61};
62
63extern struct ams ams_info;
64
65extern void ams_sensors(s8 *x, s8 *y, s8 *z);
66extern int ams_sensor_attach(void);
67
68extern int ams_pmu_init(struct device_node *np);
69extern int ams_i2c_init(struct device_node *np);
70
71extern int ams_input_init(void);
72extern void ams_input_exit(void);
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index de17a72149d9..a272cae8f60e 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -1,12 +1,15 @@
1/* 1/*
2 * f71805f.c - driver for the Fintek F71805F/FG Super-I/O chip integrated 2 * f71805f.c - driver for the Fintek F71805F/FG and F71872F/FG Super-I/O
3 * hardware monitoring features 3 * chips integrated hardware monitoring features
4 * Copyright (C) 2005-2006 Jean Delvare <khali@linux-fr.org> 4 * Copyright (C) 2005-2006 Jean Delvare <khali@linux-fr.org>
5 * 5 *
6 * The F71805F/FG is a LPC Super-I/O chip made by Fintek. It integrates 6 * The F71805F/FG is a LPC Super-I/O chip made by Fintek. It integrates
7 * complete hardware monitoring features: voltage, fan and temperature 7 * complete hardware monitoring features: voltage, fan and temperature
8 * sensors, and manual and automatic fan speed control. 8 * sensors, and manual and automatic fan speed control.
9 * 9 *
10 * The F71872F/FG is almost the same, with two more voltages monitored,
11 * and 6 VID inputs.
12 *
10 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 14 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 15 * the Free Software Foundation; either version 2 of the License, or
@@ -37,6 +40,7 @@
37static struct platform_device *pdev; 40static struct platform_device *pdev;
38 41
39#define DRVNAME "f71805f" 42#define DRVNAME "f71805f"
43enum kinds { f71805f, f71872f };
40 44
41/* 45/*
42 * Super-I/O constants and functions 46 * Super-I/O constants and functions
@@ -48,11 +52,13 @@ static struct platform_device *pdev;
48#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ 52#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */
49#define SIO_REG_DEVREV 0x22 /* Device revision */ 53#define SIO_REG_DEVREV 0x22 /* Device revision */
50#define SIO_REG_MANID 0x23 /* Fintek ID (2 bytes) */ 54#define SIO_REG_MANID 0x23 /* Fintek ID (2 bytes) */
55#define SIO_REG_FNSEL1 0x29 /* Multi Function Select 1 (F71872F) */
51#define SIO_REG_ENABLE 0x30 /* Logical device enable */ 56#define SIO_REG_ENABLE 0x30 /* Logical device enable */
52#define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ 57#define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */
53 58
54#define SIO_FINTEK_ID 0x1934 59#define SIO_FINTEK_ID 0x1934
55#define SIO_F71805F_ID 0x0406 60#define SIO_F71805F_ID 0x0406
61#define SIO_F71872F_ID 0x0341
56 62
57static inline int 63static inline int
58superio_inb(int base, int reg) 64superio_inb(int base, int reg)
@@ -96,22 +102,25 @@ superio_exit(int base)
96 * ISA constants 102 * ISA constants
97 */ 103 */
98 104
99#define REGION_LENGTH 2 105#define REGION_LENGTH 8
100#define ADDR_REG_OFFSET 0 106#define ADDR_REG_OFFSET 5
101#define DATA_REG_OFFSET 1 107#define DATA_REG_OFFSET 6
102 108
103/* 109/*
104 * Registers 110 * Registers
105 */ 111 */
106 112
107/* in nr from 0 to 8 (8-bit values) */ 113/* in nr from 0 to 10 (8-bit values) */
108#define F71805F_REG_IN(nr) (0x10 + (nr)) 114#define F71805F_REG_IN(nr) (0x10 + (nr))
109#define F71805F_REG_IN_HIGH(nr) (0x40 + 2 * (nr)) 115#define F71805F_REG_IN_HIGH(nr) ((nr) < 10 ? 0x40 + 2 * (nr) : 0x2E)
110#define F71805F_REG_IN_LOW(nr) (0x41 + 2 * (nr)) 116#define F71805F_REG_IN_LOW(nr) ((nr) < 10 ? 0x41 + 2 * (nr) : 0x2F)
111/* fan nr from 0 to 2 (12-bit values, two registers) */ 117/* fan nr from 0 to 2 (12-bit values, two registers) */
112#define F71805F_REG_FAN(nr) (0x20 + 2 * (nr)) 118#define F71805F_REG_FAN(nr) (0x20 + 2 * (nr))
113#define F71805F_REG_FAN_LOW(nr) (0x28 + 2 * (nr)) 119#define F71805F_REG_FAN_LOW(nr) (0x28 + 2 * (nr))
120#define F71805F_REG_FAN_TARGET(nr) (0x69 + 16 * (nr))
114#define F71805F_REG_FAN_CTRL(nr) (0x60 + 16 * (nr)) 121#define F71805F_REG_FAN_CTRL(nr) (0x60 + 16 * (nr))
122#define F71805F_REG_PWM_FREQ(nr) (0x63 + 16 * (nr))
123#define F71805F_REG_PWM_DUTY(nr) (0x6B + 16 * (nr))
115/* temp nr from 0 to 2 (8-bit values) */ 124/* temp nr from 0 to 2 (8-bit values) */
116#define F71805F_REG_TEMP(nr) (0x1B + (nr)) 125#define F71805F_REG_TEMP(nr) (0x1B + (nr))
117#define F71805F_REG_TEMP_HIGH(nr) (0x54 + 2 * (nr)) 126#define F71805F_REG_TEMP_HIGH(nr) (0x54 + 2 * (nr))
@@ -122,6 +131,14 @@ superio_exit(int base)
122/* status nr from 0 to 2 */ 131/* status nr from 0 to 2 */
123#define F71805F_REG_STATUS(nr) (0x36 + (nr)) 132#define F71805F_REG_STATUS(nr) (0x36 + (nr))
124 133
134/* individual register bits */
135#define FAN_CTRL_DC_MODE 0x10
136#define FAN_CTRL_LATCH_FULL 0x08
137#define FAN_CTRL_MODE_MASK 0x03
138#define FAN_CTRL_MODE_SPEED 0x00
139#define FAN_CTRL_MODE_TEMPERATURE 0x01
140#define FAN_CTRL_MODE_MANUAL 0x02
141
125/* 142/*
126 * Data structures and manipulation thereof 143 * Data structures and manipulation thereof
127 */ 144 */
@@ -138,12 +155,16 @@ struct f71805f_data {
138 unsigned long last_limits; /* In jiffies */ 155 unsigned long last_limits; /* In jiffies */
139 156
140 /* Register values */ 157 /* Register values */
141 u8 in[9]; 158 u8 in[11];
142 u8 in_high[9]; 159 u8 in_high[11];
143 u8 in_low[9]; 160 u8 in_low[11];
161 u16 has_in;
144 u16 fan[3]; 162 u16 fan[3];
145 u16 fan_low[3]; 163 u16 fan_low[3];
146 u8 fan_enabled; /* Read once at init time */ 164 u16 fan_target[3];
165 u8 fan_ctrl[3];
166 u8 pwm[3];
167 u8 pwm_freq[3];
147 u8 temp[3]; 168 u8 temp[3];
148 u8 temp_high[3]; 169 u8 temp_high[3];
149 u8 temp_hyst[3]; 170 u8 temp_hyst[3];
@@ -151,6 +172,11 @@ struct f71805f_data {
151 unsigned long alarms; 172 unsigned long alarms;
152}; 173};
153 174
175struct f71805f_sio_data {
176 enum kinds kind;
177 u8 fnsel1;
178};
179
154static inline long in_from_reg(u8 reg) 180static inline long in_from_reg(u8 reg)
155{ 181{
156 return (reg * 8); 182 return (reg * 8);
@@ -200,6 +226,33 @@ static inline u16 fan_to_reg(long rpm)
200 return (1500000 / rpm); 226 return (1500000 / rpm);
201} 227}
202 228
229static inline unsigned long pwm_freq_from_reg(u8 reg)
230{
231 unsigned long clock = (reg & 0x80) ? 48000000UL : 1000000UL;
232
233 reg &= 0x7f;
234 if (reg == 0)
235 reg++;
236 return clock / (reg << 8);
237}
238
239static inline u8 pwm_freq_to_reg(unsigned long val)
240{
241 if (val >= 187500) /* The highest we can do */
242 return 0x80;
243 if (val >= 1475) /* Use 48 MHz clock */
244 return 0x80 | (48000000UL / (val << 8));
245 if (val < 31) /* The lowest we can do */
246 return 0x7f;
247 else /* Use 1 MHz clock */
248 return 1000000UL / (val << 8);
249}
250
251static inline int pwm_mode_from_reg(u8 reg)
252{
253 return !(reg & FAN_CTRL_DC_MODE);
254}
255
203static inline long temp_from_reg(u8 reg) 256static inline long temp_from_reg(u8 reg)
204{ 257{
205 return (reg * 1000); 258 return (reg * 1000);
@@ -274,16 +327,21 @@ static struct f71805f_data *f71805f_update_device(struct device *dev)
274 /* Limit registers cache is refreshed after 60 seconds */ 327 /* Limit registers cache is refreshed after 60 seconds */
275 if (time_after(jiffies, data->last_updated + 60 * HZ) 328 if (time_after(jiffies, data->last_updated + 60 * HZ)
276 || !data->valid) { 329 || !data->valid) {
277 for (nr = 0; nr < 9; nr++) { 330 for (nr = 0; nr < 11; nr++) {
331 if (!(data->has_in & (1 << nr)))
332 continue;
278 data->in_high[nr] = f71805f_read8(data, 333 data->in_high[nr] = f71805f_read8(data,
279 F71805F_REG_IN_HIGH(nr)); 334 F71805F_REG_IN_HIGH(nr));
280 data->in_low[nr] = f71805f_read8(data, 335 data->in_low[nr] = f71805f_read8(data,
281 F71805F_REG_IN_LOW(nr)); 336 F71805F_REG_IN_LOW(nr));
282 } 337 }
283 for (nr = 0; nr < 3; nr++) { 338 for (nr = 0; nr < 3; nr++) {
284 if (data->fan_enabled & (1 << nr)) 339 data->fan_low[nr] = f71805f_read16(data,
285 data->fan_low[nr] = f71805f_read16(data, 340 F71805F_REG_FAN_LOW(nr));
286 F71805F_REG_FAN_LOW(nr)); 341 data->fan_target[nr] = f71805f_read16(data,
342 F71805F_REG_FAN_TARGET(nr));
343 data->pwm_freq[nr] = f71805f_read8(data,
344 F71805F_REG_PWM_FREQ(nr));
287 } 345 }
288 for (nr = 0; nr < 3; nr++) { 346 for (nr = 0; nr < 3; nr++) {
289 data->temp_high[nr] = f71805f_read8(data, 347 data->temp_high[nr] = f71805f_read8(data,
@@ -299,14 +357,19 @@ static struct f71805f_data *f71805f_update_device(struct device *dev)
299 /* Measurement registers cache is refreshed after 1 second */ 357 /* Measurement registers cache is refreshed after 1 second */
300 if (time_after(jiffies, data->last_updated + HZ) 358 if (time_after(jiffies, data->last_updated + HZ)
301 || !data->valid) { 359 || !data->valid) {
302 for (nr = 0; nr < 9; nr++) { 360 for (nr = 0; nr < 11; nr++) {
361 if (!(data->has_in & (1 << nr)))
362 continue;
303 data->in[nr] = f71805f_read8(data, 363 data->in[nr] = f71805f_read8(data,
304 F71805F_REG_IN(nr)); 364 F71805F_REG_IN(nr));
305 } 365 }
306 for (nr = 0; nr < 3; nr++) { 366 for (nr = 0; nr < 3; nr++) {
307 if (data->fan_enabled & (1 << nr)) 367 data->fan[nr] = f71805f_read16(data,
308 data->fan[nr] = f71805f_read16(data, 368 F71805F_REG_FAN(nr));
309 F71805F_REG_FAN(nr)); 369 data->fan_ctrl[nr] = f71805f_read8(data,
370 F71805F_REG_FAN_CTRL(nr));
371 data->pwm[nr] = f71805f_read8(data,
372 F71805F_REG_PWM_DUTY(nr));
310 } 373 }
311 for (nr = 0; nr < 3; nr++) { 374 for (nr = 0; nr < 3; nr++) {
312 data->temp[nr] = f71805f_read8(data, 375 data->temp[nr] = f71805f_read8(data,
@@ -333,35 +396,43 @@ static ssize_t show_in0(struct device *dev, struct device_attribute *devattr,
333 char *buf) 396 char *buf)
334{ 397{
335 struct f71805f_data *data = f71805f_update_device(dev); 398 struct f71805f_data *data = f71805f_update_device(dev);
399 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
400 int nr = attr->index;
336 401
337 return sprintf(buf, "%ld\n", in0_from_reg(data->in[0])); 402 return sprintf(buf, "%ld\n", in0_from_reg(data->in[nr]));
338} 403}
339 404
340static ssize_t show_in0_max(struct device *dev, struct device_attribute 405static ssize_t show_in0_max(struct device *dev, struct device_attribute
341 *devattr, char *buf) 406 *devattr, char *buf)
342{ 407{
343 struct f71805f_data *data = f71805f_update_device(dev); 408 struct f71805f_data *data = f71805f_update_device(dev);
409 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
410 int nr = attr->index;
344 411
345 return sprintf(buf, "%ld\n", in0_from_reg(data->in_high[0])); 412 return sprintf(buf, "%ld\n", in0_from_reg(data->in_high[nr]));
346} 413}
347 414
348static ssize_t show_in0_min(struct device *dev, struct device_attribute 415static ssize_t show_in0_min(struct device *dev, struct device_attribute
349 *devattr, char *buf) 416 *devattr, char *buf)
350{ 417{
351 struct f71805f_data *data = f71805f_update_device(dev); 418 struct f71805f_data *data = f71805f_update_device(dev);
419 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
420 int nr = attr->index;
352 421
353 return sprintf(buf, "%ld\n", in0_from_reg(data->in_low[0])); 422 return sprintf(buf, "%ld\n", in0_from_reg(data->in_low[nr]));
354} 423}
355 424
356static ssize_t set_in0_max(struct device *dev, struct device_attribute 425static ssize_t set_in0_max(struct device *dev, struct device_attribute
357 *devattr, const char *buf, size_t count) 426 *devattr, const char *buf, size_t count)
358{ 427{
359 struct f71805f_data *data = dev_get_drvdata(dev); 428 struct f71805f_data *data = dev_get_drvdata(dev);
429 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
430 int nr = attr->index;
360 long val = simple_strtol(buf, NULL, 10); 431 long val = simple_strtol(buf, NULL, 10);
361 432
362 mutex_lock(&data->update_lock); 433 mutex_lock(&data->update_lock);
363 data->in_high[0] = in0_to_reg(val); 434 data->in_high[nr] = in0_to_reg(val);
364 f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); 435 f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]);
365 mutex_unlock(&data->update_lock); 436 mutex_unlock(&data->update_lock);
366 437
367 return count; 438 return count;
@@ -371,11 +442,13 @@ static ssize_t set_in0_min(struct device *dev, struct device_attribute
371 *devattr, const char *buf, size_t count) 442 *devattr, const char *buf, size_t count)
372{ 443{
373 struct f71805f_data *data = dev_get_drvdata(dev); 444 struct f71805f_data *data = dev_get_drvdata(dev);
445 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
446 int nr = attr->index;
374 long val = simple_strtol(buf, NULL, 10); 447 long val = simple_strtol(buf, NULL, 10);
375 448
376 mutex_lock(&data->update_lock); 449 mutex_lock(&data->update_lock);
377 data->in_low[0] = in0_to_reg(val); 450 data->in_low[nr] = in0_to_reg(val);
378 f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); 451 f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]);
379 mutex_unlock(&data->update_lock); 452 mutex_unlock(&data->update_lock);
380 453
381 return count; 454 return count;
@@ -463,6 +536,16 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute
463 return sprintf(buf, "%ld\n", fan_from_reg(data->fan_low[nr])); 536 return sprintf(buf, "%ld\n", fan_from_reg(data->fan_low[nr]));
464} 537}
465 538
539static ssize_t show_fan_target(struct device *dev, struct device_attribute
540 *devattr, char *buf)
541{
542 struct f71805f_data *data = f71805f_update_device(dev);
543 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
544 int nr = attr->index;
545
546 return sprintf(buf, "%ld\n", fan_from_reg(data->fan_target[nr]));
547}
548
466static ssize_t set_fan_min(struct device *dev, struct device_attribute 549static ssize_t set_fan_min(struct device *dev, struct device_attribute
467 *devattr, const char *buf, size_t count) 550 *devattr, const char *buf, size_t count)
468{ 551{
@@ -479,6 +562,157 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute
479 return count; 562 return count;
480} 563}
481 564
565static ssize_t set_fan_target(struct device *dev, struct device_attribute
566 *devattr, const char *buf, size_t count)
567{
568 struct f71805f_data *data = dev_get_drvdata(dev);
569 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
570 int nr = attr->index;
571 long val = simple_strtol(buf, NULL, 10);
572
573 mutex_lock(&data->update_lock);
574 data->fan_target[nr] = fan_to_reg(val);
575 f71805f_write16(data, F71805F_REG_FAN_TARGET(nr),
576 data->fan_target[nr]);
577 mutex_unlock(&data->update_lock);
578
579 return count;
580}
581
582static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr,
583 char *buf)
584{
585 struct f71805f_data *data = f71805f_update_device(dev);
586 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
587 int nr = attr->index;
588
589 return sprintf(buf, "%d\n", (int)data->pwm[nr]);
590}
591
592static ssize_t show_pwm_enable(struct device *dev, struct device_attribute
593 *devattr, char *buf)
594{
595 struct f71805f_data *data = f71805f_update_device(dev);
596 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
597 int nr = attr->index;
598 int mode;
599
600 switch (data->fan_ctrl[nr] & FAN_CTRL_MODE_MASK) {
601 case FAN_CTRL_MODE_SPEED:
602 mode = 3;
603 break;
604 case FAN_CTRL_MODE_TEMPERATURE:
605 mode = 2;
606 break;
607 default: /* MANUAL */
608 mode = 1;
609 }
610
611 return sprintf(buf, "%d\n", mode);
612}
613
614static ssize_t show_pwm_freq(struct device *dev, struct device_attribute
615 *devattr, char *buf)
616{
617 struct f71805f_data *data = f71805f_update_device(dev);
618 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
619 int nr = attr->index;
620
621 return sprintf(buf, "%lu\n", pwm_freq_from_reg(data->pwm_freq[nr]));
622}
623
624static ssize_t show_pwm_mode(struct device *dev, struct device_attribute
625 *devattr, char *buf)
626{
627 struct f71805f_data *data = f71805f_update_device(dev);
628 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
629 int nr = attr->index;
630
631 return sprintf(buf, "%d\n", pwm_mode_from_reg(data->fan_ctrl[nr]));
632}
633
634static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr,
635 const char *buf, size_t count)
636{
637 struct f71805f_data *data = dev_get_drvdata(dev);
638 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
639 int nr = attr->index;
640 unsigned long val = simple_strtoul(buf, NULL, 10);
641
642 if (val > 255)
643 return -EINVAL;
644
645 mutex_lock(&data->update_lock);
646 data->pwm[nr] = val;
647 f71805f_write8(data, F71805F_REG_PWM_DUTY(nr), data->pwm[nr]);
648 mutex_unlock(&data->update_lock);
649
650 return count;
651}
652
653static struct attribute *f71805f_attr_pwm[];
654
655static ssize_t set_pwm_enable(struct device *dev, struct device_attribute
656 *devattr, const char *buf, size_t count)
657{
658 struct f71805f_data *data = dev_get_drvdata(dev);
659 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
660 int nr = attr->index;
661 unsigned long val = simple_strtoul(buf, NULL, 10);
662 u8 reg;
663
664 if (val < 1 || val > 3)
665 return -EINVAL;
666
667 if (val > 1) { /* Automatic mode, user can't set PWM value */
668 if (sysfs_chmod_file(&dev->kobj, f71805f_attr_pwm[nr],
669 S_IRUGO))
670 dev_dbg(dev, "chmod -w pwm%d failed\n", nr + 1);
671 }
672
673 mutex_lock(&data->update_lock);
674 reg = f71805f_read8(data, F71805F_REG_FAN_CTRL(nr))
675 & ~FAN_CTRL_MODE_MASK;
676 switch (val) {
677 case 1:
678 reg |= FAN_CTRL_MODE_MANUAL;
679 break;
680 case 2:
681 reg |= FAN_CTRL_MODE_TEMPERATURE;
682 break;
683 case 3:
684 reg |= FAN_CTRL_MODE_SPEED;
685 break;
686 }
687 data->fan_ctrl[nr] = reg;
688 f71805f_write8(data, F71805F_REG_FAN_CTRL(nr), reg);
689 mutex_unlock(&data->update_lock);
690
691 if (val == 1) { /* Manual mode, user can set PWM value */
692 if (sysfs_chmod_file(&dev->kobj, f71805f_attr_pwm[nr],
693 S_IRUGO | S_IWUSR))
694 dev_dbg(dev, "chmod +w pwm%d failed\n", nr + 1);
695 }
696
697 return count;
698}
699
700static ssize_t set_pwm_freq(struct device *dev, struct device_attribute
701 *devattr, const char *buf, size_t count)
702{
703 struct f71805f_data *data = dev_get_drvdata(dev);
704 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
705 int nr = attr->index;
706 unsigned long val = simple_strtoul(buf, NULL, 10);
707
708 mutex_lock(&data->update_lock);
709 data->pwm_freq[nr] = pwm_freq_to_reg(val);
710 f71805f_write8(data, F71805F_REG_PWM_FREQ(nr), data->pwm_freq[nr]);
711 mutex_unlock(&data->update_lock);
712
713 return count;
714}
715
482static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, 716static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
483 char *buf) 717 char *buf)
484{ 718{
@@ -557,7 +791,7 @@ static ssize_t show_alarms_in(struct device *dev, struct device_attribute
557{ 791{
558 struct f71805f_data *data = f71805f_update_device(dev); 792 struct f71805f_data *data = f71805f_update_device(dev);
559 793
560 return sprintf(buf, "%lu\n", data->alarms & 0x1ff); 794 return sprintf(buf, "%lu\n", data->alarms & 0x7ff);
561} 795}
562 796
563static ssize_t show_alarms_fan(struct device *dev, struct device_attribute 797static ssize_t show_alarms_fan(struct device *dev, struct device_attribute
@@ -594,9 +828,11 @@ static ssize_t show_name(struct device *dev, struct device_attribute
594 return sprintf(buf, "%s\n", data->name); 828 return sprintf(buf, "%s\n", data->name);
595} 829}
596 830
597static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL); 831static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL, 0);
598static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max); 832static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR,
599static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min); 833 show_in0_max, set_in0_max, 0);
834static SENSOR_DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR,
835 show_in0_min, set_in0_min, 0);
600static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1); 836static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1);
601static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR, 837static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR,
602 show_in_max, set_in_max, 1); 838 show_in_max, set_in_max, 1);
@@ -637,16 +873,32 @@ static SENSOR_DEVICE_ATTR(in8_max, S_IRUGO | S_IWUSR,
637 show_in_max, set_in_max, 8); 873 show_in_max, set_in_max, 8);
638static SENSOR_DEVICE_ATTR(in8_min, S_IRUGO | S_IWUSR, 874static SENSOR_DEVICE_ATTR(in8_min, S_IRUGO | S_IWUSR,
639 show_in_min, set_in_min, 8); 875 show_in_min, set_in_min, 8);
876static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_in0, NULL, 9);
877static SENSOR_DEVICE_ATTR(in9_max, S_IRUGO | S_IWUSR,
878 show_in0_max, set_in0_max, 9);
879static SENSOR_DEVICE_ATTR(in9_min, S_IRUGO | S_IWUSR,
880 show_in0_min, set_in0_min, 9);
881static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_in0, NULL, 10);
882static SENSOR_DEVICE_ATTR(in10_max, S_IRUGO | S_IWUSR,
883 show_in0_max, set_in0_max, 10);
884static SENSOR_DEVICE_ATTR(in10_min, S_IRUGO | S_IWUSR,
885 show_in0_min, set_in0_min, 10);
640 886
641static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); 887static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);
642static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR, 888static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR,
643 show_fan_min, set_fan_min, 0); 889 show_fan_min, set_fan_min, 0);
890static SENSOR_DEVICE_ATTR(fan1_target, S_IRUGO | S_IWUSR,
891 show_fan_target, set_fan_target, 0);
644static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); 892static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1);
645static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO | S_IWUSR, 893static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO | S_IWUSR,
646 show_fan_min, set_fan_min, 1); 894 show_fan_min, set_fan_min, 1);
895static SENSOR_DEVICE_ATTR(fan2_target, S_IRUGO | S_IWUSR,
896 show_fan_target, set_fan_target, 1);
647static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); 897static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2);
648static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO | S_IWUSR, 898static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO | S_IWUSR,
649 show_fan_min, set_fan_min, 2); 899 show_fan_min, set_fan_min, 2);
900static SENSOR_DEVICE_ATTR(fan3_target, S_IRUGO | S_IWUSR,
901 show_fan_target, set_fan_target, 2);
650 902
651static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); 903static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
652static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, 904static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR,
@@ -667,6 +919,27 @@ static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR,
667 show_temp_hyst, set_temp_hyst, 2); 919 show_temp_hyst, set_temp_hyst, 2);
668static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2); 920static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2);
669 921
922/* pwm (value) files are created read-only, write permission is
923 then added or removed dynamically as needed */
924static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO, show_pwm, set_pwm, 0);
925static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
926 show_pwm_enable, set_pwm_enable, 0);
927static SENSOR_DEVICE_ATTR(pwm1_freq, S_IRUGO | S_IWUSR,
928 show_pwm_freq, set_pwm_freq, 0);
929static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0);
930static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO, show_pwm, set_pwm, 1);
931static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR,
932 show_pwm_enable, set_pwm_enable, 1);
933static SENSOR_DEVICE_ATTR(pwm2_freq, S_IRUGO | S_IWUSR,
934 show_pwm_freq, set_pwm_freq, 1);
935static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1);
936static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO, show_pwm, set_pwm, 2);
937static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR,
938 show_pwm_enable, set_pwm_enable, 2);
939static SENSOR_DEVICE_ATTR(pwm3_freq, S_IRUGO | S_IWUSR,
940 show_pwm_freq, set_pwm_freq, 2);
941static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2);
942
670static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); 943static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
671static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); 944static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
672static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); 945static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
@@ -676,6 +949,8 @@ static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 5);
676static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6); 949static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6);
677static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7); 950static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7);
678static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 8); 951static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 8);
952static SENSOR_DEVICE_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, 9);
953static SENSOR_DEVICE_ATTR(in10_alarm, S_IRUGO, show_alarm, NULL, 10);
679static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 11); 954static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 11);
680static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 12); 955static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 12);
681static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13); 956static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13);
@@ -689,9 +964,9 @@ static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL);
689static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 964static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
690 965
691static struct attribute *f71805f_attributes[] = { 966static struct attribute *f71805f_attributes[] = {
692 &dev_attr_in0_input.attr, 967 &sensor_dev_attr_in0_input.dev_attr.attr,
693 &dev_attr_in0_max.attr, 968 &sensor_dev_attr_in0_max.dev_attr.attr,
694 &dev_attr_in0_min.attr, 969 &sensor_dev_attr_in0_min.dev_attr.attr,
695 &sensor_dev_attr_in1_input.dev_attr.attr, 970 &sensor_dev_attr_in1_input.dev_attr.attr,
696 &sensor_dev_attr_in1_max.dev_attr.attr, 971 &sensor_dev_attr_in1_max.dev_attr.attr,
697 &sensor_dev_attr_in1_min.dev_attr.attr, 972 &sensor_dev_attr_in1_min.dev_attr.attr,
@@ -701,9 +976,6 @@ static struct attribute *f71805f_attributes[] = {
701 &sensor_dev_attr_in3_input.dev_attr.attr, 976 &sensor_dev_attr_in3_input.dev_attr.attr,
702 &sensor_dev_attr_in3_max.dev_attr.attr, 977 &sensor_dev_attr_in3_max.dev_attr.attr,
703 &sensor_dev_attr_in3_min.dev_attr.attr, 978 &sensor_dev_attr_in3_min.dev_attr.attr,
704 &sensor_dev_attr_in4_input.dev_attr.attr,
705 &sensor_dev_attr_in4_max.dev_attr.attr,
706 &sensor_dev_attr_in4_min.dev_attr.attr,
707 &sensor_dev_attr_in5_input.dev_attr.attr, 979 &sensor_dev_attr_in5_input.dev_attr.attr,
708 &sensor_dev_attr_in5_max.dev_attr.attr, 980 &sensor_dev_attr_in5_max.dev_attr.attr,
709 &sensor_dev_attr_in5_min.dev_attr.attr, 981 &sensor_dev_attr_in5_min.dev_attr.attr,
@@ -713,9 +985,29 @@ static struct attribute *f71805f_attributes[] = {
713 &sensor_dev_attr_in7_input.dev_attr.attr, 985 &sensor_dev_attr_in7_input.dev_attr.attr,
714 &sensor_dev_attr_in7_max.dev_attr.attr, 986 &sensor_dev_attr_in7_max.dev_attr.attr,
715 &sensor_dev_attr_in7_min.dev_attr.attr, 987 &sensor_dev_attr_in7_min.dev_attr.attr,
716 &sensor_dev_attr_in8_input.dev_attr.attr, 988
717 &sensor_dev_attr_in8_max.dev_attr.attr, 989 &sensor_dev_attr_fan1_input.dev_attr.attr,
718 &sensor_dev_attr_in8_min.dev_attr.attr, 990 &sensor_dev_attr_fan1_min.dev_attr.attr,
991 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
992 &sensor_dev_attr_fan1_target.dev_attr.attr,
993 &sensor_dev_attr_fan2_input.dev_attr.attr,
994 &sensor_dev_attr_fan2_min.dev_attr.attr,
995 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
996 &sensor_dev_attr_fan2_target.dev_attr.attr,
997 &sensor_dev_attr_fan3_input.dev_attr.attr,
998 &sensor_dev_attr_fan3_min.dev_attr.attr,
999 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
1000 &sensor_dev_attr_fan3_target.dev_attr.attr,
1001
1002 &sensor_dev_attr_pwm1.dev_attr.attr,
1003 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
1004 &sensor_dev_attr_pwm1_mode.dev_attr.attr,
1005 &sensor_dev_attr_pwm2.dev_attr.attr,
1006 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
1007 &sensor_dev_attr_pwm2_mode.dev_attr.attr,
1008 &sensor_dev_attr_pwm3.dev_attr.attr,
1009 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
1010 &sensor_dev_attr_pwm3_mode.dev_attr.attr,
719 1011
720 &sensor_dev_attr_temp1_input.dev_attr.attr, 1012 &sensor_dev_attr_temp1_input.dev_attr.attr,
721 &sensor_dev_attr_temp1_max.dev_attr.attr, 1013 &sensor_dev_attr_temp1_max.dev_attr.attr,
@@ -734,11 +1026,9 @@ static struct attribute *f71805f_attributes[] = {
734 &sensor_dev_attr_in1_alarm.dev_attr.attr, 1026 &sensor_dev_attr_in1_alarm.dev_attr.attr,
735 &sensor_dev_attr_in2_alarm.dev_attr.attr, 1027 &sensor_dev_attr_in2_alarm.dev_attr.attr,
736 &sensor_dev_attr_in3_alarm.dev_attr.attr, 1028 &sensor_dev_attr_in3_alarm.dev_attr.attr,
737 &sensor_dev_attr_in4_alarm.dev_attr.attr,
738 &sensor_dev_attr_in5_alarm.dev_attr.attr, 1029 &sensor_dev_attr_in5_alarm.dev_attr.attr,
739 &sensor_dev_attr_in6_alarm.dev_attr.attr, 1030 &sensor_dev_attr_in6_alarm.dev_attr.attr,
740 &sensor_dev_attr_in7_alarm.dev_attr.attr, 1031 &sensor_dev_attr_in7_alarm.dev_attr.attr,
741 &sensor_dev_attr_in8_alarm.dev_attr.attr,
742 &dev_attr_alarms_in.attr, 1032 &dev_attr_alarms_in.attr,
743 &sensor_dev_attr_temp1_alarm.dev_attr.attr, 1033 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
744 &sensor_dev_attr_temp2_alarm.dev_attr.attr, 1034 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
@@ -754,29 +1044,59 @@ static const struct attribute_group f71805f_group = {
754 .attrs = f71805f_attributes, 1044 .attrs = f71805f_attributes,
755}; 1045};
756 1046
757static struct attribute *f71805f_attributes_fan[3][4] = { 1047static struct attribute *f71805f_attributes_optin[4][5] = {
758 { 1048 {
759 &sensor_dev_attr_fan1_input.dev_attr.attr, 1049 &sensor_dev_attr_in4_input.dev_attr.attr,
760 &sensor_dev_attr_fan1_min.dev_attr.attr, 1050 &sensor_dev_attr_in4_max.dev_attr.attr,
761 &sensor_dev_attr_fan1_alarm.dev_attr.attr, 1051 &sensor_dev_attr_in4_min.dev_attr.attr,
1052 &sensor_dev_attr_in4_alarm.dev_attr.attr,
1053 NULL
1054 }, {
1055 &sensor_dev_attr_in8_input.dev_attr.attr,
1056 &sensor_dev_attr_in8_max.dev_attr.attr,
1057 &sensor_dev_attr_in8_min.dev_attr.attr,
1058 &sensor_dev_attr_in8_alarm.dev_attr.attr,
762 NULL 1059 NULL
763 }, { 1060 }, {
764 &sensor_dev_attr_fan2_input.dev_attr.attr, 1061 &sensor_dev_attr_in9_input.dev_attr.attr,
765 &sensor_dev_attr_fan2_min.dev_attr.attr, 1062 &sensor_dev_attr_in9_max.dev_attr.attr,
766 &sensor_dev_attr_fan2_alarm.dev_attr.attr, 1063 &sensor_dev_attr_in9_min.dev_attr.attr,
1064 &sensor_dev_attr_in9_alarm.dev_attr.attr,
767 NULL 1065 NULL
768 }, { 1066 }, {
769 &sensor_dev_attr_fan3_input.dev_attr.attr, 1067 &sensor_dev_attr_in10_input.dev_attr.attr,
770 &sensor_dev_attr_fan3_min.dev_attr.attr, 1068 &sensor_dev_attr_in10_max.dev_attr.attr,
771 &sensor_dev_attr_fan3_alarm.dev_attr.attr, 1069 &sensor_dev_attr_in10_min.dev_attr.attr,
1070 &sensor_dev_attr_in10_alarm.dev_attr.attr,
772 NULL 1071 NULL
773 } 1072 }
774}; 1073};
775 1074
776static const struct attribute_group f71805f_group_fan[3] = { 1075static const struct attribute_group f71805f_group_optin[4] = {
777 { .attrs = f71805f_attributes_fan[0] }, 1076 { .attrs = f71805f_attributes_optin[0] },
778 { .attrs = f71805f_attributes_fan[1] }, 1077 { .attrs = f71805f_attributes_optin[1] },
779 { .attrs = f71805f_attributes_fan[2] }, 1078 { .attrs = f71805f_attributes_optin[2] },
1079 { .attrs = f71805f_attributes_optin[3] },
1080};
1081
1082/* We don't include pwm_freq files in the arrays above, because they must be
1083 created conditionally (only if pwm_mode is 1 == PWM) */
1084static struct attribute *f71805f_attributes_pwm_freq[] = {
1085 &sensor_dev_attr_pwm1_freq.dev_attr.attr,
1086 &sensor_dev_attr_pwm2_freq.dev_attr.attr,
1087 &sensor_dev_attr_pwm3_freq.dev_attr.attr,
1088 NULL
1089};
1090
1091static const struct attribute_group f71805f_group_pwm_freq = {
1092 .attrs = f71805f_attributes_pwm_freq,
1093};
1094
1095/* We also need an indexed access to pwmN files to toggle writability */
1096static struct attribute *f71805f_attr_pwm[] = {
1097 &sensor_dev_attr_pwm1.dev_attr.attr,
1098 &sensor_dev_attr_pwm2.dev_attr.attr,
1099 &sensor_dev_attr_pwm3.dev_attr.attr,
780}; 1100};
781 1101
782/* 1102/*
@@ -798,18 +1118,30 @@ static void __devinit f71805f_init_device(struct f71805f_data *data)
798 /* Fan monitoring can be disabled. If it is, we won't be polling 1118 /* Fan monitoring can be disabled. If it is, we won't be polling
799 the register values, and won't create the related sysfs files. */ 1119 the register values, and won't create the related sysfs files. */
800 for (i = 0; i < 3; i++) { 1120 for (i = 0; i < 3; i++) {
801 reg = f71805f_read8(data, F71805F_REG_FAN_CTRL(i)); 1121 data->fan_ctrl[i] = f71805f_read8(data,
802 if (!(reg & 0x80)) 1122 F71805F_REG_FAN_CTRL(i));
803 data->fan_enabled |= (1 << i); 1123 /* Clear latch full bit, else "speed mode" fan speed control
1124 doesn't work */
1125 if (data->fan_ctrl[i] & FAN_CTRL_LATCH_FULL) {
1126 data->fan_ctrl[i] &= ~FAN_CTRL_LATCH_FULL;
1127 f71805f_write8(data, F71805F_REG_FAN_CTRL(i),
1128 data->fan_ctrl[i]);
1129 }
804 } 1130 }
805} 1131}
806 1132
807static int __devinit f71805f_probe(struct platform_device *pdev) 1133static int __devinit f71805f_probe(struct platform_device *pdev)
808{ 1134{
1135 struct f71805f_sio_data *sio_data = pdev->dev.platform_data;
809 struct f71805f_data *data; 1136 struct f71805f_data *data;
810 struct resource *res; 1137 struct resource *res;
811 int i, err; 1138 int i, err;
812 1139
1140 static const char *names[] = {
1141 "f71805f",
1142 "f71872f",
1143 };
1144
813 if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { 1145 if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) {
814 err = -ENOMEM; 1146 err = -ENOMEM;
815 printk(KERN_ERR DRVNAME ": Out of memory\n"); 1147 printk(KERN_ERR DRVNAME ": Out of memory\n");
@@ -819,24 +1151,69 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
819 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 1151 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
820 data->addr = res->start; 1152 data->addr = res->start;
821 mutex_init(&data->lock); 1153 mutex_init(&data->lock);
822 data->name = "f71805f"; 1154 data->name = names[sio_data->kind];
823 mutex_init(&data->update_lock); 1155 mutex_init(&data->update_lock);
824 1156
825 platform_set_drvdata(pdev, data); 1157 platform_set_drvdata(pdev, data);
826 1158
1159 /* Some voltage inputs depend on chip model and configuration */
1160 switch (sio_data->kind) {
1161 case f71805f:
1162 data->has_in = 0x1ff;
1163 break;
1164 case f71872f:
1165 data->has_in = 0x6ef;
1166 if (sio_data->fnsel1 & 0x01)
1167 data->has_in |= (1 << 4); /* in4 */
1168 if (sio_data->fnsel1 & 0x02)
1169 data->has_in |= (1 << 8); /* in8 */
1170 break;
1171 }
1172
827 /* Initialize the F71805F chip */ 1173 /* Initialize the F71805F chip */
828 f71805f_init_device(data); 1174 f71805f_init_device(data);
829 1175
830 /* Register sysfs interface files */ 1176 /* Register sysfs interface files */
831 if ((err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group))) 1177 if ((err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group)))
832 goto exit_free; 1178 goto exit_free;
833 for (i = 0; i < 3; i++) { 1179 if (data->has_in & (1 << 4)) { /* in4 */
834 if (!(data->fan_enabled & (1 << i))) 1180 if ((err = sysfs_create_group(&pdev->dev.kobj,
835 continue; 1181 &f71805f_group_optin[0])))
1182 goto exit_remove_files;
1183 }
1184 if (data->has_in & (1 << 8)) { /* in8 */
1185 if ((err = sysfs_create_group(&pdev->dev.kobj,
1186 &f71805f_group_optin[1])))
1187 goto exit_remove_files;
1188 }
1189 if (data->has_in & (1 << 9)) { /* in9 (F71872F/FG only) */
836 if ((err = sysfs_create_group(&pdev->dev.kobj, 1190 if ((err = sysfs_create_group(&pdev->dev.kobj,
837 &f71805f_group_fan[i]))) 1191 &f71805f_group_optin[2])))
838 goto exit_remove_files; 1192 goto exit_remove_files;
839 } 1193 }
1194 if (data->has_in & (1 << 10)) { /* in9 (F71872F/FG only) */
1195 if ((err = sysfs_create_group(&pdev->dev.kobj,
1196 &f71805f_group_optin[3])))
1197 goto exit_remove_files;
1198 }
1199 for (i = 0; i < 3; i++) {
1200 /* If control mode is PWM, create pwm_freq file */
1201 if (!(data->fan_ctrl[i] & FAN_CTRL_DC_MODE)) {
1202 if ((err = sysfs_create_file(&pdev->dev.kobj,
1203 f71805f_attributes_pwm_freq[i])))
1204 goto exit_remove_files;
1205 }
1206 /* If PWM is in manual mode, add write permission */
1207 if (data->fan_ctrl[i] & FAN_CTRL_MODE_MANUAL) {
1208 if ((err = sysfs_chmod_file(&pdev->dev.kobj,
1209 f71805f_attr_pwm[i],
1210 S_IRUGO | S_IWUSR))) {
1211 dev_err(&pdev->dev, "chmod +w pwm%d failed\n",
1212 i + 1);
1213 goto exit_remove_files;
1214 }
1215 }
1216 }
840 1217
841 data->class_dev = hwmon_device_register(&pdev->dev); 1218 data->class_dev = hwmon_device_register(&pdev->dev);
842 if (IS_ERR(data->class_dev)) { 1219 if (IS_ERR(data->class_dev)) {
@@ -849,8 +1226,9 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
849 1226
850exit_remove_files: 1227exit_remove_files:
851 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); 1228 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group);
852 for (i = 0; i < 3; i++) 1229 for (i = 0; i < 4; i++)
853 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_fan[i]); 1230 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]);
1231 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq);
854exit_free: 1232exit_free:
855 platform_set_drvdata(pdev, NULL); 1233 platform_set_drvdata(pdev, NULL);
856 kfree(data); 1234 kfree(data);
@@ -866,8 +1244,9 @@ static int __devexit f71805f_remove(struct platform_device *pdev)
866 platform_set_drvdata(pdev, NULL); 1244 platform_set_drvdata(pdev, NULL);
867 hwmon_device_unregister(data->class_dev); 1245 hwmon_device_unregister(data->class_dev);
868 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); 1246 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group);
869 for (i = 0; i < 3; i++) 1247 for (i = 0; i < 4; i++)
870 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_fan[i]); 1248 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]);
1249 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq);
871 kfree(data); 1250 kfree(data);
872 1251
873 return 0; 1252 return 0;
@@ -882,7 +1261,8 @@ static struct platform_driver f71805f_driver = {
882 .remove = __devexit_p(f71805f_remove), 1261 .remove = __devexit_p(f71805f_remove),
883}; 1262};
884 1263
885static int __init f71805f_device_add(unsigned short address) 1264static int __init f71805f_device_add(unsigned short address,
1265 const struct f71805f_sio_data *sio_data)
886{ 1266{
887 struct resource res = { 1267 struct resource res = {
888 .start = address, 1268 .start = address,
@@ -906,26 +1286,45 @@ static int __init f71805f_device_add(unsigned short address)
906 goto exit_device_put; 1286 goto exit_device_put;
907 } 1287 }
908 1288
1289 pdev->dev.platform_data = kmalloc(sizeof(struct f71805f_sio_data),
1290 GFP_KERNEL);
1291 if (!pdev->dev.platform_data) {
1292 err = -ENOMEM;
1293 printk(KERN_ERR DRVNAME ": Platform data allocation failed\n");
1294 goto exit_device_put;
1295 }
1296 memcpy(pdev->dev.platform_data, sio_data,
1297 sizeof(struct f71805f_sio_data));
1298
909 err = platform_device_add(pdev); 1299 err = platform_device_add(pdev);
910 if (err) { 1300 if (err) {
911 printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", 1301 printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n",
912 err); 1302 err);
913 goto exit_device_put; 1303 goto exit_kfree_data;
914 } 1304 }
915 1305
916 return 0; 1306 return 0;
917 1307
1308exit_kfree_data:
1309 kfree(pdev->dev.platform_data);
1310 pdev->dev.platform_data = NULL;
918exit_device_put: 1311exit_device_put:
919 platform_device_put(pdev); 1312 platform_device_put(pdev);
920exit: 1313exit:
921 return err; 1314 return err;
922} 1315}
923 1316
924static int __init f71805f_find(int sioaddr, unsigned short *address) 1317static int __init f71805f_find(int sioaddr, unsigned short *address,
1318 struct f71805f_sio_data *sio_data)
925{ 1319{
926 int err = -ENODEV; 1320 int err = -ENODEV;
927 u16 devid; 1321 u16 devid;
928 1322
1323 static const char *names[] = {
1324 "F71805F/FG",
1325 "F71872F/FG",
1326 };
1327
929 superio_enter(sioaddr); 1328 superio_enter(sioaddr);
930 1329
931 devid = superio_inw(sioaddr, SIO_REG_MANID); 1330 devid = superio_inw(sioaddr, SIO_REG_MANID);
@@ -933,7 +1332,15 @@ static int __init f71805f_find(int sioaddr, unsigned short *address)
933 goto exit; 1332 goto exit;
934 1333
935 devid = superio_inw(sioaddr, SIO_REG_DEVID); 1334 devid = superio_inw(sioaddr, SIO_REG_DEVID);
936 if (devid != SIO_F71805F_ID) { 1335 switch (devid) {
1336 case SIO_F71805F_ID:
1337 sio_data->kind = f71805f;
1338 break;
1339 case SIO_F71872F_ID:
1340 sio_data->kind = f71872f;
1341 sio_data->fnsel1 = superio_inb(sioaddr, SIO_REG_FNSEL1);
1342 break;
1343 default:
937 printk(KERN_INFO DRVNAME ": Unsupported Fintek device, " 1344 printk(KERN_INFO DRVNAME ": Unsupported Fintek device, "
938 "skipping\n"); 1345 "skipping\n");
939 goto exit; 1346 goto exit;
@@ -952,10 +1359,12 @@ static int __init f71805f_find(int sioaddr, unsigned short *address)
952 "skipping\n"); 1359 "skipping\n");
953 goto exit; 1360 goto exit;
954 } 1361 }
1362 *address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */
955 1363
956 err = 0; 1364 err = 0;
957 printk(KERN_INFO DRVNAME ": Found F71805F chip at %#x, revision %u\n", 1365 printk(KERN_INFO DRVNAME ": Found %s chip at %#x, revision %u\n",
958 *address, superio_inb(sioaddr, SIO_REG_DEVREV)); 1366 names[sio_data->kind], *address,
1367 superio_inb(sioaddr, SIO_REG_DEVREV));
959 1368
960exit: 1369exit:
961 superio_exit(sioaddr); 1370 superio_exit(sioaddr);
@@ -966,9 +1375,10 @@ static int __init f71805f_init(void)
966{ 1375{
967 int err; 1376 int err;
968 unsigned short address; 1377 unsigned short address;
1378 struct f71805f_sio_data sio_data;
969 1379
970 if (f71805f_find(0x2e, &address) 1380 if (f71805f_find(0x2e, &address, &sio_data)
971 && f71805f_find(0x4e, &address)) 1381 && f71805f_find(0x4e, &address, &sio_data))
972 return -ENODEV; 1382 return -ENODEV;
973 1383
974 err = platform_driver_register(&f71805f_driver); 1384 err = platform_driver_register(&f71805f_driver);
@@ -976,7 +1386,7 @@ static int __init f71805f_init(void)
976 goto exit; 1386 goto exit;
977 1387
978 /* Sets global pdev as a side effect */ 1388 /* Sets global pdev as a side effect */
979 err = f71805f_device_add(address); 1389 err = f71805f_device_add(address, &sio_data);
980 if (err) 1390 if (err)
981 goto exit_driver; 1391 goto exit_driver;
982 1392
@@ -990,13 +1400,16 @@ exit:
990 1400
991static void __exit f71805f_exit(void) 1401static void __exit f71805f_exit(void)
992{ 1402{
1403 kfree(pdev->dev.platform_data);
1404 pdev->dev.platform_data = NULL;
993 platform_device_unregister(pdev); 1405 platform_device_unregister(pdev);
1406
994 platform_driver_unregister(&f71805f_driver); 1407 platform_driver_unregister(&f71805f_driver);
995} 1408}
996 1409
997MODULE_AUTHOR("Jean Delvare <khali@linux-fr>"); 1410MODULE_AUTHOR("Jean Delvare <khali@linux-fr>");
998MODULE_LICENSE("GPL"); 1411MODULE_LICENSE("GPL");
999MODULE_DESCRIPTION("F71805F hardware monitoring driver"); 1412MODULE_DESCRIPTION("F71805F/F71872F hardware monitoring driver");
1000 1413
1001module_init(f71805f_init); 1414module_init(f71805f_init);
1002module_exit(f71805f_exit); 1415module_exit(f71805f_exit);
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
index e8ef62b83d6b..bf759ea545ac 100644
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -478,74 +478,64 @@ static struct attribute_group hdaps_attribute_group = {
478/* Module stuff */ 478/* Module stuff */
479 479
480/* hdaps_dmi_match - found a match. return one, short-circuiting the hunt. */ 480/* hdaps_dmi_match - found a match. return one, short-circuiting the hunt. */
481static int hdaps_dmi_match(struct dmi_system_id *id) 481static int __init hdaps_dmi_match(struct dmi_system_id *id)
482{ 482{
483 printk(KERN_INFO "hdaps: %s detected.\n", id->ident); 483 printk(KERN_INFO "hdaps: %s detected.\n", id->ident);
484 return 1; 484 return 1;
485} 485}
486 486
487/* hdaps_dmi_match_invert - found an inverted match. */ 487/* hdaps_dmi_match_invert - found an inverted match. */
488static int hdaps_dmi_match_invert(struct dmi_system_id *id) 488static int __init hdaps_dmi_match_invert(struct dmi_system_id *id)
489{ 489{
490 hdaps_invert = 1; 490 hdaps_invert = 1;
491 printk(KERN_INFO "hdaps: inverting axis readings.\n"); 491 printk(KERN_INFO "hdaps: inverting axis readings.\n");
492 return hdaps_dmi_match(id); 492 return hdaps_dmi_match(id);
493} 493}
494 494
495#define HDAPS_DMI_MATCH_NORMAL(model) { \ 495#define HDAPS_DMI_MATCH_NORMAL(vendor, model) { \
496 .ident = "IBM " model, \ 496 .ident = vendor " " model, \
497 .callback = hdaps_dmi_match, \ 497 .callback = hdaps_dmi_match, \
498 .matches = { \ 498 .matches = { \
499 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), \ 499 DMI_MATCH(DMI_BOARD_VENDOR, vendor), \
500 DMI_MATCH(DMI_PRODUCT_VERSION, model) \ 500 DMI_MATCH(DMI_PRODUCT_VERSION, model) \
501 } \ 501 } \
502} 502}
503 503
504#define HDAPS_DMI_MATCH_INVERT(model) { \ 504#define HDAPS_DMI_MATCH_INVERT(vendor, model) { \
505 .ident = "IBM " model, \ 505 .ident = vendor " " model, \
506 .callback = hdaps_dmi_match_invert, \ 506 .callback = hdaps_dmi_match_invert, \
507 .matches = { \ 507 .matches = { \
508 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), \ 508 DMI_MATCH(DMI_BOARD_VENDOR, vendor), \
509 DMI_MATCH(DMI_PRODUCT_VERSION, model) \ 509 DMI_MATCH(DMI_PRODUCT_VERSION, model) \
510 } \ 510 } \
511} 511}
512 512
513#define HDAPS_DMI_MATCH_LENOVO(model) { \ 513/* Note that HDAPS_DMI_MATCH_NORMAL("ThinkPad T42") would match
514 .ident = "Lenovo " model, \ 514 "ThinkPad T42p", so the order of the entries matters.
515 .callback = hdaps_dmi_match_invert, \ 515 If your ThinkPad is not recognized, please update to latest
516 .matches = { \ 516 BIOS. This is especially the case for some R52 ThinkPads. */
517 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), \ 517static struct dmi_system_id __initdata hdaps_whitelist[] = {
518 DMI_MATCH(DMI_PRODUCT_VERSION, model) \ 518 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad R50p"),
519 } \ 519 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R50"),
520} 520 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"),
521 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R52"),
522 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T41p"),
523 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T41"),
524 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T42p"),
525 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T42"),
526 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T43"),
527 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T60"),
528 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X40"),
529 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X41"),
530 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X60"),
531 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad Z60m"),
532 { .ident = NULL }
533};
521 534
522static int __init hdaps_init(void) 535static int __init hdaps_init(void)
523{ 536{
524 int ret; 537 int ret;
525 538
526 /* Note that HDAPS_DMI_MATCH_NORMAL("ThinkPad T42") would match
527 "ThinkPad T42p", so the order of the entries matters */
528 struct dmi_system_id hdaps_whitelist[] = {
529 HDAPS_DMI_MATCH_NORMAL("ThinkPad H"),
530 HDAPS_DMI_MATCH_INVERT("ThinkPad R50p"),
531 HDAPS_DMI_MATCH_NORMAL("ThinkPad R50"),
532 HDAPS_DMI_MATCH_NORMAL("ThinkPad R51"),
533 HDAPS_DMI_MATCH_NORMAL("ThinkPad R52"),
534 HDAPS_DMI_MATCH_NORMAL("ThinkPad H"), /* R52 (1846AQG) */
535 HDAPS_DMI_MATCH_INVERT("ThinkPad T41p"),
536 HDAPS_DMI_MATCH_NORMAL("ThinkPad T41"),
537 HDAPS_DMI_MATCH_INVERT("ThinkPad T42p"),
538 HDAPS_DMI_MATCH_NORMAL("ThinkPad T42"),
539 HDAPS_DMI_MATCH_NORMAL("ThinkPad T43"),
540 HDAPS_DMI_MATCH_LENOVO("ThinkPad T60p"),
541 HDAPS_DMI_MATCH_LENOVO("ThinkPad T60"),
542 HDAPS_DMI_MATCH_NORMAL("ThinkPad X40"),
543 HDAPS_DMI_MATCH_NORMAL("ThinkPad X41"),
544 HDAPS_DMI_MATCH_LENOVO("ThinkPad X60"),
545 HDAPS_DMI_MATCH_NORMAL("ThinkPad Z60m"),
546 { .ident = NULL }
547 };
548
549 if (!dmi_check_system(hdaps_whitelist)) { 539 if (!dmi_check_system(hdaps_whitelist)) {
550 printk(KERN_WARNING "hdaps: supported laptop not found!\n"); 540 printk(KERN_WARNING "hdaps: supported laptop not found!\n");
551 ret = -ENODEV; 541 ret = -ENODEV;
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c
index 9d67320e6840..31c42002708f 100644
--- a/drivers/hwmon/hwmon-vid.c
+++ b/drivers/hwmon/hwmon-vid.c
@@ -1,7 +1,7 @@
1/* 1/*
2 hwmon-vid.c - VID/VRM/VRD voltage conversions 2 hwmon-vid.c - VID/VRM/VRD voltage conversions
3 3
4 Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz> 4 Copyright (c) 2004 Rudolf Marek <r.marek@assembler.cz>
5 5
6 Partly imported from i2c-vid.h of the lm_sensors project 6 Partly imported from i2c-vid.h of the lm_sensors project
7 Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> 7 Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
@@ -232,7 +232,7 @@ u8 vid_which_vrm(void)
232EXPORT_SYMBOL(vid_from_reg); 232EXPORT_SYMBOL(vid_from_reg);
233EXPORT_SYMBOL(vid_which_vrm); 233EXPORT_SYMBOL(vid_which_vrm);
234 234
235MODULE_AUTHOR("Rudolf Marek <r.marek@sh.cvut.cz>"); 235MODULE_AUTHOR("Rudolf Marek <r.marek@assembler.cz>");
236 236
237MODULE_DESCRIPTION("hwmon-vid driver"); 237MODULE_DESCRIPTION("hwmon-vid driver");
238MODULE_LICENSE("GPL"); 238MODULE_LICENSE("GPL");
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 323ef06719c1..1ed8b7e2c35d 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -3,7 +3,7 @@
3 monitoring. 3 monitoring.
4 4
5 Supports: IT8705F Super I/O chip w/LPC interface 5 Supports: IT8705F Super I/O chip w/LPC interface
6 IT8712F Super I/O chip w/LPC interface & SMBus 6 IT8712F Super I/O chip w/LPC interface
7 IT8716F Super I/O chip w/LPC interface 7 IT8716F Super I/O chip w/LPC interface
8 IT8718F Super I/O chip w/LPC interface 8 IT8718F Super I/O chip w/LPC interface
9 Sis950 A clone of the IT8705F 9 Sis950 A clone of the IT8705F
@@ -41,12 +41,8 @@
41#include <asm/io.h> 41#include <asm/io.h>
42 42
43 43
44/* Addresses to scan */
45static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END };
46static unsigned short isa_address; 44static unsigned short isa_address;
47 45enum chips { it87, it8712, it8716, it8718 };
48/* Insmod parameters */
49I2C_CLIENT_INSMOD_4(it87, it8712, it8716, it8718);
50 46
51#define REG 0x2e /* The register to read/write */ 47#define REG 0x2e /* The register to read/write */
52#define DEV 0x07 /* Register: Logical device select */ 48#define DEV 0x07 /* Register: Logical device select */
@@ -162,8 +158,6 @@ static u8 vid_value;
162#define IT87_REG_TEMP_HIGH(nr) (0x40 + (nr) * 2) 158#define IT87_REG_TEMP_HIGH(nr) (0x40 + (nr) * 2)
163#define IT87_REG_TEMP_LOW(nr) (0x41 + (nr) * 2) 159#define IT87_REG_TEMP_LOW(nr) (0x41 + (nr) * 2)
164 160
165#define IT87_REG_I2C_ADDR 0x48
166
167#define IT87_REG_VIN_ENABLE 0x50 161#define IT87_REG_VIN_ENABLE 0x50
168#define IT87_REG_TEMP_ENABLE 0x51 162#define IT87_REG_TEMP_ENABLE 0x51
169 163
@@ -242,33 +236,22 @@ struct it87_data {
242}; 236};
243 237
244 238
245static int it87_attach_adapter(struct i2c_adapter *adapter); 239static int it87_detect(struct i2c_adapter *adapter);
246static int it87_isa_attach_adapter(struct i2c_adapter *adapter);
247static int it87_detect(struct i2c_adapter *adapter, int address, int kind);
248static int it87_detach_client(struct i2c_client *client); 240static int it87_detach_client(struct i2c_client *client);
249 241
250static int it87_read_value(struct i2c_client *client, u8 reg); 242static int it87_read_value(struct i2c_client *client, u8 reg);
251static int it87_write_value(struct i2c_client *client, u8 reg, u8 value); 243static void it87_write_value(struct i2c_client *client, u8 reg, u8 value);
252static struct it87_data *it87_update_device(struct device *dev); 244static struct it87_data *it87_update_device(struct device *dev);
253static int it87_check_pwm(struct i2c_client *client); 245static int it87_check_pwm(struct i2c_client *client);
254static void it87_init_client(struct i2c_client *client, struct it87_data *data); 246static void it87_init_client(struct i2c_client *client, struct it87_data *data);
255 247
256 248
257static struct i2c_driver it87_driver = {
258 .driver = {
259 .name = "it87",
260 },
261 .id = I2C_DRIVERID_IT87,
262 .attach_adapter = it87_attach_adapter,
263 .detach_client = it87_detach_client,
264};
265
266static struct i2c_driver it87_isa_driver = { 249static struct i2c_driver it87_isa_driver = {
267 .driver = { 250 .driver = {
268 .owner = THIS_MODULE, 251 .owner = THIS_MODULE,
269 .name = "it87-isa", 252 .name = "it87-isa",
270 }, 253 },
271 .attach_adapter = it87_isa_attach_adapter, 254 .attach_adapter = it87_detect,
272 .detach_client = it87_detach_client, 255 .detach_client = it87_detach_client,
273}; 256};
274 257
@@ -850,22 +833,6 @@ static const struct attribute_group it87_group_opt = {
850 .attrs = it87_attributes_opt, 833 .attrs = it87_attributes_opt,
851}; 834};
852 835
853/* This function is called when:
854 * it87_driver is inserted (when this module is loaded), for each
855 available adapter
856 * when a new adapter is inserted (and it87_driver is still present) */
857static int it87_attach_adapter(struct i2c_adapter *adapter)
858{
859 if (!(adapter->class & I2C_CLASS_HWMON))
860 return 0;
861 return i2c_probe(adapter, &addr_data, it87_detect);
862}
863
864static int it87_isa_attach_adapter(struct i2c_adapter *adapter)
865{
866 return it87_detect(adapter, isa_address, -1);
867}
868
869/* SuperIO detection - will change isa_address if a chip is found */ 836/* SuperIO detection - will change isa_address if a chip is found */
870static int __init it87_find(unsigned short *address) 837static int __init it87_find(unsigned short *address)
871{ 838{
@@ -916,29 +883,20 @@ exit:
916} 883}
917 884
918/* This function is called by i2c_probe */ 885/* This function is called by i2c_probe */
919static int it87_detect(struct i2c_adapter *adapter, int address, int kind) 886static int it87_detect(struct i2c_adapter *adapter)
920{ 887{
921 int i;
922 struct i2c_client *new_client; 888 struct i2c_client *new_client;
923 struct it87_data *data; 889 struct it87_data *data;
924 int err = 0; 890 int err = 0;
925 const char *name = ""; 891 const char *name;
926 int is_isa = i2c_is_isa_adapter(adapter);
927 int enable_pwm_interface; 892 int enable_pwm_interface;
928 893
929 if (!is_isa &&
930 !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
931 goto ERROR0;
932
933 /* Reserve the ISA region */ 894 /* Reserve the ISA region */
934 if (is_isa) 895 if (!request_region(isa_address, IT87_EXTENT,
935 if (!request_region(address, IT87_EXTENT, 896 it87_isa_driver.driver.name)){
936 it87_isa_driver.driver.name)) 897 err = -EBUSY;
937 goto ERROR0; 898 goto ERROR0;
938 899 }
939 /* For now, we presume we have a valid client. We create the
940 client structure, even though we cannot fill it completely yet.
941 But it allows us to access it87_{read,write}_value. */
942 900
943 if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) { 901 if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) {
944 err = -ENOMEM; 902 err = -ENOMEM;
@@ -946,80 +904,46 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
946 } 904 }
947 905
948 new_client = &data->client; 906 new_client = &data->client;
949 if (is_isa) 907 mutex_init(&data->lock);
950 mutex_init(&data->lock);
951 i2c_set_clientdata(new_client, data); 908 i2c_set_clientdata(new_client, data);
952 new_client->addr = address; 909 new_client->addr = isa_address;
953 new_client->adapter = adapter; 910 new_client->adapter = adapter;
954 new_client->driver = is_isa ? &it87_isa_driver : &it87_driver; 911 new_client->driver = &it87_isa_driver;
955 new_client->flags = 0;
956 912
957 /* Now, we do the remaining detection. */ 913 /* Now, we do the remaining detection. */
958 914 if ((it87_read_value(new_client, IT87_REG_CONFIG) & 0x80)
959 if (kind < 0) { 915 || it87_read_value(new_client, IT87_REG_CHIPID) != 0x90) {
960 if ((it87_read_value(new_client, IT87_REG_CONFIG) & 0x80) 916 err = -ENODEV;
961 || (!is_isa 917 goto ERROR2;
962 && it87_read_value(new_client, IT87_REG_I2C_ADDR) != address)) {
963 err = -ENODEV;
964 goto ERROR2;
965 }
966 } 918 }
967 919
968 /* Determine the chip type. */ 920 /* Determine the chip type. */
969 if (kind <= 0) { 921 switch (chip_type) {
970 i = it87_read_value(new_client, IT87_REG_CHIPID); 922 case IT8712F_DEVID:
971 if (i == 0x90) { 923 data->type = it8712;
972 kind = it87;
973 if (is_isa) {
974 switch (chip_type) {
975 case IT8712F_DEVID:
976 kind = it8712;
977 break;
978 case IT8716F_DEVID:
979 kind = it8716;
980 break;
981 case IT8718F_DEVID:
982 kind = it8718;
983 break;
984 }
985 }
986 }
987 else {
988 if (kind == 0)
989 dev_info(&adapter->dev,
990 "Ignoring 'force' parameter for unknown chip at "
991 "adapter %d, address 0x%02x\n",
992 i2c_adapter_id(adapter), address);
993 err = -ENODEV;
994 goto ERROR2;
995 }
996 }
997
998 if (kind == it87) {
999 name = "it87";
1000 } else if (kind == it8712) {
1001 name = "it8712"; 924 name = "it8712";
1002 } else if (kind == it8716) { 925 break;
926 case IT8716F_DEVID:
927 data->type = it8716;
1003 name = "it8716"; 928 name = "it8716";
1004 } else if (kind == it8718) { 929 break;
930 case IT8718F_DEVID:
931 data->type = it8718;
1005 name = "it8718"; 932 name = "it8718";
933 break;
934 default:
935 data->type = it87;
936 name = "it87";
1006 } 937 }
1007 938
1008 /* Fill in the remaining client fields and put it into the global list */ 939 /* Fill in the remaining client fields and put it into the global list */
1009 strlcpy(new_client->name, name, I2C_NAME_SIZE); 940 strlcpy(new_client->name, name, I2C_NAME_SIZE);
1010 data->type = kind;
1011 data->valid = 0;
1012 mutex_init(&data->update_lock); 941 mutex_init(&data->update_lock);
1013 942
1014 /* Tell the I2C layer a new client has arrived */ 943 /* Tell the I2C layer a new client has arrived */
1015 if ((err = i2c_attach_client(new_client))) 944 if ((err = i2c_attach_client(new_client)))
1016 goto ERROR2; 945 goto ERROR2;
1017 946
1018 if (!is_isa)
1019 dev_info(&new_client->dev, "The I2C interface to IT87xxF "
1020 "hardware monitoring chips is deprecated. Please "
1021 "report if you still rely on it.\n");
1022
1023 /* Check PWM configuration */ 947 /* Check PWM configuration */
1024 enable_pwm_interface = it87_check_pwm(new_client); 948 enable_pwm_interface = it87_check_pwm(new_client);
1025 949
@@ -1129,8 +1053,7 @@ ERROR3:
1129ERROR2: 1053ERROR2:
1130 kfree(data); 1054 kfree(data);
1131ERROR1: 1055ERROR1:
1132 if (is_isa) 1056 release_region(isa_address, IT87_EXTENT);
1133 release_region(address, IT87_EXTENT);
1134ERROR0: 1057ERROR0:
1135 return err; 1058 return err;
1136} 1059}
@@ -1147,50 +1070,39 @@ static int it87_detach_client(struct i2c_client *client)
1147 if ((err = i2c_detach_client(client))) 1070 if ((err = i2c_detach_client(client)))
1148 return err; 1071 return err;
1149 1072
1150 if(i2c_is_isa_client(client)) 1073 release_region(client->addr, IT87_EXTENT);
1151 release_region(client->addr, IT87_EXTENT);
1152 kfree(data); 1074 kfree(data);
1153 1075
1154 return 0; 1076 return 0;
1155} 1077}
1156 1078
1157/* The SMBus locks itself, but ISA access must be locked explicitly! 1079/* ISA access must be locked explicitly!
1158 We don't want to lock the whole ISA bus, so we lock each client
1159 separately.
1160 We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, 1080 We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
1161 would slow down the IT87 access and should not be necessary. */ 1081 would slow down the IT87 access and should not be necessary. */
1162static int it87_read_value(struct i2c_client *client, u8 reg) 1082static int it87_read_value(struct i2c_client *client, u8 reg)
1163{ 1083{
1164 struct it87_data *data = i2c_get_clientdata(client); 1084 struct it87_data *data = i2c_get_clientdata(client);
1165
1166 int res; 1085 int res;
1167 if (i2c_is_isa_client(client)) { 1086
1168 mutex_lock(&data->lock); 1087 mutex_lock(&data->lock);
1169 outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); 1088 outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
1170 res = inb_p(client->addr + IT87_DATA_REG_OFFSET); 1089 res = inb_p(client->addr + IT87_DATA_REG_OFFSET);
1171 mutex_unlock(&data->lock); 1090 mutex_unlock(&data->lock);
1172 return res; 1091
1173 } else 1092 return res;
1174 return i2c_smbus_read_byte_data(client, reg);
1175} 1093}
1176 1094
1177/* The SMBus locks itself, but ISA access muse be locked explicitly! 1095/* ISA access must be locked explicitly!
1178 We don't want to lock the whole ISA bus, so we lock each client
1179 separately.
1180 We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, 1096 We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
1181 would slow down the IT87 access and should not be necessary. */ 1097 would slow down the IT87 access and should not be necessary. */
1182static int it87_write_value(struct i2c_client *client, u8 reg, u8 value) 1098static void it87_write_value(struct i2c_client *client, u8 reg, u8 value)
1183{ 1099{
1184 struct it87_data *data = i2c_get_clientdata(client); 1100 struct it87_data *data = i2c_get_clientdata(client);
1185 1101
1186 if (i2c_is_isa_client(client)) { 1102 mutex_lock(&data->lock);
1187 mutex_lock(&data->lock); 1103 outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
1188 outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); 1104 outb_p(value, client->addr + IT87_DATA_REG_OFFSET);
1189 outb_p(value, client->addr + IT87_DATA_REG_OFFSET); 1105 mutex_unlock(&data->lock);
1190 mutex_unlock(&data->lock);
1191 return 0;
1192 } else
1193 return i2c_smbus_write_byte_data(client, reg, value);
1194} 1106}
1195 1107
1196/* Return 1 if and only if the PWM interface is safe to use */ 1108/* Return 1 if and only if the PWM interface is safe to use */
@@ -1426,26 +1338,14 @@ static int __init sm_it87_init(void)
1426{ 1338{
1427 int res; 1339 int res;
1428 1340
1429 res = i2c_add_driver(&it87_driver); 1341 if ((res = it87_find(&isa_address)))
1430 if (res)
1431 return res; 1342 return res;
1432 1343 return i2c_isa_add_driver(&it87_isa_driver);
1433 if (!it87_find(&isa_address)) {
1434 res = i2c_isa_add_driver(&it87_isa_driver);
1435 if (res) {
1436 i2c_del_driver(&it87_driver);
1437 return res;
1438 }
1439 }
1440
1441 return 0;
1442} 1344}
1443 1345
1444static void __exit sm_it87_exit(void) 1346static void __exit sm_it87_exit(void)
1445{ 1347{
1446 if (isa_address) 1348 i2c_isa_del_driver(&it87_isa_driver);
1447 i2c_isa_del_driver(&it87_isa_driver);
1448 i2c_del_driver(&it87_driver);
1449} 1349}
1450 1350
1451 1351
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index f58b64ed09e3..5d8d0ca08fa9 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * k8temp.c - Linux kernel module for hardware monitoring 2 * k8temp.c - Linux kernel module for hardware monitoring
3 * 3 *
4 * Copyright (C) 2006 Rudolf Marek <r.marek@sh.cvut.cz> 4 * Copyright (C) 2006 Rudolf Marek <r.marek@assembler.cz>
5 * 5 *
6 * Inspired from the w83785 and amd756 drivers. 6 * Inspired from the w83785 and amd756 drivers.
7 * 7 *
@@ -286,7 +286,7 @@ static void __exit k8temp_exit(void)
286 pci_unregister_driver(&k8temp_driver); 286 pci_unregister_driver(&k8temp_driver);
287} 287}
288 288
289MODULE_AUTHOR("Rudolf Marek <r.marek@sh.cvut.cz>"); 289MODULE_AUTHOR("Rudolf Marek <r.marek@assembler.cz>");
290MODULE_DESCRIPTION("AMD K8 core temperature monitor"); 290MODULE_DESCRIPTION("AMD K8 core temperature monitor");
291MODULE_LICENSE("GPL"); 291MODULE_LICENSE("GPL");
292 292
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index 3b8b81984ad4..c8a21be09d87 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -1000,7 +1000,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
1000 (i&0x02) ? "external" : "internal"); 1000 (i&0x02) ? "external" : "internal");
1001 1001
1002 data->vid_conf = confreg[3]; 1002 data->vid_conf = confreg[3];
1003 data->vrm = 90; 1003 data->vrm = vid_which_vrm();
1004 } 1004 }
1005 1005
1006 /* Fan clock dividers may be needed before any data is read */ 1006 /* Fan clock dividers may be needed before any data is read */
diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c
new file mode 100644
index 000000000000..affa21a5ccfd
--- /dev/null
+++ b/drivers/hwmon/pc87427.c
@@ -0,0 +1,627 @@
1/*
2 * pc87427.c - hardware monitoring driver for the
3 * National Semiconductor PC87427 Super-I/O chip
4 * Copyright (C) 2006 Jean Delvare <khali@linux-fr.org>
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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * Supports the following chips:
16 *
17 * Chip #vin #fan #pwm #temp devid
18 * PC87427 - 8 - - 0xF2
19 *
20 * This driver assumes that no more than one chip is present.
21 * Only fan inputs are supported so far, although the chip can do much more.
22 */
23
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/slab.h>
27#include <linux/jiffies.h>
28#include <linux/platform_device.h>
29#include <linux/hwmon.h>
30#include <linux/hwmon-sysfs.h>
31#include <linux/err.h>
32#include <linux/mutex.h>
33#include <linux/sysfs.h>
34#include <asm/io.h>
35
36static struct platform_device *pdev;
37
38#define DRVNAME "pc87427"
39
40/* The lock mutex protects both the I/O accesses (needed because the
41 device is using banked registers) and the register cache (needed to keep
42 the data in the registers and the cache in sync at any time). */
43struct pc87427_data {
44 struct class_device *class_dev;
45 struct mutex lock;
46 int address[2];
47 const char *name;
48
49 unsigned long last_updated; /* in jiffies */
50 u8 fan_enabled; /* bit vector */
51 u16 fan[8]; /* register values */
52 u16 fan_min[8]; /* register values */
53 u8 fan_status[8]; /* register values */
54};
55
56/*
57 * Super-I/O registers and operations
58 */
59
60#define SIOREG_LDSEL 0x07 /* Logical device select */
61#define SIOREG_DEVID 0x20 /* Device ID */
62#define SIOREG_ACT 0x30 /* Device activation */
63#define SIOREG_MAP 0x50 /* I/O or memory mapping */
64#define SIOREG_IOBASE 0x60 /* I/O base address */
65
66static const u8 logdev[2] = { 0x09, 0x14 };
67static const char *logdev_str[2] = { DRVNAME " FMC", DRVNAME " HMC" };
68#define LD_FAN 0
69#define LD_IN 1
70#define LD_TEMP 1
71
72static inline void superio_outb(int sioaddr, int reg, int val)
73{
74 outb(reg, sioaddr);
75 outb(val, sioaddr + 1);
76}
77
78static inline int superio_inb(int sioaddr, int reg)
79{
80 outb(reg, sioaddr);
81 return inb(sioaddr + 1);
82}
83
84static inline void superio_exit(int sioaddr)
85{
86 outb(0x02, sioaddr);
87 outb(0x02, sioaddr + 1);
88}
89
90/*
91 * Logical devices
92 */
93
94#define REGION_LENGTH 32
95#define PC87427_REG_BANK 0x0f
96#define BANK_FM(nr) (nr)
97#define BANK_FT(nr) (0x08 + (nr))
98#define BANK_FC(nr) (0x10 + (nr) * 2)
99
100/*
101 * I/O access functions
102 */
103
104/* ldi is the logical device index */
105static inline int pc87427_read8(struct pc87427_data *data, u8 ldi, u8 reg)
106{
107 return inb(data->address[ldi] + reg);
108}
109
110/* Must be called with data->lock held, except during init */
111static inline int pc87427_read8_bank(struct pc87427_data *data, u8 ldi,
112 u8 bank, u8 reg)
113{
114 outb(bank, data->address[ldi] + PC87427_REG_BANK);
115 return inb(data->address[ldi] + reg);
116}
117
118/* Must be called with data->lock held, except during init */
119static inline void pc87427_write8_bank(struct pc87427_data *data, u8 ldi,
120 u8 bank, u8 reg, u8 value)
121{
122 outb(bank, data->address[ldi] + PC87427_REG_BANK);
123 outb(value, data->address[ldi] + reg);
124}
125
126/*
127 * Fan registers and conversions
128 */
129
130/* fan data registers are 16-bit wide */
131#define PC87427_REG_FAN 0x12
132#define PC87427_REG_FAN_MIN 0x14
133#define PC87427_REG_FAN_STATUS 0x10
134
135#define FAN_STATUS_STALL (1 << 3)
136#define FAN_STATUS_LOSPD (1 << 1)
137#define FAN_STATUS_MONEN (1 << 0)
138
139/* Dedicated function to read all registers related to a given fan input.
140 This saves us quite a few locks and bank selections.
141 Must be called with data->lock held.
142 nr is from 0 to 7 */
143static void pc87427_readall_fan(struct pc87427_data *data, u8 nr)
144{
145 int iobase = data->address[LD_FAN];
146
147 outb(BANK_FM(nr), iobase + PC87427_REG_BANK);
148 data->fan[nr] = inw(iobase + PC87427_REG_FAN);
149 data->fan_min[nr] = inw(iobase + PC87427_REG_FAN_MIN);
150 data->fan_status[nr] = inb(iobase + PC87427_REG_FAN_STATUS);
151 /* Clear fan alarm bits */
152 outb(data->fan_status[nr], iobase + PC87427_REG_FAN_STATUS);
153}
154
155/* The 2 LSB of fan speed registers are used for something different.
156 The actual 2 LSB of the measurements are not available. */
157static inline unsigned long fan_from_reg(u16 reg)
158{
159 reg &= 0xfffc;
160 if (reg == 0x0000 || reg == 0xfffc)
161 return 0;
162 return 5400000UL / reg;
163}
164
165/* The 2 LSB of the fan speed limit registers are not significant. */
166static inline u16 fan_to_reg(unsigned long val)
167{
168 if (val < 83UL)
169 return 0xffff;
170 if (val >= 1350000UL)
171 return 0x0004;
172 return ((1350000UL + val / 2) / val) << 2;
173}
174
175/*
176 * Data interface
177 */
178
179static struct pc87427_data *pc87427_update_device(struct device *dev)
180{
181 struct pc87427_data *data = dev_get_drvdata(dev);
182 int i;
183
184 mutex_lock(&data->lock);
185 if (!time_after(jiffies, data->last_updated + HZ)
186 && data->last_updated)
187 goto done;
188
189 /* Fans */
190 for (i = 0; i < 8; i++) {
191 if (!(data->fan_enabled & (1 << i)))
192 continue;
193 pc87427_readall_fan(data, i);
194 }
195 data->last_updated = jiffies;
196
197done:
198 mutex_unlock(&data->lock);
199 return data;
200}
201
202static ssize_t show_fan_input(struct device *dev, struct device_attribute
203 *devattr, char *buf)
204{
205 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
206 struct pc87427_data *data = pc87427_update_device(dev);
207 int nr = attr->index;
208
209 return sprintf(buf, "%lu\n", fan_from_reg(data->fan[nr]));
210}
211
212static ssize_t show_fan_min(struct device *dev, struct device_attribute
213 *devattr, char *buf)
214{
215 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
216 struct pc87427_data *data = pc87427_update_device(dev);
217 int nr = attr->index;
218
219 return sprintf(buf, "%lu\n", fan_from_reg(data->fan_min[nr]));
220}
221
222static ssize_t show_fan_alarm(struct device *dev, struct device_attribute
223 *devattr, char *buf)
224{
225 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
226 struct pc87427_data *data = pc87427_update_device(dev);
227 int nr = attr->index;
228
229 return sprintf(buf, "%d\n", !!(data->fan_status[nr]
230 & FAN_STATUS_LOSPD));
231}
232
233static ssize_t show_fan_fault(struct device *dev, struct device_attribute
234 *devattr, char *buf)
235{
236 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
237 struct pc87427_data *data = pc87427_update_device(dev);
238 int nr = attr->index;
239
240 return sprintf(buf, "%d\n", !!(data->fan_status[nr]
241 & FAN_STATUS_STALL));
242}
243
244static ssize_t set_fan_min(struct device *dev, struct device_attribute
245 *devattr, const char *buf, size_t count)
246{
247 struct pc87427_data *data = dev_get_drvdata(dev);
248 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
249 int nr = attr->index;
250 unsigned long val = simple_strtoul(buf, NULL, 10);
251 int iobase = data->address[LD_FAN];
252
253 mutex_lock(&data->lock);
254 outb(BANK_FM(nr), iobase + PC87427_REG_BANK);
255 /* The low speed limit registers are read-only while monitoring
256 is enabled, so we have to disable monitoring, then change the
257 limit, and finally enable monitoring again. */
258 outb(0, iobase + PC87427_REG_FAN_STATUS);
259 data->fan_min[nr] = fan_to_reg(val);
260 outw(data->fan_min[nr], iobase + PC87427_REG_FAN_MIN);
261 outb(FAN_STATUS_MONEN, iobase + PC87427_REG_FAN_STATUS);
262 mutex_unlock(&data->lock);
263
264 return count;
265}
266
267static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0);
268static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1);
269static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2);
270static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan_input, NULL, 3);
271static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan_input, NULL, 4);
272static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan_input, NULL, 5);
273static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan_input, NULL, 6);
274static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_fan_input, NULL, 7);
275
276static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO,
277 show_fan_min, set_fan_min, 0);
278static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO,
279 show_fan_min, set_fan_min, 1);
280static SENSOR_DEVICE_ATTR(fan3_min, S_IWUSR | S_IRUGO,
281 show_fan_min, set_fan_min, 2);
282static SENSOR_DEVICE_ATTR(fan4_min, S_IWUSR | S_IRUGO,
283 show_fan_min, set_fan_min, 3);
284static SENSOR_DEVICE_ATTR(fan5_min, S_IWUSR | S_IRUGO,
285 show_fan_min, set_fan_min, 4);
286static SENSOR_DEVICE_ATTR(fan6_min, S_IWUSR | S_IRUGO,
287 show_fan_min, set_fan_min, 5);
288static SENSOR_DEVICE_ATTR(fan7_min, S_IWUSR | S_IRUGO,
289 show_fan_min, set_fan_min, 6);
290static SENSOR_DEVICE_ATTR(fan8_min, S_IWUSR | S_IRUGO,
291 show_fan_min, set_fan_min, 7);
292
293static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0);
294static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 1);
295static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 2);
296static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 3);
297static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_fan_alarm, NULL, 4);
298static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_fan_alarm, NULL, 5);
299static SENSOR_DEVICE_ATTR(fan7_alarm, S_IRUGO, show_fan_alarm, NULL, 6);
300static SENSOR_DEVICE_ATTR(fan8_alarm, S_IRUGO, show_fan_alarm, NULL, 7);
301
302static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, show_fan_fault, NULL, 0);
303static SENSOR_DEVICE_ATTR(fan2_fault, S_IRUGO, show_fan_fault, NULL, 1);
304static SENSOR_DEVICE_ATTR(fan3_fault, S_IRUGO, show_fan_fault, NULL, 2);
305static SENSOR_DEVICE_ATTR(fan4_fault, S_IRUGO, show_fan_fault, NULL, 3);
306static SENSOR_DEVICE_ATTR(fan5_fault, S_IRUGO, show_fan_fault, NULL, 4);
307static SENSOR_DEVICE_ATTR(fan6_fault, S_IRUGO, show_fan_fault, NULL, 5);
308static SENSOR_DEVICE_ATTR(fan7_fault, S_IRUGO, show_fan_fault, NULL, 6);
309static SENSOR_DEVICE_ATTR(fan8_fault, S_IRUGO, show_fan_fault, NULL, 7);
310
311static struct attribute *pc87427_attributes_fan[8][5] = {
312 {
313 &sensor_dev_attr_fan1_input.dev_attr.attr,
314 &sensor_dev_attr_fan1_min.dev_attr.attr,
315 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
316 &sensor_dev_attr_fan1_fault.dev_attr.attr,
317 NULL
318 }, {
319 &sensor_dev_attr_fan2_input.dev_attr.attr,
320 &sensor_dev_attr_fan2_min.dev_attr.attr,
321 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
322 &sensor_dev_attr_fan2_fault.dev_attr.attr,
323 NULL
324 }, {
325 &sensor_dev_attr_fan3_input.dev_attr.attr,
326 &sensor_dev_attr_fan3_min.dev_attr.attr,
327 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
328 &sensor_dev_attr_fan3_fault.dev_attr.attr,
329 NULL
330 }, {
331 &sensor_dev_attr_fan4_input.dev_attr.attr,
332 &sensor_dev_attr_fan4_min.dev_attr.attr,
333 &sensor_dev_attr_fan4_alarm.dev_attr.attr,
334 &sensor_dev_attr_fan4_fault.dev_attr.attr,
335 NULL
336 }, {
337 &sensor_dev_attr_fan5_input.dev_attr.attr,
338 &sensor_dev_attr_fan5_min.dev_attr.attr,
339 &sensor_dev_attr_fan5_alarm.dev_attr.attr,
340 &sensor_dev_attr_fan5_fault.dev_attr.attr,
341 NULL
342 }, {
343 &sensor_dev_attr_fan6_input.dev_attr.attr,
344 &sensor_dev_attr_fan6_min.dev_attr.attr,
345 &sensor_dev_attr_fan6_alarm.dev_attr.attr,
346 &sensor_dev_attr_fan6_fault.dev_attr.attr,
347 NULL
348 }, {
349 &sensor_dev_attr_fan7_input.dev_attr.attr,
350 &sensor_dev_attr_fan7_min.dev_attr.attr,
351 &sensor_dev_attr_fan7_alarm.dev_attr.attr,
352 &sensor_dev_attr_fan7_fault.dev_attr.attr,
353 NULL
354 }, {
355 &sensor_dev_attr_fan8_input.dev_attr.attr,
356 &sensor_dev_attr_fan8_min.dev_attr.attr,
357 &sensor_dev_attr_fan8_alarm.dev_attr.attr,
358 &sensor_dev_attr_fan8_fault.dev_attr.attr,
359 NULL
360 }
361};
362
363static const struct attribute_group pc87427_group_fan[8] = {
364 { .attrs = pc87427_attributes_fan[0] },
365 { .attrs = pc87427_attributes_fan[1] },
366 { .attrs = pc87427_attributes_fan[2] },
367 { .attrs = pc87427_attributes_fan[3] },
368 { .attrs = pc87427_attributes_fan[4] },
369 { .attrs = pc87427_attributes_fan[5] },
370 { .attrs = pc87427_attributes_fan[6] },
371 { .attrs = pc87427_attributes_fan[7] },
372};
373
374static ssize_t show_name(struct device *dev, struct device_attribute
375 *devattr, char *buf)
376{
377 struct pc87427_data *data = dev_get_drvdata(dev);
378
379 return sprintf(buf, "%s\n", data->name);
380}
381static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
382
383
384/*
385 * Device detection, attach and detach
386 */
387
388static void __devinit pc87427_init_device(struct device *dev)
389{
390 struct pc87427_data *data = dev_get_drvdata(dev);
391 int i;
392 u8 reg;
393
394 /* The FMC module should be ready */
395 reg = pc87427_read8(data, LD_FAN, PC87427_REG_BANK);
396 if (!(reg & 0x80))
397 dev_warn(dev, "FMC module not ready!\n");
398
399 /* Check which fans are enabled */
400 for (i = 0; i < 8; i++) {
401 reg = pc87427_read8_bank(data, LD_FAN, BANK_FM(i),
402 PC87427_REG_FAN_STATUS);
403 if (reg & FAN_STATUS_MONEN)
404 data->fan_enabled |= (1 << i);
405 }
406
407 if (!data->fan_enabled) {
408 dev_dbg(dev, "Enabling all fan inputs\n");
409 for (i = 0; i < 8; i++)
410 pc87427_write8_bank(data, LD_FAN, BANK_FM(i),
411 PC87427_REG_FAN_STATUS,
412 FAN_STATUS_MONEN);
413 data->fan_enabled = 0xff;
414 }
415}
416
417static int __devinit pc87427_probe(struct platform_device *pdev)
418{
419 struct pc87427_data *data;
420 struct resource *res;
421 int i, err;
422
423 if (!(data = kzalloc(sizeof(struct pc87427_data), GFP_KERNEL))) {
424 err = -ENOMEM;
425 printk(KERN_ERR DRVNAME ": Out of memory\n");
426 goto exit;
427 }
428
429 /* This will need to be revisited when we add support for
430 temperature and voltage monitoring. */
431 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
432 data->address[0] = res->start;
433
434 mutex_init(&data->lock);
435 data->name = "pc87427";
436 platform_set_drvdata(pdev, data);
437 pc87427_init_device(&pdev->dev);
438
439 /* Register sysfs hooks */
440 if ((err = device_create_file(&pdev->dev, &dev_attr_name)))
441 goto exit_kfree;
442 for (i = 0; i < 8; i++) {
443 if (!(data->fan_enabled & (1 << i)))
444 continue;
445 if ((err = sysfs_create_group(&pdev->dev.kobj,
446 &pc87427_group_fan[i])))
447 goto exit_remove_files;
448 }
449
450 data->class_dev = hwmon_device_register(&pdev->dev);
451 if (IS_ERR(data->class_dev)) {
452 err = PTR_ERR(data->class_dev);
453 dev_err(&pdev->dev, "Class registration failed (%d)\n", err);
454 goto exit_remove_files;
455 }
456
457 return 0;
458
459exit_remove_files:
460 for (i = 0; i < 8; i++) {
461 if (!(data->fan_enabled & (1 << i)))
462 continue;
463 sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]);
464 }
465exit_kfree:
466 platform_set_drvdata(pdev, NULL);
467 kfree(data);
468exit:
469 return err;
470}
471
472static int __devexit pc87427_remove(struct platform_device *pdev)
473{
474 struct pc87427_data *data = platform_get_drvdata(pdev);
475 int i;
476
477 platform_set_drvdata(pdev, NULL);
478 hwmon_device_unregister(data->class_dev);
479 device_remove_file(&pdev->dev, &dev_attr_name);
480 for (i = 0; i < 8; i++) {
481 if (!(data->fan_enabled & (1 << i)))
482 continue;
483 sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]);
484 }
485 kfree(data);
486
487 return 0;
488}
489
490
491static struct platform_driver pc87427_driver = {
492 .driver = {
493 .owner = THIS_MODULE,
494 .name = DRVNAME,
495 },
496 .probe = pc87427_probe,
497 .remove = __devexit_p(pc87427_remove),
498};
499
500static int __init pc87427_device_add(unsigned short address)
501{
502 struct resource res = {
503 .start = address,
504 .end = address + REGION_LENGTH - 1,
505 .name = logdev_str[0],
506 .flags = IORESOURCE_IO,
507 };
508 int err;
509
510 pdev = platform_device_alloc(DRVNAME, address);
511 if (!pdev) {
512 err = -ENOMEM;
513 printk(KERN_ERR DRVNAME ": Device allocation failed\n");
514 goto exit;
515 }
516
517 err = platform_device_add_resources(pdev, &res, 1);
518 if (err) {
519 printk(KERN_ERR DRVNAME ": Device resource addition failed "
520 "(%d)\n", err);
521 goto exit_device_put;
522 }
523
524 err = platform_device_add(pdev);
525 if (err) {
526 printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n",
527 err);
528 goto exit_device_put;
529 }
530
531 return 0;
532
533exit_device_put:
534 platform_device_put(pdev);
535exit:
536 return err;
537}
538
539static int __init pc87427_find(int sioaddr, unsigned short *address)
540{
541 u16 val;
542 int i, err = 0;
543
544 /* Identify device */
545 val = superio_inb(sioaddr, SIOREG_DEVID);
546 if (val != 0xf2) { /* PC87427 */
547 err = -ENODEV;
548 goto exit;
549 }
550
551 for (i = 0; i < 2; i++) {
552 address[i] = 0;
553 /* Select logical device */
554 superio_outb(sioaddr, SIOREG_LDSEL, logdev[i]);
555
556 val = superio_inb(sioaddr, SIOREG_ACT);
557 if (!(val & 0x01)) {
558 printk(KERN_INFO DRVNAME ": Logical device 0x%02x "
559 "not activated\n", logdev[i]);
560 continue;
561 }
562
563 val = superio_inb(sioaddr, SIOREG_MAP);
564 if (val & 0x01) {
565 printk(KERN_WARNING DRVNAME ": Logical device 0x%02x "
566 "is memory-mapped, can't use\n", logdev[i]);
567 continue;
568 }
569
570 val = (superio_inb(sioaddr, SIOREG_IOBASE) << 8)
571 | superio_inb(sioaddr, SIOREG_IOBASE + 1);
572 if (!val) {
573 printk(KERN_INFO DRVNAME ": I/O base address not set "
574 "for logical device 0x%02x\n", logdev[i]);
575 continue;
576 }
577 address[i] = val;
578 }
579
580exit:
581 superio_exit(sioaddr);
582 return err;
583}
584
585static int __init pc87427_init(void)
586{
587 int err;
588 unsigned short address[2];
589
590 if (pc87427_find(0x2e, address)
591 && pc87427_find(0x4e, address))
592 return -ENODEV;
593
594 /* For now the driver only handles fans so we only care about the
595 first address. */
596 if (!address[0])
597 return -ENODEV;
598
599 err = platform_driver_register(&pc87427_driver);
600 if (err)
601 goto exit;
602
603 /* Sets global pdev as a side effect */
604 err = pc87427_device_add(address[0]);
605 if (err)
606 goto exit_driver;
607
608 return 0;
609
610exit_driver:
611 platform_driver_unregister(&pc87427_driver);
612exit:
613 return err;
614}
615
616static void __exit pc87427_exit(void)
617{
618 platform_device_unregister(pdev);
619 platform_driver_unregister(&pc87427_driver);
620}
621
622MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
623MODULE_DESCRIPTION("PC87427 hardware monitoring driver");
624MODULE_LICENSE("GPL");
625
626module_init(pc87427_init);
627module_exit(pc87427_exit);
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 2257806d0102..212a1558c63b 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -3,7 +3,7 @@
3 the Winbond W83627EHF Super-I/O chip 3 the Winbond W83627EHF Super-I/O chip
4 Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> 4 Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
5 Copyright (C) 2006 Yuan Mu (Winbond), 5 Copyright (C) 2006 Yuan Mu (Winbond),
6 Rudolf Marek <r.marek@sh.cvut.cz> 6 Rudolf Marek <r.marek@assembler.cz>
7 David Hubbard <david.c.hubbard@gmail.com> 7 David Hubbard <david.c.hubbard@gmail.com>
8 8
9 Shamelessly ripped from the w83627hf driver 9 Shamelessly ripped from the w83627hf driver
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 4e108262576f..b0fa296740d1 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -3,7 +3,7 @@
3 monitoring 3 monitoring
4 Copyright (C) 2004, 2005 Winbond Electronics Corp. 4 Copyright (C) 2004, 2005 Winbond Electronics Corp.
5 Chunhao Huang <DZShen@Winbond.com.tw>, 5 Chunhao Huang <DZShen@Winbond.com.tw>,
6 Rudolf Marek <r.marek@sh.cvut.cz> 6 Rudolf Marek <r.marek@assembler.cz>
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
new file mode 100644
index 000000000000..c12ac5abc2bb
--- /dev/null
+++ b/drivers/hwmon/w83793.c
@@ -0,0 +1,1609 @@
1/*
2 w83793.c - Linux kernel driver for hardware monitoring
3 Copyright (C) 2006 Winbond Electronics Corp.
4 Yuan Mu
5 Rudolf Marek <r.marek@assembler.cz>
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 - version 2.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20*/
21
22/*
23 Supports following chips:
24
25 Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
26 w83793 10 12 8 6 0x7b 0x5ca3 yes no
27*/
28
29#include <linux/module.h>
30#include <linux/init.h>
31#include <linux/slab.h>
32#include <linux/i2c.h>
33#include <linux/hwmon.h>
34#include <linux/hwmon-vid.h>
35#include <linux/hwmon-sysfs.h>
36#include <linux/err.h>
37#include <linux/mutex.h>
38
39/* Addresses to scan */
40static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
41
42/* Insmod parameters */
43I2C_CLIENT_INSMOD_1(w83793);
44I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
45 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
46
47static int reset;
48module_param(reset, bool, 0);
49MODULE_PARM_DESC(reset, "Set to 1 to reset chip, not recommended");
50
51/*
52 Address 0x00, 0x0d, 0x0e, 0x0f in all three banks are reserved
53 as ID, Bank Select registers
54*/
55#define W83793_REG_BANKSEL 0x00
56#define W83793_REG_VENDORID 0x0d
57#define W83793_REG_CHIPID 0x0e
58#define W83793_REG_DEVICEID 0x0f
59
60#define W83793_REG_CONFIG 0x40
61#define W83793_REG_MFC 0x58
62#define W83793_REG_FANIN_CTRL 0x5c
63#define W83793_REG_FANIN_SEL 0x5d
64#define W83793_REG_I2C_ADDR 0x0b
65#define W83793_REG_I2C_SUBADDR 0x0c
66#define W83793_REG_VID_INA 0x05
67#define W83793_REG_VID_INB 0x06
68#define W83793_REG_VID_LATCHA 0x07
69#define W83793_REG_VID_LATCHB 0x08
70#define W83793_REG_VID_CTRL 0x59
71
72static u16 W83793_REG_TEMP_MODE[2] = { 0x5e, 0x5f };
73
74#define TEMP_READ 0
75#define TEMP_CRIT 1
76#define TEMP_CRIT_HYST 2
77#define TEMP_WARN 3
78#define TEMP_WARN_HYST 4
79/* only crit and crit_hyst affect real-time alarm status
80 current crit crit_hyst warn warn_hyst */
81static u16 W83793_REG_TEMP[][5] = {
82 {0x1c, 0x78, 0x79, 0x7a, 0x7b},
83 {0x1d, 0x7c, 0x7d, 0x7e, 0x7f},
84 {0x1e, 0x80, 0x81, 0x82, 0x83},
85 {0x1f, 0x84, 0x85, 0x86, 0x87},
86 {0x20, 0x88, 0x89, 0x8a, 0x8b},
87 {0x21, 0x8c, 0x8d, 0x8e, 0x8f},
88};
89
90#define W83793_REG_TEMP_LOW_BITS 0x22
91
92#define W83793_REG_BEEP(index) (0x53 + (index))
93#define W83793_REG_ALARM(index) (0x4b + (index))
94
95#define W83793_REG_CLR_CHASSIS 0x4a /* SMI MASK4 */
96#define W83793_REG_IRQ_CTRL 0x50
97#define W83793_REG_OVT_CTRL 0x51
98#define W83793_REG_OVT_BEEP 0x52
99
100#define IN_READ 0
101#define IN_MAX 1
102#define IN_LOW 2
103static const u16 W83793_REG_IN[][3] = {
104 /* Current, High, Low */
105 {0x10, 0x60, 0x61}, /* Vcore A */
106 {0x11, 0x62, 0x63}, /* Vcore B */
107 {0x12, 0x64, 0x65}, /* Vtt */
108 {0x14, 0x6a, 0x6b}, /* VSEN1 */
109 {0x15, 0x6c, 0x6d}, /* VSEN2 */
110 {0x16, 0x6e, 0x6f}, /* +3VSEN */
111 {0x17, 0x70, 0x71}, /* +12VSEN */
112 {0x18, 0x72, 0x73}, /* 5VDD */
113 {0x19, 0x74, 0x75}, /* 5VSB */
114 {0x1a, 0x76, 0x77}, /* VBAT */
115};
116
117/* Low Bits of Vcore A/B Vtt Read/High/Low */
118static const u16 W83793_REG_IN_LOW_BITS[] = { 0x1b, 0x68, 0x69 };
119static u8 scale_in[] = { 2, 2, 2, 16, 16, 16, 8, 24, 24, 16 };
120
121#define W83793_REG_FAN(index) (0x23 + 2 * (index)) /* High byte */
122#define W83793_REG_FAN_MIN(index) (0x90 + 2 * (index)) /* High byte */
123
124#define W83793_REG_PWM_DEFAULT 0xb2
125#define W83793_REG_PWM_ENABLE 0x207
126#define W83793_REG_PWM_UPTIME 0xc3 /* Unit in 0.1 second */
127#define W83793_REG_PWM_DOWNTIME 0xc4 /* Unit in 0.1 second */
128#define W83793_REG_TEMP_CRITICAL 0xc5
129
130#define PWM_DUTY 0
131#define PWM_START 1
132#define PWM_NONSTOP 2
133#define W83793_REG_PWM(index, nr) (((nr) == 0 ? 0xb3 : \
134 (nr) == 1 ? 0x220 : 0x218) + (index))
135
136/* bit field, fan1 is bit0, fan2 is bit1 ... */
137#define W83793_REG_TEMP_FAN_MAP(index) (0x201 + (index))
138#define W83793_REG_TEMP_TOL(index) (0x208 + (index))
139#define W83793_REG_TEMP_CRUISE(index) (0x210 + (index))
140#define W83793_REG_PWM_STOP_TIME(index) (0x228 + (index))
141#define W83793_REG_SF2_TEMP(index, nr) (0x230 + ((index) << 4) + (nr))
142#define W83793_REG_SF2_PWM(index, nr) (0x238 + ((index) << 4) + (nr))
143
144static inline unsigned long FAN_FROM_REG(u16 val)
145{
146 if ((val >= 0xfff) || (val == 0))
147 return 0;
148 return (1350000UL / val);
149}
150
151static inline u16 FAN_TO_REG(long rpm)
152{
153 if (rpm <= 0)
154 return 0x0fff;
155 return SENSORS_LIMIT((1350000 + (rpm >> 1)) / rpm, 1, 0xffe);
156}
157
158static inline unsigned long TIME_FROM_REG(u8 reg)
159{
160 return (reg * 100);
161}
162
163static inline u8 TIME_TO_REG(unsigned long val)
164{
165 return SENSORS_LIMIT((val + 50) / 100, 0, 0xff);
166}
167
168static inline long TEMP_FROM_REG(s8 reg)
169{
170 return (reg * 1000);
171}
172
173static inline s8 TEMP_TO_REG(long val, s8 min, s8 max)
174{
175 return SENSORS_LIMIT((val + (val < 0 ? -500 : 500)) / 1000, min, max);
176}
177
178struct w83793_data {
179 struct i2c_client client;
180 struct i2c_client *lm75[2];
181 struct class_device *class_dev;
182 struct mutex update_lock;
183 char valid; /* !=0 if following fields are valid */
184 unsigned long last_updated; /* In jiffies */
185 unsigned long last_nonvolatile; /* In jiffies, last time we update the
186 nonvolatile registers */
187
188 u8 bank;
189 u8 vrm;
190 u8 vid[2];
191 u8 in[10][3]; /* Register value, read/high/low */
192 u8 in_low_bits[3]; /* Additional resolution for VCore A/B Vtt */
193
194 u16 has_fan; /* Only fan1- fan5 has own pins */
195 u16 fan[12]; /* Register value combine */
196 u16 fan_min[12]; /* Register value combine */
197
198 s8 temp[6][5]; /* current, crit, crit_hyst,warn, warn_hyst */
199 u8 temp_low_bits; /* Additional resolution TD1-TD4 */
200 u8 temp_mode[2]; /* byte 0: Temp D1-D4 mode each has 2 bits
201 byte 1: Temp R1,R2 mode, each has 1 bit */
202 u8 temp_critical; /* If reached all fan will be at full speed */
203 u8 temp_fan_map[6]; /* Temp controls which pwm fan, bit field */
204
205 u8 has_pwm;
206 u8 pwm_enable; /* Register value, each Temp has 1 bit */
207 u8 pwm_uptime; /* Register value */
208 u8 pwm_downtime; /* Register value */
209 u8 pwm_default; /* All fan default pwm, next poweron valid */
210 u8 pwm[8][3]; /* Register value */
211 u8 pwm_stop_time[8];
212 u8 temp_cruise[6];
213
214 u8 alarms[5]; /* realtime status registers */
215 u8 beeps[5];
216 u8 beep_enable;
217 u8 tolerance[3]; /* Temp tolerance(Smart Fan I/II) */
218 u8 sf2_pwm[6][7]; /* Smart FanII: Fan duty cycle */
219 u8 sf2_temp[6][7]; /* Smart FanII: Temp level point */
220};
221
222static u8 w83793_read_value(struct i2c_client *client, u16 reg);
223static int w83793_write_value(struct i2c_client *client, u16 reg, u8 value);
224static int w83793_attach_adapter(struct i2c_adapter *adapter);
225static int w83793_detect(struct i2c_adapter *adapter, int address, int kind);
226static int w83793_detach_client(struct i2c_client *client);
227static void w83793_init_client(struct i2c_client *client);
228static void w83793_update_nonvolatile(struct device *dev);
229static struct w83793_data *w83793_update_device(struct device *dev);
230
231static struct i2c_driver w83793_driver = {
232 .driver = {
233 .name = "w83793",
234 },
235 .attach_adapter = w83793_attach_adapter,
236 .detach_client = w83793_detach_client,
237};
238
239static ssize_t
240show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
241{
242 struct i2c_client *client = to_i2c_client(dev);
243 struct w83793_data *data = i2c_get_clientdata(client);
244
245 return sprintf(buf, "%d\n", data->vrm);
246}
247
248static ssize_t
249show_vid(struct device *dev, struct device_attribute *attr, char *buf)
250{
251 struct w83793_data *data = w83793_update_device(dev);
252 struct sensor_device_attribute_2 *sensor_attr =
253 to_sensor_dev_attr_2(attr);
254 int index = sensor_attr->index;
255
256 return sprintf(buf, "%d\n", vid_from_reg(data->vid[index], data->vrm));
257}
258
259static ssize_t
260store_vrm(struct device *dev, struct device_attribute *attr,
261 const char *buf, size_t count)
262{
263 struct i2c_client *client = to_i2c_client(dev);
264 struct w83793_data *data = i2c_get_clientdata(client);
265
266 data->vrm = simple_strtoul(buf, NULL, 10);
267 return count;
268}
269
270#define ALARM_STATUS 0
271#define BEEP_ENABLE 1
272static ssize_t
273show_alarm_beep(struct device *dev, struct device_attribute *attr, char *buf)
274{
275 struct w83793_data *data = w83793_update_device(dev);
276 struct sensor_device_attribute_2 *sensor_attr =
277 to_sensor_dev_attr_2(attr);
278 int nr = sensor_attr->nr;
279 int index = sensor_attr->index >> 3;
280 int bit = sensor_attr->index & 0x07;
281 u8 val;
282
283 if (ALARM_STATUS == nr) {
284 val = (data->alarms[index] >> (bit)) & 1;
285 } else { /* BEEP_ENABLE */
286 val = (data->beeps[index] >> (bit)) & 1;
287 }
288
289 return sprintf(buf, "%u\n", val);
290}
291
292static ssize_t
293store_beep(struct device *dev, struct device_attribute *attr,
294 const char *buf, size_t count)
295{
296 struct i2c_client *client = to_i2c_client(dev);
297 struct w83793_data *data = i2c_get_clientdata(client);
298 struct sensor_device_attribute_2 *sensor_attr =
299 to_sensor_dev_attr_2(attr);
300 int index = sensor_attr->index >> 3;
301 int shift = sensor_attr->index & 0x07;
302 u8 beep_bit = 1 << shift;
303 u8 val;
304
305 val = simple_strtoul(buf, NULL, 10);
306 if (val != 0 && val != 1)
307 return -EINVAL;
308
309 mutex_lock(&data->update_lock);
310 data->beeps[index] = w83793_read_value(client, W83793_REG_BEEP(index));
311 data->beeps[index] &= ~beep_bit;
312 data->beeps[index] |= val << shift;
313 w83793_write_value(client, W83793_REG_BEEP(index), data->beeps[index]);
314 mutex_unlock(&data->update_lock);
315
316 return count;
317}
318
319static ssize_t
320show_beep_enable(struct device *dev, struct device_attribute *attr, char *buf)
321{
322 struct w83793_data *data = w83793_update_device(dev);
323 return sprintf(buf, "%u\n", (data->beep_enable >> 1) & 0x01);
324}
325
326static ssize_t
327store_beep_enable(struct device *dev, struct device_attribute *attr,
328 const char *buf, size_t count)
329{
330 struct i2c_client *client = to_i2c_client(dev);
331 struct w83793_data *data = i2c_get_clientdata(client);
332 u8 val = simple_strtoul(buf, NULL, 10);
333
334 if (val != 0 && val != 1)
335 return -EINVAL;
336
337 mutex_lock(&data->update_lock);
338 data->beep_enable = w83793_read_value(client, W83793_REG_OVT_BEEP)
339 & 0xfd;
340 data->beep_enable |= val << 1;
341 w83793_write_value(client, W83793_REG_OVT_BEEP, data->beep_enable);
342 mutex_unlock(&data->update_lock);
343
344 return count;
345}
346
347/* Write any value to clear chassis alarm */
348static ssize_t
349store_chassis_clear(struct device *dev,
350 struct device_attribute *attr, const char *buf,
351 size_t count)
352{
353 struct i2c_client *client = to_i2c_client(dev);
354 struct w83793_data *data = i2c_get_clientdata(client);
355 u8 val;
356
357 mutex_lock(&data->update_lock);
358 val = w83793_read_value(client, W83793_REG_CLR_CHASSIS);
359 val |= 0x80;
360 w83793_write_value(client, W83793_REG_CLR_CHASSIS, val);
361 mutex_unlock(&data->update_lock);
362 return count;
363}
364
365#define FAN_INPUT 0
366#define FAN_MIN 1
367static ssize_t
368show_fan(struct device *dev, struct device_attribute *attr, char *buf)
369{
370 struct sensor_device_attribute_2 *sensor_attr =
371 to_sensor_dev_attr_2(attr);
372 int nr = sensor_attr->nr;
373 int index = sensor_attr->index;
374 struct w83793_data *data = w83793_update_device(dev);
375 u16 val;
376
377 if (FAN_INPUT == nr) {
378 val = data->fan[index] & 0x0fff;
379 } else {
380 val = data->fan_min[index] & 0x0fff;
381 }
382
383 return sprintf(buf, "%lu\n", FAN_FROM_REG(val));
384}
385
386static ssize_t
387store_fan_min(struct device *dev, struct device_attribute *attr,
388 const char *buf, size_t count)
389{
390 struct sensor_device_attribute_2 *sensor_attr =
391 to_sensor_dev_attr_2(attr);
392 int index = sensor_attr->index;
393 struct i2c_client *client = to_i2c_client(dev);
394 struct w83793_data *data = i2c_get_clientdata(client);
395 u16 val = FAN_TO_REG(simple_strtoul(buf, NULL, 10));
396
397 mutex_lock(&data->update_lock);
398 data->fan_min[index] = val;
399 w83793_write_value(client, W83793_REG_FAN_MIN(index),
400 (val >> 8) & 0xff);
401 w83793_write_value(client, W83793_REG_FAN_MIN(index) + 1, val & 0xff);
402 mutex_unlock(&data->update_lock);
403
404 return count;
405}
406
407#define PWM_DUTY 0
408#define PWM_START 1
409#define PWM_NONSTOP 2
410#define PWM_STOP_TIME 3
411static ssize_t
412show_pwm(struct device *dev, struct device_attribute *attr, char *buf)
413{
414 struct sensor_device_attribute_2 *sensor_attr =
415 to_sensor_dev_attr_2(attr);
416 struct w83793_data *data = w83793_update_device(dev);
417 u16 val;
418 int nr = sensor_attr->nr;
419 int index = sensor_attr->index;
420
421 if (PWM_STOP_TIME == nr)
422 val = TIME_FROM_REG(data->pwm_stop_time[index]);
423 else
424 val = (data->pwm[index][nr] & 0x3f) << 2;
425
426 return sprintf(buf, "%d\n", val);
427}
428
429static ssize_t
430store_pwm(struct device *dev, struct device_attribute *attr,
431 const char *buf, size_t count)
432{
433 struct i2c_client *client = to_i2c_client(dev);
434 struct w83793_data *data = i2c_get_clientdata(client);
435 struct sensor_device_attribute_2 *sensor_attr =
436 to_sensor_dev_attr_2(attr);
437 int nr = sensor_attr->nr;
438 int index = sensor_attr->index;
439 u8 val;
440
441 mutex_lock(&data->update_lock);
442 if (PWM_STOP_TIME == nr) {
443 val = TIME_TO_REG(simple_strtoul(buf, NULL, 10));
444 data->pwm_stop_time[index] = val;
445 w83793_write_value(client, W83793_REG_PWM_STOP_TIME(index),
446 val);
447 } else {
448 val = SENSORS_LIMIT(simple_strtoul(buf, NULL, 10), 0, 0xff)
449 >> 2;
450 data->pwm[index][nr] =
451 w83793_read_value(client, W83793_REG_PWM(index, nr)) & 0xc0;
452 data->pwm[index][nr] |= val;
453 w83793_write_value(client, W83793_REG_PWM(index, nr),
454 data->pwm[index][nr]);
455 }
456
457 mutex_unlock(&data->update_lock);
458 return count;
459}
460
461static ssize_t
462show_temp(struct device *dev, struct device_attribute *attr, char *buf)
463{
464 struct sensor_device_attribute_2 *sensor_attr =
465 to_sensor_dev_attr_2(attr);
466 int nr = sensor_attr->nr;
467 int index = sensor_attr->index;
468 struct w83793_data *data = w83793_update_device(dev);
469 long temp = TEMP_FROM_REG(data->temp[index][nr]);
470
471 if (TEMP_READ == nr && index < 4) { /* Only TD1-TD4 have low bits */
472 int low = ((data->temp_low_bits >> (index * 2)) & 0x03) * 250;
473 temp += temp > 0 ? low : -low;
474 }
475 return sprintf(buf, "%ld\n", temp);
476}
477
478static ssize_t
479store_temp(struct device *dev, struct device_attribute *attr,
480 const char *buf, size_t count)
481{
482 struct sensor_device_attribute_2 *sensor_attr =
483 to_sensor_dev_attr_2(attr);
484 int nr = sensor_attr->nr;
485 int index = sensor_attr->index;
486 struct i2c_client *client = to_i2c_client(dev);
487 struct w83793_data *data = i2c_get_clientdata(client);
488 long tmp = simple_strtol(buf, NULL, 10);
489
490 mutex_lock(&data->update_lock);
491 data->temp[index][nr] = TEMP_TO_REG(tmp, -128, 127);
492 w83793_write_value(client, W83793_REG_TEMP[index][nr],
493 data->temp[index][nr]);
494 mutex_unlock(&data->update_lock);
495 return count;
496}
497
498/*
499 TD1-TD4
500 each has 4 mode:(2 bits)
501 0: Stop monitor
502 1: Use internal temp sensor(default)
503 2: Use sensor in AMD CPU and get result by AMDSI
504 3: Use sensor in Intel CPU and get result by PECI
505
506 TR1-TR2
507 each has 2 mode:(1 bit)
508 0: Disable temp sensor monitor
509 1: To enable temp sensors monitor
510*/
511
512/* 0 disable, 5 AMDSI, 6 PECI */
513static u8 TO_TEMP_MODE[] = { 0, 0, 5, 6 };
514
515static ssize_t
516show_temp_mode(struct device *dev, struct device_attribute *attr, char *buf)
517{
518 struct w83793_data *data = w83793_update_device(dev);
519 struct sensor_device_attribute_2 *sensor_attr =
520 to_sensor_dev_attr_2(attr);
521 int index = sensor_attr->index;
522 u8 mask = (index < 4) ? 0x03 : 0x01;
523 u8 shift = (index < 4) ? (2 * index) : (index - 4);
524 u8 tmp;
525 index = (index < 4) ? 0 : 1;
526
527 tmp = (data->temp_mode[index] >> shift) & mask;
528
529 /* for the internal sensor, found out if diode or thermistor */
530 if (tmp == 1) {
531 tmp = index == 0 ? 3 : 4;
532 } else {
533 tmp = TO_TEMP_MODE[tmp];
534 }
535
536 return sprintf(buf, "%d\n", tmp);
537}
538
539static ssize_t
540store_temp_mode(struct device *dev, struct device_attribute *attr,
541 const char *buf, size_t count)
542{
543 struct i2c_client *client = to_i2c_client(dev);
544 struct w83793_data *data = i2c_get_clientdata(client);
545 struct sensor_device_attribute_2 *sensor_attr =
546 to_sensor_dev_attr_2(attr);
547 int index = sensor_attr->index;
548 u8 mask = (index < 4) ? 0x03 : 0x01;
549 u8 shift = (index < 4) ? (2 * index) : (index - 4);
550 u8 val = simple_strtoul(buf, NULL, 10);
551
552 /* transform the sysfs interface values into table above */
553 if ((val == 5 || val == 6) && (index < 4)) {
554 val -= 3;
555 } else if ((val == 3 && index < 4)
556 || (val == 4 && index >= 4)
557 || val == 0) {
558 /* transform diode or thermistor into internal enable */
559 val = !!val;
560 } else {
561 return -EINVAL;
562 }
563
564 index = (index < 4) ? 0 : 1;
565 mutex_lock(&data->update_lock);
566 data->temp_mode[index] =
567 w83793_read_value(client, W83793_REG_TEMP_MODE[index]);
568 data->temp_mode[index] &= ~(mask << shift);
569 data->temp_mode[index] |= val << shift;
570 w83793_write_value(client, W83793_REG_TEMP_MODE[index],
571 data->temp_mode[index]);
572 mutex_unlock(&data->update_lock);
573
574 return count;
575}
576
577#define SETUP_PWM_DEFAULT 0
578#define SETUP_PWM_UPTIME 1 /* Unit in 0.1s */
579#define SETUP_PWM_DOWNTIME 2 /* Unit in 0.1s */
580#define SETUP_TEMP_CRITICAL 3
581static ssize_t
582show_sf_setup(struct device *dev, struct device_attribute *attr, char *buf)
583{
584 struct sensor_device_attribute_2 *sensor_attr =
585 to_sensor_dev_attr_2(attr);
586 int nr = sensor_attr->nr;
587 struct w83793_data *data = w83793_update_device(dev);
588 u32 val = 0;
589
590 if (SETUP_PWM_DEFAULT == nr) {
591 val = (data->pwm_default & 0x3f) << 2;
592 } else if (SETUP_PWM_UPTIME == nr) {
593 val = TIME_FROM_REG(data->pwm_uptime);
594 } else if (SETUP_PWM_DOWNTIME == nr) {
595 val = TIME_FROM_REG(data->pwm_downtime);
596 } else if (SETUP_TEMP_CRITICAL == nr) {
597 val = TEMP_FROM_REG(data->temp_critical & 0x7f);
598 }
599
600 return sprintf(buf, "%d\n", val);
601}
602
603static ssize_t
604store_sf_setup(struct device *dev, struct device_attribute *attr,
605 const char *buf, size_t count)
606{
607 struct sensor_device_attribute_2 *sensor_attr =
608 to_sensor_dev_attr_2(attr);
609 int nr = sensor_attr->nr;
610 struct i2c_client *client = to_i2c_client(dev);
611 struct w83793_data *data = i2c_get_clientdata(client);
612
613 mutex_lock(&data->update_lock);
614 if (SETUP_PWM_DEFAULT == nr) {
615 data->pwm_default =
616 w83793_read_value(client, W83793_REG_PWM_DEFAULT) & 0xc0;
617 data->pwm_default |= SENSORS_LIMIT(simple_strtoul(buf, NULL,
618 10),
619 0, 0xff) >> 2;
620 w83793_write_value(client, W83793_REG_PWM_DEFAULT,
621 data->pwm_default);
622 } else if (SETUP_PWM_UPTIME == nr) {
623 data->pwm_uptime = TIME_TO_REG(simple_strtoul(buf, NULL, 10));
624 data->pwm_uptime += data->pwm_uptime == 0 ? 1 : 0;
625 w83793_write_value(client, W83793_REG_PWM_UPTIME,
626 data->pwm_uptime);
627 } else if (SETUP_PWM_DOWNTIME == nr) {
628 data->pwm_downtime = TIME_TO_REG(simple_strtoul(buf, NULL, 10));
629 data->pwm_downtime += data->pwm_downtime == 0 ? 1 : 0;
630 w83793_write_value(client, W83793_REG_PWM_DOWNTIME,
631 data->pwm_downtime);
632 } else { /* SETUP_TEMP_CRITICAL */
633 data->temp_critical =
634 w83793_read_value(client, W83793_REG_TEMP_CRITICAL) & 0x80;
635 data->temp_critical |= TEMP_TO_REG(simple_strtol(buf, NULL, 10),
636 0, 0x7f);
637 w83793_write_value(client, W83793_REG_TEMP_CRITICAL,
638 data->temp_critical);
639 }
640
641 mutex_unlock(&data->update_lock);
642 return count;
643}
644
645/*
646 Temp SmartFan control
647 TEMP_FAN_MAP
648 Temp channel control which pwm fan, bitfield, bit 0 indicate pwm1...
649 It's possible two or more temp channels control the same fan, w83793
650 always prefers to pick the most critical request and applies it to
651 the related Fan.
652 It's possible one fan is not in any mapping of 6 temp channels, this
653 means the fan is manual mode
654
655 TEMP_PWM_ENABLE
656 Each temp channel has its own SmartFan mode, and temp channel
657 control fans that are set by TEMP_FAN_MAP
658 0: SmartFanII mode
659 1: Thermal Cruise Mode
660
661 TEMP_CRUISE
662 Target temperature in thermal cruise mode, w83793 will try to turn
663 fan speed to keep the temperature of target device around this
664 temperature.
665
666 TEMP_TOLERANCE
667 If Temp higher or lower than target with this tolerance, w83793
668 will take actions to speed up or slow down the fan to keep the
669 temperature within the tolerance range.
670*/
671
672#define TEMP_FAN_MAP 0
673#define TEMP_PWM_ENABLE 1
674#define TEMP_CRUISE 2
675#define TEMP_TOLERANCE 3
676static ssize_t
677show_sf_ctrl(struct device *dev, struct device_attribute *attr, char *buf)
678{
679 struct sensor_device_attribute_2 *sensor_attr =
680 to_sensor_dev_attr_2(attr);
681 int nr = sensor_attr->nr;
682 int index = sensor_attr->index;
683 struct w83793_data *data = w83793_update_device(dev);
684 u32 val;
685
686 if (TEMP_FAN_MAP == nr) {
687 val = data->temp_fan_map[index];
688 } else if (TEMP_PWM_ENABLE == nr) {
689 /* +2 to transfrom into 2 and 3 to conform with sysfs intf */
690 val = ((data->pwm_enable >> index) & 0x01) + 2;
691 } else if (TEMP_CRUISE == nr) {
692 val = TEMP_FROM_REG(data->temp_cruise[index] & 0x7f);
693 } else { /* TEMP_TOLERANCE */
694 val = data->tolerance[index >> 1] >> ((index & 0x01) ? 4 : 0);
695 val = TEMP_FROM_REG(val & 0x0f);
696 }
697 return sprintf(buf, "%d\n", val);
698}
699
700static ssize_t
701store_sf_ctrl(struct device *dev, struct device_attribute *attr,
702 const char *buf, size_t count)
703{
704 struct sensor_device_attribute_2 *sensor_attr =
705 to_sensor_dev_attr_2(attr);
706 int nr = sensor_attr->nr;
707 int index = sensor_attr->index;
708 struct i2c_client *client = to_i2c_client(dev);
709 struct w83793_data *data = i2c_get_clientdata(client);
710 u32 val;
711
712 mutex_lock(&data->update_lock);
713 if (TEMP_FAN_MAP == nr) {
714 val = simple_strtoul(buf, NULL, 10) & 0xff;
715 w83793_write_value(client, W83793_REG_TEMP_FAN_MAP(index), val);
716 data->temp_fan_map[index] = val;
717 } else if (TEMP_PWM_ENABLE == nr) {
718 val = simple_strtoul(buf, NULL, 10);
719 if (2 == val || 3 == val) {
720 data->pwm_enable =
721 w83793_read_value(client, W83793_REG_PWM_ENABLE);
722 if (val - 2)
723 data->pwm_enable |= 1 << index;
724 else
725 data->pwm_enable &= ~(1 << index);
726 w83793_write_value(client, W83793_REG_PWM_ENABLE,
727 data->pwm_enable);
728 } else {
729 mutex_unlock(&data->update_lock);
730 return -EINVAL;
731 }
732 } else if (TEMP_CRUISE == nr) {
733 data->temp_cruise[index] =
734 w83793_read_value(client, W83793_REG_TEMP_CRUISE(index));
735 val = TEMP_TO_REG(simple_strtol(buf, NULL, 10), 0, 0x7f);
736 data->temp_cruise[index] &= 0x80;
737 data->temp_cruise[index] |= val;
738
739 w83793_write_value(client, W83793_REG_TEMP_CRUISE(index),
740 data->temp_cruise[index]);
741 } else { /* TEMP_TOLERANCE */
742 int i = index >> 1;
743 u8 shift = (index & 0x01) ? 4 : 0;
744 data->tolerance[i] =
745 w83793_read_value(client, W83793_REG_TEMP_TOL(i));
746
747 val = TEMP_TO_REG(simple_strtol(buf, NULL, 10), 0, 0x0f);
748 data->tolerance[i] &= ~(0x0f << shift);
749 data->tolerance[i] |= val << shift;
750 w83793_write_value(client, W83793_REG_TEMP_TOL(i),
751 data->tolerance[i]);
752 }
753
754 mutex_unlock(&data->update_lock);
755 return count;
756}
757
758static ssize_t
759show_sf2_pwm(struct device *dev, struct device_attribute *attr, char *buf)
760{
761 struct sensor_device_attribute_2 *sensor_attr =
762 to_sensor_dev_attr_2(attr);
763 int nr = sensor_attr->nr;
764 int index = sensor_attr->index;
765 struct w83793_data *data = w83793_update_device(dev);
766
767 return sprintf(buf, "%d\n", (data->sf2_pwm[index][nr] & 0x3f) << 2);
768}
769
770static ssize_t
771store_sf2_pwm(struct device *dev, struct device_attribute *attr,
772 const char *buf, size_t count)
773{
774 struct i2c_client *client = to_i2c_client(dev);
775 struct w83793_data *data = i2c_get_clientdata(client);
776 struct sensor_device_attribute_2 *sensor_attr =
777 to_sensor_dev_attr_2(attr);
778 int nr = sensor_attr->nr;
779 int index = sensor_attr->index;
780 u8 val = SENSORS_LIMIT(simple_strtoul(buf, NULL, 10), 0, 0xff) >> 2;
781
782 mutex_lock(&data->update_lock);
783 data->sf2_pwm[index][nr] =
784 w83793_read_value(client, W83793_REG_SF2_PWM(index, nr)) & 0xc0;
785 data->sf2_pwm[index][nr] |= val;
786 w83793_write_value(client, W83793_REG_SF2_PWM(index, nr),
787 data->sf2_pwm[index][nr]);
788 mutex_unlock(&data->update_lock);
789 return count;
790}
791
792static ssize_t
793show_sf2_temp(struct device *dev, struct device_attribute *attr, char *buf)
794{
795 struct sensor_device_attribute_2 *sensor_attr =
796 to_sensor_dev_attr_2(attr);
797 int nr = sensor_attr->nr;
798 int index = sensor_attr->index;
799 struct w83793_data *data = w83793_update_device(dev);
800
801 return sprintf(buf, "%ld\n",
802 TEMP_FROM_REG(data->sf2_temp[index][nr] & 0x7f));
803}
804
805static ssize_t
806store_sf2_temp(struct device *dev, struct device_attribute *attr,
807 const char *buf, size_t count)
808{
809 struct i2c_client *client = to_i2c_client(dev);
810 struct w83793_data *data = i2c_get_clientdata(client);
811 struct sensor_device_attribute_2 *sensor_attr =
812 to_sensor_dev_attr_2(attr);
813 int nr = sensor_attr->nr;
814 int index = sensor_attr->index;
815 u8 val = TEMP_TO_REG(simple_strtol(buf, NULL, 10), 0, 0x7f);
816
817 mutex_lock(&data->update_lock);
818 data->sf2_temp[index][nr] =
819 w83793_read_value(client, W83793_REG_SF2_TEMP(index, nr)) & 0x80;
820 data->sf2_temp[index][nr] |= val;
821 w83793_write_value(client, W83793_REG_SF2_TEMP(index, nr),
822 data->sf2_temp[index][nr]);
823 mutex_unlock(&data->update_lock);
824 return count;
825}
826
827/* only Vcore A/B and Vtt have additional 2 bits precision */
828static ssize_t
829show_in(struct device *dev, struct device_attribute *attr, char *buf)
830{
831 struct sensor_device_attribute_2 *sensor_attr =
832 to_sensor_dev_attr_2(attr);
833 int nr = sensor_attr->nr;
834 int index = sensor_attr->index;
835 struct w83793_data *data = w83793_update_device(dev);
836 u16 val = data->in[index][nr];
837
838 if (index < 3) {
839 val <<= 2;
840 val += (data->in_low_bits[nr] >> (index * 2)) & 0x3;
841 }
842 return sprintf(buf, "%d\n", val * scale_in[index]);
843}
844
845static ssize_t
846store_in(struct device *dev, struct device_attribute *attr,
847 const char *buf, size_t count)
848{
849 struct sensor_device_attribute_2 *sensor_attr =
850 to_sensor_dev_attr_2(attr);
851 int nr = sensor_attr->nr;
852 int index = sensor_attr->index;
853 struct i2c_client *client = to_i2c_client(dev);
854 struct w83793_data *data = i2c_get_clientdata(client);
855 u32 val;
856
857 val =
858 (simple_strtoul(buf, NULL, 10) +
859 scale_in[index] / 2) / scale_in[index];
860 mutex_lock(&data->update_lock);
861 if (index > 2) {
862 val = SENSORS_LIMIT(val, 0, 255);
863 } else {
864 val = SENSORS_LIMIT(val, 0, 0x3FF);
865 data->in_low_bits[nr] =
866 w83793_read_value(client, W83793_REG_IN_LOW_BITS[nr]);
867 data->in_low_bits[nr] &= ~(0x03 << (2 * index));
868 data->in_low_bits[nr] |= (val & 0x03) << (2 * index);
869 w83793_write_value(client, W83793_REG_IN_LOW_BITS[nr],
870 data->in_low_bits[nr]);
871 val >>= 2;
872 }
873 data->in[index][nr] = val;
874 w83793_write_value(client, W83793_REG_IN[index][nr],
875 data->in[index][nr]);
876 mutex_unlock(&data->update_lock);
877 return count;
878}
879
880#define NOT_USED -1
881
882#define SENSOR_ATTR_IN(index) \
883 SENSOR_ATTR_2(in##index##_input, S_IRUGO, show_in, NULL, \
884 IN_READ, index), \
885 SENSOR_ATTR_2(in##index##_max, S_IRUGO | S_IWUSR, show_in, \
886 store_in, IN_MAX, index), \
887 SENSOR_ATTR_2(in##index##_min, S_IRUGO | S_IWUSR, show_in, \
888 store_in, IN_LOW, index), \
889 SENSOR_ATTR_2(in##index##_alarm, S_IRUGO, show_alarm_beep, \
890 NULL, ALARM_STATUS, index + ((index > 2) ? 1 : 0)), \
891 SENSOR_ATTR_2(in##index##_beep, S_IWUSR | S_IRUGO, \
892 show_alarm_beep, store_beep, BEEP_ENABLE, \
893 index + ((index > 2) ? 1 : 0))
894
895#define SENSOR_ATTR_FAN(index) \
896 SENSOR_ATTR_2(fan##index##_alarm, S_IRUGO, show_alarm_beep, \
897 NULL, ALARM_STATUS, index + 17), \
898 SENSOR_ATTR_2(fan##index##_beep, S_IWUSR | S_IRUGO, \
899 show_alarm_beep, store_beep, BEEP_ENABLE, index + 17), \
900 SENSOR_ATTR_2(fan##index##_input, S_IRUGO, show_fan, \
901 NULL, FAN_INPUT, index - 1), \
902 SENSOR_ATTR_2(fan##index##_min, S_IWUSR | S_IRUGO, \
903 show_fan, store_fan_min, FAN_MIN, index - 1)
904
905#define SENSOR_ATTR_PWM(index) \
906 SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm, \
907 store_pwm, PWM_DUTY, index - 1), \
908 SENSOR_ATTR_2(pwm##index##_nonstop, S_IWUSR | S_IRUGO, \
909 show_pwm, store_pwm, PWM_NONSTOP, index - 1), \
910 SENSOR_ATTR_2(pwm##index##_start, S_IWUSR | S_IRUGO, \
911 show_pwm, store_pwm, PWM_START, index - 1), \
912 SENSOR_ATTR_2(pwm##index##_stop_time, S_IWUSR | S_IRUGO, \
913 show_pwm, store_pwm, PWM_STOP_TIME, index - 1)
914
915#define SENSOR_ATTR_TEMP(index) \
916 SENSOR_ATTR_2(temp##index##_type, S_IRUGO | S_IWUSR, \
917 show_temp_mode, store_temp_mode, NOT_USED, index - 1), \
918 SENSOR_ATTR_2(temp##index##_input, S_IRUGO, show_temp, \
919 NULL, TEMP_READ, index - 1), \
920 SENSOR_ATTR_2(temp##index##_max, S_IRUGO | S_IWUSR, show_temp, \
921 store_temp, TEMP_CRIT, index - 1), \
922 SENSOR_ATTR_2(temp##index##_max_hyst, S_IRUGO | S_IWUSR, \
923 show_temp, store_temp, TEMP_CRIT_HYST, index - 1), \
924 SENSOR_ATTR_2(temp##index##_warn, S_IRUGO | S_IWUSR, show_temp, \
925 store_temp, TEMP_WARN, index - 1), \
926 SENSOR_ATTR_2(temp##index##_warn_hyst, S_IRUGO | S_IWUSR, \
927 show_temp, store_temp, TEMP_WARN_HYST, index - 1), \
928 SENSOR_ATTR_2(temp##index##_alarm, S_IRUGO, \
929 show_alarm_beep, NULL, ALARM_STATUS, index + 11), \
930 SENSOR_ATTR_2(temp##index##_beep, S_IWUSR | S_IRUGO, \
931 show_alarm_beep, store_beep, BEEP_ENABLE, index + 11), \
932 SENSOR_ATTR_2(temp##index##_auto_channels_pwm, \
933 S_IRUGO | S_IWUSR, show_sf_ctrl, store_sf_ctrl, \
934 TEMP_FAN_MAP, index - 1), \
935 SENSOR_ATTR_2(temp##index##_pwm_enable, S_IWUSR | S_IRUGO, \
936 show_sf_ctrl, store_sf_ctrl, TEMP_PWM_ENABLE, \
937 index - 1), \
938 SENSOR_ATTR_2(thermal_cruise##index, S_IRUGO | S_IWUSR, \
939 show_sf_ctrl, store_sf_ctrl, TEMP_CRUISE, index - 1), \
940 SENSOR_ATTR_2(tolerance##index, S_IRUGO | S_IWUSR, show_sf_ctrl,\
941 store_sf_ctrl, TEMP_TOLERANCE, index - 1), \
942 SENSOR_ATTR_2(temp##index##_auto_point1_pwm, S_IRUGO | S_IWUSR, \
943 show_sf2_pwm, store_sf2_pwm, 0, index - 1), \
944 SENSOR_ATTR_2(temp##index##_auto_point2_pwm, S_IRUGO | S_IWUSR, \
945 show_sf2_pwm, store_sf2_pwm, 1, index - 1), \
946 SENSOR_ATTR_2(temp##index##_auto_point3_pwm, S_IRUGO | S_IWUSR, \
947 show_sf2_pwm, store_sf2_pwm, 2, index - 1), \
948 SENSOR_ATTR_2(temp##index##_auto_point4_pwm, S_IRUGO | S_IWUSR, \
949 show_sf2_pwm, store_sf2_pwm, 3, index - 1), \
950 SENSOR_ATTR_2(temp##index##_auto_point5_pwm, S_IRUGO | S_IWUSR, \
951 show_sf2_pwm, store_sf2_pwm, 4, index - 1), \
952 SENSOR_ATTR_2(temp##index##_auto_point6_pwm, S_IRUGO | S_IWUSR, \
953 show_sf2_pwm, store_sf2_pwm, 5, index - 1), \
954 SENSOR_ATTR_2(temp##index##_auto_point7_pwm, S_IRUGO | S_IWUSR, \
955 show_sf2_pwm, store_sf2_pwm, 6, index - 1), \
956 SENSOR_ATTR_2(temp##index##_auto_point1_temp, S_IRUGO | S_IWUSR,\
957 show_sf2_temp, store_sf2_temp, 0, index - 1), \
958 SENSOR_ATTR_2(temp##index##_auto_point2_temp, S_IRUGO | S_IWUSR,\
959 show_sf2_temp, store_sf2_temp, 1, index - 1), \
960 SENSOR_ATTR_2(temp##index##_auto_point3_temp, S_IRUGO | S_IWUSR,\
961 show_sf2_temp, store_sf2_temp, 2, index - 1), \
962 SENSOR_ATTR_2(temp##index##_auto_point4_temp, S_IRUGO | S_IWUSR,\
963 show_sf2_temp, store_sf2_temp, 3, index - 1), \
964 SENSOR_ATTR_2(temp##index##_auto_point5_temp, S_IRUGO | S_IWUSR,\
965 show_sf2_temp, store_sf2_temp, 4, index - 1), \
966 SENSOR_ATTR_2(temp##index##_auto_point6_temp, S_IRUGO | S_IWUSR,\
967 show_sf2_temp, store_sf2_temp, 5, index - 1), \
968 SENSOR_ATTR_2(temp##index##_auto_point7_temp, S_IRUGO | S_IWUSR,\
969 show_sf2_temp, store_sf2_temp, 6, index - 1)
970
971static struct sensor_device_attribute_2 w83793_sensor_attr_2[] = {
972 SENSOR_ATTR_IN(0),
973 SENSOR_ATTR_IN(1),
974 SENSOR_ATTR_IN(2),
975 SENSOR_ATTR_IN(3),
976 SENSOR_ATTR_IN(4),
977 SENSOR_ATTR_IN(5),
978 SENSOR_ATTR_IN(6),
979 SENSOR_ATTR_IN(7),
980 SENSOR_ATTR_IN(8),
981 SENSOR_ATTR_IN(9),
982 SENSOR_ATTR_TEMP(1),
983 SENSOR_ATTR_TEMP(2),
984 SENSOR_ATTR_TEMP(3),
985 SENSOR_ATTR_TEMP(4),
986 SENSOR_ATTR_TEMP(5),
987 SENSOR_ATTR_TEMP(6),
988 SENSOR_ATTR_FAN(1),
989 SENSOR_ATTR_FAN(2),
990 SENSOR_ATTR_FAN(3),
991 SENSOR_ATTR_FAN(4),
992 SENSOR_ATTR_FAN(5),
993 SENSOR_ATTR_PWM(1),
994 SENSOR_ATTR_PWM(2),
995 SENSOR_ATTR_PWM(3),
996};
997
998/* Fan6-Fan12 */
999static struct sensor_device_attribute_2 w83793_left_fan[] = {
1000 SENSOR_ATTR_FAN(6),
1001 SENSOR_ATTR_FAN(7),
1002 SENSOR_ATTR_FAN(8),
1003 SENSOR_ATTR_FAN(9),
1004 SENSOR_ATTR_FAN(10),
1005 SENSOR_ATTR_FAN(11),
1006 SENSOR_ATTR_FAN(12),
1007};
1008
1009/* Pwm4-Pwm8 */
1010static struct sensor_device_attribute_2 w83793_left_pwm[] = {
1011 SENSOR_ATTR_PWM(4),
1012 SENSOR_ATTR_PWM(5),
1013 SENSOR_ATTR_PWM(6),
1014 SENSOR_ATTR_PWM(7),
1015 SENSOR_ATTR_PWM(8),
1016};
1017
1018static struct sensor_device_attribute_2 sda_single_files[] = {
1019 SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0),
1020 SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1),
1021 SENSOR_ATTR_2(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm,
1022 NOT_USED, NOT_USED),
1023 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep,
1024 store_chassis_clear, ALARM_STATUS, 30),
1025 SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable,
1026 store_beep_enable, NOT_USED, NOT_USED),
1027 SENSOR_ATTR_2(pwm_default, S_IWUSR | S_IRUGO, show_sf_setup,
1028 store_sf_setup, SETUP_PWM_DEFAULT, NOT_USED),
1029 SENSOR_ATTR_2(pwm_uptime, S_IWUSR | S_IRUGO, show_sf_setup,
1030 store_sf_setup, SETUP_PWM_UPTIME, NOT_USED),
1031 SENSOR_ATTR_2(pwm_downtime, S_IWUSR | S_IRUGO, show_sf_setup,
1032 store_sf_setup, SETUP_PWM_DOWNTIME, NOT_USED),
1033 SENSOR_ATTR_2(temp_critical, S_IWUSR | S_IRUGO, show_sf_setup,
1034 store_sf_setup, SETUP_TEMP_CRITICAL, NOT_USED),
1035};
1036
1037static void w83793_init_client(struct i2c_client *client)
1038{
1039 if (reset) {
1040 w83793_write_value(client, W83793_REG_CONFIG, 0x80);
1041 }
1042
1043 /* Start monitoring */
1044 w83793_write_value(client, W83793_REG_CONFIG,
1045 w83793_read_value(client, W83793_REG_CONFIG) | 0x01);
1046
1047}
1048
1049static int w83793_attach_adapter(struct i2c_adapter *adapter)
1050{
1051 if (!(adapter->class & I2C_CLASS_HWMON))
1052 return 0;
1053 return i2c_probe(adapter, &addr_data, w83793_detect);
1054}
1055
1056static int w83793_detach_client(struct i2c_client *client)
1057{
1058 struct w83793_data *data = i2c_get_clientdata(client);
1059 struct device *dev = &client->dev;
1060 int err, i;
1061
1062 /* main client */
1063 if (data) {
1064 hwmon_device_unregister(data->class_dev);
1065
1066 for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++)
1067 device_remove_file(dev,
1068 &w83793_sensor_attr_2[i].dev_attr);
1069
1070 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++)
1071 device_remove_file(dev, &sda_single_files[i].dev_attr);
1072
1073 for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++)
1074 device_remove_file(dev, &w83793_left_fan[i].dev_attr);
1075
1076 for (i = 0; i < ARRAY_SIZE(w83793_left_pwm); i++)
1077 device_remove_file(dev, &w83793_left_pwm[i].dev_attr);
1078 }
1079
1080 if ((err = i2c_detach_client(client)))
1081 return err;
1082
1083 /* main client */
1084 if (data)
1085 kfree(data);
1086 /* subclient */
1087 else
1088 kfree(client);
1089
1090 return 0;
1091}
1092
1093static int
1094w83793_create_subclient(struct i2c_adapter *adapter,
1095 struct i2c_client *client, int addr,
1096 struct i2c_client **sub_cli)
1097{
1098 int err = 0;
1099 struct i2c_client *sub_client;
1100
1101 (*sub_cli) = sub_client =
1102 kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
1103 if (!(sub_client)) {
1104 return -ENOMEM;
1105 }
1106 sub_client->addr = 0x48 + addr;
1107 i2c_set_clientdata(sub_client, NULL);
1108 sub_client->adapter = adapter;
1109 sub_client->driver = &w83793_driver;
1110 strlcpy(sub_client->name, "w83793 subclient", I2C_NAME_SIZE);
1111 if ((err = i2c_attach_client(sub_client))) {
1112 dev_err(&client->dev, "subclient registration "
1113 "at address 0x%x failed\n", sub_client->addr);
1114 kfree(sub_client);
1115 }
1116 return err;
1117}
1118
1119static int
1120w83793_detect_subclients(struct i2c_adapter *adapter, int address,
1121 int kind, struct i2c_client *client)
1122{
1123 int i, id, err;
1124 u8 tmp;
1125 struct w83793_data *data = i2c_get_clientdata(client);
1126
1127 id = i2c_adapter_id(adapter);
1128 if (force_subclients[0] == id && force_subclients[1] == address) {
1129 for (i = 2; i <= 3; i++) {
1130 if (force_subclients[i] < 0x48
1131 || force_subclients[i] > 0x4f) {
1132 dev_err(&client->dev,
1133 "invalid subclient "
1134 "address %d; must be 0x48-0x4f\n",
1135 force_subclients[i]);
1136 err = -EINVAL;
1137 goto ERROR_SC_0;
1138 }
1139 }
1140 w83793_write_value(client, W83793_REG_I2C_SUBADDR,
1141 (force_subclients[2] & 0x07) |
1142 ((force_subclients[3] & 0x07) << 4));
1143 }
1144
1145 tmp = w83793_read_value(client, W83793_REG_I2C_SUBADDR);
1146 if (!(tmp & 0x08)) {
1147 err =
1148 w83793_create_subclient(adapter, client, tmp & 0x7,
1149 &data->lm75[0]);
1150 if (err < 0)
1151 goto ERROR_SC_0;
1152 }
1153 if (!(tmp & 0x80)) {
1154 if ((data->lm75[0] != NULL)
1155 && ((tmp & 0x7) == ((tmp >> 4) & 0x7))) {
1156 dev_err(&client->dev,
1157 "duplicate addresses 0x%x, "
1158 "use force_subclients\n", data->lm75[0]->addr);
1159 err = -ENODEV;
1160 goto ERROR_SC_1;
1161 }
1162 err = w83793_create_subclient(adapter, client,
1163 (tmp >> 4) & 0x7, &data->lm75[1]);
1164 if (err < 0)
1165 goto ERROR_SC_1;
1166 }
1167
1168 return 0;
1169
1170 /* Undo inits in case of errors */
1171
1172ERROR_SC_1:
1173 if (data->lm75[0] != NULL) {
1174 i2c_detach_client(data->lm75[0]);
1175 kfree(data->lm75[0]);
1176 }
1177ERROR_SC_0:
1178 return err;
1179}
1180
1181static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1182{
1183 int i;
1184 u8 tmp, val;
1185 struct i2c_client *client;
1186 struct device *dev;
1187 struct w83793_data *data;
1188 int files_fan = ARRAY_SIZE(w83793_left_fan) / 7;
1189 int files_pwm = ARRAY_SIZE(w83793_left_pwm) / 5;
1190 int err = 0;
1191
1192 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
1193 goto exit;
1194 }
1195
1196 /* OK. For now, we presume we have a valid client. We now create the
1197 client structure, even though we cannot fill it completely yet.
1198 But it allows us to access w83793_{read,write}_value. */
1199
1200 if (!(data = kzalloc(sizeof(struct w83793_data), GFP_KERNEL))) {
1201 err = -ENOMEM;
1202 goto exit;
1203 }
1204
1205 client = &data->client;
1206 dev = &client->dev;
1207 i2c_set_clientdata(client, data);
1208 client->addr = address;
1209 client->adapter = adapter;
1210 client->driver = &w83793_driver;
1211
1212 data->bank = i2c_smbus_read_byte_data(client, W83793_REG_BANKSEL);
1213
1214 /* Now, we do the remaining detection. */
1215 if (kind < 0) {
1216 tmp = data->bank & 0x80 ? 0x5c : 0xa3;
1217 /* Check Winbond vendor ID */
1218 if (tmp != i2c_smbus_read_byte_data(client,
1219 W83793_REG_VENDORID)) {
1220 pr_debug("w83793: Detection failed at check "
1221 "vendor id\n");
1222 err = -ENODEV;
1223 goto free_mem;
1224 }
1225
1226 /* If Winbond chip, address of chip and W83793_REG_I2C_ADDR
1227 should match */
1228 if ((data->bank & 0x07) == 0
1229 && i2c_smbus_read_byte_data(client, W83793_REG_I2C_ADDR) !=
1230 (address << 1)) {
1231 pr_debug("w83793: Detection failed at check "
1232 "i2c addr\n");
1233 err = -ENODEV;
1234 goto free_mem;
1235 }
1236
1237 }
1238
1239 /* We have either had a force parameter, or we have already detected the
1240 Winbond. Determine the chip type now */
1241
1242 if (kind <= 0) {
1243 if (0x7b == w83793_read_value(client, W83793_REG_CHIPID)) {
1244 kind = w83793;
1245 } else {
1246 if (kind == 0)
1247 dev_warn(&adapter->dev, "w83793: Ignoring "
1248 "'force' parameter for unknown chip "
1249 "at address 0x%02x\n", address);
1250 err = -ENODEV;
1251 goto free_mem;
1252 }
1253 }
1254
1255 /* Fill in the remaining client fields and put into the global list */
1256 strlcpy(client->name, "w83793", I2C_NAME_SIZE);
1257
1258 mutex_init(&data->update_lock);
1259
1260 /* Tell the I2C layer a new client has arrived */
1261 if ((err = i2c_attach_client(client)))
1262 goto free_mem;
1263
1264 if ((err = w83793_detect_subclients(adapter, address, kind, client)))
1265 goto detach_client;
1266
1267 /* Initialize the chip */
1268 w83793_init_client(client);
1269
1270 data->vrm = vid_which_vrm();
1271 /*
1272 Only fan 1-5 has their own input pins,
1273 Pwm 1-3 has their own pins
1274 */
1275 data->has_fan = 0x1f;
1276 data->has_pwm = 0x07;
1277 tmp = w83793_read_value(client, W83793_REG_MFC);
1278 val = w83793_read_value(client, W83793_REG_FANIN_CTRL);
1279
1280 /* check the function of pins 49-56 */
1281 if (!(tmp & 0x80)) {
1282 data->has_pwm |= 0x18; /* pwm 4,5 */
1283 if (val & 0x01) { /* fan 6 */
1284 data->has_fan |= 0x20;
1285 data->has_pwm |= 0x20;
1286 }
1287 if (val & 0x02) { /* fan 7 */
1288 data->has_fan |= 0x40;
1289 data->has_pwm |= 0x40;
1290 }
1291 if (!(tmp & 0x40) && (val & 0x04)) { /* fan 8 */
1292 data->has_fan |= 0x80;
1293 data->has_pwm |= 0x80;
1294 }
1295 }
1296
1297 if (0x08 == (tmp & 0x0c)) {
1298 if (val & 0x08) /* fan 9 */
1299 data->has_fan |= 0x100;
1300 if (val & 0x10) /* fan 10 */
1301 data->has_fan |= 0x200;
1302 }
1303
1304 if (0x20 == (tmp & 0x30)) {
1305 if (val & 0x20) /* fan 11 */
1306 data->has_fan |= 0x400;
1307 if (val & 0x40) /* fan 12 */
1308 data->has_fan |= 0x800;
1309 }
1310
1311 if ((tmp & 0x01) && (val & 0x04)) { /* fan 8, second location */
1312 data->has_fan |= 0x80;
1313 data->has_pwm |= 0x80;
1314 }
1315
1316 /* Register sysfs hooks */
1317 for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) {
1318 err = device_create_file(dev,
1319 &w83793_sensor_attr_2[i].dev_attr);
1320 if (err)
1321 goto exit_remove;
1322 }
1323
1324 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) {
1325 err = device_create_file(dev, &sda_single_files[i].dev_attr);
1326 if (err)
1327 goto exit_remove;
1328
1329 }
1330
1331 for (i = 5; i < 12; i++) {
1332 int j;
1333 if (!(data->has_fan & (1 << i)))
1334 continue;
1335 for (j = 0; j < files_fan; j++) {
1336 err = device_create_file(dev,
1337 &w83793_left_fan[(i - 5) * files_fan
1338 + j].dev_attr);
1339 if (err)
1340 goto exit_remove;
1341 }
1342 }
1343
1344 for (i = 3; i < 8; i++) {
1345 int j;
1346 if (!(data->has_pwm & (1 << i)))
1347 continue;
1348 for (j = 0; j < files_pwm; j++) {
1349 err = device_create_file(dev,
1350 &w83793_left_pwm[(i - 3) * files_pwm
1351 + j].dev_attr);
1352 if (err)
1353 goto exit_remove;
1354 }
1355 }
1356
1357 data->class_dev = hwmon_device_register(dev);
1358 if (IS_ERR(data->class_dev)) {
1359 err = PTR_ERR(data->class_dev);
1360 goto exit_remove;
1361 }
1362
1363 return 0;
1364
1365 /* Unregister sysfs hooks */
1366
1367exit_remove:
1368 for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++)
1369 device_remove_file(dev, &w83793_sensor_attr_2[i].dev_attr);
1370
1371 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++)
1372 device_remove_file(dev, &sda_single_files[i].dev_attr);
1373
1374 for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++)
1375 device_remove_file(dev, &w83793_left_fan[i].dev_attr);
1376
1377 for (i = 0; i < ARRAY_SIZE(w83793_left_pwm); i++)
1378 device_remove_file(dev, &w83793_left_pwm[i].dev_attr);
1379
1380 if (data->lm75[0] != NULL) {
1381 i2c_detach_client(data->lm75[0]);
1382 kfree(data->lm75[0]);
1383 }
1384 if (data->lm75[1] != NULL) {
1385 i2c_detach_client(data->lm75[1]);
1386 kfree(data->lm75[1]);
1387 }
1388detach_client:
1389 i2c_detach_client(client);
1390free_mem:
1391 kfree(data);
1392exit:
1393 return err;
1394}
1395
1396static void w83793_update_nonvolatile(struct device *dev)
1397{
1398 struct i2c_client *client = to_i2c_client(dev);
1399 struct w83793_data *data = i2c_get_clientdata(client);
1400 int i, j;
1401 /*
1402 They are somewhat "stable" registers, and to update them everytime
1403 takes so much time, it's just not worthy. Update them in a long
1404 interval to avoid exception.
1405 */
1406 if (!(time_after(jiffies, data->last_nonvolatile + HZ * 300)
1407 || !data->valid))
1408 return;
1409 /* update voltage limits */
1410 for (i = 1; i < 3; i++) {
1411 for (j = 0; j < ARRAY_SIZE(data->in); j++) {
1412 data->in[j][i] =
1413 w83793_read_value(client, W83793_REG_IN[j][i]);
1414 }
1415 data->in_low_bits[i] =
1416 w83793_read_value(client, W83793_REG_IN_LOW_BITS[i]);
1417 }
1418
1419 for (i = 0; i < ARRAY_SIZE(data->fan_min); i++) {
1420 /* Update the Fan measured value and limits */
1421 if (!(data->has_fan & (1 << i))) {
1422 continue;
1423 }
1424 data->fan_min[i] =
1425 w83793_read_value(client, W83793_REG_FAN_MIN(i)) << 8;
1426 data->fan_min[i] |=
1427 w83793_read_value(client, W83793_REG_FAN_MIN(i) + 1);
1428 }
1429
1430 for (i = 0; i < ARRAY_SIZE(data->temp_fan_map); i++) {
1431 data->temp_fan_map[i] =
1432 w83793_read_value(client, W83793_REG_TEMP_FAN_MAP(i));
1433 for (j = 1; j < 5; j++) {
1434 data->temp[i][j] =
1435 w83793_read_value(client, W83793_REG_TEMP[i][j]);
1436 }
1437 data->temp_cruise[i] =
1438 w83793_read_value(client, W83793_REG_TEMP_CRUISE(i));
1439 for (j = 0; j < 7; j++) {
1440 data->sf2_pwm[i][j] =
1441 w83793_read_value(client, W83793_REG_SF2_PWM(i, j));
1442 data->sf2_temp[i][j] =
1443 w83793_read_value(client,
1444 W83793_REG_SF2_TEMP(i, j));
1445 }
1446 }
1447
1448 for (i = 0; i < ARRAY_SIZE(data->temp_mode); i++)
1449 data->temp_mode[i] =
1450 w83793_read_value(client, W83793_REG_TEMP_MODE[i]);
1451
1452 for (i = 0; i < ARRAY_SIZE(data->tolerance); i++) {
1453 data->tolerance[i] =
1454 w83793_read_value(client, W83793_REG_TEMP_TOL(i));
1455 }
1456
1457 for (i = 0; i < ARRAY_SIZE(data->pwm); i++) {
1458 if (!(data->has_pwm & (1 << i)))
1459 continue;
1460 data->pwm[i][PWM_NONSTOP] =
1461 w83793_read_value(client, W83793_REG_PWM(i, PWM_NONSTOP));
1462 data->pwm[i][PWM_START] =
1463 w83793_read_value(client, W83793_REG_PWM(i, PWM_START));
1464 data->pwm_stop_time[i] =
1465 w83793_read_value(client, W83793_REG_PWM_STOP_TIME(i));
1466 }
1467
1468 data->pwm_default = w83793_read_value(client, W83793_REG_PWM_DEFAULT);
1469 data->pwm_enable = w83793_read_value(client, W83793_REG_PWM_ENABLE);
1470 data->pwm_uptime = w83793_read_value(client, W83793_REG_PWM_UPTIME);
1471 data->pwm_downtime = w83793_read_value(client, W83793_REG_PWM_DOWNTIME);
1472 data->temp_critical =
1473 w83793_read_value(client, W83793_REG_TEMP_CRITICAL);
1474 data->beep_enable = w83793_read_value(client, W83793_REG_OVT_BEEP);
1475
1476 for (i = 0; i < ARRAY_SIZE(data->beeps); i++) {
1477 data->beeps[i] = w83793_read_value(client, W83793_REG_BEEP(i));
1478 }
1479
1480 data->last_nonvolatile = jiffies;
1481}
1482
1483static struct w83793_data *w83793_update_device(struct device *dev)
1484{
1485 struct i2c_client *client = to_i2c_client(dev);
1486 struct w83793_data *data = i2c_get_clientdata(client);
1487 int i;
1488
1489 mutex_lock(&data->update_lock);
1490
1491 if (!(time_after(jiffies, data->last_updated + HZ * 2)
1492 || !data->valid))
1493 goto END;
1494
1495 /* Update the voltages measured value and limits */
1496 for (i = 0; i < ARRAY_SIZE(data->in); i++)
1497 data->in[i][IN_READ] =
1498 w83793_read_value(client, W83793_REG_IN[i][IN_READ]);
1499
1500 data->in_low_bits[IN_READ] =
1501 w83793_read_value(client, W83793_REG_IN_LOW_BITS[IN_READ]);
1502
1503 for (i = 0; i < ARRAY_SIZE(data->fan); i++) {
1504 if (!(data->has_fan & (1 << i))) {
1505 continue;
1506 }
1507 data->fan[i] =
1508 w83793_read_value(client, W83793_REG_FAN(i)) << 8;
1509 data->fan[i] |=
1510 w83793_read_value(client, W83793_REG_FAN(i) + 1);
1511 }
1512
1513 for (i = 0; i < ARRAY_SIZE(data->temp); i++)
1514 data->temp[i][TEMP_READ] =
1515 w83793_read_value(client, W83793_REG_TEMP[i][TEMP_READ]);
1516
1517 data->temp_low_bits =
1518 w83793_read_value(client, W83793_REG_TEMP_LOW_BITS);
1519
1520 for (i = 0; i < ARRAY_SIZE(data->pwm); i++) {
1521 if (data->has_pwm & (1 << i))
1522 data->pwm[i][PWM_DUTY] =
1523 w83793_read_value(client,
1524 W83793_REG_PWM(i, PWM_DUTY));
1525 }
1526
1527 for (i = 0; i < ARRAY_SIZE(data->alarms); i++)
1528 data->alarms[i] =
1529 w83793_read_value(client, W83793_REG_ALARM(i));
1530 data->vid[0] = w83793_read_value(client, W83793_REG_VID_INA);
1531 data->vid[1] = w83793_read_value(client, W83793_REG_VID_INB);
1532 w83793_update_nonvolatile(dev);
1533 data->last_updated = jiffies;
1534 data->valid = 1;
1535
1536END:
1537 mutex_unlock(&data->update_lock);
1538 return data;
1539}
1540
1541/* Ignore the possibility that somebody change bank outside the driver
1542 Must be called with data->update_lock held, except during initialization */
1543static u8 w83793_read_value(struct i2c_client *client, u16 reg)
1544{
1545 struct w83793_data *data = i2c_get_clientdata(client);
1546 u8 res = 0xff;
1547 u8 new_bank = reg >> 8;
1548
1549 new_bank |= data->bank & 0xfc;
1550 if (data->bank != new_bank) {
1551 if (i2c_smbus_write_byte_data
1552 (client, W83793_REG_BANKSEL, new_bank) >= 0)
1553 data->bank = new_bank;
1554 else {
1555 dev_err(&client->dev,
1556 "set bank to %d failed, fall back "
1557 "to bank %d, read reg 0x%x error\n",
1558 new_bank, data->bank, reg);
1559 res = 0x0; /* read 0x0 from the chip */
1560 goto END;
1561 }
1562 }
1563 res = i2c_smbus_read_byte_data(client, reg & 0xff);
1564END:
1565 return res;
1566}
1567
1568/* Must be called with data->update_lock held, except during initialization */
1569static int w83793_write_value(struct i2c_client *client, u16 reg, u8 value)
1570{
1571 struct w83793_data *data = i2c_get_clientdata(client);
1572 int res;
1573 u8 new_bank = reg >> 8;
1574
1575 new_bank |= data->bank & 0xfc;
1576 if (data->bank != new_bank) {
1577 if ((res = i2c_smbus_write_byte_data
1578 (client, W83793_REG_BANKSEL, new_bank)) >= 0)
1579 data->bank = new_bank;
1580 else {
1581 dev_err(&client->dev,
1582 "set bank to %d failed, fall back "
1583 "to bank %d, write reg 0x%x error\n",
1584 new_bank, data->bank, reg);
1585 goto END;
1586 }
1587 }
1588
1589 res = i2c_smbus_write_byte_data(client, reg & 0xff, value);
1590END:
1591 return res;
1592}
1593
1594static int __init sensors_w83793_init(void)
1595{
1596 return i2c_add_driver(&w83793_driver);
1597}
1598
1599static void __exit sensors_w83793_exit(void)
1600{
1601 i2c_del_driver(&w83793_driver);
1602}
1603
1604MODULE_AUTHOR("Yuan Mu");
1605MODULE_DESCRIPTION("w83793 driver");
1606MODULE_LICENSE("GPL");
1607
1608module_init(sensors_w83793_init);
1609module_exit(sensors_w83793_exit);
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index 33fbb47100a3..8e1e3f8e40a4 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -2,7 +2,7 @@
2 * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge 2 * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge
3 * 3 *
4 * Copyright (C) 2004 Patrick Mochel 4 * Copyright (C) 2004 Patrick Mochel
5 * 2005 Rudolf Marek <r.marek@sh.cvut.cz> 5 * 2005 Rudolf Marek <r.marek@assembler.cz>
6 * 6 *
7 * The 1563 southbridge is deceptively similar to the 1533, with a 7 * The 1563 southbridge is deceptively similar to the 1533, with a
8 * few notable exceptions. One of those happens to be the fact they 8 * few notable exceptions. One of those happens to be the fact they
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index 60bef94cd25f..4ee56def61f2 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -82,7 +82,7 @@ struct tps65010 {
82 struct i2c_client client; 82 struct i2c_client client;
83 struct mutex lock; 83 struct mutex lock;
84 int irq; 84 int irq;
85 struct work_struct work; 85 struct delayed_work work;
86 struct dentry *file; 86 struct dentry *file;
87 unsigned charging:1; 87 unsigned charging:1;
88 unsigned por:1; 88 unsigned por:1;
@@ -328,7 +328,7 @@ static void tps65010_interrupt(struct tps65010 *tps)
328{ 328{
329 u8 tmp = 0, mask, poll; 329 u8 tmp = 0, mask, poll;
330 330
331 /* IRQs won't trigger irqs for certain events, but we can get 331 /* IRQs won't trigger for certain events, but we can get
332 * others by polling (normally, with external power applied). 332 * others by polling (normally, with external power applied).
333 */ 333 */
334 poll = 0; 334 poll = 0;
@@ -411,10 +411,11 @@ static void tps65010_interrupt(struct tps65010 *tps)
411} 411}
412 412
413/* handle IRQs and polling using keventd for now */ 413/* handle IRQs and polling using keventd for now */
414static void tps65010_work(void *_tps) 414static void tps65010_work(struct work_struct *work)
415{ 415{
416 struct tps65010 *tps = _tps; 416 struct tps65010 *tps;
417 417
418 tps = container_of(work, struct tps65010, work.work);
418 mutex_lock(&tps->lock); 419 mutex_lock(&tps->lock);
419 420
420 tps65010_interrupt(tps); 421 tps65010_interrupt(tps);
@@ -452,7 +453,7 @@ static irqreturn_t tps65010_irq(int irq, void *_tps)
452 453
453 disable_irq_nosync(irq); 454 disable_irq_nosync(irq);
454 set_bit(FLAG_IRQ_ENABLE, &tps->flags); 455 set_bit(FLAG_IRQ_ENABLE, &tps->flags);
455 (void) schedule_work(&tps->work); 456 (void) schedule_work(&tps->work.work);
456 return IRQ_HANDLED; 457 return IRQ_HANDLED;
457} 458}
458 459
@@ -465,13 +466,15 @@ static int __exit tps65010_detach_client(struct i2c_client *client)
465 struct tps65010 *tps; 466 struct tps65010 *tps;
466 467
467 tps = container_of(client, struct tps65010, client); 468 tps = container_of(client, struct tps65010, client);
469 free_irq(tps->irq, tps);
468#ifdef CONFIG_ARM 470#ifdef CONFIG_ARM
469 if (machine_is_omap_h2()) 471 if (machine_is_omap_h2())
470 omap_free_gpio(58); 472 omap_free_gpio(58);
471 if (machine_is_omap_osk()) 473 if (machine_is_omap_osk())
472 omap_free_gpio(OMAP_MPUIO(1)); 474 omap_free_gpio(OMAP_MPUIO(1));
473#endif 475#endif
474 free_irq(tps->irq, tps); 476 cancel_delayed_work(&tps->work);
477 flush_scheduled_work();
475 debugfs_remove(tps->file); 478 debugfs_remove(tps->file);
476 if (i2c_detach_client(client) == 0) 479 if (i2c_detach_client(client) == 0)
477 kfree(tps); 480 kfree(tps);
@@ -505,7 +508,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind)
505 return 0; 508 return 0;
506 509
507 mutex_init(&tps->lock); 510 mutex_init(&tps->lock);
508 INIT_WORK(&tps->work, tps65010_work, tps); 511 INIT_DELAYED_WORK(&tps->work, tps65010_work);
509 tps->irq = -1; 512 tps->irq = -1;
510 tps->client.addr = address; 513 tps->client.addr = address;
511 tps->client.adapter = bus; 514 tps->client.adapter = bus;
@@ -620,7 +623,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind)
620 (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f 623 (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f
621 | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); 624 | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3));
622 625
623 tps65010_work(tps); 626 tps65010_work(&tps->work.work);
624 627
625 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, 628 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL,
626 tps, DEBUG_FOPS); 629 tps, DEBUG_FOPS);
@@ -672,7 +675,7 @@ int tps65010_set_vbus_draw(unsigned mA)
672 && test_and_set_bit( 675 && test_and_set_bit(
673 FLAG_VBUS_CHANGED, &the_tps->flags)) { 676 FLAG_VBUS_CHANGED, &the_tps->flags)) {
674 /* gadget drivers call this in_irq() */ 677 /* gadget drivers call this in_irq() */
675 (void) schedule_work(&the_tps->work); 678 (void) schedule_work(&the_tps->work.work);
676 } 679 }
677 local_irq_restore(flags); 680 local_irq_restore(flags);
678 681
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index e3a267622bb6..d33717c8afd4 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -2147,7 +2147,7 @@ static int ide_floppy_probe(ide_drive_t *drive)
2147 printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name); 2147 printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
2148 goto failed; 2148 goto failed;
2149 } 2149 }
2150 if ((floppy = (idefloppy_floppy_t *) kzalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { 2150 if ((floppy = kzalloc(sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
2151 printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); 2151 printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
2152 goto failed; 2152 goto failed;
2153 } 2153 }
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index e2f4bb549063..b3bcd1d7315e 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2573,11 +2573,11 @@ static idetape_stage_t *__idetape_kmalloc_stage (idetape_tape_t *tape, int full,
2573 int pages = tape->pages_per_stage; 2573 int pages = tape->pages_per_stage;
2574 char *b_data = NULL; 2574 char *b_data = NULL;
2575 2575
2576 if ((stage = (idetape_stage_t *) kmalloc (sizeof (idetape_stage_t),GFP_KERNEL)) == NULL) 2576 if ((stage = kmalloc(sizeof (idetape_stage_t),GFP_KERNEL)) == NULL)
2577 return NULL; 2577 return NULL;
2578 stage->next = NULL; 2578 stage->next = NULL;
2579 2579
2580 bh = stage->bh = (struct idetape_bh *)kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); 2580 bh = stage->bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL);
2581 if (bh == NULL) 2581 if (bh == NULL)
2582 goto abort; 2582 goto abort;
2583 bh->b_reqnext = NULL; 2583 bh->b_reqnext = NULL;
@@ -2607,7 +2607,7 @@ static idetape_stage_t *__idetape_kmalloc_stage (idetape_tape_t *tape, int full,
2607 continue; 2607 continue;
2608 } 2608 }
2609 prev_bh = bh; 2609 prev_bh = bh;
2610 if ((bh = (struct idetape_bh *)kmalloc(sizeof(struct idetape_bh), GFP_KERNEL)) == NULL) { 2610 if ((bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL)) == NULL) {
2611 free_page((unsigned long) b_data); 2611 free_page((unsigned long) b_data);
2612 goto abort; 2612 goto abort;
2613 } 2613 }
@@ -4860,7 +4860,7 @@ static int ide_tape_probe(ide_drive_t *drive)
4860 printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name); 4860 printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name);
4861 printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n"); 4861 printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n");
4862 } 4862 }
4863 tape = (idetape_tape_t *) kzalloc (sizeof (idetape_tape_t), GFP_KERNEL); 4863 tape = kzalloc(sizeof (idetape_tape_t), GFP_KERNEL);
4864 if (tape == NULL) { 4864 if (tape == NULL) {
4865 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); 4865 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
4866 goto failed; 4866 goto failed;
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index e993a51f250e..08119da06d54 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -4,6 +4,7 @@
4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
5 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 5 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
6 * Portions Copyright (C) 2003 Red Hat Inc 6 * Portions Copyright (C) 2003 Red Hat Inc
7 * Portions Copyright (C) 2005-2006 MontaVista Software, Inc.
7 * 8 *
8 * Thanks to HighPoint Technologies for their assistance, and hardware. 9 * Thanks to HighPoint Technologies for their assistance, and hardware.
9 * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his 10 * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his
@@ -11,9 +12,11 @@
11 * development and support. 12 * development and support.
12 * 13 *
13 * 14 *
14 * Highpoint have their own driver (source except for the raid part) 15 * HighPoint has its own drivers (open source except for the RAID part)
15 * available from http://www.highpoint-tech.com/hpt3xx-opensource-v131.tgz 16 * available from http://www.highpoint-tech.com/BIOS%20+%20Driver/.
16 * This may be useful to anyone wanting to work on the mainstream hpt IDE. 17 * This may be useful to anyone wanting to work on this driver, however do not
18 * trust them too much since the code tends to become less and less meaningful
19 * as the time passes... :-/
17 * 20 *
18 * Note that final HPT370 support was done by force extraction of GPL. 21 * Note that final HPT370 support was done by force extraction of GPL.
19 * 22 *
@@ -52,6 +55,29 @@
52 * keeping me sane. 55 * keeping me sane.
53 * Alan Cox <alan@redhat.com> 56 * Alan Cox <alan@redhat.com>
54 * 57 *
58 * - fix the clock turnaround code: it was writing to the wrong ports when
59 * called for the secondary channel, caching the current clock mode per-
60 * channel caused the cached register value to get out of sync with the
61 * actual one, the channels weren't serialized, the turnaround shouldn't
62 * be done on 66 MHz PCI bus
63 * - avoid calibrating PLL twice as the second time results in a wrong PCI
64 * frequency and thus in the wrong timings for the secondary channel
65 * - disable UltraATA/133 for HPT372 by default (50 MHz DPLL clock do not
66 * allow for this speed anyway)
67 * - add support for HPT302N and HPT371N clocking (the same as for HPT372N)
68 * - HPT371/N are single channel chips, so avoid touching the primary channel
69 * which exists only virtually (there's no pins for it)
70 * - fix/remove bad/unused timing tables and use one set of tables for the whole
71 * HPT37x chip family; save space by introducing the separate transfer mode
72 * table in which the mode lookup is done
73 * - use f_CNT value saved by the HighPoint BIOS as reading it directly gives
74 * the wrong PCI frequency since DPLL has already been calibrated by BIOS
75 * - fix the hotswap code: it caused RESET- to glitch when tristating the bus,
76 * and for HPT36x the obsolete HDIO_TRISTATE_HWIF handler was called instead
77 * - pass to init_chipset() handlers a copy of the IDE PCI device structure as
78 * they tamper with its fields
79 * <source@mvista.com>
80 *
55 */ 81 */
56 82
57 83
@@ -76,8 +102,8 @@
76 102
77/* various tuning parameters */ 103/* various tuning parameters */
78#define HPT_RESET_STATE_ENGINE 104#define HPT_RESET_STATE_ENGINE
79#undef HPT_DELAY_INTERRUPT 105#undef HPT_DELAY_INTERRUPT
80#undef HPT_SERIALIZE_IO 106#define HPT_SERIALIZE_IO 0
81 107
82static const char *quirk_drives[] = { 108static const char *quirk_drives[] = {
83 "QUANTUM FIREBALLlct08 08", 109 "QUANTUM FIREBALLlct08 08",
@@ -141,305 +167,175 @@ static const char *bad_ata33[] = {
141 NULL 167 NULL
142}; 168};
143 169
144struct chipset_bus_clock_list_entry { 170static u8 xfer_speeds[] = {
145 u8 xfer_speed; 171 XFER_UDMA_6,
146 unsigned int chipset_settings; 172 XFER_UDMA_5,
173 XFER_UDMA_4,
174 XFER_UDMA_3,
175 XFER_UDMA_2,
176 XFER_UDMA_1,
177 XFER_UDMA_0,
178
179 XFER_MW_DMA_2,
180 XFER_MW_DMA_1,
181 XFER_MW_DMA_0,
182
183 XFER_PIO_4,
184 XFER_PIO_3,
185 XFER_PIO_2,
186 XFER_PIO_1,
187 XFER_PIO_0
147}; 188};
148 189
149/* key for bus clock timings 190/* Key for bus clock timings
150 * bit 191 * 36x 37x
151 * 0:3 data_high_time. inactive time of DIOW_/DIOR_ for PIO and MW 192 * bits bits
152 * DMA. cycles = value + 1 193 * 0:3 0:3 data_high_time. Inactive time of DIOW_/DIOR_ for PIO and MW DMA.
153 * 4:8 data_low_time. active time of DIOW_/DIOR_ for PIO and MW 194 * cycles = value + 1
154 * DMA. cycles = value + 1 195 * 4:7 4:8 data_low_time. Active time of DIOW_/DIOR_ for PIO and MW DMA.
155 * 9:12 cmd_high_time. inactive time of DIOW_/DIOR_ during task file 196 * cycles = value + 1
156 * register access. 197 * 8:11 9:12 cmd_high_time. Inactive time of DIOW_/DIOR_ during task file
157 * 13:17 cmd_low_time. active time of DIOW_/DIOR_ during task file 198 * register access.
158 * register access. 199 * 12:15 13:17 cmd_low_time. Active time of DIOW_/DIOR_ during task file
159 * 18:21 udma_cycle_time. clock freq and clock cycles for UDMA xfer. 200 * register access.
160 * during task file register access. 201 * 16:18 18:20 udma_cycle_time. Clock cycles for UDMA xfer.
161 * 22:24 pre_high_time. time to initialize 1st cycle for PIO and MW DMA 202 * - 21 CLK frequency: 0=ATA clock, 1=dual ATA clock.
162 * xfer. 203 * 19:21 22:24 pre_high_time. Time to initialize the 1st cycle for PIO and
163 * 25:27 cmd_pre_high_time. time to initialize 1st PIO cycle for task 204 * MW DMA xfer.
164 * register access. 205 * 22:24 25:27 cmd_pre_high_time. Time to initialize the 1st PIO cycle for
165 * 28 UDMA enable 206 * task file register access.
166 * 29 DMA enable 207 * 28 28 UDMA enable.
167 * 30 PIO_MST enable. if set, the chip is in bus master mode during 208 * 29 29 DMA enable.
168 * PIO. 209 * 30 30 PIO MST enable. If set, the chip is in bus master mode during
169 * 31 FIFO enable. 210 * PIO xfer.
211 * 31 31 FIFO enable.
170 */ 212 */
171static struct chipset_bus_clock_list_entry forty_base_hpt366[] = {
172 { XFER_UDMA_4, 0x900fd943 },
173 { XFER_UDMA_3, 0x900ad943 },
174 { XFER_UDMA_2, 0x900bd943 },
175 { XFER_UDMA_1, 0x9008d943 },
176 { XFER_UDMA_0, 0x9008d943 },
177
178 { XFER_MW_DMA_2, 0xa008d943 },
179 { XFER_MW_DMA_1, 0xa010d955 },
180 { XFER_MW_DMA_0, 0xa010d9fc },
181
182 { XFER_PIO_4, 0xc008d963 },
183 { XFER_PIO_3, 0xc010d974 },
184 { XFER_PIO_2, 0xc010d997 },
185 { XFER_PIO_1, 0xc010d9c7 },
186 { XFER_PIO_0, 0xc018d9d9 },
187 { 0, 0x0120d9d9 }
188};
189
190static struct chipset_bus_clock_list_entry thirty_three_base_hpt366[] = {
191 { XFER_UDMA_4, 0x90c9a731 },
192 { XFER_UDMA_3, 0x90cfa731 },
193 { XFER_UDMA_2, 0x90caa731 },
194 { XFER_UDMA_1, 0x90cba731 },
195 { XFER_UDMA_0, 0x90c8a731 },
196
197 { XFER_MW_DMA_2, 0xa0c8a731 },
198 { XFER_MW_DMA_1, 0xa0c8a732 }, /* 0xa0c8a733 */
199 { XFER_MW_DMA_0, 0xa0c8a797 },
200
201 { XFER_PIO_4, 0xc0c8a731 },
202 { XFER_PIO_3, 0xc0c8a742 },
203 { XFER_PIO_2, 0xc0d0a753 },
204 { XFER_PIO_1, 0xc0d0a7a3 }, /* 0xc0d0a793 */
205 { XFER_PIO_0, 0xc0d0a7aa }, /* 0xc0d0a7a7 */
206 { 0, 0x0120a7a7 }
207};
208
209static struct chipset_bus_clock_list_entry twenty_five_base_hpt366[] = {
210 { XFER_UDMA_4, 0x90c98521 },
211 { XFER_UDMA_3, 0x90cf8521 },
212 { XFER_UDMA_2, 0x90cf8521 },
213 { XFER_UDMA_1, 0x90cb8521 },
214 { XFER_UDMA_0, 0x90cb8521 },
215
216 { XFER_MW_DMA_2, 0xa0ca8521 },
217 { XFER_MW_DMA_1, 0xa0ca8532 },
218 { XFER_MW_DMA_0, 0xa0ca8575 },
219
220 { XFER_PIO_4, 0xc0ca8521 },
221 { XFER_PIO_3, 0xc0ca8532 },
222 { XFER_PIO_2, 0xc0ca8542 },
223 { XFER_PIO_1, 0xc0d08572 },
224 { XFER_PIO_0, 0xc0d08585 },
225 { 0, 0x01208585 }
226};
227
228/* from highpoint documentation. these are old values */
229static struct chipset_bus_clock_list_entry thirty_three_base_hpt370[] = {
230/* { XFER_UDMA_5, 0x1A85F442, 0x16454e31 }, */
231 { XFER_UDMA_5, 0x16454e31 },
232 { XFER_UDMA_4, 0x16454e31 },
233 { XFER_UDMA_3, 0x166d4e31 },
234 { XFER_UDMA_2, 0x16494e31 },
235 { XFER_UDMA_1, 0x164d4e31 },
236 { XFER_UDMA_0, 0x16514e31 },
237
238 { XFER_MW_DMA_2, 0x26514e21 },
239 { XFER_MW_DMA_1, 0x26514e33 },
240 { XFER_MW_DMA_0, 0x26514e97 },
241
242 { XFER_PIO_4, 0x06514e21 },
243 { XFER_PIO_3, 0x06514e22 },
244 { XFER_PIO_2, 0x06514e33 },
245 { XFER_PIO_1, 0x06914e43 },
246 { XFER_PIO_0, 0x06914e57 },
247 { 0, 0x06514e57 }
248};
249
250static struct chipset_bus_clock_list_entry sixty_six_base_hpt370[] = {
251 { XFER_UDMA_5, 0x14846231 },
252 { XFER_UDMA_4, 0x14886231 },
253 { XFER_UDMA_3, 0x148c6231 },
254 { XFER_UDMA_2, 0x148c6231 },
255 { XFER_UDMA_1, 0x14906231 },
256 { XFER_UDMA_0, 0x14986231 },
257
258 { XFER_MW_DMA_2, 0x26514e21 },
259 { XFER_MW_DMA_1, 0x26514e33 },
260 { XFER_MW_DMA_0, 0x26514e97 },
261
262 { XFER_PIO_4, 0x06514e21 },
263 { XFER_PIO_3, 0x06514e22 },
264 { XFER_PIO_2, 0x06514e33 },
265 { XFER_PIO_1, 0x06914e43 },
266 { XFER_PIO_0, 0x06914e57 },
267 { 0, 0x06514e57 }
268};
269
270/* these are the current (4 sep 2001) timings from highpoint */
271static struct chipset_bus_clock_list_entry thirty_three_base_hpt370a[] = {
272 { XFER_UDMA_5, 0x12446231 },
273 { XFER_UDMA_4, 0x12446231 },
274 { XFER_UDMA_3, 0x126c6231 },
275 { XFER_UDMA_2, 0x12486231 },
276 { XFER_UDMA_1, 0x124c6233 },
277 { XFER_UDMA_0, 0x12506297 },
278
279 { XFER_MW_DMA_2, 0x22406c31 },
280 { XFER_MW_DMA_1, 0x22406c33 },
281 { XFER_MW_DMA_0, 0x22406c97 },
282
283 { XFER_PIO_4, 0x06414e31 },
284 { XFER_PIO_3, 0x06414e42 },
285 { XFER_PIO_2, 0x06414e53 },
286 { XFER_PIO_1, 0x06814e93 },
287 { XFER_PIO_0, 0x06814ea7 },
288 { 0, 0x06814ea7 }
289};
290
291/* 2x 33MHz timings */
292static struct chipset_bus_clock_list_entry sixty_six_base_hpt370a[] = {
293 { XFER_UDMA_5, 0x1488e673 },
294 { XFER_UDMA_4, 0x1488e673 },
295 { XFER_UDMA_3, 0x1498e673 },
296 { XFER_UDMA_2, 0x1490e673 },
297 { XFER_UDMA_1, 0x1498e677 },
298 { XFER_UDMA_0, 0x14a0e73f },
299
300 { XFER_MW_DMA_2, 0x2480fa73 },
301 { XFER_MW_DMA_1, 0x2480fa77 },
302 { XFER_MW_DMA_0, 0x2480fb3f },
303
304 { XFER_PIO_4, 0x0c82be73 },
305 { XFER_PIO_3, 0x0c82be95 },
306 { XFER_PIO_2, 0x0c82beb7 },
307 { XFER_PIO_1, 0x0d02bf37 },
308 { XFER_PIO_0, 0x0d02bf5f },
309 { 0, 0x0d02bf5f }
310};
311 213
312static struct chipset_bus_clock_list_entry fifty_base_hpt370a[] = { 214static u32 forty_base_hpt36x[] = {
313 { XFER_UDMA_5, 0x12848242 }, 215 /* XFER_UDMA_6 */ 0x900fd943,
314 { XFER_UDMA_4, 0x12ac8242 }, 216 /* XFER_UDMA_5 */ 0x900fd943,
315 { XFER_UDMA_3, 0x128c8242 }, 217 /* XFER_UDMA_4 */ 0x900fd943,
316 { XFER_UDMA_2, 0x120c8242 }, 218 /* XFER_UDMA_3 */ 0x900ad943,
317 { XFER_UDMA_1, 0x12148254 }, 219 /* XFER_UDMA_2 */ 0x900bd943,
318 { XFER_UDMA_0, 0x121882ea }, 220 /* XFER_UDMA_1 */ 0x9008d943,
319 221 /* XFER_UDMA_0 */ 0x9008d943,
320 { XFER_MW_DMA_2, 0x22808242 }, 222
321 { XFER_MW_DMA_1, 0x22808254 }, 223 /* XFER_MW_DMA_2 */ 0xa008d943,
322 { XFER_MW_DMA_0, 0x228082ea }, 224 /* XFER_MW_DMA_1 */ 0xa010d955,
323 225 /* XFER_MW_DMA_0 */ 0xa010d9fc,
324 { XFER_PIO_4, 0x0a81f442 }, 226
325 { XFER_PIO_3, 0x0a81f443 }, 227 /* XFER_PIO_4 */ 0xc008d963,
326 { XFER_PIO_2, 0x0a81f454 }, 228 /* XFER_PIO_3 */ 0xc010d974,
327 { XFER_PIO_1, 0x0ac1f465 }, 229 /* XFER_PIO_2 */ 0xc010d997,
328 { XFER_PIO_0, 0x0ac1f48a }, 230 /* XFER_PIO_1 */ 0xc010d9c7,
329 { 0, 0x0ac1f48a } 231 /* XFER_PIO_0 */ 0xc018d9d9
330}; 232};
331 233
332static struct chipset_bus_clock_list_entry thirty_three_base_hpt372[] = { 234static u32 thirty_three_base_hpt36x[] = {
333 { XFER_UDMA_6, 0x1c81dc62 }, 235 /* XFER_UDMA_6 */ 0x90c9a731,
334 { XFER_UDMA_5, 0x1c6ddc62 }, 236 /* XFER_UDMA_5 */ 0x90c9a731,
335 { XFER_UDMA_4, 0x1c8ddc62 }, 237 /* XFER_UDMA_4 */ 0x90c9a731,
336 { XFER_UDMA_3, 0x1c8edc62 }, /* checkme */ 238 /* XFER_UDMA_3 */ 0x90cfa731,
337 { XFER_UDMA_2, 0x1c91dc62 }, 239 /* XFER_UDMA_2 */ 0x90caa731,
338 { XFER_UDMA_1, 0x1c9adc62 }, /* checkme */ 240 /* XFER_UDMA_1 */ 0x90cba731,
339 { XFER_UDMA_0, 0x1c82dc62 }, /* checkme */ 241 /* XFER_UDMA_0 */ 0x90c8a731,
340 242
341 { XFER_MW_DMA_2, 0x2c829262 }, 243 /* XFER_MW_DMA_2 */ 0xa0c8a731,
342 { XFER_MW_DMA_1, 0x2c829266 }, /* checkme */ 244 /* XFER_MW_DMA_1 */ 0xa0c8a732, /* 0xa0c8a733 */
343 { XFER_MW_DMA_0, 0x2c82922e }, /* checkme */ 245 /* XFER_MW_DMA_0 */ 0xa0c8a797,
344 246
345 { XFER_PIO_4, 0x0c829c62 }, 247 /* XFER_PIO_4 */ 0xc0c8a731,
346 { XFER_PIO_3, 0x0c829c84 }, 248 /* XFER_PIO_3 */ 0xc0c8a742,
347 { XFER_PIO_2, 0x0c829ca6 }, 249 /* XFER_PIO_2 */ 0xc0d0a753,
348 { XFER_PIO_1, 0x0d029d26 }, 250 /* XFER_PIO_1 */ 0xc0d0a7a3, /* 0xc0d0a793 */
349 { XFER_PIO_0, 0x0d029d5e }, 251 /* XFER_PIO_0 */ 0xc0d0a7aa /* 0xc0d0a7a7 */
350 { 0, 0x0d029d5e }
351}; 252};
352 253
353static struct chipset_bus_clock_list_entry fifty_base_hpt372[] = { 254static u32 twenty_five_base_hpt36x[] = {
354 { XFER_UDMA_5, 0x12848242 }, 255 /* XFER_UDMA_6 */ 0x90c98521,
355 { XFER_UDMA_4, 0x12ac8242 }, 256 /* XFER_UDMA_5 */ 0x90c98521,
356 { XFER_UDMA_3, 0x128c8242 }, 257 /* XFER_UDMA_4 */ 0x90c98521,
357 { XFER_UDMA_2, 0x120c8242 }, 258 /* XFER_UDMA_3 */ 0x90cf8521,
358 { XFER_UDMA_1, 0x12148254 }, 259 /* XFER_UDMA_2 */ 0x90cf8521,
359 { XFER_UDMA_0, 0x121882ea }, 260 /* XFER_UDMA_1 */ 0x90cb8521,
360 261 /* XFER_UDMA_0 */ 0x90cb8521,
361 { XFER_MW_DMA_2, 0x22808242 }, 262
362 { XFER_MW_DMA_1, 0x22808254 }, 263 /* XFER_MW_DMA_2 */ 0xa0ca8521,
363 { XFER_MW_DMA_0, 0x228082ea }, 264 /* XFER_MW_DMA_1 */ 0xa0ca8532,
364 265 /* XFER_MW_DMA_0 */ 0xa0ca8575,
365 { XFER_PIO_4, 0x0a81f442 }, 266
366 { XFER_PIO_3, 0x0a81f443 }, 267 /* XFER_PIO_4 */ 0xc0ca8521,
367 { XFER_PIO_2, 0x0a81f454 }, 268 /* XFER_PIO_3 */ 0xc0ca8532,
368 { XFER_PIO_1, 0x0ac1f465 }, 269 /* XFER_PIO_2 */ 0xc0ca8542,
369 { XFER_PIO_0, 0x0ac1f48a }, 270 /* XFER_PIO_1 */ 0xc0d08572,
370 { 0, 0x0a81f443 } 271 /* XFER_PIO_0 */ 0xc0d08585
371}; 272};
372 273
373static struct chipset_bus_clock_list_entry sixty_six_base_hpt372[] = { 274static u32 thirty_three_base_hpt37x[] = {
374 { XFER_UDMA_6, 0x1c869c62 }, 275 /* XFER_UDMA_6 */ 0x12446231, /* 0x12646231 ?? */
375 { XFER_UDMA_5, 0x1cae9c62 }, 276 /* XFER_UDMA_5 */ 0x12446231,
376 { XFER_UDMA_4, 0x1c8a9c62 }, 277 /* XFER_UDMA_4 */ 0x12446231,
377 { XFER_UDMA_3, 0x1c8e9c62 }, 278 /* XFER_UDMA_3 */ 0x126c6231,
378 { XFER_UDMA_2, 0x1c929c62 }, 279 /* XFER_UDMA_2 */ 0x12486231,
379 { XFER_UDMA_1, 0x1c9a9c62 }, 280 /* XFER_UDMA_1 */ 0x124c6233,
380 { XFER_UDMA_0, 0x1c829c62 }, 281 /* XFER_UDMA_0 */ 0x12506297,
381 282
382 { XFER_MW_DMA_2, 0x2c829c62 }, 283 /* XFER_MW_DMA_2 */ 0x22406c31,
383 { XFER_MW_DMA_1, 0x2c829c66 }, 284 /* XFER_MW_DMA_1 */ 0x22406c33,
384 { XFER_MW_DMA_0, 0x2c829d2e }, 285 /* XFER_MW_DMA_0 */ 0x22406c97,
385 286
386 { XFER_PIO_4, 0x0c829c62 }, 287 /* XFER_PIO_4 */ 0x06414e31,
387 { XFER_PIO_3, 0x0c829c84 }, 288 /* XFER_PIO_3 */ 0x06414e42,
388 { XFER_PIO_2, 0x0c829ca6 }, 289 /* XFER_PIO_2 */ 0x06414e53,
389 { XFER_PIO_1, 0x0d029d26 }, 290 /* XFER_PIO_1 */ 0x06814e93,
390 { XFER_PIO_0, 0x0d029d5e }, 291 /* XFER_PIO_0 */ 0x06814ea7
391 { 0, 0x0d029d26 }
392}; 292};
393 293
394static struct chipset_bus_clock_list_entry thirty_three_base_hpt374[] = { 294static u32 fifty_base_hpt37x[] = {
395 { XFER_UDMA_6, 0x12808242 }, 295 /* XFER_UDMA_6 */ 0x12848242,
396 { XFER_UDMA_5, 0x12848242 }, 296 /* XFER_UDMA_5 */ 0x12848242,
397 { XFER_UDMA_4, 0x12ac8242 }, 297 /* XFER_UDMA_4 */ 0x12ac8242,
398 { XFER_UDMA_3, 0x128c8242 }, 298 /* XFER_UDMA_3 */ 0x128c8242,
399 { XFER_UDMA_2, 0x120c8242 }, 299 /* XFER_UDMA_2 */ 0x120c8242,
400 { XFER_UDMA_1, 0x12148254 }, 300 /* XFER_UDMA_1 */ 0x12148254,
401 { XFER_UDMA_0, 0x121882ea }, 301 /* XFER_UDMA_0 */ 0x121882ea,
402 302
403 { XFER_MW_DMA_2, 0x22808242 }, 303 /* XFER_MW_DMA_2 */ 0x22808242,
404 { XFER_MW_DMA_1, 0x22808254 }, 304 /* XFER_MW_DMA_1 */ 0x22808254,
405 { XFER_MW_DMA_0, 0x228082ea }, 305 /* XFER_MW_DMA_0 */ 0x228082ea,
406 306
407 { XFER_PIO_4, 0x0a81f442 }, 307 /* XFER_PIO_4 */ 0x0a81f442,
408 { XFER_PIO_3, 0x0a81f443 }, 308 /* XFER_PIO_3 */ 0x0a81f443,
409 { XFER_PIO_2, 0x0a81f454 }, 309 /* XFER_PIO_2 */ 0x0a81f454,
410 { XFER_PIO_1, 0x0ac1f465 }, 310 /* XFER_PIO_1 */ 0x0ac1f465,
411 { XFER_PIO_0, 0x0ac1f48a }, 311 /* XFER_PIO_0 */ 0x0ac1f48a
412 { 0, 0x06814e93 }
413}; 312};
414 313
415/* FIXME: 50MHz timings for HPT374 */ 314static u32 sixty_six_base_hpt37x[] = {
416 315 /* XFER_UDMA_6 */ 0x1c869c62,
417#if 0 316 /* XFER_UDMA_5 */ 0x1cae9c62, /* 0x1c8a9c62 */
418static struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = { 317 /* XFER_UDMA_4 */ 0x1c8a9c62,
419 { XFER_UDMA_6, 0x12406231 }, /* checkme */ 318 /* XFER_UDMA_3 */ 0x1c8e9c62,
420 { XFER_UDMA_5, 0x12446231 }, /* 0x14846231 */ 319 /* XFER_UDMA_2 */ 0x1c929c62,
421 { XFER_UDMA_4, 0x16814ea7 }, /* 0x14886231 */ 320 /* XFER_UDMA_1 */ 0x1c9a9c62,
422 { XFER_UDMA_3, 0x16814ea7 }, /* 0x148c6231 */ 321 /* XFER_UDMA_0 */ 0x1c829c62,
423 { XFER_UDMA_2, 0x16814ea7 }, /* 0x148c6231 */ 322
424 { XFER_UDMA_1, 0x16814ea7 }, /* 0x14906231 */ 323 /* XFER_MW_DMA_2 */ 0x2c829c62,
425 { XFER_UDMA_0, 0x16814ea7 }, /* 0x14986231 */ 324 /* XFER_MW_DMA_1 */ 0x2c829c66,
426 { XFER_MW_DMA_2, 0x16814ea7 }, /* 0x26514e21 */ 325 /* XFER_MW_DMA_0 */ 0x2c829d2e,
427 { XFER_MW_DMA_1, 0x16814ea7 }, /* 0x26514e97 */ 326
428 { XFER_MW_DMA_0, 0x16814ea7 }, /* 0x26514e97 */ 327 /* XFER_PIO_4 */ 0x0c829c62,
429 { XFER_PIO_4, 0x06814ea7 }, /* 0x06514e21 */ 328 /* XFER_PIO_3 */ 0x0c829c84,
430 { XFER_PIO_3, 0x06814ea7 }, /* 0x06514e22 */ 329 /* XFER_PIO_2 */ 0x0c829ca6,
431 { XFER_PIO_2, 0x06814ea7 }, /* 0x06514e33 */ 330 /* XFER_PIO_1 */ 0x0d029d26,
432 { XFER_PIO_1, 0x06814ea7 }, /* 0x06914e43 */ 331 /* XFER_PIO_0 */ 0x0d029d5e
433 { XFER_PIO_0, 0x06814ea7 }, /* 0x06914e57 */
434 { 0, 0x06814ea7 }
435}; 332};
436#endif
437 333
438#define HPT366_DEBUG_DRIVE_INFO 0 334#define HPT366_DEBUG_DRIVE_INFO 0
439#define HPT374_ALLOW_ATA133_6 0 335#define HPT374_ALLOW_ATA133_6 0
440#define HPT371_ALLOW_ATA133_6 0 336#define HPT371_ALLOW_ATA133_6 0
441#define HPT302_ALLOW_ATA133_6 0 337#define HPT302_ALLOW_ATA133_6 0
442#define HPT372_ALLOW_ATA133_6 1 338#define HPT372_ALLOW_ATA133_6 0
443#define HPT370_ALLOW_ATA100_5 1 339#define HPT370_ALLOW_ATA100_5 1
444#define HPT366_ALLOW_ATA66_4 1 340#define HPT366_ALLOW_ATA66_4 1
445#define HPT366_ALLOW_ATA66_3 1 341#define HPT366_ALLOW_ATA66_3 1
@@ -461,9 +357,10 @@ struct hpt_info
461 int revision; /* Chipset revision */ 357 int revision; /* Chipset revision */
462 int flags; /* Chipset properties */ 358 int flags; /* Chipset properties */
463#define PLL_MODE 1 359#define PLL_MODE 1
464#define IS_372N 2 360#define IS_3xxN 2
361#define PCI_66MHZ 4
465 /* Speed table */ 362 /* Speed table */
466 struct chipset_bus_clock_list_entry *speed; 363 u32 *speed;
467}; 364};
468 365
469/* 366/*
@@ -600,12 +497,20 @@ static int check_in_drive_lists (ide_drive_t *drive, const char **list)
600 return 0; 497 return 0;
601} 498}
602 499
603static unsigned int pci_bus_clock_list (u8 speed, struct chipset_bus_clock_list_entry * chipset_table) 500static u32 pci_bus_clock_list(u8 speed, u32 *chipset_table)
604{ 501{
605 for ( ; chipset_table->xfer_speed ; chipset_table++) 502 int i;
606 if (chipset_table->xfer_speed == speed) 503
607 return chipset_table->chipset_settings; 504 /*
608 return chipset_table->chipset_settings; 505 * Lookup the transfer mode table to get the index into
506 * the timing table.
507 *
508 * NOTE: For XFER_PIO_SLOW, PIO mode 0 timings will be used.
509 */
510 for (i = 0; i < ARRAY_SIZE(xfer_speeds) - 1; i++)
511 if (xfer_speeds[i] == speed)
512 break;
513 return chipset_table[i];
609} 514}
610 515
611static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed) 516static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed)
@@ -956,156 +861,127 @@ static int hpt374_ide_dma_end (ide_drive_t *drive)
956} 861}
957 862
958/** 863/**
959 * hpt372n_set_clock - perform clock switching dance 864 * hpt3xxn_set_clock - perform clock switching dance
960 * @drive: Drive to switch 865 * @hwif: hwif to switch
961 * @mode: Switching mode (0x21 for write, 0x23 otherwise) 866 * @mode: clocking mode (0x21 for write, 0x23 otherwise)
962 * 867 *
963 * Switch the DPLL clock on the HPT372N devices. This is a 868 * Switch the DPLL clock on the HPT3xxN devices. This is a right mess.
964 * right mess. 869 * NOTE: avoid touching the disabled primary channel on HPT371N -- it
870 * doesn't physically exist anyway...
965 */ 871 */
966 872
967static void hpt372n_set_clock(ide_drive_t *drive, int mode) 873static void hpt3xxn_set_clock(ide_hwif_t *hwif, u8 mode)
968{ 874{
969 ide_hwif_t *hwif = HWIF(drive); 875 u8 mcr1, scr2 = hwif->INB(hwif->dma_master + 0x7b);
970 876
971 /* FIXME: should we check for DMA active and BUG() */ 877 if ((scr2 & 0x7f) == mode)
878 return;
879
880 /* MISC. control register 1 has the channel enable bit... */
881 mcr1 = hwif->INB(hwif->dma_master + 0x70);
882
972 /* Tristate the bus */ 883 /* Tristate the bus */
973 outb(0x80, hwif->dma_base+0x73); 884 if (mcr1 & 0x04)
974 outb(0x80, hwif->dma_base+0x77); 885 hwif->OUTB(0x80, hwif->dma_master + 0x73);
975 886 hwif->OUTB(0x80, hwif->dma_master + 0x77);
887
976 /* Switch clock and reset channels */ 888 /* Switch clock and reset channels */
977 outb(mode, hwif->dma_base+0x7B); 889 hwif->OUTB(mode, hwif->dma_master + 0x7b);
978 outb(0xC0, hwif->dma_base+0x79); 890 hwif->OUTB(0xc0, hwif->dma_master + 0x79);
979 891
980 /* Reset state machines */ 892 /* Reset state machines */
981 outb(0x37, hwif->dma_base+0x70); 893 if (mcr1 & 0x04)
982 outb(0x37, hwif->dma_base+0x74); 894 hwif->OUTB(0x37, hwif->dma_master + 0x70);
983 895 hwif->OUTB(0x37, hwif->dma_master + 0x74);
896
984 /* Complete reset */ 897 /* Complete reset */
985 outb(0x00, hwif->dma_base+0x79); 898 hwif->OUTB(0x00, hwif->dma_master + 0x79);
986 899
987 /* Reconnect channels to bus */ 900 /* Reconnect channels to bus */
988 outb(0x00, hwif->dma_base+0x73); 901 if (mcr1 & 0x04)
989 outb(0x00, hwif->dma_base+0x77); 902 hwif->OUTB(0x00, hwif->dma_master + 0x73);
903 hwif->OUTB(0x00, hwif->dma_master + 0x77);
990} 904}
991 905
992/** 906/**
993 * hpt372n_rw_disk - prepare for I/O 907 * hpt3xxn_rw_disk - prepare for I/O
994 * @drive: drive for command 908 * @drive: drive for command
995 * @rq: block request structure 909 * @rq: block request structure
996 * 910 *
997 * This is called when a disk I/O is issued to the 372N. 911 * This is called when a disk I/O is issued to HPT3xxN.
998 * We need it because of the clock switching. 912 * We need it because of the clock switching.
999 */ 913 */
1000 914
1001static void hpt372n_rw_disk(ide_drive_t *drive, struct request *rq) 915static void hpt3xxn_rw_disk(ide_drive_t *drive, struct request *rq)
1002{
1003 ide_hwif_t *hwif = drive->hwif;
1004 int wantclock;
1005
1006 wantclock = rq_data_dir(rq) ? 0x23 : 0x21;
1007
1008 if (hwif->config_data != wantclock) {
1009 hpt372n_set_clock(drive, wantclock);
1010 hwif->config_data = wantclock;
1011 }
1012}
1013
1014/*
1015 * Since SUN Cobalt is attempting to do this operation, I should disclose
1016 * this has been a long time ago Thu Jul 27 16:40:57 2000 was the patch date
1017 * HOTSWAP ATA Infrastructure.
1018 */
1019
1020static void hpt3xx_reset (ide_drive_t *drive)
1021{
1022}
1023
1024static int hpt3xx_tristate (ide_drive_t * drive, int state)
1025{ 916{
1026 ide_hwif_t *hwif = HWIF(drive); 917 ide_hwif_t *hwif = HWIF(drive);
1027 struct pci_dev *dev = hwif->pci_dev; 918 u8 wantclock = rq_data_dir(rq) ? 0x23 : 0x21;
1028 u8 reg59h = 0, reset = (hwif->channel) ? 0x80 : 0x40;
1029 u8 regXXh = 0, state_reg= (hwif->channel) ? 0x57 : 0x53;
1030
1031 pci_read_config_byte(dev, 0x59, &reg59h);
1032 pci_read_config_byte(dev, state_reg, &regXXh);
1033 919
1034 if (state) { 920 hpt3xxn_set_clock(hwif, wantclock);
1035 (void) ide_do_reset(drive);
1036 pci_write_config_byte(dev, state_reg, regXXh|0x80);
1037 pci_write_config_byte(dev, 0x59, reg59h|reset);
1038 } else {
1039 pci_write_config_byte(dev, 0x59, reg59h & ~(reset));
1040 pci_write_config_byte(dev, state_reg, regXXh & ~(0x80));
1041 (void) ide_do_reset(drive);
1042 }
1043 return 0;
1044} 921}
1045 922
1046/* 923/*
1047 * set/get power state for a drive. 924 * Set/get power state for a drive.
1048 * turning the power off does the following things:
1049 * 1) soft-reset the drive
1050 * 2) tri-states the ide bus
1051 * 925 *
1052 * when we turn things back on, we need to re-initialize things. 926 * When we turn the power back on, we need to re-initialize things.
1053 */ 927 */
1054#define TRISTATE_BIT 0x8000 928#define TRISTATE_BIT 0x8000
1055static int hpt370_busproc(ide_drive_t * drive, int state) 929
930static int hpt3xx_busproc(ide_drive_t *drive, int state)
1056{ 931{
1057 ide_hwif_t *hwif = drive->hwif; 932 ide_hwif_t *hwif = drive->hwif;
1058 struct pci_dev *dev = hwif->pci_dev; 933 struct pci_dev *dev = hwif->pci_dev;
1059 u8 tristate = 0, resetmask = 0, bus_reg = 0; 934 u8 tristate, resetmask, bus_reg = 0;
1060 u16 tri_reg; 935 u16 tri_reg = 0;
1061 936
1062 hwif->bus_state = state; 937 hwif->bus_state = state;
1063 938
1064 if (hwif->channel) { 939 if (hwif->channel) {
1065 /* secondary channel */ 940 /* secondary channel */
1066 tristate = 0x56; 941 tristate = 0x56;
1067 resetmask = 0x80; 942 resetmask = 0x80;
1068 } else { 943 } else {
1069 /* primary channel */ 944 /* primary channel */
1070 tristate = 0x52; 945 tristate = 0x52;
1071 resetmask = 0x40; 946 resetmask = 0x40;
1072 } 947 }
1073 948
1074 /* grab status */ 949 /* Grab the status. */
1075 pci_read_config_word(dev, tristate, &tri_reg); 950 pci_read_config_word(dev, tristate, &tri_reg);
1076 pci_read_config_byte(dev, 0x59, &bus_reg); 951 pci_read_config_byte(dev, 0x59, &bus_reg);
1077 952
1078 /* set the state. we don't set it if we don't need to do so. 953 /*
1079 * make sure that the drive knows that it has failed if it's off */ 954 * Set the state. We don't set it if we don't need to do so.
955 * Make sure that the drive knows that it has failed if it's off.
956 */
1080 switch (state) { 957 switch (state) {
1081 case BUSSTATE_ON: 958 case BUSSTATE_ON:
1082 hwif->drives[0].failures = 0; 959 if (!(bus_reg & resetmask))
1083 hwif->drives[1].failures = 0;
1084 if ((bus_reg & resetmask) == 0)
1085 return 0; 960 return 0;
1086 tri_reg &= ~TRISTATE_BIT; 961 hwif->drives[0].failures = hwif->drives[1].failures = 0;
1087 bus_reg &= ~resetmask; 962
1088 break; 963 pci_write_config_byte(dev, 0x59, bus_reg & ~resetmask);
964 pci_write_config_word(dev, tristate, tri_reg & ~TRISTATE_BIT);
965 return 0;
1089 case BUSSTATE_OFF: 966 case BUSSTATE_OFF:
1090 hwif->drives[0].failures = hwif->drives[0].max_failures + 1; 967 if ((bus_reg & resetmask) && !(tri_reg & TRISTATE_BIT))
1091 hwif->drives[1].failures = hwif->drives[1].max_failures + 1;
1092 if ((tri_reg & TRISTATE_BIT) == 0 && (bus_reg & resetmask))
1093 return 0; 968 return 0;
1094 tri_reg &= ~TRISTATE_BIT; 969 tri_reg &= ~TRISTATE_BIT;
1095 bus_reg |= resetmask;
1096 break; 970 break;
1097 case BUSSTATE_TRISTATE: 971 case BUSSTATE_TRISTATE:
1098 hwif->drives[0].failures = hwif->drives[0].max_failures + 1; 972 if ((bus_reg & resetmask) && (tri_reg & TRISTATE_BIT))
1099 hwif->drives[1].failures = hwif->drives[1].max_failures + 1;
1100 if ((tri_reg & TRISTATE_BIT) && (bus_reg & resetmask))
1101 return 0; 973 return 0;
1102 tri_reg |= TRISTATE_BIT; 974 tri_reg |= TRISTATE_BIT;
1103 bus_reg |= resetmask;
1104 break; 975 break;
976 default:
977 return -EINVAL;
1105 } 978 }
1106 pci_write_config_byte(dev, 0x59, bus_reg);
1107 pci_write_config_word(dev, tristate, tri_reg);
1108 979
980 hwif->drives[0].failures = hwif->drives[0].max_failures + 1;
981 hwif->drives[1].failures = hwif->drives[1].max_failures + 1;
982
983 pci_write_config_word(dev, tristate, tri_reg);
984 pci_write_config_byte(dev, 0x59, bus_reg | resetmask);
1109 return 0; 985 return 0;
1110} 986}
1111 987
@@ -1119,14 +995,14 @@ static void __devinit hpt366_clocking(ide_hwif_t *hwif)
1119 /* detect bus speed by looking at control reg timing: */ 995 /* detect bus speed by looking at control reg timing: */
1120 switch((reg1 >> 8) & 7) { 996 switch((reg1 >> 8) & 7) {
1121 case 5: 997 case 5:
1122 info->speed = forty_base_hpt366; 998 info->speed = forty_base_hpt36x;
1123 break; 999 break;
1124 case 9: 1000 case 9:
1125 info->speed = twenty_five_base_hpt366; 1001 info->speed = twenty_five_base_hpt36x;
1126 break; 1002 break;
1127 case 7: 1003 case 7:
1128 default: 1004 default:
1129 info->speed = thirty_three_base_hpt366; 1005 info->speed = thirty_three_base_hpt36x;
1130 break; 1006 break;
1131 } 1007 }
1132} 1008}
@@ -1136,9 +1012,9 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif)
1136 struct hpt_info *info = ide_get_hwifdata(hwif); 1012 struct hpt_info *info = ide_get_hwifdata(hwif);
1137 struct pci_dev *dev = hwif->pci_dev; 1013 struct pci_dev *dev = hwif->pci_dev;
1138 int adjust, i; 1014 int adjust, i;
1139 u16 freq; 1015 u16 freq = 0;
1140 u32 pll; 1016 u32 pll, temp = 0;
1141 u8 reg5bh; 1017 u8 reg5bh = 0, mcr1 = 0;
1142 1018
1143 /* 1019 /*
1144 * default to pci clock. make sure MA15/16 are set to output 1020 * default to pci clock. make sure MA15/16 are set to output
@@ -1151,27 +1027,40 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif)
1151 pci_write_config_byte(dev, 0x5b, 0x23); 1027 pci_write_config_byte(dev, 0x5b, 0x23);
1152 1028
1153 /* 1029 /*
1154 * set up the PLL. we need to adjust it so that it's stable. 1030 * We'll have to read f_CNT value in order to determine
1155 * freq = Tpll * 192 / Tpci 1031 * the PCI clock frequency according to the following ratio:
1032 *
1033 * f_CNT = Fpci * 192 / Fdpll
1034 *
1035 * First try reading the register in which the HighPoint BIOS
1036 * saves f_CNT value before reprogramming the DPLL from its
1037 * default setting (which differs for the various chips).
1038 * NOTE: This register is only accessible via I/O space.
1156 * 1039 *
1157 * Todo. For non x86 should probably check the dword is 1040 * In case the signature check fails, we'll have to resort to
1158 * set to 0xABCDExxx indicating the BIOS saved f_CNT 1041 * reading the f_CNT register itself in hopes that nobody has
1042 * touched the DPLL yet...
1159 */ 1043 */
1160 pci_read_config_word(dev, 0x78, &freq); 1044 temp = inl(pci_resource_start(dev, 4) + 0x90);
1161 freq &= 0x1FF; 1045 if ((temp & 0xFFFFF000) != 0xABCDE000) {
1162 1046 printk(KERN_WARNING "HPT37X: no clock data saved by BIOS\n");
1047
1048 /* Calculate the average value of f_CNT */
1049 for (temp = i = 0; i < 128; i++) {
1050 pci_read_config_word(dev, 0x78, &freq);
1051 temp += freq & 0x1ff;
1052 mdelay(1);
1053 }
1054 freq = temp / 128;
1055 } else
1056 freq = temp & 0x1ff;
1057
1163 /* 1058 /*
1164 * The 372N uses different PCI clock information and has 1059 * HPT3xxN chips use different PCI clock information.
1165 * some other complications 1060 * Currently we always set up the PLL for them.
1166 * On PCI33 timing we must clock switch
1167 * On PCI66 timing we must NOT use the PCI clock
1168 *
1169 * Currently we always set up the PLL for the 372N
1170 */ 1061 */
1171 1062
1172 if(info->flags & IS_372N) 1063 if (info->flags & IS_3xxN) {
1173 {
1174 printk(KERN_INFO "hpt: HPT372N detected, using 372N timing.\n");
1175 if(freq < 0x55) 1064 if(freq < 0x55)
1176 pll = F_LOW_PCI_33; 1065 pll = F_LOW_PCI_33;
1177 else if(freq < 0x70) 1066 else if(freq < 0x70)
@@ -1180,10 +1069,8 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif)
1180 pll = F_LOW_PCI_50; 1069 pll = F_LOW_PCI_50;
1181 else 1070 else
1182 pll = F_LOW_PCI_66; 1071 pll = F_LOW_PCI_66;
1183 1072
1184 printk(KERN_INFO "FREQ: %d PLL: %d\n", freq, pll); 1073 printk(KERN_INFO "HPT3xxN detected, FREQ: %d, PLL: %d\n", freq, pll);
1185
1186 /* We always use the pll not the PCI clock on 372N */
1187 } 1074 }
1188 else 1075 else
1189 { 1076 {
@@ -1197,41 +1084,22 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif)
1197 pll = F_LOW_PCI_66; 1084 pll = F_LOW_PCI_66;
1198 1085
1199 if (pll == F_LOW_PCI_33) { 1086 if (pll == F_LOW_PCI_33) {
1200 if (info->revision >= 8) 1087 info->speed = thirty_three_base_hpt37x;
1201 info->speed = thirty_three_base_hpt374;
1202 else if (info->revision >= 5)
1203 info->speed = thirty_three_base_hpt372;
1204 else if (info->revision >= 4)
1205 info->speed = thirty_three_base_hpt370a;
1206 else
1207 info->speed = thirty_three_base_hpt370;
1208 printk(KERN_DEBUG "HPT37X: using 33MHz PCI clock\n"); 1088 printk(KERN_DEBUG "HPT37X: using 33MHz PCI clock\n");
1209 } else if (pll == F_LOW_PCI_40) { 1089 } else if (pll == F_LOW_PCI_40) {
1210 /* Unsupported */ 1090 /* Unsupported */
1211 } else if (pll == F_LOW_PCI_50) { 1091 } else if (pll == F_LOW_PCI_50) {
1212 if (info->revision >= 8) 1092 info->speed = fifty_base_hpt37x;
1213 info->speed = fifty_base_hpt370a;
1214 else if (info->revision >= 5)
1215 info->speed = fifty_base_hpt372;
1216 else if (info->revision >= 4)
1217 info->speed = fifty_base_hpt370a;
1218 else
1219 info->speed = fifty_base_hpt370a;
1220 printk(KERN_DEBUG "HPT37X: using 50MHz PCI clock\n"); 1093 printk(KERN_DEBUG "HPT37X: using 50MHz PCI clock\n");
1221 } else { 1094 } else {
1222 if (info->revision >= 8) { 1095 info->speed = sixty_six_base_hpt37x;
1223 printk(KERN_ERR "HPT37x: 66MHz timings are not supported.\n");
1224 }
1225 else if (info->revision >= 5)
1226 info->speed = sixty_six_base_hpt372;
1227 else if (info->revision >= 4)
1228 info->speed = sixty_six_base_hpt370a;
1229 else
1230 info->speed = sixty_six_base_hpt370;
1231 printk(KERN_DEBUG "HPT37X: using 66MHz PCI clock\n"); 1096 printk(KERN_DEBUG "HPT37X: using 66MHz PCI clock\n");
1232 } 1097 }
1233 } 1098 }
1234 1099
1100 if (pll == F_LOW_PCI_66)
1101 info->flags |= PCI_66MHZ;
1102
1235 /* 1103 /*
1236 * only try the pll if we don't have a table for the clock 1104 * only try the pll if we don't have a table for the clock
1237 * speed that we're running at. NOTE: the internal PLL will 1105 * speed that we're running at. NOTE: the internal PLL will
@@ -1248,11 +1116,8 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif)
1248 info->flags |= PLL_MODE; 1116 info->flags |= PLL_MODE;
1249 1117
1250 /* 1118 /*
1251 * FIXME: make this work correctly, esp with 372N as per 1119 * Adjust the PLL based upon the PCI clock, enable it, and
1252 * reference driver code. 1120 * wait for stabilization...
1253 *
1254 * adjust PLL based upon PCI clock, enable it, and wait for
1255 * stabilization.
1256 */ 1121 */
1257 adjust = 0; 1122 adjust = 0;
1258 freq = (pll < F_LOW_PCI_50) ? 2 : 4; 1123 freq = (pll < F_LOW_PCI_50) ? 2 : 4;
@@ -1275,22 +1140,12 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif)
1275 pci_write_config_dword(dev, 0x5c, 1140 pci_write_config_dword(dev, 0x5c,
1276 pll & ~0x100); 1141 pll & ~0x100);
1277 pci_write_config_byte(dev, 0x5b, 0x21); 1142 pci_write_config_byte(dev, 0x5b, 0x21);
1278 if (info->revision >= 8) 1143
1279 info->speed = fifty_base_hpt370a; 1144 info->speed = fifty_base_hpt37x;
1280 else if (info->revision >= 5)
1281 info->speed = fifty_base_hpt372;
1282 else if (info->revision >= 4)
1283 info->speed = fifty_base_hpt370a;
1284 else
1285 info->speed = fifty_base_hpt370a;
1286 printk("HPT37X: using 50MHz internal PLL\n"); 1145 printk("HPT37X: using 50MHz internal PLL\n");
1287 goto init_hpt37X_done; 1146 goto init_hpt37X_done;
1288 } 1147 }
1289 } 1148 }
1290 if (!pci_get_drvdata(dev)) {
1291 printk("No Clock Stabilization!!!\n");
1292 return;
1293 }
1294pll_recal: 1149pll_recal:
1295 if (adjust & 1) 1150 if (adjust & 1)
1296 pll -= (adjust >> 1); 1151 pll -= (adjust >> 1);
@@ -1300,11 +1155,16 @@ pll_recal:
1300 1155
1301init_hpt37X_done: 1156init_hpt37X_done:
1302 if (!info->speed) 1157 if (!info->speed)
1303 printk(KERN_ERR "HPT37X%s: unknown bus timing [%d %d].\n", 1158 printk(KERN_ERR "HPT37x%s: unknown bus timing [%d %d].\n",
1304 (info->flags & IS_372N)?"N":"", pll, freq); 1159 (info->flags & IS_3xxN) ? "N" : "", pll, freq);
1305 /* reset state engine */ 1160 /*
1306 pci_write_config_byte(dev, 0x50, 0x37); 1161 * Reset the state engines.
1307 pci_write_config_byte(dev, 0x54, 0x37); 1162 * NOTE: avoid accidentally enabling the primary channel on HPT371N.
1163 */
1164 pci_read_config_byte(dev, 0x50, &mcr1);
1165 if (mcr1 & 0x04)
1166 pci_write_config_byte(dev, 0x50, 0x37);
1167 pci_write_config_byte(dev, 0x54, 0x37);
1308 udelay(100); 1168 udelay(100);
1309} 1169}
1310 1170
@@ -1367,6 +1227,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1367 struct pci_dev *dev = hwif->pci_dev; 1227 struct pci_dev *dev = hwif->pci_dev;
1368 struct hpt_info *info = ide_get_hwifdata(hwif); 1228 struct hpt_info *info = ide_get_hwifdata(hwif);
1369 u8 ata66 = 0, regmask = (hwif->channel) ? 0x01 : 0x02; 1229 u8 ata66 = 0, regmask = (hwif->channel) ? 0x01 : 0x02;
1230 int serialize = HPT_SERIALIZE_IO;
1370 1231
1371 hwif->tuneproc = &hpt3xx_tune_drive; 1232 hwif->tuneproc = &hpt3xx_tune_drive;
1372 hwif->speedproc = &hpt3xx_tune_chipset; 1233 hwif->speedproc = &hpt3xx_tune_chipset;
@@ -1374,8 +1235,20 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1374 hwif->intrproc = &hpt3xx_intrproc; 1235 hwif->intrproc = &hpt3xx_intrproc;
1375 hwif->maskproc = &hpt3xx_maskproc; 1236 hwif->maskproc = &hpt3xx_maskproc;
1376 1237
1377 if(info->flags & IS_372N) 1238 /*
1378 hwif->rw_disk = &hpt372n_rw_disk; 1239 * HPT3xxN chips have some complications:
1240 *
1241 * - on 33 MHz PCI we must clock switch
1242 * - on 66 MHz PCI we must NOT use the PCI clock
1243 */
1244 if ((info->flags & (IS_3xxN | PCI_66MHZ)) == IS_3xxN) {
1245 /*
1246 * Clock is shared between the channels,
1247 * so we'll have to serialize them... :-(
1248 */
1249 serialize = 1;
1250 hwif->rw_disk = &hpt3xxn_rw_disk;
1251 }
1379 1252
1380 /* 1253 /*
1381 * The HPT37x uses the CBLID pins as outputs for MA15/MA16 1254 * The HPT37x uses the CBLID pins as outputs for MA15/MA16
@@ -1418,29 +1291,15 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1418 PCI_FUNC(hwif->pci_dev->devfn)); 1291 PCI_FUNC(hwif->pci_dev->devfn));
1419#endif /* DEBUG */ 1292#endif /* DEBUG */
1420 1293
1421#ifdef HPT_SERIALIZE_IO 1294 /* Serialize access to this device */
1422 /* serialize access to this device */ 1295 if (serialize && hwif->mate)
1423 if (hwif->mate)
1424 hwif->serialized = hwif->mate->serialized = 1; 1296 hwif->serialized = hwif->mate->serialized = 1;
1425#endif
1426 1297
1427 if (info->revision >= 3) { 1298 /*
1428 u8 reg5ah = 0; 1299 * Set up ioctl for power status.
1429 pci_write_config_byte(dev, 0x5a, reg5ah & ~0x10); 1300 * NOTE: power affects both drives on each channel.
1430 /* 1301 */
1431 * set up ioctl for power status. 1302 hwif->busproc = &hpt3xx_busproc;
1432 * note: power affects both
1433 * drives on each channel
1434 */
1435 hwif->resetproc = &hpt3xx_reset;
1436 hwif->busproc = &hpt370_busproc;
1437 } else if (info->revision >= 2) {
1438 hwif->resetproc = &hpt3xx_reset;
1439 hwif->busproc = &hpt3xx_tristate;
1440 } else {
1441 hwif->resetproc = &hpt3xx_reset;
1442 hwif->busproc = &hpt3xx_tristate;
1443 }
1444 1303
1445 if (!hwif->dma_base) { 1304 if (!hwif->dma_base) {
1446 hwif->drives[0].autotune = 1; 1305 hwif->drives[0].autotune = 1;
@@ -1490,7 +1349,7 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase)
1490 return; 1349 return;
1491 1350
1492 if(info->speed == NULL) { 1351 if(info->speed == NULL) {
1493 printk(KERN_WARNING "hpt: no known IDE timings, disabling DMA.\n"); 1352 printk(KERN_WARNING "hpt366: no known IDE timings, disabling DMA.\n");
1494 return; 1353 return;
1495 } 1354 }
1496 1355
@@ -1519,9 +1378,10 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase)
1519 1378
1520static void __devinit init_iops_hpt366(ide_hwif_t *hwif) 1379static void __devinit init_iops_hpt366(ide_hwif_t *hwif)
1521{ 1380{
1522 struct hpt_info *info = kzalloc(sizeof(struct hpt_info), GFP_KERNEL); 1381 struct hpt_info *info = kzalloc(sizeof(struct hpt_info), GFP_KERNEL);
1523 unsigned long dmabase = pci_resource_start(hwif->pci_dev, 4); 1382 struct pci_dev *dev = hwif->pci_dev;
1524 u8 did, rid; 1383 u16 did = dev->device;
1384 u8 rid = 0;
1525 1385
1526 if(info == NULL) { 1386 if(info == NULL) {
1527 printk(KERN_WARNING "hpt366: out of memory.\n"); 1387 printk(KERN_WARNING "hpt366: out of memory.\n");
@@ -1529,15 +1389,22 @@ static void __devinit init_iops_hpt366(ide_hwif_t *hwif)
1529 } 1389 }
1530 ide_set_hwifdata(hwif, info); 1390 ide_set_hwifdata(hwif, info);
1531 1391
1532 if(dmabase) { 1392 /* Avoid doing the same thing twice. */
1533 did = inb(dmabase + 0x22); 1393 if (hwif->channel && hwif->mate) {
1534 rid = inb(dmabase + 0x28); 1394 memcpy(info, ide_get_hwifdata(hwif->mate), sizeof(struct hpt_info));
1535 1395 return;
1536 if((did == 4 && rid == 6) || (did == 5 && rid > 1))
1537 info->flags |= IS_372N;
1538 } 1396 }
1539 1397
1540 info->revision = hpt_revision(hwif->pci_dev); 1398 pci_read_config_byte(dev, PCI_CLASS_REVISION, &rid);
1399
1400 if (( did == PCI_DEVICE_ID_TTI_HPT366 && rid == 6) ||
1401 ((did == PCI_DEVICE_ID_TTI_HPT372 ||
1402 did == PCI_DEVICE_ID_TTI_HPT302 ||
1403 did == PCI_DEVICE_ID_TTI_HPT371) && rid > 1) ||
1404 did == PCI_DEVICE_ID_TTI_HPT372N)
1405 info->flags |= IS_3xxN;
1406
1407 info->revision = hpt_revision(dev);
1541 1408
1542 if (info->revision >= 3) 1409 if (info->revision >= 3)
1543 hpt37x_clocking(hwif); 1410 hpt37x_clocking(hwif);
@@ -1574,6 +1441,23 @@ static int __devinit init_setup_hpt37x(struct pci_dev *dev, ide_pci_device_t *d)
1574 return ide_setup_pci_device(dev, d); 1441 return ide_setup_pci_device(dev, d);
1575} 1442}
1576 1443
1444static int __devinit init_setup_hpt371(struct pci_dev *dev, ide_pci_device_t *d)
1445{
1446 u8 mcr1 = 0;
1447
1448 /*
1449 * HPT371 chips physically have only one channel, the secondary one,
1450 * but the primary channel registers do exist! Go figure...
1451 * So, we manually disable the non-existing channel here
1452 * (if the BIOS hasn't done this already).
1453 */
1454 pci_read_config_byte(dev, 0x50, &mcr1);
1455 if (mcr1 & 0x04)
1456 pci_write_config_byte(dev, 0x50, (mcr1 & ~0x04));
1457
1458 return ide_setup_pci_device(dev, d);
1459}
1460
1577static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) 1461static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
1578{ 1462{
1579 struct pci_dev *findev = NULL; 1463 struct pci_dev *findev = NULL;
@@ -1661,13 +1545,14 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = {
1661 .bootable = OFF_BOARD, 1545 .bootable = OFF_BOARD,
1662 },{ /* 3 */ 1546 },{ /* 3 */
1663 .name = "HPT371", 1547 .name = "HPT371",
1664 .init_setup = init_setup_hpt37x, 1548 .init_setup = init_setup_hpt371,
1665 .init_chipset = init_chipset_hpt366, 1549 .init_chipset = init_chipset_hpt366,
1666 .init_iops = init_iops_hpt366, 1550 .init_iops = init_iops_hpt366,
1667 .init_hwif = init_hwif_hpt366, 1551 .init_hwif = init_hwif_hpt366,
1668 .init_dma = init_dma_hpt366, 1552 .init_dma = init_dma_hpt366,
1669 .channels = 2, 1553 .channels = 2,
1670 .autodma = AUTODMA, 1554 .autodma = AUTODMA,
1555 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
1671 .bootable = OFF_BOARD, 1556 .bootable = OFF_BOARD,
1672 },{ /* 4 */ 1557 },{ /* 4 */
1673 .name = "HPT374", 1558 .name = "HPT374",
@@ -1699,13 +1584,16 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = {
1699 * 1584 *
1700 * Called when the PCI registration layer (or the IDE initialization) 1585 * Called when the PCI registration layer (or the IDE initialization)
1701 * finds a device matching our IDE device tables. 1586 * finds a device matching our IDE device tables.
1587 *
1588 * NOTE: since we'll have to modify some fields of the ide_pci_device_t
1589 * structure depending on the chip's revision, we'd better pass a local
1590 * copy down the call chain...
1702 */ 1591 */
1703
1704static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) 1592static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1705{ 1593{
1706 ide_pci_device_t *d = &hpt366_chipsets[id->driver_data]; 1594 ide_pci_device_t d = hpt366_chipsets[id->driver_data];
1707 1595
1708 return d->init_setup(dev, d); 1596 return d.init_setup(dev, &d);
1709} 1597}
1710 1598
1711static struct pci_device_id hpt366_pci_tbl[] = { 1599static struct pci_device_id hpt366_pci_tbl[] = {
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 0491ec7a7c0a..44bc6cc734ab 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -80,24 +80,61 @@ static int tune_pci = 0;
80module_param(tune_pci, int, 0444); 80module_param(tune_pci, int, 0444);
81MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if nonzero"); 81MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if nonzero");
82 82
83struct mutex mthca_device_mutex; 83DEFINE_MUTEX(mthca_device_mutex);
84
85#define MTHCA_DEFAULT_NUM_QP (1 << 16)
86#define MTHCA_DEFAULT_RDB_PER_QP (1 << 2)
87#define MTHCA_DEFAULT_NUM_CQ (1 << 16)
88#define MTHCA_DEFAULT_NUM_MCG (1 << 13)
89#define MTHCA_DEFAULT_NUM_MPT (1 << 17)
90#define MTHCA_DEFAULT_NUM_MTT (1 << 20)
91#define MTHCA_DEFAULT_NUM_UDAV (1 << 15)
92#define MTHCA_DEFAULT_NUM_RESERVED_MTTS (1 << 18)
93#define MTHCA_DEFAULT_NUM_UARC_SIZE (1 << 18)
94
95static struct mthca_profile hca_profile = {
96 .num_qp = MTHCA_DEFAULT_NUM_QP,
97 .rdb_per_qp = MTHCA_DEFAULT_RDB_PER_QP,
98 .num_cq = MTHCA_DEFAULT_NUM_CQ,
99 .num_mcg = MTHCA_DEFAULT_NUM_MCG,
100 .num_mpt = MTHCA_DEFAULT_NUM_MPT,
101 .num_mtt = MTHCA_DEFAULT_NUM_MTT,
102 .num_udav = MTHCA_DEFAULT_NUM_UDAV, /* Tavor only */
103 .fmr_reserved_mtts = MTHCA_DEFAULT_NUM_RESERVED_MTTS, /* Tavor only */
104 .uarc_size = MTHCA_DEFAULT_NUM_UARC_SIZE, /* Arbel only */
105};
106
107module_param_named(num_qp, hca_profile.num_qp, int, 0444);
108MODULE_PARM_DESC(num_qp, "maximum number of QPs per HCA");
109
110module_param_named(rdb_per_qp, hca_profile.rdb_per_qp, int, 0444);
111MODULE_PARM_DESC(rdb_per_qp, "number of RDB buffers per QP");
112
113module_param_named(num_cq, hca_profile.num_cq, int, 0444);
114MODULE_PARM_DESC(num_cq, "maximum number of CQs per HCA");
115
116module_param_named(num_mcg, hca_profile.num_mcg, int, 0444);
117MODULE_PARM_DESC(num_mcg, "maximum number of multicast groups per HCA");
118
119module_param_named(num_mpt, hca_profile.num_mpt, int, 0444);
120MODULE_PARM_DESC(num_mpt,
121 "maximum number of memory protection table entries per HCA");
122
123module_param_named(num_mtt, hca_profile.num_mtt, int, 0444);
124MODULE_PARM_DESC(num_mtt,
125 "maximum number of memory translation table segments per HCA");
126
127module_param_named(num_udav, hca_profile.num_udav, int, 0444);
128MODULE_PARM_DESC(num_udav, "maximum number of UD address vectors per HCA");
129
130module_param_named(fmr_reserved_mtts, hca_profile.fmr_reserved_mtts, int, 0444);
131MODULE_PARM_DESC(fmr_reserved_mtts,
132 "number of memory translation table segments reserved for FMR");
84 133
85static const char mthca_version[] __devinitdata = 134static const char mthca_version[] __devinitdata =
86 DRV_NAME ": Mellanox InfiniBand HCA driver v" 135 DRV_NAME ": Mellanox InfiniBand HCA driver v"
87 DRV_VERSION " (" DRV_RELDATE ")\n"; 136 DRV_VERSION " (" DRV_RELDATE ")\n";
88 137
89static struct mthca_profile default_profile = {
90 .num_qp = 1 << 16,
91 .rdb_per_qp = 4,
92 .num_cq = 1 << 16,
93 .num_mcg = 1 << 13,
94 .num_mpt = 1 << 17,
95 .num_mtt = 1 << 20,
96 .num_udav = 1 << 15, /* Tavor only */
97 .fmr_reserved_mtts = 1 << 18, /* Tavor only */
98 .uarc_size = 1 << 18, /* Arbel only */
99};
100
101static int mthca_tune_pci(struct mthca_dev *mdev) 138static int mthca_tune_pci(struct mthca_dev *mdev)
102{ 139{
103 int cap; 140 int cap;
@@ -303,7 +340,7 @@ static int mthca_init_tavor(struct mthca_dev *mdev)
303 goto err_disable; 340 goto err_disable;
304 } 341 }
305 342
306 profile = default_profile; 343 profile = hca_profile;
307 profile.num_uar = dev_lim.uar_size / PAGE_SIZE; 344 profile.num_uar = dev_lim.uar_size / PAGE_SIZE;
308 profile.uarc_size = 0; 345 profile.uarc_size = 0;
309 if (mdev->mthca_flags & MTHCA_FLAG_SRQ) 346 if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
@@ -621,7 +658,7 @@ static int mthca_init_arbel(struct mthca_dev *mdev)
621 goto err_stop_fw; 658 goto err_stop_fw;
622 } 659 }
623 660
624 profile = default_profile; 661 profile = hca_profile;
625 profile.num_uar = dev_lim.uar_size / PAGE_SIZE; 662 profile.num_uar = dev_lim.uar_size / PAGE_SIZE;
626 profile.num_udav = 0; 663 profile.num_udav = 0;
627 if (mdev->mthca_flags & MTHCA_FLAG_SRQ) 664 if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
@@ -1278,11 +1315,55 @@ static struct pci_driver mthca_driver = {
1278 .remove = __devexit_p(mthca_remove_one) 1315 .remove = __devexit_p(mthca_remove_one)
1279}; 1316};
1280 1317
1318static void __init __mthca_check_profile_val(const char *name, int *pval,
1319 int pval_default)
1320{
1321 /* value must be positive and power of 2 */
1322 int old_pval = *pval;
1323
1324 if (old_pval <= 0)
1325 *pval = pval_default;
1326 else
1327 *pval = roundup_pow_of_two(old_pval);
1328
1329 if (old_pval != *pval) {
1330 printk(KERN_WARNING PFX "Invalid value %d for %s in module parameter.\n",
1331 old_pval, name);
1332 printk(KERN_WARNING PFX "Corrected %s to %d.\n", name, *pval);
1333 }
1334}
1335
1336#define mthca_check_profile_val(name, default) \
1337 __mthca_check_profile_val(#name, &hca_profile.name, default)
1338
1339static void __init mthca_validate_profile(void)
1340{
1341 mthca_check_profile_val(num_qp, MTHCA_DEFAULT_NUM_QP);
1342 mthca_check_profile_val(rdb_per_qp, MTHCA_DEFAULT_RDB_PER_QP);
1343 mthca_check_profile_val(num_cq, MTHCA_DEFAULT_NUM_CQ);
1344 mthca_check_profile_val(num_mcg, MTHCA_DEFAULT_NUM_MCG);
1345 mthca_check_profile_val(num_mpt, MTHCA_DEFAULT_NUM_MPT);
1346 mthca_check_profile_val(num_mtt, MTHCA_DEFAULT_NUM_MTT);
1347 mthca_check_profile_val(num_udav, MTHCA_DEFAULT_NUM_UDAV);
1348 mthca_check_profile_val(fmr_reserved_mtts, MTHCA_DEFAULT_NUM_RESERVED_MTTS);
1349
1350 if (hca_profile.fmr_reserved_mtts >= hca_profile.num_mtt) {
1351 printk(KERN_WARNING PFX "Invalid fmr_reserved_mtts module parameter %d.\n",
1352 hca_profile.fmr_reserved_mtts);
1353 printk(KERN_WARNING PFX "(Must be smaller than num_mtt %d)\n",
1354 hca_profile.num_mtt);
1355 hca_profile.fmr_reserved_mtts = hca_profile.num_mtt / 2;
1356 printk(KERN_WARNING PFX "Corrected fmr_reserved_mtts to %d.\n",
1357 hca_profile.fmr_reserved_mtts);
1358 }
1359}
1360
1281static int __init mthca_init(void) 1361static int __init mthca_init(void)
1282{ 1362{
1283 int ret; 1363 int ret;
1284 1364
1285 mutex_init(&mthca_device_mutex); 1365 mthca_validate_profile();
1366
1286 ret = mthca_catas_init(); 1367 ret = mthca_catas_init();
1287 if (ret) 1368 if (ret)
1288 return ret; 1369 return ret;
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index e9b6a6f07dd7..cdecbf5911c8 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1898,7 +1898,7 @@ static void srp_add_one(struct ib_device *device)
1898 */ 1898 */
1899 srp_dev->fmr_page_shift = max(9, ffs(dev_attr->page_size_cap) - 1); 1899 srp_dev->fmr_page_shift = max(9, ffs(dev_attr->page_size_cap) - 1);
1900 srp_dev->fmr_page_size = 1 << srp_dev->fmr_page_shift; 1900 srp_dev->fmr_page_size = 1 << srp_dev->fmr_page_shift;
1901 srp_dev->fmr_page_mask = ~((unsigned long) srp_dev->fmr_page_size - 1); 1901 srp_dev->fmr_page_mask = ~((u64) srp_dev->fmr_page_size - 1);
1902 1902
1903 INIT_LIST_HEAD(&srp_dev->dev_list); 1903 INIT_LIST_HEAD(&srp_dev->dev_list);
1904 1904
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 868a540ef7cd..c21772317b86 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -87,7 +87,7 @@ struct srp_device {
87 struct ib_fmr_pool *fmr_pool; 87 struct ib_fmr_pool *fmr_pool;
88 int fmr_page_shift; 88 int fmr_page_shift;
89 int fmr_page_size; 89 int fmr_page_size;
90 unsigned long fmr_page_mask; 90 u64 fmr_page_mask;
91}; 91};
92 92
93struct srp_host { 93struct srp_host {
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c
index 16583d71753b..c67e84ec2d6a 100644
--- a/drivers/input/keyboard/amikbd.c
+++ b/drivers/input/keyboard/amikbd.c
@@ -187,7 +187,7 @@ static irqreturn_t amikbd_interrupt(int irq, void *dummy)
187 187
188static int __init amikbd_init(void) 188static int __init amikbd_init(void)
189{ 189{
190 int i, j; 190 int i, j, err;
191 191
192 if (!AMIGAHW_PRESENT(AMI_KEYBOARD)) 192 if (!AMIGAHW_PRESENT(AMI_KEYBOARD))
193 return -ENODEV; 193 return -ENODEV;
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c
index 54bc569db4b0..35461eab2faf 100644
--- a/drivers/input/keyboard/hilkbd.c
+++ b/drivers/input/keyboard/hilkbd.c
@@ -23,7 +23,12 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/hil.h> 25#include <linux/hil.h>
26#include <linux/io.h>
26#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <asm/irq.h>
29#ifdef CONFIG_HP300
30#include <asm/hwtest.h>
31#endif
27 32
28 33
29MODULE_AUTHOR("Philip Blundell, Matthew Wilcox, Helge Deller"); 34MODULE_AUTHOR("Philip Blundell, Matthew Wilcox, Helge Deller");
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
index 3826db9403e6..cc0238366414 100644
--- a/drivers/input/keyboard/sunkbd.c
+++ b/drivers/input/keyboard/sunkbd.c
@@ -225,7 +225,7 @@ static void sunkbd_reinit(struct work_struct *work)
225static void sunkbd_enable(struct sunkbd *sunkbd, int enable) 225static void sunkbd_enable(struct sunkbd *sunkbd, int enable)
226{ 226{
227 serio_pause_rx(sunkbd->serio); 227 serio_pause_rx(sunkbd->serio);
228 sunkbd->enabled = 1; 228 sunkbd->enabled = enable;
229 serio_continue_rx(sunkbd->serio); 229 serio_continue_rx(sunkbd->serio);
230} 230}
231 231
diff --git a/drivers/isdn/act2000/act2000_isa.c b/drivers/isdn/act2000/act2000_isa.c
index 3cac23739344..09ea50dd3459 100644
--- a/drivers/isdn/act2000/act2000_isa.c
+++ b/drivers/isdn/act2000/act2000_isa.c
@@ -408,7 +408,7 @@ act2000_isa_download(act2000_card * card, act2000_ddef __user * cb)
408 p = cblock.buffer; 408 p = cblock.buffer;
409 if (!access_ok(VERIFY_READ, p, length)) 409 if (!access_ok(VERIFY_READ, p, length))
410 return -EFAULT; 410 return -EFAULT;
411 buf = (u_char *) kmalloc(1024, GFP_KERNEL); 411 buf = kmalloc(1024, GFP_KERNEL);
412 if (!buf) 412 if (!buf)
413 return -ENOMEM; 413 return -ENOMEM;
414 timeout = 0; 414 timeout = 0;
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c
index 097bfa7bc323..c4d438c17dab 100644
--- a/drivers/isdn/capi/capidrv.c
+++ b/drivers/isdn/capi/capidrv.c
@@ -2013,7 +2013,7 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)
2013 strcpy(card->name, id); 2013 strcpy(card->name, id);
2014 card->contrnr = contr; 2014 card->contrnr = contr;
2015 card->nbchan = profp->nbchannel; 2015 card->nbchan = profp->nbchannel;
2016 card->bchans = (capidrv_bchan *) kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC); 2016 card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC);
2017 if (!card->bchans) { 2017 if (!card->bchans) {
2018 printk(KERN_WARNING 2018 printk(KERN_WARNING
2019 "capidrv: (%s) Could not allocate bchan-structs.\n", id); 2019 "capidrv: (%s) Could not allocate bchan-structs.\n", id);
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
index 399b316111f7..06967da7c4a8 100644
--- a/drivers/isdn/divert/divert_procfs.c
+++ b/drivers/isdn/divert/divert_procfs.c
@@ -45,7 +45,7 @@ put_info_buffer(char *cp)
45 return; 45 return;
46 if (!*cp) 46 if (!*cp)
47 return; 47 return;
48 if (!(ib = (struct divert_info *) kmalloc(sizeof(struct divert_info) + strlen(cp), GFP_ATOMIC))) 48 if (!(ib = kmalloc(sizeof(struct divert_info) + strlen(cp), GFP_ATOMIC)))
49 return; /* no memory */ 49 return; /* no memory */
50 strcpy(ib->info_start, cp); /* set output string */ 50 strcpy(ib->info_start, cp); /* set output string */
51 ib->next = NULL; 51 ib->next = NULL;
diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c
index 03319ea5aa0c..7d97d54588d9 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -153,7 +153,7 @@ int cf_command(int drvid, int mode,
153 *ielenp = p - ielenp - 1; /* set total IE length */ 153 *ielenp = p - ielenp - 1; /* set total IE length */
154 154
155 /* allocate mem for information struct */ 155 /* allocate mem for information struct */
156 if (!(cs = (struct call_struc *) kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) 156 if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
157 return(-ENOMEM); /* no memory */ 157 return(-ENOMEM); /* no memory */
158 init_timer(&cs->timer); 158 init_timer(&cs->timer);
159 cs->info[0] = '\0'; 159 cs->info[0] = '\0';
@@ -276,7 +276,7 @@ int insertrule(int idx, divert_rule *newrule)
276{ struct deflect_struc *ds,*ds1=NULL; 276{ struct deflect_struc *ds,*ds1=NULL;
277 unsigned long flags; 277 unsigned long flags;
278 278
279 if (!(ds = (struct deflect_struc *) kmalloc(sizeof(struct deflect_struc), 279 if (!(ds = kmalloc(sizeof(struct deflect_struc),
280 GFP_KERNEL))) 280 GFP_KERNEL)))
281 return(-ENOMEM); /* no memory */ 281 return(-ENOMEM); /* no memory */
282 282
@@ -451,7 +451,7 @@ static int isdn_divert_icall(isdn_ctrl *ic)
451 if (dv->rule.action == DEFLECT_PROCEED) 451 if (dv->rule.action == DEFLECT_PROCEED)
452 if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime))) 452 if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime)))
453 return(0); /* no external deflection needed */ 453 return(0); /* no external deflection needed */
454 if (!(cs = (struct call_struc *) kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) 454 if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
455 return(0); /* no memory */ 455 return(0); /* no memory */
456 init_timer(&cs->timer); 456 init_timer(&cs->timer);
457 cs->info[0] = '\0'; 457 cs->info[0] = '\0';
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 63b629b1cdb2..b5e7f9c7d74e 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -1853,20 +1853,24 @@ static int gigaset_write_cmd(struct cardstate *cs,
1853{ 1853{
1854 struct cmdbuf_t *cb; 1854 struct cmdbuf_t *cb;
1855 unsigned long flags; 1855 unsigned long flags;
1856 int status; 1856 int rc;
1857 1857
1858 gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ? 1858 gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ?
1859 DEBUG_TRANSCMD : DEBUG_LOCKCMD, 1859 DEBUG_TRANSCMD : DEBUG_LOCKCMD,
1860 "CMD Transmit", len, buf); 1860 "CMD Transmit", len, buf);
1861 1861
1862 if (len <= 0) 1862 if (len <= 0) {
1863 return 0; /* nothing to do */ 1863 /* nothing to do */
1864 rc = 0;
1865 goto notqueued;
1866 }
1864 1867
1865 if (len > IF_WRITEBUF) 1868 if (len > IF_WRITEBUF)
1866 len = IF_WRITEBUF; 1869 len = IF_WRITEBUF;
1867 if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { 1870 if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) {
1868 dev_err(cs->dev, "%s: out of memory\n", __func__); 1871 dev_err(cs->dev, "%s: out of memory\n", __func__);
1869 return -ENOMEM; 1872 rc = -ENOMEM;
1873 goto notqueued;
1870 } 1874 }
1871 1875
1872 memcpy(cb->buf, buf, len); 1876 memcpy(cb->buf, buf, len);
@@ -1891,11 +1895,21 @@ static int gigaset_write_cmd(struct cardstate *cs,
1891 if (unlikely(!cs->connected)) { 1895 if (unlikely(!cs->connected)) {
1892 spin_unlock_irqrestore(&cs->lock, flags); 1896 spin_unlock_irqrestore(&cs->lock, flags);
1893 gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__); 1897 gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__);
1898 /* flush command queue */
1899 spin_lock_irqsave(&cs->cmdlock, flags);
1900 while (cs->cmdbuf != NULL)
1901 complete_cb(cs);
1902 spin_unlock_irqrestore(&cs->cmdlock, flags);
1894 return -ENODEV; 1903 return -ENODEV;
1895 } 1904 }
1896 status = start_cbsend(cs); 1905 rc = start_cbsend(cs);
1897 spin_unlock_irqrestore(&cs->lock, flags); 1906 spin_unlock_irqrestore(&cs->lock, flags);
1898 return status < 0 ? status : len; 1907 return rc < 0 ? rc : len;
1908
1909notqueued: /* request handled without queuing */
1910 if (wake_tasklet)
1911 tasklet_schedule(wake_tasklet);
1912 return rc;
1899} 1913}
1900 1914
1901/* gigaset_write_room 1915/* gigaset_write_room
@@ -1964,20 +1978,15 @@ static int gigaset_freebcshw(struct bc_state *bcs)
1964 1978
1965 /* kill URBs and tasklets before freeing - better safe than sorry */ 1979 /* kill URBs and tasklets before freeing - better safe than sorry */
1966 atomic_set(&ubc->running, 0); 1980 atomic_set(&ubc->running, 0);
1967 for (i = 0; i < BAS_OUTURBS; ++i) 1981 gig_dbg(DEBUG_INIT, "%s: killing iso URBs", __func__);
1968 if (ubc->isoouturbs[i].urb) { 1982 for (i = 0; i < BAS_OUTURBS; ++i) {
1969 gig_dbg(DEBUG_INIT, "%s: killing iso out URB %d", 1983 usb_kill_urb(ubc->isoouturbs[i].urb);
1970 __func__, i); 1984 usb_free_urb(ubc->isoouturbs[i].urb);
1971 usb_kill_urb(ubc->isoouturbs[i].urb); 1985 }
1972 usb_free_urb(ubc->isoouturbs[i].urb); 1986 for (i = 0; i < BAS_INURBS; ++i) {
1973 } 1987 usb_kill_urb(ubc->isoinurbs[i]);
1974 for (i = 0; i < BAS_INURBS; ++i) 1988 usb_free_urb(ubc->isoinurbs[i]);
1975 if (ubc->isoinurbs[i]) { 1989 }
1976 gig_dbg(DEBUG_INIT, "%s: killing iso in URB %d",
1977 __func__, i);
1978 usb_kill_urb(ubc->isoinurbs[i]);
1979 usb_free_urb(ubc->isoinurbs[i]);
1980 }
1981 tasklet_kill(&ubc->sent_tasklet); 1990 tasklet_kill(&ubc->sent_tasklet);
1982 tasklet_kill(&ubc->rcvd_tasklet); 1991 tasklet_kill(&ubc->rcvd_tasklet);
1983 kfree(ubc->isooutbuf); 1992 kfree(ubc->isooutbuf);
@@ -2099,55 +2108,32 @@ static void freeurbs(struct cardstate *cs)
2099 struct bas_bc_state *ubc; 2108 struct bas_bc_state *ubc;
2100 int i, j; 2109 int i, j;
2101 2110
2111 gig_dbg(DEBUG_INIT, "%s: killing URBs", __func__);
2102 for (j = 0; j < 2; ++j) { 2112 for (j = 0; j < 2; ++j) {
2103 ubc = cs->bcs[j].hw.bas; 2113 ubc = cs->bcs[j].hw.bas;
2104 for (i = 0; i < BAS_OUTURBS; ++i) 2114 for (i = 0; i < BAS_OUTURBS; ++i) {
2105 if (ubc->isoouturbs[i].urb) { 2115 usb_kill_urb(ubc->isoouturbs[i].urb);
2106 usb_kill_urb(ubc->isoouturbs[i].urb); 2116 usb_free_urb(ubc->isoouturbs[i].urb);
2107 gig_dbg(DEBUG_INIT, 2117 ubc->isoouturbs[i].urb = NULL;
2108 "%s: isoc output URB %d/%d unlinked", 2118 }
2109 __func__, j, i); 2119 for (i = 0; i < BAS_INURBS; ++i) {
2110 usb_free_urb(ubc->isoouturbs[i].urb); 2120 usb_kill_urb(ubc->isoinurbs[i]);
2111 ubc->isoouturbs[i].urb = NULL; 2121 usb_free_urb(ubc->isoinurbs[i]);
2112 } 2122 ubc->isoinurbs[i] = NULL;
2113 for (i = 0; i < BAS_INURBS; ++i) 2123 }
2114 if (ubc->isoinurbs[i]) {
2115 usb_kill_urb(ubc->isoinurbs[i]);
2116 gig_dbg(DEBUG_INIT,
2117 "%s: isoc input URB %d/%d unlinked",
2118 __func__, j, i);
2119 usb_free_urb(ubc->isoinurbs[i]);
2120 ubc->isoinurbs[i] = NULL;
2121 }
2122 }
2123 if (ucs->urb_int_in) {
2124 usb_kill_urb(ucs->urb_int_in);
2125 gig_dbg(DEBUG_INIT, "%s: interrupt input URB unlinked",
2126 __func__);
2127 usb_free_urb(ucs->urb_int_in);
2128 ucs->urb_int_in = NULL;
2129 }
2130 if (ucs->urb_cmd_out) {
2131 usb_kill_urb(ucs->urb_cmd_out);
2132 gig_dbg(DEBUG_INIT, "%s: command output URB unlinked",
2133 __func__);
2134 usb_free_urb(ucs->urb_cmd_out);
2135 ucs->urb_cmd_out = NULL;
2136 }
2137 if (ucs->urb_cmd_in) {
2138 usb_kill_urb(ucs->urb_cmd_in);
2139 gig_dbg(DEBUG_INIT, "%s: command input URB unlinked",
2140 __func__);
2141 usb_free_urb(ucs->urb_cmd_in);
2142 ucs->urb_cmd_in = NULL;
2143 }
2144 if (ucs->urb_ctrl) {
2145 usb_kill_urb(ucs->urb_ctrl);
2146 gig_dbg(DEBUG_INIT, "%s: control output URB unlinked",
2147 __func__);
2148 usb_free_urb(ucs->urb_ctrl);
2149 ucs->urb_ctrl = NULL;
2150 } 2124 }
2125 usb_kill_urb(ucs->urb_int_in);
2126 usb_free_urb(ucs->urb_int_in);
2127 ucs->urb_int_in = NULL;
2128 usb_kill_urb(ucs->urb_cmd_out);
2129 usb_free_urb(ucs->urb_cmd_out);
2130 ucs->urb_cmd_out = NULL;
2131 usb_kill_urb(ucs->urb_cmd_in);
2132 usb_free_urb(ucs->urb_cmd_in);
2133 ucs->urb_cmd_in = NULL;
2134 usb_kill_urb(ucs->urb_ctrl);
2135 usb_free_urb(ucs->urb_ctrl);
2136 ucs->urb_ctrl = NULL;
2151} 2137}
2152 2138
2153/* gigaset_probe 2139/* gigaset_probe
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
index 8e2b03889f3c..94a935089119 100644
--- a/drivers/isdn/hysdn/hysdn_procconf.c
+++ b/drivers/isdn/hysdn/hysdn_procconf.c
@@ -275,7 +275,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep)
275 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { 275 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
276 /* read access -> output card info data */ 276 /* read access -> output card info data */
277 277
278 if (!(tmp = (char *) kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) { 278 if (!(tmp = kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) {
279 unlock_kernel(); 279 unlock_kernel();
280 return (-EFAULT); /* out of memory */ 280 return (-EFAULT); /* out of memory */
281 } 281 }
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index f241f5e551cb..375d956884d7 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -111,7 +111,7 @@ put_log_buffer(hysdn_card * card, char *cp)
111 if (pd->if_used <= 0) 111 if (pd->if_used <= 0)
112 return; /* no open file for read */ 112 return; /* no open file for read */
113 113
114 if (!(ib = (struct log_data *) kmalloc(sizeof(struct log_data) + strlen(cp), GFP_ATOMIC))) 114 if (!(ib = kmalloc(sizeof(struct log_data) + strlen(cp), GFP_ATOMIC)))
115 return; /* no memory */ 115 return; /* no memory */
116 strcpy(ib->log_start, cp); /* set output string */ 116 strcpy(ib->log_start, cp); /* set output string */
117 ib->next = NULL; 117 ib->next = NULL;
diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c
index 2cc56d6a9fae..fb350c567c6b 100644
--- a/drivers/isdn/i4l/isdn_audio.c
+++ b/drivers/isdn/i4l/isdn_audio.c
@@ -328,7 +328,7 @@ adpcm_state *
328isdn_audio_adpcm_init(adpcm_state * s, int nbits) 328isdn_audio_adpcm_init(adpcm_state * s, int nbits)
329{ 329{
330 if (!s) 330 if (!s)
331 s = (adpcm_state *) kmalloc(sizeof(adpcm_state), GFP_ATOMIC); 331 s = kmalloc(sizeof(adpcm_state), GFP_ATOMIC);
332 if (s) { 332 if (s) {
333 s->a = 0; 333 s->a = 0;
334 s->d = 5; 334 s->d = 5;
@@ -343,7 +343,7 @@ dtmf_state *
343isdn_audio_dtmf_init(dtmf_state * s) 343isdn_audio_dtmf_init(dtmf_state * s)
344{ 344{
345 if (!s) 345 if (!s)
346 s = (dtmf_state *) kmalloc(sizeof(dtmf_state), GFP_ATOMIC); 346 s = kmalloc(sizeof(dtmf_state), GFP_ATOMIC);
347 if (s) { 347 if (s) {
348 s->idx = 0; 348 s->idx = 0;
349 s->last = ' '; 349 s->last = ' ';
@@ -621,7 +621,7 @@ silence_state *
621isdn_audio_silence_init(silence_state * s) 621isdn_audio_silence_init(silence_state * s)
622{ 622{
623 if (!s) 623 if (!s)
624 s = (silence_state *) kmalloc(sizeof(silence_state), GFP_ATOMIC); 624 s = kmalloc(sizeof(silence_state), GFP_ATOMIC);
625 if (s) { 625 if (s) {
626 s->idx = 0; 626 s->idx = 0;
627 s->state = 0; 627 s->state = 0;
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index c36c817578cb..838b3734e2b6 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -2948,7 +2948,7 @@ isdn_net_addphone(isdn_net_ioctl_phone * phone)
2948 isdn_net_phone *n; 2948 isdn_net_phone *n;
2949 2949
2950 if (p) { 2950 if (p) {
2951 if (!(n = (isdn_net_phone *) kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) 2951 if (!(n = kmalloc(sizeof(isdn_net_phone), GFP_KERNEL)))
2952 return -ENOMEM; 2952 return -ENOMEM;
2953 strcpy(n->num, phone->phone); 2953 strcpy(n->num, phone->phone);
2954 n->next = p->local->phone[phone->outgoing & 1]; 2954 n->next = p->local->phone[phone->outgoing & 1];
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 43811795b46b..1726131b20be 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -717,7 +717,7 @@ isdn_ppp_fill_rq(unsigned char *buf, int len, int proto, int slot)
717 printk(KERN_DEBUG "ippp: device not activated.\n"); 717 printk(KERN_DEBUG "ippp: device not activated.\n");
718 return 0; 718 return 0;
719 } 719 }
720 nbuf = (unsigned char *) kmalloc(len + 4, GFP_ATOMIC); 720 nbuf = kmalloc(len + 4, GFP_ATOMIC);
721 if (!nbuf) { 721 if (!nbuf) {
722 printk(KERN_WARNING "ippp: Can't alloc buf\n"); 722 printk(KERN_WARNING "ippp: Can't alloc buf\n");
723 return 0; 723 return 0;
diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c
index 6ff85574e941..eafcce5e656a 100644
--- a/drivers/isdn/pcbit/layer2.c
+++ b/drivers/isdn/pcbit/layer2.c
@@ -100,7 +100,7 @@ pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum,
100 dev_kfree_skb(skb); 100 dev_kfree_skb(skb);
101 return -1; 101 return -1;
102 } 102 }
103 if ((frame = (struct frame_buf *) kmalloc(sizeof(struct frame_buf), 103 if ((frame = kmalloc(sizeof(struct frame_buf),
104 GFP_ATOMIC)) == NULL) { 104 GFP_ATOMIC)) == NULL) {
105 printk(KERN_WARNING "pcbit_2_write: kmalloc failed\n"); 105 printk(KERN_WARNING "pcbit_2_write: kmalloc failed\n");
106 dev_kfree_skb(skb); 106 dev_kfree_skb(skb);
diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index 36412e90f09b..703cc88d1ef9 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -1,6 +1,8 @@
1# 1#
2# KVM configuration 2# KVM configuration
3# 3#
4menu "Virtualization"
5
4config KVM 6config KVM
5 tristate "Kernel-based Virtual Machine (KVM) support" 7 tristate "Kernel-based Virtual Machine (KVM) support"
6 depends on X86 && EXPERIMENTAL 8 depends on X86 && EXPERIMENTAL
@@ -31,3 +33,5 @@ config KVM_AMD
31 ---help--- 33 ---help---
32 Provides support for KVM on AMD processors equipped with the AMD-V 34 Provides support for KVM on AMD processors equipped with the AMD-V
33 (SVM) extensions. 35 (SVM) extensions.
36
37endmenu
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 5785d0870ab6..930e04ce1af6 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -140,7 +140,7 @@ enum {
140 VCPU_REGS_RBP = 5, 140 VCPU_REGS_RBP = 5,
141 VCPU_REGS_RSI = 6, 141 VCPU_REGS_RSI = 6,
142 VCPU_REGS_RDI = 7, 142 VCPU_REGS_RDI = 7,
143#ifdef __x86_64__ 143#ifdef CONFIG_X86_64
144 VCPU_REGS_R8 = 8, 144 VCPU_REGS_R8 = 8,
145 VCPU_REGS_R9 = 9, 145 VCPU_REGS_R9 = 9,
146 VCPU_REGS_R10 = 10, 146 VCPU_REGS_R10 = 10,
@@ -375,7 +375,7 @@ void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr0);
375void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr0); 375void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr0);
376void lmsw(struct kvm_vcpu *vcpu, unsigned long msw); 376void lmsw(struct kvm_vcpu *vcpu, unsigned long msw);
377 377
378#ifdef __x86_64__ 378#ifdef CONFIG_X86_64
379void set_efer(struct kvm_vcpu *vcpu, u64 efer); 379void set_efer(struct kvm_vcpu *vcpu, u64 efer);
380#endif 380#endif
381 381
@@ -485,7 +485,7 @@ static inline unsigned long read_tr_base(void)
485 return segment_base(tr); 485 return segment_base(tr);
486} 486}
487 487
488#ifdef __x86_64__ 488#ifdef CONFIG_X86_64
489static inline unsigned long read_msr(unsigned long msr) 489static inline unsigned long read_msr(unsigned long msr)
490{ 490{
491 u64 value; 491 u64 value;
@@ -533,7 +533,7 @@ static inline u32 get_rdx_init_val(void)
533#define TSS_REDIRECTION_SIZE (256 / 8) 533#define TSS_REDIRECTION_SIZE (256 / 8)
534#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1) 534#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
535 535
536#ifdef __x86_64__ 536#ifdef CONFIG_X86_64
537 537
538/* 538/*
539 * When emulating 32-bit mode, cr3 is only 32 bits even on x86_64. Therefore 539 * When emulating 32-bit mode, cr3 is only 32 bits even on x86_64. Therefore
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index b6b8a41b5ec8..fd1bb870545c 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -72,18 +72,7 @@ static struct dentry *debugfs_dir;
72#define CR8_RESEVED_BITS (~0x0fULL) 72#define CR8_RESEVED_BITS (~0x0fULL)
73#define EFER_RESERVED_BITS 0xfffffffffffff2fe 73#define EFER_RESERVED_BITS 0xfffffffffffff2fe
74 74
75struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr) 75#ifdef CONFIG_X86_64
76{
77 int i;
78
79 for (i = 0; i < vcpu->nmsrs; ++i)
80 if (vcpu->guest_msrs[i].index == msr)
81 return &vcpu->guest_msrs[i];
82 return 0;
83}
84EXPORT_SYMBOL_GPL(find_msr_entry);
85
86#ifdef __x86_64__
87// LDT or TSS descriptor in the GDT. 16 bytes. 76// LDT or TSS descriptor in the GDT. 16 bytes.
88struct segment_descriptor_64 { 77struct segment_descriptor_64 {
89 struct segment_descriptor s; 78 struct segment_descriptor s;
@@ -115,7 +104,7 @@ unsigned long segment_base(u16 selector)
115 } 104 }
116 d = (struct segment_descriptor *)(table_base + (selector & ~7)); 105 d = (struct segment_descriptor *)(table_base + (selector & ~7));
117 v = d->base_low | ((ul)d->base_mid << 16) | ((ul)d->base_high << 24); 106 v = d->base_low | ((ul)d->base_mid << 16) | ((ul)d->base_high << 24);
118#ifdef __x86_64__ 107#ifdef CONFIG_X86_64
119 if (d->system == 0 108 if (d->system == 0
120 && (d->type == 2 || d->type == 9 || d->type == 11)) 109 && (d->type == 2 || d->type == 9 || d->type == 11))
121 v |= ((ul)((struct segment_descriptor_64 *)d)->base_higher) << 32; 110 v |= ((ul)((struct segment_descriptor_64 *)d)->base_higher) << 32;
@@ -216,7 +205,6 @@ static struct kvm_vcpu *vcpu_load(struct kvm *kvm, int vcpu_slot)
216static void vcpu_put(struct kvm_vcpu *vcpu) 205static void vcpu_put(struct kvm_vcpu *vcpu)
217{ 206{
218 kvm_arch_ops->vcpu_put(vcpu); 207 kvm_arch_ops->vcpu_put(vcpu);
219 put_cpu();
220 mutex_unlock(&vcpu->mutex); 208 mutex_unlock(&vcpu->mutex);
221} 209}
222 210
@@ -351,7 +339,7 @@ void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
351 } 339 }
352 340
353 if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) { 341 if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) {
354#ifdef __x86_64__ 342#ifdef CONFIG_X86_64
355 if ((vcpu->shadow_efer & EFER_LME)) { 343 if ((vcpu->shadow_efer & EFER_LME)) {
356 int cs_db, cs_l; 344 int cs_db, cs_l;
357 345
@@ -1120,12 +1108,10 @@ static int get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
1120 return kvm_arch_ops->get_msr(vcpu, msr_index, pdata); 1108 return kvm_arch_ops->get_msr(vcpu, msr_index, pdata);
1121} 1109}
1122 1110
1123#ifdef __x86_64__ 1111#ifdef CONFIG_X86_64
1124 1112
1125void set_efer(struct kvm_vcpu *vcpu, u64 efer) 1113void set_efer(struct kvm_vcpu *vcpu, u64 efer)
1126{ 1114{
1127 struct vmx_msr_entry *msr;
1128
1129 if (efer & EFER_RESERVED_BITS) { 1115 if (efer & EFER_RESERVED_BITS) {
1130 printk(KERN_DEBUG "set_efer: 0x%llx #GP, reserved bits\n", 1116 printk(KERN_DEBUG "set_efer: 0x%llx #GP, reserved bits\n",
1131 efer); 1117 efer);
@@ -1140,16 +1126,12 @@ void set_efer(struct kvm_vcpu *vcpu, u64 efer)
1140 return; 1126 return;
1141 } 1127 }
1142 1128
1129 kvm_arch_ops->set_efer(vcpu, efer);
1130
1143 efer &= ~EFER_LMA; 1131 efer &= ~EFER_LMA;
1144 efer |= vcpu->shadow_efer & EFER_LMA; 1132 efer |= vcpu->shadow_efer & EFER_LMA;
1145 1133
1146 vcpu->shadow_efer = efer; 1134 vcpu->shadow_efer = efer;
1147
1148 msr = find_msr_entry(vcpu, MSR_EFER);
1149
1150 if (!(efer & EFER_LMA))
1151 efer &= ~EFER_LME;
1152 msr->data = efer;
1153} 1135}
1154EXPORT_SYMBOL_GPL(set_efer); 1136EXPORT_SYMBOL_GPL(set_efer);
1155 1137
@@ -1243,7 +1225,7 @@ static int kvm_dev_ioctl_get_regs(struct kvm *kvm, struct kvm_regs *regs)
1243 regs->rdi = vcpu->regs[VCPU_REGS_RDI]; 1225 regs->rdi = vcpu->regs[VCPU_REGS_RDI];
1244 regs->rsp = vcpu->regs[VCPU_REGS_RSP]; 1226 regs->rsp = vcpu->regs[VCPU_REGS_RSP];
1245 regs->rbp = vcpu->regs[VCPU_REGS_RBP]; 1227 regs->rbp = vcpu->regs[VCPU_REGS_RBP];
1246#ifdef __x86_64__ 1228#ifdef CONFIG_X86_64
1247 regs->r8 = vcpu->regs[VCPU_REGS_R8]; 1229 regs->r8 = vcpu->regs[VCPU_REGS_R8];
1248 regs->r9 = vcpu->regs[VCPU_REGS_R9]; 1230 regs->r9 = vcpu->regs[VCPU_REGS_R9];
1249 regs->r10 = vcpu->regs[VCPU_REGS_R10]; 1231 regs->r10 = vcpu->regs[VCPU_REGS_R10];
@@ -1287,7 +1269,7 @@ static int kvm_dev_ioctl_set_regs(struct kvm *kvm, struct kvm_regs *regs)
1287 vcpu->regs[VCPU_REGS_RDI] = regs->rdi; 1269 vcpu->regs[VCPU_REGS_RDI] = regs->rdi;
1288 vcpu->regs[VCPU_REGS_RSP] = regs->rsp; 1270 vcpu->regs[VCPU_REGS_RSP] = regs->rsp;
1289 vcpu->regs[VCPU_REGS_RBP] = regs->rbp; 1271 vcpu->regs[VCPU_REGS_RBP] = regs->rbp;
1290#ifdef __x86_64__ 1272#ifdef CONFIG_X86_64
1291 vcpu->regs[VCPU_REGS_R8] = regs->r8; 1273 vcpu->regs[VCPU_REGS_R8] = regs->r8;
1292 vcpu->regs[VCPU_REGS_R9] = regs->r9; 1274 vcpu->regs[VCPU_REGS_R9] = regs->r9;
1293 vcpu->regs[VCPU_REGS_R10] = regs->r10; 1275 vcpu->regs[VCPU_REGS_R10] = regs->r10;
@@ -1401,7 +1383,7 @@ static int kvm_dev_ioctl_set_sregs(struct kvm *kvm, struct kvm_sregs *sregs)
1401 vcpu->cr8 = sregs->cr8; 1383 vcpu->cr8 = sregs->cr8;
1402 1384
1403 mmu_reset_needed |= vcpu->shadow_efer != sregs->efer; 1385 mmu_reset_needed |= vcpu->shadow_efer != sregs->efer;
1404#ifdef __x86_64__ 1386#ifdef CONFIG_X86_64
1405 kvm_arch_ops->set_efer(vcpu, sregs->efer); 1387 kvm_arch_ops->set_efer(vcpu, sregs->efer);
1406#endif 1388#endif
1407 vcpu->apic_base = sregs->apic_base; 1389 vcpu->apic_base = sregs->apic_base;
@@ -1434,7 +1416,7 @@ static int kvm_dev_ioctl_set_sregs(struct kvm *kvm, struct kvm_sregs *sregs)
1434static u32 msrs_to_save[] = { 1416static u32 msrs_to_save[] = {
1435 MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP, 1417 MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP,
1436 MSR_K6_STAR, 1418 MSR_K6_STAR,
1437#ifdef __x86_64__ 1419#ifdef CONFIG_X86_64
1438 MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR, 1420 MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR,
1439#endif 1421#endif
1440 MSR_IA32_TIME_STAMP_COUNTER, 1422 MSR_IA32_TIME_STAMP_COUNTER,
diff --git a/drivers/kvm/kvm_svm.h b/drivers/kvm/kvm_svm.h
index 7d7f2aa10960..74cc862f4935 100644
--- a/drivers/kvm/kvm_svm.h
+++ b/drivers/kvm/kvm_svm.h
@@ -9,7 +9,7 @@
9#include "kvm.h" 9#include "kvm.h"
10 10
11static const u32 host_save_msrs[] = { 11static const u32 host_save_msrs[] = {
12#ifdef __x86_64__ 12#ifdef CONFIG_X86_64
13 MSR_STAR, MSR_LSTAR, MSR_CSTAR, MSR_SYSCALL_MASK, MSR_KERNEL_GS_BASE, 13 MSR_STAR, MSR_LSTAR, MSR_CSTAR, MSR_SYSCALL_MASK, MSR_KERNEL_GS_BASE,
14 MSR_FS_BASE, MSR_GS_BASE, 14 MSR_FS_BASE, MSR_GS_BASE,
15#endif 15#endif
diff --git a/drivers/kvm/kvm_vmx.h b/drivers/kvm/kvm_vmx.h
index 87e12d2bfa16..d139f73fb6e1 100644
--- a/drivers/kvm/kvm_vmx.h
+++ b/drivers/kvm/kvm_vmx.h
@@ -1,7 +1,7 @@
1#ifndef __KVM_VMX_H 1#ifndef __KVM_VMX_H
2#define __KVM_VMX_H 2#define __KVM_VMX_H
3 3
4#ifdef __x86_64__ 4#ifdef CONFIG_X86_64
5/* 5/*
6 * avoid save/load MSR_SYSCALL_MASK and MSR_LSTAR by std vt 6 * avoid save/load MSR_SYSCALL_MASK and MSR_LSTAR by std vt
7 * mechanism (cpu bug AA24) 7 * mechanism (cpu bug AA24)
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index 4e29d9b7211c..3d367cbfe1f9 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -61,22 +61,9 @@
61 61
62 62
63#define PT32_PTE_COPY_MASK \ 63#define PT32_PTE_COPY_MASK \
64 (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK | \ 64 (PT_PRESENT_MASK | PT_ACCESSED_MASK | PT_DIRTY_MASK | PT_GLOBAL_MASK)
65 PT_ACCESSED_MASK | PT_DIRTY_MASK | PT_PAT_MASK | \
66 PT_GLOBAL_MASK )
67
68#define PT32_NON_PTE_COPY_MASK \
69 (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK | \
70 PT_ACCESSED_MASK | PT_DIRTY_MASK)
71
72
73#define PT64_PTE_COPY_MASK \
74 (PT64_NX_MASK | PT32_PTE_COPY_MASK)
75
76#define PT64_NON_PTE_COPY_MASK \
77 (PT64_NX_MASK | PT32_NON_PTE_COPY_MASK)
78
79 65
66#define PT64_PTE_COPY_MASK (PT64_NX_MASK | PT32_PTE_COPY_MASK)
80 67
81#define PT_FIRST_AVAIL_BITS_SHIFT 9 68#define PT_FIRST_AVAIL_BITS_SHIFT 9
82#define PT64_SECOND_AVAIL_BITS_SHIFT 52 69#define PT64_SECOND_AVAIL_BITS_SHIFT 52
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h
index 765c2e1a048e..a9771b4c5bb8 100644
--- a/drivers/kvm/paging_tmpl.h
+++ b/drivers/kvm/paging_tmpl.h
@@ -32,7 +32,6 @@
32 #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level) 32 #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level)
33 #define PT_LEVEL_MASK(level) PT64_LEVEL_MASK(level) 33 #define PT_LEVEL_MASK(level) PT64_LEVEL_MASK(level)
34 #define PT_PTE_COPY_MASK PT64_PTE_COPY_MASK 34 #define PT_PTE_COPY_MASK PT64_PTE_COPY_MASK
35 #define PT_NON_PTE_COPY_MASK PT64_NON_PTE_COPY_MASK
36#elif PTTYPE == 32 35#elif PTTYPE == 32
37 #define pt_element_t u32 36 #define pt_element_t u32
38 #define guest_walker guest_walker32 37 #define guest_walker guest_walker32
@@ -43,7 +42,6 @@
43 #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level) 42 #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level)
44 #define PT_LEVEL_MASK(level) PT32_LEVEL_MASK(level) 43 #define PT_LEVEL_MASK(level) PT32_LEVEL_MASK(level)
45 #define PT_PTE_COPY_MASK PT32_PTE_COPY_MASK 44 #define PT_PTE_COPY_MASK PT32_PTE_COPY_MASK
46 #define PT_NON_PTE_COPY_MASK PT32_NON_PTE_COPY_MASK
47#else 45#else
48 #error Invalid PTTYPE value 46 #error Invalid PTTYPE value
49#endif 47#endif
@@ -105,9 +103,7 @@ static void FNAME(set_pde)(struct kvm_vcpu *vcpu, u64 guest_pde,
105 if (PTTYPE == 32 && is_cpuid_PSE36()) 103 if (PTTYPE == 32 && is_cpuid_PSE36())
106 gaddr |= (guest_pde & PT32_DIR_PSE36_MASK) << 104 gaddr |= (guest_pde & PT32_DIR_PSE36_MASK) <<
107 (32 - PT32_DIR_PSE36_SHIFT); 105 (32 - PT32_DIR_PSE36_SHIFT);
108 *shadow_pte = (guest_pde & (PT_NON_PTE_COPY_MASK | PT_GLOBAL_MASK)) | 106 *shadow_pte = guest_pde & PT_PTE_COPY_MASK;
109 ((guest_pde & PT_DIR_PAT_MASK) >>
110 (PT_DIR_PAT_SHIFT - PT_PAT_SHIFT));
111 set_pte_common(vcpu, shadow_pte, gaddr, 107 set_pte_common(vcpu, shadow_pte, gaddr,
112 guest_pde & PT_DIRTY_MASK, access_bits); 108 guest_pde & PT_DIRTY_MASK, access_bits);
113} 109}
@@ -162,6 +158,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
162 u32 index = SHADOW_PT_INDEX(addr, level); 158 u32 index = SHADOW_PT_INDEX(addr, level);
163 u64 *shadow_ent = ((u64 *)__va(shadow_addr)) + index; 159 u64 *shadow_ent = ((u64 *)__va(shadow_addr)) + index;
164 pt_element_t *guest_ent; 160 pt_element_t *guest_ent;
161 u64 shadow_pte;
165 162
166 if (is_present_pte(*shadow_ent) || is_io_pte(*shadow_ent)) { 163 if (is_present_pte(*shadow_ent) || is_io_pte(*shadow_ent)) {
167 if (level == PT_PAGE_TABLE_LEVEL) 164 if (level == PT_PAGE_TABLE_LEVEL)
@@ -204,14 +201,11 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
204 shadow_addr = kvm_mmu_alloc_page(vcpu, shadow_ent); 201 shadow_addr = kvm_mmu_alloc_page(vcpu, shadow_ent);
205 if (!VALID_PAGE(shadow_addr)) 202 if (!VALID_PAGE(shadow_addr))
206 return ERR_PTR(-ENOMEM); 203 return ERR_PTR(-ENOMEM);
207 if (!kvm_arch_ops->is_long_mode(vcpu) && level == 3) 204 shadow_pte = shadow_addr | PT_PRESENT_MASK;
208 *shadow_ent = shadow_addr | 205 if (vcpu->mmu.root_level > 3 || level != 3)
209 (*guest_ent & (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK)); 206 shadow_pte |= PT_ACCESSED_MASK
210 else { 207 | PT_WRITABLE_MASK | PT_USER_MASK;
211 *shadow_ent = shadow_addr | 208 *shadow_ent = shadow_pte;
212 (*guest_ent & PT_NON_PTE_COPY_MASK);
213 *shadow_ent |= (PT_WRITABLE_MASK | PT_USER_MASK);
214 }
215 prev_shadow_ent = shadow_ent; 209 prev_shadow_ent = shadow_ent;
216 } 210 }
217} 211}
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index a33a89c68138..0e6bc8c649ce 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -287,7 +287,7 @@ static void svm_hardware_enable(void *garbage)
287 287
288 struct svm_cpu_data *svm_data; 288 struct svm_cpu_data *svm_data;
289 uint64_t efer; 289 uint64_t efer;
290#ifdef __x86_64__ 290#ifdef CONFIG_X86_64
291 struct desc_ptr gdt_descr; 291 struct desc_ptr gdt_descr;
292#else 292#else
293 struct Xgt_desc_struct gdt_descr; 293 struct Xgt_desc_struct gdt_descr;
@@ -377,6 +377,7 @@ static __init int svm_hardware_setup(void)
377 void *msrpm_va; 377 void *msrpm_va;
378 int r; 378 int r;
379 379
380 kvm_emulator_want_group7_invlpg();
380 381
381 iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER); 382 iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER);
382 383
@@ -397,7 +398,7 @@ static __init int svm_hardware_setup(void)
397 memset(msrpm_va, 0xff, PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER)); 398 memset(msrpm_va, 0xff, PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER));
398 msrpm_base = page_to_pfn(msrpm_pages) << PAGE_SHIFT; 399 msrpm_base = page_to_pfn(msrpm_pages) << PAGE_SHIFT;
399 400
400#ifdef __x86_64__ 401#ifdef CONFIG_X86_64
401 set_msr_interception(msrpm_va, MSR_GS_BASE, 1, 1); 402 set_msr_interception(msrpm_va, MSR_GS_BASE, 1, 1);
402 set_msr_interception(msrpm_va, MSR_FS_BASE, 1, 1); 403 set_msr_interception(msrpm_va, MSR_FS_BASE, 1, 1);
403 set_msr_interception(msrpm_va, MSR_KERNEL_GS_BASE, 1, 1); 404 set_msr_interception(msrpm_va, MSR_KERNEL_GS_BASE, 1, 1);
@@ -704,7 +705,7 @@ static void svm_set_gdt(struct kvm_vcpu *vcpu, struct descriptor_table *dt)
704 705
705static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) 706static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
706{ 707{
707#ifdef __x86_64__ 708#ifdef CONFIG_X86_64
708 if (vcpu->shadow_efer & KVM_EFER_LME) { 709 if (vcpu->shadow_efer & KVM_EFER_LME) {
709 if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) { 710 if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) {
710 vcpu->shadow_efer |= KVM_EFER_LMA; 711 vcpu->shadow_efer |= KVM_EFER_LMA;
@@ -1097,7 +1098,7 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 *data)
1097 case MSR_IA32_APICBASE: 1098 case MSR_IA32_APICBASE:
1098 *data = vcpu->apic_base; 1099 *data = vcpu->apic_base;
1099 break; 1100 break;
1100#ifdef __x86_64__ 1101#ifdef CONFIG_X86_64
1101 case MSR_STAR: 1102 case MSR_STAR:
1102 *data = vcpu->svm->vmcb->save.star; 1103 *data = vcpu->svm->vmcb->save.star;
1103 break; 1104 break;
@@ -1149,7 +1150,7 @@ static int rdmsr_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1149static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data) 1150static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
1150{ 1151{
1151 switch (ecx) { 1152 switch (ecx) {
1152#ifdef __x86_64__ 1153#ifdef CONFIG_X86_64
1153 case MSR_EFER: 1154 case MSR_EFER:
1154 set_efer(vcpu, data); 1155 set_efer(vcpu, data);
1155 break; 1156 break;
@@ -1172,7 +1173,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
1172 case MSR_IA32_APICBASE: 1173 case MSR_IA32_APICBASE:
1173 vcpu->apic_base = data; 1174 vcpu->apic_base = data;
1174 break; 1175 break;
1175#ifdef __x86_64___ 1176#ifdef CONFIG_X86_64_
1176 case MSR_STAR: 1177 case MSR_STAR:
1177 vcpu->svm->vmcb->save.star = data; 1178 vcpu->svm->vmcb->save.star = data;
1178 break; 1179 break;
@@ -1345,53 +1346,18 @@ static void kvm_reput_irq(struct kvm_vcpu *vcpu)
1345 1346
1346static void save_db_regs(unsigned long *db_regs) 1347static void save_db_regs(unsigned long *db_regs)
1347{ 1348{
1348#ifdef __x86_64__ 1349 asm volatile ("mov %%dr0, %0" : "=r"(db_regs[0]));
1349 asm ("mov %%dr0, %%rax \n\t" 1350 asm volatile ("mov %%dr1, %0" : "=r"(db_regs[1]));
1350 "mov %%rax, %[dr0] \n\t" 1351 asm volatile ("mov %%dr2, %0" : "=r"(db_regs[2]));
1351 "mov %%dr1, %%rax \n\t" 1352 asm volatile ("mov %%dr3, %0" : "=r"(db_regs[3]));
1352 "mov %%rax, %[dr1] \n\t"
1353 "mov %%dr2, %%rax \n\t"
1354 "mov %%rax, %[dr2] \n\t"
1355 "mov %%dr3, %%rax \n\t"
1356 "mov %%rax, %[dr3] \n\t"
1357 : [dr0] "=m"(db_regs[0]),
1358 [dr1] "=m"(db_regs[1]),
1359 [dr2] "=m"(db_regs[2]),
1360 [dr3] "=m"(db_regs[3])
1361 : : "rax");
1362#else
1363 asm ("mov %%dr0, %%eax \n\t"
1364 "mov %%eax, %[dr0] \n\t"
1365 "mov %%dr1, %%eax \n\t"
1366 "mov %%eax, %[dr1] \n\t"
1367 "mov %%dr2, %%eax \n\t"
1368 "mov %%eax, %[dr2] \n\t"
1369 "mov %%dr3, %%eax \n\t"
1370 "mov %%eax, %[dr3] \n\t"
1371 : [dr0] "=m"(db_regs[0]),
1372 [dr1] "=m"(db_regs[1]),
1373 [dr2] "=m"(db_regs[2]),
1374 [dr3] "=m"(db_regs[3])
1375 : : "eax");
1376#endif
1377} 1353}
1378 1354
1379static void load_db_regs(unsigned long *db_regs) 1355static void load_db_regs(unsigned long *db_regs)
1380{ 1356{
1381 asm volatile ("mov %[dr0], %%dr0 \n\t" 1357 asm volatile ("mov %0, %%dr0" : : "r"(db_regs[0]));
1382 "mov %[dr1], %%dr1 \n\t" 1358 asm volatile ("mov %0, %%dr1" : : "r"(db_regs[1]));
1383 "mov %[dr2], %%dr2 \n\t" 1359 asm volatile ("mov %0, %%dr2" : : "r"(db_regs[2]));
1384 "mov %[dr3], %%dr3 \n\t" 1360 asm volatile ("mov %0, %%dr3" : : "r"(db_regs[3]));
1385 :
1386 : [dr0] "r"(db_regs[0]),
1387 [dr1] "r"(db_regs[1]),
1388 [dr2] "r"(db_regs[2]),
1389 [dr3] "r"(db_regs[3])
1390#ifdef __x86_64__
1391 : "rax");
1392#else
1393 : "eax");
1394#endif
1395} 1361}
1396 1362
1397static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 1363static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
@@ -1422,7 +1388,7 @@ again:
1422 load_db_regs(vcpu->svm->db_regs); 1388 load_db_regs(vcpu->svm->db_regs);
1423 } 1389 }
1424 asm volatile ( 1390 asm volatile (
1425#ifdef __x86_64__ 1391#ifdef CONFIG_X86_64
1426 "push %%rbx; push %%rcx; push %%rdx;" 1392 "push %%rbx; push %%rcx; push %%rdx;"
1427 "push %%rsi; push %%rdi; push %%rbp;" 1393 "push %%rsi; push %%rdi; push %%rbp;"
1428 "push %%r8; push %%r9; push %%r10; push %%r11;" 1394 "push %%r8; push %%r9; push %%r10; push %%r11;"
@@ -1432,7 +1398,7 @@ again:
1432 "push %%esi; push %%edi; push %%ebp;" 1398 "push %%esi; push %%edi; push %%ebp;"
1433#endif 1399#endif
1434 1400
1435#ifdef __x86_64__ 1401#ifdef CONFIG_X86_64
1436 "mov %c[rbx](%[vcpu]), %%rbx \n\t" 1402 "mov %c[rbx](%[vcpu]), %%rbx \n\t"
1437 "mov %c[rcx](%[vcpu]), %%rcx \n\t" 1403 "mov %c[rcx](%[vcpu]), %%rcx \n\t"
1438 "mov %c[rdx](%[vcpu]), %%rdx \n\t" 1404 "mov %c[rdx](%[vcpu]), %%rdx \n\t"
@@ -1456,7 +1422,7 @@ again:
1456 "mov %c[rbp](%[vcpu]), %%ebp \n\t" 1422 "mov %c[rbp](%[vcpu]), %%ebp \n\t"
1457#endif 1423#endif
1458 1424
1459#ifdef __x86_64__ 1425#ifdef CONFIG_X86_64
1460 /* Enter guest mode */ 1426 /* Enter guest mode */
1461 "push %%rax \n\t" 1427 "push %%rax \n\t"
1462 "mov %c[svm](%[vcpu]), %%rax \n\t" 1428 "mov %c[svm](%[vcpu]), %%rax \n\t"
@@ -1477,7 +1443,7 @@ again:
1477#endif 1443#endif
1478 1444
1479 /* Save guest registers, load host registers */ 1445 /* Save guest registers, load host registers */
1480#ifdef __x86_64__ 1446#ifdef CONFIG_X86_64
1481 "mov %%rbx, %c[rbx](%[vcpu]) \n\t" 1447 "mov %%rbx, %c[rbx](%[vcpu]) \n\t"
1482 "mov %%rcx, %c[rcx](%[vcpu]) \n\t" 1448 "mov %%rcx, %c[rcx](%[vcpu]) \n\t"
1483 "mov %%rdx, %c[rdx](%[vcpu]) \n\t" 1449 "mov %%rdx, %c[rdx](%[vcpu]) \n\t"
@@ -1518,7 +1484,7 @@ again:
1518 [rsi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RSI])), 1484 [rsi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RSI])),
1519 [rdi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RDI])), 1485 [rdi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RDI])),
1520 [rbp]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RBP])) 1486 [rbp]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RBP]))
1521#ifdef __x86_64__ 1487#ifdef CONFIG_X86_64
1522 ,[r8 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R8 ])), 1488 ,[r8 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R8 ])),
1523 [r9 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R9 ])), 1489 [r9 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R9 ])),
1524 [r10]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R10])), 1490 [r10]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R10])),
@@ -1663,9 +1629,7 @@ static struct kvm_arch_ops svm_arch_ops = {
1663 1629
1664static int __init svm_init(void) 1630static int __init svm_init(void)
1665{ 1631{
1666 kvm_emulator_want_group7_invlpg(); 1632 return kvm_init_arch(&svm_arch_ops, THIS_MODULE);
1667 kvm_init_arch(&svm_arch_ops, THIS_MODULE);
1668 return 0;
1669} 1633}
1670 1634
1671static void __exit svm_exit(void) 1635static void __exit svm_exit(void)
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index bda7a7ae2167..f0f0b1a781f8 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -22,6 +22,7 @@
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/highmem.h> 23#include <linux/highmem.h>
24#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/desc.h>
25 26
26#include "segment_descriptor.h" 27#include "segment_descriptor.h"
27 28
@@ -33,7 +34,7 @@ MODULE_LICENSE("GPL");
33static DEFINE_PER_CPU(struct vmcs *, vmxarea); 34static DEFINE_PER_CPU(struct vmcs *, vmxarea);
34static DEFINE_PER_CPU(struct vmcs *, current_vmcs); 35static DEFINE_PER_CPU(struct vmcs *, current_vmcs);
35 36
36#ifdef __x86_64__ 37#ifdef CONFIG_X86_64
37#define HOST_IS_64 1 38#define HOST_IS_64 1
38#else 39#else
39#define HOST_IS_64 0 40#define HOST_IS_64 0
@@ -70,15 +71,13 @@ static struct kvm_vmx_segment_field {
70}; 71};
71 72
72static const u32 vmx_msr_index[] = { 73static const u32 vmx_msr_index[] = {
73#ifdef __x86_64__ 74#ifdef CONFIG_X86_64
74 MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR, MSR_KERNEL_GS_BASE, 75 MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR, MSR_KERNEL_GS_BASE,
75#endif 76#endif
76 MSR_EFER, MSR_K6_STAR, 77 MSR_EFER, MSR_K6_STAR,
77}; 78};
78#define NR_VMX_MSR (sizeof(vmx_msr_index) / sizeof(*vmx_msr_index)) 79#define NR_VMX_MSR (sizeof(vmx_msr_index) / sizeof(*vmx_msr_index))
79 80
80struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr);
81
82static inline int is_page_fault(u32 intr_info) 81static inline int is_page_fault(u32 intr_info)
83{ 82{
84 return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VECTOR_MASK | 83 return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VECTOR_MASK |
@@ -92,6 +91,16 @@ static inline int is_external_interrupt(u32 intr_info)
92 == (INTR_TYPE_EXT_INTR | INTR_INFO_VALID_MASK); 91 == (INTR_TYPE_EXT_INTR | INTR_INFO_VALID_MASK);
93} 92}
94 93
94static struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr)
95{
96 int i;
97
98 for (i = 0; i < vcpu->nmsrs; ++i)
99 if (vcpu->guest_msrs[i].index == msr)
100 return &vcpu->guest_msrs[i];
101 return 0;
102}
103
95static void vmcs_clear(struct vmcs *vmcs) 104static void vmcs_clear(struct vmcs *vmcs)
96{ 105{
97 u64 phys_addr = __pa(vmcs); 106 u64 phys_addr = __pa(vmcs);
@@ -137,7 +146,7 @@ static u32 vmcs_read32(unsigned long field)
137 146
138static u64 vmcs_read64(unsigned long field) 147static u64 vmcs_read64(unsigned long field)
139{ 148{
140#ifdef __x86_64__ 149#ifdef CONFIG_X86_64
141 return vmcs_readl(field); 150 return vmcs_readl(field);
142#else 151#else
143 return vmcs_readl(field) | ((u64)vmcs_readl(field+1) << 32); 152 return vmcs_readl(field) | ((u64)vmcs_readl(field+1) << 32);
@@ -167,7 +176,7 @@ static void vmcs_write32(unsigned long field, u32 value)
167 176
168static void vmcs_write64(unsigned long field, u64 value) 177static void vmcs_write64(unsigned long field, u64 value)
169{ 178{
170#ifdef __x86_64__ 179#ifdef CONFIG_X86_64
171 vmcs_writel(field, value); 180 vmcs_writel(field, value);
172#else 181#else
173 vmcs_writel(field, value); 182 vmcs_writel(field, value);
@@ -296,7 +305,7 @@ static void guest_write_tsc(u64 guest_tsc)
296 305
297static void reload_tss(void) 306static void reload_tss(void)
298{ 307{
299#ifndef __x86_64__ 308#ifndef CONFIG_X86_64
300 309
301 /* 310 /*
302 * VT restores TR but not its size. Useless. 311 * VT restores TR but not its size. Useless.
@@ -327,7 +336,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
327 } 336 }
328 337
329 switch (msr_index) { 338 switch (msr_index) {
330#ifdef __x86_64__ 339#ifdef CONFIG_X86_64
331 case MSR_FS_BASE: 340 case MSR_FS_BASE:
332 data = vmcs_readl(GUEST_FS_BASE); 341 data = vmcs_readl(GUEST_FS_BASE);
333 break; 342 break;
@@ -390,7 +399,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
390{ 399{
391 struct vmx_msr_entry *msr; 400 struct vmx_msr_entry *msr;
392 switch (msr_index) { 401 switch (msr_index) {
393#ifdef __x86_64__ 402#ifdef CONFIG_X86_64
394 case MSR_FS_BASE: 403 case MSR_FS_BASE:
395 vmcs_writel(GUEST_FS_BASE, data); 404 vmcs_writel(GUEST_FS_BASE, data);
396 break; 405 break;
@@ -525,7 +534,7 @@ static __init void hardware_enable(void *garbage)
525 u64 old; 534 u64 old;
526 535
527 rdmsrl(MSR_IA32_FEATURE_CONTROL, old); 536 rdmsrl(MSR_IA32_FEATURE_CONTROL, old);
528 if ((old & 5) == 0) 537 if ((old & 5) != 5)
529 /* enable and lock */ 538 /* enable and lock */
530 wrmsrl(MSR_IA32_FEATURE_CONTROL, old | 5); 539 wrmsrl(MSR_IA32_FEATURE_CONTROL, old | 5);
531 write_cr4(read_cr4() | CR4_VMXE); /* FIXME: not cpu hotplug safe */ 540 write_cr4(read_cr4() | CR4_VMXE); /* FIXME: not cpu hotplug safe */
@@ -725,7 +734,7 @@ static void enter_rmode(struct kvm_vcpu *vcpu)
725 fix_rmode_seg(VCPU_SREG_FS, &vcpu->rmode.fs); 734 fix_rmode_seg(VCPU_SREG_FS, &vcpu->rmode.fs);
726} 735}
727 736
728#ifdef __x86_64__ 737#ifdef CONFIG_X86_64
729 738
730static void enter_lmode(struct kvm_vcpu *vcpu) 739static void enter_lmode(struct kvm_vcpu *vcpu)
731{ 740{
@@ -767,7 +776,7 @@ static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
767 if (!vcpu->rmode.active && !(cr0 & CR0_PE_MASK)) 776 if (!vcpu->rmode.active && !(cr0 & CR0_PE_MASK))
768 enter_rmode(vcpu); 777 enter_rmode(vcpu);
769 778
770#ifdef __x86_64__ 779#ifdef CONFIG_X86_64
771 if (vcpu->shadow_efer & EFER_LME) { 780 if (vcpu->shadow_efer & EFER_LME) {
772 if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) 781 if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK))
773 enter_lmode(vcpu); 782 enter_lmode(vcpu);
@@ -808,7 +817,7 @@ static void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
808 vcpu->cr4 = cr4; 817 vcpu->cr4 = cr4;
809} 818}
810 819
811#ifdef __x86_64__ 820#ifdef CONFIG_X86_64
812 821
813static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer) 822static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer)
814{ 823{
@@ -883,6 +892,8 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu,
883 ar |= (var->db & 1) << 14; 892 ar |= (var->db & 1) << 14;
884 ar |= (var->g & 1) << 15; 893 ar |= (var->g & 1) << 15;
885 } 894 }
895 if (ar == 0) /* a 0 value means unusable */
896 ar = AR_UNUSABLE_MASK;
886 vmcs_write32(sf->ar_bytes, ar); 897 vmcs_write32(sf->ar_bytes, ar);
887} 898}
888 899
@@ -1095,7 +1106,7 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu)
1095 vmcs_write16(HOST_FS_SELECTOR, read_fs()); /* 22.2.4 */ 1106 vmcs_write16(HOST_FS_SELECTOR, read_fs()); /* 22.2.4 */
1096 vmcs_write16(HOST_GS_SELECTOR, read_gs()); /* 22.2.4 */ 1107 vmcs_write16(HOST_GS_SELECTOR, read_gs()); /* 22.2.4 */
1097 vmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); /* 22.2.4 */ 1108 vmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); /* 22.2.4 */
1098#ifdef __x86_64__ 1109#ifdef CONFIG_X86_64
1099 rdmsrl(MSR_FS_BASE, a); 1110 rdmsrl(MSR_FS_BASE, a);
1100 vmcs_writel(HOST_FS_BASE, a); /* 22.2.4 */ 1111 vmcs_writel(HOST_FS_BASE, a); /* 22.2.4 */
1101 rdmsrl(MSR_GS_BASE, a); 1112 rdmsrl(MSR_GS_BASE, a);
@@ -1164,8 +1175,10 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu)
1164 VM_ENTRY_CONTROLS, 0); 1175 VM_ENTRY_CONTROLS, 0);
1165 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0); /* 22.2.1 */ 1176 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0); /* 22.2.1 */
1166 1177
1178#ifdef CONFIG_X86_64
1167 vmcs_writel(VIRTUAL_APIC_PAGE_ADDR, 0); 1179 vmcs_writel(VIRTUAL_APIC_PAGE_ADDR, 0);
1168 vmcs_writel(TPR_THRESHOLD, 0); 1180 vmcs_writel(TPR_THRESHOLD, 0);
1181#endif
1169 1182
1170 vmcs_writel(CR0_GUEST_HOST_MASK, KVM_GUEST_CR0_MASK); 1183 vmcs_writel(CR0_GUEST_HOST_MASK, KVM_GUEST_CR0_MASK);
1171 vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK); 1184 vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK);
@@ -1173,7 +1186,7 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu)
1173 vcpu->cr0 = 0x60000010; 1186 vcpu->cr0 = 0x60000010;
1174 vmx_set_cr0(vcpu, vcpu->cr0); // enter rmode 1187 vmx_set_cr0(vcpu, vcpu->cr0); // enter rmode
1175 vmx_set_cr4(vcpu, 0); 1188 vmx_set_cr4(vcpu, 0);
1176#ifdef __x86_64__ 1189#ifdef CONFIG_X86_64
1177 vmx_set_efer(vcpu, 0); 1190 vmx_set_efer(vcpu, 0);
1178#endif 1191#endif
1179 1192
@@ -1689,7 +1702,7 @@ again:
1689 vmcs_write16(HOST_GS_SELECTOR, 0); 1702 vmcs_write16(HOST_GS_SELECTOR, 0);
1690 } 1703 }
1691 1704
1692#ifdef __x86_64__ 1705#ifdef CONFIG_X86_64
1693 vmcs_writel(HOST_FS_BASE, read_msr(MSR_FS_BASE)); 1706 vmcs_writel(HOST_FS_BASE, read_msr(MSR_FS_BASE));
1694 vmcs_writel(HOST_GS_BASE, read_msr(MSR_GS_BASE)); 1707 vmcs_writel(HOST_GS_BASE, read_msr(MSR_GS_BASE));
1695#else 1708#else
@@ -1713,7 +1726,7 @@ again:
1713 asm ( 1726 asm (
1714 /* Store host registers */ 1727 /* Store host registers */
1715 "pushf \n\t" 1728 "pushf \n\t"
1716#ifdef __x86_64__ 1729#ifdef CONFIG_X86_64
1717 "push %%rax; push %%rbx; push %%rdx;" 1730 "push %%rax; push %%rbx; push %%rdx;"
1718 "push %%rsi; push %%rdi; push %%rbp;" 1731 "push %%rsi; push %%rdi; push %%rbp;"
1719 "push %%r8; push %%r9; push %%r10; push %%r11;" 1732 "push %%r8; push %%r9; push %%r10; push %%r11;"
@@ -1727,7 +1740,7 @@ again:
1727 /* Check if vmlaunch of vmresume is needed */ 1740 /* Check if vmlaunch of vmresume is needed */
1728 "cmp $0, %1 \n\t" 1741 "cmp $0, %1 \n\t"
1729 /* Load guest registers. Don't clobber flags. */ 1742 /* Load guest registers. Don't clobber flags. */
1730#ifdef __x86_64__ 1743#ifdef CONFIG_X86_64
1731 "mov %c[cr2](%3), %%rax \n\t" 1744 "mov %c[cr2](%3), %%rax \n\t"
1732 "mov %%rax, %%cr2 \n\t" 1745 "mov %%rax, %%cr2 \n\t"
1733 "mov %c[rax](%3), %%rax \n\t" 1746 "mov %c[rax](%3), %%rax \n\t"
@@ -1764,7 +1777,7 @@ again:
1764 ".globl kvm_vmx_return \n\t" 1777 ".globl kvm_vmx_return \n\t"
1765 "kvm_vmx_return: " 1778 "kvm_vmx_return: "
1766 /* Save guest registers, load host registers, keep flags */ 1779 /* Save guest registers, load host registers, keep flags */
1767#ifdef __x86_64__ 1780#ifdef CONFIG_X86_64
1768 "xchg %3, 0(%%rsp) \n\t" 1781 "xchg %3, 0(%%rsp) \n\t"
1769 "mov %%rax, %c[rax](%3) \n\t" 1782 "mov %%rax, %c[rax](%3) \n\t"
1770 "mov %%rbx, %c[rbx](%3) \n\t" 1783 "mov %%rbx, %c[rbx](%3) \n\t"
@@ -1816,7 +1829,7 @@ again:
1816 [rsi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RSI])), 1829 [rsi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RSI])),
1817 [rdi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RDI])), 1830 [rdi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RDI])),
1818 [rbp]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RBP])), 1831 [rbp]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RBP])),
1819#ifdef __x86_64__ 1832#ifdef CONFIG_X86_64
1820 [r8 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R8 ])), 1833 [r8 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R8 ])),
1821 [r9 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R9 ])), 1834 [r9 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R9 ])),
1822 [r10]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R10])), 1835 [r10]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R10])),
@@ -1837,7 +1850,7 @@ again:
1837 fx_save(vcpu->guest_fx_image); 1850 fx_save(vcpu->guest_fx_image);
1838 fx_restore(vcpu->host_fx_image); 1851 fx_restore(vcpu->host_fx_image);
1839 1852
1840#ifndef __x86_64__ 1853#ifndef CONFIG_X86_64
1841 asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS)); 1854 asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
1842#endif 1855#endif
1843 1856
@@ -1855,7 +1868,7 @@ again:
1855 */ 1868 */
1856 local_irq_disable(); 1869 local_irq_disable();
1857 load_gs(gs_sel); 1870 load_gs(gs_sel);
1858#ifdef __x86_64__ 1871#ifdef CONFIG_X86_64
1859 wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE)); 1872 wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE));
1860#endif 1873#endif
1861 local_irq_enable(); 1874 local_irq_enable();
@@ -1965,7 +1978,7 @@ static struct kvm_arch_ops vmx_arch_ops = {
1965 .set_cr0_no_modeswitch = vmx_set_cr0_no_modeswitch, 1978 .set_cr0_no_modeswitch = vmx_set_cr0_no_modeswitch,
1966 .set_cr3 = vmx_set_cr3, 1979 .set_cr3 = vmx_set_cr3,
1967 .set_cr4 = vmx_set_cr4, 1980 .set_cr4 = vmx_set_cr4,
1968#ifdef __x86_64__ 1981#ifdef CONFIG_X86_64
1969 .set_efer = vmx_set_efer, 1982 .set_efer = vmx_set_efer,
1970#endif 1983#endif
1971 .get_idt = vmx_get_idt, 1984 .get_idt = vmx_get_idt,
@@ -1989,8 +2002,7 @@ static struct kvm_arch_ops vmx_arch_ops = {
1989 2002
1990static int __init vmx_init(void) 2003static int __init vmx_init(void)
1991{ 2004{
1992 kvm_init_arch(&vmx_arch_ops, THIS_MODULE); 2005 return kvm_init_arch(&vmx_arch_ops, THIS_MODULE);
1993 return 0;
1994} 2006}
1995 2007
1996static void __exit vmx_exit(void) 2008static void __exit vmx_exit(void)
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index 7e838bf0592d..1bff3e925fda 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -238,7 +238,7 @@ struct operand {
238 * any modified flags. 238 * any modified flags.
239 */ 239 */
240 240
241#if defined(__x86_64__) 241#if defined(CONFIG_X86_64)
242#define _LO32 "k" /* force 32-bit operand */ 242#define _LO32 "k" /* force 32-bit operand */
243#define _STK "%%rsp" /* stack pointer */ 243#define _STK "%%rsp" /* stack pointer */
244#elif defined(__i386__) 244#elif defined(__i386__)
@@ -385,7 +385,7 @@ struct operand {
385 } while (0) 385 } while (0)
386 386
387/* Emulate an instruction with quadword operands (x86/64 only). */ 387/* Emulate an instruction with quadword operands (x86/64 only). */
388#if defined(__x86_64__) 388#if defined(CONFIG_X86_64)
389#define __emulate_2op_8byte(_op, _src, _dst, _eflags, _qx, _qy) \ 389#define __emulate_2op_8byte(_op, _src, _dst, _eflags, _qx, _qy) \
390 do { \ 390 do { \
391 __asm__ __volatile__ ( \ 391 __asm__ __volatile__ ( \
@@ -495,7 +495,7 @@ x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
495 case X86EMUL_MODE_PROT32: 495 case X86EMUL_MODE_PROT32:
496 op_bytes = ad_bytes = 4; 496 op_bytes = ad_bytes = 4;
497 break; 497 break;
498#ifdef __x86_64__ 498#ifdef CONFIG_X86_64
499 case X86EMUL_MODE_PROT64: 499 case X86EMUL_MODE_PROT64:
500 op_bytes = 4; 500 op_bytes = 4;
501 ad_bytes = 8; 501 ad_bytes = 8;
@@ -1341,7 +1341,7 @@ twobyte_special_insn:
1341 } 1341 }
1342 break; 1342 break;
1343 } 1343 }
1344#elif defined(__x86_64__) 1344#elif defined(CONFIG_X86_64)
1345 { 1345 {
1346 unsigned long old, new; 1346 unsigned long old, new;
1347 if ((rc = ops->read_emulated(cr2, &old, 8, ctxt)) != 0) 1347 if ((rc = ops->read_emulated(cr2, &old, 8, ctxt)) != 0)
diff --git a/drivers/kvm/x86_emulate.h b/drivers/kvm/x86_emulate.h
index 658b58de30fc..5d41bd55125e 100644
--- a/drivers/kvm/x86_emulate.h
+++ b/drivers/kvm/x86_emulate.h
@@ -162,7 +162,7 @@ struct x86_emulate_ctxt {
162/* Host execution mode. */ 162/* Host execution mode. */
163#if defined(__i386__) 163#if defined(__i386__)
164#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT32 164#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT32
165#elif defined(__x86_64__) 165#elif defined(CONFIG_X86_64)
166#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64 166#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64
167#endif 167#endif
168 168
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index d43ea81d6df9..7cec6de5e2b0 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -828,7 +828,7 @@ static ssize_t adb_write(struct file *file, const char __user *buf,
828 if (!access_ok(VERIFY_READ, buf, count)) 828 if (!access_ok(VERIFY_READ, buf, count))
829 return -EFAULT; 829 return -EFAULT;
830 830
831 req = (struct adb_request *) kmalloc(sizeof(struct adb_request), 831 req = kmalloc(sizeof(struct adb_request),
832 GFP_KERNEL); 832 GFP_KERNEL);
833 if (req == NULL) 833 if (req == NULL)
834 return -ENOMEM; 834 return -ENOMEM;
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c
index 8862a83b8d84..4300c628f8af 100644
--- a/drivers/macintosh/apm_emu.c
+++ b/drivers/macintosh/apm_emu.c
@@ -321,7 +321,7 @@ static int do_open(struct inode * inode, struct file * filp)
321{ 321{
322 struct apm_user * as; 322 struct apm_user * as;
323 323
324 as = (struct apm_user *)kmalloc(sizeof(*as), GFP_KERNEL); 324 as = kmalloc(sizeof(*as), GFP_KERNEL);
325 if (as == NULL) { 325 if (as == NULL) {
326 printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n", 326 printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n",
327 sizeof(*as)); 327 sizeof(*as));
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index 6dde27ab79a8..6f30459b9385 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -945,7 +945,7 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id)
945 */ 945 */
946 tlen = sizeof(struct property) + len + 18; 946 tlen = sizeof(struct property) + len + 18;
947 947
948 prop = kcalloc(tlen, 1, GFP_KERNEL); 948 prop = kzalloc(tlen, GFP_KERNEL);
949 if (prop == NULL) 949 if (prop == NULL)
950 return NULL; 950 return NULL;
951 hdr = (struct smu_sdbp_header *)(prop + 1); 951 hdr = (struct smu_sdbp_header *)(prop + 1);
diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c
index d9986f3a3fbf..93e6ef9233f9 100644
--- a/drivers/macintosh/via-pmu68k.c
+++ b/drivers/macintosh/via-pmu68k.c
@@ -847,7 +847,7 @@ pbook_pci_save(void)
847 n_pbook_pci_saves = npci; 847 n_pbook_pci_saves = npci;
848 if (npci == 0) 848 if (npci == 0)
849 return; 849 return;
850 ps = (struct pci_save *) kmalloc(npci * sizeof(*ps), GFP_KERNEL); 850 ps = kmalloc(npci * sizeof(*ps), GFP_KERNEL);
851 pbook_pci_saves = ps; 851 pbook_pci_saves = ps;
852 if (ps == NULL) 852 if (ps == NULL)
853 return; 853 return;
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index a7a5ab554338..4ebd0f2a75ec 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -173,7 +173,7 @@ static int make_request(request_queue_t *q, struct bio *bio)
173 conf_t *conf = (conf_t*)mddev->private; 173 conf_t *conf = (conf_t*)mddev->private;
174 int failit = 0; 174 int failit = 0;
175 175
176 if (bio->bi_rw & 1) { 176 if (bio_data_dir(bio) == WRITE) {
177 /* write request */ 177 /* write request */
178 if (atomic_read(&conf->counters[WriteAll])) { 178 if (atomic_read(&conf->counters[WriteAll])) {
179 /* special case - don't decrement, don't generic_make_request, 179 /* special case - don't decrement, don't generic_make_request,
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index b3c5e12f081d..b30f74be3982 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1736,7 +1736,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1736 /* take from bio_init */ 1736 /* take from bio_init */
1737 bio->bi_next = NULL; 1737 bio->bi_next = NULL;
1738 bio->bi_flags |= 1 << BIO_UPTODATE; 1738 bio->bi_flags |= 1 << BIO_UPTODATE;
1739 bio->bi_rw = 0; 1739 bio->bi_rw = READ;
1740 bio->bi_vcnt = 0; 1740 bio->bi_vcnt = 0;
1741 bio->bi_idx = 0; 1741 bio->bi_idx = 0;
1742 bio->bi_phys_segments = 0; 1742 bio->bi_phys_segments = 0;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 7492d6033ac6..f0141910bb8d 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1785,7 +1785,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1785 biolist = bio; 1785 biolist = bio;
1786 bio->bi_private = r10_bio; 1786 bio->bi_private = r10_bio;
1787 bio->bi_end_io = end_sync_read; 1787 bio->bi_end_io = end_sync_read;
1788 bio->bi_rw = 0; 1788 bio->bi_rw = READ;
1789 bio->bi_sector = r10_bio->devs[j].addr + 1789 bio->bi_sector = r10_bio->devs[j].addr +
1790 conf->mirrors[d].rdev->data_offset; 1790 conf->mirrors[d].rdev->data_offset;
1791 bio->bi_bdev = conf->mirrors[d].rdev->bdev; 1791 bio->bi_bdev = conf->mirrors[d].rdev->bdev;
@@ -1801,7 +1801,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1801 biolist = bio; 1801 biolist = bio;
1802 bio->bi_private = r10_bio; 1802 bio->bi_private = r10_bio;
1803 bio->bi_end_io = end_sync_write; 1803 bio->bi_end_io = end_sync_write;
1804 bio->bi_rw = 1; 1804 bio->bi_rw = WRITE;
1805 bio->bi_sector = r10_bio->devs[k].addr + 1805 bio->bi_sector = r10_bio->devs[k].addr +
1806 conf->mirrors[i].rdev->data_offset; 1806 conf->mirrors[i].rdev->data_offset;
1807 bio->bi_bdev = conf->mirrors[i].rdev->bdev; 1807 bio->bi_bdev = conf->mirrors[i].rdev->bdev;
@@ -1870,7 +1870,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1870 biolist = bio; 1870 biolist = bio;
1871 bio->bi_private = r10_bio; 1871 bio->bi_private = r10_bio;
1872 bio->bi_end_io = end_sync_read; 1872 bio->bi_end_io = end_sync_read;
1873 bio->bi_rw = 0; 1873 bio->bi_rw = READ;
1874 bio->bi_sector = r10_bio->devs[i].addr + 1874 bio->bi_sector = r10_bio->devs[i].addr +
1875 conf->mirrors[d].rdev->data_offset; 1875 conf->mirrors[d].rdev->data_offset;
1876 bio->bi_bdev = conf->mirrors[d].rdev->bdev; 1876 bio->bi_bdev = conf->mirrors[d].rdev->bdev;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 377f8bc9b78b..be008f034ada 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1827,16 +1827,16 @@ static void handle_stripe5(struct stripe_head *sh)
1827 struct bio *bi; 1827 struct bio *bi;
1828 mdk_rdev_t *rdev; 1828 mdk_rdev_t *rdev;
1829 if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags)) 1829 if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags))
1830 rw = 1; 1830 rw = WRITE;
1831 else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags)) 1831 else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags))
1832 rw = 0; 1832 rw = READ;
1833 else 1833 else
1834 continue; 1834 continue;
1835 1835
1836 bi = &sh->dev[i].req; 1836 bi = &sh->dev[i].req;
1837 1837
1838 bi->bi_rw = rw; 1838 bi->bi_rw = rw;
1839 if (rw) 1839 if (rw == WRITE)
1840 bi->bi_end_io = raid5_end_write_request; 1840 bi->bi_end_io = raid5_end_write_request;
1841 else 1841 else
1842 bi->bi_end_io = raid5_end_read_request; 1842 bi->bi_end_io = raid5_end_read_request;
@@ -1872,7 +1872,7 @@ static void handle_stripe5(struct stripe_head *sh)
1872 atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); 1872 atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
1873 generic_make_request(bi); 1873 generic_make_request(bi);
1874 } else { 1874 } else {
1875 if (rw == 1) 1875 if (rw == WRITE)
1876 set_bit(STRIPE_DEGRADED, &sh->state); 1876 set_bit(STRIPE_DEGRADED, &sh->state);
1877 PRINTK("skip op %ld on disc %d for sector %llu\n", 1877 PRINTK("skip op %ld on disc %d for sector %llu\n",
1878 bi->bi_rw, i, (unsigned long long)sh->sector); 1878 bi->bi_rw, i, (unsigned long long)sh->sector);
@@ -2370,16 +2370,16 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
2370 struct bio *bi; 2370 struct bio *bi;
2371 mdk_rdev_t *rdev; 2371 mdk_rdev_t *rdev;
2372 if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags)) 2372 if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags))
2373 rw = 1; 2373 rw = WRITE;
2374 else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags)) 2374 else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags))
2375 rw = 0; 2375 rw = READ;
2376 else 2376 else
2377 continue; 2377 continue;
2378 2378
2379 bi = &sh->dev[i].req; 2379 bi = &sh->dev[i].req;
2380 2380
2381 bi->bi_rw = rw; 2381 bi->bi_rw = rw;
2382 if (rw) 2382 if (rw == WRITE)
2383 bi->bi_end_io = raid5_end_write_request; 2383 bi->bi_end_io = raid5_end_write_request;
2384 else 2384 else
2385 bi->bi_end_io = raid5_end_read_request; 2385 bi->bi_end_io = raid5_end_read_request;
@@ -2415,7 +2415,7 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
2415 atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); 2415 atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
2416 generic_make_request(bi); 2416 generic_make_request(bi);
2417 } else { 2417 } else {
2418 if (rw == 1) 2418 if (rw == WRITE)
2419 set_bit(STRIPE_DEGRADED, &sh->state); 2419 set_bit(STRIPE_DEGRADED, &sh->state);
2420 PRINTK("skip op %ld on disc %d for sector %llu\n", 2420 PRINTK("skip op %ld on disc %d for sector %llu\n",
2421 bi->bi_rw, i, (unsigned long long)sh->sector); 2421 bi->bi_rw, i, (unsigned long long)sh->sector);
@@ -2567,7 +2567,7 @@ static int raid5_mergeable_bvec(request_queue_t *q, struct bio *bio, struct bio_
2567 unsigned int chunk_sectors = mddev->chunk_size >> 9; 2567 unsigned int chunk_sectors = mddev->chunk_size >> 9;
2568 unsigned int bio_sectors = bio->bi_size >> 9; 2568 unsigned int bio_sectors = bio->bi_size >> 9;
2569 2569
2570 if (bio_data_dir(bio)) 2570 if (bio_data_dir(bio) == WRITE)
2571 return biovec->bv_len; /* always allow writes to be mergeable */ 2571 return biovec->bv_len; /* always allow writes to be mergeable */
2572 2572
2573 max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9; 2573 max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9;
@@ -2751,7 +2751,7 @@ static int make_request(request_queue_t *q, struct bio * bi)
2751 disk_stat_inc(mddev->gendisk, ios[rw]); 2751 disk_stat_inc(mddev->gendisk, ios[rw]);
2752 disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bi)); 2752 disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bi));
2753 2753
2754 if (bio_data_dir(bi) == READ && 2754 if (rw == READ &&
2755 mddev->reshape_position == MaxSector && 2755 mddev->reshape_position == MaxSector &&
2756 chunk_aligned_read(q,bi)) 2756 chunk_aligned_read(q,bi))
2757 return 0; 2757 return 0;
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index 240ad084fa78..50bc32a8bd55 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -480,7 +480,7 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message,
480 struct ca_msg *hw_buffer; 480 struct ca_msg *hw_buffer;
481 int result = 0; 481 int result = 0;
482 482
483 if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { 483 if ((hw_buffer = kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) {
484 dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); 484 dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
485 return -ENOMEM; 485 return -ENOMEM;
486 } 486 }
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index 80a85cb4975f..3e35931af35d 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -657,7 +657,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
657 657
658 case BTTV_BOARD_TWINHAN_DST: 658 case BTTV_BOARD_TWINHAN_DST:
659 /* DST is not a frontend driver !!! */ 659 /* DST is not a frontend driver !!! */
660 state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL); 660 state = kmalloc(sizeof (struct dst_state), GFP_KERNEL);
661 if (!state) { 661 if (!state) {
662 printk("dvb_bt8xx: No memory\n"); 662 printk("dvb_bt8xx: No memory\n");
663 break; 663 break;
diff --git a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
index 42f39a89bc4d..a6fb1d6a7b5d 100644
--- a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
+++ b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
@@ -195,7 +195,7 @@ struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* conf
195 struct ttusbdecfe_state* state = NULL; 195 struct ttusbdecfe_state* state = NULL;
196 196
197 /* allocate memory for the internal state */ 197 /* allocate memory for the internal state */
198 state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); 198 state = kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL);
199 if (state == NULL) 199 if (state == NULL)
200 return NULL; 200 return NULL;
201 201
@@ -215,7 +215,7 @@ struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* conf
215 struct ttusbdecfe_state* state = NULL; 215 struct ttusbdecfe_state* state = NULL;
216 216
217 /* allocate memory for the internal state */ 217 /* allocate memory for the internal state */
218 state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); 218 state = kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL);
219 if (state == NULL) 219 if (state == NULL)
220 return NULL; 220 return NULL;
221 221
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c
index b1012e92ee04..917021fc2993 100644
--- a/drivers/media/video/dabusb.c
+++ b/drivers/media/video/dabusb.c
@@ -218,7 +218,7 @@ static int dabusb_alloc_buffers (pdabusb_t s)
218 pipesize, packets, transfer_buffer_length); 218 pipesize, packets, transfer_buffer_length);
219 219
220 while (buffers < (s->total_buffer_size << 10)) { 220 while (buffers < (s->total_buffer_size << 10)) {
221 b = (pbuff_t) kzalloc (sizeof (buff_t), GFP_KERNEL); 221 b = kzalloc(sizeof (buff_t), GFP_KERNEL);
222 if (!b) { 222 if (!b) {
223 err("kzalloc(sizeof(buff_t))==NULL"); 223 err("kzalloc(sizeof(buff_t))==NULL");
224 goto err; 224 goto err;
@@ -659,7 +659,7 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm
659 switch (cmd) { 659 switch (cmd) {
660 660
661 case IOCTL_DAB_BULK: 661 case IOCTL_DAB_BULK:
662 pbulk = (pbulk_transfer_t) kmalloc (sizeof (bulk_transfer_t), GFP_KERNEL); 662 pbulk = kmalloc(sizeof (bulk_transfer_t), GFP_KERNEL);
663 663
664 if (!pbulk) { 664 if (!pbulk) {
665 ret = -ENOMEM; 665 ret = -ENOMEM;
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c
index 368d6e219fa4..86d2884e16c6 100644
--- a/drivers/media/video/planb.c
+++ b/drivers/media/video/planb.c
@@ -138,7 +138,7 @@ static int grabbuf_alloc(struct planb *pb)
138 + MAX_LNUM 138 + MAX_LNUM
139#endif /* PLANB_GSCANLINE */ 139#endif /* PLANB_GSCANLINE */
140 ); 140 );
141 if ((pb->rawbuf = (unsigned char**) kmalloc (npage 141 if ((pb->rawbuf = kmalloc(npage
142 * sizeof(unsigned long), GFP_KERNEL)) == 0) 142 * sizeof(unsigned long), GFP_KERNEL)) == 0)
143 return -ENOMEM; 143 return -ENOMEM;
144 for (i = 0; i < npage; i++) { 144 for (i = 0; i < npage; i++) {
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index d8b88024bc2f..b560c9d7c516 100644
--- a/drivers/media/video/usbvideo/usbvideo.c
+++ b/drivers/media/video/usbvideo/usbvideo.c
@@ -690,7 +690,7 @@ int usbvideo_register(
690 } 690 }
691 691
692 base_size = num_cams * sizeof(struct uvd) + sizeof(struct usbvideo); 692 base_size = num_cams * sizeof(struct uvd) + sizeof(struct usbvideo);
693 cams = (struct usbvideo *) kzalloc(base_size, GFP_KERNEL); 693 cams = kzalloc(base_size, GFP_KERNEL);
694 if (cams == NULL) { 694 if (cams == NULL) {
695 err("Failed to allocate %d. bytes for usbvideo struct", base_size); 695 err("Failed to allocate %d. bytes for usbvideo struct", base_size);
696 return -ENOMEM; 696 return -ENOMEM;
diff --git a/drivers/media/video/videocodec.c b/drivers/media/video/videocodec.c
index 2ae3fb250630..290e64135650 100644
--- a/drivers/media/video/videocodec.c
+++ b/drivers/media/video/videocodec.c
@@ -346,7 +346,7 @@ videocodec_build_table (void)
346 size); 346 size);
347 347
348 kfree(videocodec_buf); 348 kfree(videocodec_buf);
349 videocodec_buf = (char *) kmalloc(size, GFP_KERNEL); 349 videocodec_buf = kmalloc(size, GFP_KERNEL);
350 350
351 i = 0; 351 i = 0;
352 i += scnprintf(videocodec_buf + i, size - 1, 352 i += scnprintf(videocodec_buf + i, size - 1,
diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h
index dc388a3ff5e0..cbe384fb848c 100644
--- a/drivers/message/i2o/core.h
+++ b/drivers/message/i2o/core.h
@@ -18,7 +18,7 @@ extern struct i2o_driver i2o_exec_driver;
18extern int i2o_exec_lct_get(struct i2o_controller *); 18extern int i2o_exec_lct_get(struct i2o_controller *);
19 19
20extern int __init i2o_exec_init(void); 20extern int __init i2o_exec_init(void);
21extern void __exit i2o_exec_exit(void); 21extern void i2o_exec_exit(void);
22 22
23/* driver */ 23/* driver */
24extern struct bus_type i2o_bus_type; 24extern struct bus_type i2o_bus_type;
@@ -26,7 +26,7 @@ extern struct bus_type i2o_bus_type;
26extern int i2o_driver_dispatch(struct i2o_controller *, u32); 26extern int i2o_driver_dispatch(struct i2o_controller *, u32);
27 27
28extern int __init i2o_driver_init(void); 28extern int __init i2o_driver_init(void);
29extern void __exit i2o_driver_exit(void); 29extern void i2o_driver_exit(void);
30 30
31/* PCI */ 31/* PCI */
32extern int __init i2o_pci_init(void); 32extern int __init i2o_pci_init(void);
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index 9104b65ff70f..d3235f213c89 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -362,7 +362,7 @@ int __init i2o_driver_init(void)
362 * 362 *
363 * Unregisters the I2O bus and frees driver array. 363 * Unregisters the I2O bus and frees driver array.
364 */ 364 */
365void __exit i2o_driver_exit(void) 365void i2o_driver_exit(void)
366{ 366{
367 bus_unregister(&i2o_bus_type); 367 bus_unregister(&i2o_bus_type);
368 kfree(i2o_drivers); 368 kfree(i2o_drivers);
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 902753b2c661..a539d3b61e76 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -595,7 +595,7 @@ int __init i2o_exec_init(void)
595 * 595 *
596 * Unregisters the Exec OSM from the I2O core. 596 * Unregisters the Exec OSM from the I2O core.
597 */ 597 */
598void __exit i2o_exec_exit(void) 598void i2o_exec_exit(void)
599{ 599{
600 i2o_driver_unregister(&i2o_exec_driver); 600 i2o_driver_unregister(&i2o_exec_driver);
601}; 601};
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 1de30d711671..e33d446e7493 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -186,7 +186,7 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type)
186 if (!dev) 186 if (!dev)
187 return -ENXIO; 187 return -ENXIO;
188 188
189 ops = (u8 *) kmalloc(kcmd.oplen, GFP_KERNEL); 189 ops = kmalloc(kcmd.oplen, GFP_KERNEL);
190 if (!ops) 190 if (!ops)
191 return -ENOMEM; 191 return -ENOMEM;
192 192
@@ -199,7 +199,7 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type)
199 * It's possible to have a _very_ large table 199 * It's possible to have a _very_ large table
200 * and that the user asks for all of it at once... 200 * and that the user asks for all of it at once...
201 */ 201 */
202 res = (u8 *) kmalloc(65536, GFP_KERNEL); 202 res = kmalloc(65536, GFP_KERNEL);
203 if (!res) { 203 if (!res) {
204 kfree(ops); 204 kfree(ops);
205 return -ENOMEM; 205 return -ENOMEM;
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 5db716045927..0a7e86859bf1 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -459,7 +459,7 @@ add_dataflash(struct spi_device *spi, char *name,
459 struct mtd_info *device; 459 struct mtd_info *device;
460 struct flash_platform_data *pdata = spi->dev.platform_data; 460 struct flash_platform_data *pdata = spi->dev.platform_data;
461 461
462 priv = (struct dataflash *) kzalloc(sizeof *priv, GFP_KERNEL); 462 priv = kzalloc(sizeof *priv, GFP_KERNEL);
463 if (!priv) 463 if (!priv)
464 return -ENOMEM; 464 return -ENOMEM;
465 465
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index fa4362fb4dd8..0f3baa5d9c2a 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -768,7 +768,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
768 if (mtd->type != MTD_NORFLASH) 768 if (mtd->type != MTD_NORFLASH)
769 return; 769 return;
770 770
771 part = kcalloc(1, sizeof(struct partition), GFP_KERNEL); 771 part = kzalloc(sizeof(struct partition), GFP_KERNEL);
772 if (!part) 772 if (!part)
773 return; 773 return;
774 774
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index b98592a8bac8..f22e46dfd770 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -186,7 +186,7 @@ static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev)
186 */ 186 */
187static int ipddp_create(struct ipddp_route *new_rt) 187static int ipddp_create(struct ipddp_route *new_rt)
188{ 188{
189 struct ipddp_route *rt =(struct ipddp_route*) kmalloc(sizeof(*rt), GFP_KERNEL); 189 struct ipddp_route *rt = kmalloc(sizeof(*rt), GFP_KERNEL);
190 190
191 if (rt == NULL) 191 if (rt == NULL)
192 return -ENOMEM; 192 return -ENOMEM;
diff --git a/drivers/net/bsd_comp.c b/drivers/net/bsd_comp.c
index bae1de1e7802..7845eaf6f29f 100644
--- a/drivers/net/bsd_comp.c
+++ b/drivers/net/bsd_comp.c
@@ -395,7 +395,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
395 * Allocate the main control structure for this instance. 395 * Allocate the main control structure for this instance.
396 */ 396 */
397 maxmaxcode = MAXCODE(bits); 397 maxmaxcode = MAXCODE(bits);
398 db = (struct bsd_db *) kmalloc (sizeof (struct bsd_db), 398 db = kmalloc(sizeof (struct bsd_db),
399 GFP_KERNEL); 399 GFP_KERNEL);
400 if (!db) 400 if (!db)
401 { 401 {
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 16620bd97fbf..11af0ae7510e 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -1603,7 +1603,7 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid)
1603 irda_qos_bits_to_value (&self->qos); 1603 irda_qos_bits_to_value (&self->qos);
1604 1604
1605 /* Allocate twice the size to guarantee alignment */ 1605 /* Allocate twice the size to guarantee alignment */
1606 self->ringbuf = (void *) kmalloc (OBOE_RING_LEN << 1, GFP_KERNEL); 1606 self->ringbuf = kmalloc(OBOE_RING_LEN << 1, GFP_KERNEL);
1607 if (!self->ringbuf) 1607 if (!self->ringbuf)
1608 { 1608 {
1609 printk (KERN_ERR DRIVER_NAME ": can't allocate DMA buffers\n"); 1609 printk (KERN_ERR DRIVER_NAME ": can't allocate DMA buffers\n");
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 6e95645e7245..3ca1082ec776 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1747,7 +1747,7 @@ static int irda_usb_probe(struct usb_interface *intf,
1747 /* Don't change this buffer size and allocation without doing 1747 /* Don't change this buffer size and allocation without doing
1748 * some heavy and complete testing. Don't ask why :-( 1748 * some heavy and complete testing. Don't ask why :-(
1749 * Jean II */ 1749 * Jean II */
1750 self->speed_buff = (char *) kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL); 1750 self->speed_buff = kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
1751 if (self->speed_buff == NULL) 1751 if (self->speed_buff == NULL)
1752 goto err_out_3; 1752 goto err_out_3;
1753 1753
diff --git a/drivers/net/irda/irport.c b/drivers/net/irda/irport.c
index 654a68b490ae..3098960dc2a1 100644
--- a/drivers/net/irda/irport.c
+++ b/drivers/net/irda/irport.c
@@ -164,7 +164,7 @@ irport_open(int i, unsigned int iobase, unsigned int irq)
164 164
165 /* Allocate memory if needed */ 165 /* Allocate memory if needed */
166 if (self->tx_buff.truesize > 0) { 166 if (self->tx_buff.truesize > 0) {
167 self->tx_buff.head = (__u8 *) kmalloc(self->tx_buff.truesize, 167 self->tx_buff.head = kmalloc(self->tx_buff.truesize,
168 GFP_KERNEL); 168 GFP_KERNEL);
169 if (self->tx_buff.head == NULL) { 169 if (self->tx_buff.head == NULL) {
170 IRDA_ERROR("%s(), can't allocate memory for " 170 IRDA_ERROR("%s(), can't allocate memory for "
diff --git a/drivers/net/lp486e.c b/drivers/net/lp486e.c
index b833016f1825..177c502f7385 100644
--- a/drivers/net/lp486e.c
+++ b/drivers/net/lp486e.c
@@ -884,7 +884,7 @@ static int i596_start_xmit (struct sk_buff *skb, struct net_device *dev) {
884 884
885 dev->trans_start = jiffies; 885 dev->trans_start = jiffies;
886 886
887 tx_cmd = (struct tx_cmd *) kmalloc ((sizeof (struct tx_cmd) + sizeof (struct i596_tbd)), GFP_ATOMIC); 887 tx_cmd = kmalloc((sizeof (struct tx_cmd) + sizeof (struct i596_tbd)), GFP_ATOMIC);
888 if (tx_cmd == NULL) { 888 if (tx_cmd == NULL) {
889 printk(KERN_WARNING "%s: i596_xmit Memory squeeze, dropping packet.\n", dev->name); 889 printk(KERN_WARNING "%s: i596_xmit Memory squeeze, dropping packet.\n", dev->name);
890 lp->stats.tx_dropped++; 890 lp->stats.tx_dropped++;
@@ -1266,7 +1266,7 @@ static void set_multicast_list(struct net_device *dev) {
1266 if (dev->mc_count > 0) { 1266 if (dev->mc_count > 0) {
1267 struct dev_mc_list *dmi; 1267 struct dev_mc_list *dmi;
1268 char *cp; 1268 char *cp;
1269 cmd = (struct i596_cmd *)kmalloc(sizeof(struct i596_cmd)+2+dev->mc_count*6, GFP_ATOMIC); 1269 cmd = kmalloc(sizeof(struct i596_cmd)+2+dev->mc_count*6, GFP_ATOMIC);
1270 if (cmd == NULL) { 1270 if (cmd == NULL) {
1271 printk (KERN_ERR "%s: set_multicast Memory squeeze.\n", dev->name); 1271 printk (KERN_ERR "%s: set_multicast Memory squeeze.\n", dev->name);
1272 return; 1272 return;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index b01fc70a57db..a4d7529ef415 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -50,7 +50,7 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
50 struct phy_device *dev; 50 struct phy_device *dev;
51 /* We allocate the device, and initialize the 51 /* We allocate the device, and initialize the
52 * default values */ 52 * default values */
53 dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); 53 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
54 54
55 if (NULL == dev) 55 if (NULL == dev)
56 return (struct phy_device*) PTR_ERR((void*)-ENOMEM); 56 return (struct phy_device*) PTR_ERR((void*)-ENOMEM);
diff --git a/drivers/net/ppp_deflate.c b/drivers/net/ppp_deflate.c
index f54c55242f4a..72c8d6628f58 100644
--- a/drivers/net/ppp_deflate.c
+++ b/drivers/net/ppp_deflate.c
@@ -121,7 +121,7 @@ static void *z_comp_alloc(unsigned char *options, int opt_len)
121 if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) 121 if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
122 return NULL; 122 return NULL;
123 123
124 state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), 124 state = kmalloc(sizeof(*state),
125 GFP_KERNEL); 125 GFP_KERNEL);
126 if (state == NULL) 126 if (state == NULL)
127 return NULL; 127 return NULL;
@@ -341,7 +341,7 @@ static void *z_decomp_alloc(unsigned char *options, int opt_len)
341 if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) 341 if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
342 return NULL; 342 return NULL;
343 343
344 state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL); 344 state = kmalloc(sizeof(*state), GFP_KERNEL);
345 if (state == NULL) 345 if (state == NULL)
346 return NULL; 346 return NULL;
347 347
diff --git a/drivers/net/ppp_mppe.c b/drivers/net/ppp_mppe.c
index f3655fd772f5..d5bdd2574659 100644
--- a/drivers/net/ppp_mppe.c
+++ b/drivers/net/ppp_mppe.c
@@ -200,7 +200,7 @@ static void *mppe_alloc(unsigned char *options, int optlen)
200 || options[0] != CI_MPPE || options[1] != CILEN_MPPE) 200 || options[0] != CI_MPPE || options[1] != CILEN_MPPE)
201 goto out; 201 goto out;
202 202
203 state = (struct ppp_mppe_state *) kmalloc(sizeof(*state), GFP_KERNEL); 203 state = kmalloc(sizeof(*state), GFP_KERNEL);
204 if (state == NULL) 204 if (state == NULL)
205 goto out; 205 goto out;
206 206
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index b60f0451f6cd..8a39376f87dc 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -749,7 +749,7 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base)
749 struct skge_element *e; 749 struct skge_element *e;
750 int i; 750 int i;
751 751
752 ring->start = kcalloc(sizeof(*e), ring->count, GFP_KERNEL); 752 ring->start = kcalloc(ring->count, sizeof(*e), GFP_KERNEL);
753 if (!ring->start) 753 if (!ring->start)
754 return -ENOMEM; 754 return -ENOMEM;
755 755
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 39c2152a07f4..a0806d262fc6 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -229,10 +229,10 @@ static int sl_realloc_bufs(struct slip *sl, int mtu)
229 if (len < 576 * 2) 229 if (len < 576 * 2)
230 len = 576 * 2; 230 len = 576 * 2;
231 231
232 xbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); 232 xbuff = kmalloc(len + 4, GFP_ATOMIC);
233 rbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); 233 rbuff = kmalloc(len + 4, GFP_ATOMIC);
234#ifdef SL_INCLUDE_CSLIP 234#ifdef SL_INCLUDE_CSLIP
235 cbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); 235 cbuff = kmalloc(len + 4, GFP_ATOMIC);
236#endif 236#endif
237 237
238 238
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c
index a4f735723c41..a02c5fb40567 100644
--- a/drivers/net/wan/hostess_sv11.c
+++ b/drivers/net/wan/hostess_sv11.c
@@ -231,7 +231,7 @@ static struct sv11_device *sv11_init(int iobase, int irq)
231 return NULL; 231 return NULL;
232 } 232 }
233 233
234 sv=(struct sv11_device *)kmalloc(sizeof(struct sv11_device), GFP_KERNEL); 234 sv = kmalloc(sizeof(struct sv11_device), GFP_KERNEL);
235 if(!sv) 235 if(!sv)
236 goto fail3; 236 goto fail3;
237 237
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index 36d1c3ff7078..62184dee377c 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -3455,7 +3455,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3455 if ((err = pci_enable_device(pdev)) < 0) 3455 if ((err = pci_enable_device(pdev)) < 0)
3456 return err; 3456 return err;
3457 3457
3458 card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL); 3458 card = kmalloc(sizeof(pc300_t), GFP_KERNEL);
3459 if (card == NULL) { 3459 if (card == NULL) {
3460 printk("PC300 found at RAM 0x%016llx, " 3460 printk("PC300 found at RAM 0x%016llx, "
3461 "but could not allocate card structure.\n", 3461 "but could not allocate card structure.\n",
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index b2a23aed4428..5873c346e7e9 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -784,7 +784,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
784 continue; 784 continue;
785 } 785 }
786 786
787 new = (st_cpc_rx_buf *)kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC); 787 new = kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC);
788 if (new == 0) { 788 if (new == 0) {
789 cpc_tty_rx_disc_frame(pc300chan); 789 cpc_tty_rx_disc_frame(pc300chan);
790 continue; 790 continue;
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 9c3ccc669143..1c9edd97accd 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -123,8 +123,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
123 unsigned char *xbuff, *rbuff; 123 unsigned char *xbuff, *rbuff;
124 int len = 2* newmtu; 124 int len = 2* newmtu;
125 125
126 xbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); 126 xbuff = kmalloc(len + 4, GFP_ATOMIC);
127 rbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); 127 rbuff = kmalloc(len + 4, GFP_ATOMIC);
128 128
129 if (xbuff == NULL || rbuff == NULL) 129 if (xbuff == NULL || rbuff == NULL)
130 { 130 {
@@ -465,11 +465,11 @@ static int x25_asy_open(struct net_device *dev)
465 465
466 len = dev->mtu * 2; 466 len = dev->mtu * 2;
467 467
468 sl->rbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL); 468 sl->rbuff = kmalloc(len + 4, GFP_KERNEL);
469 if (sl->rbuff == NULL) { 469 if (sl->rbuff == NULL) {
470 goto norbuff; 470 goto norbuff;
471 } 471 }
472 sl->xbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL); 472 sl->xbuff = kmalloc(len + 4, GFP_KERNEL);
473 if (sl->xbuff == NULL) { 473 if (sl->xbuff == NULL) {
474 goto noxbuff; 474 goto noxbuff;
475 } 475 }
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index 974a8e5bec8b..efb8cf3bd8ad 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -1253,7 +1253,7 @@ static char * ap_auth_make_challenge(struct ap_data *ap)
1253 return NULL; 1253 return NULL;
1254 } 1254 }
1255 1255
1256 tmpbuf = (char *) kmalloc(WLAN_AUTH_CHALLENGE_LEN, GFP_ATOMIC); 1256 tmpbuf = kmalloc(WLAN_AUTH_CHALLENGE_LEN, GFP_ATOMIC);
1257 if (tmpbuf == NULL) { 1257 if (tmpbuf == NULL) {
1258 PDEBUG(DEBUG_AP, "AP: kmalloc failed for challenge\n"); 1258 PDEBUG(DEBUG_AP, "AP: kmalloc failed for challenge\n");
1259 return NULL; 1259 return NULL;
diff --git a/drivers/net/wireless/hostap/hostap_download.c b/drivers/net/wireless/hostap/hostap_download.c
index 24fc387bba67..c7678e67697d 100644
--- a/drivers/net/wireless/hostap/hostap_download.c
+++ b/drivers/net/wireless/hostap/hostap_download.c
@@ -201,7 +201,7 @@ static u8 * prism2_read_pda(struct net_device *dev)
201 0x7f0002 /* Intel PRO/Wireless 2011B (PCI) */, 201 0x7f0002 /* Intel PRO/Wireless 2011B (PCI) */,
202 }; 202 };
203 203
204 buf = (u8 *) kmalloc(PRISM2_PDA_SIZE, GFP_KERNEL); 204 buf = kmalloc(PRISM2_PDA_SIZE, GFP_KERNEL);
205 if (buf == NULL) 205 if (buf == NULL)
206 return NULL; 206 return NULL;
207 207
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index a394a23b9a20..3079378fb8cd 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -2252,7 +2252,7 @@ static int hostap_tx_compl_read(local_info_t *local, int error,
2252 if (txdesc->sw_support) { 2252 if (txdesc->sw_support) {
2253 len = le16_to_cpu(txdesc->data_len); 2253 len = le16_to_cpu(txdesc->data_len);
2254 if (len < PRISM2_DATA_MAXLEN) { 2254 if (len < PRISM2_DATA_MAXLEN) {
2255 *payload = (char *) kmalloc(len, GFP_ATOMIC); 2255 *payload = kmalloc(len, GFP_ATOMIC);
2256 if (*payload == NULL || 2256 if (*payload == NULL ||
2257 hfa384x_from_bap(dev, BAP0, *payload, len)) { 2257 hfa384x_from_bap(dev, BAP0, *payload, len)) {
2258 PDEBUG(DEBUG_EXTRA, "%s: could not read TX " 2258 PDEBUG(DEBUG_EXTRA, "%s: could not read TX "
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index 3b7b8063ff1c..cb08bc5db2bd 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -3829,7 +3829,7 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
3829 p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer) 3829 p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
3830 return -EINVAL; 3830 return -EINVAL;
3831 3831
3832 param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL); 3832 param = kmalloc(p->length, GFP_KERNEL);
3833 if (param == NULL) 3833 if (param == NULL)
3834 return -ENOMEM; 3834 return -ENOMEM;
3835 3835
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 0796be9d9e77..04c19cefa1da 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -250,7 +250,7 @@ u16 hostap_tx_callback_register(local_info_t *local,
250 unsigned long flags; 250 unsigned long flags;
251 struct hostap_tx_callback_info *entry; 251 struct hostap_tx_callback_info *entry;
252 252
253 entry = (struct hostap_tx_callback_info *) kmalloc(sizeof(*entry), 253 entry = kmalloc(sizeof(*entry),
254 GFP_ATOMIC); 254 GFP_ATOMIC);
255 if (entry == NULL) 255 if (entry == NULL)
256 return 0; 256 return 0;
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index dd9ba4aad7bb..0e94fbbf7a94 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -2246,7 +2246,7 @@ static int ipw2100_snapshot_alloc(struct ipw2100_priv *priv)
2246 if (priv->snapshot[0]) 2246 if (priv->snapshot[0])
2247 return 1; 2247 return 1;
2248 for (i = 0; i < 0x30; i++) { 2248 for (i = 0; i < 0x30; i++) {
2249 priv->snapshot[i] = (u8 *) kmalloc(0x1000, GFP_ATOMIC); 2249 priv->snapshot[i] = kmalloc(0x1000, GFP_ATOMIC);
2250 if (!priv->snapshot[i]) { 2250 if (!priv->snapshot[i]) {
2251 IPW_DEBUG_INFO("%s: Error allocating snapshot " 2251 IPW_DEBUG_INFO("%s: Error allocating snapshot "
2252 "buffer %d\n", priv->net_dev->name, i); 2252 "buffer %d\n", priv->net_dev->name, i);
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index 96606ed10076..838d510213c6 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -2775,7 +2775,7 @@ prism54_hostapd(struct net_device *ndev, struct iw_point *p)
2775 p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer) 2775 p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
2776 return -EINVAL; 2776 return -EINVAL;
2777 2777
2778 param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL); 2778 param = kmalloc(p->length, GFP_KERNEL);
2779 if (param == NULL) 2779 if (param == NULL)
2780 return -ENOMEM; 2780 return -ENOMEM;
2781 2781
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index 233d906c08f0..5eb81638e846 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -603,7 +603,7 @@ static wavepoint_history *wl_new_wavepoint(unsigned short nwid, unsigned char se
603 if(lp->wavepoint_table.num_wavepoints==MAX_WAVEPOINTS) 603 if(lp->wavepoint_table.num_wavepoints==MAX_WAVEPOINTS)
604 return NULL; 604 return NULL;
605 605
606 new_wavepoint=(wavepoint_history *) kmalloc(sizeof(wavepoint_history),GFP_ATOMIC); 606 new_wavepoint = kmalloc(sizeof(wavepoint_history),GFP_ATOMIC);
607 if(new_wavepoint==NULL) 607 if(new_wavepoint==NULL)
608 return NULL; 608 return NULL;
609 609
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 77e11ddad836..78ea72fb8f0c 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -101,7 +101,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr
101 101
102 /* Allocate a single memory block for values and addresses. */ 102 /* Allocate a single memory block for values and addresses. */
103 count16 = 2*count; 103 count16 = 2*count;
104 a16 = (zd_addr_t *)kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)), 104 a16 = kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)),
105 GFP_NOFS); 105 GFP_NOFS);
106 if (!a16) { 106 if (!a16) {
107 dev_dbg_f(zd_chip_dev(chip), 107 dev_dbg_f(zd_chip_dev(chip),
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 12bab64a62a1..6fb3f7979f21 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -874,7 +874,7 @@ void *iosapic_register(unsigned long hpa)
874 return NULL; 874 return NULL;
875 } 875 }
876 876
877 isi = (struct iosapic_info *)kzalloc(sizeof(struct iosapic_info), GFP_KERNEL); 877 isi = kzalloc(sizeof(struct iosapic_info), GFP_KERNEL);
878 if (!isi) { 878 if (!isi) {
879 BUG(); 879 BUG();
880 return NULL; 880 return NULL;
diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
index 298a6cfd8406..ae5e974c45a7 100644
--- a/drivers/pci/hotplug/cpqphp_nvram.c
+++ b/drivers/pci/hotplug/cpqphp_nvram.c
@@ -520,7 +520,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
520 return 2; 520 return 2;
521 521
522 while (nummem--) { 522 while (nummem--) {
523 mem_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); 523 mem_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
524 524
525 if (!mem_node) 525 if (!mem_node)
526 break; 526 break;
@@ -548,7 +548,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
548 } 548 }
549 549
550 while (numpmem--) { 550 while (numpmem--) {
551 p_mem_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); 551 p_mem_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
552 552
553 if (!p_mem_node) 553 if (!p_mem_node)
554 break; 554 break;
@@ -576,7 +576,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
576 } 576 }
577 577
578 while (numio--) { 578 while (numio--) {
579 io_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); 579 io_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
580 580
581 if (!io_node) 581 if (!io_node)
582 break; 582 break;
@@ -604,7 +604,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
604 } 604 }
605 605
606 while (numbus--) { 606 while (numbus--) {
607 bus_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); 607 bus_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
608 608
609 if (!bus_node) 609 if (!bus_node)
610 break; 610 break;
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 6d3f580f2666..25d3aadfddbf 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -1320,7 +1320,7 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1320 DBG_ENTER_ROUTINE 1320 DBG_ENTER_ROUTINE
1321 1321
1322 spin_lock_init(&list_lock); 1322 spin_lock_init(&list_lock);
1323 php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL); 1323 php_ctlr = kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL);
1324 1324
1325 if (!php_ctlr) { /* allocate controller state data */ 1325 if (!php_ctlr) { /* allocate controller state data */
1326 err("%s: HPC controller memory allocation error!\n", __FUNCTION__); 1326 err("%s: HPC controller memory allocation error!\n", __FUNCTION__);
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index 55866b6b26fa..6f5fabbd14e5 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -148,7 +148,7 @@ static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev)
148{ 148{
149 struct aer_rpc *rpc; 149 struct aer_rpc *rpc;
150 150
151 if (!(rpc = (struct aer_rpc *)kmalloc(sizeof(struct aer_rpc), 151 if (!(rpc = kmalloc(sizeof(struct aer_rpc),
152 GFP_KERNEL))) 152 GFP_KERNEL)))
153 return NULL; 153 return NULL;
154 154
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 52d4a38b3667..3334f22a86c0 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -230,7 +230,7 @@ static int __init at91_cf_probe(struct platform_device *pdev)
230 if (!io) 230 if (!io)
231 return -ENODEV; 231 return -ENODEV;
232 232
233 cf = kcalloc(1, sizeof *cf, GFP_KERNEL); 233 cf = kzalloc(sizeof *cf, GFP_KERNEL);
234 if (!cf) 234 if (!cf)
235 return -ENOMEM; 235 return -ENOMEM;
236 236
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index 06bf7f48836e..e65a6b8188f6 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -220,7 +220,7 @@ static int __devinit omap_cf_probe(struct device *dev)
220 if (irq < 0) 220 if (irq < 0)
221 return -EINVAL; 221 return -EINVAL;
222 222
223 cf = kcalloc(1, sizeof *cf, GFP_KERNEL); 223 cf = kzalloc(sizeof *cf, GFP_KERNEL);
224 if (!cf) 224 if (!cf)
225 return -ENOMEM; 225 return -ENOMEM;
226 init_timer(&cf->timer); 226 init_timer(&cf->timer);
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index 3ac5b123215a..a0b158704ca1 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -395,7 +395,7 @@ static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigne
395 struct pnp_id * id; 395 struct pnp_id * id;
396 if (!dev) 396 if (!dev)
397 return; 397 return;
398 id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); 398 id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
399 if (!id) 399 if (!id)
400 return; 400 return;
401 sprintf(id->id, "%c%c%c%x%x%x%x", 401 sprintf(id->id, "%c%c%c%x%x%x%x",
@@ -419,7 +419,7 @@ static struct pnp_dev * __init isapnp_parse_device(struct pnp_card *card, int si
419 struct pnp_dev *dev; 419 struct pnp_dev *dev;
420 420
421 isapnp_peek(tmp, size); 421 isapnp_peek(tmp, size);
422 dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL); 422 dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
423 if (!dev) 423 if (!dev)
424 return NULL; 424 return NULL;
425 dev->number = number; 425 dev->number = number;
@@ -450,7 +450,7 @@ static void __init isapnp_parse_irq_resource(struct pnp_option *option,
450 unsigned long bits; 450 unsigned long bits;
451 451
452 isapnp_peek(tmp, size); 452 isapnp_peek(tmp, size);
453 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 453 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
454 if (!irq) 454 if (!irq)
455 return; 455 return;
456 bits = (tmp[1] << 8) | tmp[0]; 456 bits = (tmp[1] << 8) | tmp[0];
@@ -474,7 +474,7 @@ static void __init isapnp_parse_dma_resource(struct pnp_option *option,
474 struct pnp_dma *dma; 474 struct pnp_dma *dma;
475 475
476 isapnp_peek(tmp, size); 476 isapnp_peek(tmp, size);
477 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); 477 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
478 if (!dma) 478 if (!dma)
479 return; 479 return;
480 dma->map = tmp[0]; 480 dma->map = tmp[0];
@@ -494,7 +494,7 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option,
494 struct pnp_port *port; 494 struct pnp_port *port;
495 495
496 isapnp_peek(tmp, size); 496 isapnp_peek(tmp, size);
497 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 497 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
498 if (!port) 498 if (!port)
499 return; 499 return;
500 port->min = (tmp[2] << 8) | tmp[1]; 500 port->min = (tmp[2] << 8) | tmp[1];
@@ -517,7 +517,7 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option,
517 struct pnp_port *port; 517 struct pnp_port *port;
518 518
519 isapnp_peek(tmp, size); 519 isapnp_peek(tmp, size);
520 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 520 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
521 if (!port) 521 if (!port)
522 return; 522 return;
523 port->min = port->max = (tmp[1] << 8) | tmp[0]; 523 port->min = port->max = (tmp[1] << 8) | tmp[0];
@@ -539,7 +539,7 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option,
539 struct pnp_mem *mem; 539 struct pnp_mem *mem;
540 540
541 isapnp_peek(tmp, size); 541 isapnp_peek(tmp, size);
542 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 542 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
543 if (!mem) 543 if (!mem)
544 return; 544 return;
545 mem->min = ((tmp[2] << 8) | tmp[1]) << 8; 545 mem->min = ((tmp[2] << 8) | tmp[1]) << 8;
@@ -562,7 +562,7 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option,
562 struct pnp_mem *mem; 562 struct pnp_mem *mem;
563 563
564 isapnp_peek(tmp, size); 564 isapnp_peek(tmp, size);
565 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 565 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
566 if (!mem) 566 if (!mem)
567 return; 567 return;
568 mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; 568 mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
@@ -584,7 +584,7 @@ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option,
584 struct pnp_mem *mem; 584 struct pnp_mem *mem;
585 585
586 isapnp_peek(tmp, size); 586 isapnp_peek(tmp, size);
587 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 587 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
588 if (!mem) 588 if (!mem)
589 return; 589 return;
590 mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; 590 mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
@@ -829,7 +829,7 @@ static unsigned char __init isapnp_checksum(unsigned char *data)
829 829
830static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device) 830static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device)
831{ 831{
832 struct pnp_id * id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); 832 struct pnp_id * id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
833 if (!id) 833 if (!id)
834 return; 834 return;
835 sprintf(id->id, "%c%c%c%x%x%x%x", 835 sprintf(id->id, "%c%c%c%x%x%x%x",
@@ -865,7 +865,7 @@ static int __init isapnp_build_device_list(void)
865 header[4], header[5], header[6], header[7], header[8]); 865 header[4], header[5], header[6], header[7], header[8]);
866 printk(KERN_DEBUG "checksum = 0x%x\n", checksum); 866 printk(KERN_DEBUG "checksum = 0x%x\n", checksum);
867#endif 867#endif
868 if ((card = kcalloc(1, sizeof(struct pnp_card), GFP_KERNEL)) == NULL) 868 if ((card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL)) == NULL)
869 continue; 869 continue;
870 870
871 card->number = csn; 871 card->number = csn;
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 6cf34a63c790..62eda5d59024 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -139,7 +139,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
139 return 0; 139 return 0;
140 140
141 pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); 141 pnp_dbg("ACPI device : hid %s", acpi_device_hid(device));
142 dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL); 142 dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
143 if (!dev) { 143 if (!dev) {
144 pnp_err("Out of memory"); 144 pnp_err("Out of memory");
145 return -ENOMEM; 145 return -ENOMEM;
@@ -169,7 +169,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
169 dev->number = num; 169 dev->number = num;
170 170
171 /* set the initial values for the PnP device */ 171 /* set the initial values for the PnP device */
172 dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); 172 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
173 if (!dev_id) 173 if (!dev_id)
174 goto err; 174 goto err;
175 pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); 175 pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id);
@@ -201,7 +201,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
201 for (i = 0; i < cid_list->count; i++) { 201 for (i = 0; i < cid_list->count; i++) {
202 if (!ispnpidacpi(cid_list->id[i].value)) 202 if (!ispnpidacpi(cid_list->id[i].value))
203 continue; 203 continue;
204 dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); 204 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
205 if (!dev_id) 205 if (!dev_id)
206 continue; 206 continue;
207 207
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 379048fdf05d..7a535542fe92 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -298,7 +298,7 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso
298 298
299 if (p->channel_count == 0) 299 if (p->channel_count == 0)
300 return; 300 return;
301 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); 301 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
302 if (!dma) 302 if (!dma)
303 return; 303 return;
304 304
@@ -354,7 +354,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option,
354 354
355 if (p->interrupt_count == 0) 355 if (p->interrupt_count == 0)
356 return; 356 return;
357 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 357 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
358 if (!irq) 358 if (!irq)
359 return; 359 return;
360 360
@@ -375,7 +375,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
375 375
376 if (p->interrupt_count == 0) 376 if (p->interrupt_count == 0)
377 return; 377 return;
378 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 378 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
379 if (!irq) 379 if (!irq)
380 return; 380 return;
381 381
@@ -396,7 +396,7 @@ pnpacpi_parse_port_option(struct pnp_option *option,
396 396
397 if (io->address_length == 0) 397 if (io->address_length == 0)
398 return; 398 return;
399 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 399 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
400 if (!port) 400 if (!port)
401 return; 401 return;
402 port->min = io->minimum; 402 port->min = io->minimum;
@@ -417,7 +417,7 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
417 417
418 if (io->address_length == 0) 418 if (io->address_length == 0)
419 return; 419 return;
420 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 420 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
421 if (!port) 421 if (!port)
422 return; 422 return;
423 port->min = port->max = io->address; 423 port->min = port->max = io->address;
@@ -436,7 +436,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,
436 436
437 if (p->address_length == 0) 437 if (p->address_length == 0)
438 return; 438 return;
439 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 439 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
440 if (!mem) 440 if (!mem)
441 return; 441 return;
442 mem->min = p->minimum; 442 mem->min = p->minimum;
@@ -459,7 +459,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,
459 459
460 if (p->address_length == 0) 460 if (p->address_length == 0)
461 return; 461 return;
462 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 462 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
463 if (!mem) 463 if (!mem)
464 return; 464 return;
465 mem->min = p->minimum; 465 mem->min = p->minimum;
@@ -482,7 +482,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
482 482
483 if (p->address_length == 0) 483 if (p->address_length == 0)
484 return; 484 return;
485 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 485 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
486 if (!mem) 486 if (!mem)
487 return; 487 return;
488 mem->min = mem->max = p->address; 488 mem->min = mem->max = p->address;
@@ -514,7 +514,7 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
514 return; 514 return;
515 515
516 if (p->resource_type == ACPI_MEMORY_RANGE) { 516 if (p->resource_type == ACPI_MEMORY_RANGE) {
517 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 517 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
518 if (!mem) 518 if (!mem)
519 return; 519 return;
520 mem->min = mem->max = p->minimum; 520 mem->min = mem->max = p->minimum;
@@ -524,7 +524,7 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
524 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; 524 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0;
525 pnp_register_mem_resource(option, mem); 525 pnp_register_mem_resource(option, mem);
526 } else if (p->resource_type == ACPI_IO_RANGE) { 526 } else if (p->resource_type == ACPI_IO_RANGE) {
527 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 527 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
528 if (!port) 528 if (!port)
529 return; 529 return;
530 port->min = port->max = p->minimum; 530 port->min = port->max = p->minimum;
@@ -721,7 +721,7 @@ int pnpacpi_build_resource_template(acpi_handle handle,
721 if (!res_cnt) 721 if (!res_cnt)
722 return -EINVAL; 722 return -EINVAL;
723 buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; 723 buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1;
724 buffer->pointer = kcalloc(1, buffer->length - 1, GFP_KERNEL); 724 buffer->pointer = kzalloc(buffer->length - 1, GFP_KERNEL);
725 if (!buffer->pointer) 725 if (!buffer->pointer)
726 return -ENOMEM; 726 return -ENOMEM;
727 pnp_dbg("Res cnt %d", res_cnt); 727 pnp_dbg("Res cnt %d", res_cnt);
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index 33adeba1a31f..95738dbd5d45 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -109,10 +109,10 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
109 if (!current->fs->root) { 109 if (!current->fs->root) {
110 return -EAGAIN; 110 return -EAGAIN;
111 } 111 }
112 if (!(envp = (char **) kcalloc (20, sizeof (char *), GFP_KERNEL))) { 112 if (!(envp = kcalloc(20, sizeof (char *), GFP_KERNEL))) {
113 return -ENOMEM; 113 return -ENOMEM;
114 } 114 }
115 if (!(buf = kcalloc (1, 256, GFP_KERNEL))) { 115 if (!(buf = kzalloc(256, GFP_KERNEL))) {
116 kfree (envp); 116 kfree (envp);
117 return -ENOMEM; 117 return -ENOMEM;
118 } 118 }
@@ -220,7 +220,7 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table
220 if(!pnpbios_is_dynamic(dev)) 220 if(!pnpbios_is_dynamic(dev))
221 return -EPERM; 221 return -EPERM;
222 222
223 node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); 223 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
224 if (!node) 224 if (!node)
225 return -1; 225 return -1;
226 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { 226 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
@@ -243,7 +243,7 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table
243 if (!pnpbios_is_dynamic(dev)) 243 if (!pnpbios_is_dynamic(dev))
244 return -EPERM; 244 return -EPERM;
245 245
246 node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); 246 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
247 if (!node) 247 if (!node)
248 return -1; 248 return -1;
249 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { 249 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
@@ -294,7 +294,7 @@ static int pnpbios_disable_resources(struct pnp_dev *dev)
294 if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) 294 if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
295 return -EPERM; 295 return -EPERM;
296 296
297 node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); 297 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
298 if (!node) 298 if (!node)
299 return -ENOMEM; 299 return -ENOMEM;
300 300
@@ -336,7 +336,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node)
336 } 336 }
337 337
338 /* set the initial values for the PnP device */ 338 /* set the initial values for the PnP device */
339 dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); 339 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
340 if (!dev_id) 340 if (!dev_id)
341 return -1; 341 return -1;
342 pnpid32_to_pnpid(node->eisa_id,id); 342 pnpid32_to_pnpid(node->eisa_id,id);
@@ -374,7 +374,7 @@ static void __init build_devlist(void)
374 struct pnp_bios_node *node; 374 struct pnp_bios_node *node;
375 struct pnp_dev *dev; 375 struct pnp_dev *dev;
376 376
377 node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); 377 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
378 if (!node) 378 if (!node)
379 return; 379 return;
380 380
@@ -391,7 +391,7 @@ static void __init build_devlist(void)
391 break; 391 break;
392 } 392 }
393 nodes_got++; 393 nodes_got++;
394 dev = kcalloc(1, sizeof (struct pnp_dev), GFP_KERNEL); 394 dev = kzalloc(sizeof (struct pnp_dev), GFP_KERNEL);
395 if (!dev) 395 if (!dev)
396 break; 396 break;
397 if(insert_device(dev,node)<0) 397 if(insert_device(dev,node)<0)
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
index 5a3dfc97f5e9..8027073f7919 100644
--- a/drivers/pnp/pnpbios/proc.c
+++ b/drivers/pnp/pnpbios/proc.c
@@ -87,7 +87,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
87 return -EFBIG; 87 return -EFBIG;
88 } 88 }
89 89
90 tmpbuf = kcalloc(1, escd.escd_size, GFP_KERNEL); 90 tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL);
91 if (!tmpbuf) return -ENOMEM; 91 if (!tmpbuf) return -ENOMEM;
92 92
93 if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { 93 if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) {
@@ -133,7 +133,7 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
133 if (pos >= 0xff) 133 if (pos >= 0xff)
134 return 0; 134 return 0;
135 135
136 node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); 136 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
137 if (!node) return -ENOMEM; 137 if (!node) return -ENOMEM;
138 138
139 for (nodenum=pos; nodenum<0xff; ) { 139 for (nodenum=pos; nodenum<0xff; ) {
@@ -168,7 +168,7 @@ static int proc_read_node(char *buf, char **start, off_t pos,
168 u8 nodenum = (long)data; 168 u8 nodenum = (long)data;
169 int len; 169 int len;
170 170
171 node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); 171 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
172 if (!node) return -ENOMEM; 172 if (!node) return -ENOMEM;
173 if (pnp_bios_get_dev_node(&nodenum, boot, node)) { 173 if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
174 kfree(node); 174 kfree(node);
@@ -188,7 +188,7 @@ static int proc_write_node(struct file *file, const char __user *buf,
188 u8 nodenum = (long)data; 188 u8 nodenum = (long)data;
189 int ret = count; 189 int ret = count;
190 190
191 node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); 191 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
192 if (!node) 192 if (!node)
193 return -ENOMEM; 193 return -ENOMEM;
194 if (pnp_bios_get_dev_node(&nodenum, boot, node)) { 194 if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index ef508a4de557..95b79685a9d1 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -248,7 +248,7 @@ static void
248pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) 248pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option)
249{ 249{
250 struct pnp_mem * mem; 250 struct pnp_mem * mem;
251 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 251 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
252 if (!mem) 252 if (!mem)
253 return; 253 return;
254 mem->min = ((p[5] << 8) | p[4]) << 8; 254 mem->min = ((p[5] << 8) | p[4]) << 8;
@@ -264,7 +264,7 @@ static void
264pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) 264pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option)
265{ 265{
266 struct pnp_mem * mem; 266 struct pnp_mem * mem;
267 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 267 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
268 if (!mem) 268 if (!mem)
269 return; 269 return;
270 mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; 270 mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4];
@@ -280,7 +280,7 @@ static void
280pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) 280pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option)
281{ 281{
282 struct pnp_mem * mem; 282 struct pnp_mem * mem;
283 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 283 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
284 if (!mem) 284 if (!mem)
285 return; 285 return;
286 mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; 286 mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4];
@@ -297,7 +297,7 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option)
297 struct pnp_irq * irq; 297 struct pnp_irq * irq;
298 unsigned long bits; 298 unsigned long bits;
299 299
300 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 300 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
301 if (!irq) 301 if (!irq)
302 return; 302 return;
303 bits = (p[2] << 8) | p[1]; 303 bits = (p[2] << 8) | p[1];
@@ -314,7 +314,7 @@ static void
314pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) 314pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option)
315{ 315{
316 struct pnp_dma * dma; 316 struct pnp_dma * dma;
317 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); 317 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
318 if (!dma) 318 if (!dma)
319 return; 319 return;
320 dma->map = p[1]; 320 dma->map = p[1];
@@ -327,7 +327,7 @@ static void
327pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) 327pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option)
328{ 328{
329 struct pnp_port * port; 329 struct pnp_port * port;
330 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 330 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
331 if (!port) 331 if (!port)
332 return; 332 return;
333 port->min = (p[3] << 8) | p[2]; 333 port->min = (p[3] << 8) | p[2];
@@ -343,7 +343,7 @@ static void
343pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) 343pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option)
344{ 344{
345 struct pnp_port * port; 345 struct pnp_port * port;
346 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 346 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
347 if (!port) 347 if (!port)
348 return; 348 return;
349 port->min = port->max = (p[2] << 8) | p[1]; 349 port->min = port->max = (p[2] << 8) | p[1];
@@ -527,7 +527,7 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de
527 case SMALL_TAG_COMPATDEVID: /* compatible ID */ 527 case SMALL_TAG_COMPATDEVID: /* compatible ID */
528 if (len != 4) 528 if (len != 4)
529 goto len_err; 529 goto len_err;
530 dev_id = kcalloc(1, sizeof (struct pnp_id), GFP_KERNEL); 530 dev_id = kzalloc(sizeof (struct pnp_id), GFP_KERNEL);
531 if (!dev_id) 531 if (!dev_id)
532 return NULL; 532 return NULL;
533 memset(dev_id, 0, sizeof(struct pnp_id)); 533 memset(dev_id, 0, sizeof(struct pnp_id));
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index 5c8addcaf1fb..4f654c901c64 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -137,6 +137,9 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
137 tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year); 137 tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
138 tm->tm_year = at91_alarm_year - 1900; 138 tm->tm_year = at91_alarm_year - 1900;
139 139
140 alrm->enabled = (at91_sys_read(AT91_RTC_IMR) & AT91_RTC_ALARM)
141 ? 1 : 0;
142
140 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, 143 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
141 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, 144 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
142 tm->tm_hour, tm->tm_min, tm->tm_sec); 145 tm->tm_hour, tm->tm_min, tm->tm_sec);
@@ -223,8 +226,6 @@ static int at91_rtc_proc(struct device *dev, struct seq_file *seq)
223{ 226{
224 unsigned long imr = at91_sys_read(AT91_RTC_IMR); 227 unsigned long imr = at91_sys_read(AT91_RTC_IMR);
225 228
226 seq_printf(seq, "alarm_IRQ\t: %s\n",
227 (imr & AT91_RTC_ALARM) ? "yes" : "no");
228 seq_printf(seq, "update_IRQ\t: %s\n", 229 seq_printf(seq, "update_IRQ\t: %s\n",
229 (imr & AT91_RTC_ACKUPD) ? "yes" : "no"); 230 (imr & AT91_RTC_ACKUPD) ? "yes" : "no");
230 seq_printf(seq, "periodic_IRQ\t: %s\n", 231 seq_printf(seq, "periodic_IRQ\t: %s\n",
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 828b329e08e0..94d3df62a5fa 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -435,7 +435,7 @@ static int rtc_dev_add_device(struct class_device *class_dev,
435 goto err_cdev_del; 435 goto err_cdev_del;
436 } 436 }
437 437
438 dev_info(class_dev->dev, "rtc intf: dev (%d:%d)\n", 438 dev_dbg(class_dev->dev, "rtc intf: dev (%d:%d)\n",
439 MAJOR(rtc->rtc_dev->devt), 439 MAJOR(rtc->rtc_dev->devt),
440 MINOR(rtc->rtc_dev->devt)); 440 MINOR(rtc->rtc_dev->devt));
441 441
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index eac5fb1fc02f..d59880d44fba 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -279,9 +279,8 @@ static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
279 local_irq_enable(); 279 local_irq_enable();
280 280
281 bcd2tm(&alm->time); 281 bcd2tm(&alm->time);
282 alm->pending = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG) 282 alm->enabled = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG)
283 & OMAP_RTC_INTERRUPTS_IT_ALARM); 283 & OMAP_RTC_INTERRUPTS_IT_ALARM);
284 alm->enabled = alm->pending && device_may_wakeup(dev);
285 284
286 return 0; 285 return 0;
287} 286}
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index d51d8f20e634..c272afd62173 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -65,7 +65,7 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
65 seq_printf(seq, "%02d\n", alrm.time.tm_mday); 65 seq_printf(seq, "%02d\n", alrm.time.tm_mday);
66 else 66 else
67 seq_printf(seq, "**\n"); 67 seq_printf(seq, "**\n");
68 seq_printf(seq, "alrm_wakeup\t: %s\n", 68 seq_printf(seq, "alarm_IRQ\t: %s\n",
69 alrm.enabled ? "yes" : "no"); 69 alrm.enabled ? "yes" : "no");
70 seq_printf(seq, "alrm_pending\t: %s\n", 70 seq_printf(seq, "alrm_pending\t: %s\n",
71 alrm.pending ? "yes" : "no"); 71 alrm.pending ? "yes" : "no");
@@ -120,7 +120,7 @@ static int rtc_proc_add_device(struct class_device *class_dev,
120 ent->owner = rtc->owner; 120 ent->owner = rtc->owner;
121 ent->data = class_dev; 121 ent->data = class_dev;
122 122
123 dev_info(class_dev->dev, "rtc intf: proc\n"); 123 dev_dbg(class_dev->dev, "rtc intf: proc\n");
124 } 124 }
125 else 125 else
126 rtc_dev = NULL; 126 rtc_dev = NULL;
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index e301dea57bb3..f406a2b55aea 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -191,6 +191,8 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm)
191 191
192 alm_en = readb(base + S3C2410_RTCALM); 192 alm_en = readb(base + S3C2410_RTCALM);
193 193
194 alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0;
195
194 pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n", 196 pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n",
195 alm_en, 197 alm_en,
196 alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, 198 alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday,
@@ -331,12 +333,8 @@ static int s3c_rtc_ioctl(struct device *dev,
331 333
332static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) 334static int s3c_rtc_proc(struct device *dev, struct seq_file *seq)
333{ 335{
334 unsigned int rtcalm = readb(s3c_rtc_base + S3C2410_RTCALM);
335 unsigned int ticnt = readb(s3c_rtc_base + S3C2410_TICNT); 336 unsigned int ticnt = readb(s3c_rtc_base + S3C2410_TICNT);
336 337
337 seq_printf(seq, "alarm_IRQ\t: %s\n",
338 (rtcalm & S3C2410_RTCALM_ALMEN) ? "yes" : "no" );
339
340 seq_printf(seq, "periodic_IRQ\t: %s\n", 338 seq_printf(seq, "periodic_IRQ\t: %s\n",
341 (ticnt & S3C2410_TICNT_ENABLE) ? "yes" : "no" ); 339 (ticnt & S3C2410_TICNT_ENABLE) ? "yes" : "no" );
342 340
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index bd4d7d174ef4..9c8ead43a59c 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -289,9 +289,7 @@ static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
289 289
290static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) 290static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq)
291{ 291{
292 seq_printf(seq, "trim/divider\t: 0x%08lx\n", RTTR); 292 seq_printf(seq, "trim/divider\t: 0x%08x\n", (u32) RTTR);
293 seq_printf(seq, "alarm_IRQ\t: %s\n",
294 (RTSR & RTSR_ALE) ? "yes" : "no" );
295 seq_printf(seq, "update_IRQ\t: %s\n", 293 seq_printf(seq, "update_IRQ\t: %s\n",
296 (RTSR & RTSR_HZE) ? "yes" : "no"); 294 (RTSR & RTSR_HZE) ? "yes" : "no");
297 seq_printf(seq, "periodic_IRQ\t: %s\n", 295 seq_printf(seq, "periodic_IRQ\t: %s\n",
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 625637b84d33..9418a59fb368 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -83,7 +83,7 @@ static int __devinit rtc_sysfs_add_device(struct class_device *class_dev,
83{ 83{
84 int err; 84 int err;
85 85
86 dev_info(class_dev->dev, "rtc intf: sysfs\n"); 86 dev_dbg(class_dev->dev, "rtc intf: sysfs\n");
87 87
88 err = sysfs_create_group(&class_dev->kobj, &rtc_attr_group); 88 err = sysfs_create_group(&class_dev->kobj, &rtc_attr_group);
89 if (err) 89 if (err)
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index c9321b920e90..25b5d7a66417 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -688,7 +688,7 @@ raw3215_probe (struct ccw_device *cdev)
688 raw->cdev = cdev; 688 raw->cdev = cdev;
689 raw->inbuf = (char *) raw + sizeof(struct raw3215_info); 689 raw->inbuf = (char *) raw + sizeof(struct raw3215_info);
690 memset(raw, 0, sizeof(struct raw3215_info)); 690 memset(raw, 0, sizeof(struct raw3215_info));
691 raw->buffer = (char *) kmalloc(RAW3215_BUFFER_SIZE, 691 raw->buffer = kmalloc(RAW3215_BUFFER_SIZE,
692 GFP_KERNEL|GFP_DMA); 692 GFP_KERNEL|GFP_DMA);
693 if (raw->buffer == NULL) { 693 if (raw->buffer == NULL) {
694 spin_lock(&raw3215_device_lock); 694 spin_lock(&raw3215_device_lock);
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c
index e3491a5f5219..3e86fd1756e5 100644
--- a/drivers/s390/char/keyboard.c
+++ b/drivers/s390/char/keyboard.c
@@ -377,7 +377,7 @@ do_kdsk_ioctl(struct kbd_data *kbd, struct kbentry __user *user_kbe,
377 if (!(key_map = kbd->key_maps[tmp.kb_table])) { 377 if (!(key_map = kbd->key_maps[tmp.kb_table])) {
378 int j; 378 int j;
379 379
380 key_map = (ushort *) kmalloc(sizeof(plain_map), 380 key_map = kmalloc(sizeof(plain_map),
381 GFP_KERNEL); 381 GFP_KERNEL);
382 if (!key_map) 382 if (!key_map)
383 return -ENOMEM; 383 return -ENOMEM;
diff --git a/drivers/s390/char/sclp_cpi.c b/drivers/s390/char/sclp_cpi.c
index 732dfbdb85c4..4f873ae148b7 100644
--- a/drivers/s390/char/sclp_cpi.c
+++ b/drivers/s390/char/sclp_cpi.c
@@ -49,6 +49,8 @@ static struct sclp_register sclp_cpi_event =
49 .send_mask = EvTyp_CtlProgIdent_Mask 49 .send_mask = EvTyp_CtlProgIdent_Mask
50}; 50};
51 51
52MODULE_LICENSE("GPL");
53
52MODULE_AUTHOR( 54MODULE_AUTHOR(
53 "Martin Peschke, IBM Deutschland Entwicklung GmbH " 55 "Martin Peschke, IBM Deutschland Entwicklung GmbH "
54 "<mpeschke@de.ibm.com>"); 56 "<mpeschke@de.ibm.com>");
@@ -127,7 +129,7 @@ cpi_prepare_req(void)
127 struct cpi_sccb *sccb; 129 struct cpi_sccb *sccb;
128 struct cpi_evbuf *evb; 130 struct cpi_evbuf *evb;
129 131
130 req = (struct sclp_req *) kmalloc(sizeof(struct sclp_req), GFP_KERNEL); 132 req = kmalloc(sizeof(struct sclp_req), GFP_KERNEL);
131 if (req == NULL) 133 if (req == NULL)
132 return ERR_PTR(-ENOMEM); 134 return ERR_PTR(-ENOMEM);
133 sccb = (struct cpi_sccb *) __get_free_page(GFP_KERNEL | GFP_DMA); 135 sccb = (struct cpi_sccb *) __get_free_page(GFP_KERNEL | GFP_DMA);
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 7835a714a405..3a403f195cf8 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -871,11 +871,32 @@ __clear_subchannel_easy(struct subchannel_id schid)
871 return -EBUSY; 871 return -EBUSY;
872} 872}
873 873
874static int pgm_check_occured;
875
876static void cio_reset_pgm_check_handler(void)
877{
878 pgm_check_occured = 1;
879}
880
881static int stsch_reset(struct subchannel_id schid, volatile struct schib *addr)
882{
883 int rc;
884
885 pgm_check_occured = 0;
886 s390_reset_pgm_handler = cio_reset_pgm_check_handler;
887 rc = stsch(schid, addr);
888 s390_reset_pgm_handler = NULL;
889 if (pgm_check_occured)
890 return -EIO;
891 else
892 return rc;
893}
894
874static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data) 895static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data)
875{ 896{
876 struct schib schib; 897 struct schib schib;
877 898
878 if (stsch_err(schid, &schib)) 899 if (stsch_reset(schid, &schib))
879 return -ENXIO; 900 return -ENXIO;
880 if (!schib.pmcw.ena) 901 if (!schib.pmcw.ena)
881 return 0; 902 return 0;
@@ -972,7 +993,7 @@ static int __reipl_subchannel_match(struct subchannel_id schid, void *data)
972 struct schib schib; 993 struct schib schib;
973 struct sch_match_id *match_id = data; 994 struct sch_match_id *match_id = data;
974 995
975 if (stsch_err(schid, &schib)) 996 if (stsch_reset(schid, &schib))
976 return -ENXIO; 997 return -ENXIO;
977 if (schib.pmcw.dnv && 998 if (schib.pmcw.dnv &&
978 (schib.pmcw.dev == match_id->devid.devno) && 999 (schib.pmcw.dev == match_id->devid.devno) &&
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 4c81d890791e..9d6c02446863 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -139,6 +139,8 @@ css_register_subchannel(struct subchannel *sch)
139 sch->dev.release = &css_subchannel_release; 139 sch->dev.release = &css_subchannel_release;
140 sch->dev.groups = subch_attr_groups; 140 sch->dev.groups = subch_attr_groups;
141 141
142 css_get_ssd_info(sch);
143
142 /* make it known to the system */ 144 /* make it known to the system */
143 ret = css_sch_device_register(sch); 145 ret = css_sch_device_register(sch);
144 if (ret) { 146 if (ret) {
@@ -146,7 +148,6 @@ css_register_subchannel(struct subchannel *sch)
146 __func__, sch->dev.bus_id); 148 __func__, sch->dev.bus_id);
147 return ret; 149 return ret;
148 } 150 }
149 css_get_ssd_info(sch);
150 return ret; 151 return ret;
151} 152}
152 153
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 9d4ea449a608..6fd1940842eb 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -979,12 +979,11 @@ __qdio_outbound_processing(struct qdio_q *q)
979 979
980 if (q->is_iqdio_q) { 980 if (q->is_iqdio_q) {
981 /* 981 /*
982 * for asynchronous queues, we better check, if the fill 982 * for asynchronous queues, we better check, if the sent
983 * level is too high. for synchronous queues, the fill 983 * buffer is already switched from PRIMED to EMPTY.
984 * level will never be that high.
985 */ 984 */
986 if (atomic_read(&q->number_of_buffers_used)> 985 if ((q->queue_type == QDIO_IQDIO_QFMT_ASYNCH) &&
987 IQDIO_FILL_LEVEL_TO_POLL) 986 !qdio_is_outbound_q_done(q))
988 qdio_mark_q(q); 987 qdio_mark_q(q);
989 988
990 } else if (!q->hydra_gives_outbound_pcis) 989 } else if (!q->hydra_gives_outbound_pcis)
@@ -1825,6 +1824,10 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev,
1825 q->sbal[j]=*(outbound_sbals_array++); 1824 q->sbal[j]=*(outbound_sbals_array++);
1826 1825
1827 q->queue_type=q_format; 1826 q->queue_type=q_format;
1827 if ((q->queue_type == QDIO_IQDIO_QFMT) &&
1828 (no_output_qs > 1) &&
1829 (i == no_output_qs-1))
1830 q->queue_type = QDIO_IQDIO_QFMT_ASYNCH;
1828 q->int_parm=int_parm; 1831 q->int_parm=int_parm;
1829 q->is_input_q=0; 1832 q->is_input_q=0;
1830 q->schid = irq_ptr->schid; 1833 q->schid = irq_ptr->schid;
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index ad60afe5dd11..81b5899f4010 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -1129,7 +1129,15 @@ static void ap_poll_thread_stop(void)
1129 mutex_unlock(&ap_poll_thread_mutex); 1129 mutex_unlock(&ap_poll_thread_mutex);
1130} 1130}
1131 1131
1132static void ap_reset(void) 1132static void ap_reset_domain(void)
1133{
1134 int i;
1135
1136 for (i = 0; i < AP_DEVICES; i++)
1137 ap_reset_queue(AP_MKQID(i, ap_domain_index));
1138}
1139
1140static void ap_reset_all(void)
1133{ 1141{
1134 int i, j; 1142 int i, j;
1135 1143
@@ -1139,7 +1147,7 @@ static void ap_reset(void)
1139} 1147}
1140 1148
1141static struct reset_call ap_reset_call = { 1149static struct reset_call ap_reset_call = {
1142 .fn = ap_reset, 1150 .fn = ap_reset_all,
1143}; 1151};
1144 1152
1145/** 1153/**
@@ -1229,10 +1237,12 @@ void ap_module_exit(void)
1229 int i; 1237 int i;
1230 struct device *dev; 1238 struct device *dev;
1231 1239
1240 ap_reset_domain();
1232 ap_poll_thread_stop(); 1241 ap_poll_thread_stop();
1233 del_timer_sync(&ap_config_timer); 1242 del_timer_sync(&ap_config_timer);
1234 del_timer_sync(&ap_poll_timer); 1243 del_timer_sync(&ap_poll_timer);
1235 destroy_workqueue(ap_work_queue); 1244 destroy_workqueue(ap_work_queue);
1245 tasklet_kill(&ap_tasklet);
1236 s390_root_dev_unregister(ap_root_device); 1246 s390_root_dev_unregister(ap_root_device);
1237 while ((dev = bus_find_device(&ap_bus_type, NULL, NULL, 1247 while ((dev = bus_find_device(&ap_bus_type, NULL, NULL,
1238 __ap_match_all))) 1248 __ap_match_all)))
diff --git a/drivers/s390/crypto/zcrypt_cex2a.c b/drivers/s390/crypto/zcrypt_cex2a.c
index a62b00083d0c..5bb13a9d0898 100644
--- a/drivers/s390/crypto/zcrypt_cex2a.c
+++ b/drivers/s390/crypto/zcrypt_cex2a.c
@@ -295,7 +295,7 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_device *zdev,
295 struct completion work; 295 struct completion work;
296 int rc; 296 int rc;
297 297
298 ap_msg.message = (void *) kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); 298 ap_msg.message = kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL);
299 if (!ap_msg.message) 299 if (!ap_msg.message)
300 return -ENOMEM; 300 return -ENOMEM;
301 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 301 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
@@ -337,7 +337,7 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_device *zdev,
337 struct completion work; 337 struct completion work;
338 int rc; 338 int rc;
339 339
340 ap_msg.message = (void *) kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); 340 ap_msg.message = kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL);
341 if (!ap_msg.message) 341 if (!ap_msg.message)
342 return -ENOMEM; 342 return -ENOMEM;
343 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 343 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
diff --git a/drivers/s390/crypto/zcrypt_pcica.c b/drivers/s390/crypto/zcrypt_pcica.c
index b6a4ecdc8025..32e37014345c 100644
--- a/drivers/s390/crypto/zcrypt_pcica.c
+++ b/drivers/s390/crypto/zcrypt_pcica.c
@@ -279,7 +279,7 @@ static long zcrypt_pcica_modexpo(struct zcrypt_device *zdev,
279 struct completion work; 279 struct completion work;
280 int rc; 280 int rc;
281 281
282 ap_msg.message = (void *) kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); 282 ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL);
283 if (!ap_msg.message) 283 if (!ap_msg.message)
284 return -ENOMEM; 284 return -ENOMEM;
285 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 285 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
@@ -321,7 +321,7 @@ static long zcrypt_pcica_modexpo_crt(struct zcrypt_device *zdev,
321 struct completion work; 321 struct completion work;
322 int rc; 322 int rc;
323 323
324 ap_msg.message = (void *) kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); 324 ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL);
325 if (!ap_msg.message) 325 if (!ap_msg.message)
326 return -ENOMEM; 326 return -ENOMEM;
327 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 327 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
diff --git a/drivers/s390/crypto/zcrypt_pcixcc.c b/drivers/s390/crypto/zcrypt_pcixcc.c
index 2da8b9381407..b7153c1e15cd 100644
--- a/drivers/s390/crypto/zcrypt_pcixcc.c
+++ b/drivers/s390/crypto/zcrypt_pcixcc.c
@@ -717,7 +717,7 @@ long zcrypt_pcixcc_send_cprb(struct zcrypt_device *zdev, struct ica_xcRB *xcRB)
717 }; 717 };
718 int rc; 718 int rc;
719 719
720 ap_msg.message = (void *) kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL); 720 ap_msg.message = kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL);
721 if (!ap_msg.message) 721 if (!ap_msg.message)
722 return -ENOMEM; 722 return -ENOMEM;
723 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 723 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
index 3257c22dd79c..03cc263fe0da 100644
--- a/drivers/s390/net/ctcmain.c
+++ b/drivers/s390/net/ctcmain.c
@@ -1646,7 +1646,7 @@ add_channel(struct ccw_device *cdev, enum channel_types type)
1646 return -1; 1646 return -1;
1647 } 1647 }
1648 memset(ch, 0, sizeof (struct channel)); 1648 memset(ch, 0, sizeof (struct channel));
1649 if ((ch->ccw = (struct ccw1 *) kmalloc(8*sizeof(struct ccw1), 1649 if ((ch->ccw = kmalloc(8*sizeof(struct ccw1),
1650 GFP_KERNEL | GFP_DMA)) == NULL) { 1650 GFP_KERNEL | GFP_DMA)) == NULL) {
1651 kfree(ch); 1651 kfree(ch);
1652 ctc_pr_warn("ctc: Out of memory in add_channel\n"); 1652 ctc_pr_warn("ctc: Out of memory in add_channel\n");
@@ -1693,7 +1693,7 @@ add_channel(struct ccw_device *cdev, enum channel_types type)
1693 return -1; 1693 return -1;
1694 } 1694 }
1695 fsm_newstate(ch->fsm, CH_STATE_IDLE); 1695 fsm_newstate(ch->fsm, CH_STATE_IDLE);
1696 if ((ch->irb = (struct irb *) kmalloc(sizeof (struct irb), 1696 if ((ch->irb = kmalloc(sizeof (struct irb),
1697 GFP_KERNEL)) == NULL) { 1697 GFP_KERNEL)) == NULL) {
1698 ctc_pr_warn("ctc: Out of memory in add_channel\n"); 1698 ctc_pr_warn("ctc: Out of memory in add_channel\n");
1699 kfree_fsm(ch->fsm); 1699 kfree_fsm(ch->fsm);
@@ -2535,7 +2535,7 @@ ctc_print_statistics(struct ctc_priv *priv)
2535 DBF_TEXT(trace, 4, __FUNCTION__); 2535 DBF_TEXT(trace, 4, __FUNCTION__);
2536 if (!priv) 2536 if (!priv)
2537 return; 2537 return;
2538 sbuf = (char *)kmalloc(2048, GFP_KERNEL); 2538 sbuf = kmalloc(2048, GFP_KERNEL);
2539 if (sbuf == NULL) 2539 if (sbuf == NULL)
2540 return; 2540 return;
2541 p = sbuf; 2541 p = sbuf;
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
index 1476ce2b437c..229aeb5fc399 100644
--- a/drivers/s390/net/iucv.c
+++ b/drivers/s390/net/iucv.c
@@ -772,7 +772,7 @@ iucv_register_program (__u8 pgmname[16],
772 } 772 }
773 773
774 /* Allocate handler entry */ 774 /* Allocate handler entry */
775 new_handler = (handler *)kmalloc(sizeof(handler), GFP_ATOMIC); 775 new_handler = kmalloc(sizeof(handler), GFP_ATOMIC);
776 if (new_handler == NULL) { 776 if (new_handler == NULL) {
777 printk(KERN_WARNING "%s: storage allocation for new handler " 777 printk(KERN_WARNING "%s: storage allocation for new handler "
778 "failed.\n", __FUNCTION__); 778 "failed.\n", __FUNCTION__);
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 5d39b2df0cc4..85093b71f9fa 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -237,7 +237,7 @@ zfcp_device_setup(char *devstr)
237 return 0; 237 return 0;
238 238
239 len = strlen(devstr) + 1; 239 len = strlen(devstr) + 1;
240 str = (char *) kmalloc(len, GFP_KERNEL); 240 str = kmalloc(len, GFP_KERNEL);
241 if (!str) 241 if (!str)
242 goto err_out; 242 goto err_out;
243 memcpy(str, devstr, len); 243 memcpy(str, devstr, len);
diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c
index 2722af5d3404..386e7de0b7e3 100644
--- a/drivers/sbus/char/vfc_dev.c
+++ b/drivers/sbus/char/vfc_dev.c
@@ -659,7 +659,7 @@ static int vfc_probe(void)
659 if (!cards) 659 if (!cards)
660 return -ENODEV; 660 return -ENODEV;
661 661
662 vfc_dev_lst = (struct vfc_dev **)kmalloc(sizeof(struct vfc_dev *) * 662 vfc_dev_lst = kmalloc(sizeof(struct vfc_dev *) *
663 (cards+1), 663 (cards+1),
664 GFP_KERNEL); 664 GFP_KERNEL);
665 if (vfc_dev_lst == NULL) 665 if (vfc_dev_lst == NULL)
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index ac108f9e2674..426cd6f49f5d 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -288,7 +288,7 @@ int aac_get_containers(struct aac_dev *dev)
288 288
289 if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS) 289 if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)
290 maximum_num_containers = MAXIMUM_NUM_CONTAINERS; 290 maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
291 fsa_dev_ptr = (struct fsa_dev_info *) kmalloc( 291 fsa_dev_ptr = kmalloc(
292 sizeof(*fsa_dev_ptr) * maximum_num_containers, GFP_KERNEL); 292 sizeof(*fsa_dev_ptr) * maximum_num_containers, GFP_KERNEL);
293 if (!fsa_dev_ptr) { 293 if (!fsa_dev_ptr) {
294 aac_fib_free(fibptr); 294 aac_fib_free(fibptr);
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index d5cf8b91a0e7..6d305b2f854e 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -386,7 +386,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
386 * Ok now init the communication subsystem 386 * Ok now init the communication subsystem
387 */ 387 */
388 388
389 dev->queues = (struct aac_queue_block *) kmalloc(sizeof(struct aac_queue_block), GFP_KERNEL); 389 dev->queues = kmalloc(sizeof(struct aac_queue_block), GFP_KERNEL);
390 if (dev->queues == NULL) { 390 if (dev->queues == NULL) {
391 printk(KERN_ERR "Error could not allocate comm region.\n"); 391 printk(KERN_ERR "Error could not allocate comm region.\n");
392 return NULL; 392 return NULL;
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index d7a61a6bdaae..1d239f6c0103 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -699,7 +699,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
699#endif 699#endif
700 int i; 700 int i;
701 ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ 701 ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */
702 SCpnt->host_scribble = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA); 702 SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA);
703 sgpnt = (struct scatterlist *) SCpnt->request_buffer; 703 sgpnt = (struct scatterlist *) SCpnt->request_buffer;
704 cptr = (struct chain *) SCpnt->host_scribble; 704 cptr = (struct chain *) SCpnt->host_scribble;
705 if (cptr == NULL) { 705 if (cptr == NULL) {
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index 46eed10b25d9..7d1fec620948 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -2565,7 +2565,7 @@ aic7xxx_allocate_scb(struct aic7xxx_host *p)
2565 } 2565 }
2566 } 2566 }
2567 scb_count = min( (i-1), p->scb_data->maxscbs - p->scb_data->numscbs); 2567 scb_count = min( (i-1), p->scb_data->maxscbs - p->scb_data->numscbs);
2568 scb_ap = (struct aic7xxx_scb *)kmalloc(sizeof (struct aic7xxx_scb) * scb_count 2568 scb_ap = kmalloc(sizeof (struct aic7xxx_scb) * scb_count
2569 + sizeof(struct aic7xxx_scb_dma), GFP_ATOMIC); 2569 + sizeof(struct aic7xxx_scb_dma), GFP_ATOMIC);
2570 if (scb_ap == NULL) 2570 if (scb_ap == NULL)
2571 return(0); 2571 return(0);
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index e95b367d09ed..a965ed3548d5 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -4319,7 +4319,7 @@ static int __devinit adapter_sg_tables_alloc(struct AdapterCtlBlk *acb)
4319 4319
4320 dprintkdbg(DBG_1, "Allocate %i pages for SG tables\n", pages); 4320 dprintkdbg(DBG_1, "Allocate %i pages for SG tables\n", pages);
4321 while (pages--) { 4321 while (pages--) {
4322 ptr = (struct SGentry *)kmalloc(PAGE_SIZE, GFP_KERNEL); 4322 ptr = kmalloc(PAGE_SIZE, GFP_KERNEL);
4323 if (!ptr) { 4323 if (!ptr) {
4324 adapter_sg_tables_free(acb); 4324 adapter_sg_tables_free(acb);
4325 return 1; 4325 return 1;
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 60b1b434eba7..365db537a28d 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -297,7 +297,7 @@ static void adpt_inquiry(adpt_hba* pHba)
297 s32 rcode; 297 s32 rcode;
298 298
299 memset(msg, 0, sizeof(msg)); 299 memset(msg, 0, sizeof(msg));
300 buf = (u8*)kmalloc(80,GFP_KERNEL|ADDR32); 300 buf = kmalloc(80,GFP_KERNEL|ADDR32);
301 if(!buf){ 301 if(!buf){
302 printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name); 302 printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name);
303 return; 303 return;
@@ -1311,7 +1311,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba)
1311 schedule_timeout_uninterruptible(1); 1311 schedule_timeout_uninterruptible(1);
1312 } while (m == EMPTY_QUEUE); 1312 } while (m == EMPTY_QUEUE);
1313 1313
1314 status = (u8*)kmalloc(4, GFP_KERNEL|ADDR32); 1314 status = kmalloc(4, GFP_KERNEL|ADDR32);
1315 if(status == NULL) { 1315 if(status == NULL) {
1316 adpt_send_nop(pHba, m); 1316 adpt_send_nop(pHba, m);
1317 printk(KERN_ERR"IOP reset failed - no free memory.\n"); 1317 printk(KERN_ERR"IOP reset failed - no free memory.\n");
@@ -1444,7 +1444,7 @@ static int adpt_i2o_parse_lct(adpt_hba* pHba)
1444 } 1444 }
1445 continue; 1445 continue;
1446 } 1446 }
1447 d = (struct i2o_device *)kmalloc(sizeof(struct i2o_device), GFP_KERNEL); 1447 d = kmalloc(sizeof(struct i2o_device), GFP_KERNEL);
1448 if(d==NULL) 1448 if(d==NULL)
1449 { 1449 {
1450 printk(KERN_CRIT"%s: Out of memory for I2O device data.\n",pHba->name); 1450 printk(KERN_CRIT"%s: Out of memory for I2O device data.\n",pHba->name);
@@ -2425,7 +2425,7 @@ static s32 adpt_i2o_reparse_lct(adpt_hba* pHba)
2425 pDev = pDev->next_lun; 2425 pDev = pDev->next_lun;
2426 } 2426 }
2427 if(!pDev ) { // Something new add it 2427 if(!pDev ) { // Something new add it
2428 d = (struct i2o_device *)kmalloc(sizeof(struct i2o_device), GFP_KERNEL); 2428 d = kmalloc(sizeof(struct i2o_device), GFP_KERNEL);
2429 if(d==NULL) 2429 if(d==NULL)
2430 { 2430 {
2431 printk(KERN_CRIT "Out of memory for I2O device data.\n"); 2431 printk(KERN_CRIT "Out of memory for I2O device data.\n");
@@ -2728,7 +2728,7 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
2728 2728
2729 kfree(pHba->reply_pool); 2729 kfree(pHba->reply_pool);
2730 2730
2731 pHba->reply_pool = (u32*)kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32); 2731 pHba->reply_pool = kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32);
2732 if(!pHba->reply_pool){ 2732 if(!pHba->reply_pool){
2733 printk(KERN_ERR"%s: Could not allocate reply pool\n",pHba->name); 2733 printk(KERN_ERR"%s: Could not allocate reply pool\n",pHba->name);
2734 return -1; 2734 return -1;
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index f160357e37a6..d561663fb4e4 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -2828,7 +2828,7 @@ static int i91u_detect(struct scsi_host_template * tpnt)
2828 2828
2829 for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) { 2829 for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) {
2830 i = tul_num_ch * tul_num_scb * sizeof(SCB); 2830 i = tul_num_ch * tul_num_scb * sizeof(SCB);
2831 if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL) 2831 if ((tul_scb = kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL)
2832 break; 2832 break;
2833 } 2833 }
2834 if (tul_scb == NULL) { 2834 if (tul_scb == NULL) {
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 824fe080d1dc..7d2311067903 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5777,7 +5777,7 @@ static int osst_probe(struct device *dev)
5777 dev_num = i; 5777 dev_num = i;
5778 5778
5779 /* allocate a struct osst_tape for this device */ 5779 /* allocate a struct osst_tape for this device */
5780 tpnt = (struct osst_tape *)kmalloc(sizeof(struct osst_tape), GFP_ATOMIC); 5780 tpnt = kmalloc(sizeof(struct osst_tape), GFP_ATOMIC);
5781 if (tpnt == NULL) { 5781 if (tpnt == NULL) {
5782 write_unlock(&os_scsi_tapes_lock); 5782 write_unlock(&os_scsi_tapes_lock);
5783 printk(KERN_ERR "osst :E: Can't allocate device descriptor, device not attached.\n"); 5783 printk(KERN_ERR "osst :E: Can't allocate device descriptor, device not attached.\n");
diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c
index aa60a5f1fbc3..3b2e1a53e6e2 100644
--- a/drivers/scsi/pluto.c
+++ b/drivers/scsi/pluto.c
@@ -117,7 +117,7 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
117#endif 117#endif
118 return 0; 118 return 0;
119 } 119 }
120 fcs = (struct ctrl_inquiry *) kmalloc (sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA); 120 fcs = kmalloc(sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA);
121 if (!fcs) { 121 if (!fcs) {
122 printk ("PLUTO: Not enough memory to probe\n"); 122 printk ("PLUTO: Not enough memory to probe\n");
123 return 0; 123 return 0;
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index d1268cb46837..0578ba42718b 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -546,7 +546,7 @@ int sr_is_xa(Scsi_CD *cd)
546 if (!xa_test) 546 if (!xa_test)
547 return 0; 547 return 0;
548 548
549 raw_sector = (unsigned char *) kmalloc(2048, GFP_KERNEL | SR_GFP_DMA(cd)); 549 raw_sector = kmalloc(2048, GFP_KERNEL | SR_GFP_DMA(cd));
550 if (!raw_sector) 550 if (!raw_sector)
551 return -ENOMEM; 551 return -ENOMEM;
552 if (0 == sr_read_sector(cd, cd->ms_offset + 16, 552 if (0 == sr_read_sector(cd, cd->ms_offset + 16,
diff --git a/drivers/scsi/sr_vendor.c b/drivers/scsi/sr_vendor.c
index a3e9d0f2eb5b..4eb3da996b36 100644
--- a/drivers/scsi/sr_vendor.c
+++ b/drivers/scsi/sr_vendor.c
@@ -117,7 +117,7 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength)
117 density = (blocklength > 2048) ? 0x81 : 0x83; 117 density = (blocklength > 2048) ? 0x81 : 0x83;
118#endif 118#endif
119 119
120 buffer = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA); 120 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
121 if (!buffer) 121 if (!buffer)
122 return -ENOMEM; 122 return -ENOMEM;
123 123
@@ -164,7 +164,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
164 if (cd->cdi.mask & CDC_MULTI_SESSION) 164 if (cd->cdi.mask & CDC_MULTI_SESSION)
165 return 0; 165 return 0;
166 166
167 buffer = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA); 167 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
168 if (!buffer) 168 if (!buffer)
169 return -ENOMEM; 169 return -ENOMEM;
170 170
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index 43f5b6aa7dc4..98e3fe10c1dc 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -266,7 +266,7 @@ static struct scsi_host_template *the_template = NULL;
266 (struct NCR5380_hostdata *)(in)->hostdata 266 (struct NCR5380_hostdata *)(in)->hostdata
267#define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata) 267#define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata)
268 268
269#define NEXT(cmd) ((struct scsi_cmnd *)((cmd)->host_scribble)) 269#define NEXT(cmd) (*(struct scsi_cmnd **)&((cmd)->host_scribble))
270#define NEXTADDR(cmd) ((struct scsi_cmnd **)&((cmd)->host_scribble)) 270#define NEXTADDR(cmd) ((struct scsi_cmnd **)&((cmd)->host_scribble))
271 271
272#define HOSTNO instance->host_no 272#define HOSTNO instance->host_no
@@ -650,7 +650,7 @@ __inline__ void NCR5380_print_phase(struct Scsi_Host *instance) { };
650#include <linux/interrupt.h> 650#include <linux/interrupt.h>
651 651
652static volatile int main_running = 0; 652static volatile int main_running = 0;
653static DECLARE_WORK(NCR5380_tqueue, (void (*)(void*))NCR5380_main, NULL); 653static DECLARE_WORK(NCR5380_tqueue, NCR5380_main);
654 654
655static __inline__ void queue_main(void) 655static __inline__ void queue_main(void)
656{ 656{
@@ -1031,7 +1031,7 @@ static int NCR5380_queue_command(struct scsi_cmnd *cmd,
1031 * reenable them. This prevents reentrancy and kernel stack overflow. 1031 * reenable them. This prevents reentrancy and kernel stack overflow.
1032 */ 1032 */
1033 1033
1034static void NCR5380_main (void *bl) 1034static void NCR5380_main (struct work_struct *bl)
1035{ 1035{
1036 struct scsi_cmnd *tmp, *prev; 1036 struct scsi_cmnd *tmp, *prev;
1037 struct Scsi_Host *instance = first_instance; 1037 struct Scsi_Host *instance = first_instance;
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index 940fa1e6f994..21cd4c7f5289 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -5545,7 +5545,7 @@ int sym_hcb_attach(struct Scsi_Host *shost, struct sym_fw *fw, struct sym_nvram
5545 /* 5545 /*
5546 * Allocate the array of lists of CCBs hashed by DSA. 5546 * Allocate the array of lists of CCBs hashed by DSA.
5547 */ 5547 */
5548 np->ccbh = kcalloc(sizeof(struct sym_ccb **), CCB_HASH_SIZE, GFP_KERNEL); 5548 np->ccbh = kcalloc(CCB_HASH_SIZE, sizeof(struct sym_ccb **), GFP_KERNEL);
5549 if (!np->ccbh) 5549 if (!np->ccbh)
5550 goto attach_failed; 5550 goto attach_failed;
5551 5551
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 4d0ff8f4a01b..52e2e64c6649 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -2239,6 +2239,30 @@ static struct pci_device_id serial_pci_tbl[] = {
2239 pbn_b0_bt_1_460800 }, 2239 pbn_b0_bt_1_460800 },
2240 2240
2241 /* 2241 /*
2242 * Korenix Jetcard F0/F1 cards (JC1204, JC1208, JC1404, JC1408).
2243 * Cards are identified by their subsystem vendor IDs, which
2244 * (in hex) match the model number.
2245 *
2246 * Note that JC140x are RS422/485 cards which require ox950
2247 * ACR = 0x10, and as such are not currently fully supported.
2248 */
2249 { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF0,
2250 0x1204, 0x0004, 0, 0,
2251 pbn_b0_4_921600 },
2252 { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF0,
2253 0x1208, 0x0004, 0, 0,
2254 pbn_b0_4_921600 },
2255/* { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF0,
2256 0x1402, 0x0002, 0, 0,
2257 pbn_b0_2_921600 }, */
2258/* { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF0,
2259 0x1404, 0x0004, 0, 0,
2260 pbn_b0_4_921600 }, */
2261 { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF1,
2262 0x1208, 0x0004, 0, 0,
2263 pbn_b0_4_921600 },
2264
2265 /*
2242 * Dell Remote Access Card 4 - Tim_T_Murphy@Dell.com 2266 * Dell Remote Access Card 4 - Tim_T_Murphy@Dell.com
2243 */ 2267 */
2244 { PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_DELL_RAC4, 2268 { PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_DELL_RAC4,
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 72f3db99ff94..3e0abbb49fe1 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -598,7 +598,7 @@ at91_ep_alloc_request(struct usb_ep *_ep, unsigned int gfp_flags)
598{ 598{
599 struct at91_request *req; 599 struct at91_request *req;
600 600
601 req = kcalloc(1, sizeof (struct at91_request), gfp_flags); 601 req = kzalloc(sizeof (struct at91_request), gfp_flags);
602 if (!req) 602 if (!req)
603 return NULL; 603 return NULL;
604 604
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 5516c59ed5ec..2d12bf9f19d6 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -2195,7 +2195,7 @@ static struct gs_buf *gs_buf_alloc(unsigned int size, gfp_t kmalloc_flags)
2195 if (size == 0) 2195 if (size == 0)
2196 return NULL; 2196 return NULL;
2197 2197
2198 gb = (struct gs_buf *)kmalloc(sizeof(struct gs_buf), kmalloc_flags); 2198 gb = kmalloc(sizeof(struct gs_buf), kmalloc_flags);
2199 if (gb == NULL) 2199 if (gb == NULL)
2200 return NULL; 2200 return NULL;
2201 2201
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 9325e46a68c0..282d82efc0b0 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -365,7 +365,7 @@ static inline struct urb *urb_list_first(int epid)
365/* Adds an urb_entry last in the list for this epid. */ 365/* Adds an urb_entry last in the list for this epid. */
366static inline void urb_list_add(struct urb *urb, int epid) 366static inline void urb_list_add(struct urb *urb, int epid)
367{ 367{
368 urb_entry_t *urb_entry = (urb_entry_t *)kmalloc(sizeof(urb_entry_t), KMALLOC_FLAG); 368 urb_entry_t *urb_entry = kmalloc(sizeof(urb_entry_t), KMALLOC_FLAG);
369 assert(urb_entry); 369 assert(urb_entry);
370 370
371 urb_entry->urb = urb; 371 urb_entry->urb = urb;
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index c703f73e1655..6c7f3efb1d40 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -766,7 +766,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
766 bep->bufp = kmalloc (bufsize, GFP_KERNEL); 766 bep->bufp = kmalloc (bufsize, GFP_KERNEL);
767 if (!bep->bufp) 767 if (!bep->bufp)
768 goto bl_fail; 768 goto bl_fail;
769 bep->dr = (struct usb_ctrlrequest *) kmalloc (sizeof (struct usb_ctrlrequest), GFP_KERNEL); 769 bep->dr = kmalloc(sizeof (struct usb_ctrlrequest), GFP_KERNEL);
770 if (!bep->dr) 770 if (!bep->dr)
771 goto bl_fail; 771 goto bl_fail;
772 bep->urbp = usb_alloc_urb (0, GFP_KERNEL); 772 bep->urbp = usb_alloc_urb (0, GFP_KERNEL);
@@ -1969,7 +1969,7 @@ static int auerswald_probe (struct usb_interface *intf,
1969 info("device is a %s", cp->dev_desc); 1969 info("device is a %s", cp->dev_desc);
1970 1970
1971 /* get the maximum allowed control transfer length */ 1971 /* get the maximum allowed control transfer length */
1972 pbuf = (__le16 *) kmalloc (2, GFP_KERNEL); /* use an allocated buffer because of urb target */ 1972 pbuf = kmalloc(2, GFP_KERNEL); /* use an allocated buffer because of urb target */
1973 if (!pbuf) { 1973 if (!pbuf) {
1974 err( "out of memory"); 1974 err( "out of memory");
1975 goto pfail; 1975 goto pfail;
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 7e8a0acd52ee..70250252ae2a 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -705,7 +705,7 @@ static int uss720_probe(struct usb_interface *intf,
705 /* 705 /*
706 * Allocate parport interface 706 * Allocate parport interface
707 */ 707 */
708 if (!(priv = kcalloc(sizeof(struct parport_uss720_private), 1, GFP_KERNEL))) { 708 if (!(priv = kzalloc(sizeof(struct parport_uss720_private), GFP_KERNEL))) {
709 usb_put_dev(usbdev); 709 usb_put_dev(usbdev);
710 return -ENOMEM; 710 return -ENOMEM;
711 } 711 }
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c
index 99f26b3e502f..ea5f44de3de2 100644
--- a/drivers/usb/net/rndis_host.c
+++ b/drivers/usb/net/rndis_host.c
@@ -469,7 +469,7 @@ static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
469 struct rndis_halt *halt; 469 struct rndis_halt *halt;
470 470
471 /* try to clear any rndis state/activity (no i/o from stack!) */ 471 /* try to clear any rndis state/activity (no i/o from stack!) */
472 halt = kcalloc(1, sizeof *halt, GFP_KERNEL); 472 halt = kzalloc(sizeof *halt, GFP_KERNEL);
473 if (halt) { 473 if (halt) {
474 halt->msg_type = RNDIS_MSG_HALT; 474 halt->msg_type = RNDIS_MSG_HALT;
475 halt->msg_len = ccpu2(sizeof *halt); 475 halt->msg_len = ccpu2(sizeof *halt);
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index a1fdb85b8c0a..45cdf9bc43b2 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -1493,7 +1493,7 @@ static struct cypress_buf *cypress_buf_alloc(unsigned int size)
1493 if (size == 0) 1493 if (size == 0)
1494 return NULL; 1494 return NULL;
1495 1495
1496 cb = (struct cypress_buf *)kmalloc(sizeof(struct cypress_buf), GFP_KERNEL); 1496 cb = kmalloc(sizeof(struct cypress_buf), GFP_KERNEL);
1497 if (cb == NULL) 1497 if (cb == NULL)
1498 return NULL; 1498 return NULL;
1499 1499
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 9d9ea874639c..efd9ce3f931f 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -1681,7 +1681,7 @@ dbg( "digi_startup: TOP" );
1681 for( i=0; i<serial->type->num_ports+1; i++ ) { 1681 for( i=0; i<serial->type->num_ports+1; i++ ) {
1682 1682
1683 /* allocate port private structure */ 1683 /* allocate port private structure */
1684 priv = (struct digi_port *)kmalloc( sizeof(struct digi_port), 1684 priv = kmalloc( sizeof(struct digi_port),
1685 GFP_KERNEL ); 1685 GFP_KERNEL );
1686 if( priv == (struct digi_port *)0 ) { 1686 if( priv == (struct digi_port *)0 ) {
1687 while( --i >= 0 ) 1687 while( --i >= 0 )
@@ -1714,7 +1714,7 @@ dbg( "digi_startup: TOP" );
1714 } 1714 }
1715 1715
1716 /* allocate serial private structure */ 1716 /* allocate serial private structure */
1717 serial_priv = (struct digi_serial *)kmalloc( sizeof(struct digi_serial), 1717 serial_priv = kmalloc( sizeof(struct digi_serial),
1718 GFP_KERNEL ); 1718 GFP_KERNEL );
1719 if( serial_priv == (struct digi_serial *)0 ) { 1719 if( serial_priv == (struct digi_serial *)0 ) {
1720 for( i=0; i<serial->type->num_ports+1; i++ ) 1720 for( i=0; i<serial->type->num_ports+1; i++ )
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 2da2684e0809..980285c0233a 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2811,7 +2811,7 @@ static struct edge_buf *edge_buf_alloc(unsigned int size)
2811 if (size == 0) 2811 if (size == 0)
2812 return NULL; 2812 return NULL;
2813 2813
2814 eb = (struct edge_buf *)kmalloc(sizeof(struct edge_buf), GFP_KERNEL); 2814 eb = kmalloc(sizeof(struct edge_buf), GFP_KERNEL);
2815 if (eb == NULL) 2815 if (eb == NULL)
2816 return NULL; 2816 return NULL;
2817 2817
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index d72cf8bc7f76..42f757a5b876 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -595,7 +595,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
595 595
596 bytes_in = 0; 596 bytes_in = 0;
597 bytes_out = 0; 597 bytes_out = 0;
598 priv = (struct ipaq_private *)kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); 598 priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL);
599 if (priv == NULL) { 599 if (priv == NULL) {
600 err("%s - Out of memory", __FUNCTION__); 600 err("%s - Out of memory", __FUNCTION__);
601 return -ENOMEM; 601 return -ENOMEM;
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index e284d6c0fd35..62bea0c923bd 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -269,7 +269,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
269 } 269 }
270 270
271 // allocate memory for write_urb transfer buffer 271 // allocate memory for write_urb transfer buffer
272 port->write_urb->transfer_buffer = (unsigned char *) kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL); 272 port->write_urb->transfer_buffer = kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL);
273 if (! port->write_urb->transfer_buffer) { 273 if (! port->write_urb->transfer_buffer) {
274 kfree(transfer_buffer); 274 kfree(transfer_buffer);
275 usb_free_urb(port->write_urb); 275 usb_free_urb(port->write_urb);
@@ -696,7 +696,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file,
696 return 0; 696 return 0;
697 697
698 case TCFLSH: // 0x540B 698 case TCFLSH: // 0x540B
699 transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL); 699 transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL);
700 if (! transfer_buffer) { 700 if (! transfer_buffer) {
701 return -ENOBUFS; 701 return -ENOBUFS;
702 } 702 }
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index d124d780e42e..5dc2ac9afa90 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -159,7 +159,7 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size)
159 if (size == 0) 159 if (size == 0)
160 return NULL; 160 return NULL;
161 161
162 pb = (struct pl2303_buf *)kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL); 162 pb = kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL);
163 if (pb == NULL) 163 if (pb == NULL)
164 return NULL; 164 return NULL;
165 165
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index f42eb9ea6405..83189005c6fb 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1710,7 +1710,7 @@ static struct circ_buf *ti_buf_alloc(void)
1710{ 1710{
1711 struct circ_buf *cb; 1711 struct circ_buf *cb;
1712 1712
1713 cb = (struct circ_buf *)kmalloc(sizeof(struct circ_buf), GFP_KERNEL); 1713 cb = kmalloc(sizeof(struct circ_buf), GFP_KERNEL);
1714 if (cb == NULL) 1714 if (cb == NULL)
1715 return NULL; 1715 return NULL;
1716 1716
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index dc45e58e2b8c..5483d8564c1b 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -416,7 +416,7 @@ static int whiteheat_attach (struct usb_serial *serial)
416 for (i = 0; i < serial->num_ports; i++) { 416 for (i = 0; i < serial->num_ports; i++) {
417 port = serial->port[i]; 417 port = serial->port[i];
418 418
419 info = (struct whiteheat_private *)kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); 419 info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL);
420 if (info == NULL) { 420 if (info == NULL) {
421 err("%s: Out of memory for port structures\n", serial->type->description); 421 err("%s: Out of memory for port structures\n", serial->type->description);
422 goto no_private; 422 goto no_private;
@@ -487,7 +487,7 @@ static int whiteheat_attach (struct usb_serial *serial)
487 usb_set_serial_port_data(port, info); 487 usb_set_serial_port_data(port, info);
488 } 488 }
489 489
490 command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); 490 command_info = kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL);
491 if (command_info == NULL) { 491 if (command_info == NULL) {
492 err("%s: Out of memory for port structures\n", serial->type->description); 492 err("%s: Out of memory for port structures\n", serial->type->description);
493 goto no_command_private; 493 goto no_command_private;
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index fb8bacaae27c..e3528eca29a5 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -646,7 +646,7 @@ sddr09_read_sg_test_only(struct us_data *us) {
646 return result; 646 return result;
647 } 647 }
648 648
649 buf = (unsigned char *) kmalloc(bulklen, GFP_NOIO); 649 buf = kmalloc(bulklen, GFP_NOIO);
650 if (!buf) 650 if (!buf)
651 return -ENOMEM; 651 return -ENOMEM;
652 652
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index 6761b68c35e9..6c9dc2e69c82 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -447,7 +447,7 @@ static int clcdfb_probe(struct amba_device *dev, void *id)
447 goto out; 447 goto out;
448 } 448 }
449 449
450 fb = (struct clcd_fb *) kmalloc(sizeof(struct clcd_fb), GFP_KERNEL); 450 fb = kmalloc(sizeof(struct clcd_fb), GFP_KERNEL);
451 if (!fb) { 451 if (!fb) {
452 printk(KERN_INFO "CLCD: could not allocate new clcd_fb struct\n"); 452 printk(KERN_INFO "CLCD: could not allocate new clcd_fb struct\n");
453 ret = -ENOMEM; 453 ret = -ENOMEM;
diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index 88a47845c4f7..1a849b870bcc 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -2906,14 +2906,6 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
2906 par->crsr.spot_x = par->crsr.spot_y = 0; 2906 par->crsr.spot_x = par->crsr.spot_y = 0;
2907 par->crsr.height = par->crsr.width = 0; 2907 par->crsr.height = par->crsr.width = 0;
2908 2908
2909#if 0 /* fbmon not done. uncomment for 2.5.x -brad */
2910 if (!fbmon_valid_timings(pixclock[clk_shift], htotal, vtotal,
2911 &fb_info)) {
2912 DPRINTK("mode doesn't fit for monitor\n");
2913 return -EINVAL;
2914 }
2915#endif
2916
2917 return 0; 2909 return 0;
2918} 2910}
2919 2911
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 176f9b85cdbe..09684d7a7ce9 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -1488,10 +1488,6 @@ static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
1488 else 1488 else
1489 info->var.accel_flags = 0; 1489 info->var.accel_flags = 0;
1490 1490
1491#if 0 /* fbmon is not done. uncomment for 2.5.x -brad */
1492 if (!fbmon_valid_timings(pixclock, htotal, vtotal, info))
1493 return -EINVAL;
1494#endif
1495 aty_crtc_to_var(&crtc, var); 1491 aty_crtc_to_var(&crtc, var);
1496 var->pixclock = par->pll_ops->pll_to_var(info, &pll); 1492 var->pixclock = par->pll_ops->pll_to_var(info, &pll);
1497 return 0; 1493 return 0;
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c
index 797b42305b0f..fe28848e7b52 100644
--- a/drivers/video/matrox/i2c-matroxfb.c
+++ b/drivers/video/matrox/i2c-matroxfb.c
@@ -146,7 +146,7 @@ static void* i2c_matroxfb_probe(struct matrox_fb_info* minfo) {
146 unsigned long flags; 146 unsigned long flags;
147 struct matroxfb_dh_maven_info* m2info; 147 struct matroxfb_dh_maven_info* m2info;
148 148
149 m2info = (struct matroxfb_dh_maven_info*)kmalloc(sizeof(*m2info), GFP_KERNEL); 149 m2info = kmalloc(sizeof(*m2info), GFP_KERNEL);
150 if (!m2info) 150 if (!m2info)
151 return NULL; 151 return NULL;
152 152
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index e9b4115fcad0..cb2aa402ddfd 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -2028,7 +2028,7 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm
2028 } 2028 }
2029 2029
2030#ifdef CONFIG_FB_MATROX_MULTIHEAD 2030#ifdef CONFIG_FB_MATROX_MULTIHEAD
2031 minfo = (struct matrox_fb_info*)kmalloc(sizeof(*minfo), GFP_KERNEL); 2031 minfo = kmalloc(sizeof(*minfo), GFP_KERNEL);
2032 if (!minfo) 2032 if (!minfo)
2033 return -1; 2033 return -1;
2034#else 2034#else
diff --git a/drivers/video/matrox/matroxfb_crtc2.c b/drivers/video/matrox/matroxfb_crtc2.c
index 27eb4bb4f89f..2c9801090fae 100644
--- a/drivers/video/matrox/matroxfb_crtc2.c
+++ b/drivers/video/matrox/matroxfb_crtc2.c
@@ -694,7 +694,7 @@ static void* matroxfb_crtc2_probe(struct matrox_fb_info* minfo) {
694 /* hardware is CRTC2 incapable... */ 694 /* hardware is CRTC2 incapable... */
695 if (!ACCESS_FBINFO(devflags.crtc2)) 695 if (!ACCESS_FBINFO(devflags.crtc2))
696 return NULL; 696 return NULL;
697 m2info = (struct matroxfb_dh_fb_info*)kmalloc(sizeof(*m2info), GFP_KERNEL); 697 m2info = kmalloc(sizeof(*m2info), GFP_KERNEL);
698 if (!m2info) { 698 if (!m2info) {
699 printk(KERN_ERR "matroxfb_crtc2: Not enough memory for CRTC2 control structs\n"); 699 printk(KERN_ERR "matroxfb_crtc2: Not enough memory for CRTC2 control structs\n");
700 return NULL; 700 return NULL;
diff --git a/drivers/video/sstfb.c b/drivers/video/sstfb.c
index 711cb11d6eb3..59cd1e750f30 100644
--- a/drivers/video/sstfb.c
+++ b/drivers/video/sstfb.c
@@ -21,6 +21,11 @@
21 * Remove never finished and bogus 24/32bit support 21 * Remove never finished and bogus 24/32bit support
22 * Clean up macro abuse 22 * Clean up macro abuse
23 * Minor tidying for format. 23 * Minor tidying for format.
24 * 12/2006 Helge Deller <deller@gmx.de>
25 * add /sys/class/graphics/fbX/vgapass sysfs-interface
26 * add module option "mode_option" to set initial screen mode
27 * use fbdev default videomode database
28 * remove debug functions from ioctl
24 */ 29 */
25 30
26/* 31/*
@@ -65,19 +70,10 @@
65 * 70 *
66 * sstfb specific ioctls: 71 * sstfb specific ioctls:
67 * toggle vga (0x46db) : toggle vga_pass_through 72 * toggle vga (0x46db) : toggle vga_pass_through
68 * fill fb (0x46dc) : fills fb
69 * test disp (0x46de) : draws a test image
70 */ 73 */
71 74
72#undef SST_DEBUG 75#undef SST_DEBUG
73 76
74/*
75 Default video mode .
76 0 800x600@60 took from glide
77 1 640x480@75 took from glide
78 2 1024x768@76 std fb.mode
79 3 640x480@60 glide default */
80#define DEFAULT_MODE 3
81 77
82/* 78/*
83 * Includes 79 * Includes
@@ -92,20 +88,24 @@
92#include <linux/init.h> 88#include <linux/init.h>
93#include <linux/slab.h> 89#include <linux/slab.h>
94#include <asm/io.h> 90#include <asm/io.h>
95#include <asm/ioctl.h>
96#include <asm/uaccess.h> 91#include <asm/uaccess.h>
97#include <video/sstfb.h> 92#include <video/sstfb.h>
98 93
99 94
100/* initialized by setup */ 95/* initialized by setup */
101 96
102static int vgapass; /* enable Vga passthrough cable */ 97static int vgapass; /* enable VGA passthrough cable */
103static int mem; /* mem size in MB, 0 = autodetect */ 98static int mem; /* mem size in MB, 0 = autodetect */
104static int clipping = 1; /* use clipping (slower, safer) */ 99static int clipping = 1; /* use clipping (slower, safer) */
105static int gfxclk; /* force FBI freq in Mhz . Dangerous */ 100static int gfxclk; /* force FBI freq in Mhz . Dangerous */
106static int slowpci; /* slow PCI settings */ 101static int slowpci; /* slow PCI settings */
107 102
108static char *mode_option __devinitdata; 103/*
104 Possible default video modes: 800x600@60, 640x480@75, 1024x768@76, 640x480@60
105*/
106#define DEFAULT_VIDEO_MODE "640x480@60"
107
108static char *mode_option __devinitdata = DEFAULT_VIDEO_MODE;
109 109
110enum { 110enum {
111 ID_VOODOO1 = 0, 111 ID_VOODOO1 = 0,
@@ -119,48 +119,11 @@ static struct sst_spec voodoo_spec[] __devinitdata = {
119 { .name = "Voodoo2", .default_gfx_clock = 75000, .max_gfxclk = 85 }, 119 { .name = "Voodoo2", .default_gfx_clock = 75000, .max_gfxclk = 85 },
120}; 120};
121 121
122static struct fb_var_screeninfo sstfb_default =
123#if ( DEFAULT_MODE == 0 )
124 { /* 800x600@60, 16 bpp .borowed from glide/sst1/include/sst1init.h */
125 800, 600, 800, 600, 0, 0, 16, 0,
126 {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0},
127 0, 0, -1, -1, 0,
128 25000, 86, 41, 23, 1, 127, 4,
129 0, FB_VMODE_NONINTERLACED };
130#elif ( DEFAULT_MODE == 1 )
131 {/* 640x480@75, 16 bpp .borowed from glide/sst1/include/sst1init.h */
132 640, 480, 640, 480, 0, 0, 16, 0,
133 {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0},
134 0, 0, -1, -1, 0,
135 31746, 118, 17, 16, 1, 63, 3,
136 0, FB_VMODE_NONINTERLACED };
137#elif ( DEFAULT_MODE == 2 )
138 { /* 1024x768@76 took from my /etc/fb.modes */
139 1024, 768, 1024, 768,0, 0, 16,0,
140 {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0},
141 0, 0, -1, -1, 0,
142 11764, 208, 8, 36, 16, 120, 3 ,
143 0, FB_VMODE_NONINTERLACED };
144#elif ( DEFAULT_MODE == 3 )
145 { /* 640x480@60 , 16bpp glide default ?*/
146 640, 480, 640, 480, 0, 0, 16, 0,
147 {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0},
148 0, 0, -1, -1, 0,
149 39721 , 38, 26 , 25 ,18 , 96 ,2,
150 0, FB_VMODE_NONINTERLACED };
151#elif
152 #error "Invalid DEFAULT_MODE value !"
153#endif
154
155 122
156/* 123/*
157 * debug functions 124 * debug functions
158 */ 125 */
159 126
160static void sstfb_drawdebugimage(struct fb_info *info);
161static int sstfb_dump_regs(struct fb_info *info);
162
163
164#if (SST_DEBUG_REG > 0) 127#if (SST_DEBUG_REG > 0)
165static void sst_dbg_print_read_reg(u32 reg, u32 val) { 128static void sst_dbg_print_read_reg(u32 reg, u32 val) {
166 const char *regname; 129 const char *regname;
@@ -726,51 +689,77 @@ static int sstfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
726 return 0; 689 return 0;
727} 690}
728 691
729static int sstfb_ioctl(struct fb_info *info, u_int cmd, u_long arg) 692static void sstfb_setvgapass( struct fb_info *info, int enable )
730{ 693{
731 struct sstfb_par *par = info->par; 694 struct sstfb_par *par = info->par;
732 struct pci_dev *sst_dev = par->dev; 695 struct pci_dev *sst_dev = par->dev;
733 u32 fbiinit0, tmp, val; 696 u32 fbiinit0, tmp;
734 u_long p; 697
698 enable = enable ? 1:0;
699 if (par->vgapass == enable)
700 return;
701 par->vgapass = enable;
702
703 pci_read_config_dword(sst_dev, PCI_INIT_ENABLE, &tmp);
704 pci_write_config_dword(sst_dev, PCI_INIT_ENABLE,
705 tmp | PCI_EN_INIT_WR );
706 fbiinit0 = sst_read (FBIINIT0);
707 if (par->vgapass) {
708 sst_write(FBIINIT0, fbiinit0 & ~DIS_VGA_PASSTHROUGH);
709 printk(KERN_INFO "fb%d: Enabling VGA pass-through\n", info->node );
710 } else {
711 sst_write(FBIINIT0, fbiinit0 | DIS_VGA_PASSTHROUGH);
712 printk(KERN_INFO "fb%d: Disabling VGA pass-through\n", info->node );
713 }
714 pci_write_config_dword(sst_dev, PCI_INIT_ENABLE, tmp);
715}
716
717static ssize_t store_vgapass(struct device *device, struct device_attribute *attr,
718 const char *buf, size_t count)
719{
720 struct fb_info *info = dev_get_drvdata(device);
721 char ** last = NULL;
722 int val;
723
724 val = simple_strtoul(buf, last, 0);
725 sstfb_setvgapass(info, val);
726
727 return count;
728}
729
730static ssize_t show_vgapass(struct device *device, struct device_attribute *attr,
731 char *buf)
732{
733 struct fb_info *info = dev_get_drvdata(device);
734 struct sstfb_par *par = info->par;
735 return snprintf(buf, PAGE_SIZE, "%d\n", par->vgapass);
736}
737
738static struct device_attribute device_attrs[] = {
739 __ATTR(vgapass, S_IRUGO|S_IWUSR, show_vgapass, store_vgapass)
740 };
741
742static int sstfb_ioctl(struct fb_info *info, unsigned int cmd,
743 unsigned long arg)
744{
745 struct sstfb_par *par;
746 u32 val;
735 747
736 switch (cmd) { 748 switch (cmd) {
737 749 /* set/get VGA pass_through mode */
738 /* dump current FBIINIT values to system log */ 750 case SSTFB_SET_VGAPASS:
739 case _IO('F', 0xdb): /* 0x46db */
740 return sstfb_dump_regs(info);
741
742 /* fills lfb with #arg pixels */
743 case _IOW('F', 0xdc, u32): /* 0x46dc */
744 if (copy_from_user(&val, (void __user *)arg, sizeof(val))) 751 if (copy_from_user(&val, (void __user *)arg, sizeof(val)))
745 return -EFAULT; 752 return -EFAULT;
746 if (val > info->fix.smem_len) 753 sstfb_setvgapass(info, val);
747 val = info->fix.smem_len;
748 for (p = 0 ; p < val; p += 2)
749 writew(p >> 6, info->screen_base + p);
750 return 0; 754 return 0;
751 755 case SSTFB_GET_VGAPASS:
752 /* change VGA pass_through mode */ 756 par = info->par;
753 case _IOW('F', 0xdd, u32): /* 0x46dd */ 757 val = par->vgapass;
754 if (copy_from_user(&val, (void __user *)arg, sizeof(val))) 758 if (copy_to_user((void __user *)arg, &val, sizeof(val)))
755 return -EFAULT; 759 return -EFAULT;
756 pci_read_config_dword(sst_dev, PCI_INIT_ENABLE, &tmp);
757 pci_write_config_dword(sst_dev, PCI_INIT_ENABLE,
758 tmp | PCI_EN_INIT_WR );
759 fbiinit0 = sst_read (FBIINIT0);
760 if (val)
761 sst_write(FBIINIT0, fbiinit0 & ~EN_VGA_PASSTHROUGH);
762 else
763 sst_write(FBIINIT0, fbiinit0 | EN_VGA_PASSTHROUGH);
764 pci_write_config_dword(sst_dev, PCI_INIT_ENABLE, tmp);
765 return 0;
766
767 /* draw test image */
768 case _IO('F', 0xde): /* 0x46de */
769 f_dprintk("test color display at %d bpp\n",
770 info->var.bits_per_pixel);
771 sstfb_drawdebugimage(info);
772 return 0; 760 return 0;
773 } 761 }
762
774 return -EINVAL; 763 return -EINVAL;
775} 764}
776 765
@@ -804,6 +793,7 @@ static void sstfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
804/* 793/*
805 * FillRect 2D command (solidfill or invert (via ROP_XOR)) - Voodoo2 only 794 * FillRect 2D command (solidfill or invert (via ROP_XOR)) - Voodoo2 only
806 */ 795 */
796#if 0
807static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) 797static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
808{ 798{
809 struct sstfb_par *par = info->par; 799 struct sstfb_par *par = info->par;
@@ -825,6 +815,7 @@ static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
825 | (BLT_16BPP_FMT << 3) /* | BIT(14) */ | BIT(15) | BIT(16) ); 815 | (BLT_16BPP_FMT << 3) /* | BIT(14) */ | BIT(15) | BIT(16) );
826 sst_wait_idle(); 816 sst_wait_idle();
827} 817}
818#endif
828 819
829 820
830 821
@@ -1156,6 +1147,7 @@ static int __devinit sst_init(struct fb_info *info, struct sstfb_par *par)
1156 struct pll_timing gfx_timings; 1147 struct pll_timing gfx_timings;
1157 struct sst_spec *spec; 1148 struct sst_spec *spec;
1158 int Fout; 1149 int Fout;
1150 int gfx_clock;
1159 1151
1160 spec = &voodoo_spec[par->type]; 1152 spec = &voodoo_spec[par->type];
1161 f_ddprintk(" fbiinit0 fbiinit1 fbiinit2 fbiinit3 fbiinit4 " 1153 f_ddprintk(" fbiinit0 fbiinit1 fbiinit2 fbiinit3 fbiinit4 "
@@ -1196,15 +1188,15 @@ static int __devinit sst_init(struct fb_info *info, struct sstfb_par *par)
1196 } 1188 }
1197 1189
1198 /* set graphic clock */ 1190 /* set graphic clock */
1199 par->gfx_clock = spec->default_gfx_clock; 1191 gfx_clock = spec->default_gfx_clock;
1200 if ((gfxclk >10 ) && (gfxclk < spec->max_gfxclk)) { 1192 if ((gfxclk >10 ) && (gfxclk < spec->max_gfxclk)) {
1201 printk(KERN_INFO "sstfb: Using supplied graphic freq : %dMHz\n", gfxclk); 1193 printk(KERN_INFO "sstfb: Using supplied graphic freq : %dMHz\n", gfxclk);
1202 par->gfx_clock = gfxclk *1000; 1194 gfx_clock = gfxclk *1000;
1203 } else if (gfxclk) { 1195 } else if (gfxclk) {
1204 printk(KERN_WARNING "sstfb: %dMhz is way out of spec! Using default\n", gfxclk); 1196 printk(KERN_WARNING "sstfb: %dMhz is way out of spec! Using default\n", gfxclk);
1205 } 1197 }
1206 1198
1207 sst_calc_pll(par->gfx_clock, &Fout, &gfx_timings); 1199 sst_calc_pll(gfx_clock, &Fout, &gfx_timings);
1208 par->dac_sw.set_pll(info, &gfx_timings, GFX_CLOCK); 1200 par->dac_sw.set_pll(info, &gfx_timings, GFX_CLOCK);
1209 1201
1210 /* disable fbiinit remap */ 1202 /* disable fbiinit remap */
@@ -1215,10 +1207,11 @@ static int __devinit sst_init(struct fb_info *info, struct sstfb_par *par)
1215 fbiinit0 = FBIINIT0_DEFAULT; 1207 fbiinit0 = FBIINIT0_DEFAULT;
1216 fbiinit1 = FBIINIT1_DEFAULT; 1208 fbiinit1 = FBIINIT1_DEFAULT;
1217 fbiinit4 = FBIINIT4_DEFAULT; 1209 fbiinit4 = FBIINIT4_DEFAULT;
1218 if (vgapass) 1210 par->vgapass = vgapass;
1219 fbiinit0 &= ~EN_VGA_PASSTHROUGH; 1211 if (par->vgapass)
1212 fbiinit0 &= ~DIS_VGA_PASSTHROUGH;
1220 else 1213 else
1221 fbiinit0 |= EN_VGA_PASSTHROUGH; 1214 fbiinit0 |= DIS_VGA_PASSTHROUGH;
1222 if (slowpci) { 1215 if (slowpci) {
1223 fbiinit1 |= SLOW_PCI_WRITES; 1216 fbiinit1 |= SLOW_PCI_WRITES;
1224 fbiinit4 |= SLOW_PCI_READS; 1217 fbiinit4 |= SLOW_PCI_READS;
@@ -1267,7 +1260,7 @@ static void __devexit sst_shutdown(struct fb_info *info)
1267 /* TODO maybe shutdown the dac, vrefresh and so on... */ 1260 /* TODO maybe shutdown the dac, vrefresh and so on... */
1268 pci_write_config_dword(dev, PCI_INIT_ENABLE, 1261 pci_write_config_dword(dev, PCI_INIT_ENABLE,
1269 PCI_EN_INIT_WR); 1262 PCI_EN_INIT_WR);
1270 sst_unset_bits(FBIINIT0, FBI_RESET | FIFO_RESET | EN_VGA_PASSTHROUGH); 1263 sst_unset_bits(FBIINIT0, FBI_RESET | FIFO_RESET | DIS_VGA_PASSTHROUGH);
1271 pci_write_config_dword(dev, PCI_VCLK_DISABLE,0); 1264 pci_write_config_dword(dev, PCI_VCLK_DISABLE,0);
1272 /* maybe keep fbiinit* and PCI_INIT_enable in the fb_info struct 1265 /* maybe keep fbiinit* and PCI_INIT_enable in the fb_info struct
1273 * from start ? */ 1266 * from start ? */
@@ -1278,8 +1271,7 @@ static void __devexit sst_shutdown(struct fb_info *info)
1278/* 1271/*
1279 * Interface to the world 1272 * Interface to the world
1280 */ 1273 */
1281#ifndef MODULE 1274static int __devinit sstfb_setup(char *options)
1282static int __init sstfb_setup(char *options)
1283{ 1275{
1284 char *this_opt; 1276 char *this_opt;
1285 1277
@@ -1312,7 +1304,7 @@ static int __init sstfb_setup(char *options)
1312 } 1304 }
1313 return 0; 1305 return 0;
1314} 1306}
1315#endif 1307
1316 1308
1317static struct fb_ops sstfb_ops = { 1309static struct fb_ops sstfb_ops = {
1318 .owner = THIS_MODULE, 1310 .owner = THIS_MODULE,
@@ -1416,15 +1408,10 @@ static int __devinit sstfb_probe(struct pci_dev *pdev,
1416 */ 1408 */
1417 fix->line_length = 2048; /* default value, for 24 or 32bit: 4096 */ 1409 fix->line_length = 2048; /* default value, for 24 or 32bit: 4096 */
1418 1410
1419 if ( mode_option && 1411 fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 16);
1420 fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 16)) {
1421 printk(KERN_ERR "sstfb: can't set supplied video mode. Using default\n");
1422 info->var = sstfb_default;
1423 } else
1424 info->var = sstfb_default;
1425 1412
1426 if (sstfb_check_var(&info->var, info)) { 1413 if (sstfb_check_var(&info->var, info)) {
1427 printk(KERN_ERR "sstfb: invalid default video mode.\n"); 1414 printk(KERN_ERR "sstfb: invalid video mode.\n");
1428 goto fail; 1415 goto fail;
1429 } 1416 }
1430 1417
@@ -1442,10 +1429,11 @@ static int __devinit sstfb_probe(struct pci_dev *pdev,
1442 goto fail; 1429 goto fail;
1443 } 1430 }
1444 1431
1445 if (1) /* set to 0 to see an initial bitmap instead */ 1432 sstfb_clear_screen(info);
1446 sstfb_clear_screen(info); 1433
1447 else 1434 if (device_create_file(info->dev, &device_attrs[0]))
1448 sstfb_drawdebugimage(info); 1435 printk(KERN_WARNING "sstfb: can't create sysfs entry.\n");
1436
1449 1437
1450 printk(KERN_INFO "fb%d: %s frame buffer device at 0x%p\n", 1438 printk(KERN_INFO "fb%d: %s frame buffer device at 0x%p\n",
1451 info->node, fix->id, info->screen_base); 1439 info->node, fix->id, info->screen_base);
@@ -1453,6 +1441,7 @@ static int __devinit sstfb_probe(struct pci_dev *pdev,
1453 return 0; 1441 return 0;
1454 1442
1455fail: 1443fail:
1444 fb_dealloc_cmap(&info->cmap);
1456 iounmap(info->screen_base); 1445 iounmap(info->screen_base);
1457fail_fb_remap: 1446fail_fb_remap:
1458 iounmap(par->mmio_vbase); 1447 iounmap(par->mmio_vbase);
@@ -1473,21 +1462,23 @@ static void __devexit sstfb_remove(struct pci_dev *pdev)
1473 info = pci_get_drvdata(pdev); 1462 info = pci_get_drvdata(pdev);
1474 par = info->par; 1463 par = info->par;
1475 1464
1465 device_remove_file(info->dev, &device_attrs[0]);
1476 sst_shutdown(info); 1466 sst_shutdown(info);
1477 unregister_framebuffer(info);
1478 iounmap(info->screen_base); 1467 iounmap(info->screen_base);
1479 iounmap(par->mmio_vbase); 1468 iounmap(par->mmio_vbase);
1480 release_mem_region(info->fix.smem_start, 0x400000); 1469 release_mem_region(info->fix.smem_start, 0x400000);
1481 release_mem_region(info->fix.mmio_start, info->fix.mmio_len); 1470 release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
1471 fb_dealloc_cmap(&info->cmap);
1472 unregister_framebuffer(info);
1482 framebuffer_release(info); 1473 framebuffer_release(info);
1483} 1474}
1484 1475
1485 1476
1486static struct pci_device_id sstfb_id_tbl[] = { 1477static const struct pci_device_id sstfb_id_tbl[] = {
1487 { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO, 1478 { PCI_DEVICE(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO ),
1488 PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_VOODOO1 }, 1479 .driver_data = ID_VOODOO1, },
1489 { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO2, 1480 { PCI_DEVICE(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO2),
1490 PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_VOODOO2 }, 1481 .driver_data = ID_VOODOO2, },
1491 { 0 }, 1482 { 0 },
1492}; 1483};
1493 1484
@@ -1501,142 +1492,23 @@ static struct pci_driver sstfb_driver = {
1501 1492
1502static int __devinit sstfb_init(void) 1493static int __devinit sstfb_init(void)
1503{ 1494{
1504#ifndef MODULE
1505 char *option = NULL; 1495 char *option = NULL;
1506 1496
1507 if (fb_get_options("sstfb", &option)) 1497 if (fb_get_options("sstfb", &option))
1508 return -ENODEV; 1498 return -ENODEV;
1509 sstfb_setup(option); 1499 sstfb_setup(option);
1510#endif 1500
1511 return pci_register_driver(&sstfb_driver); 1501 return pci_register_driver(&sstfb_driver);
1512} 1502}
1513 1503
1514#ifdef MODULE
1515static void __devexit sstfb_exit(void) 1504static void __devexit sstfb_exit(void)
1516{ 1505{
1517 pci_unregister_driver(&sstfb_driver); 1506 pci_unregister_driver(&sstfb_driver);
1518} 1507}
1519#endif
1520 1508
1521 1509
1522/*
1523 * testing and debugging functions
1524 */
1525
1526static int sstfb_dump_regs(struct fb_info *info)
1527{
1528#ifdef SST_DEBUG
1529 static struct { u32 reg ; const char *reg_name;} pci_regs[] = {
1530 { PCI_INIT_ENABLE, "initenable"},
1531 { PCI_VCLK_ENABLE, "enable vclk"},
1532 { PCI_VCLK_DISABLE, "disable vclk"},
1533 };
1534
1535 static struct { u32 reg ; const char *reg_name;} sst_regs[] = {
1536 {FBIINIT0,"fbiinit0"},
1537 {FBIINIT1,"fbiinit1"},
1538 {FBIINIT2,"fbiinit2"},
1539 {FBIINIT3,"fbiinit3"},
1540 {FBIINIT4,"fbiinit4"},
1541 {FBIINIT5,"fbiinit5"},
1542 {FBIINIT6,"fbiinit6"},
1543 {FBIINIT7,"fbiinit7"},
1544 {LFBMODE,"lfbmode"},
1545 {FBZMODE,"fbzmode"},
1546 };
1547
1548 const int pci_s = ARRAY_SIZE(pci_regs);
1549 const int sst_s = ARRAY_SIZE(sst_regs);
1550 struct sstfb_par *par = info->par;
1551 struct pci_dev *dev = par->dev;
1552 u32 pci_res[pci_s];
1553 u32 sst_res[sst_s];
1554 int i;
1555
1556 for (i=0; i<pci_s; i++) {
1557 pci_read_config_dword(dev, pci_regs[i].reg, &pci_res[i]);
1558 }
1559 for (i=0; i<sst_s; i++) {
1560 sst_res[i] = sst_read(sst_regs[i].reg);
1561 }
1562
1563 dprintk("hardware register dump:\n");
1564 for (i=0; i<pci_s; i++) {
1565 dprintk("%s %0#10x\n", pci_regs[i].reg_name, pci_res[i]);
1566 }
1567 for (i=0; i<sst_s; i++) {
1568 dprintk("%s %0#10x\n", sst_regs[i].reg_name, sst_res[i]);
1569 }
1570 return 0;
1571#else
1572 return -EINVAL;
1573#endif
1574}
1575
1576static void sstfb_fillrect_softw( struct fb_info *info, const struct fb_fillrect *rect)
1577{
1578 u8 __iomem *fbbase_virt = info->screen_base;
1579 int x, y, w = info->var.bits_per_pixel == 16 ? 2 : 4;
1580 u32 color = rect->color, height = rect->height;
1581 u8 __iomem *p;
1582
1583 if (w==2) color |= color<<16;
1584 for (y=rect->dy; height; y++, height--) {
1585 p = fbbase_virt + y*info->fix.line_length + rect->dx*w;
1586 x = rect->width;
1587 if (w==2) x>>=1;
1588 while (x) {
1589 writel(color, p);
1590 p += 4;
1591 x--;
1592 }
1593 }
1594}
1595
1596static void sstfb_drawrect_XY( struct fb_info *info, int x, int y,
1597 int w, int h, int color, int hwfunc)
1598{
1599 struct fb_fillrect rect;
1600 rect.dx = x;
1601 rect.dy = y;
1602 rect.height = h;
1603 rect.width = w;
1604 rect.color = color;
1605 rect.rop = ROP_COPY;
1606 if (hwfunc)
1607 sstfb_fillrect(info, &rect);
1608 else
1609 sstfb_fillrect_softw(info, &rect);
1610}
1611
1612/* print some squares on the fb */
1613static void sstfb_drawdebugimage(struct fb_info *info)
1614{
1615 static int idx;
1616
1617 /* clear screen */
1618 sstfb_clear_screen(info);
1619
1620 idx = (idx+1) & 1;
1621
1622 /* white rect */
1623 sstfb_drawrect_XY(info, 0, 0, 50, 50, 0xffff, idx);
1624
1625 /* blue rect */
1626 sstfb_drawrect_XY(info, 50, 50, 50, 50, 0x001f, idx);
1627
1628 /* green rect */
1629 sstfb_drawrect_XY(info, 100, 100, 80, 80, 0x07e0, idx);
1630
1631 /* red rect */
1632 sstfb_drawrect_XY(info, 250, 250, 120, 100, 0xf800, idx);
1633}
1634
1635module_init(sstfb_init); 1510module_init(sstfb_init);
1636
1637#ifdef MODULE
1638module_exit(sstfb_exit); 1511module_exit(sstfb_exit);
1639#endif
1640 1512
1641MODULE_AUTHOR("(c) 2000,2002 Ghozlane Toumi <gtoumi@laposte.net>"); 1513MODULE_AUTHOR("(c) 2000,2002 Ghozlane Toumi <gtoumi@laposte.net>");
1642MODULE_DESCRIPTION("FBDev driver for 3dfx Voodoo Graphics and Voodoo2 based video boards"); 1514MODULE_DESCRIPTION("FBDev driver for 3dfx Voodoo Graphics and Voodoo2 based video boards");
@@ -1652,3 +1524,6 @@ module_param(gfxclk, int, 0);
1652MODULE_PARM_DESC(gfxclk, "Force graphic chip frequency in MHz. DANGEROUS. (default=auto)"); 1524MODULE_PARM_DESC(gfxclk, "Force graphic chip frequency in MHz. DANGEROUS. (default=auto)");
1653module_param(slowpci, bool, 0); 1525module_param(slowpci, bool, 0);
1654MODULE_PARM_DESC(slowpci, "Uses slow PCI settings (0 or 1) (default=0)"); 1526MODULE_PARM_DESC(slowpci, "Uses slow PCI settings (0 or 1) (default=0)");
1527module_param(mode_option, charp, 0);
1528MODULE_PARM_DESC(mode_option, "Initial video mode (default=" DEFAULT_VIDEO_MODE ")");
1529
diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig
index d18d6424cd21..904e5aeb696c 100644
--- a/drivers/w1/slaves/Kconfig
+++ b/drivers/w1/slaves/Kconfig
@@ -9,7 +9,7 @@ config W1_SLAVE_THERM
9 tristate "Thermal family implementation" 9 tristate "Thermal family implementation"
10 depends on W1 10 depends on W1
11 help 11 help
12 Say Y here if you want to connect 1-wire thermal sensors to you 12 Say Y here if you want to connect 1-wire thermal sensors to your
13 wire. 13 wire.
14 14
15config W1_SLAVE_SMEM 15config W1_SLAVE_SMEM
@@ -17,7 +17,7 @@ config W1_SLAVE_SMEM
17 depends on W1 17 depends on W1
18 help 18 help
19 Say Y here if you want to connect 1-wire 19 Say Y here if you want to connect 1-wire
20 simple 64bit memory rom(ds2401/ds2411/ds1990*) to you wire. 20 simple 64bit memory rom(ds2401/ds2411/ds1990*) to your wire.
21 21
22config W1_SLAVE_DS2433 22config W1_SLAVE_DS2433
23 tristate "4kb EEPROM family support (DS2433)" 23 tristate "4kb EEPROM family support (DS2433)"
diff --git a/fs/aio.c b/fs/aio.c
index d3a6ec2c9627..5f577a63bdf0 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -586,7 +586,7 @@ static void use_mm(struct mm_struct *mm)
586 * Note that on UML this *requires* PF_BORROWED_MM to be set, otherwise 586 * Note that on UML this *requires* PF_BORROWED_MM to be set, otherwise
587 * it won't work. Update it accordingly if you change it here 587 * it won't work. Update it accordingly if you change it here
588 */ 588 */
589 activate_mm(active_mm, mm); 589 switch_mm(active_mm, mm, tsk);
590 task_unlock(tsk); 590 task_unlock(tsk);
591 591
592 mmdrop(active_mm); 592 mmdrop(active_mm);
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 9c48250fd726..e8f6c5ad3e90 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -313,7 +313,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
313 struct autofs_sb_info *sbi; 313 struct autofs_sb_info *sbi;
314 struct autofs_info *ino; 314 struct autofs_info *ino;
315 315
316 sbi = (struct autofs_sb_info *) kmalloc(sizeof(*sbi), GFP_KERNEL); 316 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
317 if ( !sbi ) 317 if ( !sbi )
318 goto fail_unlock; 318 goto fail_unlock;
319 DPRINTK("starting up, sbi = %p",sbi); 319 DPRINTK("starting up, sbi = %p",sbi);
diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 81b042ee24e6..af5bb93276f8 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -260,7 +260,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
260 goto error; 260 goto error;
261 } 261 }
262 262
263 this_node = (befs_btree_node *) kmalloc(sizeof (befs_btree_node), 263 this_node = kmalloc(sizeof (befs_btree_node),
264 GFP_NOFS); 264 GFP_NOFS);
265 if (!this_node) { 265 if (!this_node) {
266 befs_error(sb, "befs_btree_find() failed to allocate %u " 266 befs_error(sb, "befs_btree_find() failed to allocate %u "
diff --git a/fs/befs/debug.c b/fs/befs/debug.c
index e831a8f30849..b8e304a0661e 100644
--- a/fs/befs/debug.c
+++ b/fs/befs/debug.c
@@ -28,7 +28,7 @@ void
28befs_error(const struct super_block *sb, const char *fmt, ...) 28befs_error(const struct super_block *sb, const char *fmt, ...)
29{ 29{
30 va_list args; 30 va_list args;
31 char *err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL); 31 char *err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
32 if (err_buf == NULL) { 32 if (err_buf == NULL) {
33 printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE); 33 printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
34 return; 34 return;
@@ -46,7 +46,7 @@ void
46befs_warning(const struct super_block *sb, const char *fmt, ...) 46befs_warning(const struct super_block *sb, const char *fmt, ...)
47{ 47{
48 va_list args; 48 va_list args;
49 char *err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL); 49 char *err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
50 if (err_buf == NULL) { 50 if (err_buf == NULL) {
51 printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE); 51 printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
52 return; 52 return;
@@ -70,7 +70,7 @@ befs_debug(const struct super_block *sb, const char *fmt, ...)
70 char *err_buf = NULL; 70 char *err_buf = NULL;
71 71
72 if (BEFS_SB(sb)->mount_opts.debug) { 72 if (BEFS_SB(sb)->mount_opts.debug) {
73 err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL); 73 err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
74 if (err_buf == NULL) { 74 if (err_buf == NULL) {
75 printk(KERN_ERR "could not allocate %d bytes\n", 75 printk(KERN_ERR "could not allocate %d bytes\n",
76 ERRBUFSIZE); 76 ERRBUFSIZE);
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index eac175ed9f44..134c99941a63 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/bfs/inode.c 2 * fs/bfs/inode.c
3 * BFS superblock and inode operations. 3 * BFS superblock and inode operations.
4 * Copyright (C) 1999,2000 Tigran Aivazian <tigran@veritas.com> 4 * Copyright (C) 1999-2006 Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
5 * From fs/minix, Copyright (C) 1991, 1992 Linus Torvalds. 5 * From fs/minix, Copyright (C) 1991, 1992 Linus Torvalds.
6 * 6 *
7 * Made endianness-clean by Andrew Stribblehill <ads@wompom.org>, 2005. 7 * Made endianness-clean by Andrew Stribblehill <ads@wompom.org>, 2005.
@@ -18,7 +18,7 @@
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include "bfs.h" 19#include "bfs.h"
20 20
21MODULE_AUTHOR("Tigran A. Aivazian <tigran@veritas.com>"); 21MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>");
22MODULE_DESCRIPTION("SCO UnixWare BFS filesystem for Linux"); 22MODULE_DESCRIPTION("SCO UnixWare BFS filesystem for Linux");
23MODULE_LICENSE("GPL"); 23MODULE_LICENSE("GPL");
24 24
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 00687ea62738..c2e08252af35 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -311,7 +311,7 @@ static Node *create_entry(const char __user *buffer, size_t count)
311 311
312 err = -ENOMEM; 312 err = -ENOMEM;
313 memsize = sizeof(Node) + count + 8; 313 memsize = sizeof(Node) + count + 8;
314 e = (Node *) kmalloc(memsize, GFP_USER); 314 e = kmalloc(memsize, GFP_USER);
315 if (!e) 315 if (!e)
316 goto out; 316 goto out;
317 317
diff --git a/fs/bio.c b/fs/bio.c
index 7ec737eda72b..7618bcb18368 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -916,7 +916,7 @@ void bio_set_pages_dirty(struct bio *bio)
916 } 916 }
917} 917}
918 918
919static void bio_release_pages(struct bio *bio) 919void bio_release_pages(struct bio *bio)
920{ 920{
921 struct bio_vec *bvec = bio->bi_io_vec; 921 struct bio_vec *bvec = bio->bi_io_vec;
922 int i; 922 int i;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 197f93921847..1715d6b5f411 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -129,43 +129,191 @@ blkdev_get_block(struct inode *inode, sector_t iblock,
129 return 0; 129 return 0;
130} 130}
131 131
132static int 132static int blk_end_aio(struct bio *bio, unsigned int bytes_done, int error)
133blkdev_get_blocks(struct inode *inode, sector_t iblock,
134 struct buffer_head *bh, int create)
135{ 133{
136 sector_t end_block = max_block(I_BDEV(inode)); 134 struct kiocb *iocb = bio->bi_private;
137 unsigned long max_blocks = bh->b_size >> inode->i_blkbits; 135 atomic_t *bio_count = &iocb->ki_bio_count;
138 136
139 if ((iblock + max_blocks) > end_block) { 137 if (bio_data_dir(bio) == READ)
140 max_blocks = end_block - iblock; 138 bio_check_pages_dirty(bio);
141 if ((long)max_blocks <= 0) { 139 else {
142 if (create) 140 bio_release_pages(bio);
143 return -EIO; /* write fully beyond EOF */ 141 bio_put(bio);
144 /* 142 }
145 * It is a read which is fully beyond EOF. We return 143
146 * a !buffer_mapped buffer 144 /* iocb->ki_nbytes stores error code from LLDD */
147 */ 145 if (error)
148 max_blocks = 0; 146 iocb->ki_nbytes = -EIO;
149 } 147
148 if (atomic_dec_and_test(bio_count)) {
149 if (iocb->ki_nbytes < 0)
150 aio_complete(iocb, iocb->ki_nbytes, 0);
151 else
152 aio_complete(iocb, iocb->ki_left, 0);
150 } 153 }
151 154
152 bh->b_bdev = I_BDEV(inode);
153 bh->b_blocknr = iblock;
154 bh->b_size = max_blocks << inode->i_blkbits;
155 if (max_blocks)
156 set_buffer_mapped(bh);
157 return 0; 155 return 0;
158} 156}
159 157
158#define VEC_SIZE 16
159struct pvec {
160 unsigned short nr;
161 unsigned short idx;
162 struct page *page[VEC_SIZE];
163};
164
165#define PAGES_SPANNED(addr, len) \
166 (DIV_ROUND_UP((addr) + (len), PAGE_SIZE) - (addr) / PAGE_SIZE);
167
168/*
169 * get page pointer for user addr, we internally cache struct page array for
170 * (addr, count) range in pvec to avoid frequent call to get_user_pages. If
171 * internal page list is exhausted, a batch count of up to VEC_SIZE is used
172 * to get next set of page struct.
173 */
174static struct page *blk_get_page(unsigned long addr, size_t count, int rw,
175 struct pvec *pvec)
176{
177 int ret, nr_pages;
178 if (pvec->idx == pvec->nr) {
179 nr_pages = PAGES_SPANNED(addr, count);
180 nr_pages = min(nr_pages, VEC_SIZE);
181 down_read(&current->mm->mmap_sem);
182 ret = get_user_pages(current, current->mm, addr, nr_pages,
183 rw == READ, 0, pvec->page, NULL);
184 up_read(&current->mm->mmap_sem);
185 if (ret < 0)
186 return ERR_PTR(ret);
187 pvec->nr = ret;
188 pvec->idx = 0;
189 }
190 return pvec->page[pvec->idx++];
191}
192
160static ssize_t 193static ssize_t
161blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, 194blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
162 loff_t offset, unsigned long nr_segs) 195 loff_t pos, unsigned long nr_segs)
163{ 196{
164 struct file *file = iocb->ki_filp; 197 struct inode *inode = iocb->ki_filp->f_mapping->host;
165 struct inode *inode = file->f_mapping->host; 198 unsigned blkbits = blksize_bits(bdev_hardsect_size(I_BDEV(inode)));
199 unsigned blocksize_mask = (1 << blkbits) - 1;
200 unsigned long seg = 0; /* iov segment iterator */
201 unsigned long nvec; /* number of bio vec needed */
202 unsigned long cur_off; /* offset into current page */
203 unsigned long cur_len; /* I/O len of current page, up to PAGE_SIZE */
204
205 unsigned long addr; /* user iovec address */
206 size_t count; /* user iovec len */
207 size_t nbytes = iocb->ki_nbytes = iocb->ki_left; /* total xfer size */
208 loff_t size; /* size of block device */
209 struct bio *bio;
210 atomic_t *bio_count = &iocb->ki_bio_count;
211 struct page *page;
212 struct pvec pvec;
213
214 pvec.nr = 0;
215 pvec.idx = 0;
216
217 if (pos & blocksize_mask)
218 return -EINVAL;
219
220 size = i_size_read(inode);
221 if (pos + nbytes > size) {
222 nbytes = size - pos;
223 iocb->ki_left = nbytes;
224 }
225
226 /*
227 * check first non-zero iov alignment, the remaining
228 * iov alignment is checked inside bio loop below.
229 */
230 do {
231 addr = (unsigned long) iov[seg].iov_base;
232 count = min(iov[seg].iov_len, nbytes);
233 if (addr & blocksize_mask || count & blocksize_mask)
234 return -EINVAL;
235 } while (!count && ++seg < nr_segs);
236 atomic_set(bio_count, 1);
237
238 while (nbytes) {
239 /* roughly estimate number of bio vec needed */
240 nvec = (nbytes + PAGE_SIZE - 1) / PAGE_SIZE;
241 nvec = max(nvec, nr_segs - seg);
242 nvec = min(nvec, (unsigned long) BIO_MAX_PAGES);
243
244 /* bio_alloc should not fail with GFP_KERNEL flag */
245 bio = bio_alloc(GFP_KERNEL, nvec);
246 bio->bi_bdev = I_BDEV(inode);
247 bio->bi_end_io = blk_end_aio;
248 bio->bi_private = iocb;
249 bio->bi_sector = pos >> blkbits;
250same_bio:
251 cur_off = addr & ~PAGE_MASK;
252 cur_len = PAGE_SIZE - cur_off;
253 if (count < cur_len)
254 cur_len = count;
255
256 page = blk_get_page(addr, count, rw, &pvec);
257 if (unlikely(IS_ERR(page)))
258 goto backout;
259
260 if (bio_add_page(bio, page, cur_len, cur_off)) {
261 pos += cur_len;
262 addr += cur_len;
263 count -= cur_len;
264 nbytes -= cur_len;
265
266 if (count)
267 goto same_bio;
268 while (++seg < nr_segs) {
269 addr = (unsigned long) iov[seg].iov_base;
270 count = iov[seg].iov_len;
271 if (!count)
272 continue;
273 if (unlikely(addr & blocksize_mask ||
274 count & blocksize_mask)) {
275 page = ERR_PTR(-EINVAL);
276 goto backout;
277 }
278 count = min(count, nbytes);
279 goto same_bio;
280 }
281 }
166 282
167 return blockdev_direct_IO_no_locking(rw, iocb, inode, I_BDEV(inode), 283 /* bio is ready, submit it */
168 iov, offset, nr_segs, blkdev_get_blocks, NULL); 284 if (rw == READ)
285 bio_set_pages_dirty(bio);
286 atomic_inc(bio_count);
287 submit_bio(rw, bio);
288 }
289
290completion:
291 iocb->ki_left -= nbytes;
292 nbytes = iocb->ki_left;
293 iocb->ki_pos += nbytes;
294
295 blk_run_address_space(inode->i_mapping);
296 if (atomic_dec_and_test(bio_count))
297 aio_complete(iocb, nbytes, 0);
298
299 return -EIOCBQUEUED;
300
301backout:
302 /*
303 * back out nbytes count constructed so far for this bio,
304 * we will throw away current bio.
305 */
306 nbytes += bio->bi_size;
307 bio_release_pages(bio);
308 bio_put(bio);
309
310 /*
311 * if no bio was submmitted, return the error code.
312 * otherwise, proceed with pending I/O completion.
313 */
314 if (atomic_read(bio_count) == 1)
315 return PTR_ERR(page);
316 goto completion;
169} 317}
170 318
171static int blkdev_writepage(struct page *page, struct writeback_control *wbc) 319static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 098790eb2aa1..472e33e0f3cf 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -4876,7 +4876,7 @@ int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
4876 } else { 4876 } else {
4877 /* Add file to outstanding requests */ 4877 /* Add file to outstanding requests */
4878 /* BB change to kmem cache alloc */ 4878 /* BB change to kmem cache alloc */
4879 dnotify_req = (struct dir_notify_req *) kmalloc( 4879 dnotify_req = kmalloc(
4880 sizeof(struct dir_notify_req), 4880 sizeof(struct dir_notify_req),
4881 GFP_KERNEL); 4881 GFP_KERNEL);
4882 if(dnotify_req) { 4882 if(dnotify_req) {
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 137d76c3f90a..c692487346ea 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -24,6 +24,7 @@
24#include <linux/kobject.h> 24#include <linux/kobject.h>
25#include <linux/namei.h> 25#include <linux/namei.h>
26#include <linux/debugfs.h> 26#include <linux/debugfs.h>
27#include <linux/fsnotify.h>
27 28
28#define DEBUGFS_MAGIC 0x64626720 29#define DEBUGFS_MAGIC 0x64626720
29 30
@@ -54,7 +55,8 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d
54 inode->i_op = &simple_dir_inode_operations; 55 inode->i_op = &simple_dir_inode_operations;
55 inode->i_fop = &simple_dir_operations; 56 inode->i_fop = &simple_dir_operations;
56 57
57 /* directory inodes start off with i_nlink == 2 (for "." entry) */ 58 /* directory inodes start off with i_nlink == 2
59 * (for "." entry) */
58 inc_nlink(inode); 60 inc_nlink(inode);
59 break; 61 break;
60 } 62 }
@@ -87,15 +89,22 @@ static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
87 89
88 mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; 90 mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
89 res = debugfs_mknod(dir, dentry, mode, 0); 91 res = debugfs_mknod(dir, dentry, mode, 0);
90 if (!res) 92 if (!res) {
91 inc_nlink(dir); 93 inc_nlink(dir);
94 fsnotify_mkdir(dir, dentry);
95 }
92 return res; 96 return res;
93} 97}
94 98
95static int debugfs_create(struct inode *dir, struct dentry *dentry, int mode) 99static int debugfs_create(struct inode *dir, struct dentry *dentry, int mode)
96{ 100{
101 int res;
102
97 mode = (mode & S_IALLUGO) | S_IFREG; 103 mode = (mode & S_IALLUGO) | S_IFREG;
98 return debugfs_mknod(dir, dentry, mode, 0); 104 res = debugfs_mknod(dir, dentry, mode, 0);
105 if (!res)
106 fsnotify_create(dir, dentry);
107 return res;
99} 108}
100 109
101static inline int debugfs_positive(struct dentry *dentry) 110static inline int debugfs_positive(struct dentry *dentry)
@@ -135,7 +144,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
135 * block. A pointer to that is in the struct vfsmount that we 144 * block. A pointer to that is in the struct vfsmount that we
136 * have around. 145 * have around.
137 */ 146 */
138 if (!parent ) { 147 if (!parent) {
139 if (debugfs_mount && debugfs_mount->mnt_sb) { 148 if (debugfs_mount && debugfs_mount->mnt_sb) {
140 parent = debugfs_mount->mnt_sb->s_root; 149 parent = debugfs_mount->mnt_sb->s_root;
141 } 150 }
@@ -153,6 +162,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
153 error = debugfs_mkdir(parent->d_inode, *dentry, mode); 162 error = debugfs_mkdir(parent->d_inode, *dentry, mode);
154 else 163 else
155 error = debugfs_create(parent->d_inode, *dentry, mode); 164 error = debugfs_create(parent->d_inode, *dentry, mode);
165 dput(*dentry);
156 } else 166 } else
157 error = PTR_ERR(*dentry); 167 error = PTR_ERR(*dentry);
158 mutex_unlock(&parent->d_inode->i_mutex); 168 mutex_unlock(&parent->d_inode->i_mutex);
@@ -197,13 +207,15 @@ struct dentry *debugfs_create_file(const char *name, mode_t mode,
197 207
198 pr_debug("debugfs: creating file '%s'\n",name); 208 pr_debug("debugfs: creating file '%s'\n",name);
199 209
200 error = simple_pin_fs(&debug_fs_type, &debugfs_mount, &debugfs_mount_count); 210 error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
211 &debugfs_mount_count);
201 if (error) 212 if (error)
202 goto exit; 213 goto exit;
203 214
204 error = debugfs_create_by_name(name, mode, parent, &dentry); 215 error = debugfs_create_by_name(name, mode, parent, &dentry);
205 if (error) { 216 if (error) {
206 dentry = NULL; 217 dentry = NULL;
218 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
207 goto exit; 219 goto exit;
208 } 220 }
209 221
@@ -262,6 +274,7 @@ EXPORT_SYMBOL_GPL(debugfs_create_dir);
262void debugfs_remove(struct dentry *dentry) 274void debugfs_remove(struct dentry *dentry)
263{ 275{
264 struct dentry *parent; 276 struct dentry *parent;
277 int ret = 0;
265 278
266 if (!dentry) 279 if (!dentry)
267 return; 280 return;
@@ -273,11 +286,19 @@ void debugfs_remove(struct dentry *dentry)
273 mutex_lock(&parent->d_inode->i_mutex); 286 mutex_lock(&parent->d_inode->i_mutex);
274 if (debugfs_positive(dentry)) { 287 if (debugfs_positive(dentry)) {
275 if (dentry->d_inode) { 288 if (dentry->d_inode) {
276 if (S_ISDIR(dentry->d_inode->i_mode)) 289 dget(dentry);
277 simple_rmdir(parent->d_inode, dentry); 290 if (S_ISDIR(dentry->d_inode->i_mode)) {
278 else 291 ret = simple_rmdir(parent->d_inode, dentry);
292 if (ret)
293 printk(KERN_ERR
294 "DebugFS rmdir on %s failed : "
295 "directory not empty.\n",
296 dentry->d_name.name);
297 } else
279 simple_unlink(parent->d_inode, dentry); 298 simple_unlink(parent->d_inode, dentry);
280 dput(dentry); 299 if (!ret)
300 d_delete(dentry);
301 dput(dentry);
281 } 302 }
282 } 303 }
283 mutex_unlock(&parent->d_inode->i_mutex); 304 mutex_unlock(&parent->d_inode->i_mutex);
diff --git a/fs/inode.c b/fs/inode.c
index d00de182ecb9..bf21dc6d0dbd 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1144,7 +1144,6 @@ sector_t bmap(struct inode * inode, sector_t block)
1144 res = inode->i_mapping->a_ops->bmap(inode->i_mapping, block); 1144 res = inode->i_mapping->a_ops->bmap(inode->i_mapping, block);
1145 return res; 1145 return res;
1146} 1146}
1147
1148EXPORT_SYMBOL(bmap); 1147EXPORT_SYMBOL(bmap);
1149 1148
1150/** 1149/**
@@ -1163,27 +1162,43 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
1163 1162
1164 if (IS_RDONLY(inode)) 1163 if (IS_RDONLY(inode))
1165 return; 1164 return;
1166 1165 if (inode->i_flags & S_NOATIME)
1167 if ((inode->i_flags & S_NOATIME) || 1166 return;
1168 (inode->i_sb->s_flags & MS_NOATIME) || 1167 if (inode->i_sb->s_flags & MS_NOATIME)
1169 ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))) 1168 return;
1169 if ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))
1170 return; 1170 return;
1171 1171
1172 /* 1172 /*
1173 * We may have a NULL vfsmount when coming from NFSD 1173 * We may have a NULL vfsmount when coming from NFSD
1174 */ 1174 */
1175 if (mnt && 1175 if (mnt) {
1176 ((mnt->mnt_flags & MNT_NOATIME) || 1176 if (mnt->mnt_flags & MNT_NOATIME)
1177 ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)))) 1177 return;
1178 return; 1178 if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))
1179 return;
1179 1180
1180 now = current_fs_time(inode->i_sb); 1181 if (mnt->mnt_flags & MNT_RELATIME) {
1181 if (!timespec_equal(&inode->i_atime, &now)) { 1182 /*
1182 inode->i_atime = now; 1183 * With relative atime, only update atime if the
1183 mark_inode_dirty_sync(inode); 1184 * previous atime is earlier than either the ctime or
1185 * mtime.
1186 */
1187 if (timespec_compare(&inode->i_mtime,
1188 &inode->i_atime) < 0 &&
1189 timespec_compare(&inode->i_ctime,
1190 &inode->i_atime) < 0)
1191 return;
1192 }
1184 } 1193 }
1185}
1186 1194
1195 now = current_fs_time(inode->i_sb);
1196 if (timespec_equal(&inode->i_atime, &now))
1197 return;
1198
1199 inode->i_atime = now;
1200 mark_inode_dirty_sync(inode);
1201}
1187EXPORT_SYMBOL(touch_atime); 1202EXPORT_SYMBOL(touch_atime);
1188 1203
1189/** 1204/**
diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
index 7b40c69f44eb..43baa1afa021 100644
--- a/fs/jffs/inode-v23.c
+++ b/fs/jffs/inode-v23.c
@@ -818,7 +818,7 @@ jffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
818 818
819 D1({ 819 D1({
820 int len = dentry->d_name.len; 820 int len = dentry->d_name.len;
821 char *_name = (char *) kmalloc(len + 1, GFP_KERNEL); 821 char *_name = kmalloc(len + 1, GFP_KERNEL);
822 memcpy(_name, dentry->d_name.name, len); 822 memcpy(_name, dentry->d_name.name, len);
823 _name[len] = '\0'; 823 _name[len] = '\0';
824 printk("***jffs_mkdir(): dir = 0x%p, name = \"%s\", " 824 printk("***jffs_mkdir(): dir = 0x%p, name = \"%s\", "
@@ -964,7 +964,7 @@ jffs_remove(struct inode *dir, struct dentry *dentry, int type)
964 D1({ 964 D1({
965 int len = dentry->d_name.len; 965 int len = dentry->d_name.len;
966 const char *name = dentry->d_name.name; 966 const char *name = dentry->d_name.name;
967 char *_name = (char *) kmalloc(len + 1, GFP_KERNEL); 967 char *_name = kmalloc(len + 1, GFP_KERNEL);
968 memcpy(_name, name, len); 968 memcpy(_name, name, len);
969 _name[len] = '\0'; 969 _name[len] = '\0';
970 printk("***jffs_remove(): file = \"%s\", ino = %ld\n", _name, dentry->d_inode->i_ino); 970 printk("***jffs_remove(): file = \"%s\", ino = %ld\n", _name, dentry->d_inode->i_ino);
diff --git a/fs/jffs/intrep.c b/fs/jffs/intrep.c
index d0e783f199ea..6dd18911b44c 100644
--- a/fs/jffs/intrep.c
+++ b/fs/jffs/intrep.c
@@ -436,7 +436,7 @@ jffs_checksum_flash(struct mtd_info *mtd, loff_t start, int size, __u32 *result)
436 int i, length; 436 int i, length;
437 437
438 /* Allocate read buffer */ 438 /* Allocate read buffer */
439 read_buf = (__u8 *) kmalloc (sizeof(__u8) * 4096, GFP_KERNEL); 439 read_buf = kmalloc(sizeof(__u8) * 4096, GFP_KERNEL);
440 if (!read_buf) { 440 if (!read_buf) {
441 printk(KERN_NOTICE "kmalloc failed in jffs_checksum_flash()\n"); 441 printk(KERN_NOTICE "kmalloc failed in jffs_checksum_flash()\n");
442 return -ENOMEM; 442 return -ENOMEM;
@@ -744,11 +744,11 @@ static int check_partly_erased_sectors(struct jffs_fmcontrol *fmc){
744 744
745 745
746 /* Allocate read buffers */ 746 /* Allocate read buffers */
747 read_buf1 = (__u8 *) kmalloc (sizeof(__u8) * READ_AHEAD_BYTES, GFP_KERNEL); 747 read_buf1 = kmalloc(sizeof(__u8) * READ_AHEAD_BYTES, GFP_KERNEL);
748 if (!read_buf1) 748 if (!read_buf1)
749 return -ENOMEM; 749 return -ENOMEM;
750 750
751 read_buf2 = (__u8 *) kmalloc (sizeof(__u8) * READ_AHEAD_BYTES, GFP_KERNEL); 751 read_buf2 = kmalloc(sizeof(__u8) * READ_AHEAD_BYTES, GFP_KERNEL);
752 if (!read_buf2) { 752 if (!read_buf2) {
753 kfree(read_buf1); 753 kfree(read_buf1);
754 return -ENOMEM; 754 return -ENOMEM;
@@ -876,7 +876,7 @@ jffs_scan_flash(struct jffs_control *c)
876 } 876 }
877 877
878 /* Allocate read buffer */ 878 /* Allocate read buffer */
879 read_buf = (__u8 *) kmalloc (sizeof(__u8) * 4096, GFP_KERNEL); 879 read_buf = kmalloc(sizeof(__u8) * 4096, GFP_KERNEL);
880 if (!read_buf) { 880 if (!read_buf) {
881 flash_safe_release(fmc->mtd); 881 flash_safe_release(fmc->mtd);
882 return -ENOMEM; 882 return -ENOMEM;
@@ -1463,7 +1463,7 @@ jffs_insert_node(struct jffs_control *c, struct jffs_file *f,
1463 kfree(f->name); 1463 kfree(f->name);
1464 DJM(no_name--); 1464 DJM(no_name--);
1465 } 1465 }
1466 if (!(f->name = (char *) kmalloc(raw_inode->nsize + 1, 1466 if (!(f->name = kmalloc(raw_inode->nsize + 1,
1467 GFP_KERNEL))) { 1467 GFP_KERNEL))) {
1468 return -ENOMEM; 1468 return -ENOMEM;
1469 } 1469 }
@@ -1737,7 +1737,7 @@ jffs_find_child(struct jffs_file *dir, const char *name, int len)
1737 printk("jffs_find_child(): Found \"%s\".\n", f->name); 1737 printk("jffs_find_child(): Found \"%s\".\n", f->name);
1738 } 1738 }
1739 else { 1739 else {
1740 char *copy = (char *) kmalloc(len + 1, GFP_KERNEL); 1740 char *copy = kmalloc(len + 1, GFP_KERNEL);
1741 if (copy) { 1741 if (copy) {
1742 memcpy(copy, name, len); 1742 memcpy(copy, name, len);
1743 copy[len] = '\0'; 1743 copy[len] = '\0';
@@ -2627,7 +2627,7 @@ jffs_print_tree(struct jffs_file *first_file, int indent)
2627 return; 2627 return;
2628 } 2628 }
2629 2629
2630 if (!(space = (char *) kmalloc(indent + 1, GFP_KERNEL))) { 2630 if (!(space = kmalloc(indent + 1, GFP_KERNEL))) {
2631 printk("jffs_print_tree(): Out of memory!\n"); 2631 printk("jffs_print_tree(): Out of memory!\n");
2632 return; 2632 return;
2633 } 2633 }
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 47bc0b5d1324..6d62f3222892 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -3777,12 +3777,12 @@ static int ciGetLeafPrefixKey(dtpage_t * lp, int li, dtpage_t * rp,
3777 struct component_name lkey; 3777 struct component_name lkey;
3778 struct component_name rkey; 3778 struct component_name rkey;
3779 3779
3780 lkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), 3780 lkey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
3781 GFP_KERNEL); 3781 GFP_KERNEL);
3782 if (lkey.name == NULL) 3782 if (lkey.name == NULL)
3783 return -ENOMEM; 3783 return -ENOMEM;
3784 3784
3785 rkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), 3785 rkey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
3786 GFP_KERNEL); 3786 GFP_KERNEL);
3787 if (rkey.name == NULL) { 3787 if (rkey.name == NULL) {
3788 kfree(lkey.name); 3788 kfree(lkey.name);
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index ee9b473b7b80..53f63b47a6d3 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -120,7 +120,7 @@ int diMount(struct inode *ipimap)
120 * allocate/initialize the in-memory inode map control structure 120 * allocate/initialize the in-memory inode map control structure
121 */ 121 */
122 /* allocate the in-memory inode map control structure. */ 122 /* allocate the in-memory inode map control structure. */
123 imap = (struct inomap *) kmalloc(sizeof(struct inomap), GFP_KERNEL); 123 imap = kmalloc(sizeof(struct inomap), GFP_KERNEL);
124 if (imap == NULL) { 124 if (imap == NULL) {
125 jfs_err("diMount: kmalloc returned NULL!"); 125 jfs_err("diMount: kmalloc returned NULL!");
126 return -ENOMEM; 126 return -ENOMEM;
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index 92681c9e9b20..062707745162 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -36,7 +36,7 @@ struct nlm_wait {
36 struct nlm_host * b_host; 36 struct nlm_host * b_host;
37 struct file_lock * b_lock; /* local file lock */ 37 struct file_lock * b_lock; /* local file lock */
38 unsigned short b_reclaim; /* got to reclaim lock */ 38 unsigned short b_reclaim; /* got to reclaim lock */
39 u32 b_status; /* grant callback status */ 39 __be32 b_status; /* grant callback status */
40}; 40};
41 41
42static LIST_HEAD(nlm_blocked); 42static LIST_HEAD(nlm_blocked);
@@ -53,7 +53,7 @@ struct nlm_wait *nlmclnt_prepare_block(struct nlm_host *host, struct file_lock *
53 block->b_host = host; 53 block->b_host = host;
54 block->b_lock = fl; 54 block->b_lock = fl;
55 init_waitqueue_head(&block->b_wait); 55 init_waitqueue_head(&block->b_wait);
56 block->b_status = NLM_LCK_BLOCKED; 56 block->b_status = nlm_lck_blocked;
57 list_add(&block->b_list, &nlm_blocked); 57 list_add(&block->b_list, &nlm_blocked);
58 } 58 }
59 return block; 59 return block;
@@ -89,7 +89,7 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout)
89 * nlmclnt_lock for an explanation. 89 * nlmclnt_lock for an explanation.
90 */ 90 */
91 ret = wait_event_interruptible_timeout(block->b_wait, 91 ret = wait_event_interruptible_timeout(block->b_wait,
92 block->b_status != NLM_LCK_BLOCKED, 92 block->b_status != nlm_lck_blocked,
93 timeout); 93 timeout);
94 if (ret < 0) 94 if (ret < 0)
95 return -ERESTARTSYS; 95 return -ERESTARTSYS;
@@ -131,7 +131,7 @@ __be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock
131 /* Alright, we found a lock. Set the return status 131 /* Alright, we found a lock. Set the return status
132 * and wake up the caller 132 * and wake up the caller
133 */ 133 */
134 block->b_status = NLM_LCK_GRANTED; 134 block->b_status = nlm_granted;
135 wake_up(&block->b_wait); 135 wake_up(&block->b_wait);
136 res = nlm_granted; 136 res = nlm_granted;
137 } 137 }
@@ -211,7 +211,7 @@ restart:
211 /* Now, wake up all processes that sleep on a blocked lock */ 211 /* Now, wake up all processes that sleep on a blocked lock */
212 list_for_each_entry(block, &nlm_blocked, b_list) { 212 list_for_each_entry(block, &nlm_blocked, b_list) {
213 if (block->b_host == host) { 213 if (block->b_host == host) {
214 block->b_status = NLM_LCK_DENIED_GRACE_PERIOD; 214 block->b_status = nlm_lck_denied_grace_period;
215 wake_up(&block->b_wait); 215 wake_up(&block->b_wait);
216 } 216 }
217 } 217 }
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 80a1a6dccc8f..0b4acc1c5e7d 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -27,7 +27,7 @@
27static int nlmclnt_test(struct nlm_rqst *, struct file_lock *); 27static int nlmclnt_test(struct nlm_rqst *, struct file_lock *);
28static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *); 28static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *);
29static int nlmclnt_unlock(struct nlm_rqst *, struct file_lock *); 29static int nlmclnt_unlock(struct nlm_rqst *, struct file_lock *);
30static int nlm_stat_to_errno(u32 stat); 30static int nlm_stat_to_errno(__be32 stat);
31static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host); 31static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host);
32static int nlmclnt_cancel(struct nlm_host *, int , struct file_lock *); 32static int nlmclnt_cancel(struct nlm_host *, int , struct file_lock *);
33 33
@@ -325,7 +325,7 @@ nlmclnt_call(struct nlm_rqst *req, u32 proc)
325 } 325 }
326 break; 326 break;
327 } else 327 } else
328 if (resp->status == NLM_LCK_DENIED_GRACE_PERIOD) { 328 if (resp->status == nlm_lck_denied_grace_period) {
329 dprintk("lockd: server in grace period\n"); 329 dprintk("lockd: server in grace period\n");
330 if (argp->reclaim) { 330 if (argp->reclaim) {
331 printk(KERN_WARNING 331 printk(KERN_WARNING
@@ -411,10 +411,10 @@ nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl)
411 goto out; 411 goto out;
412 412
413 switch (req->a_res.status) { 413 switch (req->a_res.status) {
414 case NLM_LCK_GRANTED: 414 case nlm_granted:
415 fl->fl_type = F_UNLCK; 415 fl->fl_type = F_UNLCK;
416 break; 416 break;
417 case NLM_LCK_DENIED: 417 case nlm_lck_denied:
418 /* 418 /*
419 * Report the conflicting lock back to the application. 419 * Report the conflicting lock back to the application.
420 */ 420 */
@@ -524,9 +524,9 @@ again:
524 if (!req->a_args.block) 524 if (!req->a_args.block)
525 break; 525 break;
526 /* Did a reclaimer thread notify us of a server reboot? */ 526 /* Did a reclaimer thread notify us of a server reboot? */
527 if (resp->status == NLM_LCK_DENIED_GRACE_PERIOD) 527 if (resp->status == nlm_lck_denied_grace_period)
528 continue; 528 continue;
529 if (resp->status != NLM_LCK_BLOCKED) 529 if (resp->status != nlm_lck_blocked)
530 break; 530 break;
531 /* Wait on an NLM blocking lock */ 531 /* Wait on an NLM blocking lock */
532 status = nlmclnt_block(block, req, NLMCLNT_POLL_TIMEOUT); 532 status = nlmclnt_block(block, req, NLMCLNT_POLL_TIMEOUT);
@@ -535,11 +535,11 @@ again:
535 */ 535 */
536 if (status < 0) 536 if (status < 0)
537 goto out_unblock; 537 goto out_unblock;
538 if (resp->status != NLM_LCK_BLOCKED) 538 if (resp->status != nlm_lck_blocked)
539 break; 539 break;
540 } 540 }
541 541
542 if (resp->status == NLM_LCK_GRANTED) { 542 if (resp->status == nlm_granted) {
543 down_read(&host->h_rwsem); 543 down_read(&host->h_rwsem);
544 /* Check whether or not the server has rebooted */ 544 /* Check whether or not the server has rebooted */
545 if (fl->fl_u.nfs_fl.state != host->h_state) { 545 if (fl->fl_u.nfs_fl.state != host->h_state) {
@@ -556,7 +556,7 @@ again:
556out_unblock: 556out_unblock:
557 nlmclnt_finish_block(block); 557 nlmclnt_finish_block(block);
558 /* Cancel the blocked request if it is still pending */ 558 /* Cancel the blocked request if it is still pending */
559 if (resp->status == NLM_LCK_BLOCKED) 559 if (resp->status == nlm_lck_blocked)
560 nlmclnt_cancel(host, req->a_args.block, fl); 560 nlmclnt_cancel(host, req->a_args.block, fl);
561out: 561out:
562 nlm_release_call(req); 562 nlm_release_call(req);
@@ -585,12 +585,12 @@ nlmclnt_reclaim(struct nlm_host *host, struct file_lock *fl)
585 req->a_args.reclaim = 1; 585 req->a_args.reclaim = 1;
586 586
587 if ((status = nlmclnt_call(req, NLMPROC_LOCK)) >= 0 587 if ((status = nlmclnt_call(req, NLMPROC_LOCK)) >= 0
588 && req->a_res.status == NLM_LCK_GRANTED) 588 && req->a_res.status == nlm_granted)
589 return 0; 589 return 0;
590 590
591 printk(KERN_WARNING "lockd: failed to reclaim lock for pid %d " 591 printk(KERN_WARNING "lockd: failed to reclaim lock for pid %d "
592 "(errno %d, status %d)\n", fl->fl_pid, 592 "(errno %d, status %d)\n", fl->fl_pid,
593 status, req->a_res.status); 593 status, ntohl(req->a_res.status));
594 594
595 /* 595 /*
596 * FIXME: This is a serious failure. We can 596 * FIXME: This is a serious failure. We can
@@ -637,10 +637,10 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl)
637 if (status < 0) 637 if (status < 0)
638 goto out; 638 goto out;
639 639
640 if (resp->status == NLM_LCK_GRANTED) 640 if (resp->status == nlm_granted)
641 goto out; 641 goto out;
642 642
643 if (resp->status != NLM_LCK_DENIED_NOLOCKS) 643 if (resp->status != nlm_lck_denied_nolocks)
644 printk("lockd: unexpected unlock status: %d\n", resp->status); 644 printk("lockd: unexpected unlock status: %d\n", resp->status);
645 /* What to do now? I'm out of my depth... */ 645 /* What to do now? I'm out of my depth... */
646 status = -ENOLCK; 646 status = -ENOLCK;
@@ -652,7 +652,7 @@ out:
652static void nlmclnt_unlock_callback(struct rpc_task *task, void *data) 652static void nlmclnt_unlock_callback(struct rpc_task *task, void *data)
653{ 653{
654 struct nlm_rqst *req = data; 654 struct nlm_rqst *req = data;
655 int status = req->a_res.status; 655 u32 status = ntohl(req->a_res.status);
656 656
657 if (RPC_ASSASSINATED(task)) 657 if (RPC_ASSASSINATED(task))
658 goto die; 658 goto die;
@@ -720,6 +720,7 @@ static int nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *fl
720static void nlmclnt_cancel_callback(struct rpc_task *task, void *data) 720static void nlmclnt_cancel_callback(struct rpc_task *task, void *data)
721{ 721{
722 struct nlm_rqst *req = data; 722 struct nlm_rqst *req = data;
723 u32 status = ntohl(req->a_res.status);
723 724
724 if (RPC_ASSASSINATED(task)) 725 if (RPC_ASSASSINATED(task))
725 goto die; 726 goto die;
@@ -731,9 +732,9 @@ static void nlmclnt_cancel_callback(struct rpc_task *task, void *data)
731 } 732 }
732 733
733 dprintk("lockd: cancel status %u (task %u)\n", 734 dprintk("lockd: cancel status %u (task %u)\n",
734 req->a_res.status, task->tk_pid); 735 status, task->tk_pid);
735 736
736 switch (req->a_res.status) { 737 switch (status) {
737 case NLM_LCK_GRANTED: 738 case NLM_LCK_GRANTED:
738 case NLM_LCK_DENIED_GRACE_PERIOD: 739 case NLM_LCK_DENIED_GRACE_PERIOD:
739 case NLM_LCK_DENIED: 740 case NLM_LCK_DENIED:
@@ -744,7 +745,7 @@ static void nlmclnt_cancel_callback(struct rpc_task *task, void *data)
744 goto retry_cancel; 745 goto retry_cancel;
745 default: 746 default:
746 printk(KERN_NOTICE "lockd: weird return %d for CANCEL call\n", 747 printk(KERN_NOTICE "lockd: weird return %d for CANCEL call\n",
747 req->a_res.status); 748 status);
748 } 749 }
749 750
750die: 751die:
@@ -768,9 +769,9 @@ static const struct rpc_call_ops nlmclnt_cancel_ops = {
768 * Convert an NLM status code to a generic kernel errno 769 * Convert an NLM status code to a generic kernel errno
769 */ 770 */
770static int 771static int
771nlm_stat_to_errno(u32 status) 772nlm_stat_to_errno(__be32 status)
772{ 773{
773 switch(status) { 774 switch(ntohl(status)) {
774 case NLM_LCK_GRANTED: 775 case NLM_LCK_GRANTED:
775 return 0; 776 return 0;
776 case NLM_LCK_DENIED: 777 case NLM_LCK_DENIED:
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 5c054b20fd5e..c7db0a5bccdc 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -645,7 +645,7 @@ static const struct rpc_call_ops nlmsvc_grant_ops = {
645 * block. 645 * block.
646 */ 646 */
647void 647void
648nlmsvc_grant_reply(struct nlm_cookie *cookie, u32 status) 648nlmsvc_grant_reply(struct nlm_cookie *cookie, __be32 status)
649{ 649{
650 struct nlm_block *block; 650 struct nlm_block *block;
651 651
@@ -655,7 +655,7 @@ nlmsvc_grant_reply(struct nlm_cookie *cookie, u32 status)
655 return; 655 return;
656 656
657 if (block) { 657 if (block) {
658 if (status == NLM_LCK_DENIED_GRACE_PERIOD) { 658 if (status == nlm_lck_denied_grace_period) {
659 /* Try again in a couple of seconds */ 659 /* Try again in a couple of seconds */
660 nlmsvc_insert_block(block, 10 * HZ); 660 nlmsvc_insert_block(block, 10 * HZ);
661 } else { 661 } else {
diff --git a/fs/lockd/svcshare.c b/fs/lockd/svcshare.c
index 6220dc2a3f2c..068886de4dda 100644
--- a/fs/lockd/svcshare.c
+++ b/fs/lockd/svcshare.c
@@ -39,7 +39,7 @@ nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file,
39 return nlm_lck_denied; 39 return nlm_lck_denied;
40 } 40 }
41 41
42 share = (struct nlm_share *) kmalloc(sizeof(*share) + oh->len, 42 share = kmalloc(sizeof(*share) + oh->len,
43 GFP_KERNEL); 43 GFP_KERNEL);
44 if (share == NULL) 44 if (share == NULL)
45 return nlm_lck_denied_nolocks; 45 return nlm_lck_denied_nolocks;
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index b7c949256e5a..34dae5d70738 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -361,7 +361,7 @@ nlmsvc_decode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
361{ 361{
362 if (!(p = nlm_decode_cookie(p, &resp->cookie))) 362 if (!(p = nlm_decode_cookie(p, &resp->cookie)))
363 return 0; 363 return 0;
364 resp->status = ntohl(*p++); 364 resp->status = *p++;
365 return xdr_argsize_check(rqstp, p); 365 return xdr_argsize_check(rqstp, p);
366} 366}
367 367
@@ -407,8 +407,8 @@ nlmclt_decode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
407{ 407{
408 if (!(p = nlm_decode_cookie(p, &resp->cookie))) 408 if (!(p = nlm_decode_cookie(p, &resp->cookie)))
409 return -EIO; 409 return -EIO;
410 resp->status = ntohl(*p++); 410 resp->status = *p++;
411 if (resp->status == NLM_LCK_DENIED) { 411 if (resp->status == nlm_lck_denied) {
412 struct file_lock *fl = &resp->lock.fl; 412 struct file_lock *fl = &resp->lock.fl;
413 u32 excl; 413 u32 excl;
414 s32 start, len, end; 414 s32 start, len, end;
@@ -506,7 +506,7 @@ nlmclt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
506{ 506{
507 if (!(p = nlm_decode_cookie(p, &resp->cookie))) 507 if (!(p = nlm_decode_cookie(p, &resp->cookie)))
508 return -EIO; 508 return -EIO;
509 resp->status = ntohl(*p++); 509 resp->status = *p++;
510 return 0; 510 return 0;
511} 511}
512 512
diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
index f4c0b2b9f75a..a78240551219 100644
--- a/fs/lockd/xdr4.c
+++ b/fs/lockd/xdr4.c
@@ -367,7 +367,7 @@ nlm4svc_decode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
367{ 367{
368 if (!(p = nlm4_decode_cookie(p, &resp->cookie))) 368 if (!(p = nlm4_decode_cookie(p, &resp->cookie)))
369 return 0; 369 return 0;
370 resp->status = ntohl(*p++); 370 resp->status = *p++;
371 return xdr_argsize_check(rqstp, p); 371 return xdr_argsize_check(rqstp, p);
372} 372}
373 373
@@ -413,8 +413,8 @@ nlm4clt_decode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
413{ 413{
414 if (!(p = nlm4_decode_cookie(p, &resp->cookie))) 414 if (!(p = nlm4_decode_cookie(p, &resp->cookie)))
415 return -EIO; 415 return -EIO;
416 resp->status = ntohl(*p++); 416 resp->status = *p++;
417 if (resp->status == NLM_LCK_DENIED) { 417 if (resp->status == nlm_lck_denied) {
418 struct file_lock *fl = &resp->lock.fl; 418 struct file_lock *fl = &resp->lock.fl;
419 u32 excl; 419 u32 excl;
420 s64 start, end, len; 420 s64 start, end, len;
@@ -512,7 +512,7 @@ nlm4clt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
512{ 512{
513 if (!(p = nlm4_decode_cookie(p, &resp->cookie))) 513 if (!(p = nlm4_decode_cookie(p, &resp->cookie)))
514 return -EIO; 514 return -EIO;
515 resp->status = ntohl(*p++); 515 resp->status = *p++;
516 return 0; 516 return 0;
517} 517}
518 518
diff --git a/fs/namespace.c b/fs/namespace.c
index fde8553faa76..5ef336c1103c 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -368,6 +368,7 @@ static int show_vfsmnt(struct seq_file *m, void *v)
368 { MNT_NOEXEC, ",noexec" }, 368 { MNT_NOEXEC, ",noexec" },
369 { MNT_NOATIME, ",noatime" }, 369 { MNT_NOATIME, ",noatime" },
370 { MNT_NODIRATIME, ",nodiratime" }, 370 { MNT_NODIRATIME, ",nodiratime" },
371 { MNT_RELATIME, ",relatime" },
371 { 0, NULL } 372 { 0, NULL }
372 }; 373 };
373 struct proc_fs_info *fs_infop; 374 struct proc_fs_info *fs_infop;
@@ -1405,9 +1406,11 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
1405 mnt_flags |= MNT_NOATIME; 1406 mnt_flags |= MNT_NOATIME;
1406 if (flags & MS_NODIRATIME) 1407 if (flags & MS_NODIRATIME)
1407 mnt_flags |= MNT_NODIRATIME; 1408 mnt_flags |= MNT_NODIRATIME;
1409 if (flags & MS_RELATIME)
1410 mnt_flags |= MNT_RELATIME;
1408 1411
1409 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | 1412 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
1410 MS_NOATIME | MS_NODIRATIME); 1413 MS_NOATIME | MS_NODIRATIME | MS_RELATIME);
1411 1414
1412 /* ... and get the mountpoint */ 1415 /* ... and get the mountpoint */
1413 retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd); 1416 retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 47462ac94474..67a90bf795d5 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -327,11 +327,12 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
327 char *optarg; 327 char *optarg;
328 unsigned long optint; 328 unsigned long optint;
329 int version = 0; 329 int version = 0;
330 int ret;
330 331
331 data->flags = 0; 332 data->flags = 0;
332 data->int_flags = 0; 333 data->int_flags = 0;
333 data->mounted_uid = 0; 334 data->mounted_uid = 0;
334 data->wdog_pid = -1; 335 data->wdog_pid = NULL;
335 data->ncp_fd = ~0; 336 data->ncp_fd = ~0;
336 data->time_out = 10; 337 data->time_out = 10;
337 data->retry_count = 20; 338 data->retry_count = 20;
@@ -343,8 +344,9 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
343 data->mounted_vol[0] = 0; 344 data->mounted_vol[0] = 0;
344 345
345 while ((optval = ncp_getopt("ncpfs", &options, ncp_opts, NULL, &optarg, &optint)) != 0) { 346 while ((optval = ncp_getopt("ncpfs", &options, ncp_opts, NULL, &optarg, &optint)) != 0) {
346 if (optval < 0) 347 ret = optval;
347 return optval; 348 if (ret < 0)
349 goto err;
348 switch (optval) { 350 switch (optval) {
349 case 'u': 351 case 'u':
350 data->uid = optint; 352 data->uid = optint;
@@ -371,7 +373,7 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
371 data->flags = optint; 373 data->flags = optint;
372 break; 374 break;
373 case 'w': 375 case 'w':
374 data->wdog_pid = optint; 376 data->wdog_pid = find_get_pid(optint);
375 break; 377 break;
376 case 'n': 378 case 'n':
377 data->ncp_fd = optint; 379 data->ncp_fd = optint;
@@ -380,18 +382,21 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
380 data->info_fd = optint; 382 data->info_fd = optint;
381 break; 383 break;
382 case 'v': 384 case 'v':
383 if (optint < NCP_MOUNT_VERSION_V4) { 385 ret = -ECHRNG;
384 return -ECHRNG; 386 if (optint < NCP_MOUNT_VERSION_V4)
385 } 387 goto err;
386 if (optint > NCP_MOUNT_VERSION_V5) { 388 if (optint > NCP_MOUNT_VERSION_V5)
387 return -ECHRNG; 389 goto err;
388 }
389 version = optint; 390 version = optint;
390 break; 391 break;
391 392
392 } 393 }
393 } 394 }
394 return 0; 395 return 0;
396err:
397 put_pid(data->wdog_pid);
398 data->wdog_pid = NULL;
399 return ret;
395} 400}
396 401
397static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) 402static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
@@ -409,6 +414,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
409#endif 414#endif
410 struct ncp_entry_info finfo; 415 struct ncp_entry_info finfo;
411 416
417 data.wdog_pid = NULL;
412 server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL); 418 server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
413 if (!server) 419 if (!server)
414 return -ENOMEM; 420 return -ENOMEM;
@@ -425,7 +431,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
425 data.flags = md->flags; 431 data.flags = md->flags;
426 data.int_flags = NCP_IMOUNT_LOGGEDIN_POSSIBLE; 432 data.int_flags = NCP_IMOUNT_LOGGEDIN_POSSIBLE;
427 data.mounted_uid = md->mounted_uid; 433 data.mounted_uid = md->mounted_uid;
428 data.wdog_pid = md->wdog_pid; 434 data.wdog_pid = find_get_pid(md->wdog_pid);
429 data.ncp_fd = md->ncp_fd; 435 data.ncp_fd = md->ncp_fd;
430 data.time_out = md->time_out; 436 data.time_out = md->time_out;
431 data.retry_count = md->retry_count; 437 data.retry_count = md->retry_count;
@@ -445,7 +451,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
445 data.flags = md->flags; 451 data.flags = md->flags;
446 data.int_flags = 0; 452 data.int_flags = 0;
447 data.mounted_uid = md->mounted_uid; 453 data.mounted_uid = md->mounted_uid;
448 data.wdog_pid = md->wdog_pid; 454 data.wdog_pid = find_get_pid(md->wdog_pid);
449 data.ncp_fd = md->ncp_fd; 455 data.ncp_fd = md->ncp_fd;
450 data.time_out = md->time_out; 456 data.time_out = md->time_out;
451 data.retry_count = md->retry_count; 457 data.retry_count = md->retry_count;
@@ -679,6 +685,7 @@ out_fput:
679 */ 685 */
680 fput(ncp_filp); 686 fput(ncp_filp);
681out: 687out:
688 put_pid(data.wdog_pid);
682 sb->s_fs_info = NULL; 689 sb->s_fs_info = NULL;
683 kfree(server); 690 kfree(server);
684 return error; 691 return error;
@@ -711,7 +718,8 @@ static void ncp_put_super(struct super_block *sb)
711 if (server->info_filp) 718 if (server->info_filp)
712 fput(server->info_filp); 719 fput(server->info_filp);
713 fput(server->ncp_filp); 720 fput(server->ncp_filp);
714 kill_proc(server->m.wdog_pid, SIGTERM, 1); 721 kill_pid(server->m.wdog_pid, SIGTERM, 1);
722 put_pid(server->m.wdog_pid);
715 723
716 kfree(server->priv.data); 724 kfree(server->priv.data);
717 kfree(server->auth.object_name); 725 kfree(server->auth.object_name);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index ee458aeab24a..b3fd29baadc3 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1877,7 +1877,7 @@ static int nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir,
1877 struct nfs_server *server = NFS_SERVER(dir->d_inode); 1877 struct nfs_server *server = NFS_SERVER(dir->d_inode);
1878 struct unlink_desc *up; 1878 struct unlink_desc *up;
1879 1879
1880 up = (struct unlink_desc *) kmalloc(sizeof(*up), GFP_KERNEL); 1880 up = kmalloc(sizeof(*up), GFP_KERNEL);
1881 if (!up) 1881 if (!up)
1882 return -ENOMEM; 1882 return -ENOMEM;
1883 1883
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index f37df46d2eaa..248dd92e6a56 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -787,15 +787,20 @@ exp_get_by_name(svc_client *clp, struct vfsmount *mnt, struct dentry *dentry,
787 key.ex_dentry = dentry; 787 key.ex_dentry = dentry;
788 788
789 exp = svc_export_lookup(&key); 789 exp = svc_export_lookup(&key);
790 if (exp != NULL) 790 if (exp != NULL) {
791 switch (cache_check(&svc_export_cache, &exp->h, reqp)) { 791 int err;
792
793 err = cache_check(&svc_export_cache, &exp->h, reqp);
794 switch (err) {
792 case 0: break; 795 case 0: break;
793 case -EAGAIN: 796 case -EAGAIN:
794 exp = ERR_PTR(-EAGAIN); 797 case -ETIMEDOUT:
798 exp = ERR_PTR(err);
795 break; 799 break;
796 default: 800 default:
797 exp = NULL; 801 exp = NULL;
798 } 802 }
803 }
799 804
800 return exp; 805 return exp;
801} 806}
@@ -950,6 +955,8 @@ exp_export(struct nfsctl_export *nxp)
950 955
951 exp = exp_get_by_name(clp, nd.mnt, nd.dentry, NULL); 956 exp = exp_get_by_name(clp, nd.mnt, nd.dentry, NULL);
952 957
958 memset(&new, 0, sizeof(new));
959
953 /* must make sure there won't be an ex_fsid clash */ 960 /* must make sure there won't be an ex_fsid clash */
954 if ((nxp->ex_flags & NFSEXP_FSID) && 961 if ((nxp->ex_flags & NFSEXP_FSID) &&
955 (fsid_key = exp_get_fsid_key(clp, nxp->ex_dev)) && 962 (fsid_key = exp_get_fsid_key(clp, nxp->ex_dev)) &&
@@ -980,6 +987,9 @@ exp_export(struct nfsctl_export *nxp)
980 987
981 new.h.expiry_time = NEVER; 988 new.h.expiry_time = NEVER;
982 new.h.flags = 0; 989 new.h.flags = 0;
990 new.ex_path = kstrdup(nxp->ex_path, GFP_KERNEL);
991 if (!new.ex_path)
992 goto finish;
983 new.ex_client = clp; 993 new.ex_client = clp;
984 new.ex_mnt = nd.mnt; 994 new.ex_mnt = nd.mnt;
985 new.ex_dentry = nd.dentry; 995 new.ex_dentry = nd.dentry;
@@ -1000,10 +1010,11 @@ exp_export(struct nfsctl_export *nxp)
1000 /* failed to create at least one index */ 1010 /* failed to create at least one index */
1001 exp_do_unexport(exp); 1011 exp_do_unexport(exp);
1002 cache_flush(); 1012 cache_flush();
1003 err = -ENOMEM; 1013 } else
1004 } 1014 err = 0;
1005
1006finish: 1015finish:
1016 if (new.ex_path)
1017 kfree(new.ex_path);
1007 if (exp) 1018 if (exp)
1008 exp_put(exp); 1019 exp_put(exp);
1009 if (fsid_key && !IS_ERR(fsid_key)) 1020 if (fsid_key && !IS_ERR(fsid_key))
@@ -1104,6 +1115,10 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
1104 path, nd.dentry, clp->name, 1115 path, nd.dentry, clp->name,
1105 inode->i_sb->s_id, inode->i_ino); 1116 inode->i_sb->s_id, inode->i_ino);
1106 exp = exp_parent(clp, nd.mnt, nd.dentry, NULL); 1117 exp = exp_parent(clp, nd.mnt, nd.dentry, NULL);
1118 if (IS_ERR(exp)) {
1119 err = PTR_ERR(exp);
1120 goto out;
1121 }
1107 if (!exp) { 1122 if (!exp) {
1108 dprintk("nfsd: exp_rootfh export not found.\n"); 1123 dprintk("nfsd: exp_rootfh export not found.\n");
1109 goto out; 1124 goto out;
@@ -1159,12 +1174,10 @@ exp_pseudoroot(struct auth_domain *clp, struct svc_fh *fhp,
1159 mk_fsid_v1(fsidv, 0); 1174 mk_fsid_v1(fsidv, 0);
1160 1175
1161 exp = exp_find(clp, 1, fsidv, creq); 1176 exp = exp_find(clp, 1, fsidv, creq);
1162 if (IS_ERR(exp) && PTR_ERR(exp) == -EAGAIN) 1177 if (IS_ERR(exp))
1163 return nfserr_dropit; 1178 return nfserrno(PTR_ERR(exp));
1164 if (exp == NULL) 1179 if (exp == NULL)
1165 return nfserr_perm; 1180 return nfserr_perm;
1166 else if (IS_ERR(exp))
1167 return nfserrno(PTR_ERR(exp));
1168 rv = fh_compose(fhp, exp, exp->ex_dentry, NULL); 1181 rv = fh_compose(fhp, exp, exp->ex_dentry, NULL);
1169 exp_put(exp); 1182 exp_put(exp);
1170 return rv; 1183 return rv;
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c
index 11fdaf7721b4..221acd1f11f6 100644
--- a/fs/nfsd/lockd.c
+++ b/fs/nfsd/lockd.c
@@ -22,7 +22,7 @@
22/* 22/*
23 * Note: we hold the dentry use count while the file is open. 23 * Note: we hold the dentry use count while the file is open.
24 */ 24 */
25static u32 25static __be32
26nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp) 26nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp)
27{ 27{
28 __be32 nfserr; 28 __be32 nfserr;
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 50bc94243ca1..8522729830db 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -33,13 +33,6 @@
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * Note: some routines in this file are just trivial wrappers
38 * (e.g. nfsd4_lookup()) defined solely for the sake of consistent
39 * naming. Since all such routines have been declared "inline",
40 * there shouldn't be any associated overhead. At some point in
41 * the future, I might inline these "by hand" to clean up a
42 * little.
43 */ 36 */
44 37
45#include <linux/param.h> 38#include <linux/param.h>
@@ -161,8 +154,9 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_
161} 154}
162 155
163 156
164static inline __be32 157static __be32
165nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open, struct nfs4_stateowner **replay_owner) 158nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
159 struct nfsd4_open *open)
166{ 160{
167 __be32 status; 161 __be32 status;
168 dprintk("NFSD: nfsd4_open filename %.*s op_stateowner %p\n", 162 dprintk("NFSD: nfsd4_open filename %.*s op_stateowner %p\n",
@@ -179,11 +173,11 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open
179 status = nfsd4_process_open1(open); 173 status = nfsd4_process_open1(open);
180 if (status == nfserr_replay_me) { 174 if (status == nfserr_replay_me) {
181 struct nfs4_replay *rp = &open->op_stateowner->so_replay; 175 struct nfs4_replay *rp = &open->op_stateowner->so_replay;
182 fh_put(current_fh); 176 fh_put(&cstate->current_fh);
183 current_fh->fh_handle.fh_size = rp->rp_openfh_len; 177 cstate->current_fh.fh_handle.fh_size = rp->rp_openfh_len;
184 memcpy(&current_fh->fh_handle.fh_base, rp->rp_openfh, 178 memcpy(&cstate->current_fh.fh_handle.fh_base, rp->rp_openfh,
185 rp->rp_openfh_len); 179 rp->rp_openfh_len);
186 status = fh_verify(rqstp, current_fh, 0, MAY_NOP); 180 status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP);
187 if (status) 181 if (status)
188 dprintk("nfsd4_open: replay failed" 182 dprintk("nfsd4_open: replay failed"
189 " restoring previous filehandle\n"); 183 " restoring previous filehandle\n");
@@ -215,7 +209,8 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open
215 * (3) set open->op_truncate if the file is to be 209 * (3) set open->op_truncate if the file is to be
216 * truncated after opening, (4) do permission checking. 210 * truncated after opening, (4) do permission checking.
217 */ 211 */
218 status = do_open_lookup(rqstp, current_fh, open); 212 status = do_open_lookup(rqstp, &cstate->current_fh,
213 open);
219 if (status) 214 if (status)
220 goto out; 215 goto out;
221 break; 216 break;
@@ -227,7 +222,8 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open
227 * open->op_truncate if the file is to be truncated 222 * open->op_truncate if the file is to be truncated
228 * after opening, (3) do permission checking. 223 * after opening, (3) do permission checking.
229 */ 224 */
230 status = do_open_fhandle(rqstp, current_fh, open); 225 status = do_open_fhandle(rqstp, &cstate->current_fh,
226 open);
231 if (status) 227 if (status)
232 goto out; 228 goto out;
233 break; 229 break;
@@ -248,11 +244,11 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open
248 * successful, it (1) truncates the file if open->op_truncate was 244 * successful, it (1) truncates the file if open->op_truncate was
249 * set, (2) sets open->op_stateid, (3) sets open->op_delegation. 245 * set, (2) sets open->op_stateid, (3) sets open->op_delegation.
250 */ 246 */
251 status = nfsd4_process_open2(rqstp, current_fh, open); 247 status = nfsd4_process_open2(rqstp, &cstate->current_fh, open);
252out: 248out:
253 if (open->op_stateowner) { 249 if (open->op_stateowner) {
254 nfs4_get_stateowner(open->op_stateowner); 250 nfs4_get_stateowner(open->op_stateowner);
255 *replay_owner = open->op_stateowner; 251 cstate->replay_owner = open->op_stateowner;
256 } 252 }
257 nfs4_unlock_state(); 253 nfs4_unlock_state();
258 return status; 254 return status;
@@ -261,71 +257,80 @@ out:
261/* 257/*
262 * filehandle-manipulating ops. 258 * filehandle-manipulating ops.
263 */ 259 */
264static inline __be32 260static __be32
265nfsd4_getfh(struct svc_fh *current_fh, struct svc_fh **getfh) 261nfsd4_getfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
262 struct svc_fh **getfh)
266{ 263{
267 if (!current_fh->fh_dentry) 264 if (!cstate->current_fh.fh_dentry)
268 return nfserr_nofilehandle; 265 return nfserr_nofilehandle;
269 266
270 *getfh = current_fh; 267 *getfh = &cstate->current_fh;
271 return nfs_ok; 268 return nfs_ok;
272} 269}
273 270
274static inline __be32 271static __be32
275nfsd4_putfh(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_putfh *putfh) 272nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
273 struct nfsd4_putfh *putfh)
276{ 274{
277 fh_put(current_fh); 275 fh_put(&cstate->current_fh);
278 current_fh->fh_handle.fh_size = putfh->pf_fhlen; 276 cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen;
279 memcpy(&current_fh->fh_handle.fh_base, putfh->pf_fhval, putfh->pf_fhlen); 277 memcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval,
280 return fh_verify(rqstp, current_fh, 0, MAY_NOP); 278 putfh->pf_fhlen);
279 return fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP);
281} 280}
282 281
283static inline __be32 282static __be32
284nfsd4_putrootfh(struct svc_rqst *rqstp, struct svc_fh *current_fh) 283nfsd4_putrootfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
284 void *arg)
285{ 285{
286 __be32 status; 286 __be32 status;
287 287
288 fh_put(current_fh); 288 fh_put(&cstate->current_fh);
289 status = exp_pseudoroot(rqstp->rq_client, current_fh, 289 status = exp_pseudoroot(rqstp->rq_client, &cstate->current_fh,
290 &rqstp->rq_chandle); 290 &rqstp->rq_chandle);
291 return status; 291 return status;
292} 292}
293 293
294static inline __be32 294static __be32
295nfsd4_restorefh(struct svc_fh *current_fh, struct svc_fh *save_fh) 295nfsd4_restorefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
296 void *arg)
296{ 297{
297 if (!save_fh->fh_dentry) 298 if (!cstate->save_fh.fh_dentry)
298 return nfserr_restorefh; 299 return nfserr_restorefh;
299 300
300 fh_dup2(current_fh, save_fh); 301 fh_dup2(&cstate->current_fh, &cstate->save_fh);
301 return nfs_ok; 302 return nfs_ok;
302} 303}
303 304
304static inline __be32 305static __be32
305nfsd4_savefh(struct svc_fh *current_fh, struct svc_fh *save_fh) 306nfsd4_savefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
307 void *arg)
306{ 308{
307 if (!current_fh->fh_dentry) 309 if (!cstate->current_fh.fh_dentry)
308 return nfserr_nofilehandle; 310 return nfserr_nofilehandle;
309 311
310 fh_dup2(save_fh, current_fh); 312 fh_dup2(&cstate->save_fh, &cstate->current_fh);
311 return nfs_ok; 313 return nfs_ok;
312} 314}
313 315
314/* 316/*
315 * misc nfsv4 ops 317 * misc nfsv4 ops
316 */ 318 */
317static inline __be32 319static __be32
318nfsd4_access(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_access *access) 320nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
321 struct nfsd4_access *access)
319{ 322{
320 if (access->ac_req_access & ~NFS3_ACCESS_FULL) 323 if (access->ac_req_access & ~NFS3_ACCESS_FULL)
321 return nfserr_inval; 324 return nfserr_inval;
322 325
323 access->ac_resp_access = access->ac_req_access; 326 access->ac_resp_access = access->ac_req_access;
324 return nfsd_access(rqstp, current_fh, &access->ac_resp_access, &access->ac_supported); 327 return nfsd_access(rqstp, &cstate->current_fh, &access->ac_resp_access,
328 &access->ac_supported);
325} 329}
326 330
327static inline __be32 331static __be32
328nfsd4_commit(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_commit *commit) 332nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
333 struct nfsd4_commit *commit)
329{ 334{
330 __be32 status; 335 __be32 status;
331 336
@@ -333,14 +338,16 @@ nfsd4_commit(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_com
333 *p++ = nfssvc_boot.tv_sec; 338 *p++ = nfssvc_boot.tv_sec;
334 *p++ = nfssvc_boot.tv_usec; 339 *p++ = nfssvc_boot.tv_usec;
335 340
336 status = nfsd_commit(rqstp, current_fh, commit->co_offset, commit->co_count); 341 status = nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset,
342 commit->co_count);
337 if (status == nfserr_symlink) 343 if (status == nfserr_symlink)
338 status = nfserr_inval; 344 status = nfserr_inval;
339 return status; 345 return status;
340} 346}
341 347
342static __be32 348static __be32
343nfsd4_create(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_create *create) 349nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
350 struct nfsd4_create *create)
344{ 351{
345 struct svc_fh resfh; 352 struct svc_fh resfh;
346 __be32 status; 353 __be32 status;
@@ -348,7 +355,7 @@ nfsd4_create(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_cre
348 355
349 fh_init(&resfh, NFS4_FHSIZE); 356 fh_init(&resfh, NFS4_FHSIZE);
350 357
351 status = fh_verify(rqstp, current_fh, S_IFDIR, MAY_CREATE); 358 status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, MAY_CREATE);
352 if (status == nfserr_symlink) 359 if (status == nfserr_symlink)
353 status = nfserr_notdir; 360 status = nfserr_notdir;
354 if (status) 361 if (status)
@@ -365,9 +372,10 @@ nfsd4_create(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_cre
365 */ 372 */
366 create->cr_linkname[create->cr_linklen] = 0; 373 create->cr_linkname[create->cr_linklen] = 0;
367 374
368 status = nfsd_symlink(rqstp, current_fh, create->cr_name, 375 status = nfsd_symlink(rqstp, &cstate->current_fh,
369 create->cr_namelen, create->cr_linkname, 376 create->cr_name, create->cr_namelen,
370 create->cr_linklen, &resfh, &create->cr_iattr); 377 create->cr_linkname, create->cr_linklen,
378 &resfh, &create->cr_iattr);
371 break; 379 break;
372 380
373 case NF4BLK: 381 case NF4BLK:
@@ -375,9 +383,9 @@ nfsd4_create(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_cre
375 if (MAJOR(rdev) != create->cr_specdata1 || 383 if (MAJOR(rdev) != create->cr_specdata1 ||
376 MINOR(rdev) != create->cr_specdata2) 384 MINOR(rdev) != create->cr_specdata2)
377 return nfserr_inval; 385 return nfserr_inval;
378 status = nfsd_create(rqstp, current_fh, create->cr_name, 386 status = nfsd_create(rqstp, &cstate->current_fh,
379 create->cr_namelen, &create->cr_iattr, 387 create->cr_name, create->cr_namelen,
380 S_IFBLK, rdev, &resfh); 388 &create->cr_iattr, S_IFBLK, rdev, &resfh);
381 break; 389 break;
382 390
383 case NF4CHR: 391 case NF4CHR:
@@ -385,28 +393,28 @@ nfsd4_create(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_cre
385 if (MAJOR(rdev) != create->cr_specdata1 || 393 if (MAJOR(rdev) != create->cr_specdata1 ||
386 MINOR(rdev) != create->cr_specdata2) 394 MINOR(rdev) != create->cr_specdata2)
387 return nfserr_inval; 395 return nfserr_inval;
388 status = nfsd_create(rqstp, current_fh, create->cr_name, 396 status = nfsd_create(rqstp, &cstate->current_fh,
389 create->cr_namelen, &create->cr_iattr, 397 create->cr_name, create->cr_namelen,
390 S_IFCHR, rdev, &resfh); 398 &create->cr_iattr,S_IFCHR, rdev, &resfh);
391 break; 399 break;
392 400
393 case NF4SOCK: 401 case NF4SOCK:
394 status = nfsd_create(rqstp, current_fh, create->cr_name, 402 status = nfsd_create(rqstp, &cstate->current_fh,
395 create->cr_namelen, &create->cr_iattr, 403 create->cr_name, create->cr_namelen,
396 S_IFSOCK, 0, &resfh); 404 &create->cr_iattr, S_IFSOCK, 0, &resfh);
397 break; 405 break;
398 406
399 case NF4FIFO: 407 case NF4FIFO:
400 status = nfsd_create(rqstp, current_fh, create->cr_name, 408 status = nfsd_create(rqstp, &cstate->current_fh,
401 create->cr_namelen, &create->cr_iattr, 409 create->cr_name, create->cr_namelen,
402 S_IFIFO, 0, &resfh); 410 &create->cr_iattr, S_IFIFO, 0, &resfh);
403 break; 411 break;
404 412
405 case NF4DIR: 413 case NF4DIR:
406 create->cr_iattr.ia_valid &= ~ATTR_SIZE; 414 create->cr_iattr.ia_valid &= ~ATTR_SIZE;
407 status = nfsd_create(rqstp, current_fh, create->cr_name, 415 status = nfsd_create(rqstp, &cstate->current_fh,
408 create->cr_namelen, &create->cr_iattr, 416 create->cr_name, create->cr_namelen,
409 S_IFDIR, 0, &resfh); 417 &create->cr_iattr, S_IFDIR, 0, &resfh);
410 break; 418 break;
411 419
412 default: 420 default:
@@ -414,21 +422,22 @@ nfsd4_create(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_cre
414 } 422 }
415 423
416 if (!status) { 424 if (!status) {
417 fh_unlock(current_fh); 425 fh_unlock(&cstate->current_fh);
418 set_change_info(&create->cr_cinfo, current_fh); 426 set_change_info(&create->cr_cinfo, &cstate->current_fh);
419 fh_dup2(current_fh, &resfh); 427 fh_dup2(&cstate->current_fh, &resfh);
420 } 428 }
421 429
422 fh_put(&resfh); 430 fh_put(&resfh);
423 return status; 431 return status;
424} 432}
425 433
426static inline __be32 434static __be32
427nfsd4_getattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_getattr *getattr) 435nfsd4_getattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
436 struct nfsd4_getattr *getattr)
428{ 437{
429 __be32 status; 438 __be32 status;
430 439
431 status = fh_verify(rqstp, current_fh, 0, MAY_NOP); 440 status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP);
432 if (status) 441 if (status)
433 return status; 442 return status;
434 443
@@ -438,26 +447,28 @@ nfsd4_getattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_ge
438 getattr->ga_bmval[0] &= NFSD_SUPPORTED_ATTRS_WORD0; 447 getattr->ga_bmval[0] &= NFSD_SUPPORTED_ATTRS_WORD0;
439 getattr->ga_bmval[1] &= NFSD_SUPPORTED_ATTRS_WORD1; 448 getattr->ga_bmval[1] &= NFSD_SUPPORTED_ATTRS_WORD1;
440 449
441 getattr->ga_fhp = current_fh; 450 getattr->ga_fhp = &cstate->current_fh;
442 return nfs_ok; 451 return nfs_ok;
443} 452}
444 453
445static inline __be32 454static __be32
446nfsd4_link(struct svc_rqst *rqstp, struct svc_fh *current_fh, 455nfsd4_link(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
447 struct svc_fh *save_fh, struct nfsd4_link *link) 456 struct nfsd4_link *link)
448{ 457{
449 __be32 status = nfserr_nofilehandle; 458 __be32 status = nfserr_nofilehandle;
450 459
451 if (!save_fh->fh_dentry) 460 if (!cstate->save_fh.fh_dentry)
452 return status; 461 return status;
453 status = nfsd_link(rqstp, current_fh, link->li_name, link->li_namelen, save_fh); 462 status = nfsd_link(rqstp, &cstate->current_fh,
463 link->li_name, link->li_namelen, &cstate->save_fh);
454 if (!status) 464 if (!status)
455 set_change_info(&link->li_cinfo, current_fh); 465 set_change_info(&link->li_cinfo, &cstate->current_fh);
456 return status; 466 return status;
457} 467}
458 468
459static __be32 469static __be32
460nfsd4_lookupp(struct svc_rqst *rqstp, struct svc_fh *current_fh) 470nfsd4_lookupp(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
471 void *arg)
461{ 472{
462 struct svc_fh tmp_fh; 473 struct svc_fh tmp_fh;
463 __be32 ret; 474 __be32 ret;
@@ -466,22 +477,27 @@ nfsd4_lookupp(struct svc_rqst *rqstp, struct svc_fh *current_fh)
466 if((ret = exp_pseudoroot(rqstp->rq_client, &tmp_fh, 477 if((ret = exp_pseudoroot(rqstp->rq_client, &tmp_fh,
467 &rqstp->rq_chandle)) != 0) 478 &rqstp->rq_chandle)) != 0)
468 return ret; 479 return ret;
469 if (tmp_fh.fh_dentry == current_fh->fh_dentry) { 480 if (tmp_fh.fh_dentry == cstate->current_fh.fh_dentry) {
470 fh_put(&tmp_fh); 481 fh_put(&tmp_fh);
471 return nfserr_noent; 482 return nfserr_noent;
472 } 483 }
473 fh_put(&tmp_fh); 484 fh_put(&tmp_fh);
474 return nfsd_lookup(rqstp, current_fh, "..", 2, current_fh); 485 return nfsd_lookup(rqstp, &cstate->current_fh,
486 "..", 2, &cstate->current_fh);
475} 487}
476 488
477static inline __be32 489static __be32
478nfsd4_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lookup *lookup) 490nfsd4_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
491 struct nfsd4_lookup *lookup)
479{ 492{
480 return nfsd_lookup(rqstp, current_fh, lookup->lo_name, lookup->lo_len, current_fh); 493 return nfsd_lookup(rqstp, &cstate->current_fh,
494 lookup->lo_name, lookup->lo_len,
495 &cstate->current_fh);
481} 496}
482 497
483static inline __be32 498static __be32
484nfsd4_read(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_read *read) 499nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
500 struct nfsd4_read *read)
485{ 501{
486 __be32 status; 502 __be32 status;
487 503
@@ -493,7 +509,8 @@ nfsd4_read(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_read
493 509
494 nfs4_lock_state(); 510 nfs4_lock_state();
495 /* check stateid */ 511 /* check stateid */
496 if ((status = nfs4_preprocess_stateid_op(current_fh, &read->rd_stateid, 512 if ((status = nfs4_preprocess_stateid_op(&cstate->current_fh,
513 &read->rd_stateid,
497 CHECK_FH | RD_STATE, &read->rd_filp))) { 514 CHECK_FH | RD_STATE, &read->rd_filp))) {
498 dprintk("NFSD: nfsd4_read: couldn't process stateid!\n"); 515 dprintk("NFSD: nfsd4_read: couldn't process stateid!\n");
499 goto out; 516 goto out;
@@ -504,12 +521,13 @@ nfsd4_read(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_read
504out: 521out:
505 nfs4_unlock_state(); 522 nfs4_unlock_state();
506 read->rd_rqstp = rqstp; 523 read->rd_rqstp = rqstp;
507 read->rd_fhp = current_fh; 524 read->rd_fhp = &cstate->current_fh;
508 return status; 525 return status;
509} 526}
510 527
511static inline __be32 528static __be32
512nfsd4_readdir(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_readdir *readdir) 529nfsd4_readdir(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
530 struct nfsd4_readdir *readdir)
513{ 531{
514 u64 cookie = readdir->rd_cookie; 532 u64 cookie = readdir->rd_cookie;
515 static const nfs4_verifier zeroverf; 533 static const nfs4_verifier zeroverf;
@@ -527,48 +545,51 @@ nfsd4_readdir(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_re
527 return nfserr_bad_cookie; 545 return nfserr_bad_cookie;
528 546
529 readdir->rd_rqstp = rqstp; 547 readdir->rd_rqstp = rqstp;
530 readdir->rd_fhp = current_fh; 548 readdir->rd_fhp = &cstate->current_fh;
531 return nfs_ok; 549 return nfs_ok;
532} 550}
533 551
534static inline __be32 552static __be32
535nfsd4_readlink(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_readlink *readlink) 553nfsd4_readlink(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
554 struct nfsd4_readlink *readlink)
536{ 555{
537 readlink->rl_rqstp = rqstp; 556 readlink->rl_rqstp = rqstp;
538 readlink->rl_fhp = current_fh; 557 readlink->rl_fhp = &cstate->current_fh;
539 return nfs_ok; 558 return nfs_ok;
540} 559}
541 560
542static inline __be32 561static __be32
543nfsd4_remove(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_remove *remove) 562nfsd4_remove(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
563 struct nfsd4_remove *remove)
544{ 564{
545 __be32 status; 565 __be32 status;
546 566
547 if (nfs4_in_grace()) 567 if (nfs4_in_grace())
548 return nfserr_grace; 568 return nfserr_grace;
549 status = nfsd_unlink(rqstp, current_fh, 0, remove->rm_name, remove->rm_namelen); 569 status = nfsd_unlink(rqstp, &cstate->current_fh, 0,
570 remove->rm_name, remove->rm_namelen);
550 if (status == nfserr_symlink) 571 if (status == nfserr_symlink)
551 return nfserr_notdir; 572 return nfserr_notdir;
552 if (!status) { 573 if (!status) {
553 fh_unlock(current_fh); 574 fh_unlock(&cstate->current_fh);
554 set_change_info(&remove->rm_cinfo, current_fh); 575 set_change_info(&remove->rm_cinfo, &cstate->current_fh);
555 } 576 }
556 return status; 577 return status;
557} 578}
558 579
559static inline __be32 580static __be32
560nfsd4_rename(struct svc_rqst *rqstp, struct svc_fh *current_fh, 581nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
561 struct svc_fh *save_fh, struct nfsd4_rename *rename) 582 struct nfsd4_rename *rename)
562{ 583{
563 __be32 status = nfserr_nofilehandle; 584 __be32 status = nfserr_nofilehandle;
564 585
565 if (!save_fh->fh_dentry) 586 if (!cstate->save_fh.fh_dentry)
566 return status; 587 return status;
567 if (nfs4_in_grace() && !(save_fh->fh_export->ex_flags 588 if (nfs4_in_grace() && !(cstate->save_fh.fh_export->ex_flags
568 & NFSEXP_NOSUBTREECHECK)) 589 & NFSEXP_NOSUBTREECHECK))
569 return nfserr_grace; 590 return nfserr_grace;
570 status = nfsd_rename(rqstp, save_fh, rename->rn_sname, 591 status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname,
571 rename->rn_snamelen, current_fh, 592 rename->rn_snamelen, &cstate->current_fh,
572 rename->rn_tname, rename->rn_tnamelen); 593 rename->rn_tname, rename->rn_tnamelen);
573 594
574 /* the underlying filesystem returns different error's than required 595 /* the underlying filesystem returns different error's than required
@@ -576,27 +597,28 @@ nfsd4_rename(struct svc_rqst *rqstp, struct svc_fh *current_fh,
576 if (status == nfserr_isdir) 597 if (status == nfserr_isdir)
577 status = nfserr_exist; 598 status = nfserr_exist;
578 else if ((status == nfserr_notdir) && 599 else if ((status == nfserr_notdir) &&
579 (S_ISDIR(save_fh->fh_dentry->d_inode->i_mode) && 600 (S_ISDIR(cstate->save_fh.fh_dentry->d_inode->i_mode) &&
580 S_ISDIR(current_fh->fh_dentry->d_inode->i_mode))) 601 S_ISDIR(cstate->current_fh.fh_dentry->d_inode->i_mode)))
581 status = nfserr_exist; 602 status = nfserr_exist;
582 else if (status == nfserr_symlink) 603 else if (status == nfserr_symlink)
583 status = nfserr_notdir; 604 status = nfserr_notdir;
584 605
585 if (!status) { 606 if (!status) {
586 set_change_info(&rename->rn_sinfo, current_fh); 607 set_change_info(&rename->rn_sinfo, &cstate->current_fh);
587 set_change_info(&rename->rn_tinfo, save_fh); 608 set_change_info(&rename->rn_tinfo, &cstate->save_fh);
588 } 609 }
589 return status; 610 return status;
590} 611}
591 612
592static inline __be32 613static __be32
593nfsd4_setattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_setattr *setattr) 614nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
615 struct nfsd4_setattr *setattr)
594{ 616{
595 __be32 status = nfs_ok; 617 __be32 status = nfs_ok;
596 618
597 if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { 619 if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
598 nfs4_lock_state(); 620 nfs4_lock_state();
599 status = nfs4_preprocess_stateid_op(current_fh, 621 status = nfs4_preprocess_stateid_op(&cstate->current_fh,
600 &setattr->sa_stateid, CHECK_FH | WR_STATE, NULL); 622 &setattr->sa_stateid, CHECK_FH | WR_STATE, NULL);
601 nfs4_unlock_state(); 623 nfs4_unlock_state();
602 if (status) { 624 if (status) {
@@ -606,16 +628,18 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_se
606 } 628 }
607 status = nfs_ok; 629 status = nfs_ok;
608 if (setattr->sa_acl != NULL) 630 if (setattr->sa_acl != NULL)
609 status = nfsd4_set_nfs4_acl(rqstp, current_fh, setattr->sa_acl); 631 status = nfsd4_set_nfs4_acl(rqstp, &cstate->current_fh,
632 setattr->sa_acl);
610 if (status) 633 if (status)
611 return status; 634 return status;
612 status = nfsd_setattr(rqstp, current_fh, &setattr->sa_iattr, 635 status = nfsd_setattr(rqstp, &cstate->current_fh, &setattr->sa_iattr,
613 0, (time_t)0); 636 0, (time_t)0);
614 return status; 637 return status;
615} 638}
616 639
617static inline __be32 640static __be32
618nfsd4_write(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_write *write) 641nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
642 struct nfsd4_write *write)
619{ 643{
620 stateid_t *stateid = &write->wr_stateid; 644 stateid_t *stateid = &write->wr_stateid;
621 struct file *filp = NULL; 645 struct file *filp = NULL;
@@ -628,7 +652,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_writ
628 return nfserr_inval; 652 return nfserr_inval;
629 653
630 nfs4_lock_state(); 654 nfs4_lock_state();
631 status = nfs4_preprocess_stateid_op(current_fh, stateid, 655 status = nfs4_preprocess_stateid_op(&cstate->current_fh, stateid,
632 CHECK_FH | WR_STATE, &filp); 656 CHECK_FH | WR_STATE, &filp);
633 if (filp) 657 if (filp)
634 get_file(filp); 658 get_file(filp);
@@ -645,9 +669,9 @@ nfsd4_write(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_writ
645 *p++ = nfssvc_boot.tv_sec; 669 *p++ = nfssvc_boot.tv_sec;
646 *p++ = nfssvc_boot.tv_usec; 670 *p++ = nfssvc_boot.tv_usec;
647 671
648 status = nfsd_write(rqstp, current_fh, filp, write->wr_offset, 672 status = nfsd_write(rqstp, &cstate->current_fh, filp,
649 rqstp->rq_vec, write->wr_vlen, write->wr_buflen, 673 write->wr_offset, rqstp->rq_vec, write->wr_vlen,
650 &write->wr_how_written); 674 write->wr_buflen, &write->wr_how_written);
651 if (filp) 675 if (filp)
652 fput(filp); 676 fput(filp);
653 677
@@ -662,13 +686,14 @@ nfsd4_write(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_writ
662 * to NFS_OK after the call; NVERIFY by mapping NFSERR_NOT_SAME to NFS_OK. 686 * to NFS_OK after the call; NVERIFY by mapping NFSERR_NOT_SAME to NFS_OK.
663 */ 687 */
664static __be32 688static __be32
665nfsd4_verify(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_verify *verify) 689_nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
690 struct nfsd4_verify *verify)
666{ 691{
667 __be32 *buf, *p; 692 __be32 *buf, *p;
668 int count; 693 int count;
669 __be32 status; 694 __be32 status;
670 695
671 status = fh_verify(rqstp, current_fh, 0, MAY_NOP); 696 status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP);
672 if (status) 697 if (status)
673 return status; 698 return status;
674 699
@@ -689,8 +714,9 @@ nfsd4_verify(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_ver
689 if (!buf) 714 if (!buf)
690 return nfserr_resource; 715 return nfserr_resource;
691 716
692 status = nfsd4_encode_fattr(current_fh, current_fh->fh_export, 717 status = nfsd4_encode_fattr(&cstate->current_fh,
693 current_fh->fh_dentry, buf, 718 cstate->current_fh.fh_export,
719 cstate->current_fh.fh_dentry, buf,
694 &count, verify->ve_bmval, 720 &count, verify->ve_bmval,
695 rqstp); 721 rqstp);
696 722
@@ -712,6 +738,26 @@ out_kfree:
712 return status; 738 return status;
713} 739}
714 740
741static __be32
742nfsd4_nverify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
743 struct nfsd4_verify *verify)
744{
745 __be32 status;
746
747 status = _nfsd4_verify(rqstp, cstate, verify);
748 return status == nfserr_not_same ? nfs_ok : status;
749}
750
751static __be32
752nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
753 struct nfsd4_verify *verify)
754{
755 __be32 status;
756
757 status = _nfsd4_verify(rqstp, cstate, verify);
758 return status == nfserr_same ? nfs_ok : status;
759}
760
715/* 761/*
716 * NULL call. 762 * NULL call.
717 */ 763 */
@@ -727,6 +773,42 @@ static inline void nfsd4_increment_op_stats(u32 opnum)
727 nfsdstats.nfs4_opcount[opnum]++; 773 nfsdstats.nfs4_opcount[opnum]++;
728} 774}
729 775
776static void cstate_free(struct nfsd4_compound_state *cstate)
777{
778 if (cstate == NULL)
779 return;
780 fh_put(&cstate->current_fh);
781 fh_put(&cstate->save_fh);
782 BUG_ON(cstate->replay_owner);
783 kfree(cstate);
784}
785
786static struct nfsd4_compound_state *cstate_alloc(void)
787{
788 struct nfsd4_compound_state *cstate;
789
790 cstate = kmalloc(sizeof(struct nfsd4_compound_state), GFP_KERNEL);
791 if (cstate == NULL)
792 return NULL;
793 fh_init(&cstate->current_fh, NFS4_FHSIZE);
794 fh_init(&cstate->save_fh, NFS4_FHSIZE);
795 cstate->replay_owner = NULL;
796 return cstate;
797}
798
799typedef __be32(*nfsd4op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
800 void *);
801
802struct nfsd4_operation {
803 nfsd4op_func op_func;
804 u32 op_flags;
805/* Most ops require a valid current filehandle; a few don't: */
806#define ALLOWED_WITHOUT_FH 1
807/* GETATTR and ops not listed as returning NFS4ERR_MOVED: */
808#define ALLOWED_ON_ABSENT_FS 2
809};
810
811static struct nfsd4_operation nfsd4_ops[];
730 812
731/* 813/*
732 * COMPOUND call. 814 * COMPOUND call.
@@ -737,21 +819,15 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
737 struct nfsd4_compoundres *resp) 819 struct nfsd4_compoundres *resp)
738{ 820{
739 struct nfsd4_op *op; 821 struct nfsd4_op *op;
740 struct svc_fh *current_fh = NULL; 822 struct nfsd4_operation *opdesc;
741 struct svc_fh *save_fh = NULL; 823 struct nfsd4_compound_state *cstate = NULL;
742 struct nfs4_stateowner *replay_owner = NULL; 824 int slack_bytes;
743 int slack_space; /* in words, not bytes! */
744 __be32 status; 825 __be32 status;
745 826
746 status = nfserr_resource; 827 status = nfserr_resource;
747 current_fh = kmalloc(sizeof(*current_fh), GFP_KERNEL); 828 cstate = cstate_alloc();
748 if (current_fh == NULL) 829 if (cstate == NULL)
749 goto out;
750 fh_init(current_fh, NFS4_FHSIZE);
751 save_fh = kmalloc(sizeof(*save_fh), GFP_KERNEL);
752 if (save_fh == NULL)
753 goto out; 830 goto out;
754 fh_init(save_fh, NFS4_FHSIZE);
755 831
756 resp->xbuf = &rqstp->rq_res; 832 resp->xbuf = &rqstp->rq_res;
757 resp->p = rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len; 833 resp->p = rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len;
@@ -790,164 +866,44 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
790 * failed response to the next operation. If we don't 866 * failed response to the next operation. If we don't
791 * have enough room, fail with ERR_RESOURCE. 867 * have enough room, fail with ERR_RESOURCE.
792 */ 868 */
793/* FIXME - is slack_space *really* words, or bytes??? - neilb */ 869 slack_bytes = (char *)resp->end - (char *)resp->p;
794 slack_space = (char *)resp->end - (char *)resp->p; 870 if (slack_bytes < COMPOUND_SLACK_SPACE
795 if (slack_space < COMPOUND_SLACK_SPACE + COMPOUND_ERR_SLACK_SPACE) { 871 + COMPOUND_ERR_SLACK_SPACE) {
796 BUG_ON(slack_space < COMPOUND_ERR_SLACK_SPACE); 872 BUG_ON(slack_bytes < COMPOUND_ERR_SLACK_SPACE);
797 op->status = nfserr_resource; 873 op->status = nfserr_resource;
798 goto encode_op; 874 goto encode_op;
799 } 875 }
800 876
801 /* All operations except RENEW, SETCLIENTID, RESTOREFH 877 opdesc = &nfsd4_ops[op->opnum];
802 * SETCLIENTID_CONFIRM, PUTFH and PUTROOTFH 878
803 * require a valid current filehandle 879 if (!cstate->current_fh.fh_dentry) {
804 */ 880 if (!(opdesc->op_flags & ALLOWED_WITHOUT_FH)) {
805 if (!current_fh->fh_dentry) {
806 if (!((op->opnum == OP_PUTFH) ||
807 (op->opnum == OP_PUTROOTFH) ||
808 (op->opnum == OP_SETCLIENTID) ||
809 (op->opnum == OP_SETCLIENTID_CONFIRM) ||
810 (op->opnum == OP_RENEW) ||
811 (op->opnum == OP_RESTOREFH) ||
812 (op->opnum == OP_RELEASE_LOCKOWNER))) {
813 op->status = nfserr_nofilehandle; 881 op->status = nfserr_nofilehandle;
814 goto encode_op; 882 goto encode_op;
815 } 883 }
816 } 884 } else if (cstate->current_fh.fh_export->ex_fslocs.migrated &&
817 /* Check must be done at start of each operation, except 885 !(opdesc->op_flags & ALLOWED_ON_ABSENT_FS)) {
818 * for GETATTR and ops not listed as returning NFS4ERR_MOVED
819 */
820 else if (current_fh->fh_export->ex_fslocs.migrated &&
821 !((op->opnum == OP_GETATTR) ||
822 (op->opnum == OP_PUTROOTFH) ||
823 (op->opnum == OP_PUTPUBFH) ||
824 (op->opnum == OP_RENEW) ||
825 (op->opnum == OP_SETCLIENTID) ||
826 (op->opnum == OP_RELEASE_LOCKOWNER))) {
827 op->status = nfserr_moved; 886 op->status = nfserr_moved;
828 goto encode_op; 887 goto encode_op;
829 } 888 }
830 switch (op->opnum) { 889
831 case OP_ACCESS: 890 if (opdesc->op_func)
832 op->status = nfsd4_access(rqstp, current_fh, &op->u.access); 891 op->status = opdesc->op_func(rqstp, cstate, &op->u);
833 break; 892 else
834 case OP_CLOSE:
835 op->status = nfsd4_close(rqstp, current_fh, &op->u.close, &replay_owner);
836 break;
837 case OP_COMMIT:
838 op->status = nfsd4_commit(rqstp, current_fh, &op->u.commit);
839 break;
840 case OP_CREATE:
841 op->status = nfsd4_create(rqstp, current_fh, &op->u.create);
842 break;
843 case OP_DELEGRETURN:
844 op->status = nfsd4_delegreturn(rqstp, current_fh, &op->u.delegreturn);
845 break;
846 case OP_GETATTR:
847 op->status = nfsd4_getattr(rqstp, current_fh, &op->u.getattr);
848 break;
849 case OP_GETFH:
850 op->status = nfsd4_getfh(current_fh, &op->u.getfh);
851 break;
852 case OP_LINK:
853 op->status = nfsd4_link(rqstp, current_fh, save_fh, &op->u.link);
854 break;
855 case OP_LOCK:
856 op->status = nfsd4_lock(rqstp, current_fh, &op->u.lock, &replay_owner);
857 break;
858 case OP_LOCKT:
859 op->status = nfsd4_lockt(rqstp, current_fh, &op->u.lockt);
860 break;
861 case OP_LOCKU:
862 op->status = nfsd4_locku(rqstp, current_fh, &op->u.locku, &replay_owner);
863 break;
864 case OP_LOOKUP:
865 op->status = nfsd4_lookup(rqstp, current_fh, &op->u.lookup);
866 break;
867 case OP_LOOKUPP:
868 op->status = nfsd4_lookupp(rqstp, current_fh);
869 break;
870 case OP_NVERIFY:
871 op->status = nfsd4_verify(rqstp, current_fh, &op->u.nverify);
872 if (op->status == nfserr_not_same)
873 op->status = nfs_ok;
874 break;
875 case OP_OPEN:
876 op->status = nfsd4_open(rqstp, current_fh, &op->u.open, &replay_owner);
877 break;
878 case OP_OPEN_CONFIRM:
879 op->status = nfsd4_open_confirm(rqstp, current_fh, &op->u.open_confirm, &replay_owner);
880 break;
881 case OP_OPEN_DOWNGRADE:
882 op->status = nfsd4_open_downgrade(rqstp, current_fh, &op->u.open_downgrade, &replay_owner);
883 break;
884 case OP_PUTFH:
885 op->status = nfsd4_putfh(rqstp, current_fh, &op->u.putfh);
886 break;
887 case OP_PUTROOTFH:
888 op->status = nfsd4_putrootfh(rqstp, current_fh);
889 break;
890 case OP_READ:
891 op->status = nfsd4_read(rqstp, current_fh, &op->u.read);
892 break;
893 case OP_READDIR:
894 op->status = nfsd4_readdir(rqstp, current_fh, &op->u.readdir);
895 break;
896 case OP_READLINK:
897 op->status = nfsd4_readlink(rqstp, current_fh, &op->u.readlink);
898 break;
899 case OP_REMOVE:
900 op->status = nfsd4_remove(rqstp, current_fh, &op->u.remove);
901 break;
902 case OP_RENAME:
903 op->status = nfsd4_rename(rqstp, current_fh, save_fh, &op->u.rename);
904 break;
905 case OP_RENEW:
906 op->status = nfsd4_renew(&op->u.renew);
907 break;
908 case OP_RESTOREFH:
909 op->status = nfsd4_restorefh(current_fh, save_fh);
910 break;
911 case OP_SAVEFH:
912 op->status = nfsd4_savefh(current_fh, save_fh);
913 break;
914 case OP_SETATTR:
915 op->status = nfsd4_setattr(rqstp, current_fh, &op->u.setattr);
916 break;
917 case OP_SETCLIENTID:
918 op->status = nfsd4_setclientid(rqstp, &op->u.setclientid);
919 break;
920 case OP_SETCLIENTID_CONFIRM:
921 op->status = nfsd4_setclientid_confirm(rqstp, &op->u.setclientid_confirm);
922 break;
923 case OP_VERIFY:
924 op->status = nfsd4_verify(rqstp, current_fh, &op->u.verify);
925 if (op->status == nfserr_same)
926 op->status = nfs_ok;
927 break;
928 case OP_WRITE:
929 op->status = nfsd4_write(rqstp, current_fh, &op->u.write);
930 break;
931 case OP_RELEASE_LOCKOWNER:
932 op->status = nfsd4_release_lockowner(rqstp, &op->u.release_lockowner);
933 break;
934 default:
935 BUG_ON(op->status == nfs_ok); 893 BUG_ON(op->status == nfs_ok);
936 break;
937 }
938 894
939encode_op: 895encode_op:
940 if (op->status == nfserr_replay_me) { 896 if (op->status == nfserr_replay_me) {
941 op->replay = &replay_owner->so_replay; 897 op->replay = &cstate->replay_owner->so_replay;
942 nfsd4_encode_replay(resp, op); 898 nfsd4_encode_replay(resp, op);
943 status = op->status = op->replay->rp_status; 899 status = op->status = op->replay->rp_status;
944 } else { 900 } else {
945 nfsd4_encode_operation(resp, op); 901 nfsd4_encode_operation(resp, op);
946 status = op->status; 902 status = op->status;
947 } 903 }
948 if (replay_owner && (replay_owner != (void *)(-1))) { 904 if (cstate->replay_owner) {
949 nfs4_put_stateowner(replay_owner); 905 nfs4_put_stateowner(cstate->replay_owner);
950 replay_owner = NULL; 906 cstate->replay_owner = NULL;
951 } 907 }
952 /* XXX Ugh, we need to get rid of this kind of special case: */ 908 /* XXX Ugh, we need to get rid of this kind of special case: */
953 if (op->opnum == OP_READ && op->u.read.rd_filp) 909 if (op->opnum == OP_READ && op->u.read.rd_filp)
@@ -958,15 +914,124 @@ encode_op:
958 914
959out: 915out:
960 nfsd4_release_compoundargs(args); 916 nfsd4_release_compoundargs(args);
961 if (current_fh) 917 cstate_free(cstate);
962 fh_put(current_fh);
963 kfree(current_fh);
964 if (save_fh)
965 fh_put(save_fh);
966 kfree(save_fh);
967 return status; 918 return status;
968} 919}
969 920
921static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = {
922 [OP_ACCESS] = {
923 .op_func = (nfsd4op_func)nfsd4_access,
924 },
925 [OP_CLOSE] = {
926 .op_func = (nfsd4op_func)nfsd4_close,
927 },
928 [OP_COMMIT] = {
929 .op_func = (nfsd4op_func)nfsd4_commit,
930 },
931 [OP_CREATE] = {
932 .op_func = (nfsd4op_func)nfsd4_create,
933 },
934 [OP_DELEGRETURN] = {
935 .op_func = (nfsd4op_func)nfsd4_delegreturn,
936 },
937 [OP_GETATTR] = {
938 .op_func = (nfsd4op_func)nfsd4_getattr,
939 .op_flags = ALLOWED_ON_ABSENT_FS,
940 },
941 [OP_GETFH] = {
942 .op_func = (nfsd4op_func)nfsd4_getfh,
943 },
944 [OP_LINK] = {
945 .op_func = (nfsd4op_func)nfsd4_link,
946 },
947 [OP_LOCK] = {
948 .op_func = (nfsd4op_func)nfsd4_lock,
949 },
950 [OP_LOCKT] = {
951 .op_func = (nfsd4op_func)nfsd4_lockt,
952 },
953 [OP_LOCKU] = {
954 .op_func = (nfsd4op_func)nfsd4_locku,
955 },
956 [OP_LOOKUP] = {
957 .op_func = (nfsd4op_func)nfsd4_lookup,
958 },
959 [OP_LOOKUPP] = {
960 .op_func = (nfsd4op_func)nfsd4_lookupp,
961 },
962 [OP_NVERIFY] = {
963 .op_func = (nfsd4op_func)nfsd4_nverify,
964 },
965 [OP_OPEN] = {
966 .op_func = (nfsd4op_func)nfsd4_open,
967 },
968 [OP_OPEN_CONFIRM] = {
969 .op_func = (nfsd4op_func)nfsd4_open_confirm,
970 },
971 [OP_OPEN_DOWNGRADE] = {
972 .op_func = (nfsd4op_func)nfsd4_open_downgrade,
973 },
974 [OP_PUTFH] = {
975 .op_func = (nfsd4op_func)nfsd4_putfh,
976 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
977 },
978 [OP_PUTPUBFH] = {
979 /* unsupported; just for future reference: */
980 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
981 },
982 [OP_PUTROOTFH] = {
983 .op_func = (nfsd4op_func)nfsd4_putrootfh,
984 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
985 },
986 [OP_READ] = {
987 .op_func = (nfsd4op_func)nfsd4_read,
988 },
989 [OP_READDIR] = {
990 .op_func = (nfsd4op_func)nfsd4_readdir,
991 },
992 [OP_READLINK] = {
993 .op_func = (nfsd4op_func)nfsd4_readlink,
994 },
995 [OP_REMOVE] = {
996 .op_func = (nfsd4op_func)nfsd4_remove,
997 },
998 [OP_RENAME] = {
999 .op_func = (nfsd4op_func)nfsd4_rename,
1000 },
1001 [OP_RENEW] = {
1002 .op_func = (nfsd4op_func)nfsd4_renew,
1003 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
1004 },
1005 [OP_RESTOREFH] = {
1006 .op_func = (nfsd4op_func)nfsd4_restorefh,
1007 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
1008 },
1009 [OP_SAVEFH] = {
1010 .op_func = (nfsd4op_func)nfsd4_savefh,
1011 },
1012 [OP_SETATTR] = {
1013 .op_func = (nfsd4op_func)nfsd4_setattr,
1014 },
1015 [OP_SETCLIENTID] = {
1016 .op_func = (nfsd4op_func)nfsd4_setclientid,
1017 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
1018 },
1019 [OP_SETCLIENTID_CONFIRM] = {
1020 .op_func = (nfsd4op_func)nfsd4_setclientid_confirm,
1021 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
1022 },
1023 [OP_VERIFY] = {
1024 .op_func = (nfsd4op_func)nfsd4_verify,
1025 },
1026 [OP_WRITE] = {
1027 .op_func = (nfsd4op_func)nfsd4_write,
1028 },
1029 [OP_RELEASE_LOCKOWNER] = {
1030 .op_func = (nfsd4op_func)nfsd4_release_lockowner,
1031 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
1032 },
1033};
1034
970#define nfs4svc_decode_voidargs NULL 1035#define nfs4svc_decode_voidargs NULL
971#define nfs4svc_release_void NULL 1036#define nfs4svc_release_void NULL
972#define nfsd4_voidres nfsd4_voidargs 1037#define nfsd4_voidres nfsd4_voidargs
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index b7179bd45a1e..9de89df961f4 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -711,7 +711,8 @@ out_err:
711 * 711 *
712 */ 712 */
713__be32 713__be32
714nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_setclientid *setclid) 714nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
715 struct nfsd4_setclientid *setclid)
715{ 716{
716 __be32 ip_addr = rqstp->rq_addr.sin_addr.s_addr; 717 __be32 ip_addr = rqstp->rq_addr.sin_addr.s_addr;
717 struct xdr_netobj clname = { 718 struct xdr_netobj clname = {
@@ -876,7 +877,9 @@ out:
876 * NOTE: callback information will be processed here in a future patch 877 * NOTE: callback information will be processed here in a future patch
877 */ 878 */
878__be32 879__be32
879nfsd4_setclientid_confirm(struct svc_rqst *rqstp, struct nfsd4_setclientid_confirm *setclientid_confirm) 880nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
881 struct nfsd4_compound_state *cstate,
882 struct nfsd4_setclientid_confirm *setclientid_confirm)
880{ 883{
881 __be32 ip_addr = rqstp->rq_addr.sin_addr.s_addr; 884 __be32 ip_addr = rqstp->rq_addr.sin_addr.s_addr;
882 struct nfs4_client *conf, *unconf; 885 struct nfs4_client *conf, *unconf;
@@ -1833,7 +1836,8 @@ static void laundromat_main(struct work_struct *);
1833static DECLARE_DELAYED_WORK(laundromat_work, laundromat_main); 1836static DECLARE_DELAYED_WORK(laundromat_work, laundromat_main);
1834 1837
1835__be32 1838__be32
1836nfsd4_renew(clientid_t *clid) 1839nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
1840 clientid_t *clid)
1837{ 1841{
1838 struct nfs4_client *clp; 1842 struct nfs4_client *clp;
1839 __be32 status; 1843 __be32 status;
@@ -2241,24 +2245,25 @@ check_replay:
2241} 2245}
2242 2246
2243__be32 2247__be32
2244nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_confirm *oc, struct nfs4_stateowner **replay_owner) 2248nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2249 struct nfsd4_open_confirm *oc)
2245{ 2250{
2246 __be32 status; 2251 __be32 status;
2247 struct nfs4_stateowner *sop; 2252 struct nfs4_stateowner *sop;
2248 struct nfs4_stateid *stp; 2253 struct nfs4_stateid *stp;
2249 2254
2250 dprintk("NFSD: nfsd4_open_confirm on file %.*s\n", 2255 dprintk("NFSD: nfsd4_open_confirm on file %.*s\n",
2251 (int)current_fh->fh_dentry->d_name.len, 2256 (int)cstate->current_fh.fh_dentry->d_name.len,
2252 current_fh->fh_dentry->d_name.name); 2257 cstate->current_fh.fh_dentry->d_name.name);
2253 2258
2254 status = fh_verify(rqstp, current_fh, S_IFREG, 0); 2259 status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0);
2255 if (status) 2260 if (status)
2256 return status; 2261 return status;
2257 2262
2258 nfs4_lock_state(); 2263 nfs4_lock_state();
2259 2264
2260 if ((status = nfs4_preprocess_seqid_op(current_fh, oc->oc_seqid, 2265 if ((status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2261 &oc->oc_req_stateid, 2266 oc->oc_seqid, &oc->oc_req_stateid,
2262 CHECK_FH | CONFIRM | OPEN_STATE, 2267 CHECK_FH | CONFIRM | OPEN_STATE,
2263 &oc->oc_stateowner, &stp, NULL))) 2268 &oc->oc_stateowner, &stp, NULL)))
2264 goto out; 2269 goto out;
@@ -2278,7 +2283,7 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs
2278out: 2283out:
2279 if (oc->oc_stateowner) { 2284 if (oc->oc_stateowner) {
2280 nfs4_get_stateowner(oc->oc_stateowner); 2285 nfs4_get_stateowner(oc->oc_stateowner);
2281 *replay_owner = oc->oc_stateowner; 2286 cstate->replay_owner = oc->oc_stateowner;
2282 } 2287 }
2283 nfs4_unlock_state(); 2288 nfs4_unlock_state();
2284 return status; 2289 return status;
@@ -2310,22 +2315,25 @@ reset_union_bmap_deny(unsigned long deny, unsigned long *bmap)
2310} 2315}
2311 2316
2312__be32 2317__be32
2313nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_downgrade *od, struct nfs4_stateowner **replay_owner) 2318nfsd4_open_downgrade(struct svc_rqst *rqstp,
2319 struct nfsd4_compound_state *cstate,
2320 struct nfsd4_open_downgrade *od)
2314{ 2321{
2315 __be32 status; 2322 __be32 status;
2316 struct nfs4_stateid *stp; 2323 struct nfs4_stateid *stp;
2317 unsigned int share_access; 2324 unsigned int share_access;
2318 2325
2319 dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n", 2326 dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n",
2320 (int)current_fh->fh_dentry->d_name.len, 2327 (int)cstate->current_fh.fh_dentry->d_name.len,
2321 current_fh->fh_dentry->d_name.name); 2328 cstate->current_fh.fh_dentry->d_name.name);
2322 2329
2323 if (!access_valid(od->od_share_access) 2330 if (!access_valid(od->od_share_access)
2324 || !deny_valid(od->od_share_deny)) 2331 || !deny_valid(od->od_share_deny))
2325 return nfserr_inval; 2332 return nfserr_inval;
2326 2333
2327 nfs4_lock_state(); 2334 nfs4_lock_state();
2328 if ((status = nfs4_preprocess_seqid_op(current_fh, od->od_seqid, 2335 if ((status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2336 od->od_seqid,
2329 &od->od_stateid, 2337 &od->od_stateid,
2330 CHECK_FH | OPEN_STATE, 2338 CHECK_FH | OPEN_STATE,
2331 &od->od_stateowner, &stp, NULL))) 2339 &od->od_stateowner, &stp, NULL)))
@@ -2355,7 +2363,7 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct n
2355out: 2363out:
2356 if (od->od_stateowner) { 2364 if (od->od_stateowner) {
2357 nfs4_get_stateowner(od->od_stateowner); 2365 nfs4_get_stateowner(od->od_stateowner);
2358 *replay_owner = od->od_stateowner; 2366 cstate->replay_owner = od->od_stateowner;
2359 } 2367 }
2360 nfs4_unlock_state(); 2368 nfs4_unlock_state();
2361 return status; 2369 return status;
@@ -2365,18 +2373,20 @@ out:
2365 * nfs4_unlock_state() called after encode 2373 * nfs4_unlock_state() called after encode
2366 */ 2374 */
2367__be32 2375__be32
2368nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_close *close, struct nfs4_stateowner **replay_owner) 2376nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2377 struct nfsd4_close *close)
2369{ 2378{
2370 __be32 status; 2379 __be32 status;
2371 struct nfs4_stateid *stp; 2380 struct nfs4_stateid *stp;
2372 2381
2373 dprintk("NFSD: nfsd4_close on file %.*s\n", 2382 dprintk("NFSD: nfsd4_close on file %.*s\n",
2374 (int)current_fh->fh_dentry->d_name.len, 2383 (int)cstate->current_fh.fh_dentry->d_name.len,
2375 current_fh->fh_dentry->d_name.name); 2384 cstate->current_fh.fh_dentry->d_name.name);
2376 2385
2377 nfs4_lock_state(); 2386 nfs4_lock_state();
2378 /* check close_lru for replay */ 2387 /* check close_lru for replay */
2379 if ((status = nfs4_preprocess_seqid_op(current_fh, close->cl_seqid, 2388 if ((status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2389 close->cl_seqid,
2380 &close->cl_stateid, 2390 &close->cl_stateid,
2381 CHECK_FH | OPEN_STATE | CLOSE_STATE, 2391 CHECK_FH | OPEN_STATE | CLOSE_STATE,
2382 &close->cl_stateowner, &stp, NULL))) 2392 &close->cl_stateowner, &stp, NULL)))
@@ -2397,22 +2407,24 @@ nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_clos
2397out: 2407out:
2398 if (close->cl_stateowner) { 2408 if (close->cl_stateowner) {
2399 nfs4_get_stateowner(close->cl_stateowner); 2409 nfs4_get_stateowner(close->cl_stateowner);
2400 *replay_owner = close->cl_stateowner; 2410 cstate->replay_owner = close->cl_stateowner;
2401 } 2411 }
2402 nfs4_unlock_state(); 2412 nfs4_unlock_state();
2403 return status; 2413 return status;
2404} 2414}
2405 2415
2406__be32 2416__be32
2407nfsd4_delegreturn(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_delegreturn *dr) 2417nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2418 struct nfsd4_delegreturn *dr)
2408{ 2419{
2409 __be32 status; 2420 __be32 status;
2410 2421
2411 if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0))) 2422 if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0)))
2412 goto out; 2423 goto out;
2413 2424
2414 nfs4_lock_state(); 2425 nfs4_lock_state();
2415 status = nfs4_preprocess_stateid_op(current_fh, &dr->dr_stateid, DELEG_RET, NULL); 2426 status = nfs4_preprocess_stateid_op(&cstate->current_fh,
2427 &dr->dr_stateid, DELEG_RET, NULL);
2416 nfs4_unlock_state(); 2428 nfs4_unlock_state();
2417out: 2429out:
2418 return status; 2430 return status;
@@ -2635,7 +2647,8 @@ check_lock_length(u64 offset, u64 length)
2635 * LOCK operation 2647 * LOCK operation
2636 */ 2648 */
2637__be32 2649__be32
2638nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock *lock, struct nfs4_stateowner **replay_owner) 2650nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2651 struct nfsd4_lock *lock)
2639{ 2652{
2640 struct nfs4_stateowner *open_sop = NULL; 2653 struct nfs4_stateowner *open_sop = NULL;
2641 struct nfs4_stateowner *lock_sop = NULL; 2654 struct nfs4_stateowner *lock_sop = NULL;
@@ -2654,7 +2667,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2654 if (check_lock_length(lock->lk_offset, lock->lk_length)) 2667 if (check_lock_length(lock->lk_offset, lock->lk_length))
2655 return nfserr_inval; 2668 return nfserr_inval;
2656 2669
2657 if ((status = fh_verify(rqstp, current_fh, S_IFREG, MAY_LOCK))) { 2670 if ((status = fh_verify(rqstp, &cstate->current_fh,
2671 S_IFREG, MAY_LOCK))) {
2658 dprintk("NFSD: nfsd4_lock: permission denied!\n"); 2672 dprintk("NFSD: nfsd4_lock: permission denied!\n");
2659 return status; 2673 return status;
2660 } 2674 }
@@ -2675,7 +2689,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2675 goto out; 2689 goto out;
2676 2690
2677 /* validate and update open stateid and open seqid */ 2691 /* validate and update open stateid and open seqid */
2678 status = nfs4_preprocess_seqid_op(current_fh, 2692 status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2679 lock->lk_new_open_seqid, 2693 lock->lk_new_open_seqid,
2680 &lock->lk_new_open_stateid, 2694 &lock->lk_new_open_stateid,
2681 CHECK_FH | OPEN_STATE, 2695 CHECK_FH | OPEN_STATE,
@@ -2702,7 +2716,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2702 goto out; 2716 goto out;
2703 } else { 2717 } else {
2704 /* lock (lock owner + lock stateid) already exists */ 2718 /* lock (lock owner + lock stateid) already exists */
2705 status = nfs4_preprocess_seqid_op(current_fh, 2719 status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2706 lock->lk_old_lock_seqid, 2720 lock->lk_old_lock_seqid,
2707 &lock->lk_old_lock_stateid, 2721 &lock->lk_old_lock_stateid,
2708 CHECK_FH | LOCK_STATE, 2722 CHECK_FH | LOCK_STATE,
@@ -2759,7 +2773,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2759 conflock.fl_ops = NULL; 2773 conflock.fl_ops = NULL;
2760 conflock.fl_lmops = NULL; 2774 conflock.fl_lmops = NULL;
2761 err = posix_lock_file_conf(filp, &file_lock, &conflock); 2775 err = posix_lock_file_conf(filp, &file_lock, &conflock);
2762 dprintk("NFSD: nfsd4_lock: posix_lock_file_conf status %d\n",status);
2763 switch (-err) { 2776 switch (-err) {
2764 case 0: /* success! */ 2777 case 0: /* success! */
2765 update_stateid(&lock_stp->st_stateid); 2778 update_stateid(&lock_stp->st_stateid);
@@ -2785,7 +2798,7 @@ out:
2785 release_stateowner(lock_sop); 2798 release_stateowner(lock_sop);
2786 if (lock->lk_replay_owner) { 2799 if (lock->lk_replay_owner) {
2787 nfs4_get_stateowner(lock->lk_replay_owner); 2800 nfs4_get_stateowner(lock->lk_replay_owner);
2788 *replay_owner = lock->lk_replay_owner; 2801 cstate->replay_owner = lock->lk_replay_owner;
2789 } 2802 }
2790 nfs4_unlock_state(); 2803 nfs4_unlock_state();
2791 return status; 2804 return status;
@@ -2795,7 +2808,8 @@ out:
2795 * LOCKT operation 2808 * LOCKT operation
2796 */ 2809 */
2797__be32 2810__be32
2798nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lockt *lockt) 2811nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2812 struct nfsd4_lockt *lockt)
2799{ 2813{
2800 struct inode *inode; 2814 struct inode *inode;
2801 struct file file; 2815 struct file file;
@@ -2816,14 +2830,14 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2816 if (STALE_CLIENTID(&lockt->lt_clientid)) 2830 if (STALE_CLIENTID(&lockt->lt_clientid))
2817 goto out; 2831 goto out;
2818 2832
2819 if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0))) { 2833 if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) {
2820 dprintk("NFSD: nfsd4_lockt: fh_verify() failed!\n"); 2834 dprintk("NFSD: nfsd4_lockt: fh_verify() failed!\n");
2821 if (status == nfserr_symlink) 2835 if (status == nfserr_symlink)
2822 status = nfserr_inval; 2836 status = nfserr_inval;
2823 goto out; 2837 goto out;
2824 } 2838 }
2825 2839
2826 inode = current_fh->fh_dentry->d_inode; 2840 inode = cstate->current_fh.fh_dentry->d_inode;
2827 locks_init_lock(&file_lock); 2841 locks_init_lock(&file_lock);
2828 switch (lockt->lt_type) { 2842 switch (lockt->lt_type) {
2829 case NFS4_READ_LT: 2843 case NFS4_READ_LT:
@@ -2862,7 +2876,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2862 * only the dentry:inode set. 2876 * only the dentry:inode set.
2863 */ 2877 */
2864 memset(&file, 0, sizeof (struct file)); 2878 memset(&file, 0, sizeof (struct file));
2865 file.f_path.dentry = current_fh->fh_dentry; 2879 file.f_path.dentry = cstate->current_fh.fh_dentry;
2866 2880
2867 status = nfs_ok; 2881 status = nfs_ok;
2868 if (posix_test_lock(&file, &file_lock, &conflock)) { 2882 if (posix_test_lock(&file, &file_lock, &conflock)) {
@@ -2875,7 +2889,8 @@ out:
2875} 2889}
2876 2890
2877__be32 2891__be32
2878nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_locku *locku, struct nfs4_stateowner **replay_owner) 2892nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2893 struct nfsd4_locku *locku)
2879{ 2894{
2880 struct nfs4_stateid *stp; 2895 struct nfs4_stateid *stp;
2881 struct file *filp = NULL; 2896 struct file *filp = NULL;
@@ -2892,7 +2907,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2892 2907
2893 nfs4_lock_state(); 2908 nfs4_lock_state();
2894 2909
2895 if ((status = nfs4_preprocess_seqid_op(current_fh, 2910 if ((status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2896 locku->lu_seqid, 2911 locku->lu_seqid,
2897 &locku->lu_stateid, 2912 &locku->lu_stateid,
2898 CHECK_FH | LOCK_STATE, 2913 CHECK_FH | LOCK_STATE,
@@ -2933,7 +2948,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2933out: 2948out:
2934 if (locku->lu_stateowner) { 2949 if (locku->lu_stateowner) {
2935 nfs4_get_stateowner(locku->lu_stateowner); 2950 nfs4_get_stateowner(locku->lu_stateowner);
2936 *replay_owner = locku->lu_stateowner; 2951 cstate->replay_owner = locku->lu_stateowner;
2937 } 2952 }
2938 nfs4_unlock_state(); 2953 nfs4_unlock_state();
2939 return status; 2954 return status;
@@ -2968,7 +2983,9 @@ out:
2968} 2983}
2969 2984
2970__be32 2985__be32
2971nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner *rlockowner) 2986nfsd4_release_lockowner(struct svc_rqst *rqstp,
2987 struct nfsd4_compound_state *cstate,
2988 struct nfsd4_release_lockowner *rlockowner)
2972{ 2989{
2973 clientid_t *clid = &rlockowner->rl_clientid; 2990 clientid_t *clid = &rlockowner->rl_clientid;
2974 struct nfs4_stateowner *sop; 2991 struct nfs4_stateowner *sop;
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index f3f239db04bb..fea46368afb2 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1845,15 +1845,11 @@ nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd,
1845 1845
1846 exp_get(exp); 1846 exp_get(exp);
1847 if (d_mountpoint(dentry)) { 1847 if (d_mountpoint(dentry)) {
1848 if (nfsd_cross_mnt(cd->rd_rqstp, &dentry, &exp)) { 1848 int err;
1849 /* 1849
1850 * -EAGAIN is the only error returned from 1850 err = nfsd_cross_mnt(cd->rd_rqstp, &dentry, &exp);
1851 * nfsd_cross_mnt() and it indicates that an 1851 if (err) {
1852 * up-call has been initiated to fill in the export 1852 nfserr = nfserrno(err);
1853 * options on exp. When the answer comes back,
1854 * this call will be retried.
1855 */
1856 nfserr = nfserr_dropit;
1857 goto out_put; 1853 goto out_put;
1858 } 1854 }
1859 1855
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 727ab3bd450d..b06bf9f70efc 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -169,9 +169,11 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
169 exp = exp_find(rqstp->rq_client, 0, tfh, &rqstp->rq_chandle); 169 exp = exp_find(rqstp->rq_client, 0, tfh, &rqstp->rq_chandle);
170 } 170 }
171 171
172 error = nfserr_dropit; 172 if (IS_ERR(exp) && (PTR_ERR(exp) == -EAGAIN
173 if (IS_ERR(exp) && PTR_ERR(exp) == -EAGAIN) 173 || PTR_ERR(exp) == -ETIMEDOUT)) {
174 error = nfserrno(PTR_ERR(exp));
174 goto out; 175 goto out;
176 }
175 177
176 error = nfserr_stale; 178 error = nfserr_stale;
177 if (!exp || IS_ERR(exp)) 179 if (!exp || IS_ERR(exp))
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 4883d7586229..7a79c23aa6d4 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -99,7 +99,7 @@ static struct raparm_hbucket raparm_hash[RAPARM_HASH_SIZE];
99/* 99/*
100 * Called from nfsd_lookup and encode_dirent. Check if we have crossed 100 * Called from nfsd_lookup and encode_dirent. Check if we have crossed
101 * a mount point. 101 * a mount point.
102 * Returns -EAGAIN leaving *dpp and *expp unchanged, 102 * Returns -EAGAIN or -ETIMEDOUT leaving *dpp and *expp unchanged,
103 * or nfs_ok having possibly changed *dpp and *expp 103 * or nfs_ok having possibly changed *dpp and *expp
104 */ 104 */
105int 105int
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index edc91ca3792a..f27e5378caf2 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -1959,7 +1959,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
1959 goto bail; 1959 goto bail;
1960 } 1960 }
1961 1961
1962 *tc = kcalloc(1, sizeof(struct ocfs2_truncate_context), GFP_KERNEL); 1962 *tc = kzalloc(sizeof(struct ocfs2_truncate_context), GFP_KERNEL);
1963 if (!(*tc)) { 1963 if (!(*tc)) {
1964 status = -ENOMEM; 1964 status = -ENOMEM;
1965 mlog_errno(status); 1965 mlog_errno(status);
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 4cd9a9580456..a25ef5a50386 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1553,7 +1553,7 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
1553 struct o2hb_region *reg = NULL; 1553 struct o2hb_region *reg = NULL;
1554 struct config_item *ret = NULL; 1554 struct config_item *ret = NULL;
1555 1555
1556 reg = kcalloc(1, sizeof(struct o2hb_region), GFP_KERNEL); 1556 reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL);
1557 if (reg == NULL) 1557 if (reg == NULL)
1558 goto out; /* ENOMEM */ 1558 goto out; /* ENOMEM */
1559 1559
@@ -1679,7 +1679,7 @@ struct config_group *o2hb_alloc_hb_set(void)
1679 struct o2hb_heartbeat_group *hs = NULL; 1679 struct o2hb_heartbeat_group *hs = NULL;
1680 struct config_group *ret = NULL; 1680 struct config_group *ret = NULL;
1681 1681
1682 hs = kcalloc(1, sizeof(struct o2hb_heartbeat_group), GFP_KERNEL); 1682 hs = kzalloc(sizeof(struct o2hb_heartbeat_group), GFP_KERNEL);
1683 if (hs == NULL) 1683 if (hs == NULL)
1684 goto out; 1684 goto out;
1685 1685
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index 357f1d551771..b17333a0606b 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -714,7 +714,7 @@ static struct config_item *o2nm_node_group_make_item(struct config_group *group,
714 if (strlen(name) > O2NM_MAX_NAME_LEN) 714 if (strlen(name) > O2NM_MAX_NAME_LEN)
715 goto out; /* ENAMETOOLONG */ 715 goto out; /* ENAMETOOLONG */
716 716
717 node = kcalloc(1, sizeof(struct o2nm_node), GFP_KERNEL); 717 node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL);
718 if (node == NULL) 718 if (node == NULL)
719 goto out; /* ENOMEM */ 719 goto out; /* ENOMEM */
720 720
@@ -825,8 +825,8 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g
825 if (o2nm_single_cluster) 825 if (o2nm_single_cluster)
826 goto out; /* ENOSPC */ 826 goto out; /* ENOSPC */
827 827
828 cluster = kcalloc(1, sizeof(struct o2nm_cluster), GFP_KERNEL); 828 cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL);
829 ns = kcalloc(1, sizeof(struct o2nm_node_group), GFP_KERNEL); 829 ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL);
830 defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); 830 defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL);
831 o2hb_group = o2hb_alloc_hb_set(); 831 o2hb_group = o2hb_alloc_hb_set();
832 if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL) 832 if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL)
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 457753df1ae7..ae4ff4a6636b 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -324,7 +324,7 @@ static struct o2net_sock_container *sc_alloc(struct o2nm_node *node)
324 struct page *page = NULL; 324 struct page *page = NULL;
325 325
326 page = alloc_page(GFP_NOFS); 326 page = alloc_page(GFP_NOFS);
327 sc = kcalloc(1, sizeof(*sc), GFP_NOFS); 327 sc = kzalloc(sizeof(*sc), GFP_NOFS);
328 if (sc == NULL || page == NULL) 328 if (sc == NULL || page == NULL)
329 goto out; 329 goto out;
330 330
@@ -714,7 +714,7 @@ int o2net_register_handler(u32 msg_type, u32 key, u32 max_len,
714 goto out; 714 goto out;
715 } 715 }
716 716
717 nmh = kcalloc(1, sizeof(struct o2net_msg_handler), GFP_NOFS); 717 nmh = kzalloc(sizeof(struct o2net_msg_handler), GFP_NOFS);
718 if (nmh == NULL) { 718 if (nmh == NULL) {
719 ret = -ENOMEM; 719 ret = -ENOMEM;
720 goto out; 720 goto out;
@@ -1918,9 +1918,9 @@ int o2net_init(void)
1918 1918
1919 o2quo_init(); 1919 o2quo_init();
1920 1920
1921 o2net_hand = kcalloc(1, sizeof(struct o2net_handshake), GFP_KERNEL); 1921 o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL);
1922 o2net_keep_req = kcalloc(1, sizeof(struct o2net_msg), GFP_KERNEL); 1922 o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL);
1923 o2net_keep_resp = kcalloc(1, sizeof(struct o2net_msg), GFP_KERNEL); 1923 o2net_keep_resp = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL);
1924 if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) { 1924 if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) {
1925 kfree(o2net_hand); 1925 kfree(o2net_hand);
1926 kfree(o2net_keep_req); 1926 kfree(o2net_keep_req);
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index 420a375a3949..f0b25f2dd205 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -920,7 +920,7 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm)
920 920
921 mlog_entry("%p", dlm); 921 mlog_entry("%p", dlm);
922 922
923 ctxt = kcalloc(1, sizeof(*ctxt), GFP_KERNEL); 923 ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL);
924 if (!ctxt) { 924 if (!ctxt) {
925 status = -ENOMEM; 925 status = -ENOMEM;
926 mlog_errno(status); 926 mlog_errno(status);
@@ -1223,7 +1223,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
1223 int i; 1223 int i;
1224 struct dlm_ctxt *dlm = NULL; 1224 struct dlm_ctxt *dlm = NULL;
1225 1225
1226 dlm = kcalloc(1, sizeof(*dlm), GFP_KERNEL); 1226 dlm = kzalloc(sizeof(*dlm), GFP_KERNEL);
1227 if (!dlm) { 1227 if (!dlm) {
1228 mlog_errno(-ENOMEM); 1228 mlog_errno(-ENOMEM);
1229 goto leave; 1229 goto leave;
diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
index 42a1b91979b5..e5ca3db197f6 100644
--- a/fs/ocfs2/dlm/dlmlock.c
+++ b/fs/ocfs2/dlm/dlmlock.c
@@ -408,13 +408,13 @@ struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie,
408 struct dlm_lock *lock; 408 struct dlm_lock *lock;
409 int kernel_allocated = 0; 409 int kernel_allocated = 0;
410 410
411 lock = kcalloc(1, sizeof(*lock), GFP_NOFS); 411 lock = kzalloc(sizeof(*lock), GFP_NOFS);
412 if (!lock) 412 if (!lock)
413 return NULL; 413 return NULL;
414 414
415 if (!lksb) { 415 if (!lksb) {
416 /* zero memory only if kernel-allocated */ 416 /* zero memory only if kernel-allocated */
417 lksb = kcalloc(1, sizeof(*lksb), GFP_NOFS); 417 lksb = kzalloc(sizeof(*lksb), GFP_NOFS);
418 if (!lksb) { 418 if (!lksb) {
419 kfree(lock); 419 kfree(lock);
420 return NULL; 420 return NULL;
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 856012b4fa49..0ad872055cb3 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -1939,7 +1939,7 @@ int dlm_dispatch_assert_master(struct dlm_ctxt *dlm,
1939 int ignore_higher, u8 request_from, u32 flags) 1939 int ignore_higher, u8 request_from, u32 flags)
1940{ 1940{
1941 struct dlm_work_item *item; 1941 struct dlm_work_item *item;
1942 item = kcalloc(1, sizeof(*item), GFP_NOFS); 1942 item = kzalloc(sizeof(*item), GFP_NOFS);
1943 if (!item) 1943 if (!item)
1944 return -ENOMEM; 1944 return -ENOMEM;
1945 1945
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index fb3e2b0817f1..367a11e9e2ed 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -757,7 +757,7 @@ static int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node)
757 } 757 }
758 BUG_ON(num == dead_node); 758 BUG_ON(num == dead_node);
759 759
760 ndata = kcalloc(1, sizeof(*ndata), GFP_NOFS); 760 ndata = kzalloc(sizeof(*ndata), GFP_NOFS);
761 if (!ndata) { 761 if (!ndata) {
762 dlm_destroy_recovery_area(dlm, dead_node); 762 dlm_destroy_recovery_area(dlm, dead_node);
763 return -ENOMEM; 763 return -ENOMEM;
@@ -842,7 +842,7 @@ int dlm_request_all_locks_handler(struct o2net_msg *msg, u32 len, void *data)
842 } 842 }
843 BUG_ON(lr->dead_node != dlm->reco.dead_node); 843 BUG_ON(lr->dead_node != dlm->reco.dead_node);
844 844
845 item = kcalloc(1, sizeof(*item), GFP_NOFS); 845 item = kzalloc(sizeof(*item), GFP_NOFS);
846 if (!item) { 846 if (!item) {
847 dlm_put(dlm); 847 dlm_put(dlm);
848 return -ENOMEM; 848 return -ENOMEM;
@@ -1323,7 +1323,7 @@ int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data)
1323 1323
1324 ret = -ENOMEM; 1324 ret = -ENOMEM;
1325 buf = kmalloc(be16_to_cpu(msg->data_len), GFP_NOFS); 1325 buf = kmalloc(be16_to_cpu(msg->data_len), GFP_NOFS);
1326 item = kcalloc(1, sizeof(*item), GFP_NOFS); 1326 item = kzalloc(sizeof(*item), GFP_NOFS);
1327 if (!buf || !item) 1327 if (!buf || !item)
1328 goto leave; 1328 goto leave;
1329 1329
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index e9a82ad95c1e..9fd590b9bde3 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -153,6 +153,14 @@ int ocfs2_should_update_atime(struct inode *inode,
153 ((vfsmnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))) 153 ((vfsmnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)))
154 return 0; 154 return 0;
155 155
156 if (vfsmnt->mnt_flags & MNT_RELATIME) {
157 if ((timespec_compare(&inode->i_atime, &inode->i_mtime) <= 0) ||
158 (timespec_compare(&inode->i_atime, &inode->i_ctime) <= 0))
159 return 1;
160
161 return 0;
162 }
163
156 now = CURRENT_TIME; 164 now = CURRENT_TIME;
157 if ((now.tv_sec - inode->i_atime.tv_sec <= osb->s_atime_quantum)) 165 if ((now.tv_sec - inode->i_atime.tv_sec <= osb->s_atime_quantum))
158 return 0; 166 return 0;
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 698d79a74ef8..4dedd9789108 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -776,7 +776,7 @@ static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb,
776{ 776{
777 int status; 777 int status;
778 778
779 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); 779 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
780 if (!(*ac)) { 780 if (!(*ac)) {
781 status = -ENOMEM; 781 status = -ENOMEM;
782 mlog_errno(status); 782 mlog_errno(status);
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index aa6f5aadedc4..2d3ac32cb74e 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -175,7 +175,7 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb)
175 struct buffer_head *bh = NULL; 175 struct buffer_head *bh = NULL;
176 struct ocfs2_slot_info *si; 176 struct ocfs2_slot_info *si;
177 177
178 si = kcalloc(1, sizeof(struct ocfs2_slot_info), GFP_KERNEL); 178 si = kzalloc(sizeof(struct ocfs2_slot_info), GFP_KERNEL);
179 if (!si) { 179 if (!si) {
180 status = -ENOMEM; 180 status = -ENOMEM;
181 mlog_errno(status); 181 mlog_errno(status);
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 000d71cca6c5..6dbb11762759 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -488,7 +488,7 @@ int ocfs2_reserve_new_metadata(struct ocfs2_super *osb,
488 int status; 488 int status;
489 u32 slot; 489 u32 slot;
490 490
491 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); 491 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
492 if (!(*ac)) { 492 if (!(*ac)) {
493 status = -ENOMEM; 493 status = -ENOMEM;
494 mlog_errno(status); 494 mlog_errno(status);
@@ -530,7 +530,7 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
530{ 530{
531 int status; 531 int status;
532 532
533 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); 533 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
534 if (!(*ac)) { 534 if (!(*ac)) {
535 status = -ENOMEM; 535 status = -ENOMEM;
536 mlog_errno(status); 536 mlog_errno(status);
@@ -595,7 +595,7 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb,
595 595
596 mlog_entry_void(); 596 mlog_entry_void();
597 597
598 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); 598 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
599 if (!(*ac)) { 599 if (!(*ac)) {
600 status = -ENOMEM; 600 status = -ENOMEM;
601 mlog_errno(status); 601 mlog_errno(status);
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index a6d2f8cc165b..6e300a88a47e 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1231,7 +1231,7 @@ static int ocfs2_setup_osb_uuid(struct ocfs2_super *osb, const unsigned char *uu
1231 1231
1232 BUG_ON(uuid_bytes != OCFS2_VOL_UUID_LEN); 1232 BUG_ON(uuid_bytes != OCFS2_VOL_UUID_LEN);
1233 1233
1234 osb->uuid_str = kcalloc(1, OCFS2_VOL_UUID_LEN * 2 + 1, GFP_KERNEL); 1234 osb->uuid_str = kzalloc(OCFS2_VOL_UUID_LEN * 2 + 1, GFP_KERNEL);
1235 if (osb->uuid_str == NULL) 1235 if (osb->uuid_str == NULL)
1236 return -ENOMEM; 1236 return -ENOMEM;
1237 1237
@@ -1262,7 +1262,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
1262 1262
1263 mlog_entry_void(); 1263 mlog_entry_void();
1264 1264
1265 osb = kcalloc(1, sizeof(struct ocfs2_super), GFP_KERNEL); 1265 osb = kzalloc(sizeof(struct ocfs2_super), GFP_KERNEL);
1266 if (!osb) { 1266 if (!osb) {
1267 status = -ENOMEM; 1267 status = -ENOMEM;
1268 mlog_errno(status); 1268 mlog_errno(status);
@@ -1387,7 +1387,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
1387 */ 1387 */
1388 /* initialize our journal structure */ 1388 /* initialize our journal structure */
1389 1389
1390 journal = kcalloc(1, sizeof(struct ocfs2_journal), GFP_KERNEL); 1390 journal = kzalloc(sizeof(struct ocfs2_journal), GFP_KERNEL);
1391 if (!journal) { 1391 if (!journal) {
1392 mlog(ML_ERROR, "unable to alloc journal\n"); 1392 mlog(ML_ERROR, "unable to alloc journal\n");
1393 status = -ENOMEM; 1393 status = -ENOMEM;
diff --git a/fs/ocfs2/vote.c b/fs/ocfs2/vote.c
index 0315a8b61ed6..0afd8b9af70f 100644
--- a/fs/ocfs2/vote.c
+++ b/fs/ocfs2/vote.c
@@ -479,7 +479,7 @@ static struct ocfs2_net_wait_ctxt *ocfs2_new_net_wait_ctxt(unsigned int response
479{ 479{
480 struct ocfs2_net_wait_ctxt *w; 480 struct ocfs2_net_wait_ctxt *w;
481 481
482 w = kcalloc(1, sizeof(*w), GFP_NOFS); 482 w = kzalloc(sizeof(*w), GFP_NOFS);
483 if (!w) { 483 if (!w) {
484 mlog_errno(-ENOMEM); 484 mlog_errno(-ENOMEM);
485 goto bail; 485 goto bail;
@@ -642,7 +642,7 @@ static struct ocfs2_vote_msg * ocfs2_new_vote_request(struct ocfs2_super *osb,
642 642
643 BUG_ON(!ocfs2_is_valid_vote_request(type)); 643 BUG_ON(!ocfs2_is_valid_vote_request(type));
644 644
645 request = kcalloc(1, sizeof(*request), GFP_NOFS); 645 request = kzalloc(sizeof(*request), GFP_NOFS);
646 if (!request) { 646 if (!request) {
647 mlog_errno(-ENOMEM); 647 mlog_errno(-ENOMEM);
648 } else { 648 } else {
diff --git a/fs/pipe.c b/fs/pipe.c
index f8b6bdcb879a..9a06e8e48e8d 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -207,7 +207,7 @@ int generic_pipe_buf_pin(struct pipe_inode_info *info, struct pipe_buffer *buf)
207 return 0; 207 return 0;
208} 208}
209 209
210static struct pipe_buf_operations anon_pipe_buf_ops = { 210static const struct pipe_buf_operations anon_pipe_buf_ops = {
211 .can_merge = 1, 211 .can_merge = 1,
212 .map = generic_pipe_buf_map, 212 .map = generic_pipe_buf_map,
213 .unmap = generic_pipe_buf_unmap, 213 .unmap = generic_pipe_buf_unmap,
@@ -243,7 +243,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
243 if (bufs) { 243 if (bufs) {
244 int curbuf = pipe->curbuf; 244 int curbuf = pipe->curbuf;
245 struct pipe_buffer *buf = pipe->bufs + curbuf; 245 struct pipe_buffer *buf = pipe->bufs + curbuf;
246 struct pipe_buf_operations *ops = buf->ops; 246 const struct pipe_buf_operations *ops = buf->ops;
247 void *addr; 247 void *addr;
248 size_t chars = buf->len; 248 size_t chars = buf->len;
249 int error, atomic; 249 int error, atomic;
@@ -365,7 +365,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
365 int lastbuf = (pipe->curbuf + pipe->nrbufs - 1) & 365 int lastbuf = (pipe->curbuf + pipe->nrbufs - 1) &
366 (PIPE_BUFFERS-1); 366 (PIPE_BUFFERS-1);
367 struct pipe_buffer *buf = pipe->bufs + lastbuf; 367 struct pipe_buffer *buf = pipe->bufs + lastbuf;
368 struct pipe_buf_operations *ops = buf->ops; 368 const struct pipe_buf_operations *ops = buf->ops;
369 int offset = buf->offset + buf->len; 369 int offset = buf->offset + buf->len;
370 370
371 if (ops->can_merge && offset + chars <= PAGE_SIZE) { 371 if (ops->can_merge && offset + chars <= PAGE_SIZE) {
@@ -756,7 +756,7 @@ const struct file_operations rdwr_fifo_fops = {
756 .fasync = pipe_rdwr_fasync, 756 .fasync = pipe_rdwr_fasync,
757}; 757};
758 758
759static struct file_operations read_pipe_fops = { 759static const struct file_operations read_pipe_fops = {
760 .llseek = no_llseek, 760 .llseek = no_llseek,
761 .read = do_sync_read, 761 .read = do_sync_read,
762 .aio_read = pipe_read, 762 .aio_read = pipe_read,
@@ -768,7 +768,7 @@ static struct file_operations read_pipe_fops = {
768 .fasync = pipe_read_fasync, 768 .fasync = pipe_read_fasync,
769}; 769};
770 770
771static struct file_operations write_pipe_fops = { 771static const struct file_operations write_pipe_fops = {
772 .llseek = no_llseek, 772 .llseek = no_llseek,
773 .read = bad_pipe_r, 773 .read = bad_pipe_r,
774 .write = do_sync_write, 774 .write = do_sync_write,
@@ -780,7 +780,7 @@ static struct file_operations write_pipe_fops = {
780 .fasync = pipe_write_fasync, 780 .fasync = pipe_write_fasync,
781}; 781};
782 782
783static struct file_operations rdwr_pipe_fops = { 783static const struct file_operations rdwr_pipe_fops = {
784 .llseek = no_llseek, 784 .llseek = no_llseek,
785 .read = do_sync_read, 785 .read = do_sync_read,
786 .aio_read = pipe_read, 786 .aio_read = pipe_read,
diff --git a/fs/read_write.c b/fs/read_write.c
index 1d3dda4fa70c..707ac21700d3 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -450,8 +450,6 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to)
450 return seg; 450 return seg;
451} 451}
452 452
453EXPORT_UNUSED_SYMBOL(iov_shorten); /* June 2006 */
454
455ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov, 453ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov,
456 unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn) 454 unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn)
457{ 455{
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index 97ae1b92bc47..5296a29cc5eb 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -135,7 +135,7 @@ static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size)
135 int n; 135 int n;
136 136
137 *size = reiserfs_acl_size(acl->a_count); 137 *size = reiserfs_acl_size(acl->a_count);
138 ext_acl = (reiserfs_acl_header *) kmalloc(sizeof(reiserfs_acl_header) + 138 ext_acl = kmalloc(sizeof(reiserfs_acl_header) +
139 acl->a_count * 139 acl->a_count *
140 sizeof(reiserfs_acl_entry), 140 sizeof(reiserfs_acl_entry),
141 GFP_NOFS); 141 GFP_NOFS);
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index 4af4cd729a5a..84dfe3f3482e 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -482,12 +482,13 @@ smb_put_super(struct super_block *sb)
482 smb_close_socket(server); 482 smb_close_socket(server);
483 483
484 if (server->conn_pid) 484 if (server->conn_pid)
485 kill_proc(server->conn_pid, SIGTERM, 1); 485 kill_pid(server->conn_pid, SIGTERM, 1);
486 486
487 kfree(server->ops); 487 kfree(server->ops);
488 smb_unload_nls(server); 488 smb_unload_nls(server);
489 sb->s_fs_info = NULL; 489 sb->s_fs_info = NULL;
490 smb_unlock_server(server); 490 smb_unlock_server(server);
491 put_pid(server->conn_pid);
491 kfree(server); 492 kfree(server);
492} 493}
493 494
@@ -530,7 +531,7 @@ static int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
530 INIT_LIST_HEAD(&server->xmitq); 531 INIT_LIST_HEAD(&server->xmitq);
531 INIT_LIST_HEAD(&server->recvq); 532 INIT_LIST_HEAD(&server->recvq);
532 server->conn_error = 0; 533 server->conn_error = 0;
533 server->conn_pid = 0; 534 server->conn_pid = NULL;
534 server->state = CONN_INVALID; /* no connection yet */ 535 server->state = CONN_INVALID; /* no connection yet */
535 server->generation = 0; 536 server->generation = 0;
536 537
diff --git a/fs/smbfs/proc.c b/fs/smbfs/proc.c
index a5ced9e0c6c4..feac46050619 100644
--- a/fs/smbfs/proc.c
+++ b/fs/smbfs/proc.c
@@ -877,7 +877,7 @@ smb_newconn(struct smb_sb_info *server, struct smb_conn_opt *opt)
877 goto out_putf; 877 goto out_putf;
878 878
879 server->sock_file = filp; 879 server->sock_file = filp;
880 server->conn_pid = current->pid; 880 server->conn_pid = get_pid(task_pid(current));
881 server->opt = *opt; 881 server->opt = *opt;
882 server->generation += 1; 882 server->generation += 1;
883 server->state = CONN_VALID; 883 server->state = CONN_VALID;
@@ -971,8 +971,8 @@ smb_newconn(struct smb_sb_info *server, struct smb_conn_opt *opt)
971 } 971 }
972 972
973 VERBOSE("protocol=%d, max_xmit=%d, pid=%d capabilities=0x%x\n", 973 VERBOSE("protocol=%d, max_xmit=%d, pid=%d capabilities=0x%x\n",
974 server->opt.protocol, server->opt.max_xmit, server->conn_pid, 974 server->opt.protocol, server->opt.max_xmit,
975 server->opt.capabilities); 975 pid_nr(server->conn_pid), server->opt.capabilities);
976 976
977 /* FIXME: this really should be done by smbmount. */ 977 /* FIXME: this really should be done by smbmount. */
978 if (server->opt.max_xmit > SMB_MAX_PACKET_SIZE) { 978 if (server->opt.max_xmit > SMB_MAX_PACKET_SIZE) {
diff --git a/fs/smbfs/smbiod.c b/fs/smbfs/smbiod.c
index e67540441288..89eaf31f1d46 100644
--- a/fs/smbfs/smbiod.c
+++ b/fs/smbfs/smbiod.c
@@ -152,7 +152,7 @@ int smbiod_retry(struct smb_sb_info *server)
152{ 152{
153 struct list_head *head; 153 struct list_head *head;
154 struct smb_request *req; 154 struct smb_request *req;
155 pid_t pid = server->conn_pid; 155 struct pid *pid = get_pid(server->conn_pid);
156 int result = 0; 156 int result = 0;
157 157
158 VERBOSE("state: %d\n", server->state); 158 VERBOSE("state: %d\n", server->state);
@@ -222,7 +222,7 @@ int smbiod_retry(struct smb_sb_info *server)
222 /* 222 /*
223 * Note: use the "priv" flag, as a user process may need to reconnect. 223 * Note: use the "priv" flag, as a user process may need to reconnect.
224 */ 224 */
225 result = kill_proc(pid, SIGUSR1, 1); 225 result = kill_pid(pid, SIGUSR1, 1);
226 if (result) { 226 if (result) {
227 /* FIXME: this is most likely fatal, umount? */ 227 /* FIXME: this is most likely fatal, umount? */
228 printk(KERN_ERR "smb_retry: signal failed [%d]\n", result); 228 printk(KERN_ERR "smb_retry: signal failed [%d]\n", result);
@@ -233,6 +233,7 @@ int smbiod_retry(struct smb_sb_info *server)
233 /* FIXME: The retried requests should perhaps get a "time boost". */ 233 /* FIXME: The retried requests should perhaps get a "time boost". */
234 234
235out: 235out:
236 put_pid(pid);
236 return result; 237 return result;
237} 238}
238 239
diff --git a/fs/splice.c b/fs/splice.c
index bbd0aeb3f68e..2fca6ebf4cc2 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -42,7 +42,7 @@ struct splice_pipe_desc {
42 struct partial_page *partial; /* pages[] may not be contig */ 42 struct partial_page *partial; /* pages[] may not be contig */
43 int nr_pages; /* number of pages in map */ 43 int nr_pages; /* number of pages in map */
44 unsigned int flags; /* splice flags */ 44 unsigned int flags; /* splice flags */
45 struct pipe_buf_operations *ops;/* ops associated with output pipe */ 45 const struct pipe_buf_operations *ops;/* ops associated with output pipe */
46}; 46};
47 47
48/* 48/*
@@ -139,7 +139,7 @@ error:
139 return err; 139 return err;
140} 140}
141 141
142static struct pipe_buf_operations page_cache_pipe_buf_ops = { 142static const struct pipe_buf_operations page_cache_pipe_buf_ops = {
143 .can_merge = 0, 143 .can_merge = 0,
144 .map = generic_pipe_buf_map, 144 .map = generic_pipe_buf_map,
145 .unmap = generic_pipe_buf_unmap, 145 .unmap = generic_pipe_buf_unmap,
@@ -159,7 +159,7 @@ static int user_page_pipe_buf_steal(struct pipe_inode_info *pipe,
159 return generic_pipe_buf_steal(pipe, buf); 159 return generic_pipe_buf_steal(pipe, buf);
160} 160}
161 161
162static struct pipe_buf_operations user_page_pipe_buf_ops = { 162static const struct pipe_buf_operations user_page_pipe_buf_ops = {
163 .can_merge = 0, 163 .can_merge = 0,
164 .map = generic_pipe_buf_map, 164 .map = generic_pipe_buf_map,
165 .unmap = generic_pipe_buf_unmap, 165 .unmap = generic_pipe_buf_unmap,
@@ -724,7 +724,7 @@ static ssize_t __splice_from_pipe(struct pipe_inode_info *pipe,
724 for (;;) { 724 for (;;) {
725 if (pipe->nrbufs) { 725 if (pipe->nrbufs) {
726 struct pipe_buffer *buf = pipe->bufs + pipe->curbuf; 726 struct pipe_buffer *buf = pipe->bufs + pipe->curbuf;
727 struct pipe_buf_operations *ops = buf->ops; 727 const struct pipe_buf_operations *ops = buf->ops;
728 728
729 sd.len = buf->len; 729 sd.len = buf->len;
730 if (sd.len > sd.total_len) 730 if (sd.len > sd.total_len)
diff --git a/include/asm-alpha/cacheflush.h b/include/asm-alpha/cacheflush.h
index 805640b41078..b686cc7fc44e 100644
--- a/include/asm-alpha/cacheflush.h
+++ b/include/asm-alpha/cacheflush.h
@@ -6,6 +6,7 @@
6/* Caches aren't brain-dead on the Alpha. */ 6/* Caches aren't brain-dead on the Alpha. */
7#define flush_cache_all() do { } while (0) 7#define flush_cache_all() do { } while (0)
8#define flush_cache_mm(mm) do { } while (0) 8#define flush_cache_mm(mm) do { } while (0)
9#define flush_cache_dup_mm(mm) do { } while (0)
9#define flush_cache_range(vma, start, end) do { } while (0) 10#define flush_cache_range(vma, start, end) do { } while (0)
10#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 11#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
11#define flush_dcache_page(page) do { } while (0) 12#define flush_dcache_page(page) do { } while (0)
diff --git a/include/asm-arm/arch-imx/imx-regs.h b/include/asm-arm/arch-imx/imx-regs.h
index a6912b3d8671..e56a4e247d62 100644
--- a/include/asm-arm/arch-imx/imx-regs.h
+++ b/include/asm-arm/arch-imx/imx-regs.h
@@ -41,7 +41,13 @@
41 41
42/* PLL registers */ 42/* PLL registers */
43#define CSCR __REG(IMX_PLL_BASE) /* Clock Source Control Register */ 43#define CSCR __REG(IMX_PLL_BASE) /* Clock Source Control Register */
44#define CSCR_SYSTEM_SEL (1<<16) 44#define CSCR_SPLL_RESTART (1<<22)
45#define CSCR_MPLL_RESTART (1<<21)
46#define CSCR_SYSTEM_SEL (1<<16)
47#define CSCR_BCLK_DIV (0xf<<10)
48#define CSCR_MPU_PRESC (1<<15)
49#define CSCR_SPEN (1<<1)
50#define CSCR_MPEN (1<<0)
45 51
46#define MPCTL0 __REG(IMX_PLL_BASE + 0x4) /* MCU PLL Control Register 0 */ 52#define MPCTL0 __REG(IMX_PLL_BASE + 0x4) /* MCU PLL Control Register 0 */
47#define MPCTL1 __REG(IMX_PLL_BASE + 0x8) /* MCU PLL and System Clock Register 1 */ 53#define MPCTL1 __REG(IMX_PLL_BASE + 0x8) /* MCU PLL and System Clock Register 1 */
@@ -49,8 +55,6 @@
49#define SPCTL1 __REG(IMX_PLL_BASE + 0x10) /* System PLL Control Register 1 */ 55#define SPCTL1 __REG(IMX_PLL_BASE + 0x10) /* System PLL Control Register 1 */
50#define PCDR __REG(IMX_PLL_BASE + 0x20) /* Peripheral Clock Divider Register */ 56#define PCDR __REG(IMX_PLL_BASE + 0x20) /* Peripheral Clock Divider Register */
51 57
52#define CSCR_MPLL_RESTART (1<<21)
53
54/* 58/*
55 * GPIO Module and I/O Multiplexer 59 * GPIO Module and I/O Multiplexer
56 * x = 0..3 for reg_A, reg_B, reg_C, reg_D 60 * x = 0..3 for reg_A, reg_B, reg_C, reg_D
diff --git a/include/asm-arm/arch-s3c2410/regs-udc.h b/include/asm-arm/arch-s3c2410/regs-udc.h
index 487861d5b49a..3c8354619b60 100644
--- a/include/asm-arm/arch-s3c2410/regs-udc.h
+++ b/include/asm-arm/arch-s3c2410/regs-udc.h
@@ -11,8 +11,7 @@
11#ifndef __ASM_ARCH_REGS_UDC_H 11#ifndef __ASM_ARCH_REGS_UDC_H
12#define __ASM_ARCH_REGS_UDC_H 12#define __ASM_ARCH_REGS_UDC_H
13 13
14 14#define S3C2410_USBDREG(x) (x)
15#define S3C2410_USBDREG(x) ((x) + S3C24XX_VA_USBDEV)
16 15
17#define S3C2410_UDC_FUNC_ADDR_REG S3C2410_USBDREG(0x0140) 16#define S3C2410_UDC_FUNC_ADDR_REG S3C2410_USBDREG(0x0140)
18#define S3C2410_UDC_PWR_REG S3C2410_USBDREG(0x0144) 17#define S3C2410_UDC_PWR_REG S3C2410_USBDREG(0x0144)
@@ -136,8 +135,8 @@
136#define S3C2410_UDC_OCSR2_ISO (1<<6) // R/W 135#define S3C2410_UDC_OCSR2_ISO (1<<6) // R/W
137#define S3C2410_UDC_OCSR2_DMAIEN (1<<5) // R/W 136#define S3C2410_UDC_OCSR2_DMAIEN (1<<5) // R/W
138 137
139#define S3C2410_UDC_SETIX(x) \ 138#define S3C2410_UDC_SETIX(base,x) \
140 __raw_writel(S3C2410_UDC_INDEX_ ## x, S3C2410_UDC_INDEX_REG); 139 writel(S3C2410_UDC_INDEX_ ## x, base+S3C2410_UDC_INDEX_REG);
141 140
142 141
143#define S3C2410_UDC_EP0_CSR_OPKRDY (1<<0) 142#define S3C2410_UDC_EP0_CSR_OPKRDY (1<<0)
diff --git a/include/asm-arm/cacheflush.h b/include/asm-arm/cacheflush.h
index f0845646aacb..378a3a2ce8d9 100644
--- a/include/asm-arm/cacheflush.h
+++ b/include/asm-arm/cacheflush.h
@@ -319,6 +319,8 @@ extern void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
319 unsigned long len, int write); 319 unsigned long len, int write);
320#endif 320#endif
321 321
322#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
323
322/* 324/*
323 * flush_cache_user_range is used when we want to ensure that the 325 * flush_cache_user_range is used when we want to ensure that the
324 * Harvard caches are synchronised for the user space address range. 326 * Harvard caches are synchronised for the user space address range.
diff --git a/include/asm-arm/cpu-multi32.h b/include/asm-arm/cpu-multi32.h
index 4679f63688e9..715e18a4add1 100644
--- a/include/asm-arm/cpu-multi32.h
+++ b/include/asm-arm/cpu-multi32.h
@@ -50,9 +50,10 @@ extern struct processor {
50 */ 50 */
51 void (*switch_mm)(unsigned long pgd_phys, struct mm_struct *mm); 51 void (*switch_mm)(unsigned long pgd_phys, struct mm_struct *mm);
52 /* 52 /*
53 * Set a PTE 53 * Set a possibly extended PTE. Non-extended PTEs should
54 * ignore 'ext'.
54 */ 55 */
55 void (*set_pte)(pte_t *ptep, pte_t pte); 56 void (*set_pte_ext)(pte_t *ptep, pte_t pte, unsigned int ext);
56} processor; 57} processor;
57 58
58#define cpu_proc_init() processor._proc_init() 59#define cpu_proc_init() processor._proc_init()
@@ -60,5 +61,5 @@ extern struct processor {
60#define cpu_reset(addr) processor.reset(addr) 61#define cpu_reset(addr) processor.reset(addr)
61#define cpu_do_idle() processor._do_idle() 62#define cpu_do_idle() processor._do_idle()
62#define cpu_dcache_clean_area(addr,sz) processor.dcache_clean_area(addr,sz) 63#define cpu_dcache_clean_area(addr,sz) processor.dcache_clean_area(addr,sz)
63#define cpu_set_pte(ptep, pte) processor.set_pte(ptep, pte) 64#define cpu_set_pte_ext(ptep,pte,ext) processor.set_pte_ext(ptep,pte,ext)
64#define cpu_do_switch_mm(pgd,mm) processor.switch_mm(pgd,mm) 65#define cpu_do_switch_mm(pgd,mm) processor.switch_mm(pgd,mm)
diff --git a/include/asm-arm/cpu-single.h b/include/asm-arm/cpu-single.h
index 6723e67244fa..0b120ee36091 100644
--- a/include/asm-arm/cpu-single.h
+++ b/include/asm-arm/cpu-single.h
@@ -28,7 +28,7 @@
28#define cpu_do_idle __cpu_fn(CPU_NAME,_do_idle) 28#define cpu_do_idle __cpu_fn(CPU_NAME,_do_idle)
29#define cpu_dcache_clean_area __cpu_fn(CPU_NAME,_dcache_clean_area) 29#define cpu_dcache_clean_area __cpu_fn(CPU_NAME,_dcache_clean_area)
30#define cpu_do_switch_mm __cpu_fn(CPU_NAME,_switch_mm) 30#define cpu_do_switch_mm __cpu_fn(CPU_NAME,_switch_mm)
31#define cpu_set_pte __cpu_fn(CPU_NAME,_set_pte) 31#define cpu_set_pte_ext __cpu_fn(CPU_NAME,_set_pte_ext)
32 32
33#include <asm/page.h> 33#include <asm/page.h>
34 34
@@ -40,5 +40,5 @@ extern void cpu_proc_fin(void);
40extern int cpu_do_idle(void); 40extern int cpu_do_idle(void);
41extern void cpu_dcache_clean_area(void *, int); 41extern void cpu_dcache_clean_area(void *, int);
42extern void cpu_do_switch_mm(unsigned long pgd_phys, struct mm_struct *mm); 42extern void cpu_do_switch_mm(unsigned long pgd_phys, struct mm_struct *mm);
43extern void cpu_set_pte(pte_t *ptep, pte_t pte); 43extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext);
44extern void cpu_reset(unsigned long addr) __attribute__((noreturn)); 44extern void cpu_reset(unsigned long addr) __attribute__((noreturn));
diff --git a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
index 88cd5c784ef0..b8cf2d5ec304 100644
--- a/include/asm-arm/pgtable.h
+++ b/include/asm-arm/pgtable.h
@@ -21,6 +21,7 @@
21 21
22#include <asm/memory.h> 22#include <asm/memory.h>
23#include <asm/arch/vmalloc.h> 23#include <asm/arch/vmalloc.h>
24#include <asm/pgtable-hwdef.h>
24 25
25/* 26/*
26 * Just any arbitrary offset to the start of the vmalloc VM area: the 27 * Just any arbitrary offset to the start of the vmalloc VM area: the
@@ -170,7 +171,6 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
170#define L_PTE_EXEC (1 << 6) 171#define L_PTE_EXEC (1 << 6)
171#define L_PTE_DIRTY (1 << 7) 172#define L_PTE_DIRTY (1 << 7)
172#define L_PTE_SHARED (1 << 10) /* shared(v6), coherent(xsc3) */ 173#define L_PTE_SHARED (1 << 10) /* shared(v6), coherent(xsc3) */
173#define L_PTE_ASID (1 << 11) /* non-global (use ASID, v6) */
174 174
175#ifndef __ASSEMBLY__ 175#ifndef __ASSEMBLY__
176 176
@@ -228,7 +228,7 @@ extern struct page *empty_zero_page;
228#define pfn_pte(pfn,prot) (__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))) 228#define pfn_pte(pfn,prot) (__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)))
229 229
230#define pte_none(pte) (!pte_val(pte)) 230#define pte_none(pte) (!pte_val(pte))
231#define pte_clear(mm,addr,ptep) set_pte_at((mm),(addr),(ptep), __pte(0)) 231#define pte_clear(mm,addr,ptep) set_pte_ext(ptep, __pte(0), 0)
232#define pte_page(pte) (pfn_to_page(pte_pfn(pte))) 232#define pte_page(pte) (pfn_to_page(pte_pfn(pte)))
233#define pte_offset_kernel(dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr)) 233#define pte_offset_kernel(dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr))
234#define pte_offset_map(dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr)) 234#define pte_offset_map(dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr))
@@ -236,8 +236,11 @@ extern struct page *empty_zero_page;
236#define pte_unmap(pte) do { } while (0) 236#define pte_unmap(pte) do { } while (0)
237#define pte_unmap_nested(pte) do { } while (0) 237#define pte_unmap_nested(pte) do { } while (0)
238 238
239#define set_pte(ptep, pte) cpu_set_pte(ptep,pte) 239#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext)
240#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) 240
241#define set_pte_at(mm,addr,ptep,pteval) do { \
242 set_pte_ext(ptep, pteval, (addr) >= PAGE_OFFSET ? 0 : PTE_EXT_NG); \
243 } while (0)
241 244
242/* 245/*
243 * The following only work if pte_present() is true. 246 * The following only work if pte_present() is true.
diff --git a/include/asm-arm/processor.h b/include/asm-arm/processor.h
index b442e8e2a809..1bbf16182d62 100644
--- a/include/asm-arm/processor.h
+++ b/include/asm-arm/processor.h
@@ -103,14 +103,14 @@ extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
103#if __LINUX_ARM_ARCH__ >= 5 103#if __LINUX_ARM_ARCH__ >= 5
104 104
105#define ARCH_HAS_PREFETCH 105#define ARCH_HAS_PREFETCH
106#define prefetch(ptr) \ 106static inline void prefetch(const void *ptr)
107 ({ \ 107{
108 __asm__ __volatile__( \ 108 __asm__ __volatile__(
109 "pld\t%0" \ 109 "pld\t%0"
110 : \ 110 :
111 : "o" (*(char *)(ptr)) \ 111 : "o" (*(char *)ptr)
112 : "cc"); \ 112 : "cc");
113 }) 113}
114 114
115#define ARCH_HAS_PREFETCHW 115#define ARCH_HAS_PREFETCHW
116#define prefetchw(ptr) prefetch(ptr) 116#define prefetchw(ptr) prefetch(ptr)
diff --git a/include/asm-arm/system.h b/include/asm-arm/system.h
index f05fbe31576c..e160aeb0138d 100644
--- a/include/asm-arm/system.h
+++ b/include/asm-arm/system.h
@@ -139,23 +139,60 @@ static inline int cpu_is_xsc3(void)
139#define cpu_is_xscale() 1 139#define cpu_is_xscale() 1
140#endif 140#endif
141 141
142#define set_cr(x) \ 142static inline unsigned int get_cr(void)
143 __asm__ __volatile__( \ 143{
144 "mcr p15, 0, %0, c1, c0, 0 @ set CR" \ 144 unsigned int val;
145 : : "r" (x) : "cc") 145 asm("mrc p15, 0, %0, c1, c0, 0 @ get CR" : "=r" (val) : : "cc");
146 146 return val;
147#define get_cr() \ 147}
148 ({ \ 148
149 unsigned int __val; \ 149static inline void set_cr(unsigned int val)
150 __asm__ __volatile__( \ 150{
151 "mrc p15, 0, %0, c1, c0, 0 @ get CR" \ 151 asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR"
152 : "=r" (__val) : : "cc"); \ 152 : : "r" (val) : "cc");
153 __val; \ 153}
154 }) 154
155#define CPACC_FULL(n) (3 << (n * 2))
156#define CPACC_SVC(n) (1 << (n * 2))
157#define CPACC_DISABLE(n) (0 << (n * 2))
158
159static inline unsigned int get_copro_access(void)
160{
161 unsigned int val;
162 asm("mrc p15, 0, %0, c1, c0, 2 @ get copro access"
163 : "=r" (val) : : "cc");
164 return val;
165}
166
167static inline void set_copro_access(unsigned int val)
168{
169 asm volatile("mcr p15, 0, %0, c1, c0, 2 @ set copro access"
170 : : "r" (val) : "cc");
171}
155 172
156extern unsigned long cr_no_alignment; /* defined in entry-armv.S */ 173extern unsigned long cr_no_alignment; /* defined in entry-armv.S */
157extern unsigned long cr_alignment; /* defined in entry-armv.S */ 174extern unsigned long cr_alignment; /* defined in entry-armv.S */
158 175
176#ifndef CONFIG_SMP
177static inline void adjust_cr(unsigned long mask, unsigned long set)
178{
179 unsigned long flags, cr;
180
181 mask &= ~CR_A;
182
183 set &= mask;
184
185 local_irq_save(flags);
186
187 cr_no_alignment = (cr_no_alignment & ~mask) | set;
188 cr_alignment = (cr_alignment & ~mask) | set;
189
190 set_cr((get_cr() & ~mask) | set);
191
192 local_irq_restore(flags);
193}
194#endif
195
159#define UDBG_UNDEFINED (1 << 0) 196#define UDBG_UNDEFINED (1 << 0)
160#define UDBG_SYSCALL (1 << 1) 197#define UDBG_SYSCALL (1 << 1)
161#define UDBG_BADABORT (1 << 2) 198#define UDBG_BADABORT (1 << 2)
diff --git a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
index d9b8bddc8732..5014794f9eb3 100644
--- a/include/asm-arm/thread_info.h
+++ b/include/asm-arm/thread_info.h
@@ -147,6 +147,7 @@ extern void iwmmxt_task_switch(struct thread_info *);
147#define TIF_POLLING_NRFLAG 16 147#define TIF_POLLING_NRFLAG 16
148#define TIF_USING_IWMMXT 17 148#define TIF_USING_IWMMXT 17
149#define TIF_MEMDIE 18 149#define TIF_MEMDIE 18
150#define TIF_FREEZE 19
150 151
151#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 152#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
152#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 153#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
@@ -154,6 +155,7 @@ extern void iwmmxt_task_switch(struct thread_info *);
154#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 155#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
155#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 156#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
156#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT) 157#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
158#define _TIF_FREEZE (1 << TIF_FREEZE)
157 159
158/* 160/*
159 * Change these and you break ASM code in entry-common.S 161 * Change these and you break ASM code in entry-common.S
diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
index d44c629d8424..32b06eb52819 100644
--- a/include/asm-arm/unistd.h
+++ b/include/asm-arm/unistd.h
@@ -347,6 +347,19 @@
347#define __NR_mbind (__NR_SYSCALL_BASE+319) 347#define __NR_mbind (__NR_SYSCALL_BASE+319)
348#define __NR_get_mempolicy (__NR_SYSCALL_BASE+320) 348#define __NR_get_mempolicy (__NR_SYSCALL_BASE+320)
349#define __NR_set_mempolicy (__NR_SYSCALL_BASE+321) 349#define __NR_set_mempolicy (__NR_SYSCALL_BASE+321)
350#define __NR_openat (__NR_SYSCALL_BASE+322)
351#define __NR_mkdirat (__NR_SYSCALL_BASE+323)
352#define __NR_mknodat (__NR_SYSCALL_BASE+324)
353#define __NR_fchownat (__NR_SYSCALL_BASE+325)
354#define __NR_futimesat (__NR_SYSCALL_BASE+326)
355#define __NR_fstatat64 (__NR_SYSCALL_BASE+327)
356#define __NR_unlinkat (__NR_SYSCALL_BASE+328)
357#define __NR_renameat (__NR_SYSCALL_BASE+329)
358#define __NR_linkat (__NR_SYSCALL_BASE+330)
359#define __NR_symlinkat (__NR_SYSCALL_BASE+331)
360#define __NR_readlinkat (__NR_SYSCALL_BASE+332)
361#define __NR_fchmodat (__NR_SYSCALL_BASE+333)
362#define __NR_faccessat (__NR_SYSCALL_BASE+334)
350 363
351/* 364/*
352 * The following SWIs are ARM private. 365 * The following SWIs are ARM private.
diff --git a/include/asm-arm26/cacheflush.h b/include/asm-arm26/cacheflush.h
index 9c1b9c7f2ebd..14ae15b6faab 100644
--- a/include/asm-arm26/cacheflush.h
+++ b/include/asm-arm26/cacheflush.h
@@ -22,6 +22,7 @@
22 22
23#define flush_cache_all() do { } while (0) 23#define flush_cache_all() do { } while (0)
24#define flush_cache_mm(mm) do { } while (0) 24#define flush_cache_mm(mm) do { } while (0)
25#define flush_cache_dup_mm(mm) do { } while (0)
25#define flush_cache_range(vma,start,end) do { } while (0) 26#define flush_cache_range(vma,start,end) do { } while (0)
26#define flush_cache_page(vma,vmaddr,pfn) do { } while (0) 27#define flush_cache_page(vma,vmaddr,pfn) do { } while (0)
27#define flush_cache_vmap(start, end) do { } while (0) 28#define flush_cache_vmap(start, end) do { } while (0)
diff --git a/include/asm-avr32/cacheflush.h b/include/asm-avr32/cacheflush.h
index f1bf1708980e..dfaaa88cd412 100644
--- a/include/asm-avr32/cacheflush.h
+++ b/include/asm-avr32/cacheflush.h
@@ -87,6 +87,7 @@ void invalidate_icache_region(void *start, size_t len);
87 */ 87 */
88#define flush_cache_all() do { } while (0) 88#define flush_cache_all() do { } while (0)
89#define flush_cache_mm(mm) do { } while (0) 89#define flush_cache_mm(mm) do { } while (0)
90#define flush_cache_dup_mm(mm) do { } while (0)
90#define flush_cache_range(vma, start, end) do { } while (0) 91#define flush_cache_range(vma, start, end) do { } while (0)
91#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 92#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
92#define flush_cache_vmap(start, end) do { } while (0) 93#define flush_cache_vmap(start, end) do { } while (0)
diff --git a/include/asm-avr32/pgalloc.h b/include/asm-avr32/pgalloc.h
index 7492cfb92ced..bb82e70cde8d 100644
--- a/include/asm-avr32/pgalloc.h
+++ b/include/asm-avr32/pgalloc.h
@@ -28,7 +28,7 @@ static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
28static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm) 28static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm)
29{ 29{
30 unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t)); 30 unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t));
31 pgd_t *pgd = (pgd_t *)kmalloc(pgd_size, GFP_KERNEL); 31 pgd_t *pgd = kmalloc(pgd_size, GFP_KERNEL);
32 32
33 if (pgd) 33 if (pgd)
34 memset(pgd, 0, pgd_size); 34 memset(pgd, 0, pgd_size);
diff --git a/include/asm-cris/cacheflush.h b/include/asm-cris/cacheflush.h
index 72cc71dffe70..01af2de27c5b 100644
--- a/include/asm-cris/cacheflush.h
+++ b/include/asm-cris/cacheflush.h
@@ -9,6 +9,7 @@
9 */ 9 */
10#define flush_cache_all() do { } while (0) 10#define flush_cache_all() do { } while (0)
11#define flush_cache_mm(mm) do { } while (0) 11#define flush_cache_mm(mm) do { } while (0)
12#define flush_cache_dup_mm(mm) do { } while (0)
12#define flush_cache_range(vma, start, end) do { } while (0) 13#define flush_cache_range(vma, start, end) do { } while (0)
13#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 14#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
14#define flush_dcache_page(page) do { } while (0) 15#define flush_dcache_page(page) do { } while (0)
diff --git a/include/asm-frv/cacheflush.h b/include/asm-frv/cacheflush.h
index eaa5826bc1c8..02500405a6fb 100644
--- a/include/asm-frv/cacheflush.h
+++ b/include/asm-frv/cacheflush.h
@@ -20,6 +20,7 @@
20 */ 20 */
21#define flush_cache_all() do {} while(0) 21#define flush_cache_all() do {} while(0)
22#define flush_cache_mm(mm) do {} while(0) 22#define flush_cache_mm(mm) do {} while(0)
23#define flush_cache_dup_mm(mm) do {} while(0)
23#define flush_cache_range(mm, start, end) do {} while(0) 24#define flush_cache_range(mm, start, end) do {} while(0)
24#define flush_cache_page(vma, vmaddr, pfn) do {} while(0) 25#define flush_cache_page(vma, vmaddr, pfn) do {} while(0)
25#define flush_cache_vmap(start, end) do {} while(0) 26#define flush_cache_vmap(start, end) do {} while(0)
diff --git a/include/asm-frv/thread_info.h b/include/asm-frv/thread_info.h
index d66c48e6ef14..d881f518e6a9 100644
--- a/include/asm-frv/thread_info.h
+++ b/include/asm-frv/thread_info.h
@@ -116,6 +116,7 @@ register struct thread_info *__current_thread_info asm("gr15");
116#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */ 116#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
117#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 117#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
118#define TIF_MEMDIE 17 /* OOM killer killed process */ 118#define TIF_MEMDIE 17 /* OOM killer killed process */
119#define TIF_FREEZE 18 /* freezing for suspend */
119 120
120#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 121#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
121#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 122#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
@@ -125,6 +126,7 @@ register struct thread_info *__current_thread_info asm("gr15");
125#define _TIF_IRET (1 << TIF_IRET) 126#define _TIF_IRET (1 << TIF_IRET)
126#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 127#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
127#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 128#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
129#define _TIF_FREEZE (1 << TIF_FREEZE)
128 130
129#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ 131#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
130#define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */ 132#define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 7437ccaada77..1587121730c5 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -119,8 +119,6 @@
119 *(__ksymtab_strings) \ 119 *(__ksymtab_strings) \
120 } \ 120 } \
121 \ 121 \
122 EH_FRAME \
123 \
124 /* Built-in module parameters. */ \ 122 /* Built-in module parameters. */ \
125 __param : AT(ADDR(__param) - LOAD_OFFSET) { \ 123 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
126 VMLINUX_SYMBOL(__start___param) = .; \ 124 VMLINUX_SYMBOL(__start___param) = .; \
@@ -160,26 +158,6 @@
160 *(.kprobes.text) \ 158 *(.kprobes.text) \
161 VMLINUX_SYMBOL(__kprobes_text_end) = .; 159 VMLINUX_SYMBOL(__kprobes_text_end) = .;
162 160
163#ifdef CONFIG_STACK_UNWIND
164#define EH_FRAME \
165 /* Unwind data binary search table */ \
166 . = ALIGN(8); \
167 .eh_frame_hdr : AT(ADDR(.eh_frame_hdr) - LOAD_OFFSET) { \
168 VMLINUX_SYMBOL(__start_unwind_hdr) = .; \
169 *(.eh_frame_hdr) \
170 VMLINUX_SYMBOL(__end_unwind_hdr) = .; \
171 } \
172 /* Unwind data */ \
173 . = ALIGN(8); \
174 .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) { \
175 VMLINUX_SYMBOL(__start_unwind) = .; \
176 *(.eh_frame) \
177 VMLINUX_SYMBOL(__end_unwind) = .; \
178 }
179#else
180#define EH_FRAME
181#endif
182
183 /* DWARF debug sections. 161 /* DWARF debug sections.
184 Symbols in the DWARF debugging sections are relative to 162 Symbols in the DWARF debugging sections are relative to
185 the beginning of the section so we begin them at 0. */ 163 the beginning of the section so we begin them at 0. */
diff --git a/include/asm-h8300/cacheflush.h b/include/asm-h8300/cacheflush.h
index 1e4d95bb5ec9..71210d141b64 100644
--- a/include/asm-h8300/cacheflush.h
+++ b/include/asm-h8300/cacheflush.h
@@ -12,6 +12,7 @@
12 12
13#define flush_cache_all() 13#define flush_cache_all()
14#define flush_cache_mm(mm) 14#define flush_cache_mm(mm)
15#define flush_cache_dup_mm(mm) do { } while (0)
15#define flush_cache_range(vma,a,b) 16#define flush_cache_range(vma,a,b)
16#define flush_cache_page(vma,p,pfn) 17#define flush_cache_page(vma,p,pfn)
17#define flush_dcache_page(page) 18#define flush_dcache_page(page)
diff --git a/include/asm-i386/cacheflush.h b/include/asm-i386/cacheflush.h
index 7199f7b326f1..74e03c8f2e51 100644
--- a/include/asm-i386/cacheflush.h
+++ b/include/asm-i386/cacheflush.h
@@ -7,6 +7,7 @@
7/* Caches aren't brain-dead on the intel. */ 7/* Caches aren't brain-dead on the intel. */
8#define flush_cache_all() do { } while (0) 8#define flush_cache_all() do { } while (0)
9#define flush_cache_mm(mm) do { } while (0) 9#define flush_cache_mm(mm) do { } while (0)
10#define flush_cache_dup_mm(mm) do { } while (0)
10#define flush_cache_range(vma, start, end) do { } while (0) 11#define flush_cache_range(vma, start, end) do { } while (0)
11#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 12#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
12#define flush_dcache_page(page) do { } while (0) 13#define flush_dcache_page(page) do { } while (0)
diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
index 46d32ad92082..4b187bb377b4 100644
--- a/include/asm-i386/thread_info.h
+++ b/include/asm-i386/thread_info.h
@@ -134,6 +134,7 @@ static inline struct thread_info *current_thread_info(void)
134#define TIF_MEMDIE 16 134#define TIF_MEMDIE 16
135#define TIF_DEBUG 17 /* uses debug registers */ 135#define TIF_DEBUG 17 /* uses debug registers */
136#define TIF_IO_BITMAP 18 /* uses I/O bitmap */ 136#define TIF_IO_BITMAP 18 /* uses I/O bitmap */
137#define TIF_FREEZE 19 /* is freezing for suspend */
137 138
138#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 139#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
139#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 140#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
@@ -147,6 +148,7 @@ static inline struct thread_info *current_thread_info(void)
147#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 148#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
148#define _TIF_DEBUG (1<<TIF_DEBUG) 149#define _TIF_DEBUG (1<<TIF_DEBUG)
149#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP) 150#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP)
151#define _TIF_FREEZE (1<<TIF_FREEZE)
150 152
151/* work to do on interrupt/exception return */ 153/* work to do on interrupt/exception return */
152#define _TIF_WORK_MASK \ 154#define _TIF_WORK_MASK \
diff --git a/include/asm-i386/unwind.h b/include/asm-i386/unwind.h
index aa2c931e30db..43c70c3de2f9 100644
--- a/include/asm-i386/unwind.h
+++ b/include/asm-i386/unwind.h
@@ -1,95 +1,6 @@
1#ifndef _ASM_I386_UNWIND_H 1#ifndef _ASM_I386_UNWIND_H
2#define _ASM_I386_UNWIND_H 2#define _ASM_I386_UNWIND_H
3 3
4/*
5 * Copyright (C) 2002-2006 Novell, Inc.
6 * Jan Beulich <jbeulich@novell.com>
7 * This code is released under version 2 of the GNU GPL.
8 */
9
10#ifdef CONFIG_STACK_UNWIND
11
12#include <linux/sched.h>
13#include <asm/fixmap.h>
14#include <asm/ptrace.h>
15#include <asm/uaccess.h>
16
17struct unwind_frame_info
18{
19 struct pt_regs regs;
20 struct task_struct *task;
21 unsigned call_frame:1;
22};
23
24#define UNW_PC(frame) (frame)->regs.eip
25#define UNW_SP(frame) (frame)->regs.esp
26#ifdef CONFIG_FRAME_POINTER
27#define UNW_FP(frame) (frame)->regs.ebp
28#define FRAME_RETADDR_OFFSET 4
29#define FRAME_LINK_OFFSET 0
30#define STACK_BOTTOM(tsk) STACK_LIMIT((tsk)->thread.esp0)
31#define STACK_TOP(tsk) ((tsk)->thread.esp0)
32#else
33#define UNW_FP(frame) ((void)(frame), 0)
34#endif
35#define STACK_LIMIT(ptr) (((ptr) - 1) & ~(THREAD_SIZE - 1))
36
37#define UNW_REGISTER_INFO \
38 PTREGS_INFO(eax), \
39 PTREGS_INFO(ecx), \
40 PTREGS_INFO(edx), \
41 PTREGS_INFO(ebx), \
42 PTREGS_INFO(esp), \
43 PTREGS_INFO(ebp), \
44 PTREGS_INFO(esi), \
45 PTREGS_INFO(edi), \
46 PTREGS_INFO(eip)
47
48#define UNW_DEFAULT_RA(raItem, dataAlign) \
49 ((raItem).where == Memory && \
50 !((raItem).value * (dataAlign) + 4))
51
52static inline void arch_unw_init_frame_info(struct unwind_frame_info *info,
53 /*const*/ struct pt_regs *regs)
54{
55 if (user_mode_vm(regs))
56 info->regs = *regs;
57 else {
58 memcpy(&info->regs, regs, offsetof(struct pt_regs, esp));
59 info->regs.esp = (unsigned long)&regs->esp;
60 info->regs.xss = __KERNEL_DS;
61 }
62}
63
64static inline void arch_unw_init_blocked(struct unwind_frame_info *info)
65{
66 memset(&info->regs, 0, sizeof(info->regs));
67 info->regs.eip = info->task->thread.eip;
68 info->regs.xcs = __KERNEL_CS;
69 __get_user(info->regs.ebp, (long *)info->task->thread.esp);
70 info->regs.esp = info->task->thread.esp;
71 info->regs.xss = __KERNEL_DS;
72 info->regs.xds = __USER_DS;
73 info->regs.xes = __USER_DS;
74 info->regs.xgs = __KERNEL_PDA;
75}
76
77extern asmlinkage int arch_unwind_init_running(struct unwind_frame_info *,
78 asmlinkage int (*callback)(struct unwind_frame_info *,
79 void *arg),
80 void *arg);
81
82static inline int arch_unw_user_mode(/*const*/ struct unwind_frame_info *info)
83{
84 return user_mode_vm(&info->regs)
85 || info->regs.eip < PAGE_OFFSET
86 || (info->regs.eip >= __fix_to_virt(FIX_VDSO)
87 && info->regs.eip < __fix_to_virt(FIX_VDSO) + PAGE_SIZE)
88 || info->regs.esp < PAGE_OFFSET;
89}
90
91#else
92
93#define UNW_PC(frame) ((void)(frame), 0) 4#define UNW_PC(frame) ((void)(frame), 0)
94#define UNW_SP(frame) ((void)(frame), 0) 5#define UNW_SP(frame) ((void)(frame), 0)
95#define UNW_FP(frame) ((void)(frame), 0) 6#define UNW_FP(frame) ((void)(frame), 0)
@@ -99,6 +10,4 @@ static inline int arch_unw_user_mode(const void *info)
99 return 0; 10 return 0;
100} 11}
101 12
102#endif
103
104#endif /* _ASM_I386_UNWIND_H */ 13#endif /* _ASM_I386_UNWIND_H */
diff --git a/include/asm-ia64/cacheflush.h b/include/asm-ia64/cacheflush.h
index f2dacb4245ec..4906916d715b 100644
--- a/include/asm-ia64/cacheflush.h
+++ b/include/asm-ia64/cacheflush.h
@@ -18,6 +18,7 @@
18 18
19#define flush_cache_all() do { } while (0) 19#define flush_cache_all() do { } while (0)
20#define flush_cache_mm(mm) do { } while (0) 20#define flush_cache_mm(mm) do { } while (0)
21#define flush_cache_dup_mm(mm) do { } while (0)
21#define flush_cache_range(vma, start, end) do { } while (0) 22#define flush_cache_range(vma, start, end) do { } while (0)
22#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 23#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
23#define flush_icache_page(vma,page) do { } while (0) 24#define flush_icache_page(vma,page) do { } while (0)
diff --git a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h
index 825eb7d882e6..556f53fa44cb 100644
--- a/include/asm-ia64/pci.h
+++ b/include/asm-ia64/pci.h
@@ -78,9 +78,6 @@ pcibios_penalize_isa_irq (int irq, int active)
78#define pci_dac_dma_sync_single_for_cpu(dev,dma_addr,len,dir) do { } while (0) 78#define pci_dac_dma_sync_single_for_cpu(dev,dma_addr,len,dir) do { } while (0)
79#define pci_dac_dma_sync_single_for_device(dev,dma_addr,len,dir) do { mb(); } while (0) 79#define pci_dac_dma_sync_single_for_device(dev,dma_addr,len,dir) do { mb(); } while (0)
80 80
81#define sg_dma_len(sg) ((sg)->dma_length)
82#define sg_dma_address(sg) ((sg)->dma_address)
83
84#ifdef CONFIG_PCI 81#ifdef CONFIG_PCI
85static inline void pci_dma_burst_advice(struct pci_dev *pdev, 82static inline void pci_dma_burst_advice(struct pci_dev *pdev,
86 enum pci_dma_burst_strategy *strat, 83 enum pci_dma_burst_strategy *strat,
diff --git a/include/asm-ia64/scatterlist.h b/include/asm-ia64/scatterlist.h
index 834a189ef189..9dbea8844d5e 100644
--- a/include/asm-ia64/scatterlist.h
+++ b/include/asm-ia64/scatterlist.h
@@ -25,4 +25,7 @@ struct scatterlist {
25 */ 25 */
26#define ISA_DMA_THRESHOLD 0xffffffff 26#define ISA_DMA_THRESHOLD 0xffffffff
27 27
28#define sg_dma_len(sg) ((sg)->dma_length)
29#define sg_dma_address(sg) ((sg)->dma_address)
30
28#endif /* _ASM_IA64_SCATTERLIST_H */ 31#endif /* _ASM_IA64_SCATTERLIST_H */
diff --git a/include/asm-ia64/thread_info.h b/include/asm-ia64/thread_info.h
index 8adcde0934ca..9b505b25544f 100644
--- a/include/asm-ia64/thread_info.h
+++ b/include/asm-ia64/thread_info.h
@@ -88,6 +88,7 @@ struct thread_info {
88#define TIF_MEMDIE 17 88#define TIF_MEMDIE 17
89#define TIF_MCA_INIT 18 /* this task is processing MCA or INIT */ 89#define TIF_MCA_INIT 18 /* this task is processing MCA or INIT */
90#define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */ 90#define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */
91#define TIF_FREEZE 20 /* is freezing for suspend */
91 92
92#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 93#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
93#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 94#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
@@ -98,6 +99,7 @@ struct thread_info {
98#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 99#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
99#define _TIF_MCA_INIT (1 << TIF_MCA_INIT) 100#define _TIF_MCA_INIT (1 << TIF_MCA_INIT)
100#define _TIF_DB_DISABLED (1 << TIF_DB_DISABLED) 101#define _TIF_DB_DISABLED (1 << TIF_DB_DISABLED)
102#define _TIF_FREEZE (1 << TIF_FREEZE)
101 103
102/* "work to do on user-return" bits */ 104/* "work to do on user-return" bits */
103#define TIF_ALLWORK_MASK (_TIF_NOTIFY_RESUME|_TIF_SIGPENDING|_TIF_NEED_RESCHED|_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT) 105#define TIF_ALLWORK_MASK (_TIF_NOTIFY_RESUME|_TIF_SIGPENDING|_TIF_NEED_RESCHED|_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
diff --git a/include/asm-m32r/cacheflush.h b/include/asm-m32r/cacheflush.h
index 8b261b49149e..56961a9511b2 100644
--- a/include/asm-m32r/cacheflush.h
+++ b/include/asm-m32r/cacheflush.h
@@ -9,6 +9,7 @@ extern void _flush_cache_copyback_all(void);
9#if defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104) 9#if defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104)
10#define flush_cache_all() do { } while (0) 10#define flush_cache_all() do { } while (0)
11#define flush_cache_mm(mm) do { } while (0) 11#define flush_cache_mm(mm) do { } while (0)
12#define flush_cache_dup_mm(mm) do { } while (0)
12#define flush_cache_range(vma, start, end) do { } while (0) 13#define flush_cache_range(vma, start, end) do { } while (0)
13#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 14#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
14#define flush_dcache_page(page) do { } while (0) 15#define flush_dcache_page(page) do { } while (0)
@@ -29,6 +30,7 @@ extern void smp_flush_cache_all(void);
29#elif defined(CONFIG_CHIP_M32102) 30#elif defined(CONFIG_CHIP_M32102)
30#define flush_cache_all() do { } while (0) 31#define flush_cache_all() do { } while (0)
31#define flush_cache_mm(mm) do { } while (0) 32#define flush_cache_mm(mm) do { } while (0)
33#define flush_cache_dup_mm(mm) do { } while (0)
32#define flush_cache_range(vma, start, end) do { } while (0) 34#define flush_cache_range(vma, start, end) do { } while (0)
33#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 35#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
34#define flush_dcache_page(page) do { } while (0) 36#define flush_dcache_page(page) do { } while (0)
@@ -41,6 +43,7 @@ extern void smp_flush_cache_all(void);
41#else 43#else
42#define flush_cache_all() do { } while (0) 44#define flush_cache_all() do { } while (0)
43#define flush_cache_mm(mm) do { } while (0) 45#define flush_cache_mm(mm) do { } while (0)
46#define flush_cache_dup_mm(mm) do { } while (0)
44#define flush_cache_range(vma, start, end) do { } while (0) 47#define flush_cache_range(vma, start, end) do { } while (0)
45#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 48#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
46#define flush_dcache_page(page) do { } while (0) 49#define flush_dcache_page(page) do { } while (0)
diff --git a/include/asm-m68k/cacheflush.h b/include/asm-m68k/cacheflush.h
index 24d3ff449135..16bf375fdbe1 100644
--- a/include/asm-m68k/cacheflush.h
+++ b/include/asm-m68k/cacheflush.h
@@ -89,6 +89,8 @@ static inline void flush_cache_mm(struct mm_struct *mm)
89 __flush_cache_030(); 89 __flush_cache_030();
90} 90}
91 91
92#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
93
92/* flush_cache_range/flush_cache_page must be macros to avoid 94/* flush_cache_range/flush_cache_page must be macros to avoid
93 a dependency on linux/mm.h, which includes this file... */ 95 a dependency on linux/mm.h, which includes this file... */
94static inline void flush_cache_range(struct vm_area_struct *vma, 96static inline void flush_cache_range(struct vm_area_struct *vma,
diff --git a/include/asm-m68k/swim_iop.h b/include/asm-m68k/swim_iop.h
deleted file mode 100644
index f29b67876b01..000000000000
--- a/include/asm-m68k/swim_iop.h
+++ /dev/null
@@ -1,221 +0,0 @@
1/*
2 * SWIM access through the IOP
3 * Written by Joshua M. Thompson
4 */
5
6/* IOP number and channel number for the SWIM */
7
8#define SWIM_IOP IOP_NUM_ISM
9#define SWIM_CHAN 1
10
11/* Command code: */
12
13#define CMD_INIT 0x01 /* Initialize */
14#define CMD_SHUTDOWN 0x02 /* Shutdown */
15#define CMD_START_POLL 0x03 /* Start insert/eject polling */
16#define CMD_STOP_POLL 0x04 /* Stop insert/eject polling */
17#define CMD_SETHFSTAG 0x05 /* Set HFS tag buffer address */
18#define CMD_STATUS 0x06 /* Status */
19#define CMD_EJECT 0x07 /* Eject */
20#define CMD_FORMAT 0x08 /* Format */
21#define CMD_FORMAT_VERIFY 0x09 /* Format and Verify */
22#define CMD_WRITE 0x0A /* Write */
23#define CMD_READ 0x0B /* Read */
24#define CMD_READ_VERIFY 0x0C /* Read and Verify */
25#define CMD_CACHE_CTRL 0x0D /* Cache control */
26#define CMD_TAGBUFF_CTRL 0x0E /* Tag buffer control */
27#define CMD_GET_ICON 0x0F /* Get Icon */
28
29/* Drive types: */
30
31/* note: apple sez DRV_FDHD is 4, but I get back a type */
32/* of 5 when I do a drive status check on my FDHD */
33
34#define DRV_NONE 0 /* No drive */
35#define DRV_UNKNOWN 1 /* Unspecified drive */
36#define DRV_400K 2 /* 400K */
37#define DRV_800K 3 /* 400K/800K */
38#define DRV_FDHD 5 /* 400K/800K/720K/1440K */
39#define DRV_HD20 7 /* Apple HD20 */
40
41/* Format types: */
42
43#define FMT_HD20 0x0001 /* Apple HD20 */
44#define FMT_400K 0x0002 /* 400K (GCR) */
45#define FMT_800K 0x0004 /* 800K (GCR) */
46#define FMT_720K 0x0008 /* 720K (MFM) */
47#define FMT_1440K 0x0010 /* 1.44M (MFM) */
48
49#define FMD_KIND_400K 1
50#define FMD_KIND_800K 2
51#define FMD_KIND_720K 3
52#define FMD_KIND_1440K 1
53
54/* Icon Flags: */
55
56#define ICON_MEDIA 0x01 /* Have IOP supply media icon */
57#define ICON_DRIVE 0x01 /* Have IOP supply drive icon */
58
59/* Error codes: */
60
61#define gcrOnMFMErr -400 /* GCR (400/800K) on HD media */
62#define verErr -84 /* verify failed */
63#define fmt2Err -83 /* can't get enough sync during format */
64#define fmt1Err -82 /* can't find sector 0 after track format */
65#define sectNFErr -81 /* can't find sector */
66#define seekErr -80 /* drive error during seek */
67#define spdAdjErr -79 /* can't set drive speed */
68#define twoSideErr -78 /* drive is single-sided */
69#define initIWMErr -77 /* error during initialization */
70#define tk0badErr -76 /* track zero is bad */
71#define cantStepErr -75 /* drive error during step */
72#define wrUnderrun -74 /* write underrun occurred */
73#define badDBtSlp -73 /* bad data bitslip marks */
74#define badDCksum -72 /* bad data checksum */
75#define noDtaMkErr -71 /* can't find data mark */
76#define badBtSlpErr -70 /* bad address bitslip marks */
77#define badCksmErr -69 /* bad address-mark checksum */
78#define dataVerErr -68 /* read-verify failed */
79#define noAdrMkErr -67 /* can't find an address mark */
80#define noNybErr -66 /* no nybbles? disk is probably degaussed */
81#define offLinErr -65 /* no disk in drive */
82#define noDriveErr -64 /* drive isn't connected */
83#define nsDrvErr -56 /* no such drive */
84#define paramErr -50 /* bad positioning information */
85#define wPrErr -44 /* write protected */
86#define openErr -23 /* already initialized */
87
88#ifndef __ASSEMBLY__
89
90struct swim_drvstatus {
91 __u16 curr_track; /* Current track number */
92 __u8 write_prot; /* 0x80 if disk is write protected */
93 __u8 disk_in_drive; /* 0x01 or 0x02 if a disk is in the drive */
94 __u8 installed; /* 0x01 if drive installed, 0xFF if not */
95 __u8 num_sides; /* 0x80 if two-sided format supported */
96 __u8 two_sided; /* 0xff if two-sided format diskette */
97 __u8 new_interface; /* 0x00 if old 400K drive, 0xFF if newer */
98 __u16 errors; /* Disk error count */
99 struct { /* 32 bits */
100 __u16 reserved;
101 __u16 :4;
102 __u16 external:1; /* Drive is external */
103 __u16 scsi:1; /* Drive is a SCSI drive */
104 __u16 fixed:1; /* Drive has fixed media */
105 __u16 secondary:1; /* Drive is secondary drive */
106 __u8 type; /* Drive type */
107 } info;
108 __u8 mfm_drive; /* 0xFF if this is an FDHD drive */
109 __u8 mfm_disk; /* 0xFF if 720K/1440K (MFM) disk */
110 __u8 mfm_format; /* 0x00 if 720K, 0xFF if 1440K */
111 __u8 ctlr_type; /* 0x00 if IWM, 0xFF if SWIM */
112 __u16 curr_format; /* Current format type */
113 __u16 allowed_fmt; /* Allowed format types */
114 __u32 num_blocks; /* Number of blocks on disk */
115 __u8 icon_flags; /* Icon flags */
116 __u8 unusued;
117};
118
119/* Commands issued from the host to the IOP: */
120
121struct swimcmd_init {
122 __u8 code; /* CMD_INIT */
123 __u8 unusued;
124 __u16 error;
125 __u8 drives[28]; /* drive type list */
126};
127
128struct swimcmd_startpoll {
129 __u8 code; /* CMD_START_POLL */
130 __u8 unusued;
131 __u16 error;
132};
133
134struct swimcmd_sethfstag {
135 __u8 code; /* CMD_SETHFSTAG */
136 __u8 unusued;
137 __u16 error;
138 caddr_t tagbuf; /* HFS tag buffer address */
139};
140
141struct swimcmd_status {
142 __u8 code; /* CMD_STATUS */
143 __u8 drive_num;
144 __u16 error;
145 struct swim_drvstatus status;
146};
147
148struct swimcmd_eject {
149 __u8 code; /* CMD_EJECT */
150 __u8 drive_num;
151 __u16 error;
152 struct swim_drvstatus status;
153};
154
155struct swimcmd_format {
156 __u8 code; /* CMD_FORMAT */
157 __u8 drive_num;
158 __u16 error;
159 union {
160 struct {
161 __u16 fmt; /* format kind */
162 __u8 hdrbyte; /* fmt byte for hdr (0=default) */
163 __u8 interleave; /* interleave (0 = default) */
164 caddr_t databuf; /* sector data buff (0=default */
165 caddr_t tagbuf; /* tag data buffer (0=default) */
166 } f;
167 struct swim_drvstatus status;
168 } p;
169};
170
171struct swimcmd_fmtverify {
172 __u8 code; /* CMD_FORMAT_VERIFY */
173 __u8 drive_num;
174 __u16 error;
175};
176
177struct swimcmd_rw {
178 __u8 code; /* CMD_READ, CMD_WRITE or CMD_READ_VERIFY */
179 __u8 drive_num;
180 __u16 error;
181 caddr_t buffer; /* R/W buffer address */
182 __u32 first_block; /* Starting block */
183 __u32 num_blocks; /* Number of blocks */
184 __u8 tag[12]; /* tag data */
185};
186
187struct swimcmd_cachectl {
188 __u8 code; /* CMD_CACHE_CTRL */
189 __u8 unused;
190 __u16 error;
191 __u8 enable; /* Nonzero to enable cache */
192 __u8 install; /* +1 = install, -1 = remove, 0 = neither */
193};
194
195struct swimcmd_tagbufctl {
196 __u8 code; /* CMD_TAGBUFF_CTRL */
197 __u8 unused;
198 __u16 error;
199 caddr_t buf; /* buffer address or 0 to disable */
200};
201
202struct swimcmd_geticon {
203 __u8 code; /* CMD_GET_ICON */
204 __u8 drive_num;
205 __u16 error;
206 caddr_t buffer; /* Nuffer address */
207 __u16 kind; /* 0 = media icon, 1 = drive icon */
208 __u16 unused;
209 __u16 max_bytes; /* maximum byte count */
210};
211
212/* Messages from the SWIM IOP to the host CPU: */
213
214struct swimmsg_status {
215 __u8 code; /* 1 = insert, 2 = eject, 3 = status changed */
216 __u8 drive_num;
217 __u16 error;
218 struct swim_drvstatus status;
219};
220
221#endif /* __ASSEMBLY__ */
diff --git a/include/asm-m68knommu/cacheflush.h b/include/asm-m68knommu/cacheflush.h
index c3aadf3b0d88..163dcb1a9689 100644
--- a/include/asm-m68knommu/cacheflush.h
+++ b/include/asm-m68knommu/cacheflush.h
@@ -8,6 +8,7 @@
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_dup_mm(mm) do { } while (0)
11#define flush_cache_range(vma, start, end) __flush_cache_all() 12#define flush_cache_range(vma, start, end) __flush_cache_all()
12#define flush_cache_page(vma, vmaddr) do { } while (0) 13#define flush_cache_page(vma, vmaddr) do { } while (0)
13#define flush_dcache_range(start,len) __flush_cache_all() 14#define flush_dcache_range(start,len) __flush_cache_all()
diff --git a/include/asm-mips/cacheflush.h b/include/asm-mips/cacheflush.h
index e3c9925876a3..0ddada3bb0b6 100644
--- a/include/asm-mips/cacheflush.h
+++ b/include/asm-mips/cacheflush.h
@@ -17,6 +17,7 @@
17 * 17 *
18 * - flush_cache_all() flushes entire cache 18 * - flush_cache_all() flushes entire cache
19 * - flush_cache_mm(mm) flushes the specified mm context's cache lines 19 * - flush_cache_mm(mm) flushes the specified mm context's cache lines
20 * - flush_cache_dup mm(mm) handles cache flushing when forking
20 * - flush_cache_page(mm, vmaddr, pfn) flushes a single page 21 * - flush_cache_page(mm, vmaddr, pfn) flushes a single page
21 * - flush_cache_range(vma, start, end) flushes a range of pages 22 * - flush_cache_range(vma, start, end) flushes a range of pages
22 * - flush_icache_range(start, end) flush a range of instructions 23 * - flush_icache_range(start, end) flush a range of instructions
@@ -31,6 +32,7 @@
31extern void (*flush_cache_all)(void); 32extern void (*flush_cache_all)(void);
32extern void (*__flush_cache_all)(void); 33extern void (*__flush_cache_all)(void);
33extern void (*flush_cache_mm)(struct mm_struct *mm); 34extern void (*flush_cache_mm)(struct mm_struct *mm);
35#define flush_cache_dup_mm(mm) do { (void) (mm); } while (0)
34extern void (*flush_cache_range)(struct vm_area_struct *vma, 36extern void (*flush_cache_range)(struct vm_area_struct *vma,
35 unsigned long start, unsigned long end); 37 unsigned long start, unsigned long end);
36extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn); 38extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn);
diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index 0dc1a45c27ed..2f9e1a9ec51f 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -35,7 +35,6 @@
35#ifndef __ASSEMBLY__ 35#ifndef __ASSEMBLY__
36 36
37#include <linux/pfn.h> 37#include <linux/pfn.h>
38#include <asm/cpu-features.h>
39#include <asm/io.h> 38#include <asm/io.h>
40 39
41extern void clear_page(void * page); 40extern void clear_page(void * page);
@@ -61,16 +60,13 @@ static inline void clear_user_page(void *addr, unsigned long vaddr,
61 flush_data_cache_page((unsigned long)addr); 60 flush_data_cache_page((unsigned long)addr);
62} 61}
63 62
64static inline void copy_user_page(void *vto, void *vfrom, unsigned long vaddr, 63extern void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
65 struct page *to) 64 struct page *to);
66{ 65struct vm_area_struct;
67 extern void (*flush_data_cache_page)(unsigned long addr); 66extern void copy_user_highpage(struct page *to, struct page *from,
67 unsigned long vaddr, struct vm_area_struct *vma);
68 68
69 copy_page(vto, vfrom); 69#define __HAVE_ARCH_COPY_USER_HIGHPAGE
70 if (!cpu_has_ic_fills_f_dc ||
71 pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK))
72 flush_data_cache_page((unsigned long)vto);
73}
74 70
75/* 71/*
76 * These are used to make use of C type-checking.. 72 * These are used to make use of C type-checking..
diff --git a/include/asm-parisc/cacheflush.h b/include/asm-parisc/cacheflush.h
index 2bc41f2e0271..aedb0512cb04 100644
--- a/include/asm-parisc/cacheflush.h
+++ b/include/asm-parisc/cacheflush.h
@@ -15,6 +15,8 @@
15#define flush_cache_mm(mm) flush_cache_all_local() 15#define flush_cache_mm(mm) flush_cache_all_local()
16#endif 16#endif
17 17
18#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
19
18#define flush_kernel_dcache_range(start,size) \ 20#define flush_kernel_dcache_range(start,size) \
19 flush_kernel_dcache_range_asm((start), (start)+(size)); 21 flush_kernel_dcache_range_asm((start), (start)+(size));
20 22
diff --git a/include/asm-powerpc/cacheflush.h b/include/asm-powerpc/cacheflush.h
index 8a740c88d93d..08e93e789219 100644
--- a/include/asm-powerpc/cacheflush.h
+++ b/include/asm-powerpc/cacheflush.h
@@ -18,6 +18,7 @@
18 */ 18 */
19#define flush_cache_all() do { } while (0) 19#define flush_cache_all() do { } while (0)
20#define flush_cache_mm(mm) do { } while (0) 20#define flush_cache_mm(mm) do { } while (0)
21#define flush_cache_dup_mm(mm) do { } while (0)
21#define flush_cache_range(vma, start, end) do { } while (0) 22#define flush_cache_range(vma, start, end) do { } while (0)
22#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 23#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
23#define flush_icache_page(vma, page) do { } while (0) 24#define flush_icache_page(vma, page) do { } while (0)
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
index d339e2e88b11..3f32ca8bfec9 100644
--- a/include/asm-powerpc/thread_info.h
+++ b/include/asm-powerpc/thread_info.h
@@ -122,6 +122,7 @@ static inline struct thread_info *current_thread_info(void)
122#define TIF_RESTOREALL 12 /* Restore all regs (implies NOERROR) */ 122#define TIF_RESTOREALL 12 /* Restore all regs (implies NOERROR) */
123#define TIF_NOERROR 14 /* Force successful syscall return */ 123#define TIF_NOERROR 14 /* Force successful syscall return */
124#define TIF_RESTORE_SIGMASK 15 /* Restore signal mask in do_signal */ 124#define TIF_RESTORE_SIGMASK 15 /* Restore signal mask in do_signal */
125#define TIF_FREEZE 16 /* Freezing for suspend */
125 126
126/* as above, but as bit values */ 127/* as above, but as bit values */
127#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 128#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
@@ -138,6 +139,7 @@ static inline struct thread_info *current_thread_info(void)
138#define _TIF_RESTOREALL (1<<TIF_RESTOREALL) 139#define _TIF_RESTOREALL (1<<TIF_RESTOREALL)
139#define _TIF_NOERROR (1<<TIF_NOERROR) 140#define _TIF_NOERROR (1<<TIF_NOERROR)
140#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 141#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
142#define _TIF_FREEZE (1<<TIF_FREEZE)
141#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP) 143#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
142 144
143#define _TIF_USER_WORK_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \ 145#define _TIF_USER_WORK_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \
diff --git a/include/asm-s390/cacheflush.h b/include/asm-s390/cacheflush.h
index e399a8ba2ed7..f7cade8083f3 100644
--- a/include/asm-s390/cacheflush.h
+++ b/include/asm-s390/cacheflush.h
@@ -7,6 +7,7 @@
7/* Caches aren't brain-dead on the s390. */ 7/* Caches aren't brain-dead on the s390. */
8#define flush_cache_all() do { } while (0) 8#define flush_cache_all() do { } while (0)
9#define flush_cache_mm(mm) do { } while (0) 9#define flush_cache_mm(mm) do { } while (0)
10#define flush_cache_dup_mm(mm) do { } while (0)
10#define flush_cache_range(vma, start, end) do { } while (0) 11#define flush_cache_range(vma, start, end) do { } while (0)
11#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 12#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
12#define flush_dcache_page(page) do { } while (0) 13#define flush_dcache_page(page) do { } while (0)
diff --git a/include/asm-s390/qdio.h b/include/asm-s390/qdio.h
index 7189c79bc673..127f72e77419 100644
--- a/include/asm-s390/qdio.h
+++ b/include/asm-s390/qdio.h
@@ -34,6 +34,7 @@
34#define QDIO_QETH_QFMT 0 34#define QDIO_QETH_QFMT 0
35#define QDIO_ZFCP_QFMT 1 35#define QDIO_ZFCP_QFMT 1
36#define QDIO_IQDIO_QFMT 2 36#define QDIO_IQDIO_QFMT 2
37#define QDIO_IQDIO_QFMT_ASYNCH 3
37 38
38struct qdio_buffer_element{ 39struct qdio_buffer_element{
39 unsigned int flags; 40 unsigned int flags;
diff --git a/include/asm-s390/reset.h b/include/asm-s390/reset.h
index 9b439cf67800..532e65a2aafc 100644
--- a/include/asm-s390/reset.h
+++ b/include/asm-s390/reset.h
@@ -19,5 +19,6 @@ extern void register_reset_call(struct reset_call *reset);
19extern void unregister_reset_call(struct reset_call *reset); 19extern void unregister_reset_call(struct reset_call *reset);
20extern void s390_reset_system(void); 20extern void s390_reset_system(void);
21extern void (*s390_reset_mcck_handler)(void); 21extern void (*s390_reset_mcck_handler)(void);
22extern void (*s390_reset_pgm_handler)(void);
22 23
23#endif /* _ASM_S390_RESET_H */ 24#endif /* _ASM_S390_RESET_H */
diff --git a/include/asm-sh/cpu-sh2/cacheflush.h b/include/asm-sh/cpu-sh2/cacheflush.h
index f556fa80ea97..2979efb26de3 100644
--- a/include/asm-sh/cpu-sh2/cacheflush.h
+++ b/include/asm-sh/cpu-sh2/cacheflush.h
@@ -15,6 +15,7 @@
15 * 15 *
16 * - flush_cache_all() flushes entire cache 16 * - flush_cache_all() flushes entire cache
17 * - flush_cache_mm(mm) flushes the specified mm context's cache lines 17 * - flush_cache_mm(mm) flushes the specified mm context's cache lines
18 * - flush_cache_dup mm(mm) handles cache flushing when forking
18 * - flush_cache_page(mm, vmaddr, pfn) flushes a single page 19 * - flush_cache_page(mm, vmaddr, pfn) flushes a single page
19 * - flush_cache_range(vma, start, end) flushes a range of pages 20 * - flush_cache_range(vma, start, end) flushes a range of pages
20 * 21 *
@@ -27,6 +28,7 @@
27 */ 28 */
28#define flush_cache_all() do { } while (0) 29#define flush_cache_all() do { } while (0)
29#define flush_cache_mm(mm) do { } while (0) 30#define flush_cache_mm(mm) do { } while (0)
31#define flush_cache_dup_mm(mm) do { } while (0)
30#define flush_cache_range(vma, start, end) do { } while (0) 32#define flush_cache_range(vma, start, end) do { } while (0)
31#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 33#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
32#define flush_dcache_page(page) do { } while (0) 34#define flush_dcache_page(page) do { } while (0)
diff --git a/include/asm-sh/cpu-sh3/cacheflush.h b/include/asm-sh/cpu-sh3/cacheflush.h
index 03fde97a7fd0..f70d8ef76a15 100644
--- a/include/asm-sh/cpu-sh3/cacheflush.h
+++ b/include/asm-sh/cpu-sh3/cacheflush.h
@@ -15,6 +15,7 @@
15 * 15 *
16 * - flush_cache_all() flushes entire cache 16 * - flush_cache_all() flushes entire cache
17 * - flush_cache_mm(mm) flushes the specified mm context's cache lines 17 * - flush_cache_mm(mm) flushes the specified mm context's cache lines
18 * - flush_cache_dup mm(mm) handles cache flushing when forking
18 * - flush_cache_page(mm, vmaddr, pfn) flushes a single page 19 * - flush_cache_page(mm, vmaddr, pfn) flushes a single page
19 * - flush_cache_range(vma, start, end) flushes a range of pages 20 * - flush_cache_range(vma, start, end) flushes a range of pages
20 * 21 *
@@ -39,6 +40,7 @@
39 40
40void flush_cache_all(void); 41void flush_cache_all(void);
41void flush_cache_mm(struct mm_struct *mm); 42void flush_cache_mm(struct mm_struct *mm);
43#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
42void flush_cache_range(struct vm_area_struct *vma, unsigned long start, 44void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
43 unsigned long end); 45 unsigned long end);
44void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn); 46void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn);
@@ -48,6 +50,7 @@ void flush_icache_page(struct vm_area_struct *vma, struct page *page);
48#else 50#else
49#define flush_cache_all() do { } while (0) 51#define flush_cache_all() do { } while (0)
50#define flush_cache_mm(mm) do { } while (0) 52#define flush_cache_mm(mm) do { } while (0)
53#define flush_cache_dup_mm(mm) do { } while (0)
51#define flush_cache_range(vma, start, end) do { } while (0) 54#define flush_cache_range(vma, start, end) do { } while (0)
52#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 55#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
53#define flush_dcache_page(page) do { } while (0) 56#define flush_dcache_page(page) do { } while (0)
diff --git a/include/asm-sh/cpu-sh4/cacheflush.h b/include/asm-sh/cpu-sh4/cacheflush.h
index 515fd574267c..b01a10f31225 100644
--- a/include/asm-sh/cpu-sh4/cacheflush.h
+++ b/include/asm-sh/cpu-sh4/cacheflush.h
@@ -18,6 +18,7 @@
18 */ 18 */
19void flush_cache_all(void); 19void flush_cache_all(void);
20void flush_cache_mm(struct mm_struct *mm); 20void flush_cache_mm(struct mm_struct *mm);
21#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
21void flush_cache_range(struct vm_area_struct *vma, unsigned long start, 22void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
22 unsigned long end); 23 unsigned long end);
23void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, 24void flush_cache_page(struct vm_area_struct *vma, unsigned long addr,
diff --git a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h
index 0c01dc550819..879f741105db 100644
--- a/include/asm-sh/thread_info.h
+++ b/include/asm-sh/thread_info.h
@@ -106,6 +106,7 @@ static inline struct thread_info *current_thread_info(void)
106#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ 106#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
107#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 107#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
108#define TIF_MEMDIE 18 108#define TIF_MEMDIE 18
109#define TIF_FREEZE 19
109 110
110#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 111#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
111#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 112#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
@@ -114,6 +115,7 @@ static inline struct thread_info *current_thread_info(void)
114#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 115#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
115#define _TIF_USEDFPU (1<<TIF_USEDFPU) 116#define _TIF_USEDFPU (1<<TIF_USEDFPU)
116#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 117#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
118#define _TIF_FREEZE (1<<TIF_FREEZE)
117 119
118#define _TIF_WORK_MASK 0x000000FE /* work to do on interrupt/exception return */ 120#define _TIF_WORK_MASK 0x000000FE /* work to do on interrupt/exception return */
119#define _TIF_ALLWORK_MASK 0x000000FF /* work to do on any return to u-space */ 121#define _TIF_ALLWORK_MASK 0x000000FF /* work to do on any return to u-space */
diff --git a/include/asm-sh64/cacheflush.h b/include/asm-sh64/cacheflush.h
index 55f71aa0aa6b..1e53a47bdc97 100644
--- a/include/asm-sh64/cacheflush.h
+++ b/include/asm-sh64/cacheflush.h
@@ -21,6 +21,8 @@ extern void flush_icache_user_range(struct vm_area_struct *vma,
21 struct page *page, unsigned long addr, 21 struct page *page, unsigned long addr,
22 int len); 22 int len);
23 23
24#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
25
24#define flush_dcache_mmap_lock(mapping) do { } while (0) 26#define flush_dcache_mmap_lock(mapping) do { } while (0)
25#define flush_dcache_mmap_unlock(mapping) do { } while (0) 27#define flush_dcache_mmap_unlock(mapping) do { } while (0)
26 28
diff --git a/include/asm-sh64/pgalloc.h b/include/asm-sh64/pgalloc.h
index b29dd468817e..cb803e56cb64 100644
--- a/include/asm-sh64/pgalloc.h
+++ b/include/asm-sh64/pgalloc.h
@@ -41,7 +41,7 @@ static inline void pgd_init(unsigned long page)
41static inline pgd_t *get_pgd_slow(void) 41static inline pgd_t *get_pgd_slow(void)
42{ 42{
43 unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t)); 43 unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t));
44 pgd_t *ret = (pgd_t *)kmalloc(pgd_size, GFP_KERNEL); 44 pgd_t *ret = kmalloc(pgd_size, GFP_KERNEL);
45 return ret; 45 return ret;
46} 46}
47 47
diff --git a/include/asm-sparc/bitops.h b/include/asm-sparc/bitops.h
index 04aa3318f76a..329e696e7751 100644
--- a/include/asm-sparc/bitops.h
+++ b/include/asm-sparc/bitops.h
@@ -14,6 +14,10 @@
14 14
15#ifdef __KERNEL__ 15#ifdef __KERNEL__
16 16
17extern unsigned long ___set_bit(unsigned long *addr, unsigned long mask);
18extern unsigned long ___clear_bit(unsigned long *addr, unsigned long mask);
19extern unsigned long ___change_bit(unsigned long *addr, unsigned long mask);
20
17/* 21/*
18 * Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0' 22 * Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0'
19 * is in the highest of the four bytes and bit '31' is the high bit 23 * is in the highest of the four bytes and bit '31' is the high bit
@@ -22,134 +26,62 @@
22 */ 26 */
23static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *addr) 27static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *addr)
24{ 28{
25 register unsigned long mask asm("g2"); 29 unsigned long *ADDR, mask;
26 register unsigned long *ADDR asm("g1");
27 register int tmp1 asm("g3");
28 register int tmp2 asm("g4");
29 register int tmp3 asm("g5");
30 register int tmp4 asm("g7");
31 30
32 ADDR = ((unsigned long *) addr) + (nr >> 5); 31 ADDR = ((unsigned long *) addr) + (nr >> 5);
33 mask = 1 << (nr & 31); 32 mask = 1 << (nr & 31);
34 33
35 __asm__ __volatile__( 34 return ___set_bit(ADDR, mask) != 0;
36 "mov %%o7, %%g4\n\t"
37 "call ___set_bit\n\t"
38 " add %%o7, 8, %%o7\n"
39 : "=&r" (mask), "=r" (tmp1), "=r" (tmp2), "=r" (tmp3), "=r" (tmp4)
40 : "0" (mask), "r" (ADDR)
41 : "memory", "cc");
42
43 return mask != 0;
44} 35}
45 36
46static inline void set_bit(unsigned long nr, volatile unsigned long *addr) 37static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
47{ 38{
48 register unsigned long mask asm("g2"); 39 unsigned long *ADDR, mask;
49 register unsigned long *ADDR asm("g1");
50 register int tmp1 asm("g3");
51 register int tmp2 asm("g4");
52 register int tmp3 asm("g5");
53 register int tmp4 asm("g7");
54 40
55 ADDR = ((unsigned long *) addr) + (nr >> 5); 41 ADDR = ((unsigned long *) addr) + (nr >> 5);
56 mask = 1 << (nr & 31); 42 mask = 1 << (nr & 31);
57 43
58 __asm__ __volatile__( 44 (void) ___set_bit(ADDR, mask);
59 "mov %%o7, %%g4\n\t"
60 "call ___set_bit\n\t"
61 " add %%o7, 8, %%o7\n"
62 : "=&r" (mask), "=r" (tmp1), "=r" (tmp2), "=r" (tmp3), "=r" (tmp4)
63 : "0" (mask), "r" (ADDR)
64 : "memory", "cc");
65} 45}
66 46
67static inline int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr) 47static inline int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)
68{ 48{
69 register unsigned long mask asm("g2"); 49 unsigned long *ADDR, mask;
70 register unsigned long *ADDR asm("g1");
71 register int tmp1 asm("g3");
72 register int tmp2 asm("g4");
73 register int tmp3 asm("g5");
74 register int tmp4 asm("g7");
75 50
76 ADDR = ((unsigned long *) addr) + (nr >> 5); 51 ADDR = ((unsigned long *) addr) + (nr >> 5);
77 mask = 1 << (nr & 31); 52 mask = 1 << (nr & 31);
78 53
79 __asm__ __volatile__( 54 return ___clear_bit(ADDR, mask) != 0;
80 "mov %%o7, %%g4\n\t"
81 "call ___clear_bit\n\t"
82 " add %%o7, 8, %%o7\n"
83 : "=&r" (mask), "=r" (tmp1), "=r" (tmp2), "=r" (tmp3), "=r" (tmp4)
84 : "0" (mask), "r" (ADDR)
85 : "memory", "cc");
86
87 return mask != 0;
88} 55}
89 56
90static inline void clear_bit(unsigned long nr, volatile unsigned long *addr) 57static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
91{ 58{
92 register unsigned long mask asm("g2"); 59 unsigned long *ADDR, mask;
93 register unsigned long *ADDR asm("g1");
94 register int tmp1 asm("g3");
95 register int tmp2 asm("g4");
96 register int tmp3 asm("g5");
97 register int tmp4 asm("g7");
98 60
99 ADDR = ((unsigned long *) addr) + (nr >> 5); 61 ADDR = ((unsigned long *) addr) + (nr >> 5);
100 mask = 1 << (nr & 31); 62 mask = 1 << (nr & 31);
101 63
102 __asm__ __volatile__( 64 (void) ___clear_bit(ADDR, mask);
103 "mov %%o7, %%g4\n\t"
104 "call ___clear_bit\n\t"
105 " add %%o7, 8, %%o7\n"
106 : "=&r" (mask), "=r" (tmp1), "=r" (tmp2), "=r" (tmp3), "=r" (tmp4)
107 : "0" (mask), "r" (ADDR)
108 : "memory", "cc");
109} 65}
110 66
111static inline int test_and_change_bit(unsigned long nr, volatile unsigned long *addr) 67static inline int test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
112{ 68{
113 register unsigned long mask asm("g2"); 69 unsigned long *ADDR, mask;
114 register unsigned long *ADDR asm("g1");
115 register int tmp1 asm("g3");
116 register int tmp2 asm("g4");
117 register int tmp3 asm("g5");
118 register int tmp4 asm("g7");
119 70
120 ADDR = ((unsigned long *) addr) + (nr >> 5); 71 ADDR = ((unsigned long *) addr) + (nr >> 5);
121 mask = 1 << (nr & 31); 72 mask = 1 << (nr & 31);
122 73
123 __asm__ __volatile__( 74 return ___change_bit(ADDR, mask) != 0;
124 "mov %%o7, %%g4\n\t"
125 "call ___change_bit\n\t"
126 " add %%o7, 8, %%o7\n"
127 : "=&r" (mask), "=r" (tmp1), "=r" (tmp2), "=r" (tmp3), "=r" (tmp4)
128 : "0" (mask), "r" (ADDR)
129 : "memory", "cc");
130
131 return mask != 0;
132} 75}
133 76
134static inline void change_bit(unsigned long nr, volatile unsigned long *addr) 77static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
135{ 78{
136 register unsigned long mask asm("g2"); 79 unsigned long *ADDR, mask;
137 register unsigned long *ADDR asm("g1");
138 register int tmp1 asm("g3");
139 register int tmp2 asm("g4");
140 register int tmp3 asm("g5");
141 register int tmp4 asm("g7");
142 80
143 ADDR = ((unsigned long *) addr) + (nr >> 5); 81 ADDR = ((unsigned long *) addr) + (nr >> 5);
144 mask = 1 << (nr & 31); 82 mask = 1 << (nr & 31);
145 83
146 __asm__ __volatile__( 84 (void) ___change_bit(ADDR, mask);
147 "mov %%o7, %%g4\n\t"
148 "call ___change_bit\n\t"
149 " add %%o7, 8, %%o7\n"
150 : "=&r" (mask), "=r" (tmp1), "=r" (tmp2), "=r" (tmp3), "=r" (tmp4)
151 : "0" (mask), "r" (ADDR)
152 : "memory", "cc");
153} 85}
154 86
155#include <asm-generic/bitops/non-atomic.h> 87#include <asm-generic/bitops/non-atomic.h>
diff --git a/include/asm-sparc/cacheflush.h b/include/asm-sparc/cacheflush.h
index fc632f811cd8..68ac10910271 100644
--- a/include/asm-sparc/cacheflush.h
+++ b/include/asm-sparc/cacheflush.h
@@ -48,6 +48,7 @@ BTFIXUPDEF_CALL(void, flush_cache_page, struct vm_area_struct *, unsigned long)
48 48
49#define flush_cache_all() BTFIXUP_CALL(flush_cache_all)() 49#define flush_cache_all() BTFIXUP_CALL(flush_cache_all)()
50#define flush_cache_mm(mm) BTFIXUP_CALL(flush_cache_mm)(mm) 50#define flush_cache_mm(mm) BTFIXUP_CALL(flush_cache_mm)(mm)
51#define flush_cache_dup_mm(mm) BTFIXUP_CALL(flush_cache_mm)(mm)
51#define flush_cache_range(vma,start,end) BTFIXUP_CALL(flush_cache_range)(vma,start,end) 52#define flush_cache_range(vma,start,end) BTFIXUP_CALL(flush_cache_range)(vma,start,end)
52#define flush_cache_page(vma,addr,pfn) BTFIXUP_CALL(flush_cache_page)(vma,addr) 53#define flush_cache_page(vma,addr,pfn) BTFIXUP_CALL(flush_cache_page)(vma,addr)
53#define flush_icache_range(start, end) do { } while (0) 54#define flush_icache_range(start, end) do { } while (0)
diff --git a/include/asm-sparc64/cacheflush.h b/include/asm-sparc64/cacheflush.h
index 745d1ab60371..122e4058dd9e 100644
--- a/include/asm-sparc64/cacheflush.h
+++ b/include/asm-sparc64/cacheflush.h
@@ -12,6 +12,7 @@
12/* These are the same regardless of whether this is an SMP kernel or not. */ 12/* These are the same regardless of whether this is an SMP kernel or not. */
13#define flush_cache_mm(__mm) \ 13#define flush_cache_mm(__mm) \
14 do { if ((__mm) == current->mm) flushw_user(); } while(0) 14 do { if ((__mm) == current->mm) flushw_user(); } while(0)
15#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
15#define flush_cache_range(vma, start, end) \ 16#define flush_cache_range(vma, start, end) \
16 flush_cache_mm((vma)->vm_mm) 17 flush_cache_mm((vma)->vm_mm)
17#define flush_cache_page(vma, page, pfn) \ 18#define flush_cache_page(vma, page, pfn) \
diff --git a/include/asm-sparc64/hw_irq.h b/include/asm-sparc64/hw_irq.h
index 599b3b073450..8e44a8360829 100644
--- a/include/asm-sparc64/hw_irq.h
+++ b/include/asm-sparc64/hw_irq.h
@@ -1,6 +1,4 @@
1#ifndef __ASM_SPARC64_HW_IRQ_H 1#ifndef __ASM_SPARC64_HW_IRQ_H
2#define __ASM_SPARC64_HW_IRQ_H 2#define __ASM_SPARC64_HW_IRQ_H
3 3
4extern void hw_resend_irq(struct hw_interrupt_type *handler, unsigned int virt_irq);
5
6#endif 4#endif
diff --git a/include/asm-sparc64/percpu.h b/include/asm-sparc64/percpu.h
index ced8cbde046d..0d3df76aa47f 100644
--- a/include/asm-sparc64/percpu.h
+++ b/include/asm-sparc64/percpu.h
@@ -5,6 +5,16 @@
5 5
6#ifdef CONFIG_SMP 6#ifdef CONFIG_SMP
7 7
8#ifdef CONFIG_MODULES
9# define PERCPU_MODULE_RESERVE 8192
10#else
11# define PERCPU_MODULE_RESERVE 0
12#endif
13
14#define PERCPU_ENOUGH_ROOM \
15 (ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES) + \
16 PERCPU_MODULE_RESERVE)
17
8extern void setup_per_cpu_areas(void); 18extern void setup_per_cpu_areas(void);
9 19
10extern unsigned long __per_cpu_base; 20extern unsigned long __per_cpu_base;
diff --git a/include/asm-v850/cacheflush.h b/include/asm-v850/cacheflush.h
index e1a87f82f1a4..9ece05a202ef 100644
--- a/include/asm-v850/cacheflush.h
+++ b/include/asm-v850/cacheflush.h
@@ -24,6 +24,7 @@
24 systems with MMUs, so we don't need them. */ 24 systems with MMUs, so we don't need them. */
25#define flush_cache_all() ((void)0) 25#define flush_cache_all() ((void)0)
26#define flush_cache_mm(mm) ((void)0) 26#define flush_cache_mm(mm) ((void)0)
27#define flush_cache_dup_mm(mm) ((void)0)
27#define flush_cache_range(vma, start, end) ((void)0) 28#define flush_cache_range(vma, start, end) ((void)0)
28#define flush_cache_page(vma, vmaddr, pfn) ((void)0) 29#define flush_cache_page(vma, vmaddr, pfn) ((void)0)
29#define flush_dcache_page(page) ((void)0) 30#define flush_dcache_page(page) ((void)0)
diff --git a/include/asm-x86_64/cacheflush.h b/include/asm-x86_64/cacheflush.h
index d32f7f58752a..ab1cb5c7dc92 100644
--- a/include/asm-x86_64/cacheflush.h
+++ b/include/asm-x86_64/cacheflush.h
@@ -7,6 +7,7 @@
7/* Caches aren't brain-dead on the intel. */ 7/* Caches aren't brain-dead on the intel. */
8#define flush_cache_all() do { } while (0) 8#define flush_cache_all() do { } while (0)
9#define flush_cache_mm(mm) do { } while (0) 9#define flush_cache_mm(mm) do { } while (0)
10#define flush_cache_dup_mm(mm) do { } while (0)
10#define flush_cache_range(vma, start, end) do { } while (0) 11#define flush_cache_range(vma, start, end) do { } while (0)
11#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 12#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
12#define flush_dcache_page(page) do { } while (0) 13#define flush_dcache_page(page) do { } while (0)
diff --git a/include/asm-x86_64/thread_info.h b/include/asm-x86_64/thread_info.h
index 787a08114b48..74a6c74397f7 100644
--- a/include/asm-x86_64/thread_info.h
+++ b/include/asm-x86_64/thread_info.h
@@ -122,6 +122,7 @@ static inline struct thread_info *stack_thread_info(void)
122#define TIF_MEMDIE 20 122#define TIF_MEMDIE 20
123#define TIF_DEBUG 21 /* uses debug registers */ 123#define TIF_DEBUG 21 /* uses debug registers */
124#define TIF_IO_BITMAP 22 /* uses I/O bitmap */ 124#define TIF_IO_BITMAP 22 /* uses I/O bitmap */
125#define TIF_FREEZE 23 /* is freezing for suspend */
125 126
126#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 127#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
127#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 128#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
@@ -137,6 +138,7 @@ static inline struct thread_info *stack_thread_info(void)
137#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 138#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
138#define _TIF_DEBUG (1<<TIF_DEBUG) 139#define _TIF_DEBUG (1<<TIF_DEBUG)
139#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP) 140#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP)
141#define _TIF_FREEZE (1<<TIF_FREEZE)
140 142
141/* work to do on interrupt/exception return */ 143/* work to do on interrupt/exception return */
142#define _TIF_WORK_MASK \ 144#define _TIF_WORK_MASK \
diff --git a/include/asm-x86_64/unwind.h b/include/asm-x86_64/unwind.h
index 2f6349e48717..02710f6a4560 100644
--- a/include/asm-x86_64/unwind.h
+++ b/include/asm-x86_64/unwind.h
@@ -1,100 +1,6 @@
1#ifndef _ASM_X86_64_UNWIND_H 1#ifndef _ASM_X86_64_UNWIND_H
2#define _ASM_X86_64_UNWIND_H 2#define _ASM_X86_64_UNWIND_H
3 3
4/*
5 * Copyright (C) 2002-2006 Novell, Inc.
6 * Jan Beulich <jbeulich@novell.com>
7 * This code is released under version 2 of the GNU GPL.
8 */
9
10#ifdef CONFIG_STACK_UNWIND
11
12#include <linux/sched.h>
13#include <asm/ptrace.h>
14#include <asm/uaccess.h>
15#include <asm/vsyscall.h>
16
17struct unwind_frame_info
18{
19 struct pt_regs regs;
20 struct task_struct *task;
21 unsigned call_frame:1;
22};
23
24#define UNW_PC(frame) (frame)->regs.rip
25#define UNW_SP(frame) (frame)->regs.rsp
26#ifdef CONFIG_FRAME_POINTER
27#define UNW_FP(frame) (frame)->regs.rbp
28#define FRAME_RETADDR_OFFSET 8
29#define FRAME_LINK_OFFSET 0
30#define STACK_BOTTOM(tsk) (((tsk)->thread.rsp0 - 1) & ~(THREAD_SIZE - 1))
31#define STACK_TOP(tsk) ((tsk)->thread.rsp0)
32#endif
33/* Might need to account for the special exception and interrupt handling
34 stacks here, since normally
35 EXCEPTION_STACK_ORDER < THREAD_ORDER < IRQSTACK_ORDER,
36 but the construct is needed only for getting across the stack switch to
37 the interrupt stack - thus considering the IRQ stack itself is unnecessary,
38 and the overhead of comparing against all exception handling stacks seems
39 not desirable. */
40#define STACK_LIMIT(ptr) (((ptr) - 1) & ~(THREAD_SIZE - 1))
41
42#define UNW_REGISTER_INFO \
43 PTREGS_INFO(rax), \
44 PTREGS_INFO(rdx), \
45 PTREGS_INFO(rcx), \
46 PTREGS_INFO(rbx), \
47 PTREGS_INFO(rsi), \
48 PTREGS_INFO(rdi), \
49 PTREGS_INFO(rbp), \
50 PTREGS_INFO(rsp), \
51 PTREGS_INFO(r8), \
52 PTREGS_INFO(r9), \
53 PTREGS_INFO(r10), \
54 PTREGS_INFO(r11), \
55 PTREGS_INFO(r12), \
56 PTREGS_INFO(r13), \
57 PTREGS_INFO(r14), \
58 PTREGS_INFO(r15), \
59 PTREGS_INFO(rip)
60
61#define UNW_DEFAULT_RA(raItem, dataAlign) \
62 ((raItem).where == Memory && \
63 !((raItem).value * (dataAlign) + 8))
64
65static inline void arch_unw_init_frame_info(struct unwind_frame_info *info,
66 /*const*/ struct pt_regs *regs)
67{
68 info->regs = *regs;
69}
70
71static inline void arch_unw_init_blocked(struct unwind_frame_info *info)
72{
73 extern const char thread_return[];
74
75 memset(&info->regs, 0, sizeof(info->regs));
76 info->regs.rip = (unsigned long)thread_return;
77 info->regs.cs = __KERNEL_CS;
78 __get_user(info->regs.rbp, (unsigned long *)info->task->thread.rsp);
79 info->regs.rsp = info->task->thread.rsp;
80 info->regs.ss = __KERNEL_DS;
81}
82
83extern int arch_unwind_init_running(struct unwind_frame_info *,
84 int (*callback)(struct unwind_frame_info *,
85 void *arg),
86 void *arg);
87
88static inline int arch_unw_user_mode(const struct unwind_frame_info *info)
89{
90 return user_mode(&info->regs)
91 || (long)info->regs.rip >= 0
92 || (info->regs.rip >= VSYSCALL_START && info->regs.rip < VSYSCALL_END)
93 || (long)info->regs.rsp >= 0;
94}
95
96#else
97
98#define UNW_PC(frame) ((void)(frame), 0UL) 4#define UNW_PC(frame) ((void)(frame), 0UL)
99#define UNW_SP(frame) ((void)(frame), 0UL) 5#define UNW_SP(frame) ((void)(frame), 0UL)
100 6
@@ -103,6 +9,4 @@ static inline int arch_unw_user_mode(const void *info)
103 return 0; 9 return 0;
104} 10}
105 11
106#endif
107
108#endif /* _ASM_X86_64_UNWIND_H */ 12#endif /* _ASM_X86_64_UNWIND_H */
diff --git a/include/asm-xtensa/cacheflush.h b/include/asm-xtensa/cacheflush.h
index 337765b629de..22ef901b7845 100644
--- a/include/asm-xtensa/cacheflush.h
+++ b/include/asm-xtensa/cacheflush.h
@@ -75,6 +75,7 @@ extern void __flush_invalidate_dcache_range(unsigned long, unsigned long);
75 75
76#define flush_cache_all() __flush_invalidate_cache_all(); 76#define flush_cache_all() __flush_invalidate_cache_all();
77#define flush_cache_mm(mm) __flush_invalidate_cache_all(); 77#define flush_cache_mm(mm) __flush_invalidate_cache_all();
78#define flush_cache_dup_mm(mm) __flush_invalidate_cache_all();
78 79
79#define flush_cache_vmap(start,end) __flush_invalidate_cache_all(); 80#define flush_cache_vmap(start,end) __flush_invalidate_cache_all();
80#define flush_cache_vunmap(start,end) __flush_invalidate_cache_all(); 81#define flush_cache_vunmap(start,end) __flush_invalidate_cache_all();
@@ -88,6 +89,7 @@ extern void flush_cache_page(struct vm_area_struct*, unsigned long, unsigned lon
88 89
89#define flush_cache_all() do { } while (0) 90#define flush_cache_all() do { } while (0)
90#define flush_cache_mm(mm) do { } while (0) 91#define flush_cache_mm(mm) do { } while (0)
92#define flush_cache_dup_mm(mm) do { } while (0)
91 93
92#define flush_cache_vmap(start,end) do { } while (0) 94#define flush_cache_vmap(start,end) do { } while (0)
93#define flush_cache_vunmap(start,end) do { } while (0) 95#define flush_cache_vunmap(start,end) do { } while (0)
diff --git a/include/asm-xtensa/termbits.h b/include/asm-xtensa/termbits.h
index c780593ff5f9..057b9a3d8f83 100644
--- a/include/asm-xtensa/termbits.h
+++ b/include/asm-xtensa/termbits.h
@@ -30,6 +30,17 @@ struct termios {
30 cc_t c_cc[NCCS]; /* control characters */ 30 cc_t c_cc[NCCS]; /* control characters */
31}; 31};
32 32
33struct ktermios {
34 tcflag_t c_iflag; /* input mode flags */
35 tcflag_t c_oflag; /* output mode flags */
36 tcflag_t c_cflag; /* control mode flags */
37 tcflag_t c_lflag; /* local mode flags */
38 cc_t c_line; /* line discipline */
39 cc_t c_cc[NCCS]; /* control characters */
40 speed_t c_ispeed; /* input speed */
41 speed_t c_ospeed; /* output speed */
42};
43
33/* c_cc characters */ 44/* c_cc characters */
34 45
35#define VINTR 0 46#define VINTR 0
diff --git a/include/asm-xtensa/uaccess.h b/include/asm-xtensa/uaccess.h
index 88a64e1144d5..d6352da05b10 100644
--- a/include/asm-xtensa/uaccess.h
+++ b/include/asm-xtensa/uaccess.h
@@ -23,7 +23,6 @@
23 23
24#ifdef __ASSEMBLY__ 24#ifdef __ASSEMBLY__
25 25
26#define _ASMLANGUAGE
27#include <asm/current.h> 26#include <asm/current.h>
28#include <asm/asm-offsets.h> 27#include <asm/asm-offsets.h>
29#include <asm/processor.h> 28#include <asm/processor.h>
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 3372ec6bf53a..a30ef13c9e62 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -105,6 +105,7 @@ struct kiocb {
105 wait_queue_t ki_wait; 105 wait_queue_t ki_wait;
106 loff_t ki_pos; 106 loff_t ki_pos;
107 107
108 atomic_t ki_bio_count; /* num bio used for this iocb */
108 void *private; 109 void *private;
109 /* State that we remember to be able to restart/retry */ 110 /* State that we remember to be able to restart/retry */
110 unsigned short ki_opcode; 111 unsigned short ki_opcode;
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 092dbd0e7658..08daf3272c02 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -309,6 +309,7 @@ extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int,
309 gfp_t); 309 gfp_t);
310extern void bio_set_pages_dirty(struct bio *bio); 310extern void bio_set_pages_dirty(struct bio *bio);
311extern void bio_check_pages_dirty(struct bio *bio); 311extern void bio_check_pages_dirty(struct bio *bio);
312extern void bio_release_pages(struct bio *bio);
312extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int); 313extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int);
313extern int bio_uncopy_user(struct bio *); 314extern int bio_uncopy_user(struct bio *);
314void zero_fill_bio(struct bio *bio); 315void zero_fill_bio(struct bio *bio);
diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h
index be512cc98791..4c2632a8d31b 100644
--- a/include/linux/coda_linux.h
+++ b/include/linux/coda_linux.h
@@ -64,7 +64,7 @@ void coda_sysctl_clean(void);
64 64
65#define CODA_ALLOC(ptr, cast, size) do { \ 65#define CODA_ALLOC(ptr, cast, size) do { \
66 if (size < PAGE_SIZE) \ 66 if (size < PAGE_SIZE) \
67 ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \ 67 ptr = kmalloc((unsigned long) size, GFP_KERNEL); \
68 else \ 68 else \
69 ptr = (cast)vmalloc((unsigned long) size); \ 69 ptr = (cast)vmalloc((unsigned long) size); \
70 if (!ptr) \ 70 if (!ptr) \
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 8821e1f75b44..826b15e914e2 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -30,10 +30,19 @@ void cpuset_update_task_memory_state(void);
30 nodes_subset((nodes), current->mems_allowed) 30 nodes_subset((nodes), current->mems_allowed)
31int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl); 31int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl);
32 32
33extern int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask); 33extern int __cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask);
34static int inline cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) 34extern int __cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask);
35
36static int inline cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
37{
38 return number_of_cpusets <= 1 ||
39 __cpuset_zone_allowed_softwall(z, gfp_mask);
40}
41
42static int inline cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
35{ 43{
36 return number_of_cpusets <= 1 || __cpuset_zone_allowed(z, gfp_mask); 44 return number_of_cpusets <= 1 ||
45 __cpuset_zone_allowed_hardwall(z, gfp_mask);
37} 46}
38 47
39extern int cpuset_excl_nodes_overlap(const struct task_struct *p); 48extern int cpuset_excl_nodes_overlap(const struct task_struct *p);
@@ -94,7 +103,12 @@ static inline int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl)
94 return 1; 103 return 1;
95} 104}
96 105
97static inline int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) 106static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
107{
108 return 1;
109}
110
111static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
98{ 112{
99 return 1; 113 return 1;
100} 114}
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 6fe56aaa6685..64177ec9a019 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -929,8 +929,6 @@ extern void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max)
929#define FB_MODE_IS_FIRST 16 929#define FB_MODE_IS_FIRST 16
930#define FB_MODE_IS_FROM_VAR 32 930#define FB_MODE_IS_FROM_VAR 32
931 931
932extern int fbmon_valid_timings(u_int pixclock, u_int htotal, u_int vtotal,
933 const struct fb_info *fb_info);
934extern int fbmon_dpms(const struct fb_info *fb_info); 932extern int fbmon_dpms(const struct fb_info *fb_info);
935extern int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var, 933extern int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var,
936 struct fb_info *info); 934 struct fb_info *info);
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index 393063096134..5e75e26d4787 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -16,16 +16,15 @@ static inline int frozen(struct task_struct *p)
16 */ 16 */
17static inline int freezing(struct task_struct *p) 17static inline int freezing(struct task_struct *p)
18{ 18{
19 return p->flags & PF_FREEZE; 19 return test_tsk_thread_flag(p, TIF_FREEZE);
20} 20}
21 21
22/* 22/*
23 * Request that a process be frozen 23 * Request that a process be frozen
24 * FIXME: SMP problem. We may not modify other process' flags!
25 */ 24 */
26static inline void freeze(struct task_struct *p) 25static inline void freeze(struct task_struct *p)
27{ 26{
28 p->flags |= PF_FREEZE; 27 set_tsk_thread_flag(p, TIF_FREEZE);
29} 28}
30 29
31/* 30/*
@@ -33,7 +32,7 @@ static inline void freeze(struct task_struct *p)
33 */ 32 */
34static inline void do_not_freeze(struct task_struct *p) 33static inline void do_not_freeze(struct task_struct *p)
35{ 34{
36 p->flags &= ~PF_FREEZE; 35 clear_tsk_thread_flag(p, TIF_FREEZE);
37} 36}
38 37
39/* 38/*
@@ -54,7 +53,9 @@ static inline int thaw_process(struct task_struct *p)
54 */ 53 */
55static inline void frozen_process(struct task_struct *p) 54static inline void frozen_process(struct task_struct *p)
56{ 55{
57 p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN; 56 p->flags |= PF_FROZEN;
57 wmb();
58 clear_tsk_thread_flag(p, TIF_FREEZE);
58} 59}
59 60
60extern void refrigerator(void); 61extern void refrigerator(void);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index adce6e1d70c2..186da813541e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -120,6 +120,7 @@ extern int dir_notify_enable;
120#define MS_PRIVATE (1<<18) /* change to private */ 120#define MS_PRIVATE (1<<18) /* change to private */
121#define MS_SLAVE (1<<19) /* change to slave */ 121#define MS_SLAVE (1<<19) /* change to slave */
122#define MS_SHARED (1<<20) /* change to shared */ 122#define MS_SHARED (1<<20) /* change to shared */
123#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
123#define MS_ACTIVE (1<<30) 124#define MS_ACTIVE (1<<30)
124#define MS_NOUSER (1<<31) 125#define MS_NOUSER (1<<31)
125 126
diff --git a/include/linux/gameport.h b/include/linux/gameport.h
index 2cdba0c23957..afad95272841 100644
--- a/include/linux/gameport.h
+++ b/include/linux/gameport.h
@@ -105,7 +105,7 @@ static inline void gameport_set_phys(struct gameport *gameport,
105 105
106static inline struct gameport *gameport_allocate_port(void) 106static inline struct gameport *gameport_allocate_port(void)
107{ 107{
108 struct gameport *gameport = kcalloc(1, sizeof(struct gameport), GFP_KERNEL); 108 struct gameport *gameport = kzalloc(sizeof(struct gameport), GFP_KERNEL);
109 109
110 return gameport; 110 return gameport;
111} 111}
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 3d8768b619e9..ca9a602cffd7 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -96,7 +96,10 @@ static inline void memclear_highpage_flush(struct page *page, unsigned int offse
96 kunmap_atomic(kaddr, KM_USER0); 96 kunmap_atomic(kaddr, KM_USER0);
97} 97}
98 98
99static inline void copy_user_highpage(struct page *to, struct page *from, unsigned long vaddr) 99#ifndef __HAVE_ARCH_COPY_USER_HIGHPAGE
100
101static inline void copy_user_highpage(struct page *to, struct page *from,
102 unsigned long vaddr, struct vm_area_struct *vma)
100{ 103{
101 char *vfrom, *vto; 104 char *vfrom, *vto;
102 105
@@ -109,6 +112,8 @@ static inline void copy_user_highpage(struct page *to, struct page *from, unsign
109 smp_wmb(); 112 smp_wmb();
110} 113}
111 114
115#endif
116
112static inline void copy_highpage(struct page *to, struct page *from) 117static inline void copy_highpage(struct page *to, struct page *from)
113{ 118{
114 char *vfrom, *vto; 119 char *vfrom, *vto;
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 7ae3c3326643..d38778f2fbec 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -142,7 +142,6 @@
142#define I2C_DRIVERID_MTP008 1023 142#define I2C_DRIVERID_MTP008 1023
143#define I2C_DRIVERID_DS1621 1024 143#define I2C_DRIVERID_DS1621 1024
144#define I2C_DRIVERID_ADM1024 1025 144#define I2C_DRIVERID_ADM1024 1025
145#define I2C_DRIVERID_IT87 1026
146#define I2C_DRIVERID_CH700X 1027 /* single driver for CH7003-7009 digital pc to tv encoders */ 145#define I2C_DRIVERID_CH700X 1027 /* single driver for CH7003-7009 digital pc to tv encoders */
147#define I2C_DRIVERID_FSCPOS 1028 146#define I2C_DRIVERID_FSCPOS 1028
148#define I2C_DRIVERID_FSCSCY 1029 147#define I2C_DRIVERID_FSCSCY 1029
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index b5315150199e..6383d2d83bb0 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -75,7 +75,6 @@ extern struct nsproxy init_nsproxy;
75 .pid_ns = &init_pid_ns, \ 75 .pid_ns = &init_pid_ns, \
76 .count = ATOMIC_INIT(1), \ 76 .count = ATOMIC_INIT(1), \
77 .nslock = __SPIN_LOCK_UNLOCKED(nsproxy.nslock), \ 77 .nslock = __SPIN_LOCK_UNLOCKED(nsproxy.nslock), \
78 .id = 0, \
79 .uts_ns = &init_uts_ns, \ 78 .uts_ns = &init_uts_ns, \
80 .mnt_ns = NULL, \ 79 .mnt_ns = NULL, \
81 INIT_IPC_NS(ipc_ns) \ 80 INIT_IPC_NS(ipc_ns) \
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
index aa50d89eacd7..246de1d84a26 100644
--- a/include/linux/lockd/bind.h
+++ b/include/linux/lockd/bind.h
@@ -23,7 +23,7 @@ struct svc_rqst;
23 * This is the set of functions for lockd->nfsd communication 23 * This is the set of functions for lockd->nfsd communication
24 */ 24 */
25struct nlmsvc_binding { 25struct nlmsvc_binding {
26 u32 (*fopen)(struct svc_rqst *, 26 __be32 (*fopen)(struct svc_rqst *,
27 struct nfs_fh *, 27 struct nfs_fh *,
28 struct file **); 28 struct file **);
29 void (*fclose)(struct file *); 29 void (*fclose)(struct file *);
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 0c962b82a9de..ac25b5649c59 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -191,7 +191,7 @@ __be32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *);
191unsigned long nlmsvc_retry_blocked(void); 191unsigned long nlmsvc_retry_blocked(void);
192void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *, 192void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
193 nlm_host_match_fn_t match); 193 nlm_host_match_fn_t match);
194void nlmsvc_grant_reply(struct nlm_cookie *, u32); 194void nlmsvc_grant_reply(struct nlm_cookie *, __be32);
195 195
196/* 196/*
197 * File handling for the server personality 197 * File handling for the server personality
diff --git a/include/linux/lockd/sm_inter.h b/include/linux/lockd/sm_inter.h
index fc61d40964da..22a645828f26 100644
--- a/include/linux/lockd/sm_inter.h
+++ b/include/linux/lockd/sm_inter.h
@@ -24,7 +24,7 @@
24 * Arguments for all calls to statd 24 * Arguments for all calls to statd
25 */ 25 */
26struct nsm_args { 26struct nsm_args {
27 u32 addr; /* remote address */ 27 __be32 addr; /* remote address */
28 u32 prog; /* RPC callback info */ 28 u32 prog; /* RPC callback info */
29 u32 vers; 29 u32 vers;
30 u32 proc; 30 u32 proc;
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h
index 29e7d9fc9dad..83a1f9f6237b 100644
--- a/include/linux/lockd/xdr.h
+++ b/include/linux/lockd/xdr.h
@@ -69,7 +69,7 @@ typedef struct nlm_args nlm_args;
69 */ 69 */
70struct nlm_res { 70struct nlm_res {
71 struct nlm_cookie cookie; 71 struct nlm_cookie cookie;
72 u32 status; 72 __be32 status;
73 struct nlm_lock lock; 73 struct nlm_lock lock;
74}; 74};
75 75
@@ -80,9 +80,9 @@ struct nlm_reboot {
80 char * mon; 80 char * mon;
81 int len; 81 int len;
82 u32 state; 82 u32 state;
83 u32 addr; 83 __be32 addr;
84 u32 vers; 84 __be32 vers;
85 u32 proto; 85 __be32 proto;
86}; 86};
87 87
88/* 88/*
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 498bfbd3b4e1..ea097dddc44f 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -281,15 +281,25 @@ struct lock_class_key { };
281#if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS) 281#if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS)
282extern void early_init_irq_lock_class(void); 282extern void early_init_irq_lock_class(void);
283#else 283#else
284# define early_init_irq_lock_class() do { } while (0) 284static inline void early_init_irq_lock_class(void)
285{
286}
285#endif 287#endif
286 288
287#ifdef CONFIG_TRACE_IRQFLAGS 289#ifdef CONFIG_TRACE_IRQFLAGS
288extern void early_boot_irqs_off(void); 290extern void early_boot_irqs_off(void);
289extern void early_boot_irqs_on(void); 291extern void early_boot_irqs_on(void);
292extern void print_irqtrace_events(struct task_struct *curr);
290#else 293#else
291# define early_boot_irqs_off() do { } while (0) 294static inline void early_boot_irqs_off(void)
292# define early_boot_irqs_on() do { } while (0) 295{
296}
297static inline void early_boot_irqs_on(void)
298{
299}
300static inline void print_irqtrace_events(struct task_struct *curr)
301{
302}
293#endif 303#endif
294 304
295/* 305/*
diff --git a/include/linux/mount.h b/include/linux/mount.h
index e357dc86a4de..1b7e178b0d84 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -27,6 +27,7 @@ struct mnt_namespace;
27#define MNT_NOEXEC 0x04 27#define MNT_NOEXEC 0x04
28#define MNT_NOATIME 0x08 28#define MNT_NOATIME 0x08
29#define MNT_NODIRATIME 0x10 29#define MNT_NODIRATIME 0x10
30#define MNT_RELATIME 0x20
30 31
31#define MNT_SHRINKABLE 0x100 32#define MNT_SHRINKABLE 0x100
32 33
diff --git a/include/linux/n_r3964.h b/include/linux/n_r3964.h
index db4f3776978a..de24af79ebd3 100644
--- a/include/linux/n_r3964.h
+++ b/include/linux/n_r3964.h
@@ -116,7 +116,7 @@ struct r3964_message;
116 116
117struct r3964_client_info { 117struct r3964_client_info {
118 spinlock_t lock; 118 spinlock_t lock;
119 pid_t pid; 119 struct pid *pid;
120 unsigned int sig_flags; 120 unsigned int sig_flags;
121 121
122 struct r3964_client_info *next; 122 struct r3964_client_info *next;
diff --git a/include/linux/ncp_mount.h b/include/linux/ncp_mount.h
index f46bddcdbd3b..a2b549eb1eca 100644
--- a/include/linux/ncp_mount.h
+++ b/include/linux/ncp_mount.h
@@ -75,7 +75,7 @@ struct ncp_mount_data_kernel {
75 unsigned int int_flags; /* internal flags */ 75 unsigned int int_flags; /* internal flags */
76#define NCP_IMOUNT_LOGGEDIN_POSSIBLE 0x0001 76#define NCP_IMOUNT_LOGGEDIN_POSSIBLE 0x0001
77 __kernel_uid32_t mounted_uid; /* Who may umount() this filesystem? */ 77 __kernel_uid32_t mounted_uid; /* Who may umount() this filesystem? */
78 __kernel_pid_t wdog_pid; /* Who cares for our watchdog packets? */ 78 struct pid *wdog_pid; /* Who cares for our watchdog packets? */
79 unsigned int ncp_fd; /* The socket to the ncp port */ 79 unsigned int ncp_fd; /* The socket to the ncp port */
80 unsigned int time_out; /* How long should I wait after 80 unsigned int time_out; /* How long should I wait after
81 sending a NCP request? */ 81 sending a NCP request? */
diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
index 6c4613f8ad75..55689f39f77a 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -68,7 +68,6 @@ struct bridge_skb_cb {
68 } daddr; 68 } daddr;
69}; 69};
70 70
71extern int brnf_deferred_hooks;
72#else 71#else
73#define nf_bridge_maybe_copy_header(skb) (0) 72#define nf_bridge_maybe_copy_header(skb) (0)
74#define nf_bridge_pad(skb) (0) 73#define nf_bridge_pad(skb) (0)
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h
index 5821eb5a0a3e..ceae87a4c891 100644
--- a/include/linux/netfilter_ipv4.h
+++ b/include/linux/netfilter_ipv4.h
@@ -57,10 +57,8 @@ enum nf_ip_hook_priorities {
57 NF_IP_PRI_RAW = -300, 57 NF_IP_PRI_RAW = -300,
58 NF_IP_PRI_SELINUX_FIRST = -225, 58 NF_IP_PRI_SELINUX_FIRST = -225,
59 NF_IP_PRI_CONNTRACK = -200, 59 NF_IP_PRI_CONNTRACK = -200,
60 NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD = -175,
61 NF_IP_PRI_MANGLE = -150, 60 NF_IP_PRI_MANGLE = -150,
62 NF_IP_PRI_NAT_DST = -100, 61 NF_IP_PRI_NAT_DST = -100,
63 NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50,
64 NF_IP_PRI_FILTER = 0, 62 NF_IP_PRI_FILTER = 0,
65 NF_IP_PRI_NAT_SRC = 100, 63 NF_IP_PRI_NAT_SRC = 100,
66 NF_IP_PRI_SELINUX_LAST = 225, 64 NF_IP_PRI_SELINUX_LAST = 225,
diff --git a/include/linux/netfilter_ipv6.h b/include/linux/netfilter_ipv6.h
index ab81a6dc94ea..66ca8e3100dc 100644
--- a/include/linux/netfilter_ipv6.h
+++ b/include/linux/netfilter_ipv6.h
@@ -62,10 +62,8 @@ enum nf_ip6_hook_priorities {
62 NF_IP6_PRI_CONNTRACK_DEFRAG = -400, 62 NF_IP6_PRI_CONNTRACK_DEFRAG = -400,
63 NF_IP6_PRI_SELINUX_FIRST = -225, 63 NF_IP6_PRI_SELINUX_FIRST = -225,
64 NF_IP6_PRI_CONNTRACK = -200, 64 NF_IP6_PRI_CONNTRACK = -200,
65 NF_IP6_PRI_BRIDGE_SABOTAGE_FORWARD = -175,
66 NF_IP6_PRI_MANGLE = -150, 65 NF_IP6_PRI_MANGLE = -150,
67 NF_IP6_PRI_NAT_DST = -100, 66 NF_IP6_PRI_NAT_DST = -100,
68 NF_IP6_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50,
69 NF_IP6_PRI_FILTER = 0, 67 NF_IP6_PRI_FILTER = 0,
70 NF_IP6_PRI_NAT_SRC = 100, 68 NF_IP6_PRI_NAT_SRC = 100,
71 NF_IP6_PRI_SELINUX_LAST = 225, 69 NF_IP6_PRI_SELINUX_LAST = 225,
diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h
index edb54c3171b3..0727774772ba 100644
--- a/include/linux/nfsd/nfsd.h
+++ b/include/linux/nfsd/nfsd.h
@@ -275,12 +275,12 @@ static inline int is_fsid(struct svc_fh *fh, struct knfsd_fh *reffh)
275 * we might process an operation with side effects, and be unable to 275 * we might process an operation with side effects, and be unable to
276 * tell the client that the operation succeeded. 276 * tell the client that the operation succeeded.
277 * 277 *
278 * COMPOUND_SLACK_SPACE - this is the minimum amount of buffer space 278 * COMPOUND_SLACK_SPACE - this is the minimum bytes of buffer space
279 * needed to encode an "ordinary" _successful_ operation. (GETATTR, 279 * needed to encode an "ordinary" _successful_ operation. (GETATTR,
280 * READ, READDIR, and READLINK have their own buffer checks.) if we 280 * READ, READDIR, and READLINK have their own buffer checks.) if we
281 * fall below this level, we fail the next operation with NFS4ERR_RESOURCE. 281 * fall below this level, we fail the next operation with NFS4ERR_RESOURCE.
282 * 282 *
283 * COMPOUND_ERR_SLACK_SPACE - this is the minimum amount of buffer space 283 * COMPOUND_ERR_SLACK_SPACE - this is the minimum bytes of buffer space
284 * needed to encode an operation which has failed with NFS4ERR_RESOURCE. 284 * needed to encode an operation which has failed with NFS4ERR_RESOURCE.
285 * care is taken to ensure that we never fall below this level for any 285 * care is taken to ensure that we never fall below this level for any
286 * reason. 286 * reason.
diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
index c3673f487e84..ab5c236bd9a7 100644
--- a/include/linux/nfsd/state.h
+++ b/include/linux/nfsd/state.h
@@ -273,7 +273,6 @@ struct nfs4_stateid {
273 ((err) != nfserr_stale_stateid) && \ 273 ((err) != nfserr_stale_stateid) && \
274 ((err) != nfserr_bad_stateid)) 274 ((err) != nfserr_bad_stateid))
275 275
276extern __be32 nfsd4_renew(clientid_t *clid);
277extern __be32 nfs4_preprocess_stateid_op(struct svc_fh *current_fh, 276extern __be32 nfs4_preprocess_stateid_op(struct svc_fh *current_fh,
278 stateid_t *stateid, int flags, struct file **filp); 277 stateid_t *stateid, int flags, struct file **filp);
279extern void nfs4_lock_state(void); 278extern void nfs4_lock_state(void);
diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
index 45ca01b5f844..09799bcee0ac 100644
--- a/include/linux/nfsd/xdr4.h
+++ b/include/linux/nfsd/xdr4.h
@@ -44,6 +44,12 @@
44#define NFSD4_MAX_TAGLEN 128 44#define NFSD4_MAX_TAGLEN 128
45#define XDR_LEN(n) (((n) + 3) & ~3) 45#define XDR_LEN(n) (((n) + 3) & ~3)
46 46
47struct nfsd4_compound_state {
48 struct svc_fh current_fh;
49 struct svc_fh save_fh;
50 struct nfs4_stateowner *replay_owner;
51};
52
47struct nfsd4_change_info { 53struct nfsd4_change_info {
48 u32 atomic; 54 u32 atomic;
49 u32 before_ctime_sec; 55 u32 before_ctime_sec;
@@ -430,35 +436,39 @@ __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
430 struct dentry *dentry, __be32 *buffer, int *countp, 436 struct dentry *dentry, __be32 *buffer, int *countp,
431 u32 *bmval, struct svc_rqst *); 437 u32 *bmval, struct svc_rqst *);
432extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp, 438extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
439 struct nfsd4_compound_state *,
433 struct nfsd4_setclientid *setclid); 440 struct nfsd4_setclientid *setclid);
434extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp, 441extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
442 struct nfsd4_compound_state *,
435 struct nfsd4_setclientid_confirm *setclientid_confirm); 443 struct nfsd4_setclientid_confirm *setclientid_confirm);
436extern __be32 nfsd4_process_open1(struct nfsd4_open *open); 444extern __be32 nfsd4_process_open1(struct nfsd4_open *open);
437extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp, 445extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
438 struct svc_fh *current_fh, struct nfsd4_open *open); 446 struct svc_fh *current_fh, struct nfsd4_open *open);
439extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp, 447extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
440 struct svc_fh *current_fh, struct nfsd4_open_confirm *oc, 448 struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc);
441 struct nfs4_stateowner **); 449extern __be32 nfsd4_close(struct svc_rqst *rqstp,
442extern __be32 nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, 450 struct nfsd4_compound_state *,
443 struct nfsd4_close *close, 451 struct nfsd4_close *close);
444 struct nfs4_stateowner **replay_owner);
445extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp, 452extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
446 struct svc_fh *current_fh, struct nfsd4_open_downgrade *od, 453 struct nfsd4_compound_state *,
447 struct nfs4_stateowner **replay_owner); 454 struct nfsd4_open_downgrade *od);
448extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, 455extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
449 struct nfsd4_lock *lock, 456 struct nfsd4_lock *lock);
450 struct nfs4_stateowner **replay_owner); 457extern __be32 nfsd4_lockt(struct svc_rqst *rqstp,
451extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, 458 struct nfsd4_compound_state *,
452 struct nfsd4_lockt *lockt); 459 struct nfsd4_lockt *lockt);
453extern __be32 nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, 460extern __be32 nfsd4_locku(struct svc_rqst *rqstp,
454 struct nfsd4_locku *locku, 461 struct nfsd4_compound_state *,
455 struct nfs4_stateowner **replay_owner); 462 struct nfsd4_locku *locku);
456extern __be32 463extern __be32
457nfsd4_release_lockowner(struct svc_rqst *rqstp, 464nfsd4_release_lockowner(struct svc_rqst *rqstp,
465 struct nfsd4_compound_state *,
458 struct nfsd4_release_lockowner *rlockowner); 466 struct nfsd4_release_lockowner *rlockowner);
459extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *); 467extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
460extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp, 468extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
461 struct svc_fh *current_fh, struct nfsd4_delegreturn *dr); 469 struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr);
470extern __be32 nfsd4_renew(struct svc_rqst *rqstp,
471 struct nfsd4_compound_state *, clientid_t *clid);
462#endif 472#endif
463 473
464/* 474/*
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h
index fdfb0e44912f..0b9f0dc30d61 100644
--- a/include/linux/nsproxy.h
+++ b/include/linux/nsproxy.h
@@ -24,7 +24,6 @@ struct pid_namespace;
24struct nsproxy { 24struct nsproxy {
25 atomic_t count; 25 atomic_t count;
26 spinlock_t nslock; 26 spinlock_t nslock;
27 unsigned long id;
28 struct uts_namespace *uts_ns; 27 struct uts_namespace *uts_ns;
29 struct ipc_namespace *ipc_ns; 28 struct ipc_namespace *ipc_ns;
30 struct mnt_namespace *mnt_ns; 29 struct mnt_namespace *mnt_ns;
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 51180dba9a98..95c1e74afebc 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2067,6 +2067,10 @@
2067#define PCI_DEVICE_ID_JMICRON_JMB366 0x2366 2067#define PCI_DEVICE_ID_JMICRON_JMB366 0x2366
2068#define PCI_DEVICE_ID_JMICRON_JMB368 0x2368 2068#define PCI_DEVICE_ID_JMICRON_JMB368 0x2368
2069 2069
2070#define PCI_VENDOR_ID_KORENIX 0x1982
2071#define PCI_DEVICE_ID_KORENIX_JETCARDF0 0x1600
2072#define PCI_DEVICE_ID_KORENIX_JETCARDF1 0x16ff
2073
2070#define PCI_VENDOR_ID_TEKRAM 0x1de1 2074#define PCI_VENDOR_ID_TEKRAM 0x1de1
2071#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 2075#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29
2072 2076
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index ea4f7cd7bfd8..2e19478e9e84 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -12,7 +12,7 @@
12struct pipe_buffer { 12struct pipe_buffer {
13 struct page *page; 13 struct page *page;
14 unsigned int offset, len; 14 unsigned int offset, len;
15 struct pipe_buf_operations *ops; 15 const struct pipe_buf_operations *ops;
16 unsigned int flags; 16 unsigned int flags;
17}; 17};
18 18
@@ -41,9 +41,7 @@ struct pipe_buf_operations {
41struct pipe_inode_info { 41struct pipe_inode_info {
42 wait_queue_head_t wait; 42 wait_queue_head_t wait;
43 unsigned int nrbufs, curbuf; 43 unsigned int nrbufs, curbuf;
44 struct pipe_buffer bufs[PIPE_BUFFERS];
45 struct page *tmp_page; 44 struct page *tmp_page;
46 unsigned int start;
47 unsigned int readers; 45 unsigned int readers;
48 unsigned int writers; 46 unsigned int writers;
49 unsigned int waiting_writers; 47 unsigned int waiting_writers;
@@ -52,6 +50,7 @@ struct pipe_inode_info {
52 struct fasync_struct *fasync_readers; 50 struct fasync_struct *fasync_readers;
53 struct fasync_struct *fasync_writers; 51 struct fasync_struct *fasync_writers;
54 struct inode *inode; 52 struct inode *inode;
53 struct pipe_buffer bufs[PIPE_BUFFERS];
55}; 54};
56 55
57/* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual 56/* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 20f47b81d3fa..8bbd459eafdc 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -39,7 +39,7 @@ extern struct platform_device *platform_device_register_simple(char *, unsigned
39 39
40extern struct platform_device *platform_device_alloc(const char *name, unsigned int id); 40extern struct platform_device *platform_device_alloc(const char *name, unsigned int id);
41extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); 41extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num);
42extern int platform_device_add_data(struct platform_device *pdev, void *data, size_t size); 42extern int platform_device_add_data(struct platform_device *pdev, const void *data, size_t size);
43extern int platform_device_add(struct platform_device *pdev); 43extern int platform_device_add(struct platform_device *pdev);
44extern void platform_device_del(struct platform_device *pdev); 44extern void platform_device_del(struct platform_device *pdev);
45extern void platform_device_put(struct platform_device *pdev); 45extern void platform_device_put(struct platform_device *pdev);
diff --git a/include/linux/reciprocal_div.h b/include/linux/reciprocal_div.h
new file mode 100644
index 000000000000..f9c90b33285b
--- /dev/null
+++ b/include/linux/reciprocal_div.h
@@ -0,0 +1,32 @@
1#ifndef _LINUX_RECIPROCAL_DIV_H
2#define _LINUX_RECIPROCAL_DIV_H
3
4#include <linux/types.h>
5
6/*
7 * This file describes reciprocical division.
8 *
9 * This optimizes the (A/B) problem, when A and B are two u32
10 * and B is a known value (but not known at compile time)
11 *
12 * The math principle used is :
13 * Let RECIPROCAL_VALUE(B) be (((1LL << 32) + (B - 1))/ B)
14 * Then A / B = (u32)(((u64)(A) * (R)) >> 32)
15 *
16 * This replaces a divide by a multiply (and a shift), and
17 * is generally less expensive in CPU cycles.
18 */
19
20/*
21 * Computes the reciprocal value (R) for the value B of the divisor.
22 * Should not be called before each reciprocal_divide(),
23 * or else the performance is slower than a normal divide.
24 */
25extern u32 reciprocal_value(u32 B);
26
27
28static inline u32 reciprocal_divide(u32 A, u32 R)
29{
30 return (u32)(((u64)A * R) >> 32);
31}
32#endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index ea92e5c89089..446373535190 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1144,7 +1144,6 @@ static inline void put_task_struct(struct task_struct *t)
1144#define PF_MEMALLOC 0x00000800 /* Allocating memory */ 1144#define PF_MEMALLOC 0x00000800 /* Allocating memory */
1145#define PF_FLUSHER 0x00001000 /* responsible for disk writeback */ 1145#define PF_FLUSHER 0x00001000 /* responsible for disk writeback */
1146#define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */ 1146#define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */
1147#define PF_FREEZE 0x00004000 /* this task is being frozen for suspend now */
1148#define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */ 1147#define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */
1149#define PF_FROZEN 0x00010000 /* frozen for system suspend */ 1148#define PF_FROZEN 0x00010000 /* frozen for system suspend */
1150#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */ 1149#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 2271886744f8..1ef822e31c77 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -1,7 +1,9 @@
1/* 1/*
2 * linux/include/linux/slab.h 2 * Written by Mark Hemment, 1996 (markhe@nextd.demon.co.uk).
3 * Written by Mark Hemment, 1996. 3 *
4 * (markhe@nextd.demon.co.uk) 4 * (C) SGI 2006, Christoph Lameter <clameter@sgi.com>
5 * Cleaned up and restructured to ease the addition of alternative
6 * implementations of SLAB allocators.
5 */ 7 */
6 8
7#ifndef _LINUX_SLAB_H 9#ifndef _LINUX_SLAB_H
@@ -10,64 +12,95 @@
10#ifdef __KERNEL__ 12#ifdef __KERNEL__
11 13
12#include <linux/gfp.h> 14#include <linux/gfp.h>
13#include <linux/init.h>
14#include <linux/types.h> 15#include <linux/types.h>
15#include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */
16#include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */
17#include <linux/compiler.h>
18 16
19/* kmem_cache_t exists for legacy reasons and is not used by code in mm */
20typedef struct kmem_cache kmem_cache_t __deprecated; 17typedef struct kmem_cache kmem_cache_t __deprecated;
21 18
22/* flags to pass to kmem_cache_create(). 19/*
23 * The first 3 are only valid when the allocator as been build 20 * Flags to pass to kmem_cache_create().
24 * SLAB_DEBUG_SUPPORT. 21 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
25 */ 22 */
26#define SLAB_DEBUG_FREE 0x00000100UL /* Peform (expensive) checks on free */ 23#define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
27#define SLAB_DEBUG_INITIAL 0x00000200UL /* Call constructor (as verifier) */ 24#define SLAB_DEBUG_INITIAL 0x00000200UL /* DEBUG: Call constructor (as verifier) */
28#define SLAB_RED_ZONE 0x00000400UL /* Red zone objs in a cache */ 25#define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
29#define SLAB_POISON 0x00000800UL /* Poison objects */ 26#define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
30#define SLAB_HWCACHE_ALIGN 0x00002000UL /* align objs on a h/w cache lines */ 27#define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
31#define SLAB_CACHE_DMA 0x00004000UL /* use GFP_DMA memory */ 28#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
32#define SLAB_MUST_HWCACHE_ALIGN 0x00008000UL /* force alignment */ 29#define SLAB_MUST_HWCACHE_ALIGN 0x00008000UL /* Force alignment even if debuggin is active */
33#define SLAB_STORE_USER 0x00010000UL /* store the last owner for bug hunting */ 30#define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
34#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* track pages allocated to indicate 31#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */
35 what is reclaimable later*/ 32#define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */
36#define SLAB_PANIC 0x00040000UL /* panic if kmem_cache_create() fails */ 33#define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */
37#define SLAB_DESTROY_BY_RCU 0x00080000UL /* defer freeing pages to RCU */
38#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ 34#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */
39 35
40/* flags passed to a constructor func */ 36/* Flags passed to a constructor functions */
41#define SLAB_CTOR_CONSTRUCTOR 0x001UL /* if not set, then deconstructor */ 37#define SLAB_CTOR_CONSTRUCTOR 0x001UL /* If not set, then deconstructor */
42#define SLAB_CTOR_ATOMIC 0x002UL /* tell constructor it can't sleep */ 38#define SLAB_CTOR_ATOMIC 0x002UL /* Tell constructor it can't sleep */
43#define SLAB_CTOR_VERIFY 0x004UL /* tell constructor it's a verify call */ 39#define SLAB_CTOR_VERIFY 0x004UL /* Tell constructor it's a verify call */
44 40
45#ifndef CONFIG_SLOB 41/*
46 42 * struct kmem_cache related prototypes
47/* prototypes */ 43 */
48extern void __init kmem_cache_init(void); 44void __init kmem_cache_init(void);
45extern int slab_is_available(void);
49 46
50extern struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, 47struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
51 unsigned long, 48 unsigned long,
52 void (*)(void *, struct kmem_cache *, unsigned long), 49 void (*)(void *, struct kmem_cache *, unsigned long),
53 void (*)(void *, struct kmem_cache *, unsigned long)); 50 void (*)(void *, struct kmem_cache *, unsigned long));
54extern void kmem_cache_destroy(struct kmem_cache *); 51void kmem_cache_destroy(struct kmem_cache *);
55extern int kmem_cache_shrink(struct kmem_cache *); 52int kmem_cache_shrink(struct kmem_cache *);
56extern void *kmem_cache_alloc(struct kmem_cache *, gfp_t); 53void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
57extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); 54void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
58extern void kmem_cache_free(struct kmem_cache *, void *); 55void kmem_cache_free(struct kmem_cache *, void *);
59extern unsigned int kmem_cache_size(struct kmem_cache *); 56unsigned int kmem_cache_size(struct kmem_cache *);
60extern const char *kmem_cache_name(struct kmem_cache *); 57const char *kmem_cache_name(struct kmem_cache *);
58int kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr);
59
60#ifdef CONFIG_NUMA
61extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
62#else
63static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
64 gfp_t flags, int node)
65{
66 return kmem_cache_alloc(cachep, flags);
67}
68#endif
69
70/*
71 * Common kmalloc functions provided by all allocators
72 */
73void *__kmalloc(size_t, gfp_t);
74void *__kzalloc(size_t, gfp_t);
75void kfree(const void *);
76unsigned int ksize(const void *);
77
78/**
79 * kcalloc - allocate memory for an array. The memory is set to zero.
80 * @n: number of elements.
81 * @size: element size.
82 * @flags: the type of memory to allocate.
83 */
84static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
85{
86 if (n != 0 && size > ULONG_MAX / n)
87 return NULL;
88 return __kzalloc(n * size, flags);
89}
61 90
62/* Size description struct for general caches. */ 91/*
63struct cache_sizes { 92 * Allocator specific definitions. These are mainly used to establish optimized
64 size_t cs_size; 93 * ways to convert kmalloc() calls to kmem_cache_alloc() invocations by selecting
65 struct kmem_cache *cs_cachep; 94 * the appropriate general cache at compile time.
66 struct kmem_cache *cs_dmacachep; 95 */
67};
68extern struct cache_sizes malloc_sizes[];
69 96
70extern void *__kmalloc(size_t, gfp_t); 97#ifdef CONFIG_SLAB
98#include <linux/slab_def.h>
99#else
100/*
101 * Fallback definitions for an allocator not wanting to provide
102 * its own optimized kmalloc definitions (like SLOB).
103 */
71 104
72/** 105/**
73 * kmalloc - allocate memory 106 * kmalloc - allocate memory
@@ -116,46 +149,9 @@ extern void *__kmalloc(size_t, gfp_t);
116 */ 149 */
117static inline void *kmalloc(size_t size, gfp_t flags) 150static inline void *kmalloc(size_t size, gfp_t flags)
118{ 151{
119 if (__builtin_constant_p(size)) {
120 int i = 0;
121#define CACHE(x) \
122 if (size <= x) \
123 goto found; \
124 else \
125 i++;
126#include "kmalloc_sizes.h"
127#undef CACHE
128 {
129 extern void __you_cannot_kmalloc_that_much(void);
130 __you_cannot_kmalloc_that_much();
131 }
132found:
133 return kmem_cache_alloc((flags & GFP_DMA) ?
134 malloc_sizes[i].cs_dmacachep :
135 malloc_sizes[i].cs_cachep, flags);
136 }
137 return __kmalloc(size, flags); 152 return __kmalloc(size, flags);
138} 153}
139 154
140/*
141 * kmalloc_track_caller is a special version of kmalloc that records the
142 * calling function of the routine calling it for slab leak tracking instead
143 * of just the calling function (confusing, eh?).
144 * It's useful when the call to kmalloc comes from a widely-used standard
145 * allocator where we care about the real place the memory allocation
146 * request comes from.
147 */
148#ifndef CONFIG_DEBUG_SLAB
149#define kmalloc_track_caller(size, flags) \
150 __kmalloc(size, flags)
151#else
152extern void *__kmalloc_track_caller(size_t, gfp_t, void*);
153#define kmalloc_track_caller(size, flags) \
154 __kmalloc_track_caller(size, flags, __builtin_return_address(0))
155#endif
156
157extern void *__kzalloc(size_t, gfp_t);
158
159/** 155/**
160 * kzalloc - allocate memory. The memory is set to zero. 156 * kzalloc - allocate memory. The memory is set to zero.
161 * @size: how many bytes of memory are required. 157 * @size: how many bytes of memory are required.
@@ -163,72 +159,41 @@ extern void *__kzalloc(size_t, gfp_t);
163 */ 159 */
164static inline void *kzalloc(size_t size, gfp_t flags) 160static inline void *kzalloc(size_t size, gfp_t flags)
165{ 161{
166 if (__builtin_constant_p(size)) {
167 int i = 0;
168#define CACHE(x) \
169 if (size <= x) \
170 goto found; \
171 else \
172 i++;
173#include "kmalloc_sizes.h"
174#undef CACHE
175 {
176 extern void __you_cannot_kzalloc_that_much(void);
177 __you_cannot_kzalloc_that_much();
178 }
179found:
180 return kmem_cache_zalloc((flags & GFP_DMA) ?
181 malloc_sizes[i].cs_dmacachep :
182 malloc_sizes[i].cs_cachep, flags);
183 }
184 return __kzalloc(size, flags); 162 return __kzalloc(size, flags);
185} 163}
164#endif
186 165
187/** 166#ifndef CONFIG_NUMA
188 * kcalloc - allocate memory for an array. The memory is set to zero. 167static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
189 * @n: number of elements.
190 * @size: element size.
191 * @flags: the type of memory to allocate.
192 */
193static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
194{ 168{
195 if (n != 0 && size > ULONG_MAX / n) 169 return kmalloc(size, flags);
196 return NULL;
197 return kzalloc(n * size, flags);
198} 170}
199 171
200extern void kfree(const void *); 172static inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
201extern unsigned int ksize(const void *);
202extern int slab_is_available(void);
203
204#ifdef CONFIG_NUMA
205extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
206extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
207
208static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
209{ 173{
210 if (__builtin_constant_p(size)) { 174 return __kmalloc(size, flags);
211 int i = 0;
212#define CACHE(x) \
213 if (size <= x) \
214 goto found; \
215 else \
216 i++;
217#include "kmalloc_sizes.h"
218#undef CACHE
219 {
220 extern void __you_cannot_kmalloc_that_much(void);
221 __you_cannot_kmalloc_that_much();
222 }
223found:
224 return kmem_cache_alloc_node((flags & GFP_DMA) ?
225 malloc_sizes[i].cs_dmacachep :
226 malloc_sizes[i].cs_cachep, flags, node);
227 }
228 return __kmalloc_node(size, flags, node);
229} 175}
176#endif /* !CONFIG_NUMA */
230 177
231/* 178/*
179 * kmalloc_track_caller is a special version of kmalloc that records the
180 * calling function of the routine calling it for slab leak tracking instead
181 * of just the calling function (confusing, eh?).
182 * It's useful when the call to kmalloc comes from a widely-used standard
183 * allocator where we care about the real place the memory allocation
184 * request comes from.
185 */
186#ifdef CONFIG_DEBUG_SLAB
187extern void *__kmalloc_track_caller(size_t, gfp_t, void*);
188#define kmalloc_track_caller(size, flags) \
189 __kmalloc_track_caller(size, flags, __builtin_return_address(0))
190#else
191#define kmalloc_track_caller(size, flags) \
192 __kmalloc(size, flags)
193#endif /* DEBUG_SLAB */
194
195#ifdef CONFIG_NUMA
196/*
232 * kmalloc_node_track_caller is a special version of kmalloc_node that 197 * kmalloc_node_track_caller is a special version of kmalloc_node that
233 * records the calling function of the routine calling it for slab leak 198 * records the calling function of the routine calling it for slab leak
234 * tracking instead of just the calling function (confusing, eh?). 199 * tracking instead of just the calling function (confusing, eh?).
@@ -236,70 +201,23 @@ found:
236 * standard allocator where we care about the real place the memory 201 * standard allocator where we care about the real place the memory
237 * allocation request comes from. 202 * allocation request comes from.
238 */ 203 */
239#ifndef CONFIG_DEBUG_SLAB 204#ifdef CONFIG_DEBUG_SLAB
240#define kmalloc_node_track_caller(size, flags, node) \
241 __kmalloc_node(size, flags, node)
242#else
243extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *); 205extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
244#define kmalloc_node_track_caller(size, flags, node) \ 206#define kmalloc_node_track_caller(size, flags, node) \
245 __kmalloc_node_track_caller(size, flags, node, \ 207 __kmalloc_node_track_caller(size, flags, node, \
246 __builtin_return_address(0)) 208 __builtin_return_address(0))
209#else
210#define kmalloc_node_track_caller(size, flags, node) \
211 __kmalloc_node(size, flags, node)
247#endif 212#endif
213
248#else /* CONFIG_NUMA */ 214#else /* CONFIG_NUMA */
249static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
250 gfp_t flags, int node)
251{
252 return kmem_cache_alloc(cachep, flags);
253}
254static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
255{
256 return kmalloc(size, flags);
257}
258 215
259#define kmalloc_node_track_caller(size, flags, node) \ 216#define kmalloc_node_track_caller(size, flags, node) \
260 kmalloc_track_caller(size, flags) 217 kmalloc_track_caller(size, flags)
261#endif
262 218
263extern int FASTCALL(kmem_cache_reap(int)); 219#endif /* DEBUG_SLAB */
264extern int FASTCALL(kmem_ptr_validate(struct kmem_cache *cachep, void *ptr));
265
266#else /* CONFIG_SLOB */
267
268/* SLOB allocator routines */
269
270void kmem_cache_init(void);
271struct kmem_cache *kmem_cache_create(const char *c, size_t, size_t,
272 unsigned long,
273 void (*)(void *, struct kmem_cache *, unsigned long),
274 void (*)(void *, struct kmem_cache *, unsigned long));
275void kmem_cache_destroy(struct kmem_cache *c);
276void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags);
277void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
278void kmem_cache_free(struct kmem_cache *c, void *b);
279const char *kmem_cache_name(struct kmem_cache *);
280void *kmalloc(size_t size, gfp_t flags);
281void *__kzalloc(size_t size, gfp_t flags);
282void kfree(const void *m);
283unsigned int ksize(const void *m);
284unsigned int kmem_cache_size(struct kmem_cache *c);
285
286static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
287{
288 return __kzalloc(n * size, flags);
289}
290
291#define kmem_cache_shrink(d) (0)
292#define kmem_cache_reap(a)
293#define kmem_ptr_validate(a, b) (0)
294#define kmem_cache_alloc_node(c, f, n) kmem_cache_alloc(c, f)
295#define kmalloc_node(s, f, n) kmalloc(s, f)
296#define kzalloc(s, f) __kzalloc(s, f)
297#define kmalloc_track_caller kmalloc
298
299#define kmalloc_node_track_caller kmalloc_node
300
301#endif /* CONFIG_SLOB */
302 220
303#endif /* __KERNEL__ */ 221#endif /* __KERNEL__ */
304
305#endif /* _LINUX_SLAB_H */ 222#endif /* _LINUX_SLAB_H */
223
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
new file mode 100644
index 000000000000..4b463e66ddea
--- /dev/null
+++ b/include/linux/slab_def.h
@@ -0,0 +1,100 @@
1#ifndef _LINUX_SLAB_DEF_H
2#define _LINUX_SLAB_DEF_H
3
4/*
5 * Definitions unique to the original Linux SLAB allocator.
6 *
7 * What we provide here is a way to optimize the frequent kmalloc
8 * calls in the kernel by selecting the appropriate general cache
9 * if kmalloc was called with a size that can be established at
10 * compile time.
11 */
12
13#include <linux/init.h>
14#include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */
15#include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */
16#include <linux/compiler.h>
17
18/* Size description struct for general caches. */
19struct cache_sizes {
20 size_t cs_size;
21 struct kmem_cache *cs_cachep;
22 struct kmem_cache *cs_dmacachep;
23};
24extern struct cache_sizes malloc_sizes[];
25
26static inline void *kmalloc(size_t size, gfp_t flags)
27{
28 if (__builtin_constant_p(size)) {
29 int i = 0;
30#define CACHE(x) \
31 if (size <= x) \
32 goto found; \
33 else \
34 i++;
35#include "kmalloc_sizes.h"
36#undef CACHE
37 {
38 extern void __you_cannot_kmalloc_that_much(void);
39 __you_cannot_kmalloc_that_much();
40 }
41found:
42 return kmem_cache_alloc((flags & GFP_DMA) ?
43 malloc_sizes[i].cs_dmacachep :
44 malloc_sizes[i].cs_cachep, flags);
45 }
46 return __kmalloc(size, flags);
47}
48
49static inline void *kzalloc(size_t size, gfp_t flags)
50{
51 if (__builtin_constant_p(size)) {
52 int i = 0;
53#define CACHE(x) \
54 if (size <= x) \
55 goto found; \
56 else \
57 i++;
58#include "kmalloc_sizes.h"
59#undef CACHE
60 {
61 extern void __you_cannot_kzalloc_that_much(void);
62 __you_cannot_kzalloc_that_much();
63 }
64found:
65 return kmem_cache_zalloc((flags & GFP_DMA) ?
66 malloc_sizes[i].cs_dmacachep :
67 malloc_sizes[i].cs_cachep, flags);
68 }
69 return __kzalloc(size, flags);
70}
71
72#ifdef CONFIG_NUMA
73extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
74
75static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76{
77 if (__builtin_constant_p(size)) {
78 int i = 0;
79#define CACHE(x) \
80 if (size <= x) \
81 goto found; \
82 else \
83 i++;
84#include "kmalloc_sizes.h"
85#undef CACHE
86 {
87 extern void __you_cannot_kmalloc_that_much(void);
88 __you_cannot_kmalloc_that_much();
89 }
90found:
91 return kmem_cache_alloc_node((flags & GFP_DMA) ?
92 malloc_sizes[i].cs_dmacachep :
93 malloc_sizes[i].cs_cachep, flags, node);
94 }
95 return __kmalloc_node(size, flags, node);
96}
97
98#endif /* CONFIG_NUMA */
99
100#endif /* _LINUX_SLAB_DEF_H */
diff --git a/include/linux/smb_fs_sb.h b/include/linux/smb_fs_sb.h
index 5b4ae2cc445c..3aa97aa4277f 100644
--- a/include/linux/smb_fs_sb.h
+++ b/include/linux/smb_fs_sb.h
@@ -55,7 +55,7 @@ struct smb_sb_info {
55 * generation is incremented. 55 * generation is incremented.
56 */ 56 */
57 unsigned int generation; 57 unsigned int generation;
58 pid_t conn_pid; 58 struct pid *conn_pid;
59 struct smb_conn_opt opt; 59 struct smb_conn_opt opt;
60 wait_queue_head_t conn_wq; 60 wait_queue_head_t conn_wq;
61 int conn_complete; 61 int conn_complete;
diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
index 9df8833670cb..98a1d8cfb73d 100644
--- a/include/linux/sysrq.h
+++ b/include/linux/sysrq.h
@@ -37,23 +37,37 @@ struct sysrq_key_op {
37 37
38#ifdef CONFIG_MAGIC_SYSRQ 38#ifdef CONFIG_MAGIC_SYSRQ
39 39
40extern int sysrq_on(void);
41
42/*
43 * Do not use this one directly:
44 */
45extern int __sysrq_enabled;
46
40/* Generic SysRq interface -- you may call it from any device driver, supplying 47/* Generic SysRq interface -- you may call it from any device driver, supplying
41 * ASCII code of the key, pointer to registers and kbd/tty structs (if they 48 * ASCII code of the key, pointer to registers and kbd/tty structs (if they
42 * are available -- else NULL's). 49 * are available -- else NULL's).
43 */ 50 */
44 51
45void handle_sysrq(int, struct tty_struct *); 52void handle_sysrq(int key, struct tty_struct *tty);
46void __handle_sysrq(int, struct tty_struct *, int check_mask); 53void __handle_sysrq(int key, struct tty_struct *tty, int check_mask);
47int register_sysrq_key(int, struct sysrq_key_op *); 54int register_sysrq_key(int key, struct sysrq_key_op *op);
48int unregister_sysrq_key(int, struct sysrq_key_op *); 55int unregister_sysrq_key(int key, struct sysrq_key_op *op);
49struct sysrq_key_op *__sysrq_get_key_op(int key); 56struct sysrq_key_op *__sysrq_get_key_op(int key);
50 57
51#else 58#else
52 59
60static inline int sysrq_on(void)
61{
62 return 0;
63}
53static inline int __reterr(void) 64static inline int __reterr(void)
54{ 65{
55 return -EINVAL; 66 return -EINVAL;
56} 67}
68static inline void handle_sysrq(int key, struct tty_struct *tty)
69{
70}
57 71
58#define register_sysrq_key(ig,nore) __reterr() 72#define register_sysrq_key(ig,nore) __reterr()
59#define unregister_sysrq_key(ig,nore) __reterr() 73#define unregister_sysrq_key(ig,nore) __reterr()
diff --git a/include/linux/unwind.h b/include/linux/unwind.h
index 749928c161fb..7760860fa170 100644
--- a/include/linux/unwind.h
+++ b/include/linux/unwind.h
@@ -14,63 +14,6 @@
14 14
15struct module; 15struct module;
16 16
17#ifdef CONFIG_STACK_UNWIND
18
19#include <asm/unwind.h>
20
21#ifndef ARCH_UNWIND_SECTION_NAME
22#define ARCH_UNWIND_SECTION_NAME ".eh_frame"
23#endif
24
25/*
26 * Initialize unwind support.
27 */
28extern void unwind_init(void);
29extern void unwind_setup(void);
30
31#ifdef CONFIG_MODULES
32
33extern void *unwind_add_table(struct module *,
34 const void *table_start,
35 unsigned long table_size);
36
37extern void unwind_remove_table(void *handle, int init_only);
38
39#endif
40
41extern int unwind_init_frame_info(struct unwind_frame_info *,
42 struct task_struct *,
43 /*const*/ struct pt_regs *);
44
45/*
46 * Prepare to unwind a blocked task.
47 */
48extern int unwind_init_blocked(struct unwind_frame_info *,
49 struct task_struct *);
50
51/*
52 * Prepare to unwind the currently running thread.
53 */
54extern int unwind_init_running(struct unwind_frame_info *,
55 asmlinkage int (*callback)(struct unwind_frame_info *,
56 void *arg),
57 void *arg);
58
59/*
60 * Unwind to previous to frame. Returns 0 if successful, negative
61 * number in case of an error.
62 */
63extern int unwind(struct unwind_frame_info *);
64
65/*
66 * Unwind until the return pointer is in user-land (or until an error
67 * occurs). Returns 0 if successful, negative number in case of
68 * error.
69 */
70extern int unwind_to_user(struct unwind_frame_info *);
71
72#else
73
74struct unwind_frame_info {}; 17struct unwind_frame_info {};
75 18
76static inline void unwind_init(void) {} 19static inline void unwind_init(void) {}
@@ -85,12 +28,12 @@ static inline void *unwind_add_table(struct module *mod,
85 return NULL; 28 return NULL;
86} 29}
87 30
88#endif
89
90static inline void unwind_remove_table(void *handle, int init_only) 31static inline void unwind_remove_table(void *handle, int init_only)
91{ 32{
92} 33}
93 34
35#endif
36
94static inline int unwind_init_frame_info(struct unwind_frame_info *info, 37static inline int unwind_init_frame_info(struct unwind_frame_info *info,
95 struct task_struct *tsk, 38 struct task_struct *tsk,
96 const struct pt_regs *regs) 39 const struct pt_regs *regs)
@@ -122,6 +65,4 @@ static inline int unwind_to_user(struct unwind_frame_info *info)
122 return -ENOSYS; 65 return -ENOSYS;
123} 66}
124 67
125#endif
126
127#endif /* _LINUX_UNWIND_H */ 68#endif /* _LINUX_UNWIND_H */
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index edef8d50b26b..2a7b38d87018 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -8,16 +8,21 @@
8#include <linux/timer.h> 8#include <linux/timer.h>
9#include <linux/linkage.h> 9#include <linux/linkage.h>
10#include <linux/bitops.h> 10#include <linux/bitops.h>
11#include <asm/atomic.h>
11 12
12struct workqueue_struct; 13struct workqueue_struct;
13 14
14struct work_struct; 15struct work_struct;
15typedef void (*work_func_t)(struct work_struct *work); 16typedef void (*work_func_t)(struct work_struct *work);
16 17
18/*
19 * The first word is the work queue pointer and the flags rolled into
20 * one
21 */
22#define work_data_bits(work) ((unsigned long *)(&(work)->data))
23
17struct work_struct { 24struct work_struct {
18 /* the first word is the work queue pointer and the flags rolled into 25 atomic_long_t data;
19 * one */
20 unsigned long management;
21#define WORK_STRUCT_PENDING 0 /* T if work item pending execution */ 26#define WORK_STRUCT_PENDING 0 /* T if work item pending execution */
22#define WORK_STRUCT_NOAUTOREL 1 /* F if work item automatically released on exec */ 27#define WORK_STRUCT_NOAUTOREL 1 /* F if work item automatically released on exec */
23#define WORK_STRUCT_FLAG_MASK (3UL) 28#define WORK_STRUCT_FLAG_MASK (3UL)
@@ -26,6 +31,9 @@ struct work_struct {
26 work_func_t func; 31 work_func_t func;
27}; 32};
28 33
34#define WORK_DATA_INIT(autorelease) \
35 ATOMIC_LONG_INIT((autorelease) << WORK_STRUCT_NOAUTOREL)
36
29struct delayed_work { 37struct delayed_work {
30 struct work_struct work; 38 struct work_struct work;
31 struct timer_list timer; 39 struct timer_list timer;
@@ -36,13 +44,13 @@ struct execute_work {
36}; 44};
37 45
38#define __WORK_INITIALIZER(n, f) { \ 46#define __WORK_INITIALIZER(n, f) { \
39 .management = 0, \ 47 .data = WORK_DATA_INIT(0), \
40 .entry = { &(n).entry, &(n).entry }, \ 48 .entry = { &(n).entry, &(n).entry }, \
41 .func = (f), \ 49 .func = (f), \
42 } 50 }
43 51
44#define __WORK_INITIALIZER_NAR(n, f) { \ 52#define __WORK_INITIALIZER_NAR(n, f) { \
45 .management = (1 << WORK_STRUCT_NOAUTOREL), \ 53 .data = WORK_DATA_INIT(1), \
46 .entry = { &(n).entry, &(n).entry }, \ 54 .entry = { &(n).entry, &(n).entry }, \
47 .func = (f), \ 55 .func = (f), \
48 } 56 }
@@ -82,17 +90,21 @@ struct execute_work {
82 90
83/* 91/*
84 * initialize all of a work item in one go 92 * initialize all of a work item in one go
93 *
94 * NOTE! No point in using "atomic_long_set()": useing a direct
95 * assignment of the work data initializer allows the compiler
96 * to generate better code.
85 */ 97 */
86#define INIT_WORK(_work, _func) \ 98#define INIT_WORK(_work, _func) \
87 do { \ 99 do { \
88 (_work)->management = 0; \ 100 (_work)->data = (atomic_long_t) WORK_DATA_INIT(0); \
89 INIT_LIST_HEAD(&(_work)->entry); \ 101 INIT_LIST_HEAD(&(_work)->entry); \
90 PREPARE_WORK((_work), (_func)); \ 102 PREPARE_WORK((_work), (_func)); \
91 } while (0) 103 } while (0)
92 104
93#define INIT_WORK_NAR(_work, _func) \ 105#define INIT_WORK_NAR(_work, _func) \
94 do { \ 106 do { \
95 (_work)->management = (1 << WORK_STRUCT_NOAUTOREL); \ 107 (_work)->data = (atomic_long_t) WORK_DATA_INIT(1); \
96 INIT_LIST_HEAD(&(_work)->entry); \ 108 INIT_LIST_HEAD(&(_work)->entry); \
97 PREPARE_WORK((_work), (_func)); \ 109 PREPARE_WORK((_work), (_func)); \
98 } while (0) 110 } while (0)
@@ -114,15 +126,15 @@ struct execute_work {
114 * @work: The work item in question 126 * @work: The work item in question
115 */ 127 */
116#define work_pending(work) \ 128#define work_pending(work) \
117 test_bit(WORK_STRUCT_PENDING, &(work)->management) 129 test_bit(WORK_STRUCT_PENDING, work_data_bits(work))
118 130
119/** 131/**
120 * delayed_work_pending - Find out whether a delayable work item is currently 132 * delayed_work_pending - Find out whether a delayable work item is currently
121 * pending 133 * pending
122 * @work: The work item in question 134 * @work: The work item in question
123 */ 135 */
124#define delayed_work_pending(work) \ 136#define delayed_work_pending(w) \
125 test_bit(WORK_STRUCT_PENDING, &(work)->work.management) 137 work_pending(&(w)->work)
126 138
127/** 139/**
128 * work_release - Release a work item under execution 140 * work_release - Release a work item under execution
@@ -143,7 +155,7 @@ struct execute_work {
143 * This should also be used to release a delayed work item. 155 * This should also be used to release a delayed work item.
144 */ 156 */
145#define work_release(work) \ 157#define work_release(work) \
146 clear_bit(WORK_STRUCT_PENDING, &(work)->management) 158 clear_bit(WORK_STRUCT_PENDING, work_data_bits(work))
147 159
148 160
149extern struct workqueue_struct *__create_workqueue(const char *name, 161extern struct workqueue_struct *__create_workqueue(const char *name,
@@ -188,7 +200,7 @@ static inline int cancel_delayed_work(struct delayed_work *work)
188 200
189 ret = del_timer_sync(&work->timer); 201 ret = del_timer_sync(&work->timer);
190 if (ret) 202 if (ret)
191 clear_bit(WORK_STRUCT_PENDING, &work->work.management); 203 work_release(&work->work);
192 return ret; 204 return ret;
193} 205}
194 206
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 10a3eec191fd..41456c148842 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -739,13 +739,13 @@ struct sockaddr_hci {
739struct hci_filter { 739struct hci_filter {
740 unsigned long type_mask; 740 unsigned long type_mask;
741 unsigned long event_mask[2]; 741 unsigned long event_mask[2];
742 __u16 opcode; 742 __le16 opcode;
743}; 743};
744 744
745struct hci_ufilter { 745struct hci_ufilter {
746 __u32 type_mask; 746 __u32 type_mask;
747 __u32 event_mask[2]; 747 __u32 event_mask[2];
748 __u16 opcode; 748 __le16 opcode;
749}; 749};
750 750
751#define HCI_FLT_TYPE_BITS 31 751#define HCI_FLT_TYPE_BITS 31
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index f9cde44f93b4..7be4f4e3a0f2 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -50,9 +50,9 @@ struct fib6_node
50 struct fib6_node *parent; 50 struct fib6_node *parent;
51 struct fib6_node *left; 51 struct fib6_node *left;
52 struct fib6_node *right; 52 struct fib6_node *right;
53 53#ifdef CONFIG_IPV6_SUBTREES
54 struct fib6_node *subtree; 54 struct fib6_node *subtree;
55 55#endif
56 struct rt6_info *leaf; 56 struct rt6_info *leaf;
57 57
58 __u16 fn_bit; /* bit key */ 58 __u16 fn_bit; /* bit key */
diff --git a/include/net/netfilter/nf_conntrack_compat.h b/include/net/netfilter/nf_conntrack_compat.h
index f1b1482d7200..b9ce5c80d9d5 100644
--- a/include/net/netfilter/nf_conntrack_compat.h
+++ b/include/net/netfilter/nf_conntrack_compat.h
@@ -64,6 +64,16 @@ static inline int nf_ct_get_ctinfo(const struct sk_buff *skb,
64 return (ct != NULL); 64 return (ct != NULL);
65} 65}
66 66
67static inline int nf_ct_l3proto_try_module_get(unsigned short l3proto)
68{
69 need_conntrack();
70 return l3proto == PF_INET ? 0 : -1;
71}
72
73static inline void nf_ct_l3proto_module_put(unsigned short l3proto)
74{
75}
76
67#else /* CONFIG_IP_NF_CONNTRACK */ 77#else /* CONFIG_IP_NF_CONNTRACK */
68 78
69#include <net/netfilter/ipv4/nf_conntrack_ipv4.h> 79#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index c089f93ba591..8d7f26d684e5 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -201,13 +201,12 @@ extern struct sctp_globals {
201 struct sctp_bind_hashbucket *port_hashtable; 201 struct sctp_bind_hashbucket *port_hashtable;
202 202
203 /* This is the global local address list. 203 /* This is the global local address list.
204 * We actively maintain this complete list of interfaces on 204 * We actively maintain this complete list of addresses on
205 * the system by catching routing events. 205 * the system by catching address add/delete events.
206 * 206 *
207 * It is a list of sctp_sockaddr_entry. 207 * It is a list of sctp_sockaddr_entry.
208 */ 208 */
209 struct list_head local_addr_list; 209 struct list_head local_addr_list;
210 spinlock_t local_addr_lock;
211 210
212 /* Flag to indicate if addip is enabled. */ 211 /* Flag to indicate if addip is enabled. */
213 int addip_enable; 212 int addip_enable;
@@ -243,7 +242,6 @@ extern struct sctp_globals {
243#define sctp_port_alloc_lock (sctp_globals.port_alloc_lock) 242#define sctp_port_alloc_lock (sctp_globals.port_alloc_lock)
244#define sctp_port_hashtable (sctp_globals.port_hashtable) 243#define sctp_port_hashtable (sctp_globals.port_hashtable)
245#define sctp_local_addr_list (sctp_globals.local_addr_list) 244#define sctp_local_addr_list (sctp_globals.local_addr_list)
246#define sctp_local_addr_lock (sctp_globals.local_addr_lock)
247#define sctp_addip_enable (sctp_globals.addip_enable) 245#define sctp_addip_enable (sctp_globals.addip_enable)
248#define sctp_prsctp_enable (sctp_globals.prsctp_enable) 246#define sctp_prsctp_enable (sctp_globals.prsctp_enable)
249 247
@@ -277,6 +275,7 @@ struct sctp_sock {
277 __u16 default_flags; 275 __u16 default_flags;
278 __u32 default_context; 276 __u32 default_context;
279 __u32 default_timetolive; 277 __u32 default_timetolive;
278 __u32 default_rcv_context;
280 279
281 /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to 280 /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to
282 * the destination address every heartbeat interval. This value 281 * the destination address every heartbeat interval. This value
@@ -1659,6 +1658,9 @@ struct sctp_association {
1659 __u32 default_context; 1658 __u32 default_context;
1660 __u32 default_timetolive; 1659 __u32 default_timetolive;
1661 1660
1661 /* Default receive parameters */
1662 __u32 default_rcv_context;
1663
1662 /* This tracks outbound ssn for a given stream. */ 1664 /* This tracks outbound ssn for a given stream. */
1663 struct sctp_ssnmap *ssnmap; 1665 struct sctp_ssnmap *ssnmap;
1664 1666
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index 1b7aae6cdd82..9e4a39fd129d 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -95,6 +95,8 @@ enum sctp_optname {
95#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO 95#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
96 SCTP_DELAYED_ACK_TIME, 96 SCTP_DELAYED_ACK_TIME,
97#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME 97#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME
98 SCTP_CONTEXT, /* Receive Context */
99#define SCTP_CONTEXT SCTP_CONTEXT
98 100
99 /* Internal Socket Options. Some of the sctp library functions are 101 /* Internal Socket Options. Some of the sctp library functions are
100 * implemented using these socket options. 102 * implemented using these socket options.
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index fd2353fa7e12..0bfa3328d686 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1456,9 +1456,9 @@ struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
1456 */ 1456 */
1457static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr) 1457static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr)
1458{ 1458{
1459 return dev->dma_ops ? 1459 if (dev->dma_ops)
1460 dev->dma_ops->mapping_error(dev, dma_addr) : 1460 return dev->dma_ops->mapping_error(dev, dma_addr);
1461 dma_mapping_error(dma_addr); 1461 return dma_mapping_error(dma_addr);
1462} 1462}
1463 1463
1464/** 1464/**
@@ -1472,9 +1472,9 @@ static inline u64 ib_dma_map_single(struct ib_device *dev,
1472 void *cpu_addr, size_t size, 1472 void *cpu_addr, size_t size,
1473 enum dma_data_direction direction) 1473 enum dma_data_direction direction)
1474{ 1474{
1475 return dev->dma_ops ? 1475 if (dev->dma_ops)
1476 dev->dma_ops->map_single(dev, cpu_addr, size, direction) : 1476 return dev->dma_ops->map_single(dev, cpu_addr, size, direction);
1477 dma_map_single(dev->dma_device, cpu_addr, size, direction); 1477 return dma_map_single(dev->dma_device, cpu_addr, size, direction);
1478} 1478}
1479 1479
1480/** 1480/**
@@ -1488,8 +1488,9 @@ static inline void ib_dma_unmap_single(struct ib_device *dev,
1488 u64 addr, size_t size, 1488 u64 addr, size_t size,
1489 enum dma_data_direction direction) 1489 enum dma_data_direction direction)
1490{ 1490{
1491 dev->dma_ops ? 1491 if (dev->dma_ops)
1492 dev->dma_ops->unmap_single(dev, addr, size, direction) : 1492 dev->dma_ops->unmap_single(dev, addr, size, direction);
1493 else
1493 dma_unmap_single(dev->dma_device, addr, size, direction); 1494 dma_unmap_single(dev->dma_device, addr, size, direction);
1494} 1495}
1495 1496
@@ -1507,9 +1508,9 @@ static inline u64 ib_dma_map_page(struct ib_device *dev,
1507 size_t size, 1508 size_t size,
1508 enum dma_data_direction direction) 1509 enum dma_data_direction direction)
1509{ 1510{
1510 return dev->dma_ops ? 1511 if (dev->dma_ops)
1511 dev->dma_ops->map_page(dev, page, offset, size, direction) : 1512 return dev->dma_ops->map_page(dev, page, offset, size, direction);
1512 dma_map_page(dev->dma_device, page, offset, size, direction); 1513 return dma_map_page(dev->dma_device, page, offset, size, direction);
1513} 1514}
1514 1515
1515/** 1516/**
@@ -1523,8 +1524,9 @@ static inline void ib_dma_unmap_page(struct ib_device *dev,
1523 u64 addr, size_t size, 1524 u64 addr, size_t size,
1524 enum dma_data_direction direction) 1525 enum dma_data_direction direction)
1525{ 1526{
1526 dev->dma_ops ? 1527 if (dev->dma_ops)
1527 dev->dma_ops->unmap_page(dev, addr, size, direction) : 1528 dev->dma_ops->unmap_page(dev, addr, size, direction);
1529 else
1528 dma_unmap_page(dev->dma_device, addr, size, direction); 1530 dma_unmap_page(dev->dma_device, addr, size, direction);
1529} 1531}
1530 1532
@@ -1539,9 +1541,9 @@ static inline int ib_dma_map_sg(struct ib_device *dev,
1539 struct scatterlist *sg, int nents, 1541 struct scatterlist *sg, int nents,
1540 enum dma_data_direction direction) 1542 enum dma_data_direction direction)
1541{ 1543{
1542 return dev->dma_ops ? 1544 if (dev->dma_ops)
1543 dev->dma_ops->map_sg(dev, sg, nents, direction) : 1545 return dev->dma_ops->map_sg(dev, sg, nents, direction);
1544 dma_map_sg(dev->dma_device, sg, nents, direction); 1546 return dma_map_sg(dev->dma_device, sg, nents, direction);
1545} 1547}
1546 1548
1547/** 1549/**
@@ -1555,8 +1557,9 @@ static inline void ib_dma_unmap_sg(struct ib_device *dev,
1555 struct scatterlist *sg, int nents, 1557 struct scatterlist *sg, int nents,
1556 enum dma_data_direction direction) 1558 enum dma_data_direction direction)
1557{ 1559{
1558 dev->dma_ops ? 1560 if (dev->dma_ops)
1559 dev->dma_ops->unmap_sg(dev, sg, nents, direction) : 1561 dev->dma_ops->unmap_sg(dev, sg, nents, direction);
1562 else
1560 dma_unmap_sg(dev->dma_device, sg, nents, direction); 1563 dma_unmap_sg(dev->dma_device, sg, nents, direction);
1561} 1564}
1562 1565
@@ -1568,8 +1571,9 @@ static inline void ib_dma_unmap_sg(struct ib_device *dev,
1568static inline u64 ib_sg_dma_address(struct ib_device *dev, 1571static inline u64 ib_sg_dma_address(struct ib_device *dev,
1569 struct scatterlist *sg) 1572 struct scatterlist *sg)
1570{ 1573{
1571 return dev->dma_ops ? 1574 if (dev->dma_ops)
1572 dev->dma_ops->dma_address(dev, sg) : sg_dma_address(sg); 1575 return dev->dma_ops->dma_address(dev, sg);
1576 return sg_dma_address(sg);
1573} 1577}
1574 1578
1575/** 1579/**
@@ -1580,8 +1584,9 @@ static inline u64 ib_sg_dma_address(struct ib_device *dev,
1580static inline unsigned int ib_sg_dma_len(struct ib_device *dev, 1584static inline unsigned int ib_sg_dma_len(struct ib_device *dev,
1581 struct scatterlist *sg) 1585 struct scatterlist *sg)
1582{ 1586{
1583 return dev->dma_ops ? 1587 if (dev->dma_ops)
1584 dev->dma_ops->dma_len(dev, sg) : sg_dma_len(sg); 1588 return dev->dma_ops->dma_len(dev, sg);
1589 return sg_dma_len(sg);
1585} 1590}
1586 1591
1587/** 1592/**
@@ -1596,8 +1601,9 @@ static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev,
1596 size_t size, 1601 size_t size,
1597 enum dma_data_direction dir) 1602 enum dma_data_direction dir)
1598{ 1603{
1599 dev->dma_ops ? 1604 if (dev->dma_ops)
1600 dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir) : 1605 dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir);
1606 else
1601 dma_sync_single_for_cpu(dev->dma_device, addr, size, dir); 1607 dma_sync_single_for_cpu(dev->dma_device, addr, size, dir);
1602} 1608}
1603 1609
@@ -1613,8 +1619,9 @@ static inline void ib_dma_sync_single_for_device(struct ib_device *dev,
1613 size_t size, 1619 size_t size,
1614 enum dma_data_direction dir) 1620 enum dma_data_direction dir)
1615{ 1621{
1616 dev->dma_ops ? 1622 if (dev->dma_ops)
1617 dev->dma_ops->sync_single_for_device(dev, addr, size, dir) : 1623 dev->dma_ops->sync_single_for_device(dev, addr, size, dir);
1624 else
1618 dma_sync_single_for_device(dev->dma_device, addr, size, dir); 1625 dma_sync_single_for_device(dev->dma_device, addr, size, dir);
1619} 1626}
1620 1627
@@ -1630,9 +1637,16 @@ static inline void *ib_dma_alloc_coherent(struct ib_device *dev,
1630 u64 *dma_handle, 1637 u64 *dma_handle,
1631 gfp_t flag) 1638 gfp_t flag)
1632{ 1639{
1633 return dev->dma_ops ? 1640 if (dev->dma_ops)
1634 dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag) : 1641 return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag);
1635 dma_alloc_coherent(dev->dma_device, size, dma_handle, flag); 1642 else {
1643 dma_addr_t handle;
1644 void *ret;
1645
1646 ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag);
1647 *dma_handle = handle;
1648 return ret;
1649 }
1636} 1650}
1637 1651
1638/** 1652/**
@@ -1646,8 +1660,9 @@ static inline void ib_dma_free_coherent(struct ib_device *dev,
1646 size_t size, void *cpu_addr, 1660 size_t size, void *cpu_addr,
1647 u64 dma_handle) 1661 u64 dma_handle)
1648{ 1662{
1649 dev->dma_ops ? 1663 if (dev->dma_ops)
1650 dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle) : 1664 dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
1665 else
1651 dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle); 1666 dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle);
1652} 1667}
1653 1668
diff --git a/include/video/sstfb.h b/include/video/sstfb.h
index 5dbf5e7e50a8..baa163f770ab 100644
--- a/include/video/sstfb.h
+++ b/include/video/sstfb.h
@@ -119,7 +119,7 @@
119#define BACKPORCH 0x0208 119#define BACKPORCH 0x0208
120#define VIDEODIMENSIONS 0x020c 120#define VIDEODIMENSIONS 0x020c
121#define FBIINIT0 0x0210 /* misc+fifo controls */ 121#define FBIINIT0 0x0210 /* misc+fifo controls */
122# define EN_VGA_PASSTHROUGH BIT(0) 122# define DIS_VGA_PASSTHROUGH BIT(0)
123# define FBI_RESET BIT(1) 123# define FBI_RESET BIT(1)
124# define FIFO_RESET BIT(2) 124# define FIFO_RESET BIT(2)
125#define FBIINIT1 0x0214 /* PCI + video controls */ 125#define FBIINIT1 0x0214 /* PCI + video controls */
@@ -251,7 +251,7 @@
251# define DACREG_ICS_CLK1_A 0 /* bit4 */ 251# define DACREG_ICS_CLK1_A 0 /* bit4 */
252 252
253/* sst default init registers */ 253/* sst default init registers */
254#define FBIINIT0_DEFAULT EN_VGA_PASSTHROUGH 254#define FBIINIT0_DEFAULT DIS_VGA_PASSTHROUGH
255 255
256#define FBIINIT1_DEFAULT \ 256#define FBIINIT1_DEFAULT \
257 ( \ 257 ( \
@@ -296,6 +296,11 @@
296 * 296 *
297 */ 297 */
298 298
299/* ioctl to enable/disable VGA passthrough */
300#define SSTFB_SET_VGAPASS _IOW('F', 0xdd, __u32)
301#define SSTFB_GET_VGAPASS _IOR('F', 0xdd, __u32)
302
303
299/* used to know witch clock to set */ 304/* used to know witch clock to set */
300enum { 305enum {
301 VID_CLOCK=0, 306 VID_CLOCK=0,
@@ -317,7 +322,7 @@ struct pll_timing {
317}; 322};
318 323
319struct dac_switch { 324struct dac_switch {
320 char * name; 325 const char *name;
321 int (*detect) (struct fb_info *info); 326 int (*detect) (struct fb_info *info);
322 int (*set_pll) (struct fb_info *info, const struct pll_timing *t, const int clock); 327 int (*set_pll) (struct fb_info *info, const struct pll_timing *t, const int clock);
323 void (*set_vidmod) (struct fb_info *info, const int bpp); 328 void (*set_vidmod) (struct fb_info *info, const int bpp);
@@ -345,7 +350,7 @@ struct sstfb_par {
345 struct pci_dev *dev; 350 struct pci_dev *dev;
346 int type; 351 int type;
347 u8 revision; 352 u8 revision;
348 int gfx_clock; /* status */ 353 u8 vgapass; /* VGA pass through: 1=enabled, 0=disabled */
349}; 354};
350 355
351#endif /* _SSTFB_H_ */ 356#endif /* _SSTFB_H_ */
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index 0992616eeed6..c82c215693d7 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -36,7 +36,7 @@ struct msg_msg *load_msg(const void __user *src, int len)
36 if (alen > DATALEN_MSG) 36 if (alen > DATALEN_MSG)
37 alen = DATALEN_MSG; 37 alen = DATALEN_MSG;
38 38
39 msg = (struct msg_msg *)kmalloc(sizeof(*msg) + alen, GFP_KERNEL); 39 msg = kmalloc(sizeof(*msg) + alen, GFP_KERNEL);
40 if (msg == NULL) 40 if (msg == NULL)
41 return ERR_PTR(-ENOMEM); 41 return ERR_PTR(-ENOMEM);
42 42
@@ -56,7 +56,7 @@ struct msg_msg *load_msg(const void __user *src, int len)
56 alen = len; 56 alen = len;
57 if (alen > DATALEN_SEG) 57 if (alen > DATALEN_SEG)
58 alen = DATALEN_SEG; 58 alen = DATALEN_SEG;
59 seg = (struct msg_msgseg *)kmalloc(sizeof(*seg) + alen, 59 seg = kmalloc(sizeof(*seg) + alen,
60 GFP_KERNEL); 60 GFP_KERNEL);
61 if (seg == NULL) { 61 if (seg == NULL) {
62 err = -ENOMEM; 62 err = -ENOMEM;
diff --git a/kernel/Makefile b/kernel/Makefile
index 5e3f3b75563a..14f4d45e0ae9 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -31,7 +31,6 @@ obj-$(CONFIG_PROVE_LOCKING) += spinlock.o
31obj-$(CONFIG_UID16) += uid16.o 31obj-$(CONFIG_UID16) += uid16.o
32obj-$(CONFIG_MODULES) += module.o 32obj-$(CONFIG_MODULES) += module.o
33obj-$(CONFIG_KALLSYMS) += kallsyms.o 33obj-$(CONFIG_KALLSYMS) += kallsyms.o
34obj-$(CONFIG_STACK_UNWIND) += unwind.o
35obj-$(CONFIG_PM) += power/ 34obj-$(CONFIG_PM) += power/
36obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o 35obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
37obj-$(CONFIG_KEXEC) += kexec.o 36obj-$(CONFIG_KEXEC) += kexec.o
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 2c3b4431472b..232aed2b10f9 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -2342,32 +2342,48 @@ static const struct cpuset *nearest_exclusive_ancestor(const struct cpuset *cs)
2342} 2342}
2343 2343
2344/** 2344/**
2345 * cpuset_zone_allowed - Can we allocate memory on zone z's memory node? 2345 * cpuset_zone_allowed_softwall - Can we allocate on zone z's memory node?
2346 * @z: is this zone on an allowed node? 2346 * @z: is this zone on an allowed node?
2347 * @gfp_mask: memory allocation flags (we use __GFP_HARDWALL) 2347 * @gfp_mask: memory allocation flags
2348 * 2348 *
2349 * If we're in interrupt, yes, we can always allocate. If zone 2349 * If we're in interrupt, yes, we can always allocate. If
2350 * __GFP_THISNODE is set, yes, we can always allocate. If zone
2350 * z's node is in our tasks mems_allowed, yes. If it's not a 2351 * z's node is in our tasks mems_allowed, yes. If it's not a
2351 * __GFP_HARDWALL request and this zone's nodes is in the nearest 2352 * __GFP_HARDWALL request and this zone's nodes is in the nearest
2352 * mem_exclusive cpuset ancestor to this tasks cpuset, yes. 2353 * mem_exclusive cpuset ancestor to this tasks cpuset, yes.
2353 * Otherwise, no. 2354 * Otherwise, no.
2354 * 2355 *
2356 * If __GFP_HARDWALL is set, cpuset_zone_allowed_softwall()
2357 * reduces to cpuset_zone_allowed_hardwall(). Otherwise,
2358 * cpuset_zone_allowed_softwall() might sleep, and might allow a zone
2359 * from an enclosing cpuset.
2360 *
2361 * cpuset_zone_allowed_hardwall() only handles the simpler case of
2362 * hardwall cpusets, and never sleeps.
2363 *
2364 * The __GFP_THISNODE placement logic is really handled elsewhere,
2365 * by forcibly using a zonelist starting at a specified node, and by
2366 * (in get_page_from_freelist()) refusing to consider the zones for
2367 * any node on the zonelist except the first. By the time any such
2368 * calls get to this routine, we should just shut up and say 'yes'.
2369 *
2355 * GFP_USER allocations are marked with the __GFP_HARDWALL bit, 2370 * GFP_USER allocations are marked with the __GFP_HARDWALL bit,
2356 * and do not allow allocations outside the current tasks cpuset. 2371 * and do not allow allocations outside the current tasks cpuset.
2357 * GFP_KERNEL allocations are not so marked, so can escape to the 2372 * GFP_KERNEL allocations are not so marked, so can escape to the
2358 * nearest mem_exclusive ancestor cpuset. 2373 * nearest enclosing mem_exclusive ancestor cpuset.
2359 * 2374 *
2360 * Scanning up parent cpusets requires callback_mutex. The __alloc_pages() 2375 * Scanning up parent cpusets requires callback_mutex. The
2361 * routine only calls here with __GFP_HARDWALL bit _not_ set if 2376 * __alloc_pages() routine only calls here with __GFP_HARDWALL bit
2362 * it's a GFP_KERNEL allocation, and all nodes in the current tasks 2377 * _not_ set if it's a GFP_KERNEL allocation, and all nodes in the
2363 * mems_allowed came up empty on the first pass over the zonelist. 2378 * current tasks mems_allowed came up empty on the first pass over
2364 * So only GFP_KERNEL allocations, if all nodes in the cpuset are 2379 * the zonelist. So only GFP_KERNEL allocations, if all nodes in the
2365 * short of memory, might require taking the callback_mutex mutex. 2380 * cpuset are short of memory, might require taking the callback_mutex
2381 * mutex.
2366 * 2382 *
2367 * The first call here from mm/page_alloc:get_page_from_freelist() 2383 * The first call here from mm/page_alloc:get_page_from_freelist()
2368 * has __GFP_HARDWALL set in gfp_mask, enforcing hardwall cpusets, so 2384 * has __GFP_HARDWALL set in gfp_mask, enforcing hardwall cpusets,
2369 * no allocation on a node outside the cpuset is allowed (unless in 2385 * so no allocation on a node outside the cpuset is allowed (unless
2370 * interrupt, of course). 2386 * in interrupt, of course).
2371 * 2387 *
2372 * The second pass through get_page_from_freelist() doesn't even call 2388 * The second pass through get_page_from_freelist() doesn't even call
2373 * here for GFP_ATOMIC calls. For those calls, the __alloc_pages() 2389 * here for GFP_ATOMIC calls. For those calls, the __alloc_pages()
@@ -2380,12 +2396,12 @@ static const struct cpuset *nearest_exclusive_ancestor(const struct cpuset *cs)
2380 * GFP_USER - only nodes in current tasks mems allowed ok. 2396 * GFP_USER - only nodes in current tasks mems allowed ok.
2381 * 2397 *
2382 * Rule: 2398 * Rule:
2383 * Don't call cpuset_zone_allowed() if you can't sleep, unless you 2399 * Don't call cpuset_zone_allowed_softwall if you can't sleep, unless you
2384 * pass in the __GFP_HARDWALL flag set in gfp_flag, which disables 2400 * pass in the __GFP_HARDWALL flag set in gfp_flag, which disables
2385 * the code that might scan up ancestor cpusets and sleep. 2401 * the code that might scan up ancestor cpusets and sleep.
2386 **/ 2402 */
2387 2403
2388int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) 2404int __cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
2389{ 2405{
2390 int node; /* node that zone z is on */ 2406 int node; /* node that zone z is on */
2391 const struct cpuset *cs; /* current cpuset ancestors */ 2407 const struct cpuset *cs; /* current cpuset ancestors */
@@ -2415,6 +2431,40 @@ int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
2415 return allowed; 2431 return allowed;
2416} 2432}
2417 2433
2434/*
2435 * cpuset_zone_allowed_hardwall - Can we allocate on zone z's memory node?
2436 * @z: is this zone on an allowed node?
2437 * @gfp_mask: memory allocation flags
2438 *
2439 * If we're in interrupt, yes, we can always allocate.
2440 * If __GFP_THISNODE is set, yes, we can always allocate. If zone
2441 * z's node is in our tasks mems_allowed, yes. Otherwise, no.
2442 *
2443 * The __GFP_THISNODE placement logic is really handled elsewhere,
2444 * by forcibly using a zonelist starting at a specified node, and by
2445 * (in get_page_from_freelist()) refusing to consider the zones for
2446 * any node on the zonelist except the first. By the time any such
2447 * calls get to this routine, we should just shut up and say 'yes'.
2448 *
2449 * Unlike the cpuset_zone_allowed_softwall() variant, above,
2450 * this variant requires that the zone be in the current tasks
2451 * mems_allowed or that we're in interrupt. It does not scan up the
2452 * cpuset hierarchy for the nearest enclosing mem_exclusive cpuset.
2453 * It never sleeps.
2454 */
2455
2456int __cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
2457{
2458 int node; /* node that zone z is on */
2459
2460 if (in_interrupt() || (gfp_mask & __GFP_THISNODE))
2461 return 1;
2462 node = zone_to_nid(z);
2463 if (node_isset(node, current->mems_allowed))
2464 return 1;
2465 return 0;
2466}
2467
2418/** 2468/**
2419 * cpuset_lock - lock out any changes to cpuset structures 2469 * cpuset_lock - lock out any changes to cpuset structures
2420 * 2470 *
diff --git a/kernel/fork.c b/kernel/fork.c
index d16c566eb645..fc723e595cd5 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -203,7 +203,7 @@ static inline int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
203 struct mempolicy *pol; 203 struct mempolicy *pol;
204 204
205 down_write(&oldmm->mmap_sem); 205 down_write(&oldmm->mmap_sem);
206 flush_cache_mm(oldmm); 206 flush_cache_dup_mm(oldmm);
207 /* 207 /*
208 * Not linked in yet - no deadlock potential: 208 * Not linked in yet - no deadlock potential:
209 */ 209 */
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index b02032476dc2..01e750559034 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -43,13 +43,49 @@
43#include "lockdep_internals.h" 43#include "lockdep_internals.h"
44 44
45/* 45/*
46 * hash_lock: protects the lockdep hashes and class/list/hash allocators. 46 * lockdep_lock: protects the lockdep graph, the hashes and the
47 * class/list/hash allocators.
47 * 48 *
48 * This is one of the rare exceptions where it's justified 49 * This is one of the rare exceptions where it's justified
49 * to use a raw spinlock - we really dont want the spinlock 50 * to use a raw spinlock - we really dont want the spinlock
50 * code to recurse back into the lockdep code. 51 * code to recurse back into the lockdep code...
51 */ 52 */
52static raw_spinlock_t hash_lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; 53static raw_spinlock_t lockdep_lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
54
55static int graph_lock(void)
56{
57 __raw_spin_lock(&lockdep_lock);
58 /*
59 * Make sure that if another CPU detected a bug while
60 * walking the graph we dont change it (while the other
61 * CPU is busy printing out stuff with the graph lock
62 * dropped already)
63 */
64 if (!debug_locks) {
65 __raw_spin_unlock(&lockdep_lock);
66 return 0;
67 }
68 return 1;
69}
70
71static inline int graph_unlock(void)
72{
73 __raw_spin_unlock(&lockdep_lock);
74 return 0;
75}
76
77/*
78 * Turn lock debugging off and return with 0 if it was off already,
79 * and also release the graph lock:
80 */
81static inline int debug_locks_off_graph_unlock(void)
82{
83 int ret = debug_locks_off();
84
85 __raw_spin_unlock(&lockdep_lock);
86
87 return ret;
88}
53 89
54static int lockdep_initialized; 90static int lockdep_initialized;
55 91
@@ -57,14 +93,15 @@ unsigned long nr_list_entries;
57static struct lock_list list_entries[MAX_LOCKDEP_ENTRIES]; 93static struct lock_list list_entries[MAX_LOCKDEP_ENTRIES];
58 94
59/* 95/*
60 * Allocate a lockdep entry. (assumes hash_lock held, returns 96 * Allocate a lockdep entry. (assumes the graph_lock held, returns
61 * with NULL on failure) 97 * with NULL on failure)
62 */ 98 */
63static struct lock_list *alloc_list_entry(void) 99static struct lock_list *alloc_list_entry(void)
64{ 100{
65 if (nr_list_entries >= MAX_LOCKDEP_ENTRIES) { 101 if (nr_list_entries >= MAX_LOCKDEP_ENTRIES) {
66 __raw_spin_unlock(&hash_lock); 102 if (!debug_locks_off_graph_unlock())
67 debug_locks_off(); 103 return NULL;
104
68 printk("BUG: MAX_LOCKDEP_ENTRIES too low!\n"); 105 printk("BUG: MAX_LOCKDEP_ENTRIES too low!\n");
69 printk("turning off the locking correctness validator.\n"); 106 printk("turning off the locking correctness validator.\n");
70 return NULL; 107 return NULL;
@@ -145,9 +182,7 @@ EXPORT_SYMBOL(lockdep_on);
145 */ 182 */
146 183
147#define VERBOSE 0 184#define VERBOSE 0
148#ifdef VERBOSE 185#define VERY_VERBOSE 0
149# define VERY_VERBOSE 0
150#endif
151 186
152#if VERBOSE 187#if VERBOSE
153# define HARDIRQ_VERBOSE 1 188# define HARDIRQ_VERBOSE 1
@@ -172,8 +207,8 @@ static int class_filter(struct lock_class *class)
172 !strcmp(class->name, "&struct->lockfield")) 207 !strcmp(class->name, "&struct->lockfield"))
173 return 1; 208 return 1;
174#endif 209#endif
175 /* Allow everything else. 0 would be filter everything else */ 210 /* Filter everything else. 1 would be to allow everything else */
176 return 1; 211 return 0;
177} 212}
178#endif 213#endif
179 214
@@ -207,7 +242,7 @@ static int softirq_verbose(struct lock_class *class)
207 242
208/* 243/*
209 * Stack-trace: tightly packed array of stack backtrace 244 * Stack-trace: tightly packed array of stack backtrace
210 * addresses. Protected by the hash_lock. 245 * addresses. Protected by the graph_lock.
211 */ 246 */
212unsigned long nr_stack_trace_entries; 247unsigned long nr_stack_trace_entries;
213static unsigned long stack_trace[MAX_STACK_TRACE_ENTRIES]; 248static unsigned long stack_trace[MAX_STACK_TRACE_ENTRIES];
@@ -226,18 +261,15 @@ static int save_trace(struct stack_trace *trace)
226 trace->max_entries = trace->nr_entries; 261 trace->max_entries = trace->nr_entries;
227 262
228 nr_stack_trace_entries += trace->nr_entries; 263 nr_stack_trace_entries += trace->nr_entries;
229 if (DEBUG_LOCKS_WARN_ON(nr_stack_trace_entries > MAX_STACK_TRACE_ENTRIES)) {
230 __raw_spin_unlock(&hash_lock);
231 return 0;
232 }
233 264
234 if (nr_stack_trace_entries == MAX_STACK_TRACE_ENTRIES) { 265 if (nr_stack_trace_entries == MAX_STACK_TRACE_ENTRIES) {
235 __raw_spin_unlock(&hash_lock); 266 if (!debug_locks_off_graph_unlock())
236 if (debug_locks_off()) { 267 return 0;
237 printk("BUG: MAX_STACK_TRACE_ENTRIES too low!\n"); 268
238 printk("turning off the locking correctness validator.\n"); 269 printk("BUG: MAX_STACK_TRACE_ENTRIES too low!\n");
239 dump_stack(); 270 printk("turning off the locking correctness validator.\n");
240 } 271 dump_stack();
272
241 return 0; 273 return 0;
242 } 274 }
243 275
@@ -526,9 +558,7 @@ print_circular_bug_header(struct lock_list *entry, unsigned int depth)
526{ 558{
527 struct task_struct *curr = current; 559 struct task_struct *curr = current;
528 560
529 __raw_spin_unlock(&hash_lock); 561 if (!debug_locks_off_graph_unlock() || debug_locks_silent)
530 debug_locks_off();
531 if (debug_locks_silent)
532 return 0; 562 return 0;
533 563
534 printk("\n=======================================================\n"); 564 printk("\n=======================================================\n");
@@ -556,12 +586,10 @@ static noinline int print_circular_bug_tail(void)
556 if (debug_locks_silent) 586 if (debug_locks_silent)
557 return 0; 587 return 0;
558 588
559 /* hash_lock unlocked by the header */
560 __raw_spin_lock(&hash_lock);
561 this.class = check_source->class; 589 this.class = check_source->class;
562 if (!save_trace(&this.trace)) 590 if (!save_trace(&this.trace))
563 return 0; 591 return 0;
564 __raw_spin_unlock(&hash_lock); 592
565 print_circular_bug_entry(&this, 0); 593 print_circular_bug_entry(&this, 0);
566 594
567 printk("\nother info that might help us debug this:\n\n"); 595 printk("\nother info that might help us debug this:\n\n");
@@ -577,8 +605,10 @@ static noinline int print_circular_bug_tail(void)
577 605
578static int noinline print_infinite_recursion_bug(void) 606static int noinline print_infinite_recursion_bug(void)
579{ 607{
580 __raw_spin_unlock(&hash_lock); 608 if (!debug_locks_off_graph_unlock())
581 DEBUG_LOCKS_WARN_ON(1); 609 return 0;
610
611 WARN_ON(1);
582 612
583 return 0; 613 return 0;
584} 614}
@@ -713,9 +743,7 @@ print_bad_irq_dependency(struct task_struct *curr,
713 enum lock_usage_bit bit2, 743 enum lock_usage_bit bit2,
714 const char *irqclass) 744 const char *irqclass)
715{ 745{
716 __raw_spin_unlock(&hash_lock); 746 if (!debug_locks_off_graph_unlock() || debug_locks_silent)
717 debug_locks_off();
718 if (debug_locks_silent)
719 return 0; 747 return 0;
720 748
721 printk("\n======================================================\n"); 749 printk("\n======================================================\n");
@@ -796,9 +824,7 @@ static int
796print_deadlock_bug(struct task_struct *curr, struct held_lock *prev, 824print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
797 struct held_lock *next) 825 struct held_lock *next)
798{ 826{
799 debug_locks_off(); 827 if (!debug_locks_off_graph_unlock() || debug_locks_silent)
800 __raw_spin_unlock(&hash_lock);
801 if (debug_locks_silent)
802 return 0; 828 return 0;
803 829
804 printk("\n=============================================\n"); 830 printk("\n=============================================\n");
@@ -974,14 +1000,14 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
974 * Debugging printouts: 1000 * Debugging printouts:
975 */ 1001 */
976 if (verbose(prev->class) || verbose(next->class)) { 1002 if (verbose(prev->class) || verbose(next->class)) {
977 __raw_spin_unlock(&hash_lock); 1003 graph_unlock();
978 printk("\n new dependency: "); 1004 printk("\n new dependency: ");
979 print_lock_name(prev->class); 1005 print_lock_name(prev->class);
980 printk(" => "); 1006 printk(" => ");
981 print_lock_name(next->class); 1007 print_lock_name(next->class);
982 printk("\n"); 1008 printk("\n");
983 dump_stack(); 1009 dump_stack();
984 __raw_spin_lock(&hash_lock); 1010 return graph_lock();
985 } 1011 }
986 return 1; 1012 return 1;
987} 1013}
@@ -1046,8 +1072,10 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
1046 } 1072 }
1047 return 1; 1073 return 1;
1048out_bug: 1074out_bug:
1049 __raw_spin_unlock(&hash_lock); 1075 if (!debug_locks_off_graph_unlock())
1050 DEBUG_LOCKS_WARN_ON(1); 1076 return 0;
1077
1078 WARN_ON(1);
1051 1079
1052 return 0; 1080 return 0;
1053} 1081}
@@ -1201,7 +1229,10 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1201 hash_head = classhashentry(key); 1229 hash_head = classhashentry(key);
1202 1230
1203 raw_local_irq_save(flags); 1231 raw_local_irq_save(flags);
1204 __raw_spin_lock(&hash_lock); 1232 if (!graph_lock()) {
1233 raw_local_irq_restore(flags);
1234 return NULL;
1235 }
1205 /* 1236 /*
1206 * We have to do the hash-walk again, to avoid races 1237 * We have to do the hash-walk again, to avoid races
1207 * with another CPU: 1238 * with another CPU:
@@ -1214,9 +1245,12 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1214 * the hash: 1245 * the hash:
1215 */ 1246 */
1216 if (nr_lock_classes >= MAX_LOCKDEP_KEYS) { 1247 if (nr_lock_classes >= MAX_LOCKDEP_KEYS) {
1217 __raw_spin_unlock(&hash_lock); 1248 if (!debug_locks_off_graph_unlock()) {
1249 raw_local_irq_restore(flags);
1250 return NULL;
1251 }
1218 raw_local_irq_restore(flags); 1252 raw_local_irq_restore(flags);
1219 debug_locks_off(); 1253
1220 printk("BUG: MAX_LOCKDEP_KEYS too low!\n"); 1254 printk("BUG: MAX_LOCKDEP_KEYS too low!\n");
1221 printk("turning off the locking correctness validator.\n"); 1255 printk("turning off the locking correctness validator.\n");
1222 return NULL; 1256 return NULL;
@@ -1237,18 +1271,23 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1237 list_add_tail_rcu(&class->hash_entry, hash_head); 1271 list_add_tail_rcu(&class->hash_entry, hash_head);
1238 1272
1239 if (verbose(class)) { 1273 if (verbose(class)) {
1240 __raw_spin_unlock(&hash_lock); 1274 graph_unlock();
1241 raw_local_irq_restore(flags); 1275 raw_local_irq_restore(flags);
1276
1242 printk("\nnew class %p: %s", class->key, class->name); 1277 printk("\nnew class %p: %s", class->key, class->name);
1243 if (class->name_version > 1) 1278 if (class->name_version > 1)
1244 printk("#%d", class->name_version); 1279 printk("#%d", class->name_version);
1245 printk("\n"); 1280 printk("\n");
1246 dump_stack(); 1281 dump_stack();
1282
1247 raw_local_irq_save(flags); 1283 raw_local_irq_save(flags);
1248 __raw_spin_lock(&hash_lock); 1284 if (!graph_lock()) {
1285 raw_local_irq_restore(flags);
1286 return NULL;
1287 }
1249 } 1288 }
1250out_unlock_set: 1289out_unlock_set:
1251 __raw_spin_unlock(&hash_lock); 1290 graph_unlock();
1252 raw_local_irq_restore(flags); 1291 raw_local_irq_restore(flags);
1253 1292
1254 if (!subclass || force) 1293 if (!subclass || force)
@@ -1264,7 +1303,7 @@ out_unlock_set:
1264 * add it and return 0 - in this case the new dependency chain is 1303 * add it and return 0 - in this case the new dependency chain is
1265 * validated. If the key is already hashed, return 1. 1304 * validated. If the key is already hashed, return 1.
1266 */ 1305 */
1267static inline int lookup_chain_cache(u64 chain_key) 1306static inline int lookup_chain_cache(u64 chain_key, struct lock_class *class)
1268{ 1307{
1269 struct list_head *hash_head = chainhashentry(chain_key); 1308 struct list_head *hash_head = chainhashentry(chain_key);
1270 struct lock_chain *chain; 1309 struct lock_chain *chain;
@@ -1278,34 +1317,32 @@ static inline int lookup_chain_cache(u64 chain_key)
1278 if (chain->chain_key == chain_key) { 1317 if (chain->chain_key == chain_key) {
1279cache_hit: 1318cache_hit:
1280 debug_atomic_inc(&chain_lookup_hits); 1319 debug_atomic_inc(&chain_lookup_hits);
1281 /* 1320 if (very_verbose(class))
1282 * In the debugging case, force redundant checking 1321 printk("\nhash chain already cached, key: %016Lx tail class: [%p] %s\n", chain_key, class->key, class->name);
1283 * by returning 1:
1284 */
1285#ifdef CONFIG_DEBUG_LOCKDEP
1286 __raw_spin_lock(&hash_lock);
1287 return 1;
1288#endif
1289 return 0; 1322 return 0;
1290 } 1323 }
1291 } 1324 }
1325 if (very_verbose(class))
1326 printk("\nnew hash chain, key: %016Lx tail class: [%p] %s\n", chain_key, class->key, class->name);
1292 /* 1327 /*
1293 * Allocate a new chain entry from the static array, and add 1328 * Allocate a new chain entry from the static array, and add
1294 * it to the hash: 1329 * it to the hash:
1295 */ 1330 */
1296 __raw_spin_lock(&hash_lock); 1331 if (!graph_lock())
1332 return 0;
1297 /* 1333 /*
1298 * We have to walk the chain again locked - to avoid duplicates: 1334 * We have to walk the chain again locked - to avoid duplicates:
1299 */ 1335 */
1300 list_for_each_entry(chain, hash_head, entry) { 1336 list_for_each_entry(chain, hash_head, entry) {
1301 if (chain->chain_key == chain_key) { 1337 if (chain->chain_key == chain_key) {
1302 __raw_spin_unlock(&hash_lock); 1338 graph_unlock();
1303 goto cache_hit; 1339 goto cache_hit;
1304 } 1340 }
1305 } 1341 }
1306 if (unlikely(nr_lock_chains >= MAX_LOCKDEP_CHAINS)) { 1342 if (unlikely(nr_lock_chains >= MAX_LOCKDEP_CHAINS)) {
1307 __raw_spin_unlock(&hash_lock); 1343 if (!debug_locks_off_graph_unlock())
1308 debug_locks_off(); 1344 return 0;
1345
1309 printk("BUG: MAX_LOCKDEP_CHAINS too low!\n"); 1346 printk("BUG: MAX_LOCKDEP_CHAINS too low!\n");
1310 printk("turning off the locking correctness validator.\n"); 1347 printk("turning off the locking correctness validator.\n");
1311 return 0; 1348 return 0;
@@ -1381,9 +1418,7 @@ print_irq_inversion_bug(struct task_struct *curr, struct lock_class *other,
1381 struct held_lock *this, int forwards, 1418 struct held_lock *this, int forwards,
1382 const char *irqclass) 1419 const char *irqclass)
1383{ 1420{
1384 __raw_spin_unlock(&hash_lock); 1421 if (!debug_locks_off_graph_unlock() || debug_locks_silent)
1385 debug_locks_off();
1386 if (debug_locks_silent)
1387 return 0; 1422 return 0;
1388 1423
1389 printk("\n=========================================================\n"); 1424 printk("\n=========================================================\n");
@@ -1453,7 +1488,7 @@ check_usage_backwards(struct task_struct *curr, struct held_lock *this,
1453 return print_irq_inversion_bug(curr, backwards_match, this, 0, irqclass); 1488 return print_irq_inversion_bug(curr, backwards_match, this, 0, irqclass);
1454} 1489}
1455 1490
1456static inline void print_irqtrace_events(struct task_struct *curr) 1491void print_irqtrace_events(struct task_struct *curr)
1457{ 1492{
1458 printk("irq event stamp: %u\n", curr->irq_events); 1493 printk("irq event stamp: %u\n", curr->irq_events);
1459 printk("hardirqs last enabled at (%u): ", curr->hardirq_enable_event); 1494 printk("hardirqs last enabled at (%u): ", curr->hardirq_enable_event);
@@ -1466,19 +1501,13 @@ static inline void print_irqtrace_events(struct task_struct *curr)
1466 print_ip_sym(curr->softirq_disable_ip); 1501 print_ip_sym(curr->softirq_disable_ip);
1467} 1502}
1468 1503
1469#else
1470static inline void print_irqtrace_events(struct task_struct *curr)
1471{
1472}
1473#endif 1504#endif
1474 1505
1475static int 1506static int
1476print_usage_bug(struct task_struct *curr, struct held_lock *this, 1507print_usage_bug(struct task_struct *curr, struct held_lock *this,
1477 enum lock_usage_bit prev_bit, enum lock_usage_bit new_bit) 1508 enum lock_usage_bit prev_bit, enum lock_usage_bit new_bit)
1478{ 1509{
1479 __raw_spin_unlock(&hash_lock); 1510 if (!debug_locks_off_graph_unlock() || debug_locks_silent)
1480 debug_locks_off();
1481 if (debug_locks_silent)
1482 return 0; 1511 return 0;
1483 1512
1484 printk("\n=================================\n"); 1513 printk("\n=================================\n");
@@ -1539,12 +1568,13 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
1539 if (likely(this->class->usage_mask & new_mask)) 1568 if (likely(this->class->usage_mask & new_mask))
1540 return 1; 1569 return 1;
1541 1570
1542 __raw_spin_lock(&hash_lock); 1571 if (!graph_lock())
1572 return 0;
1543 /* 1573 /*
1544 * Make sure we didnt race: 1574 * Make sure we didnt race:
1545 */ 1575 */
1546 if (unlikely(this->class->usage_mask & new_mask)) { 1576 if (unlikely(this->class->usage_mask & new_mask)) {
1547 __raw_spin_unlock(&hash_lock); 1577 graph_unlock();
1548 return 1; 1578 return 1;
1549 } 1579 }
1550 1580
@@ -1730,16 +1760,16 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
1730 debug_atomic_dec(&nr_unused_locks); 1760 debug_atomic_dec(&nr_unused_locks);
1731 break; 1761 break;
1732 default: 1762 default:
1733 __raw_spin_unlock(&hash_lock); 1763 if (!debug_locks_off_graph_unlock())
1734 debug_locks_off(); 1764 return 0;
1735 WARN_ON(1); 1765 WARN_ON(1);
1736 return 0; 1766 return 0;
1737 } 1767 }
1738 1768
1739 __raw_spin_unlock(&hash_lock); 1769 graph_unlock();
1740 1770
1741 /* 1771 /*
1742 * We must printk outside of the hash_lock: 1772 * We must printk outside of the graph_lock:
1743 */ 1773 */
1744 if (ret == 2) { 1774 if (ret == 2) {
1745 printk("\nmarked lock as {%s}:\n", usage_str[new_bit]); 1775 printk("\nmarked lock as {%s}:\n", usage_str[new_bit]);
@@ -2137,9 +2167,9 @@ out_calc_hash:
2137 * We look up the chain_key and do the O(N^2) check and update of 2167 * We look up the chain_key and do the O(N^2) check and update of
2138 * the dependencies only if this is a new dependency chain. 2168 * the dependencies only if this is a new dependency chain.
2139 * (If lookup_chain_cache() returns with 1 it acquires 2169 * (If lookup_chain_cache() returns with 1 it acquires
2140 * hash_lock for us) 2170 * graph_lock for us)
2141 */ 2171 */
2142 if (!trylock && (check == 2) && lookup_chain_cache(chain_key)) { 2172 if (!trylock && (check == 2) && lookup_chain_cache(chain_key, class)) {
2143 /* 2173 /*
2144 * Check whether last held lock: 2174 * Check whether last held lock:
2145 * 2175 *
@@ -2170,7 +2200,7 @@ out_calc_hash:
2170 if (!chain_head && ret != 2) 2200 if (!chain_head && ret != 2)
2171 if (!check_prevs_add(curr, hlock)) 2201 if (!check_prevs_add(curr, hlock))
2172 return 0; 2202 return 0;
2173 __raw_spin_unlock(&hash_lock); 2203 graph_unlock();
2174 } 2204 }
2175 curr->lockdep_depth++; 2205 curr->lockdep_depth++;
2176 check_chain_key(curr); 2206 check_chain_key(curr);
@@ -2433,6 +2463,7 @@ EXPORT_SYMBOL_GPL(lock_release);
2433void lockdep_reset(void) 2463void lockdep_reset(void)
2434{ 2464{
2435 unsigned long flags; 2465 unsigned long flags;
2466 int i;
2436 2467
2437 raw_local_irq_save(flags); 2468 raw_local_irq_save(flags);
2438 current->curr_chain_key = 0; 2469 current->curr_chain_key = 0;
@@ -2443,6 +2474,8 @@ void lockdep_reset(void)
2443 nr_softirq_chains = 0; 2474 nr_softirq_chains = 0;
2444 nr_process_chains = 0; 2475 nr_process_chains = 0;
2445 debug_locks = 1; 2476 debug_locks = 1;
2477 for (i = 0; i < CHAINHASH_SIZE; i++)
2478 INIT_LIST_HEAD(chainhash_table + i);
2446 raw_local_irq_restore(flags); 2479 raw_local_irq_restore(flags);
2447} 2480}
2448 2481
@@ -2479,7 +2512,7 @@ void lockdep_free_key_range(void *start, unsigned long size)
2479 int i; 2512 int i;
2480 2513
2481 raw_local_irq_save(flags); 2514 raw_local_irq_save(flags);
2482 __raw_spin_lock(&hash_lock); 2515 graph_lock();
2483 2516
2484 /* 2517 /*
2485 * Unhash all classes that were created by this module: 2518 * Unhash all classes that were created by this module:
@@ -2493,7 +2526,7 @@ void lockdep_free_key_range(void *start, unsigned long size)
2493 zap_class(class); 2526 zap_class(class);
2494 } 2527 }
2495 2528
2496 __raw_spin_unlock(&hash_lock); 2529 graph_unlock();
2497 raw_local_irq_restore(flags); 2530 raw_local_irq_restore(flags);
2498} 2531}
2499 2532
@@ -2521,20 +2554,20 @@ void lockdep_reset_lock(struct lockdep_map *lock)
2521 * Debug check: in the end all mapped classes should 2554 * Debug check: in the end all mapped classes should
2522 * be gone. 2555 * be gone.
2523 */ 2556 */
2524 __raw_spin_lock(&hash_lock); 2557 graph_lock();
2525 for (i = 0; i < CLASSHASH_SIZE; i++) { 2558 for (i = 0; i < CLASSHASH_SIZE; i++) {
2526 head = classhash_table + i; 2559 head = classhash_table + i;
2527 if (list_empty(head)) 2560 if (list_empty(head))
2528 continue; 2561 continue;
2529 list_for_each_entry_safe(class, next, head, hash_entry) { 2562 list_for_each_entry_safe(class, next, head, hash_entry) {
2530 if (unlikely(class == lock->class_cache)) { 2563 if (unlikely(class == lock->class_cache)) {
2531 __raw_spin_unlock(&hash_lock); 2564 if (debug_locks_off_graph_unlock())
2532 DEBUG_LOCKS_WARN_ON(1); 2565 WARN_ON(1);
2533 goto out_restore; 2566 goto out_restore;
2534 } 2567 }
2535 } 2568 }
2536 } 2569 }
2537 __raw_spin_unlock(&hash_lock); 2570 graph_unlock();
2538 2571
2539out_restore: 2572out_restore:
2540 raw_local_irq_restore(flags); 2573 raw_local_irq_restore(flags);
diff --git a/kernel/module.c b/kernel/module.c
index d9eae45d0145..b565eaeff7e6 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -824,9 +824,34 @@ static inline void module_unload_init(struct module *mod)
824} 824}
825#endif /* CONFIG_MODULE_UNLOAD */ 825#endif /* CONFIG_MODULE_UNLOAD */
826 826
827static ssize_t show_initstate(struct module_attribute *mattr,
828 struct module *mod, char *buffer)
829{
830 const char *state = "unknown";
831
832 switch (mod->state) {
833 case MODULE_STATE_LIVE:
834 state = "live";
835 break;
836 case MODULE_STATE_COMING:
837 state = "coming";
838 break;
839 case MODULE_STATE_GOING:
840 state = "going";
841 break;
842 }
843 return sprintf(buffer, "%s\n", state);
844}
845
846static struct module_attribute initstate = {
847 .attr = { .name = "initstate", .mode = 0444, .owner = THIS_MODULE },
848 .show = show_initstate,
849};
850
827static struct module_attribute *modinfo_attrs[] = { 851static struct module_attribute *modinfo_attrs[] = {
828 &modinfo_version, 852 &modinfo_version,
829 &modinfo_srcversion, 853 &modinfo_srcversion,
854 &initstate,
830#ifdef CONFIG_MODULE_UNLOAD 855#ifdef CONFIG_MODULE_UNLOAD
831 &refcnt, 856 &refcnt,
832#endif 857#endif
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index e2ce748e96af..f5b9ee6f6bbb 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -46,10 +46,8 @@ static inline struct nsproxy *clone_namespaces(struct nsproxy *orig)
46 struct nsproxy *ns; 46 struct nsproxy *ns;
47 47
48 ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL); 48 ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL);
49 if (ns) { 49 if (ns)
50 atomic_set(&ns->count, 1); 50 atomic_set(&ns->count, 1);
51 ns->id = -1;
52 }
53 return ns; 51 return ns;
54} 52}
55 53
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 710ed084e7c5..ed296225dcd4 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -20,13 +20,14 @@ config PM
20 sending the processor to sleep and saving power. 20 sending the processor to sleep and saving power.
21 21
22config PM_LEGACY 22config PM_LEGACY
23 bool "Legacy Power Management API" 23 bool "Legacy Power Management API (DEPRECATED)"
24 depends on PM 24 depends on PM
25 default y 25 default n
26 ---help--- 26 ---help---
27 Support for pm_register() and friends. 27 Support for pm_register() and friends. This old API is obsoleted
28 by the driver model.
28 29
29 If unsure, say Y. 30 If unsure, say N.
30 31
31config PM_DEBUG 32config PM_DEBUG
32 bool "Power Management Debug Support" 33 bool "Power Management Debug Support"
diff --git a/kernel/power/process.c b/kernel/power/process.c
index 99eeb119b06d..6d566bf7085c 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -28,8 +28,7 @@ static inline int freezeable(struct task_struct * p)
28 if ((p == current) || 28 if ((p == current) ||
29 (p->flags & PF_NOFREEZE) || 29 (p->flags & PF_NOFREEZE) ||
30 (p->exit_state == EXIT_ZOMBIE) || 30 (p->exit_state == EXIT_ZOMBIE) ||
31 (p->exit_state == EXIT_DEAD) || 31 (p->exit_state == EXIT_DEAD))
32 (p->state == TASK_STOPPED))
33 return 0; 32 return 0;
34 return 1; 33 return 1;
35} 34}
@@ -61,10 +60,16 @@ static inline void freeze_process(struct task_struct *p)
61 unsigned long flags; 60 unsigned long flags;
62 61
63 if (!freezing(p)) { 62 if (!freezing(p)) {
64 freeze(p); 63 rmb();
65 spin_lock_irqsave(&p->sighand->siglock, flags); 64 if (!frozen(p)) {
66 signal_wake_up(p, 0); 65 if (p->state == TASK_STOPPED)
67 spin_unlock_irqrestore(&p->sighand->siglock, flags); 66 force_sig_specific(SIGSTOP, p);
67
68 freeze(p);
69 spin_lock_irqsave(&p->sighand->siglock, flags);
70 signal_wake_up(p, p->state == TASK_STOPPED);
71 spin_unlock_irqrestore(&p->sighand->siglock, flags);
72 }
68 } 73 }
69} 74}
70 75
@@ -103,9 +108,7 @@ static unsigned int try_to_freeze_tasks(int freeze_user_space)
103 if (frozen(p)) 108 if (frozen(p))
104 continue; 109 continue;
105 110
106 if (p->state == TASK_TRACED && 111 if (p->state == TASK_TRACED && frozen(p->parent)) {
107 (frozen(p->parent) ||
108 p->parent->state == TASK_STOPPED)) {
109 cancel_freezing(p); 112 cancel_freezing(p);
110 continue; 113 continue;
111 } 114 }
diff --git a/kernel/relay.c b/kernel/relay.c
index 818e514729cf..a4701e7ba7d0 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -138,7 +138,7 @@ depopulate:
138 */ 138 */
139struct rchan_buf *relay_create_buf(struct rchan *chan) 139struct rchan_buf *relay_create_buf(struct rchan *chan)
140{ 140{
141 struct rchan_buf *buf = kcalloc(1, sizeof(struct rchan_buf), GFP_KERNEL); 141 struct rchan_buf *buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
142 if (!buf) 142 if (!buf)
143 return NULL; 143 return NULL;
144 144
@@ -479,7 +479,7 @@ struct rchan *relay_open(const char *base_filename,
479 if (!(subbuf_size && n_subbufs)) 479 if (!(subbuf_size && n_subbufs))
480 return NULL; 480 return NULL;
481 481
482 chan = kcalloc(1, sizeof(struct rchan), GFP_KERNEL); 482 chan = kzalloc(sizeof(struct rchan), GFP_KERNEL);
483 if (!chan) 483 if (!chan)
484 return NULL; 484 return NULL;
485 485
diff --git a/kernel/sched.c b/kernel/sched.c
index 8a0afb97af71..5cd833bc2173 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3429,6 +3429,8 @@ asmlinkage void __sched schedule(void)
3429 "%s/0x%08x/%d\n", 3429 "%s/0x%08x/%d\n",
3430 current->comm, preempt_count(), current->pid); 3430 current->comm, preempt_count(), current->pid);
3431 debug_show_held_locks(current); 3431 debug_show_held_locks(current);
3432 if (irqs_disabled())
3433 print_irqtrace_events(current);
3432 dump_stack(); 3434 dump_stack();
3433 } 3435 }
3434 profile_hit(SCHED_PROFILING, __builtin_return_address(0)); 3436 profile_hit(SCHED_PROFILING, __builtin_return_address(0));
@@ -6977,6 +6979,8 @@ void __might_sleep(char *file, int line)
6977 printk("in_atomic():%d, irqs_disabled():%d\n", 6979 printk("in_atomic():%d, irqs_disabled():%d\n",
6978 in_atomic(), irqs_disabled()); 6980 in_atomic(), irqs_disabled());
6979 debug_show_held_locks(current); 6981 debug_show_held_locks(current);
6982 if (irqs_disabled())
6983 print_irqtrace_events(current);
6980 dump_stack(); 6984 dump_stack();
6981 } 6985 }
6982#endif 6986#endif
diff --git a/kernel/signal.c b/kernel/signal.c
index 1921ffdc5e77..5630255d2e2a 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1705,7 +1705,9 @@ finish_stop(int stop_count)
1705 read_unlock(&tasklist_lock); 1705 read_unlock(&tasklist_lock);
1706 } 1706 }
1707 1707
1708 schedule(); 1708 do {
1709 schedule();
1710 } while (try_to_freeze());
1709 /* 1711 /*
1710 * Now we don't run again until continued. 1712 * Now we don't run again until continued.
1711 */ 1713 */
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 130c5ec9ee0b..600b33358ded 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -65,7 +65,6 @@ extern int sysctl_overcommit_memory;
65extern int sysctl_overcommit_ratio; 65extern int sysctl_overcommit_ratio;
66extern int sysctl_panic_on_oom; 66extern int sysctl_panic_on_oom;
67extern int max_threads; 67extern int max_threads;
68extern int sysrq_enabled;
69extern int core_uses_pid; 68extern int core_uses_pid;
70extern int suid_dumpable; 69extern int suid_dumpable;
71extern char core_pattern[]; 70extern char core_pattern[];
@@ -543,7 +542,7 @@ static ctl_table kern_table[] = {
543 { 542 {
544 .ctl_name = KERN_SYSRQ, 543 .ctl_name = KERN_SYSRQ,
545 .procname = "sysrq", 544 .procname = "sysrq",
546 .data = &sysrq_enabled, 545 .data = &__sysrq_enabled,
547 .maxlen = sizeof (int), 546 .maxlen = sizeof (int),
548 .mode = 0644, 547 .mode = 0644,
549 .proc_handler = &proc_dointvec, 548 .proc_handler = &proc_dointvec,
diff --git a/kernel/timer.c b/kernel/timer.c
index 0256ab443d8a..feddf817baa5 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1146,11 +1146,15 @@ static inline void calc_load(unsigned long ticks)
1146 unsigned long active_tasks; /* fixed-point */ 1146 unsigned long active_tasks; /* fixed-point */
1147 static int count = LOAD_FREQ; 1147 static int count = LOAD_FREQ;
1148 1148
1149 active_tasks = count_active_tasks(); 1149 count -= ticks;
1150 for (count -= ticks; count < 0; count += LOAD_FREQ) { 1150 if (unlikely(count < 0)) {
1151 CALC_LOAD(avenrun[0], EXP_1, active_tasks); 1151 active_tasks = count_active_tasks();
1152 CALC_LOAD(avenrun[1], EXP_5, active_tasks); 1152 do {
1153 CALC_LOAD(avenrun[2], EXP_15, active_tasks); 1153 CALC_LOAD(avenrun[0], EXP_1, active_tasks);
1154 CALC_LOAD(avenrun[1], EXP_5, active_tasks);
1155 CALC_LOAD(avenrun[2], EXP_15, active_tasks);
1156 count += LOAD_FREQ;
1157 } while (count < 0);
1154 } 1158 }
1155} 1159}
1156 1160
diff --git a/kernel/unwind.c b/kernel/unwind.c
deleted file mode 100644
index 09c261329249..000000000000
--- a/kernel/unwind.c
+++ /dev/null
@@ -1,1305 +0,0 @@
1/*
2 * Copyright (C) 2002-2006 Novell, Inc.
3 * Jan Beulich <jbeulich@novell.com>
4 * This code is released under version 2 of the GNU GPL.
5 *
6 * A simple API for unwinding kernel stacks. This is used for
7 * debugging and error reporting purposes. The kernel doesn't need
8 * full-blown stack unwinding with all the bells and whistles, so there
9 * is not much point in implementing the full Dwarf2 unwind API.
10 */
11
12#include <linux/unwind.h>
13#include <linux/module.h>
14#include <linux/bootmem.h>
15#include <linux/sort.h>
16#include <linux/stop_machine.h>
17#include <linux/uaccess.h>
18#include <asm/sections.h>
19#include <asm/uaccess.h>
20#include <asm/unaligned.h>
21
22extern const char __start_unwind[], __end_unwind[];
23extern const u8 __start_unwind_hdr[], __end_unwind_hdr[];
24
25#define MAX_STACK_DEPTH 8
26
27#define EXTRA_INFO(f) { \
28 BUILD_BUG_ON_ZERO(offsetof(struct unwind_frame_info, f) \
29 % FIELD_SIZEOF(struct unwind_frame_info, f)) \
30 + offsetof(struct unwind_frame_info, f) \
31 / FIELD_SIZEOF(struct unwind_frame_info, f), \
32 FIELD_SIZEOF(struct unwind_frame_info, f) \
33 }
34#define PTREGS_INFO(f) EXTRA_INFO(regs.f)
35
36static const struct {
37 unsigned offs:BITS_PER_LONG / 2;
38 unsigned width:BITS_PER_LONG / 2;
39} reg_info[] = {
40 UNW_REGISTER_INFO
41};
42
43#undef PTREGS_INFO
44#undef EXTRA_INFO
45
46#ifndef REG_INVALID
47#define REG_INVALID(r) (reg_info[r].width == 0)
48#endif
49
50#define DW_CFA_nop 0x00
51#define DW_CFA_set_loc 0x01
52#define DW_CFA_advance_loc1 0x02
53#define DW_CFA_advance_loc2 0x03
54#define DW_CFA_advance_loc4 0x04
55#define DW_CFA_offset_extended 0x05
56#define DW_CFA_restore_extended 0x06
57#define DW_CFA_undefined 0x07
58#define DW_CFA_same_value 0x08
59#define DW_CFA_register 0x09
60#define DW_CFA_remember_state 0x0a
61#define DW_CFA_restore_state 0x0b
62#define DW_CFA_def_cfa 0x0c
63#define DW_CFA_def_cfa_register 0x0d
64#define DW_CFA_def_cfa_offset 0x0e
65#define DW_CFA_def_cfa_expression 0x0f
66#define DW_CFA_expression 0x10
67#define DW_CFA_offset_extended_sf 0x11
68#define DW_CFA_def_cfa_sf 0x12
69#define DW_CFA_def_cfa_offset_sf 0x13
70#define DW_CFA_val_offset 0x14
71#define DW_CFA_val_offset_sf 0x15
72#define DW_CFA_val_expression 0x16
73#define DW_CFA_lo_user 0x1c
74#define DW_CFA_GNU_window_save 0x2d
75#define DW_CFA_GNU_args_size 0x2e
76#define DW_CFA_GNU_negative_offset_extended 0x2f
77#define DW_CFA_hi_user 0x3f
78
79#define DW_EH_PE_FORM 0x07
80#define DW_EH_PE_native 0x00
81#define DW_EH_PE_leb128 0x01
82#define DW_EH_PE_data2 0x02
83#define DW_EH_PE_data4 0x03
84#define DW_EH_PE_data8 0x04
85#define DW_EH_PE_signed 0x08
86#define DW_EH_PE_ADJUST 0x70
87#define DW_EH_PE_abs 0x00
88#define DW_EH_PE_pcrel 0x10
89#define DW_EH_PE_textrel 0x20
90#define DW_EH_PE_datarel 0x30
91#define DW_EH_PE_funcrel 0x40
92#define DW_EH_PE_aligned 0x50
93#define DW_EH_PE_indirect 0x80
94#define DW_EH_PE_omit 0xff
95
96typedef unsigned long uleb128_t;
97typedef signed long sleb128_t;
98#define sleb128abs __builtin_labs
99
100static struct unwind_table {
101 struct {
102 unsigned long pc;
103 unsigned long range;
104 } core, init;
105 const void *address;
106 unsigned long size;
107 const unsigned char *header;
108 unsigned long hdrsz;
109 struct unwind_table *link;
110 const char *name;
111} root_table;
112
113struct unwind_item {
114 enum item_location {
115 Nowhere,
116 Memory,
117 Register,
118 Value
119 } where;
120 uleb128_t value;
121};
122
123struct unwind_state {
124 uleb128_t loc, org;
125 const u8 *cieStart, *cieEnd;
126 uleb128_t codeAlign;
127 sleb128_t dataAlign;
128 struct cfa {
129 uleb128_t reg, offs;
130 } cfa;
131 struct unwind_item regs[ARRAY_SIZE(reg_info)];
132 unsigned stackDepth:8;
133 unsigned version:8;
134 const u8 *label;
135 const u8 *stack[MAX_STACK_DEPTH];
136};
137
138static const struct cfa badCFA = { ARRAY_SIZE(reg_info), 1 };
139
140static unsigned unwind_debug;
141static int __init unwind_debug_setup(char *s)
142{
143 unwind_debug = simple_strtoul(s, NULL, 0);
144 return 1;
145}
146__setup("unwind_debug=", unwind_debug_setup);
147#define dprintk(lvl, fmt, args...) \
148 ((void)(lvl > unwind_debug \
149 || printk(KERN_DEBUG "unwind: " fmt "\n", ##args)))
150
151static struct unwind_table *find_table(unsigned long pc)
152{
153 struct unwind_table *table;
154
155 for (table = &root_table; table; table = table->link)
156 if ((pc >= table->core.pc
157 && pc < table->core.pc + table->core.range)
158 || (pc >= table->init.pc
159 && pc < table->init.pc + table->init.range))
160 break;
161
162 return table;
163}
164
165static unsigned long read_pointer(const u8 **pLoc,
166 const void *end,
167 signed ptrType,
168 unsigned long text_base,
169 unsigned long data_base);
170
171static void init_unwind_table(struct unwind_table *table,
172 const char *name,
173 const void *core_start,
174 unsigned long core_size,
175 const void *init_start,
176 unsigned long init_size,
177 const void *table_start,
178 unsigned long table_size,
179 const u8 *header_start,
180 unsigned long header_size)
181{
182 const u8 *ptr = header_start + 4;
183 const u8 *end = header_start + header_size;
184
185 table->core.pc = (unsigned long)core_start;
186 table->core.range = core_size;
187 table->init.pc = (unsigned long)init_start;
188 table->init.range = init_size;
189 table->address = table_start;
190 table->size = table_size;
191 /* See if the linker provided table looks valid. */
192 if (header_size <= 4
193 || header_start[0] != 1
194 || (void *)read_pointer(&ptr, end, header_start[1], 0, 0)
195 != table_start
196 || !read_pointer(&ptr, end, header_start[2], 0, 0)
197 || !read_pointer(&ptr, end, header_start[3], 0,
198 (unsigned long)header_start)
199 || !read_pointer(&ptr, end, header_start[3], 0,
200 (unsigned long)header_start))
201 header_start = NULL;
202 table->hdrsz = header_size;
203 smp_wmb();
204 table->header = header_start;
205 table->link = NULL;
206 table->name = name;
207}
208
209void __init unwind_init(void)
210{
211 init_unwind_table(&root_table, "kernel",
212 _text, _end - _text,
213 NULL, 0,
214 __start_unwind, __end_unwind - __start_unwind,
215 __start_unwind_hdr, __end_unwind_hdr - __start_unwind_hdr);
216}
217
218static const u32 bad_cie, not_fde;
219static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *);
220static signed fde_pointer_type(const u32 *cie);
221
222struct eh_frame_hdr_table_entry {
223 unsigned long start, fde;
224};
225
226static int cmp_eh_frame_hdr_table_entries(const void *p1, const void *p2)
227{
228 const struct eh_frame_hdr_table_entry *e1 = p1;
229 const struct eh_frame_hdr_table_entry *e2 = p2;
230
231 return (e1->start > e2->start) - (e1->start < e2->start);
232}
233
234static void swap_eh_frame_hdr_table_entries(void *p1, void *p2, int size)
235{
236 struct eh_frame_hdr_table_entry *e1 = p1;
237 struct eh_frame_hdr_table_entry *e2 = p2;
238 unsigned long v;
239
240 v = e1->start;
241 e1->start = e2->start;
242 e2->start = v;
243 v = e1->fde;
244 e1->fde = e2->fde;
245 e2->fde = v;
246}
247
248static void __init setup_unwind_table(struct unwind_table *table,
249 void *(*alloc)(unsigned long))
250{
251 const u8 *ptr;
252 unsigned long tableSize = table->size, hdrSize;
253 unsigned n;
254 const u32 *fde;
255 struct {
256 u8 version;
257 u8 eh_frame_ptr_enc;
258 u8 fde_count_enc;
259 u8 table_enc;
260 unsigned long eh_frame_ptr;
261 unsigned int fde_count;
262 struct eh_frame_hdr_table_entry table[];
263 } __attribute__((__packed__)) *header;
264
265 if (table->header)
266 return;
267
268 if (table->hdrsz)
269 printk(KERN_WARNING ".eh_frame_hdr for '%s' present but unusable\n",
270 table->name);
271
272 if (tableSize & (sizeof(*fde) - 1))
273 return;
274
275 for (fde = table->address, n = 0;
276 tableSize > sizeof(*fde) && tableSize - sizeof(*fde) >= *fde;
277 tableSize -= sizeof(*fde) + *fde, fde += 1 + *fde / sizeof(*fde)) {
278 const u32 *cie = cie_for_fde(fde, table);
279 signed ptrType;
280
281 if (cie == &not_fde)
282 continue;
283 if (cie == NULL
284 || cie == &bad_cie
285 || (ptrType = fde_pointer_type(cie)) < 0)
286 return;
287 ptr = (const u8 *)(fde + 2);
288 if (!read_pointer(&ptr,
289 (const u8 *)(fde + 1) + *fde,
290 ptrType, 0, 0))
291 return;
292 ++n;
293 }
294
295 if (tableSize || !n)
296 return;
297
298 hdrSize = 4 + sizeof(unsigned long) + sizeof(unsigned int)
299 + 2 * n * sizeof(unsigned long);
300 dprintk(2, "Binary lookup table size for %s: %lu bytes", table->name, hdrSize);
301 header = alloc(hdrSize);
302 if (!header)
303 return;
304 header->version = 1;
305 header->eh_frame_ptr_enc = DW_EH_PE_abs|DW_EH_PE_native;
306 header->fde_count_enc = DW_EH_PE_abs|DW_EH_PE_data4;
307 header->table_enc = DW_EH_PE_abs|DW_EH_PE_native;
308 put_unaligned((unsigned long)table->address, &header->eh_frame_ptr);
309 BUILD_BUG_ON(offsetof(typeof(*header), fde_count)
310 % __alignof(typeof(header->fde_count)));
311 header->fde_count = n;
312
313 BUILD_BUG_ON(offsetof(typeof(*header), table)
314 % __alignof(typeof(*header->table)));
315 for (fde = table->address, tableSize = table->size, n = 0;
316 tableSize;
317 tableSize -= sizeof(*fde) + *fde, fde += 1 + *fde / sizeof(*fde)) {
318 const u32 *cie = fde + 1 - fde[1] / sizeof(*fde);
319
320 if (!fde[1])
321 continue; /* this is a CIE */
322 ptr = (const u8 *)(fde + 2);
323 header->table[n].start = read_pointer(&ptr,
324 (const u8 *)(fde + 1) + *fde,
325 fde_pointer_type(cie), 0, 0);
326 header->table[n].fde = (unsigned long)fde;
327 ++n;
328 }
329 WARN_ON(n != header->fde_count);
330
331 sort(header->table,
332 n,
333 sizeof(*header->table),
334 cmp_eh_frame_hdr_table_entries,
335 swap_eh_frame_hdr_table_entries);
336
337 table->hdrsz = hdrSize;
338 smp_wmb();
339 table->header = (const void *)header;
340}
341
342static void *__init balloc(unsigned long sz)
343{
344 return __alloc_bootmem_nopanic(sz,
345 sizeof(unsigned int),
346 __pa(MAX_DMA_ADDRESS));
347}
348
349void __init unwind_setup(void)
350{
351 setup_unwind_table(&root_table, balloc);
352}
353
354#ifdef CONFIG_MODULES
355
356static struct unwind_table *last_table;
357
358/* Must be called with module_mutex held. */
359void *unwind_add_table(struct module *module,
360 const void *table_start,
361 unsigned long table_size)
362{
363 struct unwind_table *table;
364
365 if (table_size <= 0)
366 return NULL;
367
368 table = kmalloc(sizeof(*table), GFP_KERNEL);
369 if (!table)
370 return NULL;
371
372 init_unwind_table(table, module->name,
373 module->module_core, module->core_size,
374 module->module_init, module->init_size,
375 table_start, table_size,
376 NULL, 0);
377
378 if (last_table)
379 last_table->link = table;
380 else
381 root_table.link = table;
382 last_table = table;
383
384 return table;
385}
386
387struct unlink_table_info
388{
389 struct unwind_table *table;
390 int init_only;
391};
392
393static int unlink_table(void *arg)
394{
395 struct unlink_table_info *info = arg;
396 struct unwind_table *table = info->table, *prev;
397
398 for (prev = &root_table; prev->link && prev->link != table; prev = prev->link)
399 ;
400
401 if (prev->link) {
402 if (info->init_only) {
403 table->init.pc = 0;
404 table->init.range = 0;
405 info->table = NULL;
406 } else {
407 prev->link = table->link;
408 if (!prev->link)
409 last_table = prev;
410 }
411 } else
412 info->table = NULL;
413
414 return 0;
415}
416
417/* Must be called with module_mutex held. */
418void unwind_remove_table(void *handle, int init_only)
419{
420 struct unwind_table *table = handle;
421 struct unlink_table_info info;
422
423 if (!table || table == &root_table)
424 return;
425
426 if (init_only && table == last_table) {
427 table->init.pc = 0;
428 table->init.range = 0;
429 return;
430 }
431
432 info.table = table;
433 info.init_only = init_only;
434 stop_machine_run(unlink_table, &info, NR_CPUS);
435
436 if (info.table)
437 kfree(table);
438}
439
440#endif /* CONFIG_MODULES */
441
442static uleb128_t get_uleb128(const u8 **pcur, const u8 *end)
443{
444 const u8 *cur = *pcur;
445 uleb128_t value;
446 unsigned shift;
447
448 for (shift = 0, value = 0; cur < end; shift += 7) {
449 if (shift + 7 > 8 * sizeof(value)
450 && (*cur & 0x7fU) >= (1U << (8 * sizeof(value) - shift))) {
451 cur = end + 1;
452 break;
453 }
454 value |= (uleb128_t)(*cur & 0x7f) << shift;
455 if (!(*cur++ & 0x80))
456 break;
457 }
458 *pcur = cur;
459
460 return value;
461}
462
463static sleb128_t get_sleb128(const u8 **pcur, const u8 *end)
464{
465 const u8 *cur = *pcur;
466 sleb128_t value;
467 unsigned shift;
468
469 for (shift = 0, value = 0; cur < end; shift += 7) {
470 if (shift + 7 > 8 * sizeof(value)
471 && (*cur & 0x7fU) >= (1U << (8 * sizeof(value) - shift))) {
472 cur = end + 1;
473 break;
474 }
475 value |= (sleb128_t)(*cur & 0x7f) << shift;
476 if (!(*cur & 0x80)) {
477 value |= -(*cur++ & 0x40) << shift;
478 break;
479 }
480 }
481 *pcur = cur;
482
483 return value;
484}
485
486static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *table)
487{
488 const u32 *cie;
489
490 if (!*fde || (*fde & (sizeof(*fde) - 1)))
491 return &bad_cie;
492 if (!fde[1])
493 return &not_fde; /* this is a CIE */
494 if ((fde[1] & (sizeof(*fde) - 1))
495 || fde[1] > (unsigned long)(fde + 1) - (unsigned long)table->address)
496 return NULL; /* this is not a valid FDE */
497 cie = fde + 1 - fde[1] / sizeof(*fde);
498 if (*cie <= sizeof(*cie) + 4
499 || *cie >= fde[1] - sizeof(*fde)
500 || (*cie & (sizeof(*cie) - 1))
501 || cie[1])
502 return NULL; /* this is not a (valid) CIE */
503 return cie;
504}
505
506static unsigned long read_pointer(const u8 **pLoc,
507 const void *end,
508 signed ptrType,
509 unsigned long text_base,
510 unsigned long data_base)
511{
512 unsigned long value = 0;
513 union {
514 const u8 *p8;
515 const u16 *p16u;
516 const s16 *p16s;
517 const u32 *p32u;
518 const s32 *p32s;
519 const unsigned long *pul;
520 } ptr;
521
522 if (ptrType < 0 || ptrType == DW_EH_PE_omit) {
523 dprintk(1, "Invalid pointer encoding %02X (%p,%p).", ptrType, *pLoc, end);
524 return 0;
525 }
526 ptr.p8 = *pLoc;
527 switch(ptrType & DW_EH_PE_FORM) {
528 case DW_EH_PE_data2:
529 if (end < (const void *)(ptr.p16u + 1)) {
530 dprintk(1, "Data16 overrun (%p,%p).", ptr.p8, end);
531 return 0;
532 }
533 if(ptrType & DW_EH_PE_signed)
534 value = get_unaligned(ptr.p16s++);
535 else
536 value = get_unaligned(ptr.p16u++);
537 break;
538 case DW_EH_PE_data4:
539#ifdef CONFIG_64BIT
540 if (end < (const void *)(ptr.p32u + 1)) {
541 dprintk(1, "Data32 overrun (%p,%p).", ptr.p8, end);
542 return 0;
543 }
544 if(ptrType & DW_EH_PE_signed)
545 value = get_unaligned(ptr.p32s++);
546 else
547 value = get_unaligned(ptr.p32u++);
548 break;
549 case DW_EH_PE_data8:
550 BUILD_BUG_ON(sizeof(u64) != sizeof(value));
551#else
552 BUILD_BUG_ON(sizeof(u32) != sizeof(value));
553#endif
554 case DW_EH_PE_native:
555 if (end < (const void *)(ptr.pul + 1)) {
556 dprintk(1, "DataUL overrun (%p,%p).", ptr.p8, end);
557 return 0;
558 }
559 value = get_unaligned(ptr.pul++);
560 break;
561 case DW_EH_PE_leb128:
562 BUILD_BUG_ON(sizeof(uleb128_t) > sizeof(value));
563 value = ptrType & DW_EH_PE_signed
564 ? get_sleb128(&ptr.p8, end)
565 : get_uleb128(&ptr.p8, end);
566 if ((const void *)ptr.p8 > end) {
567 dprintk(1, "DataLEB overrun (%p,%p).", ptr.p8, end);
568 return 0;
569 }
570 break;
571 default:
572 dprintk(2, "Cannot decode pointer type %02X (%p,%p).",
573 ptrType, ptr.p8, end);
574 return 0;
575 }
576 switch(ptrType & DW_EH_PE_ADJUST) {
577 case DW_EH_PE_abs:
578 break;
579 case DW_EH_PE_pcrel:
580 value += (unsigned long)*pLoc;
581 break;
582 case DW_EH_PE_textrel:
583 if (likely(text_base)) {
584 value += text_base;
585 break;
586 }
587 dprintk(2, "Text-relative encoding %02X (%p,%p), but zero text base.",
588 ptrType, *pLoc, end);
589 return 0;
590 case DW_EH_PE_datarel:
591 if (likely(data_base)) {
592 value += data_base;
593 break;
594 }
595 dprintk(2, "Data-relative encoding %02X (%p,%p), but zero data base.",
596 ptrType, *pLoc, end);
597 return 0;
598 default:
599 dprintk(2, "Cannot adjust pointer type %02X (%p,%p).",
600 ptrType, *pLoc, end);
601 return 0;
602 }
603 if ((ptrType & DW_EH_PE_indirect)
604 && probe_kernel_address((unsigned long *)value, value)) {
605 dprintk(1, "Cannot read indirect value %lx (%p,%p).",
606 value, *pLoc, end);
607 return 0;
608 }
609 *pLoc = ptr.p8;
610
611 return value;
612}
613
614static signed fde_pointer_type(const u32 *cie)
615{
616 const u8 *ptr = (const u8 *)(cie + 2);
617 unsigned version = *ptr;
618
619 if (version != 1)
620 return -1; /* unsupported */
621 if (*++ptr) {
622 const char *aug;
623 const u8 *end = (const u8 *)(cie + 1) + *cie;
624 uleb128_t len;
625
626 /* check if augmentation size is first (and thus present) */
627 if (*ptr != 'z')
628 return -1;
629 /* check if augmentation string is nul-terminated */
630 if ((ptr = memchr(aug = (const void *)ptr, 0, end - ptr)) == NULL)
631 return -1;
632 ++ptr; /* skip terminator */
633 get_uleb128(&ptr, end); /* skip code alignment */
634 get_sleb128(&ptr, end); /* skip data alignment */
635 /* skip return address column */
636 version <= 1 ? (void)++ptr : (void)get_uleb128(&ptr, end);
637 len = get_uleb128(&ptr, end); /* augmentation length */
638 if (ptr + len < ptr || ptr + len > end)
639 return -1;
640 end = ptr + len;
641 while (*++aug) {
642 if (ptr >= end)
643 return -1;
644 switch(*aug) {
645 case 'L':
646 ++ptr;
647 break;
648 case 'P': {
649 signed ptrType = *ptr++;
650
651 if (!read_pointer(&ptr, end, ptrType, 0, 0)
652 || ptr > end)
653 return -1;
654 }
655 break;
656 case 'R':
657 return *ptr;
658 default:
659 return -1;
660 }
661 }
662 }
663 return DW_EH_PE_native|DW_EH_PE_abs;
664}
665
666static int advance_loc(unsigned long delta, struct unwind_state *state)
667{
668 state->loc += delta * state->codeAlign;
669
670 return delta > 0;
671}
672
673static void set_rule(uleb128_t reg,
674 enum item_location where,
675 uleb128_t value,
676 struct unwind_state *state)
677{
678 if (reg < ARRAY_SIZE(state->regs)) {
679 state->regs[reg].where = where;
680 state->regs[reg].value = value;
681 }
682}
683
684static int processCFI(const u8 *start,
685 const u8 *end,
686 unsigned long targetLoc,
687 signed ptrType,
688 struct unwind_state *state)
689{
690 union {
691 const u8 *p8;
692 const u16 *p16;
693 const u32 *p32;
694 } ptr;
695 int result = 1;
696
697 if (start != state->cieStart) {
698 state->loc = state->org;
699 result = processCFI(state->cieStart, state->cieEnd, 0, ptrType, state);
700 if (targetLoc == 0 && state->label == NULL)
701 return result;
702 }
703 for (ptr.p8 = start; result && ptr.p8 < end; ) {
704 switch(*ptr.p8 >> 6) {
705 uleb128_t value;
706
707 case 0:
708 switch(*ptr.p8++) {
709 case DW_CFA_nop:
710 break;
711 case DW_CFA_set_loc:
712 state->loc = read_pointer(&ptr.p8, end, ptrType, 0, 0);
713 if (state->loc == 0)
714 result = 0;
715 break;
716 case DW_CFA_advance_loc1:
717 result = ptr.p8 < end && advance_loc(*ptr.p8++, state);
718 break;
719 case DW_CFA_advance_loc2:
720 result = ptr.p8 <= end + 2
721 && advance_loc(*ptr.p16++, state);
722 break;
723 case DW_CFA_advance_loc4:
724 result = ptr.p8 <= end + 4
725 && advance_loc(*ptr.p32++, state);
726 break;
727 case DW_CFA_offset_extended:
728 value = get_uleb128(&ptr.p8, end);
729 set_rule(value, Memory, get_uleb128(&ptr.p8, end), state);
730 break;
731 case DW_CFA_val_offset:
732 value = get_uleb128(&ptr.p8, end);
733 set_rule(value, Value, get_uleb128(&ptr.p8, end), state);
734 break;
735 case DW_CFA_offset_extended_sf:
736 value = get_uleb128(&ptr.p8, end);
737 set_rule(value, Memory, get_sleb128(&ptr.p8, end), state);
738 break;
739 case DW_CFA_val_offset_sf:
740 value = get_uleb128(&ptr.p8, end);
741 set_rule(value, Value, get_sleb128(&ptr.p8, end), state);
742 break;
743 case DW_CFA_restore_extended:
744 case DW_CFA_undefined:
745 case DW_CFA_same_value:
746 set_rule(get_uleb128(&ptr.p8, end), Nowhere, 0, state);
747 break;
748 case DW_CFA_register:
749 value = get_uleb128(&ptr.p8, end);
750 set_rule(value,
751 Register,
752 get_uleb128(&ptr.p8, end), state);
753 break;
754 case DW_CFA_remember_state:
755 if (ptr.p8 == state->label) {
756 state->label = NULL;
757 return 1;
758 }
759 if (state->stackDepth >= MAX_STACK_DEPTH) {
760 dprintk(1, "State stack overflow (%p,%p).", ptr.p8, end);
761 return 0;
762 }
763 state->stack[state->stackDepth++] = ptr.p8;
764 break;
765 case DW_CFA_restore_state:
766 if (state->stackDepth) {
767 const uleb128_t loc = state->loc;
768 const u8 *label = state->label;
769
770 state->label = state->stack[state->stackDepth - 1];
771 memcpy(&state->cfa, &badCFA, sizeof(state->cfa));
772 memset(state->regs, 0, sizeof(state->regs));
773 state->stackDepth = 0;
774 result = processCFI(start, end, 0, ptrType, state);
775 state->loc = loc;
776 state->label = label;
777 } else {
778 dprintk(1, "State stack underflow (%p,%p).", ptr.p8, end);
779 return 0;
780 }
781 break;
782 case DW_CFA_def_cfa:
783 state->cfa.reg = get_uleb128(&ptr.p8, end);
784 /*nobreak*/
785 case DW_CFA_def_cfa_offset:
786 state->cfa.offs = get_uleb128(&ptr.p8, end);
787 break;
788 case DW_CFA_def_cfa_sf:
789 state->cfa.reg = get_uleb128(&ptr.p8, end);
790 /*nobreak*/
791 case DW_CFA_def_cfa_offset_sf:
792 state->cfa.offs = get_sleb128(&ptr.p8, end)
793 * state->dataAlign;
794 break;
795 case DW_CFA_def_cfa_register:
796 state->cfa.reg = get_uleb128(&ptr.p8, end);
797 break;
798 /*todo case DW_CFA_def_cfa_expression: */
799 /*todo case DW_CFA_expression: */
800 /*todo case DW_CFA_val_expression: */
801 case DW_CFA_GNU_args_size:
802 get_uleb128(&ptr.p8, end);
803 break;
804 case DW_CFA_GNU_negative_offset_extended:
805 value = get_uleb128(&ptr.p8, end);
806 set_rule(value,
807 Memory,
808 (uleb128_t)0 - get_uleb128(&ptr.p8, end), state);
809 break;
810 case DW_CFA_GNU_window_save:
811 default:
812 dprintk(1, "Unrecognized CFI op %02X (%p,%p).", ptr.p8[-1], ptr.p8 - 1, end);
813 result = 0;
814 break;
815 }
816 break;
817 case 1:
818 result = advance_loc(*ptr.p8++ & 0x3f, state);
819 break;
820 case 2:
821 value = *ptr.p8++ & 0x3f;
822 set_rule(value, Memory, get_uleb128(&ptr.p8, end), state);
823 break;
824 case 3:
825 set_rule(*ptr.p8++ & 0x3f, Nowhere, 0, state);
826 break;
827 }
828 if (ptr.p8 > end) {
829 dprintk(1, "Data overrun (%p,%p).", ptr.p8, end);
830 result = 0;
831 }
832 if (result && targetLoc != 0 && targetLoc < state->loc)
833 return 1;
834 }
835
836 if (result && ptr.p8 < end)
837 dprintk(1, "Data underrun (%p,%p).", ptr.p8, end);
838
839 return result
840 && ptr.p8 == end
841 && (targetLoc == 0
842 || (/*todo While in theory this should apply, gcc in practice omits
843 everything past the function prolog, and hence the location
844 never reaches the end of the function.
845 targetLoc < state->loc &&*/ state->label == NULL));
846}
847
848/* Unwind to previous to frame. Returns 0 if successful, negative
849 * number in case of an error. */
850int unwind(struct unwind_frame_info *frame)
851{
852#define FRAME_REG(r, t) (((t *)frame)[reg_info[r].offs])
853 const u32 *fde = NULL, *cie = NULL;
854 const u8 *ptr = NULL, *end = NULL;
855 unsigned long pc = UNW_PC(frame) - frame->call_frame, sp;
856 unsigned long startLoc = 0, endLoc = 0, cfa;
857 unsigned i;
858 signed ptrType = -1;
859 uleb128_t retAddrReg = 0;
860 const struct unwind_table *table;
861 struct unwind_state state;
862
863 if (UNW_PC(frame) == 0)
864 return -EINVAL;
865 if ((table = find_table(pc)) != NULL
866 && !(table->size & (sizeof(*fde) - 1))) {
867 const u8 *hdr = table->header;
868 unsigned long tableSize;
869
870 smp_rmb();
871 if (hdr && hdr[0] == 1) {
872 switch(hdr[3] & DW_EH_PE_FORM) {
873 case DW_EH_PE_native: tableSize = sizeof(unsigned long); break;
874 case DW_EH_PE_data2: tableSize = 2; break;
875 case DW_EH_PE_data4: tableSize = 4; break;
876 case DW_EH_PE_data8: tableSize = 8; break;
877 default: tableSize = 0; break;
878 }
879 ptr = hdr + 4;
880 end = hdr + table->hdrsz;
881 if (tableSize
882 && read_pointer(&ptr, end, hdr[1], 0, 0)
883 == (unsigned long)table->address
884 && (i = read_pointer(&ptr, end, hdr[2], 0, 0)) > 0
885 && i == (end - ptr) / (2 * tableSize)
886 && !((end - ptr) % (2 * tableSize))) {
887 do {
888 const u8 *cur = ptr + (i / 2) * (2 * tableSize);
889
890 startLoc = read_pointer(&cur,
891 cur + tableSize,
892 hdr[3], 0,
893 (unsigned long)hdr);
894 if (pc < startLoc)
895 i /= 2;
896 else {
897 ptr = cur - tableSize;
898 i = (i + 1) / 2;
899 }
900 } while (startLoc && i > 1);
901 if (i == 1
902 && (startLoc = read_pointer(&ptr,
903 ptr + tableSize,
904 hdr[3], 0,
905 (unsigned long)hdr)) != 0
906 && pc >= startLoc)
907 fde = (void *)read_pointer(&ptr,
908 ptr + tableSize,
909 hdr[3], 0,
910 (unsigned long)hdr);
911 }
912 }
913 if(hdr && !fde)
914 dprintk(3, "Binary lookup for %lx failed.", pc);
915
916 if (fde != NULL) {
917 cie = cie_for_fde(fde, table);
918 ptr = (const u8 *)(fde + 2);
919 if(cie != NULL
920 && cie != &bad_cie
921 && cie != &not_fde
922 && (ptrType = fde_pointer_type(cie)) >= 0
923 && read_pointer(&ptr,
924 (const u8 *)(fde + 1) + *fde,
925 ptrType, 0, 0) == startLoc) {
926 if (!(ptrType & DW_EH_PE_indirect))
927 ptrType &= DW_EH_PE_FORM|DW_EH_PE_signed;
928 endLoc = startLoc
929 + read_pointer(&ptr,
930 (const u8 *)(fde + 1) + *fde,
931 ptrType, 0, 0);
932 if(pc >= endLoc)
933 fde = NULL;
934 } else
935 fde = NULL;
936 if(!fde)
937 dprintk(1, "Binary lookup result for %lx discarded.", pc);
938 }
939 if (fde == NULL) {
940 for (fde = table->address, tableSize = table->size;
941 cie = NULL, tableSize > sizeof(*fde)
942 && tableSize - sizeof(*fde) >= *fde;
943 tableSize -= sizeof(*fde) + *fde,
944 fde += 1 + *fde / sizeof(*fde)) {
945 cie = cie_for_fde(fde, table);
946 if (cie == &bad_cie) {
947 cie = NULL;
948 break;
949 }
950 if (cie == NULL
951 || cie == &not_fde
952 || (ptrType = fde_pointer_type(cie)) < 0)
953 continue;
954 ptr = (const u8 *)(fde + 2);
955 startLoc = read_pointer(&ptr,
956 (const u8 *)(fde + 1) + *fde,
957 ptrType, 0, 0);
958 if (!startLoc)
959 continue;
960 if (!(ptrType & DW_EH_PE_indirect))
961 ptrType &= DW_EH_PE_FORM|DW_EH_PE_signed;
962 endLoc = startLoc
963 + read_pointer(&ptr,
964 (const u8 *)(fde + 1) + *fde,
965 ptrType, 0, 0);
966 if (pc >= startLoc && pc < endLoc)
967 break;
968 }
969 if(!fde)
970 dprintk(3, "Linear lookup for %lx failed.", pc);
971 }
972 }
973 if (cie != NULL) {
974 memset(&state, 0, sizeof(state));
975 state.cieEnd = ptr; /* keep here temporarily */
976 ptr = (const u8 *)(cie + 2);
977 end = (const u8 *)(cie + 1) + *cie;
978 frame->call_frame = 1;
979 if ((state.version = *ptr) != 1)
980 cie = NULL; /* unsupported version */
981 else if (*++ptr) {
982 /* check if augmentation size is first (and thus present) */
983 if (*ptr == 'z') {
984 while (++ptr < end && *ptr) {
985 switch(*ptr) {
986 /* check for ignorable (or already handled)
987 * nul-terminated augmentation string */
988 case 'L':
989 case 'P':
990 case 'R':
991 continue;
992 case 'S':
993 frame->call_frame = 0;
994 continue;
995 default:
996 break;
997 }
998 break;
999 }
1000 }
1001 if (ptr >= end || *ptr)
1002 cie = NULL;
1003 }
1004 if(!cie)
1005 dprintk(1, "CIE unusable (%p,%p).", ptr, end);
1006 ++ptr;
1007 }
1008 if (cie != NULL) {
1009 /* get code aligment factor */
1010 state.codeAlign = get_uleb128(&ptr, end);
1011 /* get data aligment factor */
1012 state.dataAlign = get_sleb128(&ptr, end);
1013 if (state.codeAlign == 0 || state.dataAlign == 0 || ptr >= end)
1014 cie = NULL;
1015 else if (UNW_PC(frame) % state.codeAlign
1016 || UNW_SP(frame) % sleb128abs(state.dataAlign)) {
1017 dprintk(1, "Input pointer(s) misaligned (%lx,%lx).",
1018 UNW_PC(frame), UNW_SP(frame));
1019 return -EPERM;
1020 } else {
1021 retAddrReg = state.version <= 1 ? *ptr++ : get_uleb128(&ptr, end);
1022 /* skip augmentation */
1023 if (((const char *)(cie + 2))[1] == 'z') {
1024 uleb128_t augSize = get_uleb128(&ptr, end);
1025
1026 ptr += augSize;
1027 }
1028 if (ptr > end
1029 || retAddrReg >= ARRAY_SIZE(reg_info)
1030 || REG_INVALID(retAddrReg)
1031 || reg_info[retAddrReg].width != sizeof(unsigned long))
1032 cie = NULL;
1033 }
1034 if(!cie)
1035 dprintk(1, "CIE validation failed (%p,%p).", ptr, end);
1036 }
1037 if (cie != NULL) {
1038 state.cieStart = ptr;
1039 ptr = state.cieEnd;
1040 state.cieEnd = end;
1041 end = (const u8 *)(fde + 1) + *fde;
1042 /* skip augmentation */
1043 if (((const char *)(cie + 2))[1] == 'z') {
1044 uleb128_t augSize = get_uleb128(&ptr, end);
1045
1046 if ((ptr += augSize) > end)
1047 fde = NULL;
1048 }
1049 if(!fde)
1050 dprintk(1, "FDE validation failed (%p,%p).", ptr, end);
1051 }
1052 if (cie == NULL || fde == NULL) {
1053#ifdef CONFIG_FRAME_POINTER
1054 unsigned long top, bottom;
1055
1056 if ((UNW_SP(frame) | UNW_FP(frame)) % sizeof(unsigned long))
1057 return -EPERM;
1058 top = STACK_TOP(frame->task);
1059 bottom = STACK_BOTTOM(frame->task);
1060# if FRAME_RETADDR_OFFSET < 0
1061 if (UNW_SP(frame) < top
1062 && UNW_FP(frame) <= UNW_SP(frame)
1063 && bottom < UNW_FP(frame)
1064# else
1065 if (UNW_SP(frame) > top
1066 && UNW_FP(frame) >= UNW_SP(frame)
1067 && bottom > UNW_FP(frame)
1068# endif
1069 && !((UNW_SP(frame) | UNW_FP(frame))
1070 & (sizeof(unsigned long) - 1))) {
1071 unsigned long link;
1072
1073 if (!probe_kernel_address(
1074 (unsigned long *)(UNW_FP(frame)
1075 + FRAME_LINK_OFFSET),
1076 link)
1077# if FRAME_RETADDR_OFFSET < 0
1078 && link > bottom && link < UNW_FP(frame)
1079# else
1080 && link > UNW_FP(frame) && link < bottom
1081# endif
1082 && !(link & (sizeof(link) - 1))
1083 && !probe_kernel_address(
1084 (unsigned long *)(UNW_FP(frame)
1085 + FRAME_RETADDR_OFFSET), UNW_PC(frame))) {
1086 UNW_SP(frame) = UNW_FP(frame) + FRAME_RETADDR_OFFSET
1087# if FRAME_RETADDR_OFFSET < 0
1088 -
1089# else
1090 +
1091# endif
1092 sizeof(UNW_PC(frame));
1093 UNW_FP(frame) = link;
1094 return 0;
1095 }
1096 }
1097#endif
1098 return -ENXIO;
1099 }
1100 state.org = startLoc;
1101 memcpy(&state.cfa, &badCFA, sizeof(state.cfa));
1102 /* process instructions */
1103 if (!processCFI(ptr, end, pc, ptrType, &state)
1104 || state.loc > endLoc
1105 || state.regs[retAddrReg].where == Nowhere
1106 || state.cfa.reg >= ARRAY_SIZE(reg_info)
1107 || reg_info[state.cfa.reg].width != sizeof(unsigned long)
1108 || FRAME_REG(state.cfa.reg, unsigned long) % sizeof(unsigned long)
1109 || state.cfa.offs % sizeof(unsigned long)) {
1110 dprintk(1, "Unusable unwind info (%p,%p).", ptr, end);
1111 return -EIO;
1112 }
1113 /* update frame */
1114#ifndef CONFIG_AS_CFI_SIGNAL_FRAME
1115 if(frame->call_frame
1116 && !UNW_DEFAULT_RA(state.regs[retAddrReg], state.dataAlign))
1117 frame->call_frame = 0;
1118#endif
1119 cfa = FRAME_REG(state.cfa.reg, unsigned long) + state.cfa.offs;
1120 startLoc = min((unsigned long)UNW_SP(frame), cfa);
1121 endLoc = max((unsigned long)UNW_SP(frame), cfa);
1122 if (STACK_LIMIT(startLoc) != STACK_LIMIT(endLoc)) {
1123 startLoc = min(STACK_LIMIT(cfa), cfa);
1124 endLoc = max(STACK_LIMIT(cfa), cfa);
1125 }
1126#ifndef CONFIG_64BIT
1127# define CASES CASE(8); CASE(16); CASE(32)
1128#else
1129# define CASES CASE(8); CASE(16); CASE(32); CASE(64)
1130#endif
1131 pc = UNW_PC(frame);
1132 sp = UNW_SP(frame);
1133 for (i = 0; i < ARRAY_SIZE(state.regs); ++i) {
1134 if (REG_INVALID(i)) {
1135 if (state.regs[i].where == Nowhere)
1136 continue;
1137 dprintk(1, "Cannot restore register %u (%d).",
1138 i, state.regs[i].where);
1139 return -EIO;
1140 }
1141 switch(state.regs[i].where) {
1142 default:
1143 break;
1144 case Register:
1145 if (state.regs[i].value >= ARRAY_SIZE(reg_info)
1146 || REG_INVALID(state.regs[i].value)
1147 || reg_info[i].width > reg_info[state.regs[i].value].width) {
1148 dprintk(1, "Cannot restore register %u from register %lu.",
1149 i, state.regs[i].value);
1150 return -EIO;
1151 }
1152 switch(reg_info[state.regs[i].value].width) {
1153#define CASE(n) \
1154 case sizeof(u##n): \
1155 state.regs[i].value = FRAME_REG(state.regs[i].value, \
1156 const u##n); \
1157 break
1158 CASES;
1159#undef CASE
1160 default:
1161 dprintk(1, "Unsupported register size %u (%lu).",
1162 reg_info[state.regs[i].value].width,
1163 state.regs[i].value);
1164 return -EIO;
1165 }
1166 break;
1167 }
1168 }
1169 for (i = 0; i < ARRAY_SIZE(state.regs); ++i) {
1170 if (REG_INVALID(i))
1171 continue;
1172 switch(state.regs[i].where) {
1173 case Nowhere:
1174 if (reg_info[i].width != sizeof(UNW_SP(frame))
1175 || &FRAME_REG(i, __typeof__(UNW_SP(frame)))
1176 != &UNW_SP(frame))
1177 continue;
1178 UNW_SP(frame) = cfa;
1179 break;
1180 case Register:
1181 switch(reg_info[i].width) {
1182#define CASE(n) case sizeof(u##n): \
1183 FRAME_REG(i, u##n) = state.regs[i].value; \
1184 break
1185 CASES;
1186#undef CASE
1187 default:
1188 dprintk(1, "Unsupported register size %u (%u).",
1189 reg_info[i].width, i);
1190 return -EIO;
1191 }
1192 break;
1193 case Value:
1194 if (reg_info[i].width != sizeof(unsigned long)) {
1195 dprintk(1, "Unsupported value size %u (%u).",
1196 reg_info[i].width, i);
1197 return -EIO;
1198 }
1199 FRAME_REG(i, unsigned long) = cfa + state.regs[i].value
1200 * state.dataAlign;
1201 break;
1202 case Memory: {
1203 unsigned long addr = cfa + state.regs[i].value
1204 * state.dataAlign;
1205
1206 if ((state.regs[i].value * state.dataAlign)
1207 % sizeof(unsigned long)
1208 || addr < startLoc
1209 || addr + sizeof(unsigned long) < addr
1210 || addr + sizeof(unsigned long) > endLoc) {
1211 dprintk(1, "Bad memory location %lx (%lx).",
1212 addr, state.regs[i].value);
1213 return -EIO;
1214 }
1215 switch(reg_info[i].width) {
1216#define CASE(n) case sizeof(u##n): \
1217 probe_kernel_address((u##n *)addr, FRAME_REG(i, u##n)); \
1218 break
1219 CASES;
1220#undef CASE
1221 default:
1222 dprintk(1, "Unsupported memory size %u (%u).",
1223 reg_info[i].width, i);
1224 return -EIO;
1225 }
1226 }
1227 break;
1228 }
1229 }
1230
1231 if (UNW_PC(frame) % state.codeAlign
1232 || UNW_SP(frame) % sleb128abs(state.dataAlign)) {
1233 dprintk(1, "Output pointer(s) misaligned (%lx,%lx).",
1234 UNW_PC(frame), UNW_SP(frame));
1235 return -EIO;
1236 }
1237 if (pc == UNW_PC(frame) && sp == UNW_SP(frame)) {
1238 dprintk(1, "No progress (%lx,%lx).", pc, sp);
1239 return -EIO;
1240 }
1241
1242 return 0;
1243#undef CASES
1244#undef FRAME_REG
1245}
1246EXPORT_SYMBOL(unwind);
1247
1248int unwind_init_frame_info(struct unwind_frame_info *info,
1249 struct task_struct *tsk,
1250 /*const*/ struct pt_regs *regs)
1251{
1252 info->task = tsk;
1253 info->call_frame = 0;
1254 arch_unw_init_frame_info(info, regs);
1255
1256 return 0;
1257}
1258EXPORT_SYMBOL(unwind_init_frame_info);
1259
1260/*
1261 * Prepare to unwind a blocked task.
1262 */
1263int unwind_init_blocked(struct unwind_frame_info *info,
1264 struct task_struct *tsk)
1265{
1266 info->task = tsk;
1267 info->call_frame = 0;
1268 arch_unw_init_blocked(info);
1269
1270 return 0;
1271}
1272EXPORT_SYMBOL(unwind_init_blocked);
1273
1274/*
1275 * Prepare to unwind the currently running thread.
1276 */
1277int unwind_init_running(struct unwind_frame_info *info,
1278 asmlinkage int (*callback)(struct unwind_frame_info *,
1279 void *arg),
1280 void *arg)
1281{
1282 info->task = current;
1283 info->call_frame = 0;
1284
1285 return arch_unwind_init_running(info, callback, arg);
1286}
1287EXPORT_SYMBOL(unwind_init_running);
1288
1289/*
1290 * Unwind until the return pointer is in user-land (or until an error
1291 * occurs). Returns 0 if successful, negative number in case of
1292 * error.
1293 */
1294int unwind_to_user(struct unwind_frame_info *info)
1295{
1296 while (!arch_unw_user_mode(info)) {
1297 int err = unwind(info);
1298
1299 if (err < 0)
1300 return err;
1301 }
1302
1303 return 0;
1304}
1305EXPORT_SYMBOL(unwind_to_user);
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index db49886bfae1..742cbbe49bdc 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -96,13 +96,13 @@ static inline void set_wq_data(struct work_struct *work, void *wq)
96 BUG_ON(!work_pending(work)); 96 BUG_ON(!work_pending(work));
97 97
98 new = (unsigned long) wq | (1UL << WORK_STRUCT_PENDING); 98 new = (unsigned long) wq | (1UL << WORK_STRUCT_PENDING);
99 new |= work->management & WORK_STRUCT_FLAG_MASK; 99 new |= WORK_STRUCT_FLAG_MASK & *work_data_bits(work);
100 work->management = new; 100 atomic_long_set(&work->data, new);
101} 101}
102 102
103static inline void *get_wq_data(struct work_struct *work) 103static inline void *get_wq_data(struct work_struct *work)
104{ 104{
105 return (void *) (work->management & WORK_STRUCT_WQ_DATA_MASK); 105 return (void *) (atomic_long_read(&work->data) & WORK_STRUCT_WQ_DATA_MASK);
106} 106}
107 107
108static int __run_work(struct cpu_workqueue_struct *cwq, struct work_struct *work) 108static int __run_work(struct cpu_workqueue_struct *cwq, struct work_struct *work)
@@ -133,7 +133,7 @@ static int __run_work(struct cpu_workqueue_struct *cwq, struct work_struct *work
133 list_del_init(&work->entry); 133 list_del_init(&work->entry);
134 spin_unlock_irqrestore(&cwq->lock, flags); 134 spin_unlock_irqrestore(&cwq->lock, flags);
135 135
136 if (!test_bit(WORK_STRUCT_NOAUTOREL, &work->management)) 136 if (!test_bit(WORK_STRUCT_NOAUTOREL, work_data_bits(work)))
137 work_release(work); 137 work_release(work);
138 f(work); 138 f(work);
139 139
@@ -206,7 +206,7 @@ int fastcall queue_work(struct workqueue_struct *wq, struct work_struct *work)
206{ 206{
207 int ret = 0, cpu = get_cpu(); 207 int ret = 0, cpu = get_cpu();
208 208
209 if (!test_and_set_bit(WORK_STRUCT_PENDING, &work->management)) { 209 if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) {
210 if (unlikely(is_single_threaded(wq))) 210 if (unlikely(is_single_threaded(wq)))
211 cpu = singlethread_cpu; 211 cpu = singlethread_cpu;
212 BUG_ON(!list_empty(&work->entry)); 212 BUG_ON(!list_empty(&work->entry));
@@ -248,7 +248,7 @@ int fastcall queue_delayed_work(struct workqueue_struct *wq,
248 if (delay == 0) 248 if (delay == 0)
249 return queue_work(wq, work); 249 return queue_work(wq, work);
250 250
251 if (!test_and_set_bit(WORK_STRUCT_PENDING, &work->management)) { 251 if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) {
252 BUG_ON(timer_pending(timer)); 252 BUG_ON(timer_pending(timer));
253 BUG_ON(!list_empty(&work->entry)); 253 BUG_ON(!list_empty(&work->entry));
254 254
@@ -280,7 +280,7 @@ int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
280 struct timer_list *timer = &dwork->timer; 280 struct timer_list *timer = &dwork->timer;
281 struct work_struct *work = &dwork->work; 281 struct work_struct *work = &dwork->work;
282 282
283 if (!test_and_set_bit(WORK_STRUCT_PENDING, &work->management)) { 283 if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) {
284 BUG_ON(timer_pending(timer)); 284 BUG_ON(timer_pending(timer));
285 BUG_ON(!list_empty(&work->entry)); 285 BUG_ON(!list_empty(&work->entry));
286 286
@@ -321,7 +321,7 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq)
321 spin_unlock_irqrestore(&cwq->lock, flags); 321 spin_unlock_irqrestore(&cwq->lock, flags);
322 322
323 BUG_ON(get_wq_data(work) != cwq); 323 BUG_ON(get_wq_data(work) != cwq);
324 if (!test_bit(WORK_STRUCT_NOAUTOREL, &work->management)) 324 if (!test_bit(WORK_STRUCT_NOAUTOREL, work_data_bits(work)))
325 work_release(work); 325 work_release(work);
326 f(work); 326 f(work);
327 327
diff --git a/lib/Kconfig b/lib/Kconfig
index 47b172df3e31..9b03581cdecb 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -101,4 +101,9 @@ config TEXTSEARCH_FSM
101config PLIST 101config PLIST
102 boolean 102 boolean
103 103
104config IOMAP_COPY
105 boolean
106 depends on !UML
107 default y
108
104endmenu 109endmenu
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 818e4589f718..5c2681875b9a 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -354,24 +354,6 @@ config FRAME_POINTER
354 some architectures or if you use external debuggers. 354 some architectures or if you use external debuggers.
355 If you don't debug the kernel, you can say N. 355 If you don't debug the kernel, you can say N.
356 356
357config UNWIND_INFO
358 bool "Compile the kernel with frame unwind information"
359 depends on !IA64 && !PARISC && !ARM
360 depends on !MODULES || !(MIPS || PPC || SUPERH || V850)
361 help
362 If you say Y here the resulting kernel image will be slightly larger
363 but not slower, and it will give very useful debugging information.
364 If you don't debug the kernel, you can say N, but we may not be able
365 to solve problems without frame unwind information or frame pointers.
366
367config STACK_UNWIND
368 bool "Stack unwind support"
369 depends on UNWIND_INFO
370 depends on X86
371 help
372 This enables more precise stack traces, omitting all unrelated
373 occurrences of pointers into kernel code from the dump.
374
375config FORCED_INLINING 357config FORCED_INLINING
376 bool "Force gcc to inline functions marked 'inline'" 358 bool "Force gcc to inline functions marked 'inline'"
377 depends on DEBUG_KERNEL 359 depends on DEBUG_KERNEL
diff --git a/lib/Makefile b/lib/Makefile
index 2d6106af53cd..77b4bad7d441 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -5,20 +5,21 @@
5lib-y := ctype.o string.o vsprintf.o cmdline.o \ 5lib-y := ctype.o string.o vsprintf.o cmdline.o \
6 bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \ 6 bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \
7 idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \ 7 idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \
8 sha1.o irq_regs.o 8 sha1.o irq_regs.o reciprocal_div.o
9 9
10lib-$(CONFIG_MMU) += ioremap.o 10lib-$(CONFIG_MMU) += ioremap.o
11lib-$(CONFIG_SMP) += cpumask.o 11lib-$(CONFIG_SMP) += cpumask.o
12 12
13lib-y += kobject.o kref.o kobject_uevent.o klist.o 13lib-y += kobject.o kref.o kobject_uevent.o klist.o
14 14
15obj-y += sort.o parser.o halfmd4.o iomap_copy.o debug_locks.o random32.o 15obj-y += sort.o parser.o halfmd4.o debug_locks.o random32.o
16 16
17ifeq ($(CONFIG_DEBUG_KOBJECT),y) 17ifeq ($(CONFIG_DEBUG_KOBJECT),y)
18CFLAGS_kobject.o += -DDEBUG 18CFLAGS_kobject.o += -DDEBUG
19CFLAGS_kobject_uevent.o += -DDEBUG 19CFLAGS_kobject_uevent.o += -DDEBUG
20endif 20endif
21 21
22obj-$(CONFIG_IOMAP_COPY) += iomap_copy.o
22obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o 23obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
23obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o 24obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o
24lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o 25lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index d143c0faf248..b5a90fc056d3 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -55,37 +55,7 @@ static bool fail_task(struct fault_attr *attr, struct task_struct *task)
55 55
56#define MAX_STACK_TRACE_DEPTH 32 56#define MAX_STACK_TRACE_DEPTH 32
57 57
58#ifdef CONFIG_STACK_UNWIND 58#if defined(CONFIG_STACKTRACE)
59
60static asmlinkage int fail_stacktrace_callback(struct unwind_frame_info *info,
61 void *arg)
62{
63 int depth;
64 struct fault_attr *attr = arg;
65 bool found = (attr->require_start == 0 && attr->require_end == ULONG_MAX);
66
67 for (depth = 0; depth < attr->stacktrace_depth
68 && unwind(info) == 0 && UNW_PC(info); depth++) {
69 if (arch_unw_user_mode(info))
70 break;
71 if (attr->reject_start <= UNW_PC(info) &&
72 UNW_PC(info) < attr->reject_end)
73 return false;
74 if (attr->require_start <= UNW_PC(info) &&
75 UNW_PC(info) < attr->require_end)
76 found = true;
77 }
78 return found;
79}
80
81static bool fail_stacktrace(struct fault_attr *attr)
82{
83 struct unwind_frame_info info;
84
85 return unwind_init_running(&info, fail_stacktrace_callback, attr);
86}
87
88#elif defined(CONFIG_STACKTRACE)
89 59
90static bool fail_stacktrace(struct fault_attr *attr) 60static bool fail_stacktrace(struct fault_attr *attr)
91{ 61{
diff --git a/lib/ioremap.c b/lib/ioremap.c
index 99fa277f9f7b..a9e4415b02dc 100644
--- a/lib/ioremap.c
+++ b/lib/ioremap.c
@@ -5,7 +5,6 @@
5 * 5 *
6 * (C) Copyright 1995 1996 Linus Torvalds 6 * (C) Copyright 1995 1996 Linus Torvalds
7 */ 7 */
8#include <linux/io.h>
9#include <linux/vmalloc.h> 8#include <linux/vmalloc.h>
10#include <linux/mm.h> 9#include <linux/mm.h>
11 10
diff --git a/lib/reciprocal_div.c b/lib/reciprocal_div.c
new file mode 100644
index 000000000000..6a3bd48fa2a0
--- /dev/null
+++ b/lib/reciprocal_div.c
@@ -0,0 +1,9 @@
1#include <asm/div64.h>
2#include <linux/reciprocal_div.h>
3
4u32 reciprocal_value(u32 k)
5{
6 u64 val = (1LL << 32) + (k - 1);
7 do_div(val, k);
8 return (u32)val;
9}
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 0ccc7f230252..cb362f761f17 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -44,14 +44,14 @@ static void clear_huge_page(struct page *page, unsigned long addr)
44} 44}
45 45
46static void copy_huge_page(struct page *dst, struct page *src, 46static void copy_huge_page(struct page *dst, struct page *src,
47 unsigned long addr) 47 unsigned long addr, struct vm_area_struct *vma)
48{ 48{
49 int i; 49 int i;
50 50
51 might_sleep(); 51 might_sleep();
52 for (i = 0; i < HPAGE_SIZE/PAGE_SIZE; i++) { 52 for (i = 0; i < HPAGE_SIZE/PAGE_SIZE; i++) {
53 cond_resched(); 53 cond_resched();
54 copy_user_highpage(dst + i, src + i, addr + i*PAGE_SIZE); 54 copy_user_highpage(dst + i, src + i, addr + i*PAGE_SIZE, vma);
55 } 55 }
56} 56}
57 57
@@ -73,7 +73,7 @@ static struct page *dequeue_huge_page(struct vm_area_struct *vma,
73 73
74 for (z = zonelist->zones; *z; z++) { 74 for (z = zonelist->zones; *z; z++) {
75 nid = zone_to_nid(*z); 75 nid = zone_to_nid(*z);
76 if (cpuset_zone_allowed(*z, GFP_HIGHUSER) && 76 if (cpuset_zone_allowed_softwall(*z, GFP_HIGHUSER) &&
77 !list_empty(&hugepage_freelists[nid])) 77 !list_empty(&hugepage_freelists[nid]))
78 break; 78 break;
79 } 79 }
@@ -442,7 +442,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
442 } 442 }
443 443
444 spin_unlock(&mm->page_table_lock); 444 spin_unlock(&mm->page_table_lock);
445 copy_huge_page(new_page, old_page, address); 445 copy_huge_page(new_page, old_page, address, vma);
446 spin_lock(&mm->page_table_lock); 446 spin_lock(&mm->page_table_lock);
447 447
448 ptep = huge_pte_offset(mm, address & HPAGE_MASK); 448 ptep = huge_pte_offset(mm, address & HPAGE_MASK);
diff --git a/mm/memory.c b/mm/memory.c
index bf6100236e62..c00bac66ce9f 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1441,7 +1441,7 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
1441 return pte; 1441 return pte;
1442} 1442}
1443 1443
1444static inline void cow_user_page(struct page *dst, struct page *src, unsigned long va) 1444static inline void cow_user_page(struct page *dst, struct page *src, unsigned long va, struct vm_area_struct *vma)
1445{ 1445{
1446 /* 1446 /*
1447 * If the source page was a PFN mapping, we don't have 1447 * If the source page was a PFN mapping, we don't have
@@ -1464,9 +1464,9 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
1464 kunmap_atomic(kaddr, KM_USER0); 1464 kunmap_atomic(kaddr, KM_USER0);
1465 flush_dcache_page(dst); 1465 flush_dcache_page(dst);
1466 return; 1466 return;
1467 1467
1468 } 1468 }
1469 copy_user_highpage(dst, src, va); 1469 copy_user_highpage(dst, src, va, vma);
1470} 1470}
1471 1471
1472/* 1472/*
@@ -1577,7 +1577,7 @@ gotten:
1577 new_page = alloc_page_vma(GFP_HIGHUSER, vma, address); 1577 new_page = alloc_page_vma(GFP_HIGHUSER, vma, address);
1578 if (!new_page) 1578 if (!new_page)
1579 goto oom; 1579 goto oom;
1580 cow_user_page(new_page, old_page, address); 1580 cow_user_page(new_page, old_page, address, vma);
1581 } 1581 }
1582 1582
1583 /* 1583 /*
@@ -2200,7 +2200,7 @@ retry:
2200 page = alloc_page_vma(GFP_HIGHUSER, vma, address); 2200 page = alloc_page_vma(GFP_HIGHUSER, vma, address);
2201 if (!page) 2201 if (!page)
2202 goto oom; 2202 goto oom;
2203 copy_user_highpage(page, new_page, address); 2203 copy_user_highpage(page, new_page, address, vma);
2204 page_cache_release(new_page); 2204 page_cache_release(new_page);
2205 new_page = page; 2205 new_page = page;
2206 anon = 1; 2206 anon = 1;
diff --git a/mm/mincore.c b/mm/mincore.c
index 72890780c1c9..8aca6f7167bb 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/mm/mincore.c 2 * linux/mm/mincore.c
3 * 3 *
4 * Copyright (C) 1994-1999 Linus Torvalds 4 * Copyright (C) 1994-2006 Linus Torvalds
5 */ 5 */
6 6
7/* 7/*
@@ -38,46 +38,51 @@ static unsigned char mincore_page(struct vm_area_struct * vma,
38 return present; 38 return present;
39} 39}
40 40
41static long mincore_vma(struct vm_area_struct * vma, 41/*
42 unsigned long start, unsigned long end, unsigned char __user * vec) 42 * Do a chunk of "sys_mincore()". We've already checked
43 * all the arguments, we hold the mmap semaphore: we should
44 * just return the amount of info we're asked for.
45 */
46static long do_mincore(unsigned long addr, unsigned char *vec, unsigned long pages)
43{ 47{
44 long error, i, remaining; 48 unsigned long i, nr, pgoff;
45 unsigned char * tmp; 49 struct vm_area_struct *vma = find_vma(current->mm, addr);
46
47 error = -ENOMEM;
48 if (!vma->vm_file)
49 return error;
50
51 start = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
52 if (end > vma->vm_end)
53 end = vma->vm_end;
54 end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
55 50
56 error = -EAGAIN; 51 /*
57 tmp = (unsigned char *) __get_free_page(GFP_KERNEL); 52 * find_vma() didn't find anything above us, or we're
58 if (!tmp) 53 * in an unmapped hole in the address space: ENOMEM.
59 return error; 54 */
55 if (!vma || addr < vma->vm_start)
56 return -ENOMEM;
60 57
61 /* (end - start) is # of pages, and also # of bytes in "vec */ 58 /*
62 remaining = (end - start), 59 * Ok, got it. But check whether it's a segment we support
60 * mincore() on. Right now, we don't do any anonymous mappings.
61 *
62 * FIXME: This is just stupid. And returning ENOMEM is
63 * stupid too. We should just look at the page tables. But
64 * this is what we've traditionally done, so we'll just
65 * continue doing it.
66 */
67 if (!vma->vm_file)
68 return -ENOMEM;
63 69
64 error = 0; 70 /*
65 for (i = 0; remaining > 0; remaining -= PAGE_SIZE, i++) { 71 * Calculate how many pages there are left in the vma, and
66 int j = 0; 72 * what the pgoff is for our address.
67 long thispiece = (remaining < PAGE_SIZE) ? 73 */
68 remaining : PAGE_SIZE; 74 nr = (vma->vm_end - addr) >> PAGE_SHIFT;
75 if (nr > pages)
76 nr = pages;
69 77
70 while (j < thispiece) 78 pgoff = (addr - vma->vm_start) >> PAGE_SHIFT;
71 tmp[j++] = mincore_page(vma, start++); 79 pgoff += vma->vm_pgoff;
72 80
73 if (copy_to_user(vec + PAGE_SIZE * i, tmp, thispiece)) { 81 /* And then we just fill the sucker in.. */
74 error = -EFAULT; 82 for (i = 0 ; i < nr; i++, pgoff++)
75 break; 83 vec[i] = mincore_page(vma, pgoff);
76 }
77 }
78 84
79 free_page((unsigned long) tmp); 85 return nr;
80 return error;
81} 86}
82 87
83/* 88/*
@@ -107,82 +112,50 @@ static long mincore_vma(struct vm_area_struct * vma,
107asmlinkage long sys_mincore(unsigned long start, size_t len, 112asmlinkage long sys_mincore(unsigned long start, size_t len,
108 unsigned char __user * vec) 113 unsigned char __user * vec)
109{ 114{
110 int index = 0; 115 long retval;
111 unsigned long end, limit; 116 unsigned long pages;
112 struct vm_area_struct * vma; 117 unsigned char *tmp;
113 size_t max;
114 int unmapped_error = 0;
115 long error;
116
117 /* check the arguments */
118 if (start & ~PAGE_CACHE_MASK)
119 goto einval;
120
121 limit = TASK_SIZE;
122 if (start >= limit)
123 goto enomem;
124
125 if (!len)
126 return 0;
127
128 max = limit - start;
129 len = PAGE_CACHE_ALIGN(len);
130 if (len > max || !len)
131 goto enomem;
132 118
133 end = start + len; 119 /* Check the start address: needs to be page-aligned.. */
120 if (start & ~PAGE_CACHE_MASK)
121 return -EINVAL;
134 122
135 /* check the output buffer whilst holding the lock */ 123 /* ..and we need to be passed a valid user-space range */
136 error = -EFAULT; 124 if (!access_ok(VERIFY_READ, (void __user *) start, len))
137 down_read(&current->mm->mmap_sem); 125 return -ENOMEM;
138 126
139 if (!access_ok(VERIFY_WRITE, vec, len >> PAGE_SHIFT)) 127 /* This also avoids any overflows on PAGE_CACHE_ALIGN */
140 goto out; 128 pages = len >> PAGE_SHIFT;
129 pages += (len & ~PAGE_MASK) != 0;
141 130
142 /* 131 if (!access_ok(VERIFY_WRITE, vec, pages))
143 * If the interval [start,end) covers some unmapped address 132 return -EFAULT;
144 * ranges, just ignore them, but return -ENOMEM at the end.
145 */
146 error = 0;
147
148 vma = find_vma(current->mm, start);
149 while (vma) {
150 /* Here start < vma->vm_end. */
151 if (start < vma->vm_start) {
152 unmapped_error = -ENOMEM;
153 start = vma->vm_start;
154 }
155 133
156 /* Here vma->vm_start <= start < vma->vm_end. */ 134 tmp = (void *) __get_free_page(GFP_USER);
157 if (end <= vma->vm_end) { 135 if (!tmp)
158 if (start < end) { 136 return -EAGAIN;
159 error = mincore_vma(vma, start, end, 137
160 &vec[index]); 138 retval = 0;
161 if (error) 139 while (pages) {
162 goto out; 140 /*
163 } 141 * Do at most PAGE_SIZE entries per iteration, due to
164 error = unmapped_error; 142 * the temporary buffer size.
165 goto out; 143 */
144 down_read(&current->mm->mmap_sem);
145 retval = do_mincore(start, tmp, min(pages, PAGE_SIZE));
146 up_read(&current->mm->mmap_sem);
147
148 if (retval <= 0)
149 break;
150 if (copy_to_user(vec, tmp, retval)) {
151 retval = -EFAULT;
152 break;
166 } 153 }
167 154 pages -= retval;
168 /* Here vma->vm_start <= start < vma->vm_end < end. */ 155 vec += retval;
169 error = mincore_vma(vma, start, vma->vm_end, &vec[index]); 156 start += retval << PAGE_SHIFT;
170 if (error) 157 retval = 0;
171 goto out;
172 index += (vma->vm_end - start) >> PAGE_CACHE_SHIFT;
173 start = vma->vm_end;
174 vma = vma->vm_next;
175 } 158 }
176 159 free_page((unsigned long) tmp);
177 /* we found a hole in the area queried if we arrive here */ 160 return retval;
178 error = -ENOMEM;
179
180out:
181 up_read(&current->mm->mmap_sem);
182 return error;
183
184einval:
185 return -EINVAL;
186enomem:
187 return -ENOMEM;
188} 161}
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 223d9ccb7d64..64cf3c214634 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -177,7 +177,7 @@ static inline int constrained_alloc(struct zonelist *zonelist, gfp_t gfp_mask)
177 nodemask_t nodes = node_online_map; 177 nodemask_t nodes = node_online_map;
178 178
179 for (z = zonelist->zones; *z; z++) 179 for (z = zonelist->zones; *z; z++)
180 if (cpuset_zone_allowed(*z, gfp_mask)) 180 if (cpuset_zone_allowed_softwall(*z, gfp_mask))
181 node_clear(zone_to_nid(*z), nodes); 181 node_clear(zone_to_nid(*z), nodes);
182 else 182 else
183 return CONSTRAINT_CPUSET; 183 return CONSTRAINT_CPUSET;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e6b17b2989e0..8c1a116875bc 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1162,7 +1162,7 @@ zonelist_scan:
1162 zone->zone_pgdat != zonelist->zones[0]->zone_pgdat)) 1162 zone->zone_pgdat != zonelist->zones[0]->zone_pgdat))
1163 break; 1163 break;
1164 if ((alloc_flags & ALLOC_CPUSET) && 1164 if ((alloc_flags & ALLOC_CPUSET) &&
1165 !cpuset_zone_allowed(zone, gfp_mask)) 1165 !cpuset_zone_allowed_softwall(zone, gfp_mask))
1166 goto try_next_zone; 1166 goto try_next_zone;
1167 1167
1168 if (!(alloc_flags & ALLOC_NO_WATERMARKS)) { 1168 if (!(alloc_flags & ALLOC_NO_WATERMARKS)) {
diff --git a/mm/slab.c b/mm/slab.c
index 2c655532f5ef..909975f6e090 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -109,6 +109,7 @@
109#include <linux/mutex.h> 109#include <linux/mutex.h>
110#include <linux/fault-inject.h> 110#include <linux/fault-inject.h>
111#include <linux/rtmutex.h> 111#include <linux/rtmutex.h>
112#include <linux/reciprocal_div.h>
112 113
113#include <asm/cacheflush.h> 114#include <asm/cacheflush.h>
114#include <asm/tlbflush.h> 115#include <asm/tlbflush.h>
@@ -386,6 +387,7 @@ struct kmem_cache {
386 unsigned int shared; 387 unsigned int shared;
387 388
388 unsigned int buffer_size; 389 unsigned int buffer_size;
390 u32 reciprocal_buffer_size;
389/* 3) touched by every alloc & free from the backend */ 391/* 3) touched by every alloc & free from the backend */
390 struct kmem_list3 *nodelists[MAX_NUMNODES]; 392 struct kmem_list3 *nodelists[MAX_NUMNODES];
391 393
@@ -627,10 +629,17 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
627 return slab->s_mem + cache->buffer_size * idx; 629 return slab->s_mem + cache->buffer_size * idx;
628} 630}
629 631
630static inline unsigned int obj_to_index(struct kmem_cache *cache, 632/*
631 struct slab *slab, void *obj) 633 * We want to avoid an expensive divide : (offset / cache->buffer_size)
634 * Using the fact that buffer_size is a constant for a particular cache,
635 * we can replace (offset / cache->buffer_size) by
636 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
637 */
638static inline unsigned int obj_to_index(const struct kmem_cache *cache,
639 const struct slab *slab, void *obj)
632{ 640{
633 return (unsigned)(obj - slab->s_mem) / cache->buffer_size; 641 u32 offset = (obj - slab->s_mem);
642 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
634} 643}
635 644
636/* 645/*
@@ -1427,6 +1436,8 @@ void __init kmem_cache_init(void)
1427 1436
1428 cache_cache.buffer_size = ALIGN(cache_cache.buffer_size, 1437 cache_cache.buffer_size = ALIGN(cache_cache.buffer_size,
1429 cache_line_size()); 1438 cache_line_size());
1439 cache_cache.reciprocal_buffer_size =
1440 reciprocal_value(cache_cache.buffer_size);
1430 1441
1431 for (order = 0; order < MAX_ORDER; order++) { 1442 for (order = 0; order < MAX_ORDER; order++) {
1432 cache_estimate(order, cache_cache.buffer_size, 1443 cache_estimate(order, cache_cache.buffer_size,
@@ -2313,6 +2324,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2313 if (flags & SLAB_CACHE_DMA) 2324 if (flags & SLAB_CACHE_DMA)
2314 cachep->gfpflags |= GFP_DMA; 2325 cachep->gfpflags |= GFP_DMA;
2315 cachep->buffer_size = size; 2326 cachep->buffer_size = size;
2327 cachep->reciprocal_buffer_size = reciprocal_value(size);
2316 2328
2317 if (flags & CFLGS_OFF_SLAB) { 2329 if (flags & CFLGS_OFF_SLAB) {
2318 cachep->slabp_cache = kmem_find_general_cachep(slab_size, 0u); 2330 cachep->slabp_cache = kmem_find_general_cachep(slab_size, 0u);
@@ -3252,6 +3264,7 @@ void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3252 struct zone **z; 3264 struct zone **z;
3253 void *obj = NULL; 3265 void *obj = NULL;
3254 int nid; 3266 int nid;
3267 gfp_t local_flags = (flags & GFP_LEVEL_MASK);
3255 3268
3256retry: 3269retry:
3257 /* 3270 /*
@@ -3261,7 +3274,7 @@ retry:
3261 for (z = zonelist->zones; *z && !obj; z++) { 3274 for (z = zonelist->zones; *z && !obj; z++) {
3262 nid = zone_to_nid(*z); 3275 nid = zone_to_nid(*z);
3263 3276
3264 if (cpuset_zone_allowed(*z, flags | __GFP_HARDWALL) && 3277 if (cpuset_zone_allowed_hardwall(*z, flags) &&
3265 cache->nodelists[nid] && 3278 cache->nodelists[nid] &&
3266 cache->nodelists[nid]->free_objects) 3279 cache->nodelists[nid]->free_objects)
3267 obj = ____cache_alloc_node(cache, 3280 obj = ____cache_alloc_node(cache,
@@ -3275,7 +3288,12 @@ retry:
3275 * We may trigger various forms of reclaim on the allowed 3288 * We may trigger various forms of reclaim on the allowed
3276 * set and go into memory reserves if necessary. 3289 * set and go into memory reserves if necessary.
3277 */ 3290 */
3291 if (local_flags & __GFP_WAIT)
3292 local_irq_enable();
3293 kmem_flagcheck(cache, flags);
3278 obj = kmem_getpages(cache, flags, -1); 3294 obj = kmem_getpages(cache, flags, -1);
3295 if (local_flags & __GFP_WAIT)
3296 local_irq_disable();
3279 if (obj) { 3297 if (obj) {
3280 /* 3298 /*
3281 * Insert into the appropriate per node queues 3299 * Insert into the appropriate per node queues
@@ -3535,7 +3553,7 @@ EXPORT_SYMBOL(kmem_cache_zalloc);
3535 * 3553 *
3536 * Currently only used for dentry validation. 3554 * Currently only used for dentry validation.
3537 */ 3555 */
3538int fastcall kmem_ptr_validate(struct kmem_cache *cachep, void *ptr) 3556int fastcall kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr)
3539{ 3557{
3540 unsigned long addr = (unsigned long)ptr; 3558 unsigned long addr = (unsigned long)ptr;
3541 unsigned long min_addr = PAGE_OFFSET; 3559 unsigned long min_addr = PAGE_OFFSET;
diff --git a/mm/slob.c b/mm/slob.c
index 542394184a58..2e9236e10ed1 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -157,7 +157,7 @@ static int fastcall find_order(int size)
157 return order; 157 return order;
158} 158}
159 159
160void *kmalloc(size_t size, gfp_t gfp) 160void *__kmalloc(size_t size, gfp_t gfp)
161{ 161{
162 slob_t *m; 162 slob_t *m;
163 bigblock_t *bb; 163 bigblock_t *bb;
@@ -186,8 +186,7 @@ void *kmalloc(size_t size, gfp_t gfp)
186 slob_free(bb, sizeof(bigblock_t)); 186 slob_free(bb, sizeof(bigblock_t));
187 return 0; 187 return 0;
188} 188}
189 189EXPORT_SYMBOL(__kmalloc);
190EXPORT_SYMBOL(kmalloc);
191 190
192void kfree(const void *block) 191void kfree(const void *block)
193{ 192{
@@ -329,6 +328,17 @@ EXPORT_SYMBOL(kmem_cache_name);
329static struct timer_list slob_timer = TIMER_INITIALIZER( 328static struct timer_list slob_timer = TIMER_INITIALIZER(
330 (void (*)(unsigned long))kmem_cache_init, 0, 0); 329 (void (*)(unsigned long))kmem_cache_init, 0, 0);
331 330
331int kmem_cache_shrink(struct kmem_cache *d)
332{
333 return 0;
334}
335EXPORT_SYMBOL(kmem_cache_shrink);
336
337int kmem_ptr_validate(struct kmem_cache *a, const void *b)
338{
339 return 0;
340}
341
332void kmem_cache_init(void) 342void kmem_cache_init(void)
333{ 343{
334 void *p = slob_alloc(PAGE_SIZE, 0, PAGE_SIZE-1); 344 void *p = slob_alloc(PAGE_SIZE, 0, PAGE_SIZE-1);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 093f5fe6dd77..e9813b06c7a3 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -984,7 +984,7 @@ static unsigned long shrink_zones(int priority, struct zone **zones,
984 if (!populated_zone(zone)) 984 if (!populated_zone(zone))
985 continue; 985 continue;
986 986
987 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) 987 if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
988 continue; 988 continue;
989 989
990 note_zone_scanning_priority(zone, priority); 990 note_zone_scanning_priority(zone, priority);
@@ -1034,7 +1034,7 @@ unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
1034 for (i = 0; zones[i] != NULL; i++) { 1034 for (i = 0; zones[i] != NULL; i++) {
1035 struct zone *zone = zones[i]; 1035 struct zone *zone = zones[i];
1036 1036
1037 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) 1037 if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
1038 continue; 1038 continue;
1039 1039
1040 lru_pages += zone->nr_active + zone->nr_inactive; 1040 lru_pages += zone->nr_active + zone->nr_inactive;
@@ -1089,7 +1089,7 @@ out:
1089 for (i = 0; zones[i] != 0; i++) { 1089 for (i = 0; zones[i] != 0; i++) {
1090 struct zone *zone = zones[i]; 1090 struct zone *zone = zones[i];
1091 1091
1092 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) 1092 if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
1093 continue; 1093 continue;
1094 1094
1095 zone->prev_priority = priority; 1095 zone->prev_priority = priority;
@@ -1354,7 +1354,7 @@ void wakeup_kswapd(struct zone *zone, int order)
1354 return; 1354 return;
1355 if (pgdat->kswapd_max_order < order) 1355 if (pgdat->kswapd_max_order < order)
1356 pgdat->kswapd_max_order = order; 1356 pgdat->kswapd_max_order = order;
1357 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) 1357 if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
1358 return; 1358 return;
1359 if (!waitqueue_active(&pgdat->kswapd_wait)) 1359 if (!waitqueue_active(&pgdat->kswapd_wait))
1360 return; 1360 return;
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 711a085eca5b..dbf98c49dbaa 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -123,10 +123,10 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
123 if (flt->opcode && 123 if (flt->opcode &&
124 ((evt == HCI_EV_CMD_COMPLETE && 124 ((evt == HCI_EV_CMD_COMPLETE &&
125 flt->opcode != 125 flt->opcode !=
126 get_unaligned((__u16 *)(skb->data + 3))) || 126 get_unaligned((__le16 *)(skb->data + 3))) ||
127 (evt == HCI_EV_CMD_STATUS && 127 (evt == HCI_EV_CMD_STATUS &&
128 flt->opcode != 128 flt->opcode !=
129 get_unaligned((__u16 *)(skb->data + 4))))) 129 get_unaligned((__le16 *)(skb->data + 4)))))
130 continue; 130 continue;
131 } 131 }
132 132
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index bd221ad52eaf..ea3337ad0edc 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -61,9 +61,6 @@ static int brnf_filter_vlan_tagged __read_mostly = 1;
61#define brnf_filter_vlan_tagged 1 61#define brnf_filter_vlan_tagged 1
62#endif 62#endif
63 63
64int brnf_deferred_hooks;
65EXPORT_SYMBOL_GPL(brnf_deferred_hooks);
66
67static __be16 inline vlan_proto(const struct sk_buff *skb) 64static __be16 inline vlan_proto(const struct sk_buff *skb)
68{ 65{
69 return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto; 66 return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
@@ -685,110 +682,50 @@ static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff **pskb,
685 return NF_STOLEN; 682 return NF_STOLEN;
686} 683}
687 684
688/* PF_BRIDGE/LOCAL_OUT ***********************************************/ 685/* PF_BRIDGE/LOCAL_OUT ***********************************************
689static int br_nf_local_out_finish(struct sk_buff *skb) 686 *
690{ 687 * This function sees both locally originated IP packets and forwarded
691 if (skb->protocol == htons(ETH_P_8021Q)) {
692 skb_push(skb, VLAN_HLEN);
693 skb->nh.raw -= VLAN_HLEN;
694 }
695
696 NF_HOOK_THRESH(PF_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
697 br_forward_finish, NF_BR_PRI_FIRST + 1);
698
699 return 0;
700}
701
702/* This function sees both locally originated IP packets and forwarded
703 * IP packets (in both cases the destination device is a bridge 688 * IP packets (in both cases the destination device is a bridge
704 * device). It also sees bridged-and-DNAT'ed packets. 689 * device). It also sees bridged-and-DNAT'ed packets.
705 * To be able to filter on the physical bridge devices (with the physdev
706 * module), we steal packets destined to a bridge device away from the
707 * PF_INET/FORWARD and PF_INET/OUTPUT hook functions, and give them back later,
708 * when we have determined the real output device. This is done in here.
709 * 690 *
710 * If (nf_bridge->mask & BRNF_BRIDGED_DNAT) then the packet is bridged 691 * If (nf_bridge->mask & BRNF_BRIDGED_DNAT) then the packet is bridged
711 * and we fake the PF_BRIDGE/FORWARD hook. The function br_nf_forward() 692 * and we fake the PF_BRIDGE/FORWARD hook. The function br_nf_forward()
712 * will then fake the PF_INET/FORWARD hook. br_nf_local_out() has priority 693 * will then fake the PF_INET/FORWARD hook. br_nf_local_out() has priority
713 * NF_BR_PRI_FIRST, so no relevant PF_BRIDGE/INPUT functions have been nor 694 * NF_BR_PRI_FIRST, so no relevant PF_BRIDGE/INPUT functions have been nor
714 * will be executed. 695 * will be executed.
715 * Otherwise, if nf_bridge->physindev is NULL, the bridge-nf code never touched 696 */
716 * this packet before, and so the packet was locally originated. We fake
717 * the PF_INET/LOCAL_OUT hook.
718 * Finally, if nf_bridge->physindev isn't NULL, then the packet was IP routed,
719 * so we fake the PF_INET/FORWARD hook. ip_sabotage_out() makes sure
720 * even routed packets that didn't arrive on a bridge interface have their
721 * nf_bridge->physindev set. */
722static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb, 697static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb,
723 const struct net_device *in, 698 const struct net_device *in,
724 const struct net_device *out, 699 const struct net_device *out,
725 int (*okfn)(struct sk_buff *)) 700 int (*okfn)(struct sk_buff *))
726{ 701{
727 struct net_device *realindev, *realoutdev; 702 struct net_device *realindev;
728 struct sk_buff *skb = *pskb; 703 struct sk_buff *skb = *pskb;
729 struct nf_bridge_info *nf_bridge; 704 struct nf_bridge_info *nf_bridge;
730 int pf;
731 705
732 if (!skb->nf_bridge) 706 if (!skb->nf_bridge)
733 return NF_ACCEPT; 707 return NF_ACCEPT;
734 708
735 if (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP(skb))
736 pf = PF_INET;
737 else
738 pf = PF_INET6;
739
740 nf_bridge = skb->nf_bridge; 709 nf_bridge = skb->nf_bridge;
741 nf_bridge->physoutdev = skb->dev; 710 if (!(nf_bridge->mask & BRNF_BRIDGED_DNAT))
742 realindev = nf_bridge->physindev; 711 return NF_ACCEPT;
743 712
744 /* Bridged, take PF_BRIDGE/FORWARD. 713 /* Bridged, take PF_BRIDGE/FORWARD.
745 * (see big note in front of br_nf_pre_routing_finish) */ 714 * (see big note in front of br_nf_pre_routing_finish) */
746 if (nf_bridge->mask & BRNF_BRIDGED_DNAT) { 715 nf_bridge->physoutdev = skb->dev;
747 if (nf_bridge->mask & BRNF_PKT_TYPE) { 716 realindev = nf_bridge->physindev;
748 skb->pkt_type = PACKET_OTHERHOST;
749 nf_bridge->mask ^= BRNF_PKT_TYPE;
750 }
751 if (skb->protocol == htons(ETH_P_8021Q)) {
752 skb_push(skb, VLAN_HLEN);
753 skb->nh.raw -= VLAN_HLEN;
754 }
755 717
756 NF_HOOK(PF_BRIDGE, NF_BR_FORWARD, skb, realindev, 718 if (nf_bridge->mask & BRNF_PKT_TYPE) {
757 skb->dev, br_forward_finish); 719 skb->pkt_type = PACKET_OTHERHOST;
758 goto out; 720 nf_bridge->mask ^= BRNF_PKT_TYPE;
759 } 721 }
760 realoutdev = bridge_parent(skb->dev);
761 if (!realoutdev)
762 return NF_DROP;
763
764#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
765 /* iptables should match -o br0.x */
766 if (nf_bridge->netoutdev)
767 realoutdev = nf_bridge->netoutdev;
768#endif
769 if (skb->protocol == htons(ETH_P_8021Q)) { 722 if (skb->protocol == htons(ETH_P_8021Q)) {
770 skb_pull(skb, VLAN_HLEN); 723 skb_push(skb, VLAN_HLEN);
771 (*pskb)->nh.raw += VLAN_HLEN; 724 skb->nh.raw -= VLAN_HLEN;
772 }
773 /* IP forwarded traffic has a physindev, locally
774 * generated traffic hasn't. */
775 if (realindev != NULL) {
776 if (!(nf_bridge->mask & BRNF_DONT_TAKE_PARENT)) {
777 struct net_device *parent = bridge_parent(realindev);
778 if (parent)
779 realindev = parent;
780 }
781
782 NF_HOOK_THRESH(pf, NF_IP_FORWARD, skb, realindev,
783 realoutdev, br_nf_local_out_finish,
784 NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD + 1);
785 } else {
786 NF_HOOK_THRESH(pf, NF_IP_LOCAL_OUT, skb, realindev,
787 realoutdev, br_nf_local_out_finish,
788 NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT + 1);
789 } 725 }
790 726
791out: 727 NF_HOOK(PF_BRIDGE, NF_BR_FORWARD, skb, realindev, skb->dev,
728 br_forward_finish);
792 return NF_STOLEN; 729 return NF_STOLEN;
793} 730}
794 731
@@ -894,69 +831,6 @@ static unsigned int ip_sabotage_in(unsigned int hook, struct sk_buff **pskb,
894 return NF_ACCEPT; 831 return NF_ACCEPT;
895} 832}
896 833
897/* Postpone execution of PF_INET(6)/FORWARD, PF_INET(6)/LOCAL_OUT
898 * and PF_INET(6)/POST_ROUTING until we have done the forwarding
899 * decision in the bridge code and have determined nf_bridge->physoutdev. */
900static unsigned int ip_sabotage_out(unsigned int hook, struct sk_buff **pskb,
901 const struct net_device *in,
902 const struct net_device *out,
903 int (*okfn)(struct sk_buff *))
904{
905 struct sk_buff *skb = *pskb;
906
907 if ((out->hard_start_xmit == br_dev_xmit &&
908 okfn != br_nf_forward_finish &&
909 okfn != br_nf_local_out_finish && okfn != br_nf_dev_queue_xmit)
910#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
911 || ((out->priv_flags & IFF_802_1Q_VLAN) &&
912 VLAN_DEV_INFO(out)->real_dev->hard_start_xmit == br_dev_xmit)
913#endif
914 ) {
915 struct nf_bridge_info *nf_bridge;
916
917 if (!skb->nf_bridge) {
918#ifdef CONFIG_SYSCTL
919 /* This code is executed while in the IP(v6) stack,
920 the version should be 4 or 6. We can't use
921 skb->protocol because that isn't set on
922 PF_INET(6)/LOCAL_OUT. */
923 struct iphdr *ip = skb->nh.iph;
924
925 if (ip->version == 4 && !brnf_call_iptables)
926 return NF_ACCEPT;
927 else if (ip->version == 6 && !brnf_call_ip6tables)
928 return NF_ACCEPT;
929 else if (!brnf_deferred_hooks)
930 return NF_ACCEPT;
931#endif
932 if (hook == NF_IP_POST_ROUTING)
933 return NF_ACCEPT;
934 if (!nf_bridge_alloc(skb))
935 return NF_DROP;
936 }
937
938 nf_bridge = skb->nf_bridge;
939
940 /* This frame will arrive on PF_BRIDGE/LOCAL_OUT and we
941 * will need the indev then. For a brouter, the real indev
942 * can be a bridge port, so we make sure br_nf_local_out()
943 * doesn't use the bridge parent of the indev by using
944 * the BRNF_DONT_TAKE_PARENT mask. */
945 if (hook == NF_IP_FORWARD && nf_bridge->physindev == NULL) {
946 nf_bridge->mask |= BRNF_DONT_TAKE_PARENT;
947 nf_bridge->physindev = (struct net_device *)in;
948 }
949#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
950 /* the iptables outdev is br0.x, not br0 */
951 if (out->priv_flags & IFF_802_1Q_VLAN)
952 nf_bridge->netoutdev = (struct net_device *)out;
953#endif
954 return NF_STOP;
955 }
956
957 return NF_ACCEPT;
958}
959
960/* For br_nf_local_out we need (prio = NF_BR_PRI_FIRST), to insure that innocent 834/* For br_nf_local_out we need (prio = NF_BR_PRI_FIRST), to insure that innocent
961 * PF_BRIDGE/NF_BR_LOCAL_OUT functions don't get bridged traffic as input. 835 * PF_BRIDGE/NF_BR_LOCAL_OUT functions don't get bridged traffic as input.
962 * For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because 836 * For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because
@@ -1002,36 +876,6 @@ static struct nf_hook_ops br_nf_ops[] = {
1002 .pf = PF_INET6, 876 .pf = PF_INET6,
1003 .hooknum = NF_IP6_PRE_ROUTING, 877 .hooknum = NF_IP6_PRE_ROUTING,
1004 .priority = NF_IP6_PRI_FIRST, }, 878 .priority = NF_IP6_PRI_FIRST, },
1005 { .hook = ip_sabotage_out,
1006 .owner = THIS_MODULE,
1007 .pf = PF_INET,
1008 .hooknum = NF_IP_FORWARD,
1009 .priority = NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD, },
1010 { .hook = ip_sabotage_out,
1011 .owner = THIS_MODULE,
1012 .pf = PF_INET6,
1013 .hooknum = NF_IP6_FORWARD,
1014 .priority = NF_IP6_PRI_BRIDGE_SABOTAGE_FORWARD, },
1015 { .hook = ip_sabotage_out,
1016 .owner = THIS_MODULE,
1017 .pf = PF_INET,
1018 .hooknum = NF_IP_LOCAL_OUT,
1019 .priority = NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT, },
1020 { .hook = ip_sabotage_out,
1021 .owner = THIS_MODULE,
1022 .pf = PF_INET6,
1023 .hooknum = NF_IP6_LOCAL_OUT,
1024 .priority = NF_IP6_PRI_BRIDGE_SABOTAGE_LOCAL_OUT, },
1025 { .hook = ip_sabotage_out,
1026 .owner = THIS_MODULE,
1027 .pf = PF_INET,
1028 .hooknum = NF_IP_POST_ROUTING,
1029 .priority = NF_IP_PRI_FIRST, },
1030 { .hook = ip_sabotage_out,
1031 .owner = THIS_MODULE,
1032 .pf = PF_INET6,
1033 .hooknum = NF_IP6_POST_ROUTING,
1034 .priority = NF_IP6_PRI_FIRST, },
1035}; 879};
1036 880
1037#ifdef CONFIG_SYSCTL 881#ifdef CONFIG_SYSCTL
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index fa6b75372ed7..40402c59506a 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -845,8 +845,8 @@ found:
845 * Find some p such that f(p) = fval; return 1/p [RFC 3448, 6.3.1]. 845 * Find some p such that f(p) = fval; return 1/p [RFC 3448, 6.3.1].
846 */ 846 */
847 if (rtt == 0) { /* would result in divide-by-zero */ 847 if (rtt == 0) { /* would result in divide-by-zero */
848 DCCP_WARN("RTT==0, returning 1/p = 1\n"); 848 DCCP_WARN("RTT==0\n");
849 return 1000000; 849 return ~0;
850 } 850 }
851 851
852 dccp_timestamp(sk, &tstamp); 852 dccp_timestamp(sk, &tstamp);
@@ -858,7 +858,7 @@ found:
858 DCCP_WARN("X_recv==0\n"); 858 DCCP_WARN("X_recv==0\n");
859 if ((x_recv = hcrx->ccid3hcrx_x_recv) == 0) { 859 if ((x_recv = hcrx->ccid3hcrx_x_recv) == 0) {
860 DCCP_BUG("stored value of X_recv is zero"); 860 DCCP_BUG("stored value of X_recv is zero");
861 return 1000000; 861 return ~0;
862 } 862 }
863 } 863 }
864 864
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
index 363df9976c9d..f6026d4ac428 100644
--- a/net/ipv4/netfilter/Kconfig
+++ b/net/ipv4/netfilter/Kconfig
@@ -401,7 +401,7 @@ config IP_NF_NAT
401# NAT + specific targets: nf_conntrack 401# NAT + specific targets: nf_conntrack
402config NF_NAT 402config NF_NAT
403 tristate "Full NAT" 403 tristate "Full NAT"
404 depends on IP_NF_IPTABLES && NF_CONNTRACK 404 depends on IP_NF_IPTABLES && NF_CONNTRACK_IPV4
405 help 405 help
406 The Full NAT option allows masquerading, port forwarding and other 406 The Full NAT option allows masquerading, port forwarding and other
407 forms of full Network Address Port Translation. It is controlled by 407 forms of full Network Address Port Translation. It is controlled by
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 71b76ade00e1..9aa22398b3dc 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -358,6 +358,7 @@ static int mark_source_chains(struct xt_table_info *newinfo,
358 for (;;) { 358 for (;;) {
359 struct arpt_standard_target *t 359 struct arpt_standard_target *t
360 = (void *)arpt_get_target(e); 360 = (void *)arpt_get_target(e);
361 int visited = e->comefrom & (1 << hook);
361 362
362 if (e->comefrom & (1 << NF_ARP_NUMHOOKS)) { 363 if (e->comefrom & (1 << NF_ARP_NUMHOOKS)) {
363 printk("arptables: loop hook %u pos %u %08X.\n", 364 printk("arptables: loop hook %u pos %u %08X.\n",
@@ -368,11 +369,11 @@ static int mark_source_chains(struct xt_table_info *newinfo,
368 |= ((1 << hook) | (1 << NF_ARP_NUMHOOKS)); 369 |= ((1 << hook) | (1 << NF_ARP_NUMHOOKS));
369 370
370 /* Unconditional return/END. */ 371 /* Unconditional return/END. */
371 if (e->target_offset == sizeof(struct arpt_entry) 372 if ((e->target_offset == sizeof(struct arpt_entry)
372 && (strcmp(t->target.u.user.name, 373 && (strcmp(t->target.u.user.name,
373 ARPT_STANDARD_TARGET) == 0) 374 ARPT_STANDARD_TARGET) == 0)
374 && t->verdict < 0 375 && t->verdict < 0
375 && unconditional(&e->arp)) { 376 && unconditional(&e->arp)) || visited) {
376 unsigned int oldpos, size; 377 unsigned int oldpos, size;
377 378
378 if (t->verdict < -NF_MAX_VERDICT - 1) { 379 if (t->verdict < -NF_MAX_VERDICT - 1) {
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 0ff2956d35e5..09696f16aa95 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -384,6 +384,7 @@ mark_source_chains(struct xt_table_info *newinfo,
384 for (;;) { 384 for (;;) {
385 struct ipt_standard_target *t 385 struct ipt_standard_target *t
386 = (void *)ipt_get_target(e); 386 = (void *)ipt_get_target(e);
387 int visited = e->comefrom & (1 << hook);
387 388
388 if (e->comefrom & (1 << NF_IP_NUMHOOKS)) { 389 if (e->comefrom & (1 << NF_IP_NUMHOOKS)) {
389 printk("iptables: loop hook %u pos %u %08X.\n", 390 printk("iptables: loop hook %u pos %u %08X.\n",
@@ -394,11 +395,11 @@ mark_source_chains(struct xt_table_info *newinfo,
394 |= ((1 << hook) | (1 << NF_IP_NUMHOOKS)); 395 |= ((1 << hook) | (1 << NF_IP_NUMHOOKS));
395 396
396 /* Unconditional return/END. */ 397 /* Unconditional return/END. */
397 if (e->target_offset == sizeof(struct ipt_entry) 398 if ((e->target_offset == sizeof(struct ipt_entry)
398 && (strcmp(t->target.u.user.name, 399 && (strcmp(t->target.u.user.name,
399 IPT_STANDARD_TARGET) == 0) 400 IPT_STANDARD_TARGET) == 0)
400 && t->verdict < 0 401 && t->verdict < 0
401 && unconditional(&e->ip)) { 402 && unconditional(&e->ip)) || visited) {
402 unsigned int oldpos, size; 403 unsigned int oldpos, size;
403 404
404 if (t->verdict < -NF_MAX_VERDICT - 1) { 405 if (t->verdict < -NF_MAX_VERDICT - 1) {
@@ -484,7 +485,47 @@ cleanup_match(struct ipt_entry_match *m, unsigned int *i)
484} 485}
485 486
486static inline int 487static inline int
487check_match(struct ipt_entry_match *m, 488check_entry(struct ipt_entry *e, const char *name)
489{
490 struct ipt_entry_target *t;
491
492 if (!ip_checkentry(&e->ip)) {
493 duprintf("ip_tables: ip check failed %p %s.\n", e, name);
494 return -EINVAL;
495 }
496
497 if (e->target_offset + sizeof(struct ipt_entry_target) > e->next_offset)
498 return -EINVAL;
499
500 t = ipt_get_target(e);
501 if (e->target_offset + t->u.target_size > e->next_offset)
502 return -EINVAL;
503
504 return 0;
505}
506
507static inline int check_match(struct ipt_entry_match *m, const char *name,
508 const struct ipt_ip *ip, unsigned int hookmask)
509{
510 struct ipt_match *match;
511 int ret;
512
513 match = m->u.kernel.match;
514 ret = xt_check_match(match, AF_INET, m->u.match_size - sizeof(*m),
515 name, hookmask, ip->proto,
516 ip->invflags & IPT_INV_PROTO);
517 if (!ret && m->u.kernel.match->checkentry
518 && !m->u.kernel.match->checkentry(name, ip, match, m->data,
519 hookmask)) {
520 duprintf("ip_tables: check failed for `%s'.\n",
521 m->u.kernel.match->name);
522 ret = -EINVAL;
523 }
524 return ret;
525}
526
527static inline int
528find_check_match(struct ipt_entry_match *m,
488 const char *name, 529 const char *name,
489 const struct ipt_ip *ip, 530 const struct ipt_ip *ip,
490 unsigned int hookmask, 531 unsigned int hookmask,
@@ -497,26 +538,15 @@ check_match(struct ipt_entry_match *m,
497 m->u.user.revision), 538 m->u.user.revision),
498 "ipt_%s", m->u.user.name); 539 "ipt_%s", m->u.user.name);
499 if (IS_ERR(match) || !match) { 540 if (IS_ERR(match) || !match) {
500 duprintf("check_match: `%s' not found\n", m->u.user.name); 541 duprintf("find_check_match: `%s' not found\n", m->u.user.name);
501 return match ? PTR_ERR(match) : -ENOENT; 542 return match ? PTR_ERR(match) : -ENOENT;
502 } 543 }
503 m->u.kernel.match = match; 544 m->u.kernel.match = match;
504 545
505 ret = xt_check_match(match, AF_INET, m->u.match_size - sizeof(*m), 546 ret = check_match(m, name, ip, hookmask);
506 name, hookmask, ip->proto,
507 ip->invflags & IPT_INV_PROTO);
508 if (ret) 547 if (ret)
509 goto err; 548 goto err;
510 549
511 if (m->u.kernel.match->checkentry
512 && !m->u.kernel.match->checkentry(name, ip, match, m->data,
513 hookmask)) {
514 duprintf("ip_tables: check failed for `%s'.\n",
515 m->u.kernel.match->name);
516 ret = -EINVAL;
517 goto err;
518 }
519
520 (*i)++; 550 (*i)++;
521 return 0; 551 return 0;
522err: 552err:
@@ -524,10 +554,29 @@ err:
524 return ret; 554 return ret;
525} 555}
526 556
527static struct ipt_target ipt_standard_target; 557static inline int check_target(struct ipt_entry *e, const char *name)
558{
559 struct ipt_entry_target *t;
560 struct ipt_target *target;
561 int ret;
562
563 t = ipt_get_target(e);
564 target = t->u.kernel.target;
565 ret = xt_check_target(target, AF_INET, t->u.target_size - sizeof(*t),
566 name, e->comefrom, e->ip.proto,
567 e->ip.invflags & IPT_INV_PROTO);
568 if (!ret && t->u.kernel.target->checkentry
569 && !t->u.kernel.target->checkentry(name, e, target,
570 t->data, e->comefrom)) {
571 duprintf("ip_tables: check failed for `%s'.\n",
572 t->u.kernel.target->name);
573 ret = -EINVAL;
574 }
575 return ret;
576}
528 577
529static inline int 578static inline int
530check_entry(struct ipt_entry *e, const char *name, unsigned int size, 579find_check_entry(struct ipt_entry *e, const char *name, unsigned int size,
531 unsigned int *i) 580 unsigned int *i)
532{ 581{
533 struct ipt_entry_target *t; 582 struct ipt_entry_target *t;
@@ -535,49 +584,32 @@ check_entry(struct ipt_entry *e, const char *name, unsigned int size,
535 int ret; 584 int ret;
536 unsigned int j; 585 unsigned int j;
537 586
538 if (!ip_checkentry(&e->ip)) { 587 ret = check_entry(e, name);
539 duprintf("ip_tables: ip check failed %p %s.\n", e, name); 588 if (ret)
540 return -EINVAL; 589 return ret;
541 }
542
543 if (e->target_offset + sizeof(struct ipt_entry_target) > e->next_offset)
544 return -EINVAL;
545 590
546 j = 0; 591 j = 0;
547 ret = IPT_MATCH_ITERATE(e, check_match, name, &e->ip, e->comefrom, &j); 592 ret = IPT_MATCH_ITERATE(e, find_check_match, name, &e->ip,
593 e->comefrom, &j);
548 if (ret != 0) 594 if (ret != 0)
549 goto cleanup_matches; 595 goto cleanup_matches;
550 596
551 t = ipt_get_target(e); 597 t = ipt_get_target(e);
552 ret = -EINVAL;
553 if (e->target_offset + t->u.target_size > e->next_offset)
554 goto cleanup_matches;
555 target = try_then_request_module(xt_find_target(AF_INET, 598 target = try_then_request_module(xt_find_target(AF_INET,
556 t->u.user.name, 599 t->u.user.name,
557 t->u.user.revision), 600 t->u.user.revision),
558 "ipt_%s", t->u.user.name); 601 "ipt_%s", t->u.user.name);
559 if (IS_ERR(target) || !target) { 602 if (IS_ERR(target) || !target) {
560 duprintf("check_entry: `%s' not found\n", t->u.user.name); 603 duprintf("find_check_entry: `%s' not found\n", t->u.user.name);
561 ret = target ? PTR_ERR(target) : -ENOENT; 604 ret = target ? PTR_ERR(target) : -ENOENT;
562 goto cleanup_matches; 605 goto cleanup_matches;
563 } 606 }
564 t->u.kernel.target = target; 607 t->u.kernel.target = target;
565 608
566 ret = xt_check_target(target, AF_INET, t->u.target_size - sizeof(*t), 609 ret = check_target(e, name);
567 name, e->comefrom, e->ip.proto,
568 e->ip.invflags & IPT_INV_PROTO);
569 if (ret) 610 if (ret)
570 goto err; 611 goto err;
571 612
572 if (t->u.kernel.target->checkentry
573 && !t->u.kernel.target->checkentry(name, e, target, t->data,
574 e->comefrom)) {
575 duprintf("ip_tables: check failed for `%s'.\n",
576 t->u.kernel.target->name);
577 ret = -EINVAL;
578 goto err;
579 }
580
581 (*i)++; 613 (*i)++;
582 return 0; 614 return 0;
583 err: 615 err:
@@ -712,7 +744,7 @@ translate_table(const char *name,
712 /* Finally, each sanity check must pass */ 744 /* Finally, each sanity check must pass */
713 i = 0; 745 i = 0;
714 ret = IPT_ENTRY_ITERATE(entry0, newinfo->size, 746 ret = IPT_ENTRY_ITERATE(entry0, newinfo->size,
715 check_entry, name, size, &i); 747 find_check_entry, name, size, &i);
716 748
717 if (ret != 0) { 749 if (ret != 0) {
718 IPT_ENTRY_ITERATE(entry0, newinfo->size, 750 IPT_ENTRY_ITERATE(entry0, newinfo->size,
@@ -1452,14 +1484,9 @@ check_compat_entry_size_and_hooks(struct ipt_entry *e,
1452 return -EINVAL; 1484 return -EINVAL;
1453 } 1485 }
1454 1486
1455 if (!ip_checkentry(&e->ip)) { 1487 ret = check_entry(e, name);
1456 duprintf("ip_tables: ip check failed %p %s.\n", e, name); 1488 if (ret)
1457 return -EINVAL; 1489 return ret;
1458 }
1459
1460 if (e->target_offset + sizeof(struct compat_xt_entry_target) >
1461 e->next_offset)
1462 return -EINVAL;
1463 1490
1464 off = 0; 1491 off = 0;
1465 entry_offset = (void *)e - (void *)base; 1492 entry_offset = (void *)e - (void *)base;
@@ -1470,15 +1497,13 @@ check_compat_entry_size_and_hooks(struct ipt_entry *e,
1470 goto cleanup_matches; 1497 goto cleanup_matches;
1471 1498
1472 t = ipt_get_target(e); 1499 t = ipt_get_target(e);
1473 ret = -EINVAL;
1474 if (e->target_offset + t->u.target_size > e->next_offset)
1475 goto cleanup_matches;
1476 target = try_then_request_module(xt_find_target(AF_INET, 1500 target = try_then_request_module(xt_find_target(AF_INET,
1477 t->u.user.name, 1501 t->u.user.name,
1478 t->u.user.revision), 1502 t->u.user.revision),
1479 "ipt_%s", t->u.user.name); 1503 "ipt_%s", t->u.user.name);
1480 if (IS_ERR(target) || !target) { 1504 if (IS_ERR(target) || !target) {
1481 duprintf("check_entry: `%s' not found\n", t->u.user.name); 1505 duprintf("check_compat_entry_size_and_hooks: `%s' not found\n",
1506 t->u.user.name);
1482 ret = target ? PTR_ERR(target) : -ENOENT; 1507 ret = target ? PTR_ERR(target) : -ENOENT;
1483 goto cleanup_matches; 1508 goto cleanup_matches;
1484 } 1509 }
@@ -1555,57 +1580,15 @@ static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
1555 return ret; 1580 return ret;
1556} 1581}
1557 1582
1558static inline int compat_check_match(struct ipt_entry_match *m, const char *name,
1559 const struct ipt_ip *ip, unsigned int hookmask)
1560{
1561 struct ipt_match *match;
1562 int ret;
1563
1564 match = m->u.kernel.match;
1565 ret = xt_check_match(match, AF_INET, m->u.match_size - sizeof(*m),
1566 name, hookmask, ip->proto,
1567 ip->invflags & IPT_INV_PROTO);
1568 if (!ret && m->u.kernel.match->checkentry
1569 && !m->u.kernel.match->checkentry(name, ip, match, m->data,
1570 hookmask)) {
1571 duprintf("ip_tables: compat: check failed for `%s'.\n",
1572 m->u.kernel.match->name);
1573 ret = -EINVAL;
1574 }
1575 return ret;
1576}
1577
1578static inline int compat_check_target(struct ipt_entry *e, const char *name)
1579{
1580 struct ipt_entry_target *t;
1581 struct ipt_target *target;
1582 int ret;
1583
1584 t = ipt_get_target(e);
1585 target = t->u.kernel.target;
1586 ret = xt_check_target(target, AF_INET, t->u.target_size - sizeof(*t),
1587 name, e->comefrom, e->ip.proto,
1588 e->ip.invflags & IPT_INV_PROTO);
1589 if (!ret && t->u.kernel.target->checkentry
1590 && !t->u.kernel.target->checkentry(name, e, target,
1591 t->data, e->comefrom)) {
1592 duprintf("ip_tables: compat: check failed for `%s'.\n",
1593 t->u.kernel.target->name);
1594 ret = -EINVAL;
1595 }
1596 return ret;
1597}
1598
1599static inline int compat_check_entry(struct ipt_entry *e, const char *name) 1583static inline int compat_check_entry(struct ipt_entry *e, const char *name)
1600{ 1584{
1601 int ret; 1585 int ret;
1602 1586
1603 ret = IPT_MATCH_ITERATE(e, compat_check_match, name, &e->ip, 1587 ret = IPT_MATCH_ITERATE(e, check_match, name, &e->ip, e->comefrom);
1604 e->comefrom);
1605 if (ret) 1588 if (ret)
1606 return ret; 1589 return ret;
1607 1590
1608 return compat_check_target(e, name); 1591 return check_target(e, name);
1609} 1592}
1610 1593
1611static int 1594static int
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index fef56ae61abe..b1c11160b9de 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -447,6 +447,12 @@ checkentry(const char *tablename,
447 cipinfo->config = config; 447 cipinfo->config = config;
448 } 448 }
449 449
450 if (nf_ct_l3proto_try_module_get(target->family) < 0) {
451 printk(KERN_WARNING "can't load conntrack support for "
452 "proto=%d\n", target->family);
453 return 0;
454 }
455
450 return 1; 456 return 1;
451} 457}
452 458
@@ -460,6 +466,8 @@ static void destroy(const struct xt_target *target, void *targinfo)
460 clusterip_config_entry_put(cipinfo->config); 466 clusterip_config_entry_put(cipinfo->config);
461 467
462 clusterip_config_put(cipinfo->config); 468 clusterip_config_put(cipinfo->config);
469
470 nf_ct_l3proto_module_put(target->family);
463} 471}
464 472
465static struct ipt_target clusterip_tgt = { 473static struct ipt_target clusterip_tgt = {
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 090c690627e5..b67e0dd743be 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2364,8 +2364,9 @@ struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu)
2364 2364
2365EXPORT_SYMBOL(__tcp_get_md5sig_pool); 2365EXPORT_SYMBOL(__tcp_get_md5sig_pool);
2366 2366
2367void __tcp_put_md5sig_pool(void) { 2367void __tcp_put_md5sig_pool(void)
2368 __tcp_free_md5sig_pool(tcp_md5sig_pool); 2368{
2369 tcp_free_md5sig_pool();
2369} 2370}
2370 2371
2371EXPORT_SYMBOL(__tcp_put_md5sig_pool); 2372EXPORT_SYMBOL(__tcp_put_md5sig_pool);
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 1eafcfc95e81..352690e2ab82 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -978,12 +978,27 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
978 break; 978 break;
979 979
980 case IPV6_UNICAST_HOPS: 980 case IPV6_UNICAST_HOPS:
981 val = np->hop_limit;
982 break;
983
984 case IPV6_MULTICAST_HOPS: 981 case IPV6_MULTICAST_HOPS:
985 val = np->mcast_hops; 982 {
983 struct dst_entry *dst;
984
985 if (optname == IPV6_UNICAST_HOPS)
986 val = np->hop_limit;
987 else
988 val = np->mcast_hops;
989
990 dst = sk_dst_get(sk);
991 if (dst) {
992 if (val < 0)
993 val = dst_metric(dst, RTAX_HOPLIMIT);
994 if (val < 0)
995 val = ipv6_get_hoplimit(dst->dev);
996 dst_release(dst);
997 }
998 if (val < 0)
999 val = ipv6_devconf.hop_limit;
986 break; 1000 break;
1001 }
987 1002
988 case IPV6_MULTICAST_LOOP: 1003 case IPV6_MULTICAST_LOOP:
989 val = np->mc_loop; 1004 val = np->mc_loop;
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 4eec4b3988b8..99502c5da4c4 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -413,6 +413,7 @@ mark_source_chains(struct xt_table_info *newinfo,
413 unsigned int pos = newinfo->hook_entry[hook]; 413 unsigned int pos = newinfo->hook_entry[hook];
414 struct ip6t_entry *e 414 struct ip6t_entry *e
415 = (struct ip6t_entry *)(entry0 + pos); 415 = (struct ip6t_entry *)(entry0 + pos);
416 int visited = e->comefrom & (1 << hook);
416 417
417 if (!(valid_hooks & (1 << hook))) 418 if (!(valid_hooks & (1 << hook)))
418 continue; 419 continue;
@@ -433,11 +434,11 @@ mark_source_chains(struct xt_table_info *newinfo,
433 |= ((1 << hook) | (1 << NF_IP6_NUMHOOKS)); 434 |= ((1 << hook) | (1 << NF_IP6_NUMHOOKS));
434 435
435 /* Unconditional return/END. */ 436 /* Unconditional return/END. */
436 if (e->target_offset == sizeof(struct ip6t_entry) 437 if ((e->target_offset == sizeof(struct ip6t_entry)
437 && (strcmp(t->target.u.user.name, 438 && (strcmp(t->target.u.user.name,
438 IP6T_STANDARD_TARGET) == 0) 439 IP6T_STANDARD_TARGET) == 0)
439 && t->verdict < 0 440 && t->verdict < 0
440 && unconditional(&e->ipv6)) { 441 && unconditional(&e->ipv6)) || visited) {
441 unsigned int oldpos, size; 442 unsigned int oldpos, size;
442 443
443 if (t->verdict < -NF_MAX_VERDICT - 1) { 444 if (t->verdict < -NF_MAX_VERDICT - 1) {
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 9f80518aacbd..8c3d56871b50 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -494,7 +494,7 @@ do { \
494 goto out; \ 494 goto out; \
495 pn = fn->parent; \ 495 pn = fn->parent; \
496 if (FIB6_SUBTREE(pn) && FIB6_SUBTREE(pn) != fn) \ 496 if (FIB6_SUBTREE(pn) && FIB6_SUBTREE(pn) != fn) \
497 fn = fib6_lookup(pn->subtree, NULL, saddr); \ 497 fn = fib6_lookup(FIB6_SUBTREE(pn), NULL, saddr); \
498 else \ 498 else \
499 fn = pn; \ 499 fn = pn; \
500 if (fn->fn_flags & RTN_RTINFO) \ 500 if (fn->fn_flags & RTN_RTINFO) \
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index 3a66878a1829..1b853c34d301 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -1,5 +1,5 @@
1menu "Core Netfilter Configuration" 1menu "Core Netfilter Configuration"
2 depends on NET && NETFILTER 2 depends on NET && INET && NETFILTER
3 3
4config NETFILTER_NETLINK 4config NETFILTER_NETLINK
5 tristate "Netfilter netlink interface" 5 tristate "Netfilter netlink interface"
diff --git a/net/netfilter/xt_CONNMARK.c b/net/netfilter/xt_CONNMARK.c
index b5548239d412..0534bfa65cce 100644
--- a/net/netfilter/xt_CONNMARK.c
+++ b/net/netfilter/xt_CONNMARK.c
@@ -96,6 +96,11 @@ checkentry(const char *tablename,
96{ 96{
97 struct xt_connmark_target_info *matchinfo = targinfo; 97 struct xt_connmark_target_info *matchinfo = targinfo;
98 98
99 if (nf_ct_l3proto_try_module_get(target->family) < 0) {
100 printk(KERN_WARNING "can't load conntrack support for "
101 "proto=%d\n", target->family);
102 return 0;
103 }
99 if (matchinfo->mode == XT_CONNMARK_RESTORE) { 104 if (matchinfo->mode == XT_CONNMARK_RESTORE) {
100 if (strcmp(tablename, "mangle") != 0) { 105 if (strcmp(tablename, "mangle") != 0) {
101 printk(KERN_WARNING "CONNMARK: restore can only be " 106 printk(KERN_WARNING "CONNMARK: restore can only be "
@@ -111,6 +116,12 @@ checkentry(const char *tablename,
111 return 1; 116 return 1;
112} 117}
113 118
119static void
120destroy(const struct xt_target *target, void *targinfo)
121{
122 nf_ct_l3proto_module_put(target->family);
123}
124
114#ifdef CONFIG_COMPAT 125#ifdef CONFIG_COMPAT
115struct compat_xt_connmark_target_info { 126struct compat_xt_connmark_target_info {
116 compat_ulong_t mark, mask; 127 compat_ulong_t mark, mask;
@@ -147,6 +158,7 @@ static struct xt_target xt_connmark_target[] = {
147 .name = "CONNMARK", 158 .name = "CONNMARK",
148 .family = AF_INET, 159 .family = AF_INET,
149 .checkentry = checkentry, 160 .checkentry = checkentry,
161 .destroy = destroy,
150 .target = target, 162 .target = target,
151 .targetsize = sizeof(struct xt_connmark_target_info), 163 .targetsize = sizeof(struct xt_connmark_target_info),
152#ifdef CONFIG_COMPAT 164#ifdef CONFIG_COMPAT
@@ -160,6 +172,7 @@ static struct xt_target xt_connmark_target[] = {
160 .name = "CONNMARK", 172 .name = "CONNMARK",
161 .family = AF_INET6, 173 .family = AF_INET6,
162 .checkentry = checkentry, 174 .checkentry = checkentry,
175 .destroy = destroy,
163 .target = target, 176 .target = target,
164 .targetsize = sizeof(struct xt_connmark_target_info), 177 .targetsize = sizeof(struct xt_connmark_target_info),
165 .me = THIS_MODULE 178 .me = THIS_MODULE
@@ -168,7 +181,6 @@ static struct xt_target xt_connmark_target[] = {
168 181
169static int __init xt_connmark_init(void) 182static int __init xt_connmark_init(void)
170{ 183{
171 need_conntrack();
172 return xt_register_targets(xt_connmark_target, 184 return xt_register_targets(xt_connmark_target,
173 ARRAY_SIZE(xt_connmark_target)); 185 ARRAY_SIZE(xt_connmark_target));
174} 186}
diff --git a/net/netfilter/xt_CONNSECMARK.c b/net/netfilter/xt_CONNSECMARK.c
index 467386266674..a3fe3c334b09 100644
--- a/net/netfilter/xt_CONNSECMARK.c
+++ b/net/netfilter/xt_CONNSECMARK.c
@@ -93,6 +93,11 @@ static int checkentry(const char *tablename, const void *entry,
93{ 93{
94 struct xt_connsecmark_target_info *info = targinfo; 94 struct xt_connsecmark_target_info *info = targinfo;
95 95
96 if (nf_ct_l3proto_try_module_get(target->family) < 0) {
97 printk(KERN_WARNING "can't load conntrack support for "
98 "proto=%d\n", target->family);
99 return 0;
100 }
96 switch (info->mode) { 101 switch (info->mode) {
97 case CONNSECMARK_SAVE: 102 case CONNSECMARK_SAVE:
98 case CONNSECMARK_RESTORE: 103 case CONNSECMARK_RESTORE:
@@ -106,11 +111,18 @@ static int checkentry(const char *tablename, const void *entry,
106 return 1; 111 return 1;
107} 112}
108 113
114static void
115destroy(const struct xt_target *target, void *targinfo)
116{
117 nf_ct_l3proto_module_put(target->family);
118}
119
109static struct xt_target xt_connsecmark_target[] = { 120static struct xt_target xt_connsecmark_target[] = {
110 { 121 {
111 .name = "CONNSECMARK", 122 .name = "CONNSECMARK",
112 .family = AF_INET, 123 .family = AF_INET,
113 .checkentry = checkentry, 124 .checkentry = checkentry,
125 .destroy = destroy,
114 .target = target, 126 .target = target,
115 .targetsize = sizeof(struct xt_connsecmark_target_info), 127 .targetsize = sizeof(struct xt_connsecmark_target_info),
116 .table = "mangle", 128 .table = "mangle",
@@ -120,6 +132,7 @@ static struct xt_target xt_connsecmark_target[] = {
120 .name = "CONNSECMARK", 132 .name = "CONNSECMARK",
121 .family = AF_INET6, 133 .family = AF_INET6,
122 .checkentry = checkentry, 134 .checkentry = checkentry,
135 .destroy = destroy,
123 .target = target, 136 .target = target,
124 .targetsize = sizeof(struct xt_connsecmark_target_info), 137 .targetsize = sizeof(struct xt_connsecmark_target_info),
125 .table = "mangle", 138 .table = "mangle",
@@ -129,7 +142,6 @@ static struct xt_target xt_connsecmark_target[] = {
129 142
130static int __init xt_connsecmark_init(void) 143static int __init xt_connsecmark_init(void)
131{ 144{
132 need_conntrack();
133 return xt_register_targets(xt_connsecmark_target, 145 return xt_register_targets(xt_connsecmark_target,
134 ARRAY_SIZE(xt_connsecmark_target)); 146 ARRAY_SIZE(xt_connsecmark_target));
135} 147}
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index dcc497ea8183..d93cb096a675 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -139,15 +139,28 @@ static int check(const char *tablename,
139 sinfo->direction != XT_CONNBYTES_DIR_BOTH) 139 sinfo->direction != XT_CONNBYTES_DIR_BOTH)
140 return 0; 140 return 0;
141 141
142 if (nf_ct_l3proto_try_module_get(match->family) < 0) {
143 printk(KERN_WARNING "can't load conntrack support for "
144 "proto=%d\n", match->family);
145 return 0;
146 }
147
142 return 1; 148 return 1;
143} 149}
144 150
151static void
152destroy(const struct xt_match *match, void *matchinfo)
153{
154 nf_ct_l3proto_module_put(match->family);
155}
156
145static struct xt_match xt_connbytes_match[] = { 157static struct xt_match xt_connbytes_match[] = {
146 { 158 {
147 .name = "connbytes", 159 .name = "connbytes",
148 .family = AF_INET, 160 .family = AF_INET,
149 .checkentry = check, 161 .checkentry = check,
150 .match = match, 162 .match = match,
163 .destroy = destroy,
151 .matchsize = sizeof(struct xt_connbytes_info), 164 .matchsize = sizeof(struct xt_connbytes_info),
152 .me = THIS_MODULE 165 .me = THIS_MODULE
153 }, 166 },
@@ -156,6 +169,7 @@ static struct xt_match xt_connbytes_match[] = {
156 .family = AF_INET6, 169 .family = AF_INET6,
157 .checkentry = check, 170 .checkentry = check,
158 .match = match, 171 .match = match,
172 .destroy = destroy,
159 .matchsize = sizeof(struct xt_connbytes_info), 173 .matchsize = sizeof(struct xt_connbytes_info),
160 .me = THIS_MODULE 174 .me = THIS_MODULE
161 }, 175 },
diff --git a/net/netfilter/xt_connmark.c b/net/netfilter/xt_connmark.c
index a8f03057dbde..36c2defff238 100644
--- a/net/netfilter/xt_connmark.c
+++ b/net/netfilter/xt_connmark.c
@@ -63,22 +63,18 @@ checkentry(const char *tablename,
63 printk(KERN_WARNING "connmark: only support 32bit mark\n"); 63 printk(KERN_WARNING "connmark: only support 32bit mark\n");
64 return 0; 64 return 0;
65 } 65 }
66#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
67 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 66 if (nf_ct_l3proto_try_module_get(match->family) < 0) {
68 printk(KERN_WARNING "can't load nf_conntrack support for " 67 printk(KERN_WARNING "can't load conntrack support for "
69 "proto=%d\n", match->family); 68 "proto=%d\n", match->family);
70 return 0; 69 return 0;
71 } 70 }
72#endif
73 return 1; 71 return 1;
74} 72}
75 73
76static void 74static void
77destroy(const struct xt_match *match, void *matchinfo) 75destroy(const struct xt_match *match, void *matchinfo)
78{ 76{
79#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
80 nf_ct_l3proto_module_put(match->family); 77 nf_ct_l3proto_module_put(match->family);
81#endif
82} 78}
83 79
84#ifdef CONFIG_COMPAT 80#ifdef CONFIG_COMPAT
@@ -140,7 +136,6 @@ static struct xt_match xt_connmark_match[] = {
140 136
141static int __init xt_connmark_init(void) 137static int __init xt_connmark_init(void)
142{ 138{
143 need_conntrack();
144 return xt_register_matches(xt_connmark_match, 139 return xt_register_matches(xt_connmark_match,
145 ARRAY_SIZE(xt_connmark_match)); 140 ARRAY_SIZE(xt_connmark_match));
146} 141}
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c
index 0ea501a2fda5..3dc2357b8de8 100644
--- a/net/netfilter/xt_conntrack.c
+++ b/net/netfilter/xt_conntrack.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/netfilter/x_tables.h> 21#include <linux/netfilter/x_tables.h>
22#include <linux/netfilter/xt_conntrack.h> 22#include <linux/netfilter/xt_conntrack.h>
23#include <net/netfilter/nf_conntrack_compat.h>
23 24
24MODULE_LICENSE("GPL"); 25MODULE_LICENSE("GPL");
25MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>"); 26MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
@@ -228,21 +229,17 @@ checkentry(const char *tablename,
228 void *matchinfo, 229 void *matchinfo,
229 unsigned int hook_mask) 230 unsigned int hook_mask)
230{ 231{
231#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
232 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 232 if (nf_ct_l3proto_try_module_get(match->family) < 0) {
233 printk(KERN_WARNING "can't load nf_conntrack support for " 233 printk(KERN_WARNING "can't load conntrack support for "
234 "proto=%d\n", match->family); 234 "proto=%d\n", match->family);
235 return 0; 235 return 0;
236 } 236 }
237#endif
238 return 1; 237 return 1;
239} 238}
240 239
241static void destroy(const struct xt_match *match, void *matchinfo) 240static void destroy(const struct xt_match *match, void *matchinfo)
242{ 241{
243#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
244 nf_ct_l3proto_module_put(match->family); 242 nf_ct_l3proto_module_put(match->family);
245#endif
246} 243}
247 244
248static struct xt_match conntrack_match = { 245static struct xt_match conntrack_match = {
@@ -257,7 +254,6 @@ static struct xt_match conntrack_match = {
257 254
258static int __init xt_conntrack_init(void) 255static int __init xt_conntrack_init(void)
259{ 256{
260 need_conntrack();
261 return xt_register_match(&conntrack_match); 257 return xt_register_match(&conntrack_match);
262} 258}
263 259
diff --git a/net/netfilter/xt_helper.c b/net/netfilter/xt_helper.c
index 5d7818b73e3a..04bc32ba7195 100644
--- a/net/netfilter/xt_helper.c
+++ b/net/netfilter/xt_helper.c
@@ -24,6 +24,7 @@
24#endif 24#endif
25#include <linux/netfilter/x_tables.h> 25#include <linux/netfilter/x_tables.h>
26#include <linux/netfilter/xt_helper.h> 26#include <linux/netfilter/xt_helper.h>
27#include <net/netfilter/nf_conntrack_compat.h>
27 28
28MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
29MODULE_AUTHOR("Martin Josefsson <gandalf@netfilter.org>"); 30MODULE_AUTHOR("Martin Josefsson <gandalf@netfilter.org>");
@@ -143,13 +144,11 @@ static int check(const char *tablename,
143{ 144{
144 struct xt_helper_info *info = matchinfo; 145 struct xt_helper_info *info = matchinfo;
145 146
146#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
147 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 147 if (nf_ct_l3proto_try_module_get(match->family) < 0) {
148 printk(KERN_WARNING "can't load nf_conntrack support for " 148 printk(KERN_WARNING "can't load conntrack support for "
149 "proto=%d\n", match->family); 149 "proto=%d\n", match->family);
150 return 0; 150 return 0;
151 } 151 }
152#endif
153 info->name[29] = '\0'; 152 info->name[29] = '\0';
154 return 1; 153 return 1;
155} 154}
@@ -157,9 +156,7 @@ static int check(const char *tablename,
157static void 156static void
158destroy(const struct xt_match *match, void *matchinfo) 157destroy(const struct xt_match *match, void *matchinfo)
159{ 158{
160#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
161 nf_ct_l3proto_module_put(match->family); 159 nf_ct_l3proto_module_put(match->family);
162#endif
163} 160}
164 161
165static struct xt_match xt_helper_match[] = { 162static struct xt_match xt_helper_match[] = {
@@ -185,7 +182,6 @@ static struct xt_match xt_helper_match[] = {
185 182
186static int __init xt_helper_init(void) 183static int __init xt_helper_init(void)
187{ 184{
188 need_conntrack();
189 return xt_register_matches(xt_helper_match, 185 return xt_register_matches(xt_helper_match,
190 ARRAY_SIZE(xt_helper_match)); 186 ARRAY_SIZE(xt_helper_match));
191} 187}
diff --git a/net/netfilter/xt_physdev.c b/net/netfilter/xt_physdev.c
index fd8f954cded5..b9b3ffc5451d 100644
--- a/net/netfilter/xt_physdev.c
+++ b/net/netfilter/xt_physdev.c
@@ -113,20 +113,16 @@ checkentry(const char *tablename,
113 if (!(info->bitmask & XT_PHYSDEV_OP_MASK) || 113 if (!(info->bitmask & XT_PHYSDEV_OP_MASK) ||
114 info->bitmask & ~XT_PHYSDEV_OP_MASK) 114 info->bitmask & ~XT_PHYSDEV_OP_MASK)
115 return 0; 115 return 0;
116 if (brnf_deferred_hooks == 0 && 116 if (info->bitmask & XT_PHYSDEV_OP_OUT &&
117 info->bitmask & XT_PHYSDEV_OP_OUT &&
118 (!(info->bitmask & XT_PHYSDEV_OP_BRIDGED) || 117 (!(info->bitmask & XT_PHYSDEV_OP_BRIDGED) ||
119 info->invert & XT_PHYSDEV_OP_BRIDGED) && 118 info->invert & XT_PHYSDEV_OP_BRIDGED) &&
120 hook_mask & ((1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) | 119 hook_mask & ((1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) |
121 (1 << NF_IP_POST_ROUTING))) { 120 (1 << NF_IP_POST_ROUTING))) {
122 printk(KERN_WARNING "physdev match: using --physdev-out in the " 121 printk(KERN_WARNING "physdev match: using --physdev-out in the "
123 "OUTPUT, FORWARD and POSTROUTING chains for non-bridged " 122 "OUTPUT, FORWARD and POSTROUTING chains for non-bridged "
124 "traffic is deprecated and breaks other things, it will " 123 "traffic is not supported anymore.\n");
125 "be removed in January 2007. See Documentation/" 124 if (hook_mask & (1 << NF_IP_LOCAL_OUT))
126 "feature-removal-schedule.txt for details. This doesn't " 125 return 0;
127 "affect you in case you're using it for purely bridged "
128 "traffic.\n");
129 brnf_deferred_hooks = 1;
130 } 126 }
131 return 1; 127 return 1;
132} 128}
diff --git a/net/netfilter/xt_state.c b/net/netfilter/xt_state.c
index d9010b16a1f9..df37b912163a 100644
--- a/net/netfilter/xt_state.c
+++ b/net/netfilter/xt_state.c
@@ -50,22 +50,18 @@ static int check(const char *tablename,
50 void *matchinfo, 50 void *matchinfo,
51 unsigned int hook_mask) 51 unsigned int hook_mask)
52{ 52{
53#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
54 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 53 if (nf_ct_l3proto_try_module_get(match->family) < 0) {
55 printk(KERN_WARNING "can't load nf_conntrack support for " 54 printk(KERN_WARNING "can't load conntrack support for "
56 "proto=%d\n", match->family); 55 "proto=%d\n", match->family);
57 return 0; 56 return 0;
58 } 57 }
59#endif
60 return 1; 58 return 1;
61} 59}
62 60
63static void 61static void
64destroy(const struct xt_match *match, void *matchinfo) 62destroy(const struct xt_match *match, void *matchinfo)
65{ 63{
66#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
67 nf_ct_l3proto_module_put(match->family); 64 nf_ct_l3proto_module_put(match->family);
68#endif
69} 65}
70 66
71static struct xt_match xt_state_match[] = { 67static struct xt_match xt_state_match[] = {
@@ -91,7 +87,6 @@ static struct xt_match xt_state_match[] = {
91 87
92static int __init xt_state_init(void) 88static int __init xt_state_init(void)
93{ 89{
94 need_conntrack();
95 return xt_register_matches(xt_state_match, ARRAY_SIZE(xt_state_match)); 90 return xt_register_matches(xt_state_match, ARRAY_SIZE(xt_state_match));
96} 91}
97 92
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index ad0057db0f91..5db95caed0a3 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -298,6 +298,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
298 asoc->default_flags = sp->default_flags; 298 asoc->default_flags = sp->default_flags;
299 asoc->default_context = sp->default_context; 299 asoc->default_context = sp->default_context;
300 asoc->default_timetolive = sp->default_timetolive; 300 asoc->default_timetolive = sp->default_timetolive;
301 asoc->default_rcv_context = sp->default_rcv_context;
301 302
302 return asoc; 303 return asoc;
303 304
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 3c3e560087ca..d8d36dee5ab6 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -78,8 +78,44 @@
78 78
79#include <asm/uaccess.h> 79#include <asm/uaccess.h>
80 80
81/* Event handler for inet6 address addition/deletion events. */
82int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev,
83 void *ptr)
84{
85 struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr;
86 struct sctp_sockaddr_entry *addr;
87 struct list_head *pos, *temp;
88
89 switch (ev) {
90 case NETDEV_UP:
91 addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC);
92 if (addr) {
93 addr->a.v6.sin6_family = AF_INET6;
94 addr->a.v6.sin6_port = 0;
95 memcpy(&addr->a.v6.sin6_addr, &ifa->addr,
96 sizeof(struct in6_addr));
97 addr->a.v6.sin6_scope_id = ifa->idev->dev->ifindex;
98 list_add_tail(&addr->list, &sctp_local_addr_list);
99 }
100 break;
101 case NETDEV_DOWN:
102 list_for_each_safe(pos, temp, &sctp_local_addr_list) {
103 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
104 if (ipv6_addr_equal(&addr->a.v6.sin6_addr, &ifa->addr)) {
105 list_del(pos);
106 kfree(addr);
107 break;
108 }
109 }
110
111 break;
112 }
113
114 return NOTIFY_DONE;
115}
116
81static struct notifier_block sctp_inet6addr_notifier = { 117static struct notifier_block sctp_inet6addr_notifier = {
82 .notifier_call = sctp_inetaddr_event, 118 .notifier_call = sctp_inet6addr_event,
83}; 119};
84 120
85/* ICMP error handler. */ 121/* ICMP error handler. */
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index f2ba8615895b..3a3db56729ce 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -163,7 +163,7 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,
163/* Extract our IP addresses from the system and stash them in the 163/* Extract our IP addresses from the system and stash them in the
164 * protocol structure. 164 * protocol structure.
165 */ 165 */
166static void __sctp_get_local_addr_list(void) 166static void sctp_get_local_addr_list(void)
167{ 167{
168 struct net_device *dev; 168 struct net_device *dev;
169 struct list_head *pos; 169 struct list_head *pos;
@@ -179,17 +179,8 @@ static void __sctp_get_local_addr_list(void)
179 read_unlock(&dev_base_lock); 179 read_unlock(&dev_base_lock);
180} 180}
181 181
182static void sctp_get_local_addr_list(void)
183{
184 unsigned long flags;
185
186 sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags);
187 __sctp_get_local_addr_list();
188 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
189}
190
191/* Free the existing local addresses. */ 182/* Free the existing local addresses. */
192static void __sctp_free_local_addr_list(void) 183static void sctp_free_local_addr_list(void)
193{ 184{
194 struct sctp_sockaddr_entry *addr; 185 struct sctp_sockaddr_entry *addr;
195 struct list_head *pos, *temp; 186 struct list_head *pos, *temp;
@@ -201,27 +192,15 @@ static void __sctp_free_local_addr_list(void)
201 } 192 }
202} 193}
203 194
204/* Free the existing local addresses. */
205static void sctp_free_local_addr_list(void)
206{
207 unsigned long flags;
208
209 sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags);
210 __sctp_free_local_addr_list();
211 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
212}
213
214/* Copy the local addresses which are valid for 'scope' into 'bp'. */ 195/* Copy the local addresses which are valid for 'scope' into 'bp'. */
215int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope, 196int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope,
216 gfp_t gfp, int copy_flags) 197 gfp_t gfp, int copy_flags)
217{ 198{
218 struct sctp_sockaddr_entry *addr; 199 struct sctp_sockaddr_entry *addr;
219 int error = 0; 200 int error = 0;
220 struct list_head *pos; 201 struct list_head *pos, *temp;
221 unsigned long flags;
222 202
223 sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags); 203 list_for_each_safe(pos, temp, &sctp_local_addr_list) {
224 list_for_each(pos, &sctp_local_addr_list) {
225 addr = list_entry(pos, struct sctp_sockaddr_entry, list); 204 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
226 if (sctp_in_scope(&addr->a, scope)) { 205 if (sctp_in_scope(&addr->a, scope)) {
227 /* Now that the address is in scope, check to see if 206 /* Now that the address is in scope, check to see if
@@ -242,7 +221,6 @@ int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope,
242 } 221 }
243 222
244end_copy: 223end_copy:
245 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
246 return error; 224 return error;
247} 225}
248 226
@@ -622,18 +600,36 @@ static void sctp_v4_seq_dump_addr(struct seq_file *seq, union sctp_addr *addr)
622 seq_printf(seq, "%d.%d.%d.%d ", NIPQUAD(addr->v4.sin_addr)); 600 seq_printf(seq, "%d.%d.%d.%d ", NIPQUAD(addr->v4.sin_addr));
623} 601}
624 602
625/* Event handler for inet address addition/deletion events. 603/* Event handler for inet address addition/deletion events. */
626 * Basically, whenever there is an event, we re-build our local address list.
627 */
628int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev, 604int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
629 void *ptr) 605 void *ptr)
630{ 606{
631 unsigned long flags; 607 struct in_ifaddr *ifa = (struct in_ifaddr *)ptr;
608 struct sctp_sockaddr_entry *addr;
609 struct list_head *pos, *temp;
632 610
633 sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags); 611 switch (ev) {
634 __sctp_free_local_addr_list(); 612 case NETDEV_UP:
635 __sctp_get_local_addr_list(); 613 addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC);
636 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags); 614 if (addr) {
615 addr->a.v4.sin_family = AF_INET;
616 addr->a.v4.sin_port = 0;
617 addr->a.v4.sin_addr.s_addr = ifa->ifa_local;
618 list_add_tail(&addr->list, &sctp_local_addr_list);
619 }
620 break;
621 case NETDEV_DOWN:
622 list_for_each_safe(pos, temp, &sctp_local_addr_list) {
623 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
624 if (addr->a.v4.sin_addr.s_addr == ifa->ifa_local) {
625 list_del(pos);
626 kfree(addr);
627 break;
628 }
629 }
630
631 break;
632 }
637 633
638 return NOTIFY_DONE; 634 return NOTIFY_DONE;
639} 635}
@@ -1172,13 +1168,12 @@ SCTP_STATIC __init int sctp_init(void)
1172 1168
1173 /* Initialize the local address list. */ 1169 /* Initialize the local address list. */
1174 INIT_LIST_HEAD(&sctp_local_addr_list); 1170 INIT_LIST_HEAD(&sctp_local_addr_list);
1175 spin_lock_init(&sctp_local_addr_lock); 1171
1172 sctp_get_local_addr_list();
1176 1173
1177 /* Register notifier for inet address additions/deletions. */ 1174 /* Register notifier for inet address additions/deletions. */
1178 register_inetaddr_notifier(&sctp_inetaddr_notifier); 1175 register_inetaddr_notifier(&sctp_inetaddr_notifier);
1179 1176
1180 sctp_get_local_addr_list();
1181
1182 __unsafe(THIS_MODULE); 1177 __unsafe(THIS_MODULE);
1183 status = 0; 1178 status = 0;
1184out: 1179out:
@@ -1263,6 +1258,7 @@ module_exit(sctp_exit);
1263 * __stringify doesn't likes enums, so use IPPROTO_SCTP value (132) directly. 1258 * __stringify doesn't likes enums, so use IPPROTO_SCTP value (132) directly.
1264 */ 1259 */
1265MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-132"); 1260MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-132");
1261MODULE_ALIAS("net-pf-" __stringify(PF_INET6) "-proto-132");
1266MODULE_AUTHOR("Linux Kernel SCTP developers <lksctp-developers@lists.sourceforge.net>"); 1262MODULE_AUTHOR("Linux Kernel SCTP developers <lksctp-developers@lists.sourceforge.net>");
1267MODULE_DESCRIPTION("Support for the SCTP protocol (RFC2960)"); 1263MODULE_DESCRIPTION("Support for the SCTP protocol (RFC2960)");
1268MODULE_LICENSE("GPL"); 1264MODULE_LICENSE("GPL");
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 1e8132b8c4d9..bdd8bd428b64 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2746,6 +2746,46 @@ static int sctp_setsockopt_adaption_layer(struct sock *sk, char __user *optval,
2746 return 0; 2746 return 0;
2747} 2747}
2748 2748
2749/*
2750 * 7.1.29. Set or Get the default context (SCTP_CONTEXT)
2751 *
2752 * The context field in the sctp_sndrcvinfo structure is normally only
2753 * used when a failed message is retrieved holding the value that was
2754 * sent down on the actual send call. This option allows the setting of
2755 * a default context on an association basis that will be received on
2756 * reading messages from the peer. This is especially helpful in the
2757 * one-2-many model for an application to keep some reference to an
2758 * internal state machine that is processing messages on the
2759 * association. Note that the setting of this value only effects
2760 * received messages from the peer and does not effect the value that is
2761 * saved with outbound messages.
2762 */
2763static int sctp_setsockopt_context(struct sock *sk, char __user *optval,
2764 int optlen)
2765{
2766 struct sctp_assoc_value params;
2767 struct sctp_sock *sp;
2768 struct sctp_association *asoc;
2769
2770 if (optlen != sizeof(struct sctp_assoc_value))
2771 return -EINVAL;
2772 if (copy_from_user(&params, optval, optlen))
2773 return -EFAULT;
2774
2775 sp = sctp_sk(sk);
2776
2777 if (params.assoc_id != 0) {
2778 asoc = sctp_id2assoc(sk, params.assoc_id);
2779 if (!asoc)
2780 return -EINVAL;
2781 asoc->default_rcv_context = params.assoc_value;
2782 } else {
2783 sp->default_rcv_context = params.assoc_value;
2784 }
2785
2786 return 0;
2787}
2788
2749/* API 6.2 setsockopt(), getsockopt() 2789/* API 6.2 setsockopt(), getsockopt()
2750 * 2790 *
2751 * Applications use setsockopt() and getsockopt() to set or retrieve 2791 * Applications use setsockopt() and getsockopt() to set or retrieve
@@ -2857,6 +2897,9 @@ SCTP_STATIC int sctp_setsockopt(struct sock *sk, int level, int optname,
2857 case SCTP_ADAPTION_LAYER: 2897 case SCTP_ADAPTION_LAYER:
2858 retval = sctp_setsockopt_adaption_layer(sk, optval, optlen); 2898 retval = sctp_setsockopt_adaption_layer(sk, optval, optlen);
2859 break; 2899 break;
2900 case SCTP_CONTEXT:
2901 retval = sctp_setsockopt_context(sk, optval, optlen);
2902 break;
2860 2903
2861 default: 2904 default:
2862 retval = -ENOPROTOOPT; 2905 retval = -ENOPROTOOPT;
@@ -3016,6 +3059,8 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3016 sp->default_context = 0; 3059 sp->default_context = 0;
3017 sp->default_timetolive = 0; 3060 sp->default_timetolive = 0;
3018 3061
3062 sp->default_rcv_context = 0;
3063
3019 /* Initialize default setup parameters. These parameters 3064 /* Initialize default setup parameters. These parameters
3020 * can be modified with the SCTP_INITMSG socket option or 3065 * can be modified with the SCTP_INITMSG socket option or
3021 * overridden by the SCTP_INIT CMSG. 3066 * overridden by the SCTP_INIT CMSG.
@@ -3821,10 +3866,9 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
3821 sctp_assoc_t id; 3866 sctp_assoc_t id;
3822 struct sctp_bind_addr *bp; 3867 struct sctp_bind_addr *bp;
3823 struct sctp_association *asoc; 3868 struct sctp_association *asoc;
3824 struct list_head *pos; 3869 struct list_head *pos, *temp;
3825 struct sctp_sockaddr_entry *addr; 3870 struct sctp_sockaddr_entry *addr;
3826 rwlock_t *addr_lock; 3871 rwlock_t *addr_lock;
3827 unsigned long flags;
3828 int cnt = 0; 3872 int cnt = 0;
3829 3873
3830 if (len != sizeof(sctp_assoc_t)) 3874 if (len != sizeof(sctp_assoc_t))
@@ -3859,8 +3903,7 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
3859 addr = list_entry(bp->address_list.next, 3903 addr = list_entry(bp->address_list.next,
3860 struct sctp_sockaddr_entry, list); 3904 struct sctp_sockaddr_entry, list);
3861 if (sctp_is_any(&addr->a)) { 3905 if (sctp_is_any(&addr->a)) {
3862 sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags); 3906 list_for_each_safe(pos, temp, &sctp_local_addr_list) {
3863 list_for_each(pos, &sctp_local_addr_list) {
3864 addr = list_entry(pos, 3907 addr = list_entry(pos,
3865 struct sctp_sockaddr_entry, 3908 struct sctp_sockaddr_entry,
3866 list); 3909 list);
@@ -3869,8 +3912,6 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
3869 continue; 3912 continue;
3870 cnt++; 3913 cnt++;
3871 } 3914 }
3872 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock,
3873 flags);
3874 } else { 3915 } else {
3875 cnt = 1; 3916 cnt = 1;
3876 } 3917 }
@@ -3892,15 +3933,13 @@ done:
3892static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_addrs, 3933static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_addrs,
3893 void __user *to) 3934 void __user *to)
3894{ 3935{
3895 struct list_head *pos; 3936 struct list_head *pos, *next;
3896 struct sctp_sockaddr_entry *addr; 3937 struct sctp_sockaddr_entry *addr;
3897 unsigned long flags;
3898 union sctp_addr temp; 3938 union sctp_addr temp;
3899 int cnt = 0; 3939 int cnt = 0;
3900 int addrlen; 3940 int addrlen;
3901 3941
3902 sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags); 3942 list_for_each_safe(pos, next, &sctp_local_addr_list) {
3903 list_for_each(pos, &sctp_local_addr_list) {
3904 addr = list_entry(pos, struct sctp_sockaddr_entry, list); 3943 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
3905 if ((PF_INET == sk->sk_family) && 3944 if ((PF_INET == sk->sk_family) &&
3906 (AF_INET6 == addr->a.sa.sa_family)) 3945 (AF_INET6 == addr->a.sa.sa_family))
@@ -3909,16 +3948,13 @@ static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_add
3909 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), 3948 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
3910 &temp); 3949 &temp);
3911 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; 3950 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
3912 if (copy_to_user(to, &temp, addrlen)) { 3951 if (copy_to_user(to, &temp, addrlen))
3913 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock,
3914 flags);
3915 return -EFAULT; 3952 return -EFAULT;
3916 } 3953
3917 to += addrlen; 3954 to += addrlen;
3918 cnt ++; 3955 cnt ++;
3919 if (cnt >= max_addrs) break; 3956 if (cnt >= max_addrs) break;
3920 } 3957 }
3921 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
3922 3958
3923 return cnt; 3959 return cnt;
3924} 3960}
@@ -3926,15 +3962,13 @@ static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_add
3926static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port, 3962static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port,
3927 void __user **to, size_t space_left) 3963 void __user **to, size_t space_left)
3928{ 3964{
3929 struct list_head *pos; 3965 struct list_head *pos, *next;
3930 struct sctp_sockaddr_entry *addr; 3966 struct sctp_sockaddr_entry *addr;
3931 unsigned long flags;
3932 union sctp_addr temp; 3967 union sctp_addr temp;
3933 int cnt = 0; 3968 int cnt = 0;
3934 int addrlen; 3969 int addrlen;
3935 3970
3936 sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags); 3971 list_for_each_safe(pos, next, &sctp_local_addr_list) {
3937 list_for_each(pos, &sctp_local_addr_list) {
3938 addr = list_entry(pos, struct sctp_sockaddr_entry, list); 3972 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
3939 if ((PF_INET == sk->sk_family) && 3973 if ((PF_INET == sk->sk_family) &&
3940 (AF_INET6 == addr->a.sa.sa_family)) 3974 (AF_INET6 == addr->a.sa.sa_family))
@@ -3945,16 +3979,13 @@ static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port,
3945 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; 3979 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
3946 if(space_left<addrlen) 3980 if(space_left<addrlen)
3947 return -ENOMEM; 3981 return -ENOMEM;
3948 if (copy_to_user(*to, &temp, addrlen)) { 3982 if (copy_to_user(*to, &temp, addrlen))
3949 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock,
3950 flags);
3951 return -EFAULT; 3983 return -EFAULT;
3952 } 3984
3953 *to += addrlen; 3985 *to += addrlen;
3954 cnt ++; 3986 cnt ++;
3955 space_left -= addrlen; 3987 space_left -= addrlen;
3956 } 3988 }
3957 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
3958 3989
3959 return cnt; 3990 return cnt;
3960} 3991}
@@ -4435,6 +4466,42 @@ static int sctp_getsockopt_mappedv4(struct sock *sk, int len,
4435} 4466}
4436 4467
4437/* 4468/*
4469 * 7.1.29. Set or Get the default context (SCTP_CONTEXT)
4470 * (chapter and verse is quoted at sctp_setsockopt_context())
4471 */
4472static int sctp_getsockopt_context(struct sock *sk, int len,
4473 char __user *optval, int __user *optlen)
4474{
4475 struct sctp_assoc_value params;
4476 struct sctp_sock *sp;
4477 struct sctp_association *asoc;
4478
4479 if (len != sizeof(struct sctp_assoc_value))
4480 return -EINVAL;
4481
4482 if (copy_from_user(&params, optval, len))
4483 return -EFAULT;
4484
4485 sp = sctp_sk(sk);
4486
4487 if (params.assoc_id != 0) {
4488 asoc = sctp_id2assoc(sk, params.assoc_id);
4489 if (!asoc)
4490 return -EINVAL;
4491 params.assoc_value = asoc->default_rcv_context;
4492 } else {
4493 params.assoc_value = sp->default_rcv_context;
4494 }
4495
4496 if (put_user(len, optlen))
4497 return -EFAULT;
4498 if (copy_to_user(optval, &params, len))
4499 return -EFAULT;
4500
4501 return 0;
4502}
4503
4504/*
4438 * 7.1.17 Set the maximum fragrmentation size (SCTP_MAXSEG) 4505 * 7.1.17 Set the maximum fragrmentation size (SCTP_MAXSEG)
4439 * 4506 *
4440 * This socket option specifies the maximum size to put in any outgoing 4507 * This socket option specifies the maximum size to put in any outgoing
@@ -4572,6 +4639,9 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname,
4572 retval = sctp_getsockopt_adaption_layer(sk, len, optval, 4639 retval = sctp_getsockopt_adaption_layer(sk, len, optval,
4573 optlen); 4640 optlen);
4574 break; 4641 break;
4642 case SCTP_CONTEXT:
4643 retval = sctp_getsockopt_context(sk, len, optval, optlen);
4644 break;
4575 default: 4645 default:
4576 retval = -ENOPROTOOPT; 4646 retval = -ENOPROTOOPT;
4577 break; 4647 break;
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index e255a709f1b7..93ac63b055ba 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -849,8 +849,10 @@ void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
849 */ 849 */
850 sinfo.sinfo_assoc_id = sctp_assoc2id(event->asoc); 850 sinfo.sinfo_assoc_id = sctp_assoc2id(event->asoc);
851 851
852 /* context value that is set via SCTP_CONTEXT socket option. */
853 sinfo.sinfo_context = event->asoc->default_rcv_context;
854
852 /* These fields are not used while receiving. */ 855 /* These fields are not used while receiving. */
853 sinfo.sinfo_context = 0;
854 sinfo.sinfo_timetolive = 0; 856 sinfo.sinfo_timetolive = 0;
855 857
856 put_cmsg(msghdr, IPPROTO_SCTP, SCTP_SNDRCV, 858 put_cmsg(msghdr, IPPROTO_SCTP, SCTP_SNDRCV,
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 700353b330fd..066c64a97fd8 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -804,19 +804,19 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
804 804
805 integ_len = svc_getnl(&buf->head[0]); 805 integ_len = svc_getnl(&buf->head[0]);
806 if (integ_len & 3) 806 if (integ_len & 3)
807 goto out; 807 return stat;
808 if (integ_len > buf->len) 808 if (integ_len > buf->len)
809 goto out; 809 return stat;
810 if (xdr_buf_subsegment(buf, &integ_buf, 0, integ_len)) 810 if (xdr_buf_subsegment(buf, &integ_buf, 0, integ_len))
811 BUG(); 811 BUG();
812 /* copy out mic... */ 812 /* copy out mic... */
813 if (read_u32_from_xdr_buf(buf, integ_len, &mic.len)) 813 if (read_u32_from_xdr_buf(buf, integ_len, &mic.len))
814 BUG(); 814 BUG();
815 if (mic.len > RPC_MAX_AUTH_SIZE) 815 if (mic.len > RPC_MAX_AUTH_SIZE)
816 goto out; 816 return stat;
817 mic.data = kmalloc(mic.len, GFP_KERNEL); 817 mic.data = kmalloc(mic.len, GFP_KERNEL);
818 if (!mic.data) 818 if (!mic.data)
819 goto out; 819 return stat;
820 if (read_bytes_from_xdr_buf(buf, integ_len + 4, mic.data, mic.len)) 820 if (read_bytes_from_xdr_buf(buf, integ_len + 4, mic.data, mic.len))
821 goto out; 821 goto out;
822 maj_stat = gss_verify_mic(ctx, &integ_buf, &mic); 822 maj_stat = gss_verify_mic(ctx, &integ_buf, &mic);
@@ -826,6 +826,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
826 goto out; 826 goto out;
827 stat = 0; 827 stat = 0;
828out: 828out:
829 kfree(mic.data);
829 return stat; 830 return stat;
830} 831}
831 832
@@ -1065,7 +1066,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
1065 } 1066 }
1066 switch(cache_check(&rsi_cache, &rsip->h, &rqstp->rq_chandle)) { 1067 switch(cache_check(&rsi_cache, &rsip->h, &rqstp->rq_chandle)) {
1067 case -EAGAIN: 1068 case -EAGAIN:
1068 goto drop; 1069 case -ETIMEDOUT:
1069 case -ENOENT: 1070 case -ENOENT:
1070 goto drop; 1071 goto drop;
1071 case 0: 1072 case 0:
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 80aff0474572..14274490f92e 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -34,7 +34,7 @@
34 34
35#define RPCDBG_FACILITY RPCDBG_CACHE 35#define RPCDBG_FACILITY RPCDBG_CACHE
36 36
37static void cache_defer_req(struct cache_req *req, struct cache_head *item); 37static int cache_defer_req(struct cache_req *req, struct cache_head *item);
38static void cache_revisit_request(struct cache_head *item); 38static void cache_revisit_request(struct cache_head *item);
39 39
40static void cache_init(struct cache_head *h) 40static void cache_init(struct cache_head *h)
@@ -185,6 +185,7 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h);
185 * 185 *
186 * Returns 0 if the cache_head can be used, or cache_puts it and returns 186 * Returns 0 if the cache_head can be used, or cache_puts it and returns
187 * -EAGAIN if upcall is pending, 187 * -EAGAIN if upcall is pending,
188 * -ETIMEDOUT if upcall failed and should be retried,
188 * -ENOENT if cache entry was negative 189 * -ENOENT if cache entry was negative
189 */ 190 */
190int cache_check(struct cache_detail *detail, 191int cache_check(struct cache_detail *detail,
@@ -236,7 +237,8 @@ int cache_check(struct cache_detail *detail,
236 } 237 }
237 238
238 if (rv == -EAGAIN) 239 if (rv == -EAGAIN)
239 cache_defer_req(rqstp, h); 240 if (cache_defer_req(rqstp, h) != 0)
241 rv = -ETIMEDOUT;
240 242
241 if (rv) 243 if (rv)
242 cache_put(h, detail); 244 cache_put(h, detail);
@@ -523,14 +525,21 @@ static LIST_HEAD(cache_defer_list);
523static struct list_head cache_defer_hash[DFR_HASHSIZE]; 525static struct list_head cache_defer_hash[DFR_HASHSIZE];
524static int cache_defer_cnt; 526static int cache_defer_cnt;
525 527
526static void cache_defer_req(struct cache_req *req, struct cache_head *item) 528static int cache_defer_req(struct cache_req *req, struct cache_head *item)
527{ 529{
528 struct cache_deferred_req *dreq; 530 struct cache_deferred_req *dreq;
529 int hash = DFR_HASH(item); 531 int hash = DFR_HASH(item);
530 532
533 if (cache_defer_cnt >= DFR_MAX) {
534 /* too much in the cache, randomly drop this one,
535 * or continue and drop the oldest below
536 */
537 if (net_random()&1)
538 return -ETIMEDOUT;
539 }
531 dreq = req->defer(req); 540 dreq = req->defer(req);
532 if (dreq == NULL) 541 if (dreq == NULL)
533 return; 542 return -ETIMEDOUT;
534 543
535 dreq->item = item; 544 dreq->item = item;
536 dreq->recv_time = get_seconds(); 545 dreq->recv_time = get_seconds();
@@ -546,17 +555,8 @@ static void cache_defer_req(struct cache_req *req, struct cache_head *item)
546 /* it is in, now maybe clean up */ 555 /* it is in, now maybe clean up */
547 dreq = NULL; 556 dreq = NULL;
548 if (++cache_defer_cnt > DFR_MAX) { 557 if (++cache_defer_cnt > DFR_MAX) {
549 /* too much in the cache, randomly drop 558 dreq = list_entry(cache_defer_list.prev,
550 * first or last 559 struct cache_deferred_req, recent);
551 */
552 if (net_random()&1)
553 dreq = list_entry(cache_defer_list.next,
554 struct cache_deferred_req,
555 recent);
556 else
557 dreq = list_entry(cache_defer_list.prev,
558 struct cache_deferred_req,
559 recent);
560 list_del(&dreq->recent); 560 list_del(&dreq->recent);
561 list_del(&dreq->hash); 561 list_del(&dreq->hash);
562 cache_defer_cnt--; 562 cache_defer_cnt--;
@@ -571,6 +571,7 @@ static void cache_defer_req(struct cache_req *req, struct cache_head *item)
571 /* must have just been validated... */ 571 /* must have just been validated... */
572 cache_revisit_request(item); 572 cache_revisit_request(item);
573 } 573 }
574 return 0;
574} 575}
575 576
576static void cache_revisit_request(struct cache_head *item) 577static void cache_revisit_request(struct cache_head *item)
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index eb44ec929ca1..f3001f3626f6 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -308,7 +308,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
308 308
309 serv->sv_nrpools = npools; 309 serv->sv_nrpools = npools;
310 serv->sv_pools = 310 serv->sv_pools =
311 kcalloc(sizeof(struct svc_pool), serv->sv_nrpools, 311 kcalloc(serv->sv_nrpools, sizeof(struct svc_pool),
312 GFP_KERNEL); 312 GFP_KERNEL);
313 if (!serv->sv_pools) { 313 if (!serv->sv_pools) {
314 kfree(serv); 314 kfree(serv);
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index a0a953a430c2..0d1e8fb83b93 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -53,6 +53,10 @@ struct auth_domain *unix_domain_find(char *name)
53 return NULL; 53 return NULL;
54 kref_init(&new->h.ref); 54 kref_init(&new->h.ref);
55 new->h.name = kstrdup(name, GFP_KERNEL); 55 new->h.name = kstrdup(name, GFP_KERNEL);
56 if (new->h.name == NULL) {
57 kfree(new);
58 return NULL;
59 }
56 new->h.flavour = &svcauth_unix; 60 new->h.flavour = &svcauth_unix;
57 new->addr_changes = 0; 61 new->addr_changes = 0;
58 rv = auth_domain_lookup(name, &new->h); 62 rv = auth_domain_lookup(name, &new->h);
@@ -435,6 +439,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
435 default: 439 default:
436 BUG(); 440 BUG();
437 case -EAGAIN: 441 case -EAGAIN:
442 case -ETIMEDOUT:
438 return SVC_DROP; 443 return SVC_DROP;
439 case -ENOENT: 444 case -ENOENT:
440 return SVC_DENIED; 445 return SVC_DENIED;
diff --git a/net/tipc/config.c b/net/tipc/config.c
index 458a2c46cef3..baf55c459c8b 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -208,7 +208,7 @@ static void cfg_cmd_event(struct tipc_cmd_msg *msg,
208 208
209 if (mng.link_subscriptions > 64) 209 if (mng.link_subscriptions > 64)
210 break; 210 break;
211 sub = (struct subscr_data *)kmalloc(sizeof(*sub), 211 sub = kmalloc(sizeof(*sub),
212 GFP_ATOMIC); 212 GFP_ATOMIC);
213 if (sub == NULL) { 213 if (sub == NULL) {
214 warn("Memory squeeze; dropped remote link subscription\n"); 214 warn("Memory squeeze; dropped remote link subscription\n");
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 4dcb8867b5f4..124b341a18c0 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -600,7 +600,7 @@ int main(int ac, char **av)
600 input_mode = ask_silent; 600 input_mode = ask_silent;
601 valid_stdin = 1; 601 valid_stdin = 1;
602 } 602 }
603 } else if (sym_change_count) { 603 } else if (conf_get_changed()) {
604 name = getenv("KCONFIG_NOSILENTUPDATE"); 604 name = getenv("KCONFIG_NOSILENTUPDATE");
605 if (name && *name) { 605 if (name && *name) {
606 fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n")); 606 fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n"));
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 66b15ef02931..664fe29dacef 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -100,7 +100,7 @@ int conf_read_simple(const char *name, int def)
100 in = zconf_fopen(name); 100 in = zconf_fopen(name);
101 if (in) 101 if (in)
102 goto load; 102 goto load;
103 sym_change_count++; 103 sym_add_change_count(1);
104 if (!sym_defconfig_list) 104 if (!sym_defconfig_list)
105 return 1; 105 return 1;
106 106
@@ -312,7 +312,7 @@ int conf_read(const char *name)
312 struct expr *e; 312 struct expr *e;
313 int i, flags; 313 int i, flags;
314 314
315 sym_change_count = 0; 315 sym_set_change_count(0);
316 316
317 if (conf_read_simple(name, S_DEF_USER)) 317 if (conf_read_simple(name, S_DEF_USER))
318 return 1; 318 return 1;
@@ -364,7 +364,7 @@ int conf_read(const char *name)
364 sym->flags &= flags | ~SYMBOL_DEF_USER; 364 sym->flags &= flags | ~SYMBOL_DEF_USER;
365 } 365 }
366 366
367 sym_change_count += conf_warnings || conf_unsaved; 367 sym_add_change_count(conf_warnings || conf_unsaved);
368 368
369 return 0; 369 return 0;
370} 370}
@@ -432,7 +432,7 @@ int conf_write(const char *name)
432 use_timestamp ? "# " : "", 432 use_timestamp ? "# " : "",
433 use_timestamp ? ctime(&now) : ""); 433 use_timestamp ? ctime(&now) : "");
434 434
435 if (!sym_change_count) 435 if (!conf_get_changed())
436 sym_clear_all_valid(); 436 sym_clear_all_valid();
437 437
438 menu = rootmenu.list; 438 menu = rootmenu.list;
@@ -528,7 +528,7 @@ int conf_write(const char *name)
528 "# configuration written to %s\n" 528 "# configuration written to %s\n"
529 "#\n"), newname); 529 "#\n"), newname);
530 530
531 sym_change_count = 0; 531 sym_set_change_count(0);
532 532
533 return 0; 533 return 0;
534} 534}
@@ -765,3 +765,30 @@ int conf_write_autoconf(void)
765 765
766 return 0; 766 return 0;
767} 767}
768
769static int sym_change_count;
770static void (*conf_changed_callback)(void);
771
772void sym_set_change_count(int count)
773{
774 int _sym_change_count = sym_change_count;
775 sym_change_count = count;
776 if (conf_changed_callback &&
777 (bool)_sym_change_count != (bool)count)
778 conf_changed_callback();
779}
780
781void sym_add_change_count(int count)
782{
783 sym_set_change_count(count + sym_change_count);
784}
785
786bool conf_get_changed(void)
787{
788 return sym_change_count;
789}
790
791void conf_set_changed_callback(void (*fn)(void))
792{
793 conf_changed_callback = fn;
794}
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 7b0d3a93d5c0..61d8166166ef 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -38,8 +38,6 @@ static gboolean show_all = FALSE;
38static gboolean show_debug = FALSE; 38static gboolean show_debug = FALSE;
39static gboolean resizeable = FALSE; 39static gboolean resizeable = FALSE;
40 40
41static gboolean config_changed = FALSE;
42
43static char nohelp_text[] = 41static char nohelp_text[] =
44 N_("Sorry, no help available for this option yet.\n"); 42 N_("Sorry, no help available for this option yet.\n");
45 43
@@ -50,6 +48,8 @@ GtkWidget *text_w = NULL;
50GtkWidget *hpaned = NULL; 48GtkWidget *hpaned = NULL;
51GtkWidget *vpaned = NULL; 49GtkWidget *vpaned = NULL;
52GtkWidget *back_btn = NULL; 50GtkWidget *back_btn = NULL;
51GtkWidget *save_btn = NULL;
52GtkWidget *save_menu_item = NULL;
53 53
54GtkTextTag *tag1, *tag2; 54GtkTextTag *tag1, *tag2;
55GdkColor color; 55GdkColor color;
@@ -75,7 +75,7 @@ static void display_tree_part(void);
75static void update_tree(struct menu *src, GtkTreeIter * dst); 75static void update_tree(struct menu *src, GtkTreeIter * dst);
76static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row); 76static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row);
77static gchar **fill_row(struct menu *menu); 77static gchar **fill_row(struct menu *menu);
78 78static void conf_changed(void);
79 79
80/* Helping/Debugging Functions */ 80/* Helping/Debugging Functions */
81 81
@@ -224,6 +224,10 @@ void init_main_window(const gchar * glade_file)
224 gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget, 224 gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
225 show_value); 225 show_value);
226 226
227 save_btn = glade_xml_get_widget(xml, "button3");
228 save_menu_item = glade_xml_get_widget(xml, "save1");
229 conf_set_changed_callback(conf_changed);
230
227 style = gtk_widget_get_style(main_wnd); 231 style = gtk_widget_get_style(main_wnd);
228 widget = glade_xml_get_widget(xml, "toolbar1"); 232 widget = glade_xml_get_widget(xml, "toolbar1");
229 233
@@ -512,14 +516,14 @@ static void text_insert_msg(const char *title, const char *message)
512 516
513/* Main Windows Callbacks */ 517/* Main Windows Callbacks */
514 518
515void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data); 519void on_save_activate(GtkMenuItem * menuitem, gpointer user_data);
516gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event, 520gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
517 gpointer user_data) 521 gpointer user_data)
518{ 522{
519 GtkWidget *dialog, *label; 523 GtkWidget *dialog, *label;
520 gint result; 524 gint result;
521 525
522 if (config_changed == FALSE) 526 if (!conf_get_changed())
523 return FALSE; 527 return FALSE;
524 528
525 dialog = gtk_dialog_new_with_buttons(_("Warning !"), 529 dialog = gtk_dialog_new_with_buttons(_("Warning !"),
@@ -543,7 +547,7 @@ gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
543 result = gtk_dialog_run(GTK_DIALOG(dialog)); 547 result = gtk_dialog_run(GTK_DIALOG(dialog));
544 switch (result) { 548 switch (result) {
545 case GTK_RESPONSE_YES: 549 case GTK_RESPONSE_YES:
546 on_save1_activate(NULL, NULL); 550 on_save_activate(NULL, NULL);
547 return FALSE; 551 return FALSE;
548 case GTK_RESPONSE_NO: 552 case GTK_RESPONSE_NO:
549 return FALSE; 553 return FALSE;
@@ -621,12 +625,10 @@ void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
621} 625}
622 626
623 627
624void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data) 628void on_save_activate(GtkMenuItem * menuitem, gpointer user_data)
625{ 629{
626 if (conf_write(NULL)) 630 if (conf_write(NULL))
627 text_insert_msg(_("Error"), _("Unable to save configuration !")); 631 text_insert_msg(_("Error"), _("Unable to save configuration !"));
628
629 config_changed = FALSE;
630} 632}
631 633
632 634
@@ -819,12 +821,6 @@ void on_load_clicked(GtkButton * button, gpointer user_data)
819} 821}
820 822
821 823
822void on_save_clicked(GtkButton * button, gpointer user_data)
823{
824 on_save1_activate(NULL, user_data);
825}
826
827
828void on_single_clicked(GtkButton * button, gpointer user_data) 824void on_single_clicked(GtkButton * button, gpointer user_data)
829{ 825{
830 view_mode = SINGLE_VIEW; 826 view_mode = SINGLE_VIEW;
@@ -899,7 +895,6 @@ static void renderer_edited(GtkCellRendererText * cell,
899 895
900 sym_set_string_value(sym, new_def); 896 sym_set_string_value(sym, new_def);
901 897
902 config_changed = TRUE;
903 update_tree(&rootmenu, NULL); 898 update_tree(&rootmenu, NULL);
904 899
905 gtk_tree_path_free(path); 900 gtk_tree_path_free(path);
@@ -930,7 +925,6 @@ static void change_sym_value(struct menu *menu, gint col)
930 if (!sym_tristate_within_range(sym, newval)) 925 if (!sym_tristate_within_range(sym, newval))
931 newval = yes; 926 newval = yes;
932 sym_set_tristate_value(sym, newval); 927 sym_set_tristate_value(sym, newval);
933 config_changed = TRUE;
934 if (view_mode == FULL_VIEW) 928 if (view_mode == FULL_VIEW)
935 update_tree(&rootmenu, NULL); 929 update_tree(&rootmenu, NULL);
936 else if (view_mode == SPLIT_VIEW) { 930 else if (view_mode == SPLIT_VIEW) {
@@ -1633,3 +1627,10 @@ int main(int ac, char *av[])
1633 1627
1634 return 0; 1628 return 0;
1635} 1629}
1630
1631static void conf_changed(void)
1632{
1633 bool changed = conf_get_changed();
1634 gtk_widget_set_sensitive(save_btn, changed);
1635 gtk_widget_set_sensitive(save_menu_item, changed);
1636}
diff --git a/scripts/kconfig/gconf.glade b/scripts/kconfig/gconf.glade
index f8744ed64967..803233fdd6dd 100644
--- a/scripts/kconfig/gconf.glade
+++ b/scripts/kconfig/gconf.glade
@@ -70,7 +70,7 @@
70 <property name="tooltip" translatable="yes">Save the config in .config</property> 70 <property name="tooltip" translatable="yes">Save the config in .config</property>
71 <property name="label" translatable="yes">_Save</property> 71 <property name="label" translatable="yes">_Save</property>
72 <property name="use_underline">True</property> 72 <property name="use_underline">True</property>
73 <signal name="activate" handler="on_save1_activate"/> 73 <signal name="activate" handler="on_save_activate"/>
74 <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/> 74 <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
75 75
76 <child internal-child="image"> 76 <child internal-child="image">
@@ -380,7 +380,7 @@
380 <property name="visible_horizontal">True</property> 380 <property name="visible_horizontal">True</property>
381 <property name="visible_vertical">True</property> 381 <property name="visible_vertical">True</property>
382 <property name="is_important">False</property> 382 <property name="is_important">False</property>
383 <signal name="clicked" handler="on_save_clicked"/> 383 <signal name="clicked" handler="on_save_activate"/>
384 </widget> 384 </widget>
385 <packing> 385 <packing>
386 <property name="expand">False</property> 386 <property name="expand">False</property>
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 2628023a1fe1..9b2706a41548 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -65,6 +65,8 @@ char *zconf_curname(void);
65 65
66/* confdata.c */ 66/* confdata.c */
67char *conf_get_default_confname(void); 67char *conf_get_default_confname(void);
68void sym_set_change_count(int count);
69void sym_add_change_count(int count);
68 70
69/* kconfig_load.c */ 71/* kconfig_load.c */
70void kconfig_load(void); 72void kconfig_load(void);
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index a263746cfa7d..15030770d1ad 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -5,6 +5,8 @@ P(conf_read,int,(const char *name));
5P(conf_read_simple,int,(const char *name, int)); 5P(conf_read_simple,int,(const char *name, int));
6P(conf_write,int,(const char *name)); 6P(conf_write,int,(const char *name));
7P(conf_write_autoconf,int,(void)); 7P(conf_write_autoconf,int,(void));
8P(conf_get_changed,bool,(void));
9P(conf_set_changed_callback, void,(void (*fn)(void)));
8 10
9/* menu.c */ 11/* menu.c */
10P(rootmenu,struct menu,); 12P(rootmenu,struct menu,);
@@ -16,7 +18,6 @@ P(menu_get_parent_menu,struct menu *,(struct menu *menu));
16 18
17/* symbol.c */ 19/* symbol.c */
18P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); 20P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
19P(sym_change_count,int,);
20 21
21P(sym_lookup,struct symbol *,(const char *name, int isconst)); 22P(sym_lookup,struct symbol *,(const char *name, int isconst));
22P(sym_find,struct symbol *,(const char *name)); 23P(sym_find,struct symbol *,(const char *name));
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 08a4c7af93ea..3f9a1321b3e6 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -890,14 +890,19 @@ int main(int ac, char **av)
890 do { 890 do {
891 conf(&rootmenu); 891 conf(&rootmenu);
892 dialog_clear(); 892 dialog_clear();
893 res = dialog_yesno(NULL, 893 if (conf_get_changed())
894 _("Do you wish to save your " 894 res = dialog_yesno(NULL,
895 "new kernel configuration?\n" 895 _("Do you wish to save your "
896 "<ESC><ESC> to continue."), 896 "new kernel configuration?\n"
897 6, 60); 897 "<ESC><ESC> to continue."),
898 6, 60);
899 else
900 res = -1;
898 } while (res == KEY_ESC); 901 } while (res == KEY_ESC);
899 end_dialog(); 902 end_dialog();
900 if (res == 0) { 903
904 switch (res) {
905 case 0:
901 if (conf_write(NULL)) { 906 if (conf_write(NULL)) {
902 fprintf(stderr, _("\n\n" 907 fprintf(stderr, _("\n\n"
903 "Error during writing of the kernel configuration.\n" 908 "Error during writing of the kernel configuration.\n"
@@ -905,11 +910,13 @@ int main(int ac, char **av)
905 "\n\n")); 910 "\n\n"));
906 return 1; 911 return 1;
907 } 912 }
913 case -1:
908 printf(_("\n\n" 914 printf(_("\n\n"
909 "*** End of Linux kernel configuration.\n" 915 "*** End of Linux kernel configuration.\n"
910 "*** Execute 'make' to build the kernel or try 'make help'." 916 "*** Execute 'make' to build the kernel or try 'make help'."
911 "\n\n")); 917 "\n\n"));
912 } else { 918 break;
919 default:
913 fprintf(stderr, _("\n\n" 920 fprintf(stderr, _("\n\n"
914 "Your kernel configuration changes were NOT saved." 921 "Your kernel configuration changes were NOT saved."
915 "\n\n")); 922 "\n\n"));
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index f5628c57640b..0b2fcc417f59 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -38,6 +38,8 @@
38static QApplication *configApp; 38static QApplication *configApp;
39static ConfigSettings *configSettings; 39static ConfigSettings *configSettings;
40 40
41QAction *ConfigMainWindow::saveAction;
42
41static inline QString qgettext(const char* str) 43static inline QString qgettext(const char* str)
42{ 44{
43 return QString::fromLocal8Bit(gettext(str)); 45 return QString::fromLocal8Bit(gettext(str));
@@ -1306,8 +1308,11 @@ ConfigMainWindow::ConfigMainWindow(void)
1306 connect(quitAction, SIGNAL(activated()), SLOT(close())); 1308 connect(quitAction, SIGNAL(activated()), SLOT(close()));
1307 QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); 1309 QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this);
1308 connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); 1310 connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
1309 QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); 1311 saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this);
1310 connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); 1312 connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
1313 conf_set_changed_callback(conf_changed);
1314 // Set saveAction's initial state
1315 conf_changed();
1311 QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); 1316 QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this);
1312 connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); 1317 connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
1313 QAction *searchAction = new QAction("Search", "&Search", CTRL+Key_F, this); 1318 QAction *searchAction = new QAction("Search", "&Search", CTRL+Key_F, this);
@@ -1585,7 +1590,7 @@ void ConfigMainWindow::showFullView(void)
1585 */ 1590 */
1586void ConfigMainWindow::closeEvent(QCloseEvent* e) 1591void ConfigMainWindow::closeEvent(QCloseEvent* e)
1587{ 1592{
1588 if (!sym_change_count) { 1593 if (!conf_get_changed()) {
1589 e->accept(); 1594 e->accept();
1590 return; 1595 return;
1591 } 1596 }
@@ -1658,6 +1663,12 @@ void ConfigMainWindow::saveSettings(void)
1658 configSettings->writeSizes("/split2", split2->sizes()); 1663 configSettings->writeSizes("/split2", split2->sizes());
1659} 1664}
1660 1665
1666void ConfigMainWindow::conf_changed(void)
1667{
1668 if (saveAction)
1669 saveAction->setEnabled(conf_get_changed());
1670}
1671
1661void fixup_rootmenu(struct menu *menu) 1672void fixup_rootmenu(struct menu *menu)
1662{ 1673{
1663 struct menu *child; 1674 struct menu *child;
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index 6a9e3b14c227..6fc1c5f14425 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -297,6 +297,9 @@ protected:
297 297
298class ConfigMainWindow : public QMainWindow { 298class ConfigMainWindow : public QMainWindow {
299 Q_OBJECT 299 Q_OBJECT
300
301 static QAction *saveAction;
302 static void conf_changed(void);
300public: 303public:
301 ConfigMainWindow(void); 304 ConfigMainWindow(void);
302public slots: 305public slots:
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index ee225ced2ce4..8f06c474d800 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -30,7 +30,6 @@ struct symbol symbol_yes = {
30 .flags = SYMBOL_VALID, 30 .flags = SYMBOL_VALID,
31}; 31};
32 32
33int sym_change_count;
34struct symbol *sym_defconfig_list; 33struct symbol *sym_defconfig_list;
35struct symbol *modules_sym; 34struct symbol *modules_sym;
36tristate modules_val; 35tristate modules_val;
@@ -379,7 +378,7 @@ void sym_clear_all_valid(void)
379 378
380 for_all_symbols(i, sym) 379 for_all_symbols(i, sym)
381 sym->flags &= ~SYMBOL_VALID; 380 sym->flags &= ~SYMBOL_VALID;
382 sym_change_count++; 381 sym_add_change_count(1);
383 if (modules_sym) 382 if (modules_sym)
384 sym_calc_value(modules_sym); 383 sym_calc_value(modules_sym);
385} 384}
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index 2fb0a4fc61d0..d777fe85627f 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -2135,7 +2135,7 @@ void conf_parse(const char *name)
2135 sym_check_deps(sym); 2135 sym_check_deps(sym);
2136 } 2136 }
2137 2137
2138 sym_change_count = 1; 2138 sym_set_change_count(1);
2139} 2139}
2140 2140
2141const char *zconf_tokenname(int token) 2141const char *zconf_tokenname(int token)
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index ab44feb3c600..04a5864c03b1 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -504,7 +504,7 @@ void conf_parse(const char *name)
504 sym_check_deps(sym); 504 sym_check_deps(sym);
505 } 505 }
506 506
507 sym_change_count = 1; 507 sym_set_change_count(1);
508} 508}
509 509
510const char *zconf_tokenname(int token) 510const char *zconf_tokenname(int token)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index ac0a58222992..15ab5d02e80a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -997,6 +997,7 @@ static int exit_section_ref_ok(const char *name)
997 "__bug_table", /* used by powerpc for BUG() */ 997 "__bug_table", /* used by powerpc for BUG() */
998 ".exitcall.exit", 998 ".exitcall.exit",
999 ".eh_frame", 999 ".eh_frame",
1000 ".parainstructions",
1000 ".stab", 1001 ".stab",
1001 "__ex_table", 1002 "__ex_table",
1002 ".fixup", 1003 ".fixup",
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index f4c67042e3ac..3391f2a9b4d1 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -1023,7 +1023,7 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, struct snd_mix
1023 } 1023 }
1024 up_read(&mixer->card->controls_rwsem); 1024 up_read(&mixer->card->controls_rwsem);
1025 if (slot.present != 0) { 1025 if (slot.present != 0) {
1026 pslot = (struct slot *)kmalloc(sizeof(slot), GFP_KERNEL); 1026 pslot = kmalloc(sizeof(slot), GFP_KERNEL);
1027 if (! pslot) 1027 if (! pslot)
1028 return -ENOMEM; 1028 return -ENOMEM;
1029 *pslot = slot; 1029 *pslot = slot;
diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c
index 0ffa9970bf0f..7cf9913a47b2 100644
--- a/sound/oss/ad1848.c
+++ b/sound/oss/ad1848.c
@@ -1992,7 +1992,7 @@ int ad1848_init (char *name, struct resource *ports, int irq, int dma_playback,
1992 devc->audio_flags |= DMA_DUPLEX; 1992 devc->audio_flags |= DMA_DUPLEX;
1993 } 1993 }
1994 1994
1995 portc = (ad1848_port_info *) kmalloc(sizeof(ad1848_port_info), GFP_KERNEL); 1995 portc = kmalloc(sizeof(ad1848_port_info), GFP_KERNEL);
1996 if(portc==NULL) { 1996 if(portc==NULL) {
1997 release_region(devc->base, 4); 1997 release_region(devc->base, 4);
1998 return -1; 1998 return -1;
diff --git a/sound/oss/cs4232.c b/sound/oss/cs4232.c
index b6924c7f1484..de40e21bf279 100644
--- a/sound/oss/cs4232.c
+++ b/sound/oss/cs4232.c
@@ -408,7 +408,7 @@ static int __init cs4232_pnp_probe(struct pnp_dev *dev, const struct pnp_device_
408{ 408{
409 struct address_info *isapnpcfg; 409 struct address_info *isapnpcfg;
410 410
411 isapnpcfg=(struct address_info*)kmalloc(sizeof(*isapnpcfg),GFP_KERNEL); 411 isapnpcfg = kmalloc(sizeof(*isapnpcfg),GFP_KERNEL);
412 if (!isapnpcfg) 412 if (!isapnpcfg)
413 return -ENOMEM; 413 return -ENOMEM;
414 414
diff --git a/sound/oss/dmasound/tas3001c.c b/sound/oss/dmasound/tas3001c.c
index f227c9f688cc..2f21a3c00374 100644
--- a/sound/oss/dmasound/tas3001c.c
+++ b/sound/oss/dmasound/tas3001c.c
@@ -50,6 +50,7 @@ struct tas3001c_data_t {
50 int output_id; 50 int output_id;
51 int speaker_id; 51 int speaker_id;
52 struct tas_drce_t drce_state; 52 struct tas_drce_t drce_state;
53 struct work_struct change;
53}; 54};
54 55
55 56
@@ -667,14 +668,13 @@ tas3001c_update_device_parameters(struct tas3001c_data_t *self)
667} 668}
668 669
669static void 670static void
670tas3001c_device_change_handler(void *self) 671tas3001c_device_change_handler(struct work_struct *work)
671{ 672{
672 if (self) 673 struct tas3001c_data_t *self;
673 tas3001c_update_device_parameters(self); 674 self = container_of(work, struct tas3001c_data_t, change);
675 tas3001c_update_device_parameters(self);
674} 676}
675 677
676static struct work_struct device_change;
677
678static int 678static int
679tas3001c_output_device_change( struct tas3001c_data_t *self, 679tas3001c_output_device_change( struct tas3001c_data_t *self,
680 int device_id, 680 int device_id,
@@ -685,7 +685,7 @@ tas3001c_output_device_change( struct tas3001c_data_t *self,
685 self->output_id=output_id; 685 self->output_id=output_id;
686 self->speaker_id=speaker_id; 686 self->speaker_id=speaker_id;
687 687
688 schedule_work(&device_change); 688 schedule_work(&self->change);
689 return 0; 689 return 0;
690} 690}
691 691
@@ -823,7 +823,7 @@ tas3001c_init(struct i2c_client *client)
823 tas3001c_write_biquad_shadow(self, i, j, 823 tas3001c_write_biquad_shadow(self, i, j,
824 &tas3001c_eq_unity); 824 &tas3001c_eq_unity);
825 825
826 INIT_WORK(&device_change, tas3001c_device_change_handler, self); 826 INIT_WORK(&self->change, tas3001c_device_change_handler);
827 return 0; 827 return 0;
828} 828}
829 829
diff --git a/sound/oss/dmasound/tas3004.c b/sound/oss/dmasound/tas3004.c
index 82eaaca2db9a..af34fb39bc29 100644
--- a/sound/oss/dmasound/tas3004.c
+++ b/sound/oss/dmasound/tas3004.c
@@ -48,6 +48,7 @@ struct tas3004_data_t {
48 int output_id; 48 int output_id;
49 int speaker_id; 49 int speaker_id;
50 struct tas_drce_t drce_state; 50 struct tas_drce_t drce_state;
51 struct work_struct change;
51}; 52};
52 53
53#define MAKE_TIME(sec,usec) (((sec)<<12) + (50000+(usec/10)*(1<<12))/100000) 54#define MAKE_TIME(sec,usec) (((sec)<<12) + (50000+(usec/10)*(1<<12))/100000)
@@ -914,15 +915,13 @@ tas3004_update_device_parameters(struct tas3004_data_t *self)
914} 915}
915 916
916static void 917static void
917tas3004_device_change_handler(void *self) 918tas3004_device_change_handler(struct work_struct *work)
918{ 919{
919 if (!self) return; 920 struct tas3004_data_t *self;
920 921 self = container_of(work, struct tas3004_data_t, change);
921 tas3004_update_device_parameters((struct tas3004_data_t *)self); 922 tas3004_update_device_parameters(self);
922} 923}
923 924
924static struct work_struct device_change;
925
926static int 925static int
927tas3004_output_device_change( struct tas3004_data_t *self, 926tas3004_output_device_change( struct tas3004_data_t *self,
928 int device_id, 927 int device_id,
@@ -933,7 +932,7 @@ tas3004_output_device_change( struct tas3004_data_t *self,
933 self->output_id=output_id; 932 self->output_id=output_id;
934 self->speaker_id=speaker_id; 933 self->speaker_id=speaker_id;
935 934
936 schedule_work(&device_change); 935 schedule_work(&self->change);
937 936
938 return 0; 937 return 0;
939} 938}
@@ -1112,7 +1111,7 @@ tas3004_init(struct i2c_client *client)
1112 tas3004_write_register(self, TAS3004_REG_MCR2, &mcr2, WRITE_SHADOW); 1111 tas3004_write_register(self, TAS3004_REG_MCR2, &mcr2, WRITE_SHADOW);
1113 tas3004_write_register(self, TAS3004_REG_DRC, drce_init, WRITE_SHADOW); 1112 tas3004_write_register(self, TAS3004_REG_DRC, drce_init, WRITE_SHADOW);
1114 1113
1115 INIT_WORK(&device_change, tas3004_device_change_handler, self); 1114 INIT_WORK(&self->change, tas3004_device_change_handler);
1116 return 0; 1115 return 0;
1117} 1116}
1118 1117
diff --git a/sound/oss/emu10k1/audio.c b/sound/oss/emu10k1/audio.c
index 49f902f35c28..efcf589d7083 100644
--- a/sound/oss/emu10k1/audio.c
+++ b/sound/oss/emu10k1/audio.c
@@ -1139,7 +1139,7 @@ static int emu10k1_audio_open(struct inode *inode, struct file *file)
1139 1139
1140match: 1140match:
1141 1141
1142 wave_dev = (struct emu10k1_wavedevice *) kmalloc(sizeof(struct emu10k1_wavedevice), GFP_KERNEL); 1142 wave_dev = kmalloc(sizeof(struct emu10k1_wavedevice), GFP_KERNEL);
1143 1143
1144 if (wave_dev == NULL) { 1144 if (wave_dev == NULL) {
1145 ERROR(); 1145 ERROR();
@@ -1155,7 +1155,7 @@ match:
1155 /* Recording */ 1155 /* Recording */
1156 struct wiinst *wiinst; 1156 struct wiinst *wiinst;
1157 1157
1158 if ((wiinst = (struct wiinst *) kmalloc(sizeof(struct wiinst), GFP_KERNEL)) == NULL) { 1158 if ((wiinst = kmalloc(sizeof(struct wiinst), GFP_KERNEL)) == NULL) {
1159 ERROR(); 1159 ERROR();
1160 kfree(wave_dev); 1160 kfree(wave_dev);
1161 return -ENOMEM; 1161 return -ENOMEM;
@@ -1211,7 +1211,7 @@ match:
1211 struct woinst *woinst; 1211 struct woinst *woinst;
1212 int i; 1212 int i;
1213 1213
1214 if ((woinst = (struct woinst *) kmalloc(sizeof(struct woinst), GFP_KERNEL)) == NULL) { 1214 if ((woinst = kmalloc(sizeof(struct woinst), GFP_KERNEL)) == NULL) {
1215 ERROR(); 1215 ERROR();
1216 kfree(wave_dev); 1216 kfree(wave_dev);
1217 return -ENOMEM; 1217 return -ENOMEM;
diff --git a/sound/oss/emu10k1/cardmi.c b/sound/oss/emu10k1/cardmi.c
index 0545814cc67d..57674f8c8a2e 100644
--- a/sound/oss/emu10k1/cardmi.c
+++ b/sound/oss/emu10k1/cardmi.c
@@ -157,7 +157,7 @@ int emu10k1_mpuin_add_buffer(struct emu10k1_mpuin *card_mpuin, struct midi_hdr *
157 midihdr->flags |= MIDIBUF_INQUEUE; /* set */ 157 midihdr->flags |= MIDIBUF_INQUEUE; /* set */
158 midihdr->flags &= ~MIDIBUF_DONE; /* clear */ 158 midihdr->flags &= ~MIDIBUF_DONE; /* clear */
159 159
160 if ((midiq = (struct midi_queue *) kmalloc(sizeof(struct midi_queue), GFP_ATOMIC)) == NULL) { 160 if ((midiq = kmalloc(sizeof(struct midi_queue), GFP_ATOMIC)) == NULL) {
161 /* Message lost */ 161 /* Message lost */
162 return -1; 162 return -1;
163 } 163 }
diff --git a/sound/oss/emu10k1/cardmo.c b/sound/oss/emu10k1/cardmo.c
index 5938d31f9e21..a8cc75db3e45 100644
--- a/sound/oss/emu10k1/cardmo.c
+++ b/sound/oss/emu10k1/cardmo.c
@@ -117,7 +117,7 @@ int emu10k1_mpuout_add_buffer(struct emu10k1_card *card, struct midi_hdr *midihd
117 midihdr->flags |= MIDIBUF_INQUEUE; 117 midihdr->flags |= MIDIBUF_INQUEUE;
118 midihdr->flags &= ~MIDIBUF_DONE; 118 midihdr->flags &= ~MIDIBUF_DONE;
119 119
120 if ((midiq = (struct midi_queue *) kmalloc(sizeof(struct midi_queue), GFP_KERNEL)) == NULL) { 120 if ((midiq = kmalloc(sizeof(struct midi_queue), GFP_KERNEL)) == NULL) {
121 /* Message lost */ 121 /* Message lost */
122 return -1; 122 return -1;
123 } 123 }
diff --git a/sound/oss/emu10k1/midi.c b/sound/oss/emu10k1/midi.c
index 8ac77df86397..cca3dad2bdf4 100644
--- a/sound/oss/emu10k1/midi.c
+++ b/sound/oss/emu10k1/midi.c
@@ -58,7 +58,7 @@ static int midiin_add_buffer(struct emu10k1_mididevice *midi_dev, struct midi_hd
58{ 58{
59 struct midi_hdr *midihdr; 59 struct midi_hdr *midihdr;
60 60
61 if ((midihdr = (struct midi_hdr *) kmalloc(sizeof(struct midi_hdr), GFP_KERNEL)) == NULL) { 61 if ((midihdr = kmalloc(sizeof(struct midi_hdr), GFP_KERNEL)) == NULL) {
62 ERROR(); 62 ERROR();
63 return -EINVAL; 63 return -EINVAL;
64 } 64 }
@@ -128,7 +128,7 @@ match:
128 mutex_lock(&card->open_sem); 128 mutex_lock(&card->open_sem);
129 } 129 }
130 130
131 if ((midi_dev = (struct emu10k1_mididevice *) kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL) 131 if ((midi_dev = kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL)
132 return -EINVAL; 132 return -EINVAL;
133 133
134 midi_dev->card = card; 134 midi_dev->card = card;
@@ -328,7 +328,7 @@ static ssize_t emu10k1_midi_write(struct file *file, const char __user *buffer,
328 if (!access_ok(VERIFY_READ, buffer, count)) 328 if (!access_ok(VERIFY_READ, buffer, count))
329 return -EFAULT; 329 return -EFAULT;
330 330
331 if ((midihdr = (struct midi_hdr *) kmalloc(sizeof(struct midi_hdr), GFP_KERNEL)) == NULL) 331 if ((midihdr = kmalloc(sizeof(struct midi_hdr), GFP_KERNEL)) == NULL)
332 return -EINVAL; 332 return -EINVAL;
333 333
334 midihdr->bufferlength = count; 334 midihdr->bufferlength = count;
@@ -490,7 +490,7 @@ int emu10k1_seq_midi_open(int dev, int mode,
490 490
491 DPF(2, "emu10k1_seq_midi_open()\n"); 491 DPF(2, "emu10k1_seq_midi_open()\n");
492 492
493 if ((midi_dev = (struct emu10k1_mididevice *) kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL) 493 if ((midi_dev = kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL)
494 return -EINVAL; 494 return -EINVAL;
495 495
496 midi_dev->card = card; 496 midi_dev->card = card;
@@ -540,7 +540,7 @@ int emu10k1_seq_midi_out(int dev, unsigned char midi_byte)
540 540
541 card = midi_devs[dev]->devc; 541 card = midi_devs[dev]->devc;
542 542
543 if ((midihdr = (struct midi_hdr *) kmalloc(sizeof(struct midi_hdr), GFP_KERNEL)) == NULL) 543 if ((midihdr = kmalloc(sizeof(struct midi_hdr), GFP_KERNEL)) == NULL)
544 return -EINVAL; 544 return -EINVAL;
545 545
546 midihdr->bufferlength = 1; 546 midihdr->bufferlength = 1;
diff --git a/sound/oss/emu10k1/mixer.c b/sound/oss/emu10k1/mixer.c
index cbcaaa34189a..6419796c2ed7 100644
--- a/sound/oss/emu10k1/mixer.c
+++ b/sound/oss/emu10k1/mixer.c
@@ -194,7 +194,7 @@ static int emu10k1_private_mixer(struct emu10k1_card *card, unsigned int cmd, un
194 194
195 case SOUND_MIXER_PRIVATE3: 195 case SOUND_MIXER_PRIVATE3:
196 196
197 ctl = (struct mixer_private_ioctl *) kmalloc(sizeof(struct mixer_private_ioctl), GFP_KERNEL); 197 ctl = kmalloc(sizeof(struct mixer_private_ioctl), GFP_KERNEL);
198 if (ctl == NULL) 198 if (ctl == NULL)
199 return -ENOMEM; 199 return -ENOMEM;
200 200
diff --git a/sound/oss/hal2.c b/sound/oss/hal2.c
index 784bdd707055..d18286ccc14d 100644
--- a/sound/oss/hal2.c
+++ b/sound/oss/hal2.c
@@ -1435,7 +1435,7 @@ static int hal2_init_card(struct hal2_card **phal2, struct hpc3_regs *hpc3)
1435 int ret = 0; 1435 int ret = 0;
1436 struct hal2_card *hal2; 1436 struct hal2_card *hal2;
1437 1437
1438 hal2 = (struct hal2_card *) kmalloc(sizeof(struct hal2_card), GFP_KERNEL); 1438 hal2 = kmalloc(sizeof(struct hal2_card), GFP_KERNEL);
1439 if (!hal2) 1439 if (!hal2)
1440 return -ENOMEM; 1440 return -ENOMEM;
1441 memset(hal2, 0, sizeof(struct hal2_card)); 1441 memset(hal2, 0, sizeof(struct hal2_card));
diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c
index e96220541971..2796c0ef985f 100644
--- a/sound/oss/mpu401.c
+++ b/sound/oss/mpu401.c
@@ -1023,7 +1023,7 @@ int attach_mpu401(struct address_info *hw_config, struct module *owner)
1023 devc->capabilities |= MPU_CAP_INTLG; /* Supports intelligent mode */ 1023 devc->capabilities |= MPU_CAP_INTLG; /* Supports intelligent mode */
1024 1024
1025 1025
1026 mpu401_synth_operations[m] = (struct synth_operations *)kmalloc(sizeof(struct synth_operations), GFP_KERNEL); 1026 mpu401_synth_operations[m] = kmalloc(sizeof(struct synth_operations), GFP_KERNEL);
1027 1027
1028 if (mpu401_synth_operations[m] == NULL) 1028 if (mpu401_synth_operations[m] == NULL)
1029 { 1029 {
diff --git a/sound/oss/opl3.c b/sound/oss/opl3.c
index 4799bc77f987..2e8cfa5481f2 100644
--- a/sound/oss/opl3.c
+++ b/sound/oss/opl3.c
@@ -166,7 +166,7 @@ int opl3_detect(int ioaddr, int *osp)
166 return 0; 166 return 0;
167 } 167 }
168 168
169 devc = (struct opl_devinfo *)kmalloc(sizeof(*devc), GFP_KERNEL); 169 devc = kmalloc(sizeof(*devc), GFP_KERNEL);
170 170
171 if (devc == NULL) 171 if (devc == NULL)
172 { 172 {
diff --git a/sound/oss/sb_common.c b/sound/oss/sb_common.c
index 440537c72604..07cbacf63824 100644
--- a/sound/oss/sb_common.c
+++ b/sound/oss/sb_common.c
@@ -625,7 +625,7 @@ int sb_dsp_detect(struct address_info *hw_config, int pci, int pciio, struct sb_
625 */ 625 */
626 626
627 627
628 detected_devc = (sb_devc *)kmalloc(sizeof(sb_devc), GFP_KERNEL); 628 detected_devc = kmalloc(sizeof(sb_devc), GFP_KERNEL);
629 if (detected_devc == NULL) 629 if (detected_devc == NULL)
630 { 630 {
631 printk(KERN_ERR "sb: Can't allocate memory for device information\n"); 631 printk(KERN_ERR "sb: Can't allocate memory for device information\n");
diff --git a/sound/oss/sb_midi.c b/sound/oss/sb_midi.c
index 2e3bc045caba..8b796704e112 100644
--- a/sound/oss/sb_midi.c
+++ b/sound/oss/sb_midi.c
@@ -173,7 +173,7 @@ void sb_dsp_midi_init(sb_devc * devc, struct module *owner)
173 return; 173 return;
174 } 174 }
175 std_midi_synth.midi_dev = devc->my_mididev = dev; 175 std_midi_synth.midi_dev = devc->my_mididev = dev;
176 midi_devs[dev] = (struct midi_operations *)kmalloc(sizeof(struct midi_operations), GFP_KERNEL); 176 midi_devs[dev] = kmalloc(sizeof(struct midi_operations), GFP_KERNEL);
177 if (midi_devs[dev] == NULL) 177 if (midi_devs[dev] == NULL)
178 { 178 {
179 printk(KERN_WARNING "Sound Blaster: failed to allocate MIDI memory.\n"); 179 printk(KERN_WARNING "Sound Blaster: failed to allocate MIDI memory.\n");
@@ -189,7 +189,7 @@ void sb_dsp_midi_init(sb_devc * devc, struct module *owner)
189 midi_devs[dev]->devc = devc; 189 midi_devs[dev]->devc = devc;
190 190
191 191
192 midi_devs[dev]->converter = (struct synth_operations *)kmalloc(sizeof(struct synth_operations), GFP_KERNEL); 192 midi_devs[dev]->converter = kmalloc(sizeof(struct synth_operations), GFP_KERNEL);
193 if (midi_devs[dev]->converter == NULL) 193 if (midi_devs[dev]->converter == NULL)
194 { 194 {
195 printk(KERN_WARNING "Sound Blaster: failed to allocate MIDI memory.\n"); 195 printk(KERN_WARNING "Sound Blaster: failed to allocate MIDI memory.\n");
diff --git a/sound/oss/sb_mixer.c b/sound/oss/sb_mixer.c
index 238e2cf44b08..fad1a4f25ad6 100644
--- a/sound/oss/sb_mixer.c
+++ b/sound/oss/sb_mixer.c
@@ -734,7 +734,7 @@ int sb_mixer_init(sb_devc * devc, struct module *owner)
734 if (m == -1) 734 if (m == -1)
735 return 0; 735 return 0;
736 736
737 mixer_devs[m] = (struct mixer_operations *)kmalloc(sizeof(struct mixer_operations), GFP_KERNEL); 737 mixer_devs[m] = kmalloc(sizeof(struct mixer_operations), GFP_KERNEL);
738 if (mixer_devs[m] == NULL) 738 if (mixer_devs[m] == NULL)
739 { 739 {
740 printk(KERN_ERR "sb_mixer: Can't allocate memory\n"); 740 printk(KERN_ERR "sb_mixer: Can't allocate memory\n");
diff --git a/sound/oss/v_midi.c b/sound/oss/v_midi.c
index d952b2264da1..103940fd5b4f 100644
--- a/sound/oss/v_midi.c
+++ b/sound/oss/v_midi.c
@@ -183,7 +183,7 @@ static void __init attach_v_midi (struct address_info *hw_config)
183 return; 183 return;
184 } 184 }
185 185
186 m=(struct vmidi_memory *)kmalloc(sizeof(struct vmidi_memory), GFP_KERNEL); 186 m = kmalloc(sizeof(struct vmidi_memory), GFP_KERNEL);
187 if (m == NULL) 187 if (m == NULL)
188 { 188 {
189 printk(KERN_WARNING "Loopback MIDI: Failed to allocate memory\n"); 189 printk(KERN_WARNING "Loopback MIDI: Failed to allocate memory\n");
diff --git a/sound/oss/waveartist.c b/sound/oss/waveartist.c
index c5bf363d32c2..26a7c6af95bc 100644
--- a/sound/oss/waveartist.c
+++ b/sound/oss/waveartist.c
@@ -1267,7 +1267,7 @@ static int __init waveartist_init(wavnc_info *devc)
1267 conf_printf2(dev_name, devc->hw.io_base, devc->hw.irq, 1267 conf_printf2(dev_name, devc->hw.io_base, devc->hw.irq,
1268 devc->hw.dma, devc->hw.dma2); 1268 devc->hw.dma, devc->hw.dma2);
1269 1269
1270 portc = (wavnc_port_info *)kmalloc(sizeof(wavnc_port_info), GFP_KERNEL); 1270 portc = kmalloc(sizeof(wavnc_port_info), GFP_KERNEL);
1271 if (portc == NULL) 1271 if (portc == NULL)
1272 goto nomem; 1272 goto nomem;
1273 1273